1
0
Files
web/static/pkg/atmosphere/assets/index-BbOfbEG1.js
2025-11-20 19:50:28 +09:00

10327 lines
1.6 MiB

(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const r of a)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function t(a){const r={};return a.integrity&&(r.integrity=a.integrity),a.referrerPolicy&&(r.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?r.credentials="include":a.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(a){if(a.ep)return;a.ep=!0;const r=t(a);fetch(a.href,r)}})();function r1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var GO={exports:{}},s1={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var uz=Symbol.for("react.transitional.element"),hz=Symbol.for("react.fragment");function VO(n,e,t){var i=null;if(t!==void 0&&(i=""+t),e.key!==void 0&&(i=""+e.key),"key"in e){t={};for(var a in e)a!=="key"&&(t[a]=e[a])}else t=e;return e=t.ref,{$$typeof:uz,type:n,key:i,ref:e!==void 0?e:null,props:t}}s1.Fragment=hz;s1.jsx=VO;s1.jsxs=VO;GO.exports=s1;var Nt=GO.exports,kO={exports:{}},Wt={};/**
* @license React
* react.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var sM=Symbol.for("react.transitional.element"),fz=Symbol.for("react.portal"),dz=Symbol.for("react.fragment"),pz=Symbol.for("react.strict_mode"),mz=Symbol.for("react.profiler"),gz=Symbol.for("react.consumer"),vz=Symbol.for("react.context"),_z=Symbol.for("react.forward_ref"),xz=Symbol.for("react.suspense"),yz=Symbol.for("react.memo"),WO=Symbol.for("react.lazy"),Sz=Symbol.for("react.activity"),Ow=Symbol.iterator;function Tz(n){return n===null||typeof n!="object"?null:(n=Ow&&n[Ow]||n["@@iterator"],typeof n=="function"?n:null)}var XO={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},YO=Object.assign,qO={};function Ud(n,e,t){this.props=n,this.context=e,this.refs=qO,this.updater=t||XO}Ud.prototype.isReactComponent={};Ud.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};Ud.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function jO(){}jO.prototype=Ud.prototype;function oM(n,e,t){this.props=n,this.context=e,this.refs=qO,this.updater=t||XO}var lM=oM.prototype=new jO;lM.constructor=oM;YO(lM,Ud.prototype);lM.isPureReactComponent=!0;var Lw=Array.isArray;function n3(){}var ei={H:null,A:null,T:null,S:null},ZO=Object.prototype.hasOwnProperty;function cM(n,e,t){var i=t.ref;return{$$typeof:sM,type:n,key:e,ref:i!==void 0?i:null,props:t}}function Ez(n,e){return cM(n.type,e,n.props)}function uM(n){return typeof n=="object"&&n!==null&&n.$$typeof===sM}function Mz(n){var e={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(t){return e[t]})}var Iw=/\/+/g;function GS(n,e){return typeof n=="object"&&n!==null&&n.key!=null?Mz(""+n.key):e.toString(36)}function bz(n){switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:switch(typeof n.status=="string"?n.then(n3,n3):(n.status="pending",n.then(function(e){n.status==="pending"&&(n.status="fulfilled",n.value=e)},function(e){n.status==="pending"&&(n.status="rejected",n.reason=e)})),n.status){case"fulfilled":return n.value;case"rejected":throw n.reason}}throw n}function Mf(n,e,t,i,a){var r=typeof n;(r==="undefined"||r==="boolean")&&(n=null);var s=!1;if(n===null)s=!0;else switch(r){case"bigint":case"string":case"number":s=!0;break;case"object":switch(n.$$typeof){case sM:case fz:s=!0;break;case WO:return s=n._init,Mf(s(n._payload),e,t,i,a)}}if(s)return a=a(n),s=i===""?"."+GS(n,0):i,Lw(a)?(t="",s!=null&&(t=s.replace(Iw,"$&/")+"/"),Mf(a,e,t,"",function(h){return h})):a!=null&&(uM(a)&&(a=Ez(a,t+(a.key==null||n&&n.key===a.key?"":(""+a.key).replace(Iw,"$&/")+"/")+s)),e.push(a)),1;s=0;var o=i===""?".":i+":";if(Lw(n))for(var c=0;c<n.length;c++)i=n[c],r=o+GS(i,c),s+=Mf(i,e,t,r,a);else if(c=Tz(n),typeof c=="function")for(n=c.call(n),c=0;!(i=n.next()).done;)i=i.value,r=o+GS(i,c++),s+=Mf(i,e,t,r,a);else if(r==="object"){if(typeof n.then=="function")return Mf(bz(n),e,t,i,a);throw e=String(n),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return s}function wg(n,e,t){if(n==null)return n;var i=[],a=0;return Mf(n,i,"","",function(r){return e.call(t,r,a++)}),i}function Az(n){if(n._status===-1){var e=n._result;e=e(),e.then(function(t){(n._status===0||n._status===-1)&&(n._status=1,n._result=t)},function(t){(n._status===0||n._status===-1)&&(n._status=2,n._result=t)}),n._status===-1&&(n._status=0,n._result=e)}if(n._status===1)return n._result.default;throw n._result}var Uw=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Rz={map:wg,forEach:function(n,e,t){wg(n,function(){e.apply(this,arguments)},t)},count:function(n){var e=0;return wg(n,function(){e++}),e},toArray:function(n){return wg(n,function(e){return e})||[]},only:function(n){if(!uM(n))throw Error("React.Children.only expected to receive a single React element child.");return n}};Wt.Activity=Sz;Wt.Children=Rz;Wt.Component=Ud;Wt.Fragment=dz;Wt.Profiler=mz;Wt.PureComponent=oM;Wt.StrictMode=pz;Wt.Suspense=xz;Wt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ei;Wt.__COMPILER_RUNTIME={__proto__:null,c:function(n){return ei.H.useMemoCache(n)}};Wt.cache=function(n){return function(){return n.apply(null,arguments)}};Wt.cacheSignal=function(){return null};Wt.cloneElement=function(n,e,t){if(n==null)throw Error("The argument must be a React element, but you passed "+n+".");var i=YO({},n.props),a=n.key;if(e!=null)for(r in e.key!==void 0&&(a=""+e.key),e)!ZO.call(e,r)||r==="key"||r==="__self"||r==="__source"||r==="ref"&&e.ref===void 0||(i[r]=e[r]);var r=arguments.length-2;if(r===1)i.children=t;else if(1<r){for(var s=Array(r),o=0;o<r;o++)s[o]=arguments[o+2];i.children=s}return cM(n.type,a,i)};Wt.createContext=function(n){return n={$$typeof:vz,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null},n.Provider=n,n.Consumer={$$typeof:gz,_context:n},n};Wt.createElement=function(n,e,t){var i,a={},r=null;if(e!=null)for(i in e.key!==void 0&&(r=""+e.key),e)ZO.call(e,i)&&i!=="key"&&i!=="__self"&&i!=="__source"&&(a[i]=e[i]);var s=arguments.length-2;if(s===1)a.children=t;else if(1<s){for(var o=Array(s),c=0;c<s;c++)o[c]=arguments[c+2];a.children=o}if(n&&n.defaultProps)for(i in s=n.defaultProps,s)a[i]===void 0&&(a[i]=s[i]);return cM(n,r,a)};Wt.createRef=function(){return{current:null}};Wt.forwardRef=function(n){return{$$typeof:_z,render:n}};Wt.isValidElement=uM;Wt.lazy=function(n){return{$$typeof:WO,_payload:{_status:-1,_result:n},_init:Az}};Wt.memo=function(n,e){return{$$typeof:yz,type:n,compare:e===void 0?null:e}};Wt.startTransition=function(n){var e=ei.T,t={};ei.T=t;try{var i=n(),a=ei.S;a!==null&&a(t,i),typeof i=="object"&&i!==null&&typeof i.then=="function"&&i.then(n3,Uw)}catch(r){Uw(r)}finally{e!==null&&t.types!==null&&(e.types=t.types),ei.T=e}};Wt.unstable_useCacheRefresh=function(){return ei.H.useCacheRefresh()};Wt.use=function(n){return ei.H.use(n)};Wt.useActionState=function(n,e,t){return ei.H.useActionState(n,e,t)};Wt.useCallback=function(n,e){return ei.H.useCallback(n,e)};Wt.useContext=function(n){return ei.H.useContext(n)};Wt.useDebugValue=function(){};Wt.useDeferredValue=function(n,e){return ei.H.useDeferredValue(n,e)};Wt.useEffect=function(n,e){return ei.H.useEffect(n,e)};Wt.useEffectEvent=function(n){return ei.H.useEffectEvent(n)};Wt.useId=function(){return ei.H.useId()};Wt.useImperativeHandle=function(n,e,t){return ei.H.useImperativeHandle(n,e,t)};Wt.useInsertionEffect=function(n,e){return ei.H.useInsertionEffect(n,e)};Wt.useLayoutEffect=function(n,e){return ei.H.useLayoutEffect(n,e)};Wt.useMemo=function(n,e){return ei.H.useMemo(n,e)};Wt.useOptimistic=function(n,e){return ei.H.useOptimistic(n,e)};Wt.useReducer=function(n,e,t){return ei.H.useReducer(n,e,t)};Wt.useRef=function(n){return ei.H.useRef(n)};Wt.useState=function(n){return ei.H.useState(n)};Wt.useSyncExternalStore=function(n,e,t){return ei.H.useSyncExternalStore(n,e,t)};Wt.useTransition=function(){return ei.H.useTransition()};Wt.version="19.2.0";kO.exports=Wt;var be=kO.exports;const hM=r1(be);var KO={exports:{}},o1={},QO={exports:{}},JO={};/**
* @license React
* scheduler.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(n){function e(W,te){var K=W.length;W.push(te);e:for(;0<K;){var oe=K-1>>>1,ie=W[oe];if(0<a(ie,te))W[oe]=te,W[K]=ie,K=oe;else break e}}function t(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var te=W[0],K=W.pop();if(K!==te){W[0]=K;e:for(var oe=0,ie=W.length,Ce=ie>>>1;oe<Ce;){var Xe=2*(oe+1)-1,nt=W[Xe],tt=Xe+1,gt=W[tt];if(0>a(nt,K))tt<ie&&0>a(gt,nt)?(W[oe]=gt,W[tt]=K,oe=tt):(W[oe]=nt,W[Xe]=K,oe=Xe);else if(tt<ie&&0>a(gt,K))W[oe]=gt,W[tt]=K,oe=tt;else break e}}return te}function a(W,te){var K=W.sortIndex-te.sortIndex;return K!==0?K:W.id-te.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;n.unstable_now=function(){return r.now()}}else{var s=Date,o=s.now();n.unstable_now=function(){return s.now()-o}}var c=[],h=[],f=1,d=null,m=3,g=!1,x=!1,T=!1,S=!1,v=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function b(W){for(var te=t(h);te!==null;){if(te.callback===null)i(h);else if(te.startTime<=W)i(h),te.sortIndex=te.expirationTime,e(c,te);else break;te=t(h)}}function D(W){if(T=!1,b(W),!x)if(t(c)!==null)x=!0,C||(C=!0,j());else{var te=t(h);te!==null&&re(D,te.startTime-W)}}var C=!1,I=-1,P=5,O=-1;function R(){return S?!0:!(n.unstable_now()-O<P)}function B(){if(S=!1,C){var W=n.unstable_now();O=W;var te=!0;try{e:{x=!1,T&&(T=!1,y(I),I=-1),g=!0;var K=m;try{t:{for(b(W),d=t(c);d!==null&&!(d.expirationTime>W&&R());){var oe=d.callback;if(typeof oe=="function"){d.callback=null,m=d.priorityLevel;var ie=oe(d.expirationTime<=W);if(W=n.unstable_now(),typeof ie=="function"){d.callback=ie,b(W),te=!0;break t}d===t(c)&&i(c),b(W)}else i(c);d=t(c)}if(d!==null)te=!0;else{var Ce=t(h);Ce!==null&&re(D,Ce.startTime-W),te=!1}}break e}finally{d=null,m=K,g=!1}te=void 0}}finally{te?j():C=!1}}}var j;if(typeof E=="function")j=function(){E(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,se=ee.port2;ee.port1.onmessage=B,j=function(){se.postMessage(null)}}else j=function(){v(B,0)};function re(W,te){I=v(function(){W(n.unstable_now())},te)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(W){W.callback=null},n.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<W?Math.floor(1e3/W):5},n.unstable_getCurrentPriorityLevel=function(){return m},n.unstable_next=function(W){switch(m){case 1:case 2:case 3:var te=3;break;default:te=m}var K=m;m=te;try{return W()}finally{m=K}},n.unstable_requestPaint=function(){S=!0},n.unstable_runWithPriority=function(W,te){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var K=m;m=W;try{return te()}finally{m=K}},n.unstable_scheduleCallback=function(W,te,K){var oe=n.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?oe+K:oe):K=oe,W){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=K+ie,W={id:f++,callback:te,priorityLevel:W,startTime:K,expirationTime:ie,sortIndex:-1},K>oe?(W.sortIndex=K,e(h,W),t(c)===null&&W===t(h)&&(T?(y(I),I=-1):T=!0,re(D,K-oe))):(W.sortIndex=ie,e(c,W),x||g||(x=!0,C||(C=!0,j()))),W},n.unstable_shouldYield=R,n.unstable_wrapCallback=function(W){var te=m;return function(){var K=m;m=te;try{return W.apply(this,arguments)}finally{m=K}}}})(JO);QO.exports=JO;var wz=QO.exports,$O={exports:{}},Ua={};/**
* @license React
* react-dom.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Cz=be;function eL(n){var e="https://react.dev/errors/"+n;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+n+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function Ml(){}var Oa={d:{f:Ml,r:function(){throw Error(eL(522))},D:Ml,C:Ml,L:Ml,m:Ml,X:Ml,S:Ml,M:Ml},p:0,findDOMNode:null},Nz=Symbol.for("react.portal");function Dz(n,e,t){var i=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Nz,key:i==null?null:""+i,children:n,containerInfo:e,implementation:t}}var mm=Cz.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l1(n,e){if(n==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}Ua.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Oa;Ua.createPortal=function(n,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(eL(299));return Dz(n,e,null,t)};Ua.flushSync=function(n){var e=mm.T,t=Oa.p;try{if(mm.T=null,Oa.p=2,n)return n()}finally{mm.T=e,Oa.p=t,Oa.d.f()}};Ua.preconnect=function(n,e){typeof n=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,Oa.d.C(n,e))};Ua.prefetchDNS=function(n){typeof n=="string"&&Oa.d.D(n)};Ua.preinit=function(n,e){if(typeof n=="string"&&e&&typeof e.as=="string"){var t=e.as,i=l1(t,e.crossOrigin),a=typeof e.integrity=="string"?e.integrity:void 0,r=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;t==="style"?Oa.d.S(n,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:i,integrity:a,fetchPriority:r}):t==="script"&&Oa.d.X(n,{crossOrigin:i,integrity:a,fetchPriority:r,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};Ua.preinitModule=function(n,e){if(typeof n=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var t=l1(e.as,e.crossOrigin);Oa.d.M(n,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&Oa.d.M(n)};Ua.preload=function(n,e){if(typeof n=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var t=e.as,i=l1(t,e.crossOrigin);Oa.d.L(n,t,{crossOrigin:i,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};Ua.preloadModule=function(n,e){if(typeof n=="string")if(e){var t=l1(e.as,e.crossOrigin);Oa.d.m(n,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else Oa.d.m(n)};Ua.requestFormReset=function(n){Oa.d.r(n)};Ua.unstable_batchedUpdates=function(n,e){return n(e)};Ua.useFormState=function(n,e,t){return mm.H.useFormState(n,e,t)};Ua.useFormStatus=function(){return mm.H.useHostTransitionStatus()};Ua.version="19.2.0";function tL(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(tL)}catch(n){console.error(n)}}tL(),$O.exports=Ua;var Oz=$O.exports;/**
* @license React
* react-dom-client.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Hi=wz,nL=be,Lz=Oz;function Ue(n){var e="https://react.dev/errors/"+n;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+n+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function iL(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function _0(n){var e=n,t=n;if(n.alternate)for(;e.return;)e=e.return;else{n=e;do e=n,e.flags&4098&&(t=e.return),n=e.return;while(n)}return e.tag===3?t:null}function aL(n){if(n.tag===13){var e=n.memoizedState;if(e===null&&(n=n.alternate,n!==null&&(e=n.memoizedState)),e!==null)return e.dehydrated}return null}function rL(n){if(n.tag===31){var e=n.memoizedState;if(e===null&&(n=n.alternate,n!==null&&(e=n.memoizedState)),e!==null)return e.dehydrated}return null}function Pw(n){if(_0(n)!==n)throw Error(Ue(188))}function Iz(n){var e=n.alternate;if(!e){if(e=_0(n),e===null)throw Error(Ue(188));return e!==n?null:n}for(var t=n,i=e;;){var a=t.return;if(a===null)break;var r=a.alternate;if(r===null){if(i=a.return,i!==null){t=i;continue}break}if(a.child===r.child){for(r=a.child;r;){if(r===t)return Pw(a),n;if(r===i)return Pw(a),e;r=r.sibling}throw Error(Ue(188))}if(t.return!==i.return)t=a,i=r;else{for(var s=!1,o=a.child;o;){if(o===t){s=!0,t=a,i=r;break}if(o===i){s=!0,i=a,t=r;break}o=o.sibling}if(!s){for(o=r.child;o;){if(o===t){s=!0,t=r,i=a;break}if(o===i){s=!0,i=r,t=a;break}o=o.sibling}if(!s)throw Error(Ue(189))}}if(t.alternate!==i)throw Error(Ue(190))}if(t.tag!==3)throw Error(Ue(188));return t.stateNode.current===t?n:e}function sL(n){var e=n.tag;if(e===5||e===26||e===27||e===6)return n;for(n=n.child;n!==null;){if(e=sL(n),e!==null)return e;n=n.sibling}return null}var ti=Object.assign,Uz=Symbol.for("react.element"),Cg=Symbol.for("react.transitional.element"),nm=Symbol.for("react.portal"),Cf=Symbol.for("react.fragment"),oL=Symbol.for("react.strict_mode"),i3=Symbol.for("react.profiler"),lL=Symbol.for("react.consumer"),Xo=Symbol.for("react.context"),fM=Symbol.for("react.forward_ref"),a3=Symbol.for("react.suspense"),r3=Symbol.for("react.suspense_list"),dM=Symbol.for("react.memo"),zl=Symbol.for("react.lazy"),s3=Symbol.for("react.activity"),Pz=Symbol.for("react.memo_cache_sentinel"),zw=Symbol.iterator;function Mp(n){return n===null||typeof n!="object"?null:(n=zw&&n[zw]||n["@@iterator"],typeof n=="function"?n:null)}var zz=Symbol.for("react.client.reference");function o3(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===zz?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Cf:return"Fragment";case i3:return"Profiler";case oL:return"StrictMode";case a3:return"Suspense";case r3:return"SuspenseList";case s3:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case nm:return"Portal";case Xo:return n.displayName||"Context";case lL:return(n._context.displayName||"Context")+".Consumer";case fM:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case dM:return e=n.displayName||null,e!==null?e:o3(n.type)||"Memo";case zl:e=n._payload,n=n._init;try{return o3(n(e))}catch{}}return null}var im=Array.isArray,Ut=nL.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,yn=Lz.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ru={pending:!1,data:null,method:null,action:null},l3=[],Nf=-1;function oo(n){return{current:n}}function $i(n){0>Nf||(n.current=l3[Nf],l3[Nf]=null,Nf--)}function Yn(n,e){Nf++,l3[Nf]=n.current,n.current=e}var no=oo(null),km=oo(null),Jl=oo(null),T_=oo(null);function E_(n,e){switch(Yn(Jl,e),Yn(km,n),Yn(no,null),e.nodeType){case 9:case 11:n=(n=e.documentElement)&&(n=n.namespaceURI)?kC(n):0;break;default:if(n=e.tagName,e=e.namespaceURI)e=kC(e),n=wI(e,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}$i(no),Yn(no,n)}function sd(){$i(no),$i(km),$i(Jl)}function c3(n){n.memoizedState!==null&&Yn(T_,n);var e=no.current,t=wI(e,n.type);e!==t&&(Yn(km,n),Yn(no,t))}function M_(n){km.current===n&&($i(no),$i(km)),T_.current===n&&($i(T_),e0._currentValue=Ru)}var VS,Bw;function hu(n){if(VS===void 0)try{throw Error()}catch(t){var e=t.stack.trim().match(/\n( *(at )?)/);VS=e&&e[1]||"",Bw=-1<t.stack.indexOf(`
at`)?" (<anonymous>)":-1<t.stack.indexOf("@")?"@unknown:0:0":""}return`
`+VS+n+Bw}var kS=!1;function WS(n,e){if(!n||kS)return"";kS=!0;var t=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(e){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(g){var m=g}Reflect.construct(n,[],d)}else{try{d.call()}catch(g){m=g}n.call(d.prototype)}}else{try{throw Error()}catch(g){m=g}(d=n())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(g){if(g&&m&&typeof g.stack=="string")return[g.stack,m.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var r=i.DetermineComponentFrameRoot(),s=r[0],o=r[1];if(s&&o){var c=s.split(`
`),h=o.split(`
`);for(a=i=0;i<c.length&&!c[i].includes("DetermineComponentFrameRoot");)i++;for(;a<h.length&&!h[a].includes("DetermineComponentFrameRoot");)a++;if(i===c.length||a===h.length)for(i=c.length-1,a=h.length-1;1<=i&&0<=a&&c[i]!==h[a];)a--;for(;1<=i&&0<=a;i--,a--)if(c[i]!==h[a]){if(i!==1||a!==1)do if(i--,a--,0>a||c[i]!==h[a]){var f=`
`+c[i].replace(" at new "," at ");return n.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",n.displayName)),f}while(1<=i&&0<=a);break}}}finally{kS=!1,Error.prepareStackTrace=t}return(t=n?n.displayName||n.name:"")?hu(t):""}function Bz(n,e){switch(n.tag){case 26:case 27:case 5:return hu(n.type);case 16:return hu("Lazy");case 13:return n.child!==e&&e!==null?hu("Suspense Fallback"):hu("Suspense");case 19:return hu("SuspenseList");case 0:case 15:return WS(n.type,!1);case 11:return WS(n.type.render,!1);case 1:return WS(n.type,!0);case 31:return hu("Activity");default:return""}}function Hw(n){try{var e="",t=null;do e+=Bz(n,t),t=n,n=n.return;while(n);return e}catch(i){return`
Error generating stack: `+i.message+`
`+i.stack}}var u3=Object.prototype.hasOwnProperty,pM=Hi.unstable_scheduleCallback,XS=Hi.unstable_cancelCallback,Hz=Hi.unstable_shouldYield,Fz=Hi.unstable_requestPaint,br=Hi.unstable_now,Gz=Hi.unstable_getCurrentPriorityLevel,cL=Hi.unstable_ImmediatePriority,uL=Hi.unstable_UserBlockingPriority,b_=Hi.unstable_NormalPriority,Vz=Hi.unstable_LowPriority,hL=Hi.unstable_IdlePriority,kz=Hi.log,Wz=Hi.unstable_setDisableYieldValue,x0=null,Ar=null;function Wl(n){if(typeof kz=="function"&&Wz(n),Ar&&typeof Ar.setStrictMode=="function")try{Ar.setStrictMode(x0,n)}catch{}}var Rr=Math.clz32?Math.clz32:qz,Xz=Math.log,Yz=Math.LN2;function qz(n){return n>>>=0,n===0?32:31-(Xz(n)/Yz|0)|0}var Ng=256,Dg=262144,Og=4194304;function fu(n){var e=n&42;if(e!==0)return e;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function c1(n,e,t){var i=n.pendingLanes;if(i===0)return 0;var a=0,r=n.suspendedLanes,s=n.pingedLanes;n=n.warmLanes;var o=i&134217727;return o!==0?(i=o&~r,i!==0?a=fu(i):(s&=o,s!==0?a=fu(s):t||(t=o&~n,t!==0&&(a=fu(t))))):(o=i&~r,o!==0?a=fu(o):s!==0?a=fu(s):t||(t=i&~n,t!==0&&(a=fu(t)))),a===0?0:e!==0&&e!==a&&!(e&r)&&(r=a&-a,t=e&-e,r>=t||r===32&&(t&4194048)!==0)?e:a}function y0(n,e){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&e)===0}function jz(n,e){switch(n){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function fL(){var n=Og;return Og<<=1,!(Og&62914560)&&(Og=4194304),n}function YS(n){for(var e=[],t=0;31>t;t++)e.push(n);return e}function S0(n,e){n.pendingLanes|=e,e!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Zz(n,e,t,i,a,r){var s=n.pendingLanes;n.pendingLanes=t,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=t,n.entangledLanes&=t,n.errorRecoveryDisabledLanes&=t,n.shellSuspendCounter=0;var o=n.entanglements,c=n.expirationTimes,h=n.hiddenUpdates;for(t=s&~t;0<t;){var f=31-Rr(t),d=1<<f;o[f]=0,c[f]=-1;var m=h[f];if(m!==null)for(h[f]=null,f=0;f<m.length;f++){var g=m[f];g!==null&&(g.lane&=-536870913)}t&=~d}i!==0&&dL(n,i,0),r!==0&&a===0&&n.tag!==0&&(n.suspendedLanes|=r&~(s&~e))}function dL(n,e,t){n.pendingLanes|=e,n.suspendedLanes&=~e;var i=31-Rr(e);n.entangledLanes|=e,n.entanglements[i]=n.entanglements[i]|1073741824|t&261930}function pL(n,e){var t=n.entangledLanes|=e;for(n=n.entanglements;t;){var i=31-Rr(t),a=1<<i;a&e|n[i]&e&&(n[i]|=e),t&=~a}}function mL(n,e){var t=e&-e;return t=t&42?1:mM(t),t&(n.suspendedLanes|e)?0:t}function mM(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function gM(n){return n&=-n,2<n?8<n?n&134217727?32:268435456:8:2}function gL(){var n=yn.p;return n!==0?n:(n=window.event,n===void 0?32:HI(n.type))}function Fw(n,e){var t=yn.p;try{return yn.p=n,e()}finally{yn.p=t}}var _c=Math.random().toString(36).slice(2),sa="__reactFiber$"+_c,$a="__reactProps$"+_c,Pd="__reactContainer$"+_c,h3="__reactEvents$"+_c,Kz="__reactListeners$"+_c,Qz="__reactHandles$"+_c,Gw="__reactResources$"+_c,T0="__reactMarker$"+_c;function vM(n){delete n[sa],delete n[$a],delete n[h3],delete n[Kz],delete n[Qz]}function Df(n){var e=n[sa];if(e)return e;for(var t=n.parentNode;t;){if(e=t[Pd]||t[sa]){if(t=e.alternate,e.child!==null||t!==null&&t.child!==null)for(n=jC(n);n!==null;){if(t=n[sa])return t;n=jC(n)}return e}n=t,t=n.parentNode}return null}function zd(n){if(n=n[sa]||n[Pd]){var e=n.tag;if(e===5||e===6||e===13||e===31||e===26||e===27||e===3)return n}return null}function am(n){var e=n.tag;if(e===5||e===26||e===27||e===6)return n.stateNode;throw Error(Ue(33))}function jf(n){var e=n[Gw];return e||(e=n[Gw]={hoistableStyles:new Map,hoistableScripts:new Map}),e}function Ji(n){n[T0]=!0}var vL=new Set,_L={};function th(n,e){od(n,e),od(n+"Capture",e)}function od(n,e){for(_L[n]=e,n=0;n<e.length;n++)vL.add(e[n])}var Jz=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Vw={},kw={};function $z(n){return u3.call(kw,n)?!0:u3.call(Vw,n)?!1:Jz.test(n)?kw[n]=!0:(Vw[n]=!0,!1)}function Qv(n,e,t){if($z(e))if(t===null)n.removeAttribute(e);else{switch(typeof t){case"undefined":case"function":case"symbol":n.removeAttribute(e);return;case"boolean":var i=e.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){n.removeAttribute(e);return}}n.setAttribute(e,""+t)}}function Lg(n,e,t){if(t===null)n.removeAttribute(e);else{switch(typeof t){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(e);return}n.setAttribute(e,""+t)}}function Eo(n,e,t,i){if(i===null)n.removeAttribute(t);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(t);return}n.setAttributeNS(e,t,""+i)}}function qr(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function xL(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function eB(n,e,t){var i=Object.getOwnPropertyDescriptor(n.constructor.prototype,e);if(!n.hasOwnProperty(e)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var a=i.get,r=i.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return a.call(this)},set:function(s){t=""+s,r.call(this,s)}}),Object.defineProperty(n,e,{enumerable:i.enumerable}),{getValue:function(){return t},setValue:function(s){t=""+s},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function f3(n){if(!n._valueTracker){var e=xL(n)?"checked":"value";n._valueTracker=eB(n,e,""+n[e])}}function yL(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=xL(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function A_(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var tB=/[\n"\\]/g;function Kr(n){return n.replace(tB,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function d3(n,e,t,i,a,r,s,o){n.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?n.type=s:n.removeAttribute("type"),e!=null?s==="number"?(e===0&&n.value===""||n.value!=e)&&(n.value=""+qr(e)):n.value!==""+qr(e)&&(n.value=""+qr(e)):s!=="submit"&&s!=="reset"||n.removeAttribute("value"),e!=null?p3(n,s,qr(e)):t!=null?p3(n,s,qr(t)):i!=null&&n.removeAttribute("value"),a==null&&r!=null&&(n.defaultChecked=!!r),a!=null&&(n.checked=a&&typeof a!="function"&&typeof a!="symbol"),o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"?n.name=""+qr(o):n.removeAttribute("name")}function SL(n,e,t,i,a,r,s,o){if(r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"&&(n.type=r),e!=null||t!=null){if(!(r!=="submit"&&r!=="reset"||e!=null)){f3(n);return}t=t!=null?""+qr(t):"",e=e!=null?""+qr(e):t,o||e===n.value||(n.value=e),n.defaultValue=e}i=i??a,i=typeof i!="function"&&typeof i!="symbol"&&!!i,n.checked=o?n.checked:!!i,n.defaultChecked=!!i,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(n.name=s),f3(n)}function p3(n,e,t){e==="number"&&A_(n.ownerDocument)===n||n.defaultValue===""+t||(n.defaultValue=""+t)}function Zf(n,e,t,i){if(n=n.options,e){e={};for(var a=0;a<t.length;a++)e["$"+t[a]]=!0;for(t=0;t<n.length;t++)a=e.hasOwnProperty("$"+n[t].value),n[t].selected!==a&&(n[t].selected=a),a&&i&&(n[t].defaultSelected=!0)}else{for(t=""+qr(t),e=null,a=0;a<n.length;a++){if(n[a].value===t){n[a].selected=!0,i&&(n[a].defaultSelected=!0);return}e!==null||n[a].disabled||(e=n[a])}e!==null&&(e.selected=!0)}}function TL(n,e,t){if(e!=null&&(e=""+qr(e),e!==n.value&&(n.value=e),t==null)){n.defaultValue!==e&&(n.defaultValue=e);return}n.defaultValue=t!=null?""+qr(t):""}function EL(n,e,t,i){if(e==null){if(i!=null){if(t!=null)throw Error(Ue(92));if(im(i)){if(1<i.length)throw Error(Ue(93));i=i[0]}t=i}t==null&&(t=""),e=t}t=qr(e),n.defaultValue=t,i=n.textContent,i===t&&i!==""&&i!==null&&(n.value=i),f3(n)}function ld(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var nB=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ww(n,e,t){var i=e.indexOf("--")===0;t==null||typeof t=="boolean"||t===""?i?n.setProperty(e,""):e==="float"?n.cssFloat="":n[e]="":i?n.setProperty(e,t):typeof t!="number"||t===0||nB.has(e)?e==="float"?n.cssFloat=t:n[e]=(""+t).trim():n[e]=t+"px"}function ML(n,e,t){if(e!=null&&typeof e!="object")throw Error(Ue(62));if(n=n.style,t!=null){for(var i in t)!t.hasOwnProperty(i)||e!=null&&e.hasOwnProperty(i)||(i.indexOf("--")===0?n.setProperty(i,""):i==="float"?n.cssFloat="":n[i]="");for(var a in e)i=e[a],e.hasOwnProperty(a)&&t[a]!==i&&Ww(n,a,i)}else for(var r in e)e.hasOwnProperty(r)&&Ww(n,r,e[r])}function _M(n){if(n.indexOf("-")===-1)return!1;switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var iB=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),aB=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Jv(n){return aB.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function Yo(){}var m3=null;function xM(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Of=null,Kf=null;function Xw(n){var e=zd(n);if(e&&(n=e.stateNode)){var t=n[$a]||null;e:switch(n=e.stateNode,e.type){case"input":if(d3(n,t.value,t.defaultValue,t.defaultValue,t.checked,t.defaultChecked,t.type,t.name),e=t.name,t.type==="radio"&&e!=null){for(t=n;t.parentNode;)t=t.parentNode;for(t=t.querySelectorAll('input[name="'+Kr(""+e)+'"][type="radio"]'),e=0;e<t.length;e++){var i=t[e];if(i!==n&&i.form===n.form){var a=i[$a]||null;if(!a)throw Error(Ue(90));d3(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(e=0;e<t.length;e++)i=t[e],i.form===n.form&&yL(i)}break e;case"textarea":TL(n,t.value,t.defaultValue);break e;case"select":e=t.value,e!=null&&Zf(n,!!t.multiple,e,!1)}}}var qS=!1;function bL(n,e,t){if(qS)return n(e,t);qS=!0;try{var i=n(e);return i}finally{if(qS=!1,(Of!==null||Kf!==null)&&(S1(),Of&&(e=Of,n=Kf,Kf=Of=null,Xw(e),n)))for(e=0;e<n.length;e++)Xw(n[e])}}function Wm(n,e){var t=n.stateNode;if(t===null)return null;var i=t[$a]||null;if(i===null)return null;t=i[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(n=n.type,i=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!i;break e;default:n=!1}if(n)return null;if(t&&typeof t!="function")throw Error(Ue(231,e,typeof t));return t}var $o=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g3=!1;if($o)try{var bp={};Object.defineProperty(bp,"passive",{get:function(){g3=!0}}),window.addEventListener("test",bp,bp),window.removeEventListener("test",bp,bp)}catch{g3=!1}var Xl=null,yM=null,$v=null;function AL(){if($v)return $v;var n,e=yM,t=e.length,i,a="value"in Xl?Xl.value:Xl.textContent,r=a.length;for(n=0;n<t&&e[n]===a[n];n++);var s=t-n;for(i=1;i<=s&&e[t-i]===a[r-i];i++);return $v=a.slice(n,1<i?1-i:void 0)}function e_(n){var e=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&e===13&&(n=13)):n=e,n===10&&(n=13),32<=n||n===13?n:0}function Ig(){return!0}function Yw(){return!1}function er(n){function e(t,i,a,r,s){this._reactName=t,this._targetInst=a,this.type=i,this.nativeEvent=r,this.target=s,this.currentTarget=null;for(var o in n)n.hasOwnProperty(o)&&(t=n[o],this[o]=t?t(r):r[o]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?Ig:Yw,this.isPropagationStopped=Yw,this}return ti(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var t=this.nativeEvent;t&&(t.preventDefault?t.preventDefault():typeof t.returnValue!="unknown"&&(t.returnValue=!1),this.isDefaultPrevented=Ig)},stopPropagation:function(){var t=this.nativeEvent;t&&(t.stopPropagation?t.stopPropagation():typeof t.cancelBubble!="unknown"&&(t.cancelBubble=!0),this.isPropagationStopped=Ig)},persist:function(){},isPersistent:Ig}),e}var nh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},u1=er(nh),E0=ti({},nh,{view:0,detail:0}),rB=er(E0),jS,ZS,Ap,h1=ti({},E0,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:SM,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Ap&&(Ap&&n.type==="mousemove"?(jS=n.screenX-Ap.screenX,ZS=n.screenY-Ap.screenY):ZS=jS=0,Ap=n),jS)},movementY:function(n){return"movementY"in n?n.movementY:ZS}}),qw=er(h1),sB=ti({},h1,{dataTransfer:0}),oB=er(sB),lB=ti({},E0,{relatedTarget:0}),KS=er(lB),cB=ti({},nh,{animationName:0,elapsedTime:0,pseudoElement:0}),uB=er(cB),hB=ti({},nh,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),fB=er(hB),dB=ti({},nh,{data:0}),jw=er(dB),pB={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mB={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},gB={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vB(n){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(n):(n=gB[n])?!!e[n]:!1}function SM(){return vB}var _B=ti({},E0,{key:function(n){if(n.key){var e=pB[n.key]||n.key;if(e!=="Unidentified")return e}return n.type==="keypress"?(n=e_(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?mB[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:SM,charCode:function(n){return n.type==="keypress"?e_(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?e_(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),xB=er(_B),yB=ti({},h1,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Zw=er(yB),SB=ti({},E0,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:SM}),TB=er(SB),EB=ti({},nh,{propertyName:0,elapsedTime:0,pseudoElement:0}),MB=er(EB),bB=ti({},h1,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),AB=er(bB),RB=ti({},nh,{newState:0,oldState:0}),wB=er(RB),CB=[9,13,27,32],TM=$o&&"CompositionEvent"in window,gm=null;$o&&"documentMode"in document&&(gm=document.documentMode);var NB=$o&&"TextEvent"in window&&!gm,RL=$o&&(!TM||gm&&8<gm&&11>=gm),Kw=" ",Qw=!1;function wL(n,e){switch(n){case"keyup":return CB.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function CL(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Lf=!1;function DB(n,e){switch(n){case"compositionend":return CL(e);case"keypress":return e.which!==32?null:(Qw=!0,Kw);case"textInput":return n=e.data,n===Kw&&Qw?null:n;default:return null}}function OB(n,e){if(Lf)return n==="compositionend"||!TM&&wL(n,e)?(n=AL(),$v=yM=Xl=null,Lf=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return RL&&e.locale!=="ko"?null:e.data;default:return null}}var LB={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Jw(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e==="input"?!!LB[n.type]:e==="textarea"}function NL(n,e,t,i){Of?Kf?Kf.push(i):Kf=[i]:Of=i,e=W_(e,"onChange"),0<e.length&&(t=new u1("onChange","change",null,t,i),n.push({event:t,listeners:e}))}var vm=null,Xm=null;function IB(n){bI(n,0)}function f1(n){var e=am(n);if(yL(e))return n}function $w(n,e){if(n==="change")return e}var DL=!1;if($o){var QS;if($o){var JS="oninput"in document;if(!JS){var eC=document.createElement("div");eC.setAttribute("oninput","return;"),JS=typeof eC.oninput=="function"}QS=JS}else QS=!1;DL=QS&&(!document.documentMode||9<document.documentMode)}function tC(){vm&&(vm.detachEvent("onpropertychange",OL),Xm=vm=null)}function OL(n){if(n.propertyName==="value"&&f1(Xm)){var e=[];NL(e,Xm,n,xM(n)),bL(IB,e)}}function UB(n,e,t){n==="focusin"?(tC(),vm=e,Xm=t,vm.attachEvent("onpropertychange",OL)):n==="focusout"&&tC()}function PB(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return f1(Xm)}function zB(n,e){if(n==="click")return f1(e)}function BB(n,e){if(n==="input"||n==="change")return f1(e)}function HB(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var Nr=typeof Object.is=="function"?Object.is:HB;function Ym(n,e){if(Nr(n,e))return!0;if(typeof n!="object"||n===null||typeof e!="object"||e===null)return!1;var t=Object.keys(n),i=Object.keys(e);if(t.length!==i.length)return!1;for(i=0;i<t.length;i++){var a=t[i];if(!u3.call(e,a)||!Nr(n[a],e[a]))return!1}return!0}function nC(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function iC(n,e){var t=nC(n);n=0;for(var i;t;){if(t.nodeType===3){if(i=n+t.textContent.length,n<=e&&i>=e)return{node:t,offset:e-n};n=i}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=nC(t)}}function LL(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?LL(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function IL(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var e=A_(n.document);e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=A_(n.document)}return e}function EM(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}var FB=$o&&"documentMode"in document&&11>=document.documentMode,If=null,v3=null,_m=null,_3=!1;function aC(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;_3||If==null||If!==A_(i)||(i=If,"selectionStart"in i&&EM(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),_m&&Ym(_m,i)||(_m=i,i=W_(v3,"onSelect"),0<i.length&&(e=new u1("onSelect","select",null,e,t),n.push({event:e,listeners:i}),e.target=If)))}function Xc(n,e){var t={};return t[n.toLowerCase()]=e.toLowerCase(),t["Webkit"+n]="webkit"+e,t["Moz"+n]="moz"+e,t}var Uf={animationend:Xc("Animation","AnimationEnd"),animationiteration:Xc("Animation","AnimationIteration"),animationstart:Xc("Animation","AnimationStart"),transitionrun:Xc("Transition","TransitionRun"),transitionstart:Xc("Transition","TransitionStart"),transitioncancel:Xc("Transition","TransitionCancel"),transitionend:Xc("Transition","TransitionEnd")},$S={},UL={};$o&&(UL=document.createElement("div").style,"AnimationEvent"in window||(delete Uf.animationend.animation,delete Uf.animationiteration.animation,delete Uf.animationstart.animation),"TransitionEvent"in window||delete Uf.transitionend.transition);function ih(n){if($S[n])return $S[n];if(!Uf[n])return n;var e=Uf[n],t;for(t in e)if(e.hasOwnProperty(t)&&t in UL)return $S[n]=e[t];return n}var PL=ih("animationend"),zL=ih("animationiteration"),BL=ih("animationstart"),GB=ih("transitionrun"),VB=ih("transitionstart"),kB=ih("transitioncancel"),HL=ih("transitionend"),FL=new Map,x3="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");x3.push("scrollEnd");function Ds(n,e){FL.set(n,e),th(e,[n])}var R_=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Yr=[],Pf=0,MM=0;function d1(){for(var n=Pf,e=MM=Pf=0;e<n;){var t=Yr[e];Yr[e++]=null;var i=Yr[e];Yr[e++]=null;var a=Yr[e];Yr[e++]=null;var r=Yr[e];if(Yr[e++]=null,i!==null&&a!==null){var s=i.pending;s===null?a.next=a:(a.next=s.next,s.next=a),i.pending=a}r!==0&&GL(t,a,r)}}function p1(n,e,t,i){Yr[Pf++]=n,Yr[Pf++]=e,Yr[Pf++]=t,Yr[Pf++]=i,MM|=i,n.lanes|=i,n=n.alternate,n!==null&&(n.lanes|=i)}function bM(n,e,t,i){return p1(n,e,t,i),w_(n)}function ah(n,e){return p1(n,null,null,e),w_(n)}function GL(n,e,t){n.lanes|=t;var i=n.alternate;i!==null&&(i.lanes|=t);for(var a=!1,r=n.return;r!==null;)r.childLanes|=t,i=r.alternate,i!==null&&(i.childLanes|=t),r.tag===22&&(n=r.stateNode,n===null||n._visibility&1||(a=!0)),n=r,r=r.return;return n.tag===3?(r=n.stateNode,a&&e!==null&&(a=31-Rr(t),n=r.hiddenUpdates,i=n[a],i===null?n[a]=[e]:i.push(e),e.lane=t|536870912),r):null}function w_(n){if(50<Rm)throw Rm=0,F3=null,Error(Ue(185));for(var e=n.return;e!==null;)n=e,e=n.return;return n.tag===3?n.stateNode:null}var zf={};function WB(n,e,t,i){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Sr(n,e,t,i){return new WB(n,e,t,i)}function AM(n){return n=n.prototype,!(!n||!n.isReactComponent)}function jo(n,e){var t=n.alternate;return t===null?(t=Sr(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&65011712,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t.refCleanup=n.refCleanup,t}function VL(n,e){n.flags&=65011714;var t=n.alternate;return t===null?(n.childLanes=0,n.lanes=e,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,n.type=t.type,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n}function t_(n,e,t,i,a,r){var s=0;if(i=n,typeof n=="function")AM(n)&&(s=1);else if(typeof n=="string")s=ZH(n,t,no.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case s3:return n=Sr(31,t,e,a),n.elementType=s3,n.lanes=r,n;case Cf:return wu(t.children,a,r,e);case oL:s=8,a|=24;break;case i3:return n=Sr(12,t,e,a|2),n.elementType=i3,n.lanes=r,n;case a3:return n=Sr(13,t,e,a),n.elementType=a3,n.lanes=r,n;case r3:return n=Sr(19,t,e,a),n.elementType=r3,n.lanes=r,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case Xo:s=10;break e;case lL:s=9;break e;case fM:s=11;break e;case dM:s=14;break e;case zl:s=16,i=null;break e}s=29,t=Error(Ue(130,n===null?"null":typeof n,"")),i=null}return e=Sr(s,t,e,a),e.elementType=n,e.type=i,e.lanes=r,e}function wu(n,e,t,i){return n=Sr(7,n,i,e),n.lanes=t,n}function eT(n,e,t){return n=Sr(6,n,null,e),n.lanes=t,n}function kL(n){var e=Sr(18,null,null,0);return e.stateNode=n,e}function tT(n,e,t){return e=Sr(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}var rC=new WeakMap;function Qr(n,e){if(typeof n=="object"&&n!==null){var t=rC.get(n);return t!==void 0?t:(e={value:n,source:e,stack:Hw(e)},rC.set(n,e),e)}return{value:n,source:e,stack:Hw(e)}}var Bf=[],Hf=0,C_=null,qm=0,jr=[],Zr=0,cc=null,Js=1,$s="";function Ho(n,e){Bf[Hf++]=qm,Bf[Hf++]=C_,C_=n,qm=e}function WL(n,e,t){jr[Zr++]=Js,jr[Zr++]=$s,jr[Zr++]=cc,cc=n;var i=Js;n=$s;var a=32-Rr(i)-1;i&=~(1<<a),t+=1;var r=32-Rr(e)+a;if(30<r){var s=a-a%5;r=(i&(1<<s)-1).toString(32),i>>=s,a-=s,Js=1<<32-Rr(e)+a|t<<a|i,$s=r+n}else Js=1<<r|t<<a|i,$s=n}function RM(n){n.return!==null&&(Ho(n,1),WL(n,1,0))}function wM(n){for(;n===C_;)C_=Bf[--Hf],Bf[Hf]=null,qm=Bf[--Hf],Bf[Hf]=null;for(;n===cc;)cc=jr[--Zr],jr[Zr]=null,$s=jr[--Zr],jr[Zr]=null,Js=jr[--Zr],jr[Zr]=null}function XL(n,e){jr[Zr++]=Js,jr[Zr++]=$s,jr[Zr++]=cc,Js=e.id,$s=e.overflow,cc=n}var oa=null,Qn=null,un=!1,$l=null,Jr=!1,y3=Error(Ue(519));function uc(n){var e=Error(Ue(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw jm(Qr(e,n)),y3}function sC(n){var e=n.stateNode,t=n.type,i=n.memoizedProps;switch(e[sa]=n,e[$a]=i,t){case"dialog":an("cancel",e),an("close",e);break;case"iframe":case"object":case"embed":an("load",e);break;case"video":case"audio":for(t=0;t<Jm.length;t++)an(Jm[t],e);break;case"source":an("error",e);break;case"img":case"image":case"link":an("error",e),an("load",e);break;case"details":an("toggle",e);break;case"input":an("invalid",e),SL(e,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":an("invalid",e);break;case"textarea":an("invalid",e),EL(e,i.value,i.defaultValue,i.children)}t=i.children,typeof t!="string"&&typeof t!="number"&&typeof t!="bigint"||e.textContent===""+t||i.suppressHydrationWarning===!0||RI(e.textContent,t)?(i.popover!=null&&(an("beforetoggle",e),an("toggle",e)),i.onScroll!=null&&an("scroll",e),i.onScrollEnd!=null&&an("scrollend",e),i.onClick!=null&&(e.onclick=Yo),e=!0):e=!1,e||uc(n,!0)}function oC(n){for(oa=n.return;oa;)switch(oa.tag){case 5:case 31:case 13:Jr=!1;return;case 27:case 3:Jr=!0;return;default:oa=oa.return}}function Gh(n){if(n!==oa)return!1;if(!un)return oC(n),un=!0,!1;var e=n.tag,t;if((t=e!==3&&e!==27)&&((t=e===5)&&(t=n.type,t=!(t!=="form"&&t!=="button")||X3(n.type,n.memoizedProps)),t=!t),t&&Qn&&uc(n),oC(n),e===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(Ue(317));Qn=qC(n)}else if(e===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(Ue(317));Qn=qC(n)}else e===27?(e=Qn,xc(n.type)?(n=Z3,Z3=null,Qn=n):Qn=e):Qn=oa?ts(n.stateNode.nextSibling):null;return!0}function Bu(){Qn=oa=null,un=!1}function nT(){var n=$l;return n!==null&&(Za===null?Za=n:Za.push.apply(Za,n),$l=null),n}function jm(n){$l===null?$l=[n]:$l.push(n)}var S3=oo(null),rh=null,qo=null;function Hl(n,e,t){Yn(S3,e._currentValue),e._currentValue=t}function Zo(n){n._currentValue=S3.current,$i(S3)}function T3(n,e,t){for(;n!==null;){var i=n.alternate;if((n.childLanes&e)!==e?(n.childLanes|=e,i!==null&&(i.childLanes|=e)):i!==null&&(i.childLanes&e)!==e&&(i.childLanes|=e),n===t)break;n=n.return}}function E3(n,e,t,i){var a=n.child;for(a!==null&&(a.return=n);a!==null;){var r=a.dependencies;if(r!==null){var s=a.child;r=r.firstContext;e:for(;r!==null;){var o=r;r=a;for(var c=0;c<e.length;c++)if(o.context===e[c]){r.lanes|=t,o=r.alternate,o!==null&&(o.lanes|=t),T3(r.return,t,n),i||(s=null);break e}r=o.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(Ue(341));s.lanes|=t,r=s.alternate,r!==null&&(r.lanes|=t),T3(s,t,n),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===n){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Bd(n,e,t,i){n=null;for(var a=e,r=!1;a!==null;){if(!r){if(a.flags&524288)r=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(Ue(387));if(s=s.memoizedProps,s!==null){var o=a.type;Nr(a.pendingProps.value,s.value)||(n!==null?n.push(o):n=[o])}}else if(a===T_.current){if(s=a.alternate,s===null)throw Error(Ue(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(n!==null?n.push(e0):n=[e0])}a=a.return}n!==null&&E3(e,n,t,i),e.flags|=262144}function N_(n){for(n=n.firstContext;n!==null;){if(!Nr(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Hu(n){rh=n,qo=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function ca(n){return YL(rh,n)}function Ug(n,e){return rh===null&&Hu(n),YL(n,e)}function YL(n,e){var t=e._currentValue;if(e={context:e,memoizedValue:t,next:null},qo===null){if(n===null)throw Error(Ue(308));qo=e,n.dependencies={lanes:0,firstContext:e},n.flags|=524288}else qo=qo.next=e;return t}var XB=typeof AbortController<"u"?AbortController:function(){var n=[],e=this.signal={aborted:!1,addEventListener:function(t,i){n.push(i)}};this.abort=function(){e.aborted=!0,n.forEach(function(t){return t()})}},YB=Hi.unstable_scheduleCallback,qB=Hi.unstable_NormalPriority,Ni={$$typeof:Xo,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function CM(){return{controller:new XB,data:new Map,refCount:0}}function M0(n){n.refCount--,n.refCount===0&&YB(qB,function(){n.controller.abort()})}var xm=null,M3=0,cd=0,Qf=null;function jB(n,e){if(xm===null){var t=xm=[];M3=0,cd=eb(),Qf={status:"pending",value:void 0,then:function(i){t.push(i)}}}return M3++,e.then(lC,lC),e}function lC(){if(--M3===0&&xm!==null){Qf!==null&&(Qf.status="fulfilled");var n=xm;xm=null,cd=0,Qf=null;for(var e=0;e<n.length;e++)(0,n[e])()}}function ZB(n,e){var t=[],i={status:"pending",value:null,reason:null,then:function(a){t.push(a)}};return n.then(function(){i.status="fulfilled",i.value=e;for(var a=0;a<t.length;a++)(0,t[a])(e)},function(a){for(i.status="rejected",i.reason=a,a=0;a<t.length;a++)(0,t[a])(void 0)}),i}var cC=Ut.S;Ut.S=function(n,e){sI=br(),typeof e=="object"&&e!==null&&typeof e.then=="function"&&jB(n,e),cC!==null&&cC(n,e)};var Cu=oo(null);function NM(){var n=Cu.current;return n!==null?n:Hn.pooledCache}function n_(n,e){e===null?Yn(Cu,Cu.current):Yn(Cu,e.pool)}function qL(){var n=NM();return n===null?null:{parent:Ni._currentValue,pool:n}}var Hd=Error(Ue(460)),DM=Error(Ue(474)),m1=Error(Ue(542)),D_={then:function(){}};function uC(n){return n=n.status,n==="fulfilled"||n==="rejected"}function jL(n,e,t){switch(t=n[t],t===void 0?n.push(e):t!==e&&(e.then(Yo,Yo),e=t),e.status){case"fulfilled":return e.value;case"rejected":throw n=e.reason,fC(n),n;default:if(typeof e.status=="string")e.then(Yo,Yo);else{if(n=Hn,n!==null&&100<n.shellSuspendCounter)throw Error(Ue(482));n=e,n.status="pending",n.then(function(i){if(e.status==="pending"){var a=e;a.status="fulfilled",a.value=i}},function(i){if(e.status==="pending"){var a=e;a.status="rejected",a.reason=i}})}switch(e.status){case"fulfilled":return e.value;case"rejected":throw n=e.reason,fC(n),n}throw Nu=e,Hd}}function du(n){try{var e=n._init;return e(n._payload)}catch(t){throw t!==null&&typeof t=="object"&&typeof t.then=="function"?(Nu=t,Hd):t}}var Nu=null;function hC(){if(Nu===null)throw Error(Ue(459));var n=Nu;return Nu=null,n}function fC(n){if(n===Hd||n===m1)throw Error(Ue(483))}var Jf=null,Zm=0;function Pg(n){var e=Zm;return Zm+=1,Jf===null&&(Jf=[]),jL(Jf,n,e)}function Rp(n,e){e=e.props.ref,n.ref=e!==void 0?e:null}function zg(n,e){throw e.$$typeof===Uz?Error(Ue(525)):(n=Object.prototype.toString.call(e),Error(Ue(31,n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)))}function ZL(n){function e(v,y){if(n){var E=v.deletions;E===null?(v.deletions=[y],v.flags|=16):E.push(y)}}function t(v,y){if(!n)return null;for(;y!==null;)e(v,y),y=y.sibling;return null}function i(v){for(var y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function a(v,y){return v=jo(v,y),v.index=0,v.sibling=null,v}function r(v,y,E){return v.index=E,n?(E=v.alternate,E!==null?(E=E.index,E<y?(v.flags|=67108866,y):E):(v.flags|=67108866,y)):(v.flags|=1048576,y)}function s(v){return n&&v.alternate===null&&(v.flags|=67108866),v}function o(v,y,E,b){return y===null||y.tag!==6?(y=eT(E,v.mode,b),y.return=v,y):(y=a(y,E),y.return=v,y)}function c(v,y,E,b){var D=E.type;return D===Cf?f(v,y,E.props.children,b,E.key):y!==null&&(y.elementType===D||typeof D=="object"&&D!==null&&D.$$typeof===zl&&du(D)===y.type)?(y=a(y,E.props),Rp(y,E),y.return=v,y):(y=t_(E.type,E.key,E.props,null,v.mode,b),Rp(y,E),y.return=v,y)}function h(v,y,E,b){return y===null||y.tag!==4||y.stateNode.containerInfo!==E.containerInfo||y.stateNode.implementation!==E.implementation?(y=tT(E,v.mode,b),y.return=v,y):(y=a(y,E.children||[]),y.return=v,y)}function f(v,y,E,b,D){return y===null||y.tag!==7?(y=wu(E,v.mode,b,D),y.return=v,y):(y=a(y,E),y.return=v,y)}function d(v,y,E){if(typeof y=="string"&&y!==""||typeof y=="number"||typeof y=="bigint")return y=eT(""+y,v.mode,E),y.return=v,y;if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Cg:return E=t_(y.type,y.key,y.props,null,v.mode,E),Rp(E,y),E.return=v,E;case nm:return y=tT(y,v.mode,E),y.return=v,y;case zl:return y=du(y),d(v,y,E)}if(im(y)||Mp(y))return y=wu(y,v.mode,E,null),y.return=v,y;if(typeof y.then=="function")return d(v,Pg(y),E);if(y.$$typeof===Xo)return d(v,Ug(v,y),E);zg(v,y)}return null}function m(v,y,E,b){var D=y!==null?y.key:null;if(typeof E=="string"&&E!==""||typeof E=="number"||typeof E=="bigint")return D!==null?null:o(v,y,""+E,b);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case Cg:return E.key===D?c(v,y,E,b):null;case nm:return E.key===D?h(v,y,E,b):null;case zl:return E=du(E),m(v,y,E,b)}if(im(E)||Mp(E))return D!==null?null:f(v,y,E,b,null);if(typeof E.then=="function")return m(v,y,Pg(E),b);if(E.$$typeof===Xo)return m(v,y,Ug(v,E),b);zg(v,E)}return null}function g(v,y,E,b,D){if(typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint")return v=v.get(E)||null,o(y,v,""+b,D);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Cg:return v=v.get(b.key===null?E:b.key)||null,c(y,v,b,D);case nm:return v=v.get(b.key===null?E:b.key)||null,h(y,v,b,D);case zl:return b=du(b),g(v,y,E,b,D)}if(im(b)||Mp(b))return v=v.get(E)||null,f(y,v,b,D,null);if(typeof b.then=="function")return g(v,y,E,Pg(b),D);if(b.$$typeof===Xo)return g(v,y,E,Ug(y,b),D);zg(y,b)}return null}function x(v,y,E,b){for(var D=null,C=null,I=y,P=y=0,O=null;I!==null&&P<E.length;P++){I.index>P?(O=I,I=null):O=I.sibling;var R=m(v,I,E[P],b);if(R===null){I===null&&(I=O);break}n&&I&&R.alternate===null&&e(v,I),y=r(R,y,P),C===null?D=R:C.sibling=R,C=R,I=O}if(P===E.length)return t(v,I),un&&Ho(v,P),D;if(I===null){for(;P<E.length;P++)I=d(v,E[P],b),I!==null&&(y=r(I,y,P),C===null?D=I:C.sibling=I,C=I);return un&&Ho(v,P),D}for(I=i(I);P<E.length;P++)O=g(I,v,P,E[P],b),O!==null&&(n&&O.alternate!==null&&I.delete(O.key===null?P:O.key),y=r(O,y,P),C===null?D=O:C.sibling=O,C=O);return n&&I.forEach(function(B){return e(v,B)}),un&&Ho(v,P),D}function T(v,y,E,b){if(E==null)throw Error(Ue(151));for(var D=null,C=null,I=y,P=y=0,O=null,R=E.next();I!==null&&!R.done;P++,R=E.next()){I.index>P?(O=I,I=null):O=I.sibling;var B=m(v,I,R.value,b);if(B===null){I===null&&(I=O);break}n&&I&&B.alternate===null&&e(v,I),y=r(B,y,P),C===null?D=B:C.sibling=B,C=B,I=O}if(R.done)return t(v,I),un&&Ho(v,P),D;if(I===null){for(;!R.done;P++,R=E.next())R=d(v,R.value,b),R!==null&&(y=r(R,y,P),C===null?D=R:C.sibling=R,C=R);return un&&Ho(v,P),D}for(I=i(I);!R.done;P++,R=E.next())R=g(I,v,P,R.value,b),R!==null&&(n&&R.alternate!==null&&I.delete(R.key===null?P:R.key),y=r(R,y,P),C===null?D=R:C.sibling=R,C=R);return n&&I.forEach(function(j){return e(v,j)}),un&&Ho(v,P),D}function S(v,y,E,b){if(typeof E=="object"&&E!==null&&E.type===Cf&&E.key===null&&(E=E.props.children),typeof E=="object"&&E!==null){switch(E.$$typeof){case Cg:e:{for(var D=E.key;y!==null;){if(y.key===D){if(D=E.type,D===Cf){if(y.tag===7){t(v,y.sibling),b=a(y,E.props.children),b.return=v,v=b;break e}}else if(y.elementType===D||typeof D=="object"&&D!==null&&D.$$typeof===zl&&du(D)===y.type){t(v,y.sibling),b=a(y,E.props),Rp(b,E),b.return=v,v=b;break e}t(v,y);break}else e(v,y);y=y.sibling}E.type===Cf?(b=wu(E.props.children,v.mode,b,E.key),b.return=v,v=b):(b=t_(E.type,E.key,E.props,null,v.mode,b),Rp(b,E),b.return=v,v=b)}return s(v);case nm:e:{for(D=E.key;y!==null;){if(y.key===D)if(y.tag===4&&y.stateNode.containerInfo===E.containerInfo&&y.stateNode.implementation===E.implementation){t(v,y.sibling),b=a(y,E.children||[]),b.return=v,v=b;break e}else{t(v,y);break}else e(v,y);y=y.sibling}b=tT(E,v.mode,b),b.return=v,v=b}return s(v);case zl:return E=du(E),S(v,y,E,b)}if(im(E))return x(v,y,E,b);if(Mp(E)){if(D=Mp(E),typeof D!="function")throw Error(Ue(150));return E=D.call(E),T(v,y,E,b)}if(typeof E.then=="function")return S(v,y,Pg(E),b);if(E.$$typeof===Xo)return S(v,y,Ug(v,E),b);zg(v,E)}return typeof E=="string"&&E!==""||typeof E=="number"||typeof E=="bigint"?(E=""+E,y!==null&&y.tag===6?(t(v,y.sibling),b=a(y,E),b.return=v,v=b):(t(v,y),b=eT(E,v.mode,b),b.return=v,v=b),s(v)):t(v,y)}return function(v,y,E,b){try{Zm=0;var D=S(v,y,E,b);return Jf=null,D}catch(I){if(I===Hd||I===m1)throw I;var C=Sr(29,I,null,v.mode);return C.lanes=b,C.return=v,C}finally{}}}var Fu=ZL(!0),KL=ZL(!1),Bl=!1;function OM(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function b3(n,e){n=n.updateQueue,e.updateQueue===n&&(e.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function ec(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function tc(n,e,t){var i=n.updateQueue;if(i===null)return null;if(i=i.shared,xn&2){var a=i.pending;return a===null?e.next=e:(e.next=a.next,a.next=e),i.pending=e,e=w_(n),GL(n,null,t),e}return p1(n,i,e,t),w_(n)}function ym(n,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194048)!==0)){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,pL(n,t)}}function iT(n,e){var t=n.updateQueue,i=n.alternate;if(i!==null&&(i=i.updateQueue,t===i)){var a=null,r=null;if(t=t.firstBaseUpdate,t!==null){do{var s={lane:t.lane,tag:t.tag,payload:t.payload,callback:null,next:null};r===null?a=r=s:r=r.next=s,t=t.next}while(t!==null);r===null?a=r=e:r=r.next=e}else a=r=e;t={baseState:i.baseState,firstBaseUpdate:a,lastBaseUpdate:r,shared:i.shared,callbacks:i.callbacks},n.updateQueue=t;return}n=t.lastBaseUpdate,n===null?t.firstBaseUpdate=e:n.next=e,t.lastBaseUpdate=e}var A3=!1;function Sm(){if(A3){var n=Qf;if(n!==null)throw n}}function Tm(n,e,t,i){A3=!1;var a=n.updateQueue;Bl=!1;var r=a.firstBaseUpdate,s=a.lastBaseUpdate,o=a.shared.pending;if(o!==null){a.shared.pending=null;var c=o,h=c.next;c.next=null,s===null?r=h:s.next=h,s=c;var f=n.alternate;f!==null&&(f=f.updateQueue,o=f.lastBaseUpdate,o!==s&&(o===null?f.firstBaseUpdate=h:o.next=h,f.lastBaseUpdate=c))}if(r!==null){var d=a.baseState;s=0,f=h=c=null,o=r;do{var m=o.lane&-536870913,g=m!==o.lane;if(g?(cn&m)===m:(i&m)===m){m!==0&&m===cd&&(A3=!0),f!==null&&(f=f.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var x=n,T=o;m=e;var S=t;switch(T.tag){case 1:if(x=T.payload,typeof x=="function"){d=x.call(S,d,m);break e}d=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=T.payload,m=typeof x=="function"?x.call(S,d,m):x,m==null)break e;d=ti({},d,m);break e;case 2:Bl=!0}}m=o.callback,m!==null&&(n.flags|=64,g&&(n.flags|=8192),g=a.callbacks,g===null?a.callbacks=[m]:g.push(m))}else g={lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},f===null?(h=f=g,c=d):f=f.next=g,s|=m;if(o=o.next,o===null){if(o=a.shared.pending,o===null)break;g=o,o=g.next,g.next=null,a.lastBaseUpdate=g,a.shared.pending=null}}while(!0);f===null&&(c=d),a.baseState=c,a.firstBaseUpdate=h,a.lastBaseUpdate=f,r===null&&(a.shared.lanes=0),fc|=s,n.lanes=s,n.memoizedState=d}}function QL(n,e){if(typeof n!="function")throw Error(Ue(191,n));n.call(e)}function JL(n,e){var t=n.callbacks;if(t!==null)for(n.callbacks=null,n=0;n<t.length;n++)QL(t[n],e)}var ud=oo(null),O_=oo(0);function dC(n,e){n=il,Yn(O_,n),Yn(ud,e),il=n|e.baseLanes}function R3(){Yn(O_,il),Yn(ud,ud.current)}function LM(){il=O_.current,$i(ud),$i(O_)}var Dr=oo(null),es=null;function Fl(n){var e=n.alternate;Yn(yi,yi.current&1),Yn(Dr,n),es===null&&(e===null||ud.current!==null||e.memoizedState!==null)&&(es=n)}function w3(n){Yn(yi,yi.current),Yn(Dr,n),es===null&&(es=n)}function $L(n){n.tag===22?(Yn(yi,yi.current),Yn(Dr,n),es===null&&(es=n)):Gl()}function Gl(){Yn(yi,yi.current),Yn(Dr,Dr.current)}function yr(n){$i(Dr),es===n&&(es=null),$i(yi)}var yi=oo(0);function L_(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||q3(t)||j3(t)))return e}else if(e.tag===19&&(e.memoizedProps.revealOrder==="forwards"||e.memoizedProps.revealOrder==="backwards"||e.memoizedProps.revealOrder==="unstable_legacy-backwards"||e.memoizedProps.revealOrder==="together")){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var el=0,jt=null,Pn=null,wi=null,I_=!1,$f=!1,Gu=!1,U_=0,Km=0,ed=null,KB=0;function gi(){throw Error(Ue(321))}function IM(n,e){if(e===null)return!1;for(var t=0;t<e.length&&t<n.length;t++)if(!Nr(n[t],e[t]))return!1;return!0}function UM(n,e,t,i,a,r){return el=r,jt=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Ut.H=n===null||n.memoizedState===null?N5:YM,Gu=!1,r=t(i,a),Gu=!1,$f&&(r=t5(e,t,i,a)),e5(n),r}function e5(n){Ut.H=Qm;var e=Pn!==null&&Pn.next!==null;if(el=0,wi=Pn=jt=null,I_=!1,Km=0,ed=null,e)throw Error(Ue(300));n===null||Di||(n=n.dependencies,n!==null&&N_(n)&&(Di=!0))}function t5(n,e,t,i){jt=n;var a=0;do{if($f&&(ed=null),Km=0,$f=!1,25<=a)throw Error(Ue(301));if(a+=1,wi=Pn=null,n.updateQueue!=null){var r=n.updateQueue;r.lastEffect=null,r.events=null,r.stores=null,r.memoCache!=null&&(r.memoCache.index=0)}Ut.H=D5,r=e(t,i)}while($f);return r}function QB(){var n=Ut.H,e=n.useState()[0];return e=typeof e.then=="function"?b0(e):e,n=n.useState()[0],(Pn!==null?Pn.memoizedState:null)!==n&&(jt.flags|=1024),e}function PM(){var n=U_!==0;return U_=0,n}function zM(n,e,t){e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~t}function BM(n){if(I_){for(n=n.memoizedState;n!==null;){var e=n.queue;e!==null&&(e.pending=null),n=n.next}I_=!1}el=0,wi=Pn=jt=null,$f=!1,Km=U_=0,ed=null}function Ra(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wi===null?jt.memoizedState=wi=n:wi=wi.next=n,wi}function Si(){if(Pn===null){var n=jt.alternate;n=n!==null?n.memoizedState:null}else n=Pn.next;var e=wi===null?jt.memoizedState:wi.next;if(e!==null)wi=e,Pn=n;else{if(n===null)throw jt.alternate===null?Error(Ue(467)):Error(Ue(310));Pn=n,n={memoizedState:Pn.memoizedState,baseState:Pn.baseState,baseQueue:Pn.baseQueue,queue:Pn.queue,next:null},wi===null?jt.memoizedState=wi=n:wi=wi.next=n}return wi}function g1(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function b0(n){var e=Km;return Km+=1,ed===null&&(ed=[]),n=jL(ed,n,e),e=jt,(wi===null?e.memoizedState:wi.next)===null&&(e=e.alternate,Ut.H=e===null||e.memoizedState===null?N5:YM),n}function v1(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return b0(n);if(n.$$typeof===Xo)return ca(n)}throw Error(Ue(438,String(n)))}function HM(n){var e=null,t=jt.updateQueue;if(t!==null&&(e=t.memoCache),e==null){var i=jt.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(e={data:i.data.map(function(a){return a.slice()}),index:0})))}if(e==null&&(e={data:[],index:0}),t===null&&(t=g1(),jt.updateQueue=t),t.memoCache=e,t=e.data[e.index],t===void 0)for(t=e.data[e.index]=Array(n),i=0;i<n;i++)t[i]=Pz;return e.index++,t}function tl(n,e){return typeof e=="function"?e(n):e}function i_(n){var e=Si();return FM(e,Pn,n)}function FM(n,e,t){var i=n.queue;if(i===null)throw Error(Ue(311));i.lastRenderedReducer=t;var a=n.baseQueue,r=i.pending;if(r!==null){if(a!==null){var s=a.next;a.next=r.next,r.next=s}e.baseQueue=a=r,i.pending=null}if(r=n.baseState,a===null)n.memoizedState=r;else{e=a.next;var o=s=null,c=null,h=e,f=!1;do{var d=h.lane&-536870913;if(d!==h.lane?(cn&d)===d:(el&d)===d){var m=h.revertLane;if(m===0)c!==null&&(c=c.next={lane:0,revertLane:0,gesture:null,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null}),d===cd&&(f=!0);else if((el&m)===m){h=h.next,m===cd&&(f=!0);continue}else d={lane:0,revertLane:h.revertLane,gesture:null,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null},c===null?(o=c=d,s=r):c=c.next=d,jt.lanes|=m,fc|=m;d=h.action,Gu&&t(r,d),r=h.hasEagerState?h.eagerState:t(r,d)}else m={lane:d,revertLane:h.revertLane,gesture:h.gesture,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null},c===null?(o=c=m,s=r):c=c.next=m,jt.lanes|=d,fc|=d;h=h.next}while(h!==null&&h!==e);if(c===null?s=r:c.next=o,!Nr(r,n.memoizedState)&&(Di=!0,f&&(t=Qf,t!==null)))throw t;n.memoizedState=r,n.baseState=s,n.baseQueue=c,i.lastRenderedState=r}return a===null&&(i.lanes=0),[n.memoizedState,i.dispatch]}function aT(n){var e=Si(),t=e.queue;if(t===null)throw Error(Ue(311));t.lastRenderedReducer=n;var i=t.dispatch,a=t.pending,r=e.memoizedState;if(a!==null){t.pending=null;var s=a=a.next;do r=n(r,s.action),s=s.next;while(s!==a);Nr(r,e.memoizedState)||(Di=!0),e.memoizedState=r,e.baseQueue===null&&(e.baseState=r),t.lastRenderedState=r}return[r,i]}function n5(n,e,t){var i=jt,a=Si(),r=un;if(r){if(t===void 0)throw Error(Ue(407));t=t()}else t=e();var s=!Nr((Pn||a).memoizedState,t);if(s&&(a.memoizedState=t,Di=!0),a=a.queue,GM(r5.bind(null,i,a,n),[n]),a.getSnapshot!==e||s||wi!==null&&wi.memoizedState.tag&1){if(i.flags|=2048,hd(9,{destroy:void 0},a5.bind(null,i,a,t,e),null),Hn===null)throw Error(Ue(349));r||el&127||i5(i,e,t)}return t}function i5(n,e,t){n.flags|=16384,n={getSnapshot:e,value:t},e=jt.updateQueue,e===null?(e=g1(),jt.updateQueue=e,e.stores=[n]):(t=e.stores,t===null?e.stores=[n]:t.push(n))}function a5(n,e,t,i){e.value=t,e.getSnapshot=i,s5(e)&&o5(n)}function r5(n,e,t){return t(function(){s5(e)&&o5(n)})}function s5(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!Nr(n,t)}catch{return!0}}function o5(n){var e=ah(n,2);e!==null&&Qa(e,n,2)}function C3(n){var e=Ra();if(typeof n=="function"){var t=n;if(n=t(),Gu){Wl(!0);try{t()}finally{Wl(!1)}}}return e.memoizedState=e.baseState=n,e.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:n},e}function l5(n,e,t,i){return n.baseState=t,FM(n,Pn,typeof i=="function"?i:tl)}function JB(n,e,t,i,a){if(x1(n))throw Error(Ue(485));if(n=e.action,n!==null){var r={payload:a,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){r.listeners.push(s)}};Ut.T!==null?t(!0):r.isTransition=!1,i(r),t=e.pending,t===null?(r.next=e.pending=r,c5(e,r)):(r.next=t.next,e.pending=t.next=r)}}function c5(n,e){var t=e.action,i=e.payload,a=n.state;if(e.isTransition){var r=Ut.T,s={};Ut.T=s;try{var o=t(a,i),c=Ut.S;c!==null&&c(s,o),pC(n,e,o)}catch(h){N3(n,e,h)}finally{r!==null&&s.types!==null&&(r.types=s.types),Ut.T=r}}else try{r=t(a,i),pC(n,e,r)}catch(h){N3(n,e,h)}}function pC(n,e,t){t!==null&&typeof t=="object"&&typeof t.then=="function"?t.then(function(i){mC(n,e,i)},function(i){return N3(n,e,i)}):mC(n,e,t)}function mC(n,e,t){e.status="fulfilled",e.value=t,u5(e),n.state=t,e=n.pending,e!==null&&(t=e.next,t===e?n.pending=null:(t=t.next,e.next=t,c5(n,t)))}function N3(n,e,t){var i=n.pending;if(n.pending=null,i!==null){i=i.next;do e.status="rejected",e.reason=t,u5(e),e=e.next;while(e!==i)}n.action=null}function u5(n){n=n.listeners;for(var e=0;e<n.length;e++)(0,n[e])()}function h5(n,e){return e}function gC(n,e){if(un){var t=Hn.formState;if(t!==null){e:{var i=jt;if(un){if(Qn){t:{for(var a=Qn,r=Jr;a.nodeType!==8;){if(!r){a=null;break t}if(a=ts(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){Qn=ts(a.nextSibling),i=a.data==="F!";break e}}uc(i)}i=!1}i&&(e=t[0])}}return t=Ra(),t.memoizedState=t.baseState=e,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h5,lastRenderedState:e},t.queue=i,t=R5.bind(null,jt,i),i.dispatch=t,i=C3(!1),r=XM.bind(null,jt,!1,i.queue),i=Ra(),a={state:e,dispatch:null,action:n,pending:null},i.queue=a,t=JB.bind(null,jt,a,r,t),a.dispatch=t,i.memoizedState=n,[e,t,!1]}function vC(n){var e=Si();return f5(e,Pn,n)}function f5(n,e,t){if(e=FM(n,e,h5)[0],n=i_(tl)[0],typeof e=="object"&&e!==null&&typeof e.then=="function")try{var i=b0(e)}catch(s){throw s===Hd?m1:s}else i=e;e=Si();var a=e.queue,r=a.dispatch;return t!==e.memoizedState&&(jt.flags|=2048,hd(9,{destroy:void 0},$B.bind(null,a,t),null)),[i,r,n]}function $B(n,e){n.action=e}function _C(n){var e=Si(),t=Pn;if(t!==null)return f5(e,t,n);Si(),e=e.memoizedState,t=Si();var i=t.queue.dispatch;return t.memoizedState=n,[e,i,!1]}function hd(n,e,t,i){return n={tag:n,create:t,deps:i,inst:e,next:null},e=jt.updateQueue,e===null&&(e=g1(),jt.updateQueue=e),t=e.lastEffect,t===null?e.lastEffect=n.next=n:(i=t.next,t.next=n,n.next=i,e.lastEffect=n),n}function d5(){return Si().memoizedState}function a_(n,e,t,i){var a=Ra();jt.flags|=n,a.memoizedState=hd(1|e,{destroy:void 0},t,i===void 0?null:i)}function _1(n,e,t,i){var a=Si();i=i===void 0?null:i;var r=a.memoizedState.inst;Pn!==null&&i!==null&&IM(i,Pn.memoizedState.deps)?a.memoizedState=hd(e,r,t,i):(jt.flags|=n,a.memoizedState=hd(1|e,r,t,i))}function xC(n,e){a_(8390656,8,n,e)}function GM(n,e){_1(2048,8,n,e)}function eH(n){jt.flags|=4;var e=jt.updateQueue;if(e===null)e=g1(),jt.updateQueue=e,e.events=[n];else{var t=e.events;t===null?e.events=[n]:t.push(n)}}function p5(n){var e=Si().memoizedState;return eH({ref:e,nextImpl:n}),function(){if(xn&2)throw Error(Ue(440));return e.impl.apply(void 0,arguments)}}function m5(n,e){return _1(4,2,n,e)}function g5(n,e){return _1(4,4,n,e)}function v5(n,e){if(typeof e=="function"){n=n();var t=e(n);return function(){typeof t=="function"?t():e(null)}}if(e!=null)return n=n(),e.current=n,function(){e.current=null}}function _5(n,e,t){t=t!=null?t.concat([n]):null,_1(4,4,v5.bind(null,e,n),t)}function VM(){}function x5(n,e){var t=Si();e=e===void 0?null:e;var i=t.memoizedState;return e!==null&&IM(e,i[1])?i[0]:(t.memoizedState=[n,e],n)}function y5(n,e){var t=Si();e=e===void 0?null:e;var i=t.memoizedState;if(e!==null&&IM(e,i[1]))return i[0];if(i=n(),Gu){Wl(!0);try{n()}finally{Wl(!1)}}return t.memoizedState=[i,e],i}function kM(n,e,t){return t===void 0||el&1073741824&&!(cn&261930)?n.memoizedState=e:(n.memoizedState=t,n=lI(),jt.lanes|=n,fc|=n,t)}function S5(n,e,t,i){return Nr(t,e)?t:ud.current!==null?(n=kM(n,t,i),Nr(n,e)||(Di=!0),n):!(el&42)||el&1073741824&&!(cn&261930)?(Di=!0,n.memoizedState=t):(n=lI(),jt.lanes|=n,fc|=n,e)}function T5(n,e,t,i,a){var r=yn.p;yn.p=r!==0&&8>r?r:8;var s=Ut.T,o={};Ut.T=o,XM(n,!1,e,t);try{var c=a(),h=Ut.S;if(h!==null&&h(o,c),c!==null&&typeof c=="object"&&typeof c.then=="function"){var f=ZB(c,i);Em(n,e,f,wr(n))}else Em(n,e,i,wr(n))}catch(d){Em(n,e,{then:function(){},status:"rejected",reason:d},wr())}finally{yn.p=r,s!==null&&o.types!==null&&(s.types=o.types),Ut.T=s}}function tH(){}function D3(n,e,t,i){if(n.tag!==5)throw Error(Ue(476));var a=E5(n).queue;T5(n,a,e,Ru,t===null?tH:function(){return M5(n),t(i)})}function E5(n){var e=n.memoizedState;if(e!==null)return e;e={memoizedState:Ru,baseState:Ru,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:Ru},next:null};var t={};return e.next={memoizedState:t,baseState:t,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:t},next:null},n.memoizedState=e,n=n.alternate,n!==null&&(n.memoizedState=e),e}function M5(n){var e=E5(n);e.next===null&&(e=n.alternate.memoizedState),Em(n,e.next.queue,{},wr())}function WM(){return ca(e0)}function b5(){return Si().memoizedState}function A5(){return Si().memoizedState}function nH(n){for(var e=n.return;e!==null;){switch(e.tag){case 24:case 3:var t=wr();n=ec(t);var i=tc(e,n,t);i!==null&&(Qa(i,e,t),ym(i,e,t)),e={cache:CM()},n.payload=e;return}e=e.return}}function iH(n,e,t){var i=wr();t={lane:i,revertLane:0,gesture:null,action:t,hasEagerState:!1,eagerState:null,next:null},x1(n)?w5(e,t):(t=bM(n,e,t,i),t!==null&&(Qa(t,n,i),C5(t,e,i)))}function R5(n,e,t){var i=wr();Em(n,e,t,i)}function Em(n,e,t,i){var a={lane:i,revertLane:0,gesture:null,action:t,hasEagerState:!1,eagerState:null,next:null};if(x1(n))w5(e,a);else{var r=n.alternate;if(n.lanes===0&&(r===null||r.lanes===0)&&(r=e.lastRenderedReducer,r!==null))try{var s=e.lastRenderedState,o=r(s,t);if(a.hasEagerState=!0,a.eagerState=o,Nr(o,s))return p1(n,e,a,0),Hn===null&&d1(),!1}catch{}finally{}if(t=bM(n,e,a,i),t!==null)return Qa(t,n,i),C5(t,e,i),!0}return!1}function XM(n,e,t,i){if(i={lane:2,revertLane:eb(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},x1(n)){if(e)throw Error(Ue(479))}else e=bM(n,t,i,2),e!==null&&Qa(e,n,2)}function x1(n){var e=n.alternate;return n===jt||e!==null&&e===jt}function w5(n,e){$f=I_=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function C5(n,e,t){if(t&4194048){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,pL(n,t)}}var Qm={readContext:ca,use:v1,useCallback:gi,useContext:gi,useEffect:gi,useImperativeHandle:gi,useLayoutEffect:gi,useInsertionEffect:gi,useMemo:gi,useReducer:gi,useRef:gi,useState:gi,useDebugValue:gi,useDeferredValue:gi,useTransition:gi,useSyncExternalStore:gi,useId:gi,useHostTransitionStatus:gi,useFormState:gi,useActionState:gi,useOptimistic:gi,useMemoCache:gi,useCacheRefresh:gi};Qm.useEffectEvent=gi;var N5={readContext:ca,use:v1,useCallback:function(n,e){return Ra().memoizedState=[n,e===void 0?null:e],n},useContext:ca,useEffect:xC,useImperativeHandle:function(n,e,t){t=t!=null?t.concat([n]):null,a_(4194308,4,v5.bind(null,e,n),t)},useLayoutEffect:function(n,e){return a_(4194308,4,n,e)},useInsertionEffect:function(n,e){a_(4,2,n,e)},useMemo:function(n,e){var t=Ra();e=e===void 0?null:e;var i=n();if(Gu){Wl(!0);try{n()}finally{Wl(!1)}}return t.memoizedState=[i,e],i},useReducer:function(n,e,t){var i=Ra();if(t!==void 0){var a=t(e);if(Gu){Wl(!0);try{t(e)}finally{Wl(!1)}}}else a=e;return i.memoizedState=i.baseState=a,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:a},i.queue=n,n=n.dispatch=iH.bind(null,jt,n),[i.memoizedState,n]},useRef:function(n){var e=Ra();return n={current:n},e.memoizedState=n},useState:function(n){n=C3(n);var e=n.queue,t=R5.bind(null,jt,e);return e.dispatch=t,[n.memoizedState,t]},useDebugValue:VM,useDeferredValue:function(n,e){var t=Ra();return kM(t,n,e)},useTransition:function(){var n=C3(!1);return n=T5.bind(null,jt,n.queue,!0,!1),Ra().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,e,t){var i=jt,a=Ra();if(un){if(t===void 0)throw Error(Ue(407));t=t()}else{if(t=e(),Hn===null)throw Error(Ue(349));cn&127||i5(i,e,t)}a.memoizedState=t;var r={value:t,getSnapshot:e};return a.queue=r,xC(r5.bind(null,i,r,n),[n]),i.flags|=2048,hd(9,{destroy:void 0},a5.bind(null,i,r,t,e),null),t},useId:function(){var n=Ra(),e=Hn.identifierPrefix;if(un){var t=$s,i=Js;t=(i&~(1<<32-Rr(i)-1)).toString(32)+t,e="_"+e+"R_"+t,t=U_++,0<t&&(e+="H"+t.toString(32)),e+="_"}else t=KB++,e="_"+e+"r_"+t.toString(32)+"_";return n.memoizedState=e},useHostTransitionStatus:WM,useFormState:gC,useActionState:gC,useOptimistic:function(n){var e=Ra();e.memoizedState=e.baseState=n;var t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return e.queue=t,e=XM.bind(null,jt,!0,t),t.dispatch=e,[n,e]},useMemoCache:HM,useCacheRefresh:function(){return Ra().memoizedState=nH.bind(null,jt)},useEffectEvent:function(n){var e=Ra(),t={impl:n};return e.memoizedState=t,function(){if(xn&2)throw Error(Ue(440));return t.impl.apply(void 0,arguments)}}},YM={readContext:ca,use:v1,useCallback:x5,useContext:ca,useEffect:GM,useImperativeHandle:_5,useInsertionEffect:m5,useLayoutEffect:g5,useMemo:y5,useReducer:i_,useRef:d5,useState:function(){return i_(tl)},useDebugValue:VM,useDeferredValue:function(n,e){var t=Si();return S5(t,Pn.memoizedState,n,e)},useTransition:function(){var n=i_(tl)[0],e=Si().memoizedState;return[typeof n=="boolean"?n:b0(n),e]},useSyncExternalStore:n5,useId:b5,useHostTransitionStatus:WM,useFormState:vC,useActionState:vC,useOptimistic:function(n,e){var t=Si();return l5(t,Pn,n,e)},useMemoCache:HM,useCacheRefresh:A5};YM.useEffectEvent=p5;var D5={readContext:ca,use:v1,useCallback:x5,useContext:ca,useEffect:GM,useImperativeHandle:_5,useInsertionEffect:m5,useLayoutEffect:g5,useMemo:y5,useReducer:aT,useRef:d5,useState:function(){return aT(tl)},useDebugValue:VM,useDeferredValue:function(n,e){var t=Si();return Pn===null?kM(t,n,e):S5(t,Pn.memoizedState,n,e)},useTransition:function(){var n=aT(tl)[0],e=Si().memoizedState;return[typeof n=="boolean"?n:b0(n),e]},useSyncExternalStore:n5,useId:b5,useHostTransitionStatus:WM,useFormState:_C,useActionState:_C,useOptimistic:function(n,e){var t=Si();return Pn!==null?l5(t,Pn,n,e):(t.baseState=n,[n,t.queue.dispatch])},useMemoCache:HM,useCacheRefresh:A5};D5.useEffectEvent=p5;function rT(n,e,t,i){e=n.memoizedState,t=t(i,e),t=t==null?e:ti({},e,t),n.memoizedState=t,n.lanes===0&&(n.updateQueue.baseState=t)}var O3={enqueueSetState:function(n,e,t){n=n._reactInternals;var i=wr(),a=ec(i);a.payload=e,t!=null&&(a.callback=t),e=tc(n,a,i),e!==null&&(Qa(e,n,i),ym(e,n,i))},enqueueReplaceState:function(n,e,t){n=n._reactInternals;var i=wr(),a=ec(i);a.tag=1,a.payload=e,t!=null&&(a.callback=t),e=tc(n,a,i),e!==null&&(Qa(e,n,i),ym(e,n,i))},enqueueForceUpdate:function(n,e){n=n._reactInternals;var t=wr(),i=ec(t);i.tag=2,e!=null&&(i.callback=e),e=tc(n,i,t),e!==null&&(Qa(e,n,t),ym(e,n,t))}};function yC(n,e,t,i,a,r,s){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(i,r,s):e.prototype&&e.prototype.isPureReactComponent?!Ym(t,i)||!Ym(a,r):!0}function SC(n,e,t,i){n=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(t,i),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(t,i),e.state!==n&&O3.enqueueReplaceState(e,e.state,null)}function Vu(n,e){var t=e;if("ref"in e){t={};for(var i in e)i!=="ref"&&(t[i]=e[i])}if(n=n.defaultProps){t===e&&(t=ti({},t));for(var a in n)t[a]===void 0&&(t[a]=n[a])}return t}function O5(n){R_(n)}function L5(n){console.error(n)}function I5(n){R_(n)}function P_(n,e){try{var t=n.onUncaughtError;t(e.value,{componentStack:e.stack})}catch(i){setTimeout(function(){throw i})}}function TC(n,e,t){try{var i=n.onCaughtError;i(t.value,{componentStack:t.stack,errorBoundary:e.tag===1?e.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function L3(n,e,t){return t=ec(t),t.tag=3,t.payload={element:null},t.callback=function(){P_(n,e)},t}function U5(n){return n=ec(n),n.tag=3,n}function P5(n,e,t,i){var a=t.type.getDerivedStateFromError;if(typeof a=="function"){var r=i.value;n.payload=function(){return a(r)},n.callback=function(){TC(e,t,i)}}var s=t.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){TC(e,t,i),typeof a!="function"&&(nc===null?nc=new Set([this]):nc.add(this));var o=i.stack;this.componentDidCatch(i.value,{componentStack:o!==null?o:""})})}function aH(n,e,t,i,a){if(t.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(e=t.alternate,e!==null&&Bd(e,t,a,!0),t=Dr.current,t!==null){switch(t.tag){case 31:case 13:return es===null?G_():t.alternate===null&&vi===0&&(vi=3),t.flags&=-257,t.flags|=65536,t.lanes=a,i===D_?t.flags|=16384:(e=t.updateQueue,e===null?t.updateQueue=new Set([i]):e.add(i),gT(n,i,a)),!1;case 22:return t.flags|=65536,i===D_?t.flags|=16384:(e=t.updateQueue,e===null?(e={transitions:null,markerInstances:null,retryQueue:new Set([i])},t.updateQueue=e):(t=e.retryQueue,t===null?e.retryQueue=new Set([i]):t.add(i)),gT(n,i,a)),!1}throw Error(Ue(435,t.tag))}return gT(n,i,a),G_(),!1}if(un)return e=Dr.current,e!==null?(!(e.flags&65536)&&(e.flags|=256),e.flags|=65536,e.lanes=a,i!==y3&&(n=Error(Ue(422),{cause:i}),jm(Qr(n,t)))):(i!==y3&&(e=Error(Ue(423),{cause:i}),jm(Qr(e,t))),n=n.current.alternate,n.flags|=65536,a&=-a,n.lanes|=a,i=Qr(i,t),a=L3(n.stateNode,i,a),iT(n,a),vi!==4&&(vi=2)),!1;var r=Error(Ue(520),{cause:i});if(r=Qr(r,t),Am===null?Am=[r]:Am.push(r),vi!==4&&(vi=2),e===null)return!0;i=Qr(i,t),t=e;do{switch(t.tag){case 3:return t.flags|=65536,n=a&-a,t.lanes|=n,n=L3(t.stateNode,i,n),iT(t,n),!1;case 1:if(e=t.type,r=t.stateNode,(t.flags&128)===0&&(typeof e.getDerivedStateFromError=="function"||r!==null&&typeof r.componentDidCatch=="function"&&(nc===null||!nc.has(r))))return t.flags|=65536,a&=-a,t.lanes|=a,a=U5(a),P5(a,n,t,i),iT(t,a),!1}t=t.return}while(t!==null);return!1}var qM=Error(Ue(461)),Di=!1;function ra(n,e,t,i){e.child=n===null?KL(e,null,t,i):Fu(e,n.child,t,i)}function EC(n,e,t,i,a){t=t.render;var r=e.ref;if("ref"in i){var s={};for(var o in i)o!=="ref"&&(s[o]=i[o])}else s=i;return Hu(e),i=UM(n,e,t,s,r,a),o=PM(),n!==null&&!Di?(zM(n,e,a),nl(n,e,a)):(un&&o&&RM(e),e.flags|=1,ra(n,e,i,a),e.child)}function MC(n,e,t,i,a){if(n===null){var r=t.type;return typeof r=="function"&&!AM(r)&&r.defaultProps===void 0&&t.compare===null?(e.tag=15,e.type=r,z5(n,e,r,i,a)):(n=t_(t.type,null,i,e,e.mode,a),n.ref=e.ref,n.return=e,e.child=n)}if(r=n.child,!jM(n,a)){var s=r.memoizedProps;if(t=t.compare,t=t!==null?t:Ym,t(s,i)&&n.ref===e.ref)return nl(n,e,a)}return e.flags|=1,n=jo(r,i),n.ref=e.ref,n.return=e,e.child=n}function z5(n,e,t,i,a){if(n!==null){var r=n.memoizedProps;if(Ym(r,i)&&n.ref===e.ref)if(Di=!1,e.pendingProps=i=r,jM(n,a))n.flags&131072&&(Di=!0);else return e.lanes=n.lanes,nl(n,e,a)}return I3(n,e,t,i,a)}function B5(n,e,t,i){var a=i.children,r=n!==null?n.memoizedState:null;if(n===null&&e.stateNode===null&&(e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if(e.flags&128){if(r=r!==null?r.baseLanes|t:t,n!==null){for(i=e.child=n.child,a=0;i!==null;)a=a|i.lanes|i.childLanes,i=i.sibling;i=a&~r}else i=0,e.child=null;return bC(n,e,r,t,i)}if(t&536870912)e.memoizedState={baseLanes:0,cachePool:null},n!==null&&n_(e,r!==null?r.cachePool:null),r!==null?dC(e,r):R3(),$L(e);else return i=e.lanes=536870912,bC(n,e,r!==null?r.baseLanes|t:t,t,i)}else r!==null?(n_(e,r.cachePool),dC(e,r),Gl(),e.memoizedState=null):(n!==null&&n_(e,null),R3(),Gl());return ra(n,e,a,t),e.child}function rm(n,e){return n!==null&&n.tag===22||e.stateNode!==null||(e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),e.sibling}function bC(n,e,t,i,a){var r=NM();return r=r===null?null:{parent:Ni._currentValue,pool:r},e.memoizedState={baseLanes:t,cachePool:r},n!==null&&n_(e,null),R3(),$L(e),n!==null&&Bd(n,e,i,!0),e.childLanes=a,null}function r_(n,e){return e=z_({mode:e.mode,children:e.children},n.mode),e.ref=n.ref,n.child=e,e.return=n,e}function AC(n,e,t){return Fu(e,n.child,null,t),n=r_(e,e.pendingProps),n.flags|=2,yr(e),e.memoizedState=null,n}function rH(n,e,t){var i=e.pendingProps,a=(e.flags&128)!==0;if(e.flags&=-129,n===null){if(un){if(i.mode==="hidden")return n=r_(e,i),e.lanes=536870912,rm(null,n);if(w3(e),(n=Qn)?(n=NI(n,Jr),n=n!==null&&n.data==="&"?n:null,n!==null&&(e.memoizedState={dehydrated:n,treeContext:cc!==null?{id:Js,overflow:$s}:null,retryLane:536870912,hydrationErrors:null},t=kL(n),t.return=e,e.child=t,oa=e,Qn=null)):n=null,n===null)throw uc(e);return e.lanes=536870912,null}return r_(e,i)}var r=n.memoizedState;if(r!==null){var s=r.dehydrated;if(w3(e),a)if(e.flags&256)e.flags&=-257,e=AC(n,e,t);else if(e.memoizedState!==null)e.child=n.child,e.flags|=128,e=null;else throw Error(Ue(558));else if(Di||Bd(n,e,t,!1),a=(t&n.childLanes)!==0,Di||a){if(i=Hn,i!==null&&(s=mL(i,t),s!==0&&s!==r.retryLane))throw r.retryLane=s,ah(n,s),Qa(i,n,s),qM;G_(),e=AC(n,e,t)}else n=r.treeContext,Qn=ts(s.nextSibling),oa=e,un=!0,$l=null,Jr=!1,n!==null&&XL(e,n),e=r_(e,i),e.flags|=4096;return e}return n=jo(n.child,{mode:i.mode,children:i.children}),n.ref=e.ref,e.child=n,n.return=e,n}function s_(n,e){var t=e.ref;if(t===null)n!==null&&n.ref!==null&&(e.flags|=4194816);else{if(typeof t!="function"&&typeof t!="object")throw Error(Ue(284));(n===null||n.ref!==t)&&(e.flags|=4194816)}}function I3(n,e,t,i,a){return Hu(e),t=UM(n,e,t,i,void 0,a),i=PM(),n!==null&&!Di?(zM(n,e,a),nl(n,e,a)):(un&&i&&RM(e),e.flags|=1,ra(n,e,t,a),e.child)}function RC(n,e,t,i,a,r){return Hu(e),e.updateQueue=null,t=t5(e,i,t,a),e5(n),i=PM(),n!==null&&!Di?(zM(n,e,r),nl(n,e,r)):(un&&i&&RM(e),e.flags|=1,ra(n,e,t,r),e.child)}function wC(n,e,t,i,a){if(Hu(e),e.stateNode===null){var r=zf,s=t.contextType;typeof s=="object"&&s!==null&&(r=ca(s)),r=new t(i,r),e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=O3,e.stateNode=r,r._reactInternals=e,r=e.stateNode,r.props=i,r.state=e.memoizedState,r.refs={},OM(e),s=t.contextType,r.context=typeof s=="object"&&s!==null?ca(s):zf,r.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(rT(e,t,s,i),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(s=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),s!==r.state&&O3.enqueueReplaceState(r,r.state,null),Tm(e,i,r,a),Sm(),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308),i=!0}else if(n===null){r=e.stateNode;var o=e.memoizedProps,c=Vu(t,o);r.props=c;var h=r.context,f=t.contextType;s=zf,typeof f=="object"&&f!==null&&(s=ca(f));var d=t.getDerivedStateFromProps;f=typeof d=="function"||typeof r.getSnapshotBeforeUpdate=="function",o=e.pendingProps!==o,f||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(o||h!==s)&&SC(e,r,i,s),Bl=!1;var m=e.memoizedState;r.state=m,Tm(e,i,r,a),Sm(),h=e.memoizedState,o||m!==h||Bl?(typeof d=="function"&&(rT(e,t,d,i),h=e.memoizedState),(c=Bl||yC(e,t,c,i,m,h,s))?(f||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount()),typeof r.componentDidMount=="function"&&(e.flags|=4194308)):(typeof r.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=i,e.memoizedState=h),r.props=i,r.state=h,r.context=s,i=c):(typeof r.componentDidMount=="function"&&(e.flags|=4194308),i=!1)}else{r=e.stateNode,b3(n,e),s=e.memoizedProps,f=Vu(t,s),r.props=f,d=e.pendingProps,m=r.context,h=t.contextType,c=zf,typeof h=="object"&&h!==null&&(c=ca(h)),o=t.getDerivedStateFromProps,(h=typeof o=="function"||typeof r.getSnapshotBeforeUpdate=="function")||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(s!==d||m!==c)&&SC(e,r,i,c),Bl=!1,m=e.memoizedState,r.state=m,Tm(e,i,r,a),Sm();var g=e.memoizedState;s!==d||m!==g||Bl||n!==null&&n.dependencies!==null&&N_(n.dependencies)?(typeof o=="function"&&(rT(e,t,o,i),g=e.memoizedState),(f=Bl||yC(e,t,f,i,m,g,c)||n!==null&&n.dependencies!==null&&N_(n.dependencies))?(h||typeof r.UNSAFE_componentWillUpdate!="function"&&typeof r.componentWillUpdate!="function"||(typeof r.componentWillUpdate=="function"&&r.componentWillUpdate(i,g,c),typeof r.UNSAFE_componentWillUpdate=="function"&&r.UNSAFE_componentWillUpdate(i,g,c)),typeof r.componentDidUpdate=="function"&&(e.flags|=4),typeof r.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof r.componentDidUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),e.memoizedProps=i,e.memoizedState=g),r.props=i,r.state=g,r.context=c,i=f):(typeof r.componentDidUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),i=!1)}return r=i,s_(n,e),i=(e.flags&128)!==0,r||i?(r=e.stateNode,t=i&&typeof t.getDerivedStateFromError!="function"?null:r.render(),e.flags|=1,n!==null&&i?(e.child=Fu(e,n.child,null,a),e.child=Fu(e,null,t,a)):ra(n,e,t,a),e.memoizedState=r.state,n=e.child):n=nl(n,e,a),n}function CC(n,e,t,i){return Bu(),e.flags|=256,ra(n,e,t,i),e.child}var sT={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function oT(n){return{baseLanes:n,cachePool:qL()}}function lT(n,e,t){return n=n!==null?n.childLanes&~t:0,e&&(n|=Tr),n}function H5(n,e,t){var i=e.pendingProps,a=!1,r=(e.flags&128)!==0,s;if((s=r)||(s=n!==null&&n.memoizedState===null?!1:(yi.current&2)!==0),s&&(a=!0,e.flags&=-129),s=(e.flags&32)!==0,e.flags&=-33,n===null){if(un){if(a?Fl(e):Gl(),(n=Qn)?(n=NI(n,Jr),n=n!==null&&n.data!=="&"?n:null,n!==null&&(e.memoizedState={dehydrated:n,treeContext:cc!==null?{id:Js,overflow:$s}:null,retryLane:536870912,hydrationErrors:null},t=kL(n),t.return=e,e.child=t,oa=e,Qn=null)):n=null,n===null)throw uc(e);return j3(n)?e.lanes=32:e.lanes=536870912,null}var o=i.children;return i=i.fallback,a?(Gl(),a=e.mode,o=z_({mode:"hidden",children:o},a),i=wu(i,a,t,null),o.return=e,i.return=e,o.sibling=i,e.child=o,i=e.child,i.memoizedState=oT(t),i.childLanes=lT(n,s,t),e.memoizedState=sT,rm(null,i)):(Fl(e),U3(e,o))}var c=n.memoizedState;if(c!==null&&(o=c.dehydrated,o!==null)){if(r)e.flags&256?(Fl(e),e.flags&=-257,e=cT(n,e,t)):e.memoizedState!==null?(Gl(),e.child=n.child,e.flags|=128,e=null):(Gl(),o=i.fallback,a=e.mode,i=z_({mode:"visible",children:i.children},a),o=wu(o,a,t,null),o.flags|=2,i.return=e,o.return=e,i.sibling=o,e.child=i,Fu(e,n.child,null,t),i=e.child,i.memoizedState=oT(t),i.childLanes=lT(n,s,t),e.memoizedState=sT,e=rm(null,i));else if(Fl(e),j3(o)){if(s=o.nextSibling&&o.nextSibling.dataset,s)var h=s.dgst;s=h,i=Error(Ue(419)),i.stack="",i.digest=s,jm({value:i,source:null,stack:null}),e=cT(n,e,t)}else if(Di||Bd(n,e,t,!1),s=(t&n.childLanes)!==0,Di||s){if(s=Hn,s!==null&&(i=mL(s,t),i!==0&&i!==c.retryLane))throw c.retryLane=i,ah(n,i),Qa(s,n,i),qM;q3(o)||G_(),e=cT(n,e,t)}else q3(o)?(e.flags|=192,e.child=n.child,e=null):(n=c.treeContext,Qn=ts(o.nextSibling),oa=e,un=!0,$l=null,Jr=!1,n!==null&&XL(e,n),e=U3(e,i.children),e.flags|=4096);return e}return a?(Gl(),o=i.fallback,a=e.mode,c=n.child,h=c.sibling,i=jo(c,{mode:"hidden",children:i.children}),i.subtreeFlags=c.subtreeFlags&65011712,h!==null?o=jo(h,o):(o=wu(o,a,t,null),o.flags|=2),o.return=e,i.return=e,i.sibling=o,e.child=i,rm(null,i),i=e.child,o=n.child.memoizedState,o===null?o=oT(t):(a=o.cachePool,a!==null?(c=Ni._currentValue,a=a.parent!==c?{parent:c,pool:c}:a):a=qL(),o={baseLanes:o.baseLanes|t,cachePool:a}),i.memoizedState=o,i.childLanes=lT(n,s,t),e.memoizedState=sT,rm(n.child,i)):(Fl(e),t=n.child,n=t.sibling,t=jo(t,{mode:"visible",children:i.children}),t.return=e,t.sibling=null,n!==null&&(s=e.deletions,s===null?(e.deletions=[n],e.flags|=16):s.push(n)),e.child=t,e.memoizedState=null,t)}function U3(n,e){return e=z_({mode:"visible",children:e},n.mode),e.return=n,n.child=e}function z_(n,e){return n=Sr(22,n,null,e),n.lanes=0,n}function cT(n,e,t){return Fu(e,n.child,null,t),n=U3(e,e.pendingProps.children),n.flags|=2,e.memoizedState=null,n}function NC(n,e,t){n.lanes|=e;var i=n.alternate;i!==null&&(i.lanes|=e),T3(n.return,e,t)}function uT(n,e,t,i,a,r){var s=n.memoizedState;s===null?n.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:i,tail:t,tailMode:a,treeForkCount:r}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=t,s.tailMode=a,s.treeForkCount=r)}function F5(n,e,t){var i=e.pendingProps,a=i.revealOrder,r=i.tail;i=i.children;var s=yi.current,o=(s&2)!==0;if(o?(s=s&1|2,e.flags|=128):s&=1,Yn(yi,s),ra(n,e,i,t),i=un?qm:0,!o&&n!==null&&n.flags&128)e:for(n=e.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&NC(n,t,e);else if(n.tag===19)NC(n,t,e);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(a){case"forwards":for(t=e.child,a=null;t!==null;)n=t.alternate,n!==null&&L_(n)===null&&(a=t),t=t.sibling;t=a,t===null?(a=e.child,e.child=null):(a=t.sibling,t.sibling=null),uT(e,!1,a,t,r,i);break;case"backwards":case"unstable_legacy-backwards":for(t=null,a=e.child,e.child=null;a!==null;){if(n=a.alternate,n!==null&&L_(n)===null){e.child=a;break}n=a.sibling,a.sibling=t,t=a,a=n}uT(e,!0,t,null,r,i);break;case"together":uT(e,!1,null,null,void 0,i);break;default:e.memoizedState=null}return e.child}function nl(n,e,t){if(n!==null&&(e.dependencies=n.dependencies),fc|=e.lanes,!(t&e.childLanes))if(n!==null){if(Bd(n,e,t,!1),(t&e.childLanes)===0)return null}else return null;if(n!==null&&e.child!==n.child)throw Error(Ue(153));if(e.child!==null){for(n=e.child,t=jo(n,n.pendingProps),e.child=t,t.return=e;n.sibling!==null;)n=n.sibling,t=t.sibling=jo(n,n.pendingProps),t.return=e;t.sibling=null}return e.child}function jM(n,e){return n.lanes&e?!0:(n=n.dependencies,!!(n!==null&&N_(n)))}function sH(n,e,t){switch(e.tag){case 3:E_(e,e.stateNode.containerInfo),Hl(e,Ni,n.memoizedState.cache),Bu();break;case 27:case 5:c3(e);break;case 4:E_(e,e.stateNode.containerInfo);break;case 10:Hl(e,e.type,e.memoizedProps.value);break;case 31:if(e.memoizedState!==null)return e.flags|=128,w3(e),null;break;case 13:var i=e.memoizedState;if(i!==null)return i.dehydrated!==null?(Fl(e),e.flags|=128,null):t&e.child.childLanes?H5(n,e,t):(Fl(e),n=nl(n,e,t),n!==null?n.sibling:null);Fl(e);break;case 19:var a=(n.flags&128)!==0;if(i=(t&e.childLanes)!==0,i||(Bd(n,e,t,!1),i=(t&e.childLanes)!==0),a){if(i)return F5(n,e,t);e.flags|=128}if(a=e.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Yn(yi,yi.current),i)break;return null;case 22:return e.lanes=0,B5(n,e,t,e.pendingProps);case 24:Hl(e,Ni,n.memoizedState.cache)}return nl(n,e,t)}function G5(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps)Di=!0;else{if(!jM(n,t)&&!(e.flags&128))return Di=!1,sH(n,e,t);Di=!!(n.flags&131072)}else Di=!1,un&&e.flags&1048576&&WL(e,qm,e.index);switch(e.lanes=0,e.tag){case 16:e:{var i=e.pendingProps;if(n=du(e.elementType),e.type=n,typeof n=="function")AM(n)?(i=Vu(n,i),e.tag=1,e=wC(null,e,n,i,t)):(e.tag=0,e=I3(null,e,n,i,t));else{if(n!=null){var a=n.$$typeof;if(a===fM){e.tag=11,e=EC(null,e,n,i,t);break e}else if(a===dM){e.tag=14,e=MC(null,e,n,i,t);break e}}throw e=o3(n)||n,Error(Ue(306,e,""))}}return e;case 0:return I3(n,e,e.type,e.pendingProps,t);case 1:return i=e.type,a=Vu(i,e.pendingProps),wC(n,e,i,a,t);case 3:e:{if(E_(e,e.stateNode.containerInfo),n===null)throw Error(Ue(387));i=e.pendingProps;var r=e.memoizedState;a=r.element,b3(n,e),Tm(e,i,null,t);var s=e.memoizedState;if(i=s.cache,Hl(e,Ni,i),i!==r.cache&&E3(e,[Ni],t,!0),Sm(),i=s.element,r.isDehydrated)if(r={element:i,isDehydrated:!1,cache:s.cache},e.updateQueue.baseState=r,e.memoizedState=r,e.flags&256){e=CC(n,e,i,t);break e}else if(i!==a){a=Qr(Error(Ue(424)),e),jm(a),e=CC(n,e,i,t);break e}else{switch(n=e.stateNode.containerInfo,n.nodeType){case 9:n=n.body;break;default:n=n.nodeName==="HTML"?n.ownerDocument.body:n}for(Qn=ts(n.firstChild),oa=e,un=!0,$l=null,Jr=!0,t=KL(e,null,i,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling}else{if(Bu(),i===a){e=nl(n,e,t);break e}ra(n,e,i,t)}e=e.child}return e;case 26:return s_(n,e),n===null?(t=KC(e.type,null,e.pendingProps,null))?e.memoizedState=t:un||(t=e.type,n=e.pendingProps,i=X_(Jl.current).createElement(t),i[sa]=e,i[$a]=n,ua(i,t,n),Ji(i),e.stateNode=i):e.memoizedState=KC(e.type,n.memoizedProps,e.pendingProps,n.memoizedState),null;case 27:return c3(e),n===null&&un&&(i=e.stateNode=DI(e.type,e.pendingProps,Jl.current),oa=e,Jr=!0,a=Qn,xc(e.type)?(Z3=a,Qn=ts(i.firstChild)):Qn=a),ra(n,e,e.pendingProps.children,t),s_(n,e),n===null&&(e.flags|=4194304),e.child;case 5:return n===null&&un&&((a=i=Qn)&&(i=PH(i,e.type,e.pendingProps,Jr),i!==null?(e.stateNode=i,oa=e,Qn=ts(i.firstChild),Jr=!1,a=!0):a=!1),a||uc(e)),c3(e),a=e.type,r=e.pendingProps,s=n!==null?n.memoizedProps:null,i=r.children,X3(a,r)?i=null:s!==null&&X3(a,s)&&(e.flags|=32),e.memoizedState!==null&&(a=UM(n,e,QB,null,null,t),e0._currentValue=a),s_(n,e),ra(n,e,i,t),e.child;case 6:return n===null&&un&&((n=t=Qn)&&(t=zH(t,e.pendingProps,Jr),t!==null?(e.stateNode=t,oa=e,Qn=null,n=!0):n=!1),n||uc(e)),null;case 13:return H5(n,e,t);case 4:return E_(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Fu(e,null,i,t):ra(n,e,i,t),e.child;case 11:return EC(n,e,e.type,e.pendingProps,t);case 7:return ra(n,e,e.pendingProps,t),e.child;case 8:return ra(n,e,e.pendingProps.children,t),e.child;case 12:return ra(n,e,e.pendingProps.children,t),e.child;case 10:return i=e.pendingProps,Hl(e,e.type,i.value),ra(n,e,i.children,t),e.child;case 9:return a=e.type._context,i=e.pendingProps.children,Hu(e),a=ca(a),i=i(a),e.flags|=1,ra(n,e,i,t),e.child;case 14:return MC(n,e,e.type,e.pendingProps,t);case 15:return z5(n,e,e.type,e.pendingProps,t);case 19:return F5(n,e,t);case 31:return rH(n,e,t);case 22:return B5(n,e,t,e.pendingProps);case 24:return Hu(e),i=ca(Ni),n===null?(a=NM(),a===null&&(a=Hn,r=CM(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=t),a=r),e.memoizedState={parent:i,cache:a},OM(e),Hl(e,Ni,a)):(n.lanes&t&&(b3(n,e),Tm(e,null,null,t),Sm()),a=n.memoizedState,r=e.memoizedState,a.parent!==i?(a={parent:i,cache:i},e.memoizedState=a,e.lanes===0&&(e.memoizedState=e.updateQueue.baseState=a),Hl(e,Ni,i)):(i=r.cache,Hl(e,Ni,i),i!==a.cache&&E3(e,[Ni],t,!0))),ra(n,e,e.pendingProps.children,t),e.child;case 29:throw e.pendingProps}throw Error(Ue(156,e.tag))}function Mo(n){n.flags|=4}function hT(n,e,t,i,a){if((e=(n.mode&32)!==0)&&(e=!1),e){if(n.flags|=16777216,(a&335544128)===a)if(n.stateNode.complete)n.flags|=8192;else if(hI())n.flags|=8192;else throw Nu=D_,DM}else n.flags&=-16777217}function DC(n,e){if(e.type!=="stylesheet"||e.state.loading&4)n.flags&=-16777217;else if(n.flags|=16777216,!II(e))if(hI())n.flags|=8192;else throw Nu=D_,DM}function Bg(n,e){e!==null&&(n.flags|=4),n.flags&16384&&(e=n.tag!==22?fL():536870912,n.lanes|=e,fd|=e)}function wp(n,e){if(!un)switch(n.tailMode){case"hidden":e=n.tail;for(var t=null;e!==null;)e.alternate!==null&&(t=e),e=e.sibling;t===null?n.tail=null:t.sibling=null;break;case"collapsed":t=n.tail;for(var i=null;t!==null;)t.alternate!==null&&(i=t),t=t.sibling;i===null?e||n.tail===null?n.tail=null:n.tail.sibling=null:i.sibling=null}}function Kn(n){var e=n.alternate!==null&&n.alternate.child===n.child,t=0,i=0;if(e)for(var a=n.child;a!==null;)t|=a.lanes|a.childLanes,i|=a.subtreeFlags&65011712,i|=a.flags&65011712,a.return=n,a=a.sibling;else for(a=n.child;a!==null;)t|=a.lanes|a.childLanes,i|=a.subtreeFlags,i|=a.flags,a.return=n,a=a.sibling;return n.subtreeFlags|=i,n.childLanes=t,e}function oH(n,e,t){var i=e.pendingProps;switch(wM(e),e.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kn(e),null;case 1:return Kn(e),null;case 3:return t=e.stateNode,i=null,n!==null&&(i=n.memoizedState.cache),e.memoizedState.cache!==i&&(e.flags|=2048),Zo(Ni),sd(),t.pendingContext&&(t.context=t.pendingContext,t.pendingContext=null),(n===null||n.child===null)&&(Gh(e)?Mo(e):n===null||n.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,nT())),Kn(e),null;case 26:var a=e.type,r=e.memoizedState;return n===null?(Mo(e),r!==null?(Kn(e),DC(e,r)):(Kn(e),hT(e,a,null,i,t))):r?r!==n.memoizedState?(Mo(e),Kn(e),DC(e,r)):(Kn(e),e.flags&=-16777217):(n=n.memoizedProps,n!==i&&Mo(e),Kn(e),hT(e,a,n,i,t)),null;case 27:if(M_(e),t=Jl.current,a=e.type,n!==null&&e.stateNode!=null)n.memoizedProps!==i&&Mo(e);else{if(!i){if(e.stateNode===null)throw Error(Ue(166));return Kn(e),null}n=no.current,Gh(e)?sC(e):(n=DI(a,i,t),e.stateNode=n,Mo(e))}return Kn(e),null;case 5:if(M_(e),a=e.type,n!==null&&e.stateNode!=null)n.memoizedProps!==i&&Mo(e);else{if(!i){if(e.stateNode===null)throw Error(Ue(166));return Kn(e),null}if(r=no.current,Gh(e))sC(e);else{var s=X_(Jl.current);switch(r){case 1:r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":r=s.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild);break;case"select":r=typeof i.is=="string"?s.createElement("select",{is:i.is}):s.createElement("select"),i.multiple?r.multiple=!0:i.size&&(r.size=i.size);break;default:r=typeof i.is=="string"?s.createElement(a,{is:i.is}):s.createElement(a)}}r[sa]=e,r[$a]=i;e:for(s=e.child;s!==null;){if(s.tag===5||s.tag===6)r.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break e;for(;s.sibling===null;){if(s.return===null||s.return===e)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}e.stateNode=r;e:switch(ua(r,a,i),a){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Mo(e)}}return Kn(e),hT(e,e.type,n===null?null:n.memoizedProps,e.pendingProps,t),null;case 6:if(n&&e.stateNode!=null)n.memoizedProps!==i&&Mo(e);else{if(typeof i!="string"&&e.stateNode===null)throw Error(Ue(166));if(n=Jl.current,Gh(e)){if(n=e.stateNode,t=e.memoizedProps,i=null,a=oa,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}n[sa]=e,n=!!(n.nodeValue===t||i!==null&&i.suppressHydrationWarning===!0||RI(n.nodeValue,t)),n||uc(e,!0)}else n=X_(n).createTextNode(i),n[sa]=e,e.stateNode=n}return Kn(e),null;case 31:if(t=e.memoizedState,n===null||n.memoizedState!==null){if(i=Gh(e),t!==null){if(n===null){if(!i)throw Error(Ue(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(Ue(557));n[sa]=e}else Bu(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Kn(e),n=!1}else t=nT(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=t),n=!0;if(!n)return e.flags&256?(yr(e),e):(yr(e),null);if(e.flags&128)throw Error(Ue(558))}return Kn(e),null;case 13:if(i=e.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(a=Gh(e),i!==null&&i.dehydrated!==null){if(n===null){if(!a)throw Error(Ue(318));if(a=e.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(Ue(317));a[sa]=e}else Bu(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Kn(e),a=!1}else a=nT(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=a),a=!0;if(!a)return e.flags&256?(yr(e),e):(yr(e),null)}return yr(e),e.flags&128?(e.lanes=t,e):(t=i!==null,n=n!==null&&n.memoizedState!==null,t&&(i=e.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),r=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(r=i.memoizedState.cachePool.pool),r!==a&&(i.flags|=2048)),t!==n&&t&&(e.child.flags|=8192),Bg(e,e.updateQueue),Kn(e),null);case 4:return sd(),n===null&&tb(e.stateNode.containerInfo),Kn(e),null;case 10:return Zo(e.type),Kn(e),null;case 19:if($i(yi),i=e.memoizedState,i===null)return Kn(e),null;if(a=(e.flags&128)!==0,r=i.rendering,r===null)if(a)wp(i,!1);else{if(vi!==0||n!==null&&n.flags&128)for(n=e.child;n!==null;){if(r=L_(n),r!==null){for(e.flags|=128,wp(i,!1),n=r.updateQueue,e.updateQueue=n,Bg(e,n),e.subtreeFlags=0,n=t,t=e.child;t!==null;)VL(t,n),t=t.sibling;return Yn(yi,yi.current&1|2),un&&Ho(e,i.treeForkCount),e.child}n=n.sibling}i.tail!==null&&br()>H_&&(e.flags|=128,a=!0,wp(i,!1),e.lanes=4194304)}else{if(!a)if(n=L_(r),n!==null){if(e.flags|=128,a=!0,n=n.updateQueue,e.updateQueue=n,Bg(e,n),wp(i,!0),i.tail===null&&i.tailMode==="hidden"&&!r.alternate&&!un)return Kn(e),null}else 2*br()-i.renderingStartTime>H_&&t!==536870912&&(e.flags|=128,a=!0,wp(i,!1),e.lanes=4194304);i.isBackwards?(r.sibling=e.child,e.child=r):(n=i.last,n!==null?n.sibling=r:e.child=r,i.last=r)}return i.tail!==null?(n=i.tail,i.rendering=n,i.tail=n.sibling,i.renderingStartTime=br(),n.sibling=null,t=yi.current,Yn(yi,a?t&1|2:t&1),un&&Ho(e,i.treeForkCount),n):(Kn(e),null);case 22:case 23:return yr(e),LM(),i=e.memoizedState!==null,n!==null?n.memoizedState!==null!==i&&(e.flags|=8192):i&&(e.flags|=8192),i?t&536870912&&!(e.flags&128)&&(Kn(e),e.subtreeFlags&6&&(e.flags|=8192)):Kn(e),t=e.updateQueue,t!==null&&Bg(e,t.retryQueue),t=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(t=n.memoizedState.cachePool.pool),i=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),i!==t&&(e.flags|=2048),n!==null&&$i(Cu),null;case 24:return t=null,n!==null&&(t=n.memoizedState.cache),e.memoizedState.cache!==t&&(e.flags|=2048),Zo(Ni),Kn(e),null;case 25:return null;case 30:return null}throw Error(Ue(156,e.tag))}function lH(n,e){switch(wM(e),e.tag){case 1:return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return Zo(Ni),sd(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 26:case 27:case 5:return M_(e),null;case 31:if(e.memoizedState!==null){if(yr(e),e.alternate===null)throw Error(Ue(340));Bu()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 13:if(yr(e),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(Ue(340));Bu()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return $i(yi),null;case 4:return sd(),null;case 10:return Zo(e.type),null;case 22:case 23:return yr(e),LM(),n!==null&&$i(Cu),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 24:return Zo(Ni),null;case 25:return null;default:return null}}function V5(n,e){switch(wM(e),e.tag){case 3:Zo(Ni),sd();break;case 26:case 27:case 5:M_(e);break;case 4:sd();break;case 31:e.memoizedState!==null&&yr(e);break;case 13:yr(e);break;case 19:$i(yi);break;case 10:Zo(e.type);break;case 22:case 23:yr(e),LM(),n!==null&&$i(Cu);break;case 24:Zo(Ni)}}function A0(n,e){try{var t=e.updateQueue,i=t!==null?t.lastEffect:null;if(i!==null){var a=i.next;t=a;do{if((t.tag&n)===n){i=void 0;var r=t.create,s=t.inst;i=r(),s.destroy=i}t=t.next}while(t!==a)}}catch(o){Cn(e,e.return,o)}}function hc(n,e,t){try{var i=e.updateQueue,a=i!==null?i.lastEffect:null;if(a!==null){var r=a.next;i=r;do{if((i.tag&n)===n){var s=i.inst,o=s.destroy;if(o!==void 0){s.destroy=void 0,a=e;var c=t,h=o;try{h()}catch(f){Cn(a,c,f)}}}i=i.next}while(i!==r)}}catch(f){Cn(e,e.return,f)}}function k5(n){var e=n.updateQueue;if(e!==null){var t=n.stateNode;try{JL(e,t)}catch(i){Cn(n,n.return,i)}}}function W5(n,e,t){t.props=Vu(n.type,n.memoizedProps),t.state=n.memoizedState;try{t.componentWillUnmount()}catch(i){Cn(n,e,i)}}function Mm(n,e){try{var t=n.ref;if(t!==null){switch(n.tag){case 26:case 27:case 5:var i=n.stateNode;break;case 30:i=n.stateNode;break;default:i=n.stateNode}typeof t=="function"?n.refCleanup=t(i):t.current=i}}catch(a){Cn(n,e,a)}}function eo(n,e){var t=n.ref,i=n.refCleanup;if(t!==null)if(typeof i=="function")try{i()}catch(a){Cn(n,e,a)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof t=="function")try{t(null)}catch(a){Cn(n,e,a)}else t.current=null}function X5(n){var e=n.type,t=n.memoizedProps,i=n.stateNode;try{e:switch(e){case"button":case"input":case"select":case"textarea":t.autoFocus&&i.focus();break e;case"img":t.src?i.src=t.src:t.srcSet&&(i.srcset=t.srcSet)}}catch(a){Cn(n,n.return,a)}}function fT(n,e,t){try{var i=n.stateNode;NH(i,n.type,t,e),i[$a]=e}catch(a){Cn(n,n.return,a)}}function Y5(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&xc(n.type)||n.tag===4}function dT(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Y5(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&xc(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function P3(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t).insertBefore(n,e):(e=t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,e.appendChild(n),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Yo));else if(i!==4&&(i===27&&xc(n.type)&&(t=n.stateNode,e=null),n=n.child,n!==null))for(P3(n,e,t),n=n.sibling;n!==null;)P3(n,e,t),n=n.sibling}function B_(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(i!==4&&(i===27&&xc(n.type)&&(t=n.stateNode),n=n.child,n!==null))for(B_(n,e,t),n=n.sibling;n!==null;)B_(n,e,t),n=n.sibling}function q5(n){var e=n.stateNode,t=n.memoizedProps;try{for(var i=n.type,a=e.attributes;a.length;)e.removeAttributeNode(a[0]);ua(e,i,t),e[sa]=n,e[$a]=t}catch(r){Cn(n,n.return,r)}}var Go=!1,Ci=!1,pT=!1,OC=typeof WeakSet=="function"?WeakSet:Set,Ki=null;function cH(n,e){if(n=n.containerInfo,k3=Z_,n=IL(n),EM(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var i=t.getSelection&&t.getSelection();if(i&&i.rangeCount!==0){t=i.anchorNode;var a=i.anchorOffset,r=i.focusNode;i=i.focusOffset;try{t.nodeType,r.nodeType}catch{t=null;break e}var s=0,o=-1,c=-1,h=0,f=0,d=n,m=null;t:for(;;){for(var g;d!==t||a!==0&&d.nodeType!==3||(o=s+a),d!==r||i!==0&&d.nodeType!==3||(c=s+i),d.nodeType===3&&(s+=d.nodeValue.length),(g=d.firstChild)!==null;)m=d,d=g;for(;;){if(d===n)break t;if(m===t&&++h===a&&(o=s),m===r&&++f===i&&(c=s),(g=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=g}t=o===-1||c===-1?null:{start:o,end:c}}else t=null}t=t||{start:0,end:0}}else t=null;for(W3={focusedElem:n,selectionRange:t},Z_=!1,Ki=e;Ki!==null;)if(e=Ki,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,Ki=n;else for(;Ki!==null;){switch(e=Ki,r=e.alternate,n=e.flags,e.tag){case 0:if(n&4&&(n=e.updateQueue,n=n!==null?n.events:null,n!==null))for(t=0;t<n.length;t++)a=n[t],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(n&1024&&r!==null){n=void 0,t=e,a=r.memoizedProps,r=r.memoizedState,i=t.stateNode;try{var x=Vu(t.type,a);n=i.getSnapshotBeforeUpdate(x,r),i.__reactInternalSnapshotBeforeUpdate=n}catch(T){Cn(t,t.return,T)}}break;case 3:if(n&1024){if(n=e.stateNode.containerInfo,t=n.nodeType,t===9)Y3(n);else if(t===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Y3(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(n&1024)throw Error(Ue(163))}if(n=e.sibling,n!==null){n.return=e.return,Ki=n;break}Ki=e.return}}function j5(n,e,t){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Ao(n,t),i&4&&A0(5,t);break;case 1:if(Ao(n,t),i&4)if(n=t.stateNode,e===null)try{n.componentDidMount()}catch(s){Cn(t,t.return,s)}else{var a=Vu(t.type,e.memoizedProps);e=e.memoizedState;try{n.componentDidUpdate(a,e,n.__reactInternalSnapshotBeforeUpdate)}catch(s){Cn(t,t.return,s)}}i&64&&k5(t),i&512&&Mm(t,t.return);break;case 3:if(Ao(n,t),i&64&&(n=t.updateQueue,n!==null)){if(e=null,t.child!==null)switch(t.child.tag){case 27:case 5:e=t.child.stateNode;break;case 1:e=t.child.stateNode}try{JL(n,e)}catch(s){Cn(t,t.return,s)}}break;case 27:e===null&&i&4&&q5(t);case 26:case 5:Ao(n,t),e===null&&i&4&&X5(t),i&512&&Mm(t,t.return);break;case 12:Ao(n,t);break;case 31:Ao(n,t),i&4&&Q5(n,t);break;case 13:Ao(n,t),i&4&&J5(n,t),i&64&&(n=t.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(t=_H.bind(null,t),BH(n,t))));break;case 22:if(i=t.memoizedState!==null||Go,!i){e=e!==null&&e.memoizedState!==null||Ci,a=Go;var r=Ci;Go=i,(Ci=e)&&!r?Uo(n,t,(t.subtreeFlags&8772)!==0):Ao(n,t),Go=a,Ci=r}break;case 30:break;default:Ao(n,t)}}function Z5(n){var e=n.alternate;e!==null&&(n.alternate=null,Z5(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&vM(e)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var ni=null,ja=!1;function bo(n,e,t){for(t=t.child;t!==null;)K5(n,e,t),t=t.sibling}function K5(n,e,t){if(Ar&&typeof Ar.onCommitFiberUnmount=="function")try{Ar.onCommitFiberUnmount(x0,t)}catch{}switch(t.tag){case 26:Ci||eo(t,e),bo(n,e,t),t.memoizedState?t.memoizedState.count--:t.stateNode&&(t=t.stateNode,t.parentNode.removeChild(t));break;case 27:Ci||eo(t,e);var i=ni,a=ja;xc(t.type)&&(ni=t.stateNode,ja=!1),bo(n,e,t),wm(t.stateNode),ni=i,ja=a;break;case 5:Ci||eo(t,e);case 6:if(i=ni,a=ja,ni=null,bo(n,e,t),ni=i,ja=a,ni!==null)if(ja)try{(ni.nodeType===9?ni.body:ni.nodeName==="HTML"?ni.ownerDocument.body:ni).removeChild(t.stateNode)}catch(r){Cn(t,e,r)}else try{ni.removeChild(t.stateNode)}catch(r){Cn(t,e,r)}break;case 18:ni!==null&&(ja?(n=ni,XC(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.stateNode),gd(n)):XC(ni,t.stateNode));break;case 4:i=ni,a=ja,ni=t.stateNode.containerInfo,ja=!0,bo(n,e,t),ni=i,ja=a;break;case 0:case 11:case 14:case 15:hc(2,t,e),Ci||hc(4,t,e),bo(n,e,t);break;case 1:Ci||(eo(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"&&W5(t,e,i)),bo(n,e,t);break;case 21:bo(n,e,t);break;case 22:Ci=(i=Ci)||t.memoizedState!==null,bo(n,e,t),Ci=i;break;default:bo(n,e,t)}}function Q5(n,e){if(e.memoizedState===null&&(n=e.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{gd(n)}catch(t){Cn(e,e.return,t)}}}function J5(n,e){if(e.memoizedState===null&&(n=e.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{gd(n)}catch(t){Cn(e,e.return,t)}}function uH(n){switch(n.tag){case 31:case 13:case 19:var e=n.stateNode;return e===null&&(e=n.stateNode=new OC),e;case 22:return n=n.stateNode,e=n._retryCache,e===null&&(e=n._retryCache=new OC),e;default:throw Error(Ue(435,n.tag))}}function Hg(n,e){var t=uH(n);e.forEach(function(i){if(!t.has(i)){t.add(i);var a=xH.bind(null,n,i);i.then(a,a)}})}function Va(n,e){var t=e.deletions;if(t!==null)for(var i=0;i<t.length;i++){var a=t[i],r=n,s=e,o=s;e:for(;o!==null;){switch(o.tag){case 27:if(xc(o.type)){ni=o.stateNode,ja=!1;break e}break;case 5:ni=o.stateNode,ja=!1;break e;case 3:case 4:ni=o.stateNode.containerInfo,ja=!0;break e}o=o.return}if(ni===null)throw Error(Ue(160));K5(r,s,a),ni=null,ja=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(e.subtreeFlags&13886)for(e=e.child;e!==null;)$5(e,n),e=e.sibling}var Es=null;function $5(n,e){var t=n.alternate,i=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:Va(e,n),ka(n),i&4&&(hc(3,n,n.return),A0(3,n),hc(5,n,n.return));break;case 1:Va(e,n),ka(n),i&512&&(Ci||t===null||eo(t,t.return)),i&64&&Go&&(n=n.updateQueue,n!==null&&(i=n.callbacks,i!==null&&(t=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=t===null?i:t.concat(i))));break;case 26:var a=Es;if(Va(e,n),ka(n),i&512&&(Ci||t===null||eo(t,t.return)),i&4){var r=t!==null?t.memoizedState:null;if(i=n.memoizedState,t===null)if(i===null)if(n.stateNode===null){e:{i=n.type,t=n.memoizedProps,a=a.ownerDocument||a;t:switch(i){case"title":r=a.getElementsByTagName("title")[0],(!r||r[T0]||r[sa]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(i),a.head.insertBefore(r,a.querySelector("head > title"))),ua(r,i,t),r[sa]=n,Ji(r),i=r;break e;case"link":var s=JC("link","href",a).get(i+(t.href||""));if(s){for(var o=0;o<s.length;o++)if(r=s[o],r.getAttribute("href")===(t.href==null||t.href===""?null:t.href)&&r.getAttribute("rel")===(t.rel==null?null:t.rel)&&r.getAttribute("title")===(t.title==null?null:t.title)&&r.getAttribute("crossorigin")===(t.crossOrigin==null?null:t.crossOrigin)){s.splice(o,1);break t}}r=a.createElement(i),ua(r,i,t),a.head.appendChild(r);break;case"meta":if(s=JC("meta","content",a).get(i+(t.content||""))){for(o=0;o<s.length;o++)if(r=s[o],r.getAttribute("content")===(t.content==null?null:""+t.content)&&r.getAttribute("name")===(t.name==null?null:t.name)&&r.getAttribute("property")===(t.property==null?null:t.property)&&r.getAttribute("http-equiv")===(t.httpEquiv==null?null:t.httpEquiv)&&r.getAttribute("charset")===(t.charSet==null?null:t.charSet)){s.splice(o,1);break t}}r=a.createElement(i),ua(r,i,t),a.head.appendChild(r);break;default:throw Error(Ue(468,i))}r[sa]=n,Ji(r),i=r}n.stateNode=i}else $C(a,n.type,n.stateNode);else n.stateNode=QC(a,i,n.memoizedProps);else r!==i?(r===null?t.stateNode!==null&&(t=t.stateNode,t.parentNode.removeChild(t)):r.count--,i===null?$C(a,n.type,n.stateNode):QC(a,i,n.memoizedProps)):i===null&&n.stateNode!==null&&fT(n,n.memoizedProps,t.memoizedProps)}break;case 27:Va(e,n),ka(n),i&512&&(Ci||t===null||eo(t,t.return)),t!==null&&i&4&&fT(n,n.memoizedProps,t.memoizedProps);break;case 5:if(Va(e,n),ka(n),i&512&&(Ci||t===null||eo(t,t.return)),n.flags&32){a=n.stateNode;try{ld(a,"")}catch(x){Cn(n,n.return,x)}}i&4&&n.stateNode!=null&&(a=n.memoizedProps,fT(n,a,t!==null?t.memoizedProps:a)),i&1024&&(pT=!0);break;case 6:if(Va(e,n),ka(n),i&4){if(n.stateNode===null)throw Error(Ue(162));i=n.memoizedProps,t=n.stateNode;try{t.nodeValue=i}catch(x){Cn(n,n.return,x)}}break;case 3:if(c_=null,a=Es,Es=Y_(e.containerInfo),Va(e,n),Es=a,ka(n),i&4&&t!==null&&t.memoizedState.isDehydrated)try{gd(e.containerInfo)}catch(x){Cn(n,n.return,x)}pT&&(pT=!1,eI(n));break;case 4:i=Es,Es=Y_(n.stateNode.containerInfo),Va(e,n),ka(n),Es=i;break;case 12:Va(e,n),ka(n);break;case 31:Va(e,n),ka(n),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,Hg(n,i)));break;case 13:Va(e,n),ka(n),n.child.flags&8192&&n.memoizedState!==null!=(t!==null&&t.memoizedState!==null)&&(y1=br()),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,Hg(n,i)));break;case 22:a=n.memoizedState!==null;var c=t!==null&&t.memoizedState!==null,h=Go,f=Ci;if(Go=h||a,Ci=f||c,Va(e,n),Ci=f,Go=h,ka(n),i&8192)e:for(e=n.stateNode,e._visibility=a?e._visibility&-2:e._visibility|1,a&&(t===null||c||Go||Ci||pu(n)),t=null,e=n;;){if(e.tag===5||e.tag===26){if(t===null){c=t=e;try{if(r=c.stateNode,a)s=r.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{o=c.stateNode;var d=c.memoizedProps.style,m=d!=null&&d.hasOwnProperty("display")?d.display:null;o.style.display=m==null||typeof m=="boolean"?"":(""+m).trim()}}catch(x){Cn(c,c.return,x)}}}else if(e.tag===6){if(t===null){c=e;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(x){Cn(c,c.return,x)}}}else if(e.tag===18){if(t===null){c=e;try{var g=c.stateNode;a?YC(g,!0):YC(c.stateNode,!1)}catch(x){Cn(c,c.return,x)}}}else if((e.tag!==22&&e.tag!==23||e.memoizedState===null||e===n)&&e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;t===e&&(t=null),e=e.return}t===e&&(t=null),e.sibling.return=e.return,e=e.sibling}i&4&&(i=n.updateQueue,i!==null&&(t=i.retryQueue,t!==null&&(i.retryQueue=null,Hg(n,t))));break;case 19:Va(e,n),ka(n),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,Hg(n,i)));break;case 30:break;case 21:break;default:Va(e,n),ka(n)}}function ka(n){var e=n.flags;if(e&2){try{for(var t,i=n.return;i!==null;){if(Y5(i)){t=i;break}i=i.return}if(t==null)throw Error(Ue(160));switch(t.tag){case 27:var a=t.stateNode,r=dT(n);B_(n,r,a);break;case 5:var s=t.stateNode;t.flags&32&&(ld(s,""),t.flags&=-33);var o=dT(n);B_(n,o,s);break;case 3:case 4:var c=t.stateNode.containerInfo,h=dT(n);P3(n,h,c);break;default:throw Error(Ue(161))}}catch(f){Cn(n,n.return,f)}n.flags&=-3}e&4096&&(n.flags&=-4097)}function eI(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var e=n;eI(e),e.tag===5&&e.flags&1024&&e.stateNode.reset(),n=n.sibling}}function Ao(n,e){if(e.subtreeFlags&8772)for(e=e.child;e!==null;)j5(n,e.alternate,e),e=e.sibling}function pu(n){for(n=n.child;n!==null;){var e=n;switch(e.tag){case 0:case 11:case 14:case 15:hc(4,e,e.return),pu(e);break;case 1:eo(e,e.return);var t=e.stateNode;typeof t.componentWillUnmount=="function"&&W5(e,e.return,t),pu(e);break;case 27:wm(e.stateNode);case 26:case 5:eo(e,e.return),pu(e);break;case 22:e.memoizedState===null&&pu(e);break;case 30:pu(e);break;default:pu(e)}n=n.sibling}}function Uo(n,e,t){for(t=t&&(e.subtreeFlags&8772)!==0,e=e.child;e!==null;){var i=e.alternate,a=n,r=e,s=r.flags;switch(r.tag){case 0:case 11:case 15:Uo(a,r,t),A0(4,r);break;case 1:if(Uo(a,r,t),i=r,a=i.stateNode,typeof a.componentDidMount=="function")try{a.componentDidMount()}catch(h){Cn(i,i.return,h)}if(i=r,a=i.updateQueue,a!==null){var o=i.stateNode;try{var c=a.shared.hiddenCallbacks;if(c!==null)for(a.shared.hiddenCallbacks=null,a=0;a<c.length;a++)QL(c[a],o)}catch(h){Cn(i,i.return,h)}}t&&s&64&&k5(r),Mm(r,r.return);break;case 27:q5(r);case 26:case 5:Uo(a,r,t),t&&i===null&&s&4&&X5(r),Mm(r,r.return);break;case 12:Uo(a,r,t);break;case 31:Uo(a,r,t),t&&s&4&&Q5(a,r);break;case 13:Uo(a,r,t),t&&s&4&&J5(a,r);break;case 22:r.memoizedState===null&&Uo(a,r,t),Mm(r,r.return);break;case 30:break;default:Uo(a,r,t)}e=e.sibling}}function ZM(n,e){var t=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(t=n.memoizedState.cachePool.pool),n=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),n!==t&&(n!=null&&n.refCount++,t!=null&&M0(t))}function KM(n,e){n=null,e.alternate!==null&&(n=e.alternate.memoizedState.cache),e=e.memoizedState.cache,e!==n&&(e.refCount++,n!=null&&M0(n))}function ds(n,e,t,i){if(e.subtreeFlags&10256)for(e=e.child;e!==null;)tI(n,e,t,i),e=e.sibling}function tI(n,e,t,i){var a=e.flags;switch(e.tag){case 0:case 11:case 15:ds(n,e,t,i),a&2048&&A0(9,e);break;case 1:ds(n,e,t,i);break;case 3:ds(n,e,t,i),a&2048&&(n=null,e.alternate!==null&&(n=e.alternate.memoizedState.cache),e=e.memoizedState.cache,e!==n&&(e.refCount++,n!=null&&M0(n)));break;case 12:if(a&2048){ds(n,e,t,i),n=e.stateNode;try{var r=e.memoizedProps,s=r.id,o=r.onPostCommit;typeof o=="function"&&o(s,e.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(c){Cn(e,e.return,c)}}else ds(n,e,t,i);break;case 31:ds(n,e,t,i);break;case 13:ds(n,e,t,i);break;case 23:break;case 22:r=e.stateNode,s=e.alternate,e.memoizedState!==null?r._visibility&2?ds(n,e,t,i):bm(n,e):r._visibility&2?ds(n,e,t,i):(r._visibility|=2,bf(n,e,t,i,(e.subtreeFlags&10256)!==0||!1)),a&2048&&ZM(s,e);break;case 24:ds(n,e,t,i),a&2048&&KM(e.alternate,e);break;default:ds(n,e,t,i)}}function bf(n,e,t,i,a){for(a=a&&((e.subtreeFlags&10256)!==0||!1),e=e.child;e!==null;){var r=n,s=e,o=t,c=i,h=s.flags;switch(s.tag){case 0:case 11:case 15:bf(r,s,o,c,a),A0(8,s);break;case 23:break;case 22:var f=s.stateNode;s.memoizedState!==null?f._visibility&2?bf(r,s,o,c,a):bm(r,s):(f._visibility|=2,bf(r,s,o,c,a)),a&&h&2048&&ZM(s.alternate,s);break;case 24:bf(r,s,o,c,a),a&&h&2048&&KM(s.alternate,s);break;default:bf(r,s,o,c,a)}e=e.sibling}}function bm(n,e){if(e.subtreeFlags&10256)for(e=e.child;e!==null;){var t=n,i=e,a=i.flags;switch(i.tag){case 22:bm(t,i),a&2048&&ZM(i.alternate,i);break;case 24:bm(t,i),a&2048&&KM(i.alternate,i);break;default:bm(t,i)}e=e.sibling}}var sm=8192;function Vh(n,e,t){if(n.subtreeFlags&sm)for(n=n.child;n!==null;)nI(n,e,t),n=n.sibling}function nI(n,e,t){switch(n.tag){case 26:Vh(n,e,t),n.flags&sm&&n.memoizedState!==null&&KH(t,Es,n.memoizedState,n.memoizedProps);break;case 5:Vh(n,e,t);break;case 3:case 4:var i=Es;Es=Y_(n.stateNode.containerInfo),Vh(n,e,t),Es=i;break;case 22:n.memoizedState===null&&(i=n.alternate,i!==null&&i.memoizedState!==null?(i=sm,sm=16777216,Vh(n,e,t),sm=i):Vh(n,e,t));break;default:Vh(n,e,t)}}function iI(n){var e=n.alternate;if(e!==null&&(n=e.child,n!==null)){e.child=null;do e=n.sibling,n.sibling=null,n=e;while(n!==null)}}function Cp(n){var e=n.deletions;if(n.flags&16){if(e!==null)for(var t=0;t<e.length;t++){var i=e[t];Ki=i,rI(i,n)}iI(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)aI(n),n=n.sibling}function aI(n){switch(n.tag){case 0:case 11:case 15:Cp(n),n.flags&2048&&hc(9,n,n.return);break;case 3:Cp(n);break;case 12:Cp(n);break;case 22:var e=n.stateNode;n.memoizedState!==null&&e._visibility&2&&(n.return===null||n.return.tag!==13)?(e._visibility&=-3,o_(n)):Cp(n);break;default:Cp(n)}}function o_(n){var e=n.deletions;if(n.flags&16){if(e!==null)for(var t=0;t<e.length;t++){var i=e[t];Ki=i,rI(i,n)}iI(n)}for(n=n.child;n!==null;){switch(e=n,e.tag){case 0:case 11:case 15:hc(8,e,e.return),o_(e);break;case 22:t=e.stateNode,t._visibility&2&&(t._visibility&=-3,o_(e));break;default:o_(e)}n=n.sibling}}function rI(n,e){for(;Ki!==null;){var t=Ki;switch(t.tag){case 0:case 11:case 15:hc(8,t,e);break;case 23:case 22:if(t.memoizedState!==null&&t.memoizedState.cachePool!==null){var i=t.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:M0(t.memoizedState.cache)}if(i=t.child,i!==null)i.return=t,Ki=i;else e:for(t=n;Ki!==null;){i=Ki;var a=i.sibling,r=i.return;if(Z5(i),i===t){Ki=null;break e}if(a!==null){a.return=r,Ki=a;break e}Ki=r}}}var hH={getCacheForType:function(n){var e=ca(Ni),t=e.data.get(n);return t===void 0&&(t=n(),e.data.set(n,t)),t},cacheSignal:function(){return ca(Ni).controller.signal}},fH=typeof WeakMap=="function"?WeakMap:Map,xn=0,Hn=null,sn=null,cn=0,wn=0,xr=null,Yl=!1,Fd=!1,QM=!1,il=0,vi=0,fc=0,Du=0,JM=0,Tr=0,fd=0,Am=null,Za=null,z3=!1,y1=0,sI=0,H_=1/0,F_=null,nc=null,Bi=0,ic=null,dd=null,Ko=0,B3=0,H3=null,oI=null,Rm=0,F3=null;function wr(){return xn&2&&cn!==0?cn&-cn:Ut.T!==null?eb():gL()}function lI(){if(Tr===0)if(!(cn&536870912)||un){var n=Dg;Dg<<=1,!(Dg&3932160)&&(Dg=262144),Tr=n}else Tr=536870912;return n=Dr.current,n!==null&&(n.flags|=32),Tr}function Qa(n,e,t){(n===Hn&&(wn===2||wn===9)||n.cancelPendingCommit!==null)&&(pd(n,0),ql(n,cn,Tr,!1)),S0(n,t),(!(xn&2)||n!==Hn)&&(n===Hn&&(!(xn&2)&&(Du|=t),vi===4&&ql(n,cn,Tr,!1)),lo(n))}function cI(n,e,t){if(xn&6)throw Error(Ue(327));var i=!t&&(e&127)===0&&(e&n.expiredLanes)===0||y0(n,e),a=i?mH(n,e):mT(n,e,!0),r=i;do{if(a===0){Fd&&!i&&ql(n,e,0,!1);break}else{if(t=n.current.alternate,r&&!dH(t)){a=mT(n,e,!1),r=!1;continue}if(a===2){if(r=e,n.errorRecoveryDisabledLanes&r)var s=0;else s=n.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){e=s;e:{var o=n;a=Am;var c=o.current.memoizedState.isDehydrated;if(c&&(pd(o,s).flags|=256),s=mT(o,s,!1),s!==2){if(QM&&!c){o.errorRecoveryDisabledLanes|=r,Du|=r,a=4;break e}r=Za,Za=a,r!==null&&(Za===null?Za=r:Za.push.apply(Za,r))}a=s}if(r=!1,a!==2)continue}}if(a===1){pd(n,0),ql(n,e,0,!0);break}e:{switch(i=n,r=a,r){case 0:case 1:throw Error(Ue(345));case 4:if((e&4194048)!==e)break;case 6:ql(i,e,Tr,!Yl);break e;case 2:Za=null;break;case 3:case 5:break;default:throw Error(Ue(329))}if((e&62914560)===e&&(a=y1+300-br(),10<a)){if(ql(i,e,Tr,!Yl),c1(i,0,!0)!==0)break e;Ko=e,i.timeoutHandle=CI(LC.bind(null,i,t,Za,F_,z3,e,Tr,Du,fd,Yl,r,"Throttled",-0,0),a);break e}LC(i,t,Za,F_,z3,e,Tr,Du,fd,Yl,r,null,-0,0)}}break}while(!0);lo(n)}function LC(n,e,t,i,a,r,s,o,c,h,f,d,m,g){if(n.timeoutHandle=-1,d=e.subtreeFlags,d&8192||(d&16785408)===16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Yo},nI(e,r,d);var x=(r&62914560)===r?y1-br():(r&4194048)===r?sI-br():0;if(x=QH(d,x),x!==null){Ko=r,n.cancelPendingCommit=x(UC.bind(null,n,e,r,t,i,a,s,o,c,f,d,null,m,g)),ql(n,r,s,!h);return}}UC(n,e,r,t,i,a,s,o,c)}function dH(n){for(var e=n;;){var t=e.tag;if((t===0||t===11||t===15)&&e.flags&16384&&(t=e.updateQueue,t!==null&&(t=t.stores,t!==null)))for(var i=0;i<t.length;i++){var a=t[i],r=a.getSnapshot;a=a.value;try{if(!Nr(r(),a))return!1}catch{return!1}}if(t=e.child,e.subtreeFlags&16384&&t!==null)t.return=e,e=t;else{if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function ql(n,e,t,i){e&=~JM,e&=~Du,n.suspendedLanes|=e,n.pingedLanes&=~e,i&&(n.warmLanes|=e),i=n.expirationTimes;for(var a=e;0<a;){var r=31-Rr(a),s=1<<r;i[r]=-1,a&=~s}t!==0&&dL(n,t,e)}function S1(){return xn&6?!0:(R0(0),!1)}function $M(){if(sn!==null){if(wn===0)var n=sn.return;else n=sn,qo=rh=null,BM(n),Jf=null,Zm=0,n=sn;for(;n!==null;)V5(n.alternate,n),n=n.return;sn=null}}function pd(n,e){var t=n.timeoutHandle;t!==-1&&(n.timeoutHandle=-1,LH(t)),t=n.cancelPendingCommit,t!==null&&(n.cancelPendingCommit=null,t()),Ko=0,$M(),Hn=n,sn=t=jo(n.current,null),cn=e,wn=0,xr=null,Yl=!1,Fd=y0(n,e),QM=!1,fd=Tr=JM=Du=fc=vi=0,Za=Am=null,z3=!1,e&8&&(e|=e&32);var i=n.entangledLanes;if(i!==0)for(n=n.entanglements,i&=e;0<i;){var a=31-Rr(i),r=1<<a;e|=n[a],i&=~r}return il=e,d1(),t}function uI(n,e){jt=null,Ut.H=Qm,e===Hd||e===m1?(e=hC(),wn=3):e===DM?(e=hC(),wn=4):wn=e===qM?8:e!==null&&typeof e=="object"&&typeof e.then=="function"?6:1,xr=e,sn===null&&(vi=1,P_(n,Qr(e,n.current)))}function hI(){var n=Dr.current;return n===null?!0:(cn&4194048)===cn?es===null:(cn&62914560)===cn||cn&536870912?n===es:!1}function fI(){var n=Ut.H;return Ut.H=Qm,n===null?Qm:n}function dI(){var n=Ut.A;return Ut.A=hH,n}function G_(){vi=4,Yl||(cn&4194048)!==cn&&Dr.current!==null||(Fd=!0),!(fc&134217727)&&!(Du&134217727)||Hn===null||ql(Hn,cn,Tr,!1)}function mT(n,e,t){var i=xn;xn|=2;var a=fI(),r=dI();(Hn!==n||cn!==e)&&(F_=null,pd(n,e)),e=!1;var s=vi;e:do try{if(wn!==0&&sn!==null){var o=sn,c=xr;switch(wn){case 8:$M(),s=6;break e;case 3:case 2:case 9:case 6:Dr.current===null&&(e=!0);var h=wn;if(wn=0,xr=null,Ff(n,o,c,h),t&&Fd){s=0;break e}break;default:h=wn,wn=0,xr=null,Ff(n,o,c,h)}}pH(),s=vi;break}catch(f){uI(n,f)}while(!0);return e&&n.shellSuspendCounter++,qo=rh=null,xn=i,Ut.H=a,Ut.A=r,sn===null&&(Hn=null,cn=0,d1()),s}function pH(){for(;sn!==null;)pI(sn)}function mH(n,e){var t=xn;xn|=2;var i=fI(),a=dI();Hn!==n||cn!==e?(F_=null,H_=br()+500,pd(n,e)):Fd=y0(n,e);e:do try{if(wn!==0&&sn!==null){e=sn;var r=xr;t:switch(wn){case 1:wn=0,xr=null,Ff(n,e,r,1);break;case 2:case 9:if(uC(r)){wn=0,xr=null,IC(e);break}e=function(){wn!==2&&wn!==9||Hn!==n||(wn=7),lo(n)},r.then(e,e);break e;case 3:wn=7;break e;case 4:wn=5;break e;case 7:uC(r)?(wn=0,xr=null,IC(e)):(wn=0,xr=null,Ff(n,e,r,7));break;case 5:var s=null;switch(sn.tag){case 26:s=sn.memoizedState;case 5:case 27:var o=sn;if(s?II(s):o.stateNode.complete){wn=0,xr=null;var c=o.sibling;if(c!==null)sn=c;else{var h=o.return;h!==null?(sn=h,T1(h)):sn=null}break t}}wn=0,xr=null,Ff(n,e,r,5);break;case 6:wn=0,xr=null,Ff(n,e,r,6);break;case 8:$M(),vi=6;break e;default:throw Error(Ue(462))}}gH();break}catch(f){uI(n,f)}while(!0);return qo=rh=null,Ut.H=i,Ut.A=a,xn=t,sn!==null?0:(Hn=null,cn=0,d1(),vi)}function gH(){for(;sn!==null&&!Hz();)pI(sn)}function pI(n){var e=G5(n.alternate,n,il);n.memoizedProps=n.pendingProps,e===null?T1(n):sn=e}function IC(n){var e=n,t=e.alternate;switch(e.tag){case 15:case 0:e=RC(t,e,e.pendingProps,e.type,void 0,cn);break;case 11:e=RC(t,e,e.pendingProps,e.type.render,e.ref,cn);break;case 5:BM(e);default:V5(t,e),e=sn=VL(e,il),e=G5(t,e,il)}n.memoizedProps=n.pendingProps,e===null?T1(n):sn=e}function Ff(n,e,t,i){qo=rh=null,BM(e),Jf=null,Zm=0;var a=e.return;try{if(aH(n,a,e,t,cn)){vi=1,P_(n,Qr(t,n.current)),sn=null;return}}catch(r){if(a!==null)throw sn=a,r;vi=1,P_(n,Qr(t,n.current)),sn=null;return}e.flags&32768?(un||i===1?n=!0:Fd||cn&536870912?n=!1:(Yl=n=!0,(i===2||i===9||i===3||i===6)&&(i=Dr.current,i!==null&&i.tag===13&&(i.flags|=16384))),mI(e,n)):T1(e)}function T1(n){var e=n;do{if(e.flags&32768){mI(e,Yl);return}n=e.return;var t=oH(e.alternate,e,il);if(t!==null){sn=t;return}if(e=e.sibling,e!==null){sn=e;return}sn=e=n}while(e!==null);vi===0&&(vi=5)}function mI(n,e){do{var t=lH(n.alternate,n);if(t!==null){t.flags&=32767,sn=t;return}if(t=n.return,t!==null&&(t.flags|=32768,t.subtreeFlags=0,t.deletions=null),!e&&(n=n.sibling,n!==null)){sn=n;return}sn=n=t}while(n!==null);vi=6,sn=null}function UC(n,e,t,i,a,r,s,o,c){n.cancelPendingCommit=null;do E1();while(Bi!==0);if(xn&6)throw Error(Ue(327));if(e!==null){if(e===n.current)throw Error(Ue(177));if(r=e.lanes|e.childLanes,r|=MM,Zz(n,t,r,s,o,c),n===Hn&&(sn=Hn=null,cn=0),dd=e,ic=n,Ko=t,B3=r,H3=a,oI=i,e.subtreeFlags&10256||e.flags&10256?(n.callbackNode=null,n.callbackPriority=0,yH(b_,function(){return yI(),null})):(n.callbackNode=null,n.callbackPriority=0),i=(e.flags&13878)!==0,e.subtreeFlags&13878||i){i=Ut.T,Ut.T=null,a=yn.p,yn.p=2,s=xn,xn|=4;try{cH(n,e,t)}finally{xn=s,yn.p=a,Ut.T=i}}Bi=1,gI(),vI(),_I()}}function gI(){if(Bi===1){Bi=0;var n=ic,e=dd,t=(e.flags&13878)!==0;if(e.subtreeFlags&13878||t){t=Ut.T,Ut.T=null;var i=yn.p;yn.p=2;var a=xn;xn|=4;try{$5(e,n);var r=W3,s=IL(n.containerInfo),o=r.focusedElem,c=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&LL(o.ownerDocument.documentElement,o)){if(c!==null&&EM(o)){var h=c.start,f=c.end;if(f===void 0&&(f=h),"selectionStart"in o)o.selectionStart=h,o.selectionEnd=Math.min(f,o.value.length);else{var d=o.ownerDocument||document,m=d&&d.defaultView||window;if(m.getSelection){var g=m.getSelection(),x=o.textContent.length,T=Math.min(c.start,x),S=c.end===void 0?T:Math.min(c.end,x);!g.extend&&T>S&&(s=S,S=T,T=s);var v=iC(o,T),y=iC(o,S);if(v&&y&&(g.rangeCount!==1||g.anchorNode!==v.node||g.anchorOffset!==v.offset||g.focusNode!==y.node||g.focusOffset!==y.offset)){var E=d.createRange();E.setStart(v.node,v.offset),g.removeAllRanges(),T>S?(g.addRange(E),g.extend(y.node,y.offset)):(E.setEnd(y.node,y.offset),g.addRange(E))}}}}for(d=[],g=o;g=g.parentNode;)g.nodeType===1&&d.push({element:g,left:g.scrollLeft,top:g.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<d.length;o++){var b=d[o];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}Z_=!!k3,W3=k3=null}finally{xn=a,yn.p=i,Ut.T=t}}n.current=e,Bi=2}}function vI(){if(Bi===2){Bi=0;var n=ic,e=dd,t=(e.flags&8772)!==0;if(e.subtreeFlags&8772||t){t=Ut.T,Ut.T=null;var i=yn.p;yn.p=2;var a=xn;xn|=4;try{j5(n,e.alternate,e)}finally{xn=a,yn.p=i,Ut.T=t}}Bi=3}}function _I(){if(Bi===4||Bi===3){Bi=0,Fz();var n=ic,e=dd,t=Ko,i=oI;e.subtreeFlags&10256||e.flags&10256?Bi=5:(Bi=0,dd=ic=null,xI(n,n.pendingLanes));var a=n.pendingLanes;if(a===0&&(nc=null),gM(t),e=e.stateNode,Ar&&typeof Ar.onCommitFiberRoot=="function")try{Ar.onCommitFiberRoot(x0,e,void 0,(e.current.flags&128)===128)}catch{}if(i!==null){e=Ut.T,a=yn.p,yn.p=2,Ut.T=null;try{for(var r=n.onRecoverableError,s=0;s<i.length;s++){var o=i[s];r(o.value,{componentStack:o.stack})}}finally{Ut.T=e,yn.p=a}}Ko&3&&E1(),lo(n),a=n.pendingLanes,t&261930&&a&42?n===F3?Rm++:(Rm=0,F3=n):Rm=0,R0(0)}}function xI(n,e){(n.pooledCacheLanes&=e)===0&&(e=n.pooledCache,e!=null&&(n.pooledCache=null,M0(e)))}function E1(){return gI(),vI(),_I(),yI()}function yI(){if(Bi!==5)return!1;var n=ic,e=B3;B3=0;var t=gM(Ko),i=Ut.T,a=yn.p;try{yn.p=32>t?32:t,Ut.T=null,t=H3,H3=null;var r=ic,s=Ko;if(Bi=0,dd=ic=null,Ko=0,xn&6)throw Error(Ue(331));var o=xn;if(xn|=4,aI(r.current),tI(r,r.current,s,t),xn=o,R0(0,!1),Ar&&typeof Ar.onPostCommitFiberRoot=="function")try{Ar.onPostCommitFiberRoot(x0,r)}catch{}return!0}finally{yn.p=a,Ut.T=i,xI(n,e)}}function PC(n,e,t){e=Qr(t,e),e=L3(n.stateNode,e,2),n=tc(n,e,2),n!==null&&(S0(n,2),lo(n))}function Cn(n,e,t){if(n.tag===3)PC(n,n,t);else for(;e!==null;){if(e.tag===3){PC(e,n,t);break}else if(e.tag===1){var i=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(nc===null||!nc.has(i))){n=Qr(t,n),t=U5(2),i=tc(e,t,2),i!==null&&(P5(t,i,e,n),S0(i,2),lo(i));break}}e=e.return}}function gT(n,e,t){var i=n.pingCache;if(i===null){i=n.pingCache=new fH;var a=new Set;i.set(e,a)}else a=i.get(e),a===void 0&&(a=new Set,i.set(e,a));a.has(t)||(QM=!0,a.add(t),n=vH.bind(null,n,e,t),e.then(n,n))}function vH(n,e,t){var i=n.pingCache;i!==null&&i.delete(e),n.pingedLanes|=n.suspendedLanes&t,n.warmLanes&=~t,Hn===n&&(cn&t)===t&&(vi===4||vi===3&&(cn&62914560)===cn&&300>br()-y1?!(xn&2)&&pd(n,0):JM|=t,fd===cn&&(fd=0)),lo(n)}function SI(n,e){e===0&&(e=fL()),n=ah(n,e),n!==null&&(S0(n,e),lo(n))}function _H(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),SI(n,t)}function xH(n,e){var t=0;switch(n.tag){case 31:case 13:var i=n.stateNode,a=n.memoizedState;a!==null&&(t=a.retryLane);break;case 19:i=n.stateNode;break;case 22:i=n.stateNode._retryCache;break;default:throw Error(Ue(314))}i!==null&&i.delete(e),SI(n,t)}function yH(n,e){return pM(n,e)}var V_=null,Af=null,G3=!1,k_=!1,vT=!1,jl=0;function lo(n){n!==Af&&n.next===null&&(Af===null?V_=Af=n:Af=Af.next=n),k_=!0,G3||(G3=!0,TH())}function R0(n,e){if(!vT&&k_){vT=!0;do for(var t=!1,i=V_;i!==null;){if(n!==0){var a=i.pendingLanes;if(a===0)var r=0;else{var s=i.suspendedLanes,o=i.pingedLanes;r=(1<<31-Rr(42|n)+1)-1,r&=a&~(s&~o),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(t=!0,zC(i,r))}else r=cn,r=c1(i,i===Hn?r:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),!(r&3)||y0(i,r)||(t=!0,zC(i,r));i=i.next}while(t);vT=!1}}function SH(){TI()}function TI(){k_=G3=!1;var n=0;jl!==0&&OH()&&(n=jl);for(var e=br(),t=null,i=V_;i!==null;){var a=i.next,r=EI(i,e);r===0?(i.next=null,t===null?V_=a:t.next=a,a===null&&(Af=t)):(t=i,(n!==0||r&3)&&(k_=!0)),i=a}Bi!==0&&Bi!==5||R0(n),jl!==0&&(jl=0)}function EI(n,e){for(var t=n.suspendedLanes,i=n.pingedLanes,a=n.expirationTimes,r=n.pendingLanes&-62914561;0<r;){var s=31-Rr(r),o=1<<s,c=a[s];c===-1?(!(o&t)||o&i)&&(a[s]=jz(o,e)):c<=e&&(n.expiredLanes|=o),r&=~o}if(e=Hn,t=cn,t=c1(n,n===e?t:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),i=n.callbackNode,t===0||n===e&&(wn===2||wn===9)||n.cancelPendingCommit!==null)return i!==null&&i!==null&&XS(i),n.callbackNode=null,n.callbackPriority=0;if(!(t&3)||y0(n,t)){if(e=t&-t,e===n.callbackPriority)return e;switch(i!==null&&XS(i),gM(t)){case 2:case 8:t=uL;break;case 32:t=b_;break;case 268435456:t=hL;break;default:t=b_}return i=MI.bind(null,n),t=pM(t,i),n.callbackPriority=e,n.callbackNode=t,e}return i!==null&&i!==null&&XS(i),n.callbackPriority=2,n.callbackNode=null,2}function MI(n,e){if(Bi!==0&&Bi!==5)return n.callbackNode=null,n.callbackPriority=0,null;var t=n.callbackNode;if(E1()&&n.callbackNode!==t)return null;var i=cn;return i=c1(n,n===Hn?i:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),i===0?null:(cI(n,i,e),EI(n,br()),n.callbackNode!=null&&n.callbackNode===t?MI.bind(null,n):null)}function zC(n,e){if(E1())return null;cI(n,e,!0)}function TH(){IH(function(){xn&6?pM(cL,SH):TI()})}function eb(){if(jl===0){var n=cd;n===0&&(n=Ng,Ng<<=1,!(Ng&261888)&&(Ng=256)),jl=n}return jl}function BC(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Jv(""+n)}function HC(n,e){var t=e.ownerDocument.createElement("input");return t.name=e.name,t.value=e.value,n.id&&t.setAttribute("form",n.id),e.parentNode.insertBefore(t,e),n=new FormData(n),t.parentNode.removeChild(t),n}function EH(n,e,t,i,a){if(e==="submit"&&t&&t.stateNode===a){var r=BC((a[$a]||null).action),s=i.submitter;s&&(e=(e=s[$a]||null)?BC(e.formAction):s.getAttribute("formAction"),e!==null&&(r=e,s=null));var o=new u1("action","action",null,i,a);n.push({event:o,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(jl!==0){var c=s?HC(a,s):new FormData(a);D3(t,{pending:!0,data:c,method:a.method,action:r},null,c)}}else typeof r=="function"&&(o.preventDefault(),c=s?HC(a,s):new FormData(a),D3(t,{pending:!0,data:c,method:a.method,action:r},r,c))},currentTarget:a}]})}}for(var _T=0;_T<x3.length;_T++){var xT=x3[_T],MH=xT.toLowerCase(),bH=xT[0].toUpperCase()+xT.slice(1);Ds(MH,"on"+bH)}Ds(PL,"onAnimationEnd");Ds(zL,"onAnimationIteration");Ds(BL,"onAnimationStart");Ds("dblclick","onDoubleClick");Ds("focusin","onFocus");Ds("focusout","onBlur");Ds(GB,"onTransitionRun");Ds(VB,"onTransitionStart");Ds(kB,"onTransitionCancel");Ds(HL,"onTransitionEnd");od("onMouseEnter",["mouseout","mouseover"]);od("onMouseLeave",["mouseout","mouseover"]);od("onPointerEnter",["pointerout","pointerover"]);od("onPointerLeave",["pointerout","pointerover"]);th("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));th("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));th("onBeforeInput",["compositionend","keypress","textInput","paste"]);th("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));th("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));th("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Jm="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),AH=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Jm));function bI(n,e){e=(e&4)!==0;for(var t=0;t<n.length;t++){var i=n[t],a=i.event;i=i.listeners;e:{var r=void 0;if(e)for(var s=i.length-1;0<=s;s--){var o=i[s],c=o.instance,h=o.currentTarget;if(o=o.listener,c!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=h;try{r(a)}catch(f){R_(f)}a.currentTarget=null,r=c}else for(s=0;s<i.length;s++){if(o=i[s],c=o.instance,h=o.currentTarget,o=o.listener,c!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=h;try{r(a)}catch(f){R_(f)}a.currentTarget=null,r=c}}}}function an(n,e){var t=e[h3];t===void 0&&(t=e[h3]=new Set);var i=n+"__bubble";t.has(i)||(AI(e,n,2,!1),t.add(i))}function yT(n,e,t){var i=0;e&&(i|=4),AI(t,n,i,e)}var Fg="_reactListening"+Math.random().toString(36).slice(2);function tb(n){if(!n[Fg]){n[Fg]=!0,vL.forEach(function(t){t!=="selectionchange"&&(AH.has(t)||yT(t,!1,n),yT(t,!0,n))});var e=n.nodeType===9?n:n.ownerDocument;e===null||e[Fg]||(e[Fg]=!0,yT("selectionchange",!1,e))}}function AI(n,e,t,i){switch(HI(e)){case 2:var a=eF;break;case 8:a=tF;break;default:a=rb}t=a.bind(null,e,t,n),a=void 0,!g3||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(a=!0),i?a!==void 0?n.addEventListener(e,t,{capture:!0,passive:a}):n.addEventListener(e,t,!0):a!==void 0?n.addEventListener(e,t,{passive:a}):n.addEventListener(e,t,!1)}function ST(n,e,t,i,a){var r=i;if(!(e&1)&&!(e&2)&&i!==null)e:for(;;){if(i===null)return;var s=i.tag;if(s===3||s===4){var o=i.stateNode.containerInfo;if(o===a)break;if(s===4)for(s=i.return;s!==null;){var c=s.tag;if((c===3||c===4)&&s.stateNode.containerInfo===a)return;s=s.return}for(;o!==null;){if(s=Df(o),s===null)return;if(c=s.tag,c===5||c===6||c===26||c===27){i=r=s;continue e}o=o.parentNode}}i=i.return}bL(function(){var h=r,f=xM(t),d=[];e:{var m=FL.get(n);if(m!==void 0){var g=u1,x=n;switch(n){case"keypress":if(e_(t)===0)break e;case"keydown":case"keyup":g=xB;break;case"focusin":x="focus",g=KS;break;case"focusout":x="blur",g=KS;break;case"beforeblur":case"afterblur":g=KS;break;case"click":if(t.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":g=qw;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":g=oB;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":g=TB;break;case PL:case zL:case BL:g=uB;break;case HL:g=MB;break;case"scroll":case"scrollend":g=rB;break;case"wheel":g=AB;break;case"copy":case"cut":case"paste":g=fB;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":g=Zw;break;case"toggle":case"beforetoggle":g=wB}var T=(e&4)!==0,S=!T&&(n==="scroll"||n==="scrollend"),v=T?m!==null?m+"Capture":null:m;T=[];for(var y=h,E;y!==null;){var b=y;if(E=b.stateNode,b=b.tag,b!==5&&b!==26&&b!==27||E===null||v===null||(b=Wm(y,v),b!=null&&T.push($m(y,b,E))),S)break;y=y.return}0<T.length&&(m=new g(m,x,null,t,f),d.push({event:m,listeners:T}))}}if(!(e&7)){e:{if(m=n==="mouseover"||n==="pointerover",g=n==="mouseout"||n==="pointerout",m&&t!==m3&&(x=t.relatedTarget||t.fromElement)&&(Df(x)||x[Pd]))break e;if((g||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,g?(x=t.relatedTarget||t.toElement,g=h,x=x?Df(x):null,x!==null&&(S=_0(x),T=x.tag,x!==S||T!==5&&T!==27&&T!==6)&&(x=null)):(g=null,x=h),g!==x)){if(T=qw,b="onMouseLeave",v="onMouseEnter",y="mouse",(n==="pointerout"||n==="pointerover")&&(T=Zw,b="onPointerLeave",v="onPointerEnter",y="pointer"),S=g==null?m:am(g),E=x==null?m:am(x),m=new T(b,y+"leave",g,t,f),m.target=S,m.relatedTarget=E,b=null,Df(f)===h&&(T=new T(v,y+"enter",x,t,f),T.target=E,T.relatedTarget=S,b=T),S=b,g&&x)t:{for(T=RH,v=g,y=x,E=0,b=v;b;b=T(b))E++;b=0;for(var D=y;D;D=T(D))b++;for(;0<E-b;)v=T(v),E--;for(;0<b-E;)y=T(y),b--;for(;E--;){if(v===y||y!==null&&v===y.alternate){T=v;break t}v=T(v),y=T(y)}T=null}else T=null;g!==null&&FC(d,m,g,T,!1),x!==null&&S!==null&&FC(d,S,x,T,!0)}}e:{if(m=h?am(h):window,g=m.nodeName&&m.nodeName.toLowerCase(),g==="select"||g==="input"&&m.type==="file")var C=$w;else if(Jw(m))if(DL)C=BB;else{C=PB;var I=UB}else g=m.nodeName,!g||g.toLowerCase()!=="input"||m.type!=="checkbox"&&m.type!=="radio"?h&&_M(h.elementType)&&(C=$w):C=zB;if(C&&(C=C(n,h))){NL(d,C,t,f);break e}I&&I(n,m,h),n==="focusout"&&h&&m.type==="number"&&h.memoizedProps.value!=null&&p3(m,"number",m.value)}switch(I=h?am(h):window,n){case"focusin":(Jw(I)||I.contentEditable==="true")&&(If=I,v3=h,_m=null);break;case"focusout":_m=v3=If=null;break;case"mousedown":_3=!0;break;case"contextmenu":case"mouseup":case"dragend":_3=!1,aC(d,t,f);break;case"selectionchange":if(FB)break;case"keydown":case"keyup":aC(d,t,f)}var P;if(TM)e:{switch(n){case"compositionstart":var O="onCompositionStart";break e;case"compositionend":O="onCompositionEnd";break e;case"compositionupdate":O="onCompositionUpdate";break e}O=void 0}else Lf?wL(n,t)&&(O="onCompositionEnd"):n==="keydown"&&t.keyCode===229&&(O="onCompositionStart");O&&(RL&&t.locale!=="ko"&&(Lf||O!=="onCompositionStart"?O==="onCompositionEnd"&&Lf&&(P=AL()):(Xl=f,yM="value"in Xl?Xl.value:Xl.textContent,Lf=!0)),I=W_(h,O),0<I.length&&(O=new jw(O,n,null,t,f),d.push({event:O,listeners:I}),P?O.data=P:(P=CL(t),P!==null&&(O.data=P)))),(P=NB?DB(n,t):OB(n,t))&&(O=W_(h,"onBeforeInput"),0<O.length&&(I=new jw("onBeforeInput","beforeinput",null,t,f),d.push({event:I,listeners:O}),I.data=P)),EH(d,n,h,t,f)}bI(d,e)})}function $m(n,e,t){return{instance:n,listener:e,currentTarget:t}}function W_(n,e){for(var t=e+"Capture",i=[];n!==null;){var a=n,r=a.stateNode;if(a=a.tag,a!==5&&a!==26&&a!==27||r===null||(a=Wm(n,t),a!=null&&i.unshift($m(n,a,r)),a=Wm(n,e),a!=null&&i.push($m(n,a,r))),n.tag===3)return i;n=n.return}return[]}function RH(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function FC(n,e,t,i,a){for(var r=e._reactName,s=[];t!==null&&t!==i;){var o=t,c=o.alternate,h=o.stateNode;if(o=o.tag,c!==null&&c===i)break;o!==5&&o!==26&&o!==27||h===null||(c=h,a?(h=Wm(t,r),h!=null&&s.unshift($m(t,h,c))):a||(h=Wm(t,r),h!=null&&s.push($m(t,h,c)))),t=t.return}s.length!==0&&n.push({event:e,listeners:s})}var wH=/\r\n?/g,CH=/\u0000|\uFFFD/g;function GC(n){return(typeof n=="string"?n:""+n).replace(wH,`
`).replace(CH,"")}function RI(n,e){return e=GC(e),GC(n)===e}function Un(n,e,t,i,a,r){switch(t){case"children":typeof i=="string"?e==="body"||e==="textarea"&&i===""||ld(n,i):(typeof i=="number"||typeof i=="bigint")&&e!=="body"&&ld(n,""+i);break;case"className":Lg(n,"class",i);break;case"tabIndex":Lg(n,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Lg(n,t,i);break;case"style":ML(n,i,r);break;case"data":if(e!=="object"){Lg(n,"data",i);break}case"src":case"href":if(i===""&&(e!=="a"||t!=="href")){n.removeAttribute(t);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){n.removeAttribute(t);break}i=Jv(""+i),n.setAttribute(t,i);break;case"action":case"formAction":if(typeof i=="function"){n.setAttribute(t,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof r=="function"&&(t==="formAction"?(e!=="input"&&Un(n,e,"name",a.name,a,null),Un(n,e,"formEncType",a.formEncType,a,null),Un(n,e,"formMethod",a.formMethod,a,null),Un(n,e,"formTarget",a.formTarget,a,null)):(Un(n,e,"encType",a.encType,a,null),Un(n,e,"method",a.method,a,null),Un(n,e,"target",a.target,a,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){n.removeAttribute(t);break}i=Jv(""+i),n.setAttribute(t,i);break;case"onClick":i!=null&&(n.onclick=Yo);break;case"onScroll":i!=null&&an("scroll",n);break;case"onScrollEnd":i!=null&&an("scrollend",n);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(Ue(61));if(t=i.__html,t!=null){if(a.children!=null)throw Error(Ue(60));n.innerHTML=t}}break;case"multiple":n.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":n.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){n.removeAttribute("xlink:href");break}t=Jv(""+i),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?n.setAttribute(t,""+i):n.removeAttribute(t);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?n.setAttribute(t,""):n.removeAttribute(t);break;case"capture":case"download":i===!0?n.setAttribute(t,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?n.setAttribute(t,i):n.removeAttribute(t);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?n.setAttribute(t,i):n.removeAttribute(t);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?n.removeAttribute(t):n.setAttribute(t,i);break;case"popover":an("beforetoggle",n),an("toggle",n),Qv(n,"popover",i);break;case"xlinkActuate":Eo(n,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":Eo(n,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":Eo(n,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":Eo(n,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":Eo(n,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":Eo(n,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":Eo(n,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":Eo(n,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":Eo(n,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":Qv(n,"is",i);break;case"innerText":case"textContent":break;default:(!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(t=iB.get(t)||t,Qv(n,t,i))}}function V3(n,e,t,i,a,r){switch(t){case"style":ML(n,i,r);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(Ue(61));if(t=i.__html,t!=null){if(a.children!=null)throw Error(Ue(60));n.innerHTML=t}}break;case"children":typeof i=="string"?ld(n,i):(typeof i=="number"||typeof i=="bigint")&&ld(n,""+i);break;case"onScroll":i!=null&&an("scroll",n);break;case"onScrollEnd":i!=null&&an("scrollend",n);break;case"onClick":i!=null&&(n.onclick=Yo);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!_L.hasOwnProperty(t))e:{if(t[0]==="o"&&t[1]==="n"&&(a=t.endsWith("Capture"),e=t.slice(2,a?t.length-7:void 0),r=n[$a]||null,r=r!=null?r[t]:null,typeof r=="function"&&n.removeEventListener(e,r,a),typeof i=="function")){typeof r!="function"&&r!==null&&(t in n?n[t]=null:n.hasAttribute(t)&&n.removeAttribute(t)),n.addEventListener(e,i,a);break e}t in n?n[t]=i:i===!0?n.setAttribute(t,""):Qv(n,t,i)}}}function ua(n,e,t){switch(e){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":an("error",n),an("load",n);var i=!1,a=!1,r;for(r in t)if(t.hasOwnProperty(r)){var s=t[r];if(s!=null)switch(r){case"src":i=!0;break;case"srcSet":a=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(Ue(137,e));default:Un(n,e,r,s,t,null)}}a&&Un(n,e,"srcSet",t.srcSet,t,null),i&&Un(n,e,"src",t.src,t,null);return;case"input":an("invalid",n);var o=r=s=a=null,c=null,h=null;for(i in t)if(t.hasOwnProperty(i)){var f=t[i];if(f!=null)switch(i){case"name":a=f;break;case"type":s=f;break;case"checked":c=f;break;case"defaultChecked":h=f;break;case"value":r=f;break;case"defaultValue":o=f;break;case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(Ue(137,e));break;default:Un(n,e,i,f,t,null)}}SL(n,r,o,c,h,s,a,!1);return;case"select":an("invalid",n),i=s=r=null;for(a in t)if(t.hasOwnProperty(a)&&(o=t[a],o!=null))switch(a){case"value":r=o;break;case"defaultValue":s=o;break;case"multiple":i=o;default:Un(n,e,a,o,t,null)}e=r,t=s,n.multiple=!!i,e!=null?Zf(n,!!i,e,!1):t!=null&&Zf(n,!!i,t,!0);return;case"textarea":an("invalid",n),r=a=i=null;for(s in t)if(t.hasOwnProperty(s)&&(o=t[s],o!=null))switch(s){case"value":i=o;break;case"defaultValue":a=o;break;case"children":r=o;break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(Ue(91));break;default:Un(n,e,s,o,t,null)}EL(n,i,a,r);return;case"option":for(c in t)if(t.hasOwnProperty(c)&&(i=t[c],i!=null))switch(c){case"selected":n.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Un(n,e,c,i,t,null)}return;case"dialog":an("beforetoggle",n),an("toggle",n),an("cancel",n),an("close",n);break;case"iframe":case"object":an("load",n);break;case"video":case"audio":for(i=0;i<Jm.length;i++)an(Jm[i],n);break;case"image":an("error",n),an("load",n);break;case"details":an("toggle",n);break;case"embed":case"source":case"link":an("error",n),an("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(h in t)if(t.hasOwnProperty(h)&&(i=t[h],i!=null))switch(h){case"children":case"dangerouslySetInnerHTML":throw Error(Ue(137,e));default:Un(n,e,h,i,t,null)}return;default:if(_M(e)){for(f in t)t.hasOwnProperty(f)&&(i=t[f],i!==void 0&&V3(n,e,f,i,t,void 0));return}}for(o in t)t.hasOwnProperty(o)&&(i=t[o],i!=null&&Un(n,e,o,i,t,null))}function NH(n,e,t,i){switch(e){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,r=null,s=null,o=null,c=null,h=null,f=null;for(g in t){var d=t[g];if(t.hasOwnProperty(g)&&d!=null)switch(g){case"checked":break;case"value":break;case"defaultValue":c=d;default:i.hasOwnProperty(g)||Un(n,e,g,null,i,d)}}for(var m in i){var g=i[m];if(d=t[m],i.hasOwnProperty(m)&&(g!=null||d!=null))switch(m){case"type":r=g;break;case"name":a=g;break;case"checked":h=g;break;case"defaultChecked":f=g;break;case"value":s=g;break;case"defaultValue":o=g;break;case"children":case"dangerouslySetInnerHTML":if(g!=null)throw Error(Ue(137,e));break;default:g!==d&&Un(n,e,m,g,i,d)}}d3(n,s,o,c,h,f,r,a);return;case"select":g=s=o=m=null;for(r in t)if(c=t[r],t.hasOwnProperty(r)&&c!=null)switch(r){case"value":break;case"multiple":g=c;default:i.hasOwnProperty(r)||Un(n,e,r,null,i,c)}for(a in i)if(r=i[a],c=t[a],i.hasOwnProperty(a)&&(r!=null||c!=null))switch(a){case"value":m=r;break;case"defaultValue":o=r;break;case"multiple":s=r;default:r!==c&&Un(n,e,a,r,i,c)}e=o,t=s,i=g,m!=null?Zf(n,!!t,m,!1):!!i!=!!t&&(e!=null?Zf(n,!!t,e,!0):Zf(n,!!t,t?[]:"",!1));return;case"textarea":g=m=null;for(o in t)if(a=t[o],t.hasOwnProperty(o)&&a!=null&&!i.hasOwnProperty(o))switch(o){case"value":break;case"children":break;default:Un(n,e,o,null,i,a)}for(s in i)if(a=i[s],r=t[s],i.hasOwnProperty(s)&&(a!=null||r!=null))switch(s){case"value":m=a;break;case"defaultValue":g=a;break;case"children":break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(Ue(91));break;default:a!==r&&Un(n,e,s,a,i,r)}TL(n,m,g);return;case"option":for(var x in t)if(m=t[x],t.hasOwnProperty(x)&&m!=null&&!i.hasOwnProperty(x))switch(x){case"selected":n.selected=!1;break;default:Un(n,e,x,null,i,m)}for(c in i)if(m=i[c],g=t[c],i.hasOwnProperty(c)&&m!==g&&(m!=null||g!=null))switch(c){case"selected":n.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:Un(n,e,c,m,i,g)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var T in t)m=t[T],t.hasOwnProperty(T)&&m!=null&&!i.hasOwnProperty(T)&&Un(n,e,T,null,i,m);for(h in i)if(m=i[h],g=t[h],i.hasOwnProperty(h)&&m!==g&&(m!=null||g!=null))switch(h){case"children":case"dangerouslySetInnerHTML":if(m!=null)throw Error(Ue(137,e));break;default:Un(n,e,h,m,i,g)}return;default:if(_M(e)){for(var S in t)m=t[S],t.hasOwnProperty(S)&&m!==void 0&&!i.hasOwnProperty(S)&&V3(n,e,S,void 0,i,m);for(f in i)m=i[f],g=t[f],!i.hasOwnProperty(f)||m===g||m===void 0&&g===void 0||V3(n,e,f,m,i,g);return}}for(var v in t)m=t[v],t.hasOwnProperty(v)&&m!=null&&!i.hasOwnProperty(v)&&Un(n,e,v,null,i,m);for(d in i)m=i[d],g=t[d],!i.hasOwnProperty(d)||m===g||m==null&&g==null||Un(n,e,d,m,i,g)}function VC(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function DH(){if(typeof performance.getEntriesByType=="function"){for(var n=0,e=0,t=performance.getEntriesByType("resource"),i=0;i<t.length;i++){var a=t[i],r=a.transferSize,s=a.initiatorType,o=a.duration;if(r&&o&&VC(s)){for(s=0,o=a.responseEnd,i+=1;i<t.length;i++){var c=t[i],h=c.startTime;if(h>o)break;var f=c.transferSize,d=c.initiatorType;f&&VC(d)&&(c=c.responseEnd,s+=f*(c<o?1:(o-h)/(c-h)))}if(--i,e+=8*(r+s)/(a.duration/1e3),n++,10<n)break}}if(0<n)return e/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var k3=null,W3=null;function X_(n){return n.nodeType===9?n:n.ownerDocument}function kC(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function wI(n,e){if(n===0)switch(e){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&e==="foreignObject"?0:n}function X3(n,e){return n==="textarea"||n==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.children=="bigint"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var TT=null;function OH(){var n=window.event;return n&&n.type==="popstate"?n===TT?!1:(TT=n,!0):(TT=null,!1)}var CI=typeof setTimeout=="function"?setTimeout:void 0,LH=typeof clearTimeout=="function"?clearTimeout:void 0,WC=typeof Promise=="function"?Promise:void 0,IH=typeof queueMicrotask=="function"?queueMicrotask:typeof WC<"u"?function(n){return WC.resolve(null).then(n).catch(UH)}:CI;function UH(n){setTimeout(function(){throw n})}function xc(n){return n==="head"}function XC(n,e){var t=e,i=0;do{var a=t.nextSibling;if(n.removeChild(t),a&&a.nodeType===8)if(t=a.data,t==="/$"||t==="/&"){if(i===0){n.removeChild(a),gd(e);return}i--}else if(t==="$"||t==="$?"||t==="$~"||t==="$!"||t==="&")i++;else if(t==="html")wm(n.ownerDocument.documentElement);else if(t==="head"){t=n.ownerDocument.head,wm(t);for(var r=t.firstChild;r;){var s=r.nextSibling,o=r.nodeName;r[T0]||o==="SCRIPT"||o==="STYLE"||o==="LINK"&&r.rel.toLowerCase()==="stylesheet"||t.removeChild(r),r=s}}else t==="body"&&wm(n.ownerDocument.body);t=a}while(t);gd(e)}function YC(n,e){var t=n;n=0;do{var i=t.nextSibling;if(t.nodeType===1?e?(t._stashedDisplay=t.style.display,t.style.display="none"):(t.style.display=t._stashedDisplay||"",t.getAttribute("style")===""&&t.removeAttribute("style")):t.nodeType===3&&(e?(t._stashedText=t.nodeValue,t.nodeValue=""):t.nodeValue=t._stashedText||""),i&&i.nodeType===8)if(t=i.data,t==="/$"){if(n===0)break;n--}else t!=="$"&&t!=="$?"&&t!=="$~"&&t!=="$!"||n++;t=i}while(t)}function Y3(n){var e=n.firstChild;for(e&&e.nodeType===10&&(e=e.nextSibling);e;){var t=e;switch(e=e.nextSibling,t.nodeName){case"HTML":case"HEAD":case"BODY":Y3(t),vM(t);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(t.rel.toLowerCase()==="stylesheet")continue}n.removeChild(t)}}function PH(n,e,t,i){for(;n.nodeType===1;){var a=t;if(n.nodeName.toLowerCase()!==e.toLowerCase()){if(!i&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(i){if(!n[T0])switch(e){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(r=n.getAttribute("rel"),r==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(r!==a.rel||n.getAttribute("href")!==(a.href==null||a.href===""?null:a.href)||n.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin)||n.getAttribute("title")!==(a.title==null?null:a.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(r=n.getAttribute("src"),(r!==(a.src==null?null:a.src)||n.getAttribute("type")!==(a.type==null?null:a.type)||n.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin))&&r&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(e==="input"&&n.type==="hidden"){var r=a.name==null?null:""+a.name;if(a.type==="hidden"&&n.getAttribute("name")===r)return n}else return n;if(n=ts(n.nextSibling),n===null)break}return null}function zH(n,e,t){if(e==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!t||(n=ts(n.nextSibling),n===null))return null;return n}function NI(n,e){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!e||(n=ts(n.nextSibling),n===null))return null;return n}function q3(n){return n.data==="$?"||n.data==="$~"}function j3(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function BH(n,e){var t=n.ownerDocument;if(n.data==="$~")n._reactRetry=e;else if(n.data!=="$?"||t.readyState!=="loading")e();else{var i=function(){e(),t.removeEventListener("DOMContentLoaded",i)};t.addEventListener("DOMContentLoaded",i),n._reactRetry=i}}function ts(n){for(;n!=null;n=n.nextSibling){var e=n.nodeType;if(e===1||e===3)break;if(e===8){if(e=n.data,e==="$"||e==="$!"||e==="$?"||e==="$~"||e==="&"||e==="F!"||e==="F")break;if(e==="/$"||e==="/&")return null}}return n}var Z3=null;function qC(n){n=n.nextSibling;for(var e=0;n;){if(n.nodeType===8){var t=n.data;if(t==="/$"||t==="/&"){if(e===0)return ts(n.nextSibling);e--}else t!=="$"&&t!=="$!"&&t!=="$?"&&t!=="$~"&&t!=="&"||e++}n=n.nextSibling}return null}function jC(n){n=n.previousSibling;for(var e=0;n;){if(n.nodeType===8){var t=n.data;if(t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"){if(e===0)return n;e--}else t!=="/$"&&t!=="/&"||e++}n=n.previousSibling}return null}function DI(n,e,t){switch(e=X_(t),n){case"html":if(n=e.documentElement,!n)throw Error(Ue(452));return n;case"head":if(n=e.head,!n)throw Error(Ue(453));return n;case"body":if(n=e.body,!n)throw Error(Ue(454));return n;default:throw Error(Ue(451))}}function wm(n){for(var e=n.attributes;e.length;)n.removeAttributeNode(e[0]);vM(n)}var rs=new Map,ZC=new Set;function Y_(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var sl=yn.d;yn.d={f:HH,r:FH,D:GH,C:VH,L:kH,m:WH,X:YH,S:XH,M:qH};function HH(){var n=sl.f(),e=S1();return n||e}function FH(n){var e=zd(n);e!==null&&e.tag===5&&e.type==="form"?M5(e):sl.r(n)}var Gd=typeof document>"u"?null:document;function OI(n,e,t){var i=Gd;if(i&&typeof e=="string"&&e){var a=Kr(e);a='link[rel="'+n+'"][href="'+a+'"]',typeof t=="string"&&(a+='[crossorigin="'+t+'"]'),ZC.has(a)||(ZC.add(a),n={rel:n,crossOrigin:t,href:e},i.querySelector(a)===null&&(e=i.createElement("link"),ua(e,"link",n),Ji(e),i.head.appendChild(e)))}}function GH(n){sl.D(n),OI("dns-prefetch",n,null)}function VH(n,e){sl.C(n,e),OI("preconnect",n,e)}function kH(n,e,t){sl.L(n,e,t);var i=Gd;if(i&&n&&e){var a='link[rel="preload"][as="'+Kr(e)+'"]';e==="image"&&t&&t.imageSrcSet?(a+='[imagesrcset="'+Kr(t.imageSrcSet)+'"]',typeof t.imageSizes=="string"&&(a+='[imagesizes="'+Kr(t.imageSizes)+'"]')):a+='[href="'+Kr(n)+'"]';var r=a;switch(e){case"style":r=md(n);break;case"script":r=Vd(n)}rs.has(r)||(n=ti({rel:"preload",href:e==="image"&&t&&t.imageSrcSet?void 0:n,as:e},t),rs.set(r,n),i.querySelector(a)!==null||e==="style"&&i.querySelector(w0(r))||e==="script"&&i.querySelector(C0(r))||(e=i.createElement("link"),ua(e,"link",n),Ji(e),i.head.appendChild(e)))}}function WH(n,e){sl.m(n,e);var t=Gd;if(t&&n){var i=e&&typeof e.as=="string"?e.as:"script",a='link[rel="modulepreload"][as="'+Kr(i)+'"][href="'+Kr(n)+'"]',r=a;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Vd(n)}if(!rs.has(r)&&(n=ti({rel:"modulepreload",href:n},e),rs.set(r,n),t.querySelector(a)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(t.querySelector(C0(r)))return}i=t.createElement("link"),ua(i,"link",n),Ji(i),t.head.appendChild(i)}}}function XH(n,e,t){sl.S(n,e,t);var i=Gd;if(i&&n){var a=jf(i).hoistableStyles,r=md(n);e=e||"default";var s=a.get(r);if(!s){var o={loading:0,preload:null};if(s=i.querySelector(w0(r)))o.loading=5;else{n=ti({rel:"stylesheet",href:n,"data-precedence":e},t),(t=rs.get(r))&&nb(n,t);var c=s=i.createElement("link");Ji(c),ua(c,"link",n),c._p=new Promise(function(h,f){c.onload=h,c.onerror=f}),c.addEventListener("load",function(){o.loading|=1}),c.addEventListener("error",function(){o.loading|=2}),o.loading|=4,l_(s,e,i)}s={type:"stylesheet",instance:s,count:1,state:o},a.set(r,s)}}}function YH(n,e){sl.X(n,e);var t=Gd;if(t&&n){var i=jf(t).hoistableScripts,a=Vd(n),r=i.get(a);r||(r=t.querySelector(C0(a)),r||(n=ti({src:n,async:!0},e),(e=rs.get(a))&&ib(n,e),r=t.createElement("script"),Ji(r),ua(r,"link",n),t.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},i.set(a,r))}}function qH(n,e){sl.M(n,e);var t=Gd;if(t&&n){var i=jf(t).hoistableScripts,a=Vd(n),r=i.get(a);r||(r=t.querySelector(C0(a)),r||(n=ti({src:n,async:!0,type:"module"},e),(e=rs.get(a))&&ib(n,e),r=t.createElement("script"),Ji(r),ua(r,"link",n),t.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},i.set(a,r))}}function KC(n,e,t,i){var a=(a=Jl.current)?Y_(a):null;if(!a)throw Error(Ue(446));switch(n){case"meta":case"title":return null;case"style":return typeof t.precedence=="string"&&typeof t.href=="string"?(e=md(t.href),t=jf(a).hoistableStyles,i=t.get(e),i||(i={type:"style",instance:null,count:0,state:null},t.set(e,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(t.rel==="stylesheet"&&typeof t.href=="string"&&typeof t.precedence=="string"){n=md(t.href);var r=jf(a).hoistableStyles,s=r.get(n);if(s||(a=a.ownerDocument||a,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},r.set(n,s),(r=a.querySelector(w0(n)))&&!r._p&&(s.instance=r,s.state.loading=5),rs.has(n)||(t={rel:"preload",as:"style",href:t.href,crossOrigin:t.crossOrigin,integrity:t.integrity,media:t.media,hrefLang:t.hrefLang,referrerPolicy:t.referrerPolicy},rs.set(n,t),r||jH(a,n,t,s.state))),e&&i===null)throw Error(Ue(528,""));return s}if(e&&i!==null)throw Error(Ue(529,""));return null;case"script":return e=t.async,t=t.src,typeof t=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Vd(t),t=jf(a).hoistableScripts,i=t.get(e),i||(i={type:"script",instance:null,count:0,state:null},t.set(e,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(Ue(444,n))}}function md(n){return'href="'+Kr(n)+'"'}function w0(n){return'link[rel="stylesheet"]['+n+"]"}function LI(n){return ti({},n,{"data-precedence":n.precedence,precedence:null})}function jH(n,e,t,i){n.querySelector('link[rel="preload"][as="style"]['+e+"]")?i.loading=1:(e=n.createElement("link"),i.preload=e,e.addEventListener("load",function(){return i.loading|=1}),e.addEventListener("error",function(){return i.loading|=2}),ua(e,"link",t),Ji(e),n.head.appendChild(e))}function Vd(n){return'[src="'+Kr(n)+'"]'}function C0(n){return"script[async]"+n}function QC(n,e,t){if(e.count++,e.instance===null)switch(e.type){case"style":var i=n.querySelector('style[data-href~="'+Kr(t.href)+'"]');if(i)return e.instance=i,Ji(i),i;var a=ti({},t,{"data-href":t.href,"data-precedence":t.precedence,href:null,precedence:null});return i=(n.ownerDocument||n).createElement("style"),Ji(i),ua(i,"style",a),l_(i,t.precedence,n),e.instance=i;case"stylesheet":a=md(t.href);var r=n.querySelector(w0(a));if(r)return e.state.loading|=4,e.instance=r,Ji(r),r;i=LI(t),(a=rs.get(a))&&nb(i,a),r=(n.ownerDocument||n).createElement("link"),Ji(r);var s=r;return s._p=new Promise(function(o,c){s.onload=o,s.onerror=c}),ua(r,"link",i),e.state.loading|=4,l_(r,t.precedence,n),e.instance=r;case"script":return r=Vd(t.src),(a=n.querySelector(C0(r)))?(e.instance=a,Ji(a),a):(i=t,(a=rs.get(r))&&(i=ti({},t),ib(i,a)),n=n.ownerDocument||n,a=n.createElement("script"),Ji(a),ua(a,"link",i),n.head.appendChild(a),e.instance=a);case"void":return null;default:throw Error(Ue(443,e.type))}else e.type==="stylesheet"&&!(e.state.loading&4)&&(i=e.instance,e.state.loading|=4,l_(i,t.precedence,n));return e.instance}function l_(n,e,t){for(var i=t.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=i.length?i[i.length-1]:null,r=a,s=0;s<i.length;s++){var o=i[s];if(o.dataset.precedence===e)r=o;else if(r!==a)break}r?r.parentNode.insertBefore(n,r.nextSibling):(e=t.nodeType===9?t.head:t,e.insertBefore(n,e.firstChild))}function nb(n,e){n.crossOrigin==null&&(n.crossOrigin=e.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=e.referrerPolicy),n.title==null&&(n.title=e.title)}function ib(n,e){n.crossOrigin==null&&(n.crossOrigin=e.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=e.referrerPolicy),n.integrity==null&&(n.integrity=e.integrity)}var c_=null;function JC(n,e,t){if(c_===null){var i=new Map,a=c_=new Map;a.set(t,i)}else a=c_,i=a.get(t),i||(i=new Map,a.set(t,i));if(i.has(n))return i;for(i.set(n,null),t=t.getElementsByTagName(n),a=0;a<t.length;a++){var r=t[a];if(!(r[T0]||r[sa]||n==="link"&&r.getAttribute("rel")==="stylesheet")&&r.namespaceURI!=="http://www.w3.org/2000/svg"){var s=r.getAttribute(e)||"";s=n+s;var o=i.get(s);o?o.push(r):i.set(s,[r])}}return i}function $C(n,e,t){n=n.ownerDocument||n,n.head.insertBefore(t,e==="title"?n.querySelector("head > title"):null)}function ZH(n,e,t){if(t===1||e.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;switch(e.rel){case"stylesheet":return n=e.disabled,typeof e.precedence=="string"&&n==null;default:return!0}case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function II(n){return!(n.type==="stylesheet"&&!(n.state.loading&3))}function KH(n,e,t,i){if(t.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&!(t.state.loading&4)){if(t.instance===null){var a=md(i.href),r=e.querySelector(w0(a));if(r){e=r._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(n.count++,n=q_.bind(n),e.then(n,n)),t.state.loading|=4,t.instance=r,Ji(r);return}r=e.ownerDocument||e,i=LI(i),(a=rs.get(a))&&nb(i,a),r=r.createElement("link"),Ji(r);var s=r;s._p=new Promise(function(o,c){s.onload=o,s.onerror=c}),ua(r,"link",i),t.instance=r}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(t,e),(e=t.state.preload)&&!(t.state.loading&3)&&(n.count++,t=q_.bind(n),e.addEventListener("load",t),e.addEventListener("error",t))}}var ET=0;function QH(n,e){return n.stylesheets&&n.count===0&&u_(n,n.stylesheets),0<n.count||0<n.imgCount?function(t){var i=setTimeout(function(){if(n.stylesheets&&u_(n,n.stylesheets),n.unsuspend){var r=n.unsuspend;n.unsuspend=null,r()}},6e4+e);0<n.imgBytes&&ET===0&&(ET=62500*DH());var a=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&u_(n,n.stylesheets),n.unsuspend)){var r=n.unsuspend;n.unsuspend=null,r()}},(n.imgBytes>ET?50:800)+e);return n.unsuspend=t,function(){n.unsuspend=null,clearTimeout(i),clearTimeout(a)}}:null}function q_(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)u_(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var j_=null;function u_(n,e){n.stylesheets=null,n.unsuspend!==null&&(n.count++,j_=new Map,e.forEach(JH,n),j_=null,q_.call(n))}function JH(n,e){if(!(e.state.loading&4)){var t=j_.get(n);if(t)var i=t.get(null);else{t=new Map,j_.set(n,t);for(var a=n.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var s=a[r];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(t.set(s.dataset.precedence,s),i=s)}i&&t.set(null,i)}a=e.instance,s=a.getAttribute("data-precedence"),r=t.get(s)||i,r===i&&t.set(null,a),t.set(s,a),this.count++,i=q_.bind(this),a.addEventListener("load",i),a.addEventListener("error",i),r?r.parentNode.insertBefore(a,r.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(a,n.firstChild)),e.state.loading|=4}}var e0={$$typeof:Xo,Provider:null,Consumer:null,_currentValue:Ru,_currentValue2:Ru,_threadCount:0};function $H(n,e,t,i,a,r,s,o,c){this.tag=1,this.containerInfo=n,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=YS(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=YS(0),this.hiddenUpdates=YS(null),this.identifierPrefix=i,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function UI(n,e,t,i,a,r,s,o,c,h,f,d){return n=new $H(n,e,t,s,c,h,f,d,o),e=1,r===!0&&(e|=24),r=Sr(3,null,null,e),n.current=r,r.stateNode=n,e=CM(),e.refCount++,n.pooledCache=e,e.refCount++,r.memoizedState={element:i,isDehydrated:t,cache:e},OM(r),n}function PI(n){return n?(n=zf,n):zf}function zI(n,e,t,i,a,r){a=PI(a),i.context===null?i.context=a:i.pendingContext=a,i=ec(e),i.payload={element:t},r=r===void 0?null:r,r!==null&&(i.callback=r),t=tc(n,i,e),t!==null&&(Qa(t,n,e),ym(t,n,e))}function e4(n,e){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var t=n.retryLane;n.retryLane=t!==0&&t<e?t:e}}function ab(n,e){e4(n,e),(n=n.alternate)&&e4(n,e)}function BI(n){if(n.tag===13||n.tag===31){var e=ah(n,67108864);e!==null&&Qa(e,n,67108864),ab(n,67108864)}}function t4(n){if(n.tag===13||n.tag===31){var e=wr();e=mM(e);var t=ah(n,e);t!==null&&Qa(t,n,e),ab(n,e)}}var Z_=!0;function eF(n,e,t,i){var a=Ut.T;Ut.T=null;var r=yn.p;try{yn.p=2,rb(n,e,t,i)}finally{yn.p=r,Ut.T=a}}function tF(n,e,t,i){var a=Ut.T;Ut.T=null;var r=yn.p;try{yn.p=8,rb(n,e,t,i)}finally{yn.p=r,Ut.T=a}}function rb(n,e,t,i){if(Z_){var a=K3(i);if(a===null)ST(n,e,i,K_,t),n4(n,i);else if(iF(a,n,e,t,i))i.stopPropagation();else if(n4(n,i),e&4&&-1<nF.indexOf(n)){for(;a!==null;){var r=zd(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=fu(r.pendingLanes);if(s!==0){var o=r;for(o.pendingLanes|=2,o.entangledLanes|=2;s;){var c=1<<31-Rr(s);o.entanglements[1]|=c,s&=~c}lo(r),!(xn&6)&&(H_=br()+500,R0(0))}}break;case 31:case 13:o=ah(r,2),o!==null&&Qa(o,r,2),S1(),ab(r,2)}if(r=K3(i),r===null&&ST(n,e,i,K_,t),r===a)break;a=r}a!==null&&i.stopPropagation()}else ST(n,e,i,null,t)}}function K3(n){return n=xM(n),sb(n)}var K_=null;function sb(n){if(K_=null,n=Df(n),n!==null){var e=_0(n);if(e===null)n=null;else{var t=e.tag;if(t===13){if(n=aL(e),n!==null)return n;n=null}else if(t===31){if(n=rL(e),n!==null)return n;n=null}else if(t===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;n=null}else e!==n&&(n=null)}}return K_=n,null}function HI(n){switch(n){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Gz()){case cL:return 2;case uL:return 8;case b_:case Vz:return 32;case hL:return 268435456;default:return 32}default:return 32}}var Q3=!1,ac=null,rc=null,sc=null,t0=new Map,n0=new Map,Vl=[],nF="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function n4(n,e){switch(n){case"focusin":case"focusout":ac=null;break;case"dragenter":case"dragleave":rc=null;break;case"mouseover":case"mouseout":sc=null;break;case"pointerover":case"pointerout":t0.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":n0.delete(e.pointerId)}}function Np(n,e,t,i,a,r){return n===null||n.nativeEvent!==r?(n={blockedOn:e,domEventName:t,eventSystemFlags:i,nativeEvent:r,targetContainers:[a]},e!==null&&(e=zd(e),e!==null&&BI(e)),n):(n.eventSystemFlags|=i,e=n.targetContainers,a!==null&&e.indexOf(a)===-1&&e.push(a),n)}function iF(n,e,t,i,a){switch(e){case"focusin":return ac=Np(ac,n,e,t,i,a),!0;case"dragenter":return rc=Np(rc,n,e,t,i,a),!0;case"mouseover":return sc=Np(sc,n,e,t,i,a),!0;case"pointerover":var r=a.pointerId;return t0.set(r,Np(t0.get(r)||null,n,e,t,i,a)),!0;case"gotpointercapture":return r=a.pointerId,n0.set(r,Np(n0.get(r)||null,n,e,t,i,a)),!0}return!1}function FI(n){var e=Df(n.target);if(e!==null){var t=_0(e);if(t!==null){if(e=t.tag,e===13){if(e=aL(t),e!==null){n.blockedOn=e,Fw(n.priority,function(){t4(t)});return}}else if(e===31){if(e=rL(t),e!==null){n.blockedOn=e,Fw(n.priority,function(){t4(t)});return}}else if(e===3&&t.stateNode.current.memoizedState.isDehydrated){n.blockedOn=t.tag===3?t.stateNode.containerInfo:null;return}}}n.blockedOn=null}function h_(n){if(n.blockedOn!==null)return!1;for(var e=n.targetContainers;0<e.length;){var t=K3(n.nativeEvent);if(t===null){t=n.nativeEvent;var i=new t.constructor(t.type,t);m3=i,t.target.dispatchEvent(i),m3=null}else return e=zd(t),e!==null&&BI(e),n.blockedOn=t,!1;e.shift()}return!0}function i4(n,e,t){h_(n)&&t.delete(e)}function aF(){Q3=!1,ac!==null&&h_(ac)&&(ac=null),rc!==null&&h_(rc)&&(rc=null),sc!==null&&h_(sc)&&(sc=null),t0.forEach(i4),n0.forEach(i4)}function Gg(n,e){n.blockedOn===e&&(n.blockedOn=null,Q3||(Q3=!0,Hi.unstable_scheduleCallback(Hi.unstable_NormalPriority,aF)))}var Vg=null;function a4(n){Vg!==n&&(Vg=n,Hi.unstable_scheduleCallback(Hi.unstable_NormalPriority,function(){Vg===n&&(Vg=null);for(var e=0;e<n.length;e+=3){var t=n[e],i=n[e+1],a=n[e+2];if(typeof i!="function"){if(sb(i||t)===null)continue;break}var r=zd(t);r!==null&&(n.splice(e,3),e-=3,D3(r,{pending:!0,data:a,method:t.method,action:i},i,a))}}))}function gd(n){function e(c){return Gg(c,n)}ac!==null&&Gg(ac,n),rc!==null&&Gg(rc,n),sc!==null&&Gg(sc,n),t0.forEach(e),n0.forEach(e);for(var t=0;t<Vl.length;t++){var i=Vl[t];i.blockedOn===n&&(i.blockedOn=null)}for(;0<Vl.length&&(t=Vl[0],t.blockedOn===null);)FI(t),t.blockedOn===null&&Vl.shift();if(t=(n.ownerDocument||n).$$reactFormReplay,t!=null)for(i=0;i<t.length;i+=3){var a=t[i],r=t[i+1],s=a[$a]||null;if(typeof r=="function")s||a4(t);else if(s){var o=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[$a]||null)o=s.formAction;else if(sb(a)!==null)continue}else o=s.action;typeof o=="function"?t[i+1]=o:(t.splice(i,3),i-=3),a4(t)}}}function GI(){function n(r){r.canIntercept&&r.info==="react-transition"&&r.intercept({handler:function(){return new Promise(function(s){return a=s})},focusReset:"manual",scroll:"manual"})}function e(){a!==null&&(a(),a=null),i||setTimeout(t,20)}function t(){if(!i&&!navigation.transition){var r=navigation.currentEntry;r&&r.url!=null&&navigation.navigate(r.url,{state:r.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,a=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",e),navigation.addEventListener("navigateerror",e),setTimeout(t,100),function(){i=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",e),navigation.removeEventListener("navigateerror",e),a!==null&&(a(),a=null)}}}function ob(n){this._internalRoot=n}M1.prototype.render=ob.prototype.render=function(n){var e=this._internalRoot;if(e===null)throw Error(Ue(409));var t=e.current,i=wr();zI(t,i,n,e,null,null)};M1.prototype.unmount=ob.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var e=n.containerInfo;zI(n.current,2,null,n,null,null),S1(),e[Pd]=null}};function M1(n){this._internalRoot=n}M1.prototype.unstable_scheduleHydration=function(n){if(n){var e=gL();n={blockedOn:null,target:n,priority:e};for(var t=0;t<Vl.length&&e!==0&&e<Vl[t].priority;t++);Vl.splice(t,0,n),t===0&&FI(n)}};var r4=nL.version;if(r4!=="19.2.0")throw Error(Ue(527,r4,"19.2.0"));yn.findDOMNode=function(n){var e=n._reactInternals;if(e===void 0)throw typeof n.render=="function"?Error(Ue(188)):(n=Object.keys(n).join(","),Error(Ue(268,n)));return n=Iz(e),n=n!==null?sL(n):null,n=n===null?null:n.stateNode,n};var rF={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Ut,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var kg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!kg.isDisabled&&kg.supportsFiber)try{x0=kg.inject(rF),Ar=kg}catch{}}o1.createRoot=function(n,e){if(!iL(n))throw Error(Ue(299));var t=!1,i="",a=O5,r=L5,s=I5;return e!=null&&(e.unstable_strictMode===!0&&(t=!0),e.identifierPrefix!==void 0&&(i=e.identifierPrefix),e.onUncaughtError!==void 0&&(a=e.onUncaughtError),e.onCaughtError!==void 0&&(r=e.onCaughtError),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=UI(n,1,!1,null,null,t,i,null,a,r,s,GI),n[Pd]=e.current,tb(n),new ob(e)};o1.hydrateRoot=function(n,e,t){if(!iL(n))throw Error(Ue(299));var i=!1,a="",r=O5,s=L5,o=I5,c=null;return t!=null&&(t.unstable_strictMode===!0&&(i=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onUncaughtError!==void 0&&(r=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(o=t.onRecoverableError),t.formState!==void 0&&(c=t.formState)),e=UI(n,1,!0,e,t??null,i,a,c,r,s,o,GI),e.context=PI(null),t=e.current,i=wr(),i=mM(i),a=ec(i),a.callback=null,tc(t,a,i),t=i,e.current.lanes=t,S0(e,t),lo(e),n[Pd]=e.current,tb(n),new M1(e)};o1.version="19.2.0";function VI(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(VI)}catch(n){console.error(n)}}VI(),KO.exports=o1;var sF=KO.exports;const oF=r1(sF);var kI={exports:{}},yc={};/**
* @license React
* react-reconciler-constants.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/yc.ConcurrentRoot=1;yc.ContinuousEventPriority=8;yc.DefaultEventPriority=32;yc.DiscreteEventPriority=2;yc.IdleEventPriority=268435456;yc.LegacyRoot=0;yc.NoEventPriority=0;kI.exports=yc;var f_=kI.exports;/**
* @license
* Copyright 2010-2025 Three.js Authors
* SPDX-License-Identifier: MIT
*/const ws="181",mu={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},gu={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},WI=0,J3=1,XI=2,lF=3,YI=0,b1=1,Cm=2,ys=3,Cs=0,Oi=1,la=2,Sa=0,Ou=1,$3=2,eE=3,tE=4,lb=5,Qs=100,qI=101,jI=102,ZI=103,KI=104,QI=200,Gf=201,JI=202,$I=203,Q_=204,J_=205,eU=206,tU=207,nU=208,iU=209,aU=210,rU=211,sU=212,oU=213,lU=214,$_=0,i0=1,ex=2,ku=3,tx=4,nx=5,ix=6,ax=7,N0=0,cU=1,uU=2,ns=0,hU=1,fU=2,dU=3,cb=4,pU=5,mU=6,gU=7,nE="attached",vU="detached",A1=300,al=301,dc=302,a0=303,r0=304,kd=306,Ta=1e3,Li=1001,vd=1002,Fn=1003,R1=1004,cF=1004,yu=1005,uF=1005,Ht=1006,td=1007,hF=1007,Er=1008,_U=1008,Ii=1009,w1=1010,C1=1011,Wu=1012,D0=1013,Ns=1014,ri=1015,Xn=1016,N1=1017,D1=1018,Xu=1020,ub=35902,hb=35899,fb=1021,db=1022,Jn=1023,_d=1026,Yu=1027,bs=1028,O0=1029,Vo=1030,O1=1031,fF=1032,L1=1033,Nm=33776,Dm=33777,Om=33778,Lm=33779,rx=35840,sx=35841,ox=35842,lx=35843,cx=36196,ux=37492,hx=37496,fx=37808,dx=37809,px=37810,mx=37811,gx=37812,vx=37813,_x=37814,xx=37815,yx=37816,Sx=37817,Tx=37818,Ex=37819,Mx=37820,bx=37821,Ax=36492,Rx=36494,wx=36495,Cx=36283,Nx=36284,Dx=36285,Ox=36286,xU=2200,yU=2201,SU=2202,xd=2300,yd=2301,d_=2302,Su=2400,Tu=2401,s0=2402,I1=2500,pb=2501,TU=0,mb=1,Lx=2,Sc=3200,EU=3201,dF=3202,pF=3203,ol=0,MU=1,Na="",En="srgb",Wn="srgb-linear",o0="linear",Rn="srgb",mF=0,vu=7680,gF=7681,vF=7682,_F=7683,xF=34055,yF=34056,SF=5386,TF=512,EF=513,MF=514,bF=515,AF=516,RF=517,wF=518,iE=519,bU=512,AU=513,RU=514,gb=515,wU=516,CU=517,NU=518,DU=519,l0=35044,OU=35048,CF=35040,NF=35045,DF=35049,OF=35041,LF=35046,IF=35050,UF=35042,PF="100",ao="300 es",Mr=2e3,Sd=2001,zF={COMPUTE:"compute",RENDER:"render"},BF={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},HF={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function LU(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const FF={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Vf(n,e){return new FF[n](e)}function c0(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function IU(){const n=c0("canvas");return n.style.display="block",n}const s4={};let pc=null;function GF(n){pc=n}function VF(){return pc}function u0(...n){const e="THREE."+n.shift();pc?pc("log",e,...n):console.log(e,...n)}function ut(...n){const e="THREE."+n.shift();pc?pc("warn",e,...n):console.warn(e,...n)}function Bt(...n){const e="THREE."+n.shift();pc?pc("error",e,...n):console.error(e,...n)}function Td(...n){const e=n.join(" ");e in s4||(s4[e]=!0,ut(...n))}function kF(n,e,t){return new Promise(function(i,a){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:a();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}let tr=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const a=i[e];if(a!==void 0){const r=a.indexOf(t);r!==-1&&a.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const a=i.slice(0);for(let r=0,s=a.length;r<s;r++)a[r].call(this,e);e.target=null}}};const va=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let o4=1234567;const Lu=Math.PI/180,Ed=180/Math.PI;function Cr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(va[n&255]+va[n>>8&255]+va[n>>16&255]+va[n>>24&255]+"-"+va[e&255]+va[e>>8&255]+"-"+va[e>>16&15|64]+va[e>>24&255]+"-"+va[t&63|128]+va[t>>8&255]+"-"+va[t>>16&255]+va[t>>24&255]+va[i&255]+va[i>>8&255]+va[i>>16&255]+va[i>>24&255]).toLowerCase()}function Lt(n,e,t){return Math.max(e,Math.min(t,n))}function vb(n,e){return(n%e+e)%e}function WF(n,e,t,i,a){return i+(n-e)*(a-i)/(t-e)}function XF(n,e,t){return n!==e?(t-n)/(e-n):0}function Im(n,e,t){return(1-t)*n+t*e}function YF(n,e,t,i){return Im(n,e,1-Math.exp(-t*i))}function qF(n,e=1){return e-Math.abs(vb(n,e*2)-e)}function jF(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function ZF(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function KF(n,e){return n+Math.floor(Math.random()*(e-n+1))}function QF(n,e){return n+Math.random()*(e-n)}function JF(n){return n*(.5-Math.random())}function $F(n){n!==void 0&&(o4=n);let e=o4+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function eG(n){return n*Lu}function tG(n){return n*Ed}function nG(n){return(n&n-1)===0&&n!==0}function iG(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function aG(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function rG(n,e,t,i,a){const r=Math.cos,s=Math.sin,o=r(t/2),c=s(t/2),h=r((e+i)/2),f=s((e+i)/2),d=r((e-i)/2),m=s((e-i)/2),g=r((i-e)/2),x=s((i-e)/2);switch(a){case"XYX":n.set(o*f,c*d,c*m,o*h);break;case"YZY":n.set(c*m,o*f,c*d,o*h);break;case"ZXZ":n.set(c*d,c*m,o*f,o*h);break;case"XZX":n.set(o*f,c*x,c*g,o*h);break;case"YXY":n.set(c*g,o*f,c*x,o*h);break;case"ZYZ":n.set(c*x,c*g,o*f,o*h);break;default:ut("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}}function Da(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function qt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const $t={DEG2RAD:Lu,RAD2DEG:Ed,generateUUID:Cr,clamp:Lt,euclideanModulo:vb,mapLinear:WF,inverseLerp:XF,lerp:Im,damp:YF,pingpong:qF,smoothstep:jF,smootherstep:ZF,randInt:KF,randFloat:QF,randFloatSpread:JF,seededRandom:$F,degToRad:eG,radToDeg:tG,isPowerOfTwo:nG,ceilPowerOfTwo:iG,floorPowerOfTwo:aG,setQuaternionFromProperEuler:rG,normalize:qt,denormalize:Da};class de{constructor(e=0,t=0){de.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6],this.y=a[1]*t+a[4]*i+a[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Lt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Lt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),a=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*i-s*a+e.x,this.y=r*a+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Tt{constructor(e=0,t=0,i=0,a=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=a}static slerpFlat(e,t,i,a,r,s,o){let c=i[a+0],h=i[a+1],f=i[a+2],d=i[a+3],m=r[s+0],g=r[s+1],x=r[s+2],T=r[s+3];if(o<=0){e[t+0]=c,e[t+1]=h,e[t+2]=f,e[t+3]=d;return}if(o>=1){e[t+0]=m,e[t+1]=g,e[t+2]=x,e[t+3]=T;return}if(d!==T||c!==m||h!==g||f!==x){let S=c*m+h*g+f*x+d*T;S<0&&(m=-m,g=-g,x=-x,T=-T,S=-S);let v=1-o;if(S<.9995){const y=Math.acos(S),E=Math.sin(y);v=Math.sin(v*y)/E,o=Math.sin(o*y)/E,c=c*v+m*o,h=h*v+g*o,f=f*v+x*o,d=d*v+T*o}else{c=c*v+m*o,h=h*v+g*o,f=f*v+x*o,d=d*v+T*o;const y=1/Math.sqrt(c*c+h*h+f*f+d*d);c*=y,h*=y,f*=y,d*=y}}e[t]=c,e[t+1]=h,e[t+2]=f,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,a,r,s){const o=i[a],c=i[a+1],h=i[a+2],f=i[a+3],d=r[s],m=r[s+1],g=r[s+2],x=r[s+3];return e[t]=o*x+f*d+c*g-h*m,e[t+1]=c*x+f*m+h*d-o*g,e[t+2]=h*x+f*g+o*m-c*d,e[t+3]=f*x-o*d-c*m-h*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,a){return this._x=e,this._y=t,this._z=i,this._w=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,a=e._y,r=e._z,s=e._order,o=Math.cos,c=Math.sin,h=o(i/2),f=o(a/2),d=o(r/2),m=c(i/2),g=c(a/2),x=c(r/2);switch(s){case"XYZ":this._x=m*f*d+h*g*x,this._y=h*g*d-m*f*x,this._z=h*f*x+m*g*d,this._w=h*f*d-m*g*x;break;case"YXZ":this._x=m*f*d+h*g*x,this._y=h*g*d-m*f*x,this._z=h*f*x-m*g*d,this._w=h*f*d+m*g*x;break;case"ZXY":this._x=m*f*d-h*g*x,this._y=h*g*d+m*f*x,this._z=h*f*x+m*g*d,this._w=h*f*d-m*g*x;break;case"ZYX":this._x=m*f*d-h*g*x,this._y=h*g*d+m*f*x,this._z=h*f*x-m*g*d,this._w=h*f*d+m*g*x;break;case"YZX":this._x=m*f*d+h*g*x,this._y=h*g*d+m*f*x,this._z=h*f*x-m*g*d,this._w=h*f*d-m*g*x;break;case"XZY":this._x=m*f*d-h*g*x,this._y=h*g*d-m*f*x,this._z=h*f*x+m*g*d,this._w=h*f*d+m*g*x;break;default:ut("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,a=Math.sin(i);return this._x=e.x*a,this._y=e.y*a,this._z=e.z*a,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],a=t[4],r=t[8],s=t[1],o=t[5],c=t[9],h=t[2],f=t[6],d=t[10],m=i+o+d;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(f-c)*g,this._y=(r-h)*g,this._z=(s-a)*g}else if(i>o&&i>d){const g=2*Math.sqrt(1+i-o-d);this._w=(f-c)/g,this._x=.25*g,this._y=(a+s)/g,this._z=(r+h)/g}else if(o>d){const g=2*Math.sqrt(1+o-i-d);this._w=(r-h)/g,this._x=(a+s)/g,this._y=.25*g,this._z=(c+f)/g}else{const g=2*Math.sqrt(1+d-i-o);this._w=(s-a)/g,this._x=(r+h)/g,this._y=(c+f)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Lt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const a=Math.min(1,t/i);return this.slerp(e,a),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,a=e._y,r=e._z,s=e._w,o=t._x,c=t._y,h=t._z,f=t._w;return this._x=i*f+s*o+a*h-r*c,this._y=a*f+s*c+r*o-i*h,this._z=r*f+s*h+i*c-a*o,this._w=s*f-i*o-a*c-r*h,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,a=e._y,r=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,a=-a,r=-r,s=-s,o=-o);let c=1-t;if(o<.9995){const h=Math.acos(o),f=Math.sin(h);c=Math.sin(c*h)/f,t=Math.sin(t*h)/f,this._x=this._x*c+i*t,this._y=this._y*c+a*t,this._z=this._z*c+r*t,this._w=this._w*c+s*t,this._onChangeCallback()}else this._x=this._x*c+i*t,this._y=this._y*c+a*t,this._z=this._z*c+r*t,this._w=this._w*c+s*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),a=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(a*Math.sin(e),a*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{constructor(e=0,t=0,i=0){L.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(l4.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(l4.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,a=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*a,this.y=r[1]*t+r[4]*i+r[7]*a,this.z=r[2]*t+r[5]*i+r[8]*a,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,a=this.z,r=e.elements,s=1/(r[3]*t+r[7]*i+r[11]*a+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*a+r[12])*s,this.y=(r[1]*t+r[5]*i+r[9]*a+r[13])*s,this.z=(r[2]*t+r[6]*i+r[10]*a+r[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,a=this.z,r=e.x,s=e.y,o=e.z,c=e.w,h=2*(s*a-o*i),f=2*(o*t-r*a),d=2*(r*i-s*t);return this.x=t+c*h+s*d-o*f,this.y=i+c*f+o*h-r*d,this.z=a+c*d+r*f-s*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,a=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*a,this.y=r[1]*t+r[5]*i+r[9]*a,this.z=r[2]*t+r[6]*i+r[10]*a,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this.z=Lt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this.z=Lt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Lt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,a=e.y,r=e.z,s=t.x,o=t.y,c=t.z;return this.x=a*c-r*o,this.y=r*s-i*c,this.z=i*o-a*s,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return MT.copy(this).projectOnVector(e),this.sub(MT)}reflect(e){return this.sub(MT.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Lt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,a=this.z-e.z;return t*t+i*i+a*a}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const a=Math.sin(t)*e;return this.x=a*Math.sin(i),this.y=Math.cos(t)*e,this.z=a*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),a=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=a,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const MT=new L,l4=new Tt;class Et{constructor(e,t,i,a,r,s,o,c,h){Et.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,a,r,s,o,c,h)}set(e,t,i,a,r,s,o,c,h){const f=this.elements;return f[0]=e,f[1]=a,f[2]=o,f[3]=t,f[4]=r,f[5]=c,f[6]=i,f[7]=s,f[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,a=t.elements,r=this.elements,s=i[0],o=i[3],c=i[6],h=i[1],f=i[4],d=i[7],m=i[2],g=i[5],x=i[8],T=a[0],S=a[3],v=a[6],y=a[1],E=a[4],b=a[7],D=a[2],C=a[5],I=a[8];return r[0]=s*T+o*y+c*D,r[3]=s*S+o*E+c*C,r[6]=s*v+o*b+c*I,r[1]=h*T+f*y+d*D,r[4]=h*S+f*E+d*C,r[7]=h*v+f*b+d*I,r[2]=m*T+g*y+x*D,r[5]=m*S+g*E+x*C,r[8]=m*v+g*b+x*I,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],h=e[7],f=e[8];return t*s*f-t*o*h-i*r*f+i*o*c+a*r*h-a*s*c}invert(){const e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],h=e[7],f=e[8],d=f*s-o*h,m=o*c-f*r,g=h*r-s*c,x=t*d+i*m+a*g;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/x;return e[0]=d*T,e[1]=(a*h-f*i)*T,e[2]=(o*i-a*s)*T,e[3]=m*T,e[4]=(f*t-a*c)*T,e[5]=(a*r-o*t)*T,e[6]=g*T,e[7]=(i*c-h*t)*T,e[8]=(s*t-i*r)*T,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,a,r,s,o){const c=Math.cos(r),h=Math.sin(r);return this.set(i*c,i*h,-i*(c*s+h*o)+s+e,-a*h,a*c,-a*(-h*s+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(bT.makeScale(e,t)),this}rotate(e){return this.premultiply(bT.makeRotation(-e)),this}translate(e,t){return this.premultiply(bT.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let a=0;a<9;a++)if(t[a]!==i[a])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const bT=new Et,c4=new Et().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),u4=new Et().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function sG(){const n={enabled:!0,workingColorSpace:Wn,spaces:{},convert:function(a,r,s){return this.enabled===!1||r===s||!r||!s||(this.spaces[r].transfer===Rn&&(a.r=Qo(a.r),a.g=Qo(a.g),a.b=Qo(a.b)),this.spaces[r].primaries!==this.spaces[s].primaries&&(a.applyMatrix3(this.spaces[r].toXYZ),a.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Rn&&(a.r=nd(a.r),a.g=nd(a.g),a.b=nd(a.b))),a},workingToColorSpace:function(a,r){return this.convert(a,this.workingColorSpace,r)},colorSpaceToWorking:function(a,r){return this.convert(a,r,this.workingColorSpace)},getPrimaries:function(a){return this.spaces[a].primaries},getTransfer:function(a){return a===Na?o0:this.spaces[a].transfer},getToneMappingMode:function(a){return this.spaces[a].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(a,r=this.workingColorSpace){return a.fromArray(this.spaces[r].luminanceCoefficients)},define:function(a){Object.assign(this.spaces,a)},_getMatrix:function(a,r,s){return a.copy(this.spaces[r].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(a){return this.spaces[a].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(a=this.workingColorSpace){return this.spaces[a].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(a,r){return Td("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(a,r)},toWorkingColorSpace:function(a,r){return Td("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(a,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Wn]:{primaries:e,whitePoint:i,transfer:o0,toXYZ:c4,fromXYZ:u4,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:En},outputColorSpaceConfig:{drawingBufferColorSpace:En}},[En]:{primaries:e,whitePoint:i,transfer:Rn,toXYZ:c4,fromXYZ:u4,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:En}}}),n}const rn=sG();function Qo(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function nd(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let kh;class UU{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{kh===void 0&&(kh=c0("canvas")),kh.width=e.width,kh.height=e.height;const a=kh.getContext("2d");e instanceof ImageData?a.putImageData(e,0,0):a.drawImage(e,0,0,e.width,e.height),i=kh}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=c0("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const a=i.getImageData(0,0,e.width,e.height),r=a.data;for(let s=0;s<r.length;s++)r[s]=Qo(r[s]/255)*255;return i.putImageData(a,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Qo(t[i]/255)*255):t[i]=Qo(t[i]);return{data:t,width:e.width,height:e.height}}else return ut("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let oG=0;class Zl{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:oG++}),this.uuid=Cr(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},a=this.data;if(a!==null){let r;if(Array.isArray(a)){r=[];for(let s=0,o=a.length;s<o;s++)a[s].isDataTexture?r.push(AT(a[s].image)):r.push(AT(a[s]))}else r=AT(a);i.url=r}return t||(e.images[this.uuid]=i),i}}function AT(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?UU.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(ut("Texture: Unable to serialize Texture."),{})}let lG=0;const RT=new L;class Nn extends tr{constructor(e=Nn.DEFAULT_IMAGE,t=Nn.DEFAULT_MAPPING,i=Li,a=Li,r=Ht,s=Er,o=Jn,c=Ii,h=Nn.DEFAULT_ANISOTROPY,f=Na){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:lG++}),this.uuid=Cr(),this.name="",this.source=new Zl(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=a,this.magFilter=r,this.minFilter=s,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=c,this.offset=new de(0,0),this.repeat=new de(1,1),this.center=new de(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Et,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(RT).x}get height(){return this.source.getSize(RT).y}get depth(){return this.source.getSize(RT).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){ut(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const a=this[t];if(a===void 0){ut(`Texture.setValues(): property '${t}' does not exist.`);continue}a&&i&&a.isVector2&&i.isVector2||a&&i&&a.isVector3&&i.isVector3||a&&i&&a.isMatrix3&&i.isMatrix3?a.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==A1)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ta:e.x=e.x-Math.floor(e.x);break;case Li:e.x=e.x<0?0:1;break;case vd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ta:e.y=e.y-Math.floor(e.y);break;case Li:e.y=e.y<0?0:1;break;case vd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Nn.DEFAULT_IMAGE=null;Nn.DEFAULT_MAPPING=A1;Nn.DEFAULT_ANISOTROPY=1;class zt{constructor(e=0,t=0,i=0,a=1){zt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=a}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,a){return this.x=e,this.y=t,this.z=i,this.w=a,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,a=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*a+s[12]*r,this.y=s[1]*t+s[5]*i+s[9]*a+s[13]*r,this.z=s[2]*t+s[6]*i+s[10]*a+s[14]*r,this.w=s[3]*t+s[7]*i+s[11]*a+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,a,r;const c=e.elements,h=c[0],f=c[4],d=c[8],m=c[1],g=c[5],x=c[9],T=c[2],S=c[6],v=c[10];if(Math.abs(f-m)<.01&&Math.abs(d-T)<.01&&Math.abs(x-S)<.01){if(Math.abs(f+m)<.1&&Math.abs(d+T)<.1&&Math.abs(x+S)<.1&&Math.abs(h+g+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(h+1)/2,b=(g+1)/2,D=(v+1)/2,C=(f+m)/4,I=(d+T)/4,P=(x+S)/4;return E>b&&E>D?E<.01?(i=0,a=.707106781,r=.707106781):(i=Math.sqrt(E),a=C/i,r=I/i):b>D?b<.01?(i=.707106781,a=0,r=.707106781):(a=Math.sqrt(b),i=C/a,r=P/a):D<.01?(i=.707106781,a=.707106781,r=0):(r=Math.sqrt(D),i=I/r,a=P/r),this.set(i,a,r,t),this}let y=Math.sqrt((S-x)*(S-x)+(d-T)*(d-T)+(m-f)*(m-f));return Math.abs(y)<.001&&(y=1),this.x=(S-x)/y,this.y=(d-T)/y,this.z=(m-f)/y,this.w=Math.acos((h+g+v-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this.z=Lt(this.z,e.z,t.z),this.w=Lt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this.z=Lt(this.z,e,t),this.w=Lt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Lt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class _b extends tr{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ht,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new zt(0,0,e,t),this.scissorTest=!1,this.viewport=new zt(0,0,e,t);const a={width:e,height:t,depth:i.depth},r=new Nn(a);this.textures=[];const s=i.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Ht,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let a=0,r=this.textures.length;a<r;a++)this.textures[a].image.width=e,this.textures[a].image.height=t,this.textures[a].image.depth=i,this.textures[a].isData3DTexture!==!0&&(this.textures[a].isArrayTexture=this.textures[a].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const a=Object.assign({},e.textures[t].image);this.textures[t].source=new Zl(a)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _i extends _b{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class U1 extends Nn{constructor(e=null,t=1,i=1,a=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:a},this.magFilter=Fn,this.minFilter=Fn,this.wrapR=Li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class PU extends _i{constructor(e=1,t=1,i=1,a={}){super(e,t,a),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new U1(null,e,t,i),this._setTextureOptions(a),this.texture.isRenderTargetTexture=!0}}class is extends Nn{constructor(e=null,t=1,i=1,a=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:a},this.magFilter=Fn,this.minFilter=Fn,this.wrapR=Li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class zU extends _i{constructor(e=1,t=1,i=1,a={}){super(e,t,a),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new is(null,e,t,i),this._setTextureOptions(a),this.texture.isRenderTargetTexture=!0}}class ea{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(ps.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(ps.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=ps.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,ps):ps.fromBufferAttribute(r,s),ps.applyMatrix4(e.matrixWorld),this.expandByPoint(ps);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Wg.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Wg.copy(i.boundingBox)),Wg.applyMatrix4(e.matrixWorld),this.union(Wg)}const a=e.children;for(let r=0,s=a.length;r<s;r++)this.expandByObject(a[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ps),ps.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Dp),Xg.subVectors(this.max,Dp),Wh.subVectors(e.a,Dp),Xh.subVectors(e.b,Dp),Yh.subVectors(e.c,Dp),bl.subVectors(Xh,Wh),Al.subVectors(Yh,Xh),Yc.subVectors(Wh,Yh);let t=[0,-bl.z,bl.y,0,-Al.z,Al.y,0,-Yc.z,Yc.y,bl.z,0,-bl.x,Al.z,0,-Al.x,Yc.z,0,-Yc.x,-bl.y,bl.x,0,-Al.y,Al.x,0,-Yc.y,Yc.x,0];return!wT(t,Wh,Xh,Yh,Xg)||(t=[1,0,0,0,1,0,0,0,1],!wT(t,Wh,Xh,Yh,Xg))?!1:(Yg.crossVectors(bl,Al),t=[Yg.x,Yg.y,Yg.z],wT(t,Wh,Xh,Yh,Xg))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ps).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ps).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ro[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ro[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ro[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ro[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ro[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ro[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ro[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ro[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ro),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Ro=[new L,new L,new L,new L,new L,new L,new L,new L],ps=new L,Wg=new ea,Wh=new L,Xh=new L,Yh=new L,bl=new L,Al=new L,Yc=new L,Dp=new L,Xg=new L,Yg=new L,qc=new L;function wT(n,e,t,i,a){for(let r=0,s=n.length-3;r<=s;r+=3){qc.fromArray(n,r);const o=a.x*Math.abs(qc.x)+a.y*Math.abs(qc.y)+a.z*Math.abs(qc.z),c=e.dot(qc),h=t.dot(qc),f=i.dot(qc);if(Math.max(-Math.max(c,h,f),Math.min(c,h,f))>o)return!1}return!0}const cG=new ea,Op=new L,CT=new L;class ta{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):cG.setFromPoints(e).getCenter(i);let a=0;for(let r=0,s=e.length;r<s;r++)a=Math.max(a,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(a),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Op.subVectors(e,this.center);const t=Op.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),a=(i-this.radius)*.5;this.center.addScaledVector(Op,a/i),this.radius+=a}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(CT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Op.copy(e.center).add(CT)),this.expandByPoint(Op.copy(e.center).sub(CT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const wo=new L,NT=new L,qg=new L,Rl=new L,DT=new L,jg=new L,OT=new L;class sh{constructor(e=new L,t=new L(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,wo)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=wo.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(wo.copy(this.origin).addScaledVector(this.direction,t),wo.distanceToSquared(e))}distanceSqToSegment(e,t,i,a){NT.copy(e).add(t).multiplyScalar(.5),qg.copy(t).sub(e).normalize(),Rl.copy(this.origin).sub(NT);const r=e.distanceTo(t)*.5,s=-this.direction.dot(qg),o=Rl.dot(this.direction),c=-Rl.dot(qg),h=Rl.lengthSq(),f=Math.abs(1-s*s);let d,m,g,x;if(f>0)if(d=s*c-o,m=s*o-c,x=r*f,d>=0)if(m>=-x)if(m<=x){const T=1/f;d*=T,m*=T,g=d*(d+s*m+2*o)+m*(s*d+m+2*c)+h}else m=r,d=Math.max(0,-(s*m+o)),g=-d*d+m*(m+2*c)+h;else m=-r,d=Math.max(0,-(s*m+o)),g=-d*d+m*(m+2*c)+h;else m<=-x?(d=Math.max(0,-(-s*r+o)),m=d>0?-r:Math.min(Math.max(-r,-c),r),g=-d*d+m*(m+2*c)+h):m<=x?(d=0,m=Math.min(Math.max(-r,-c),r),g=m*(m+2*c)+h):(d=Math.max(0,-(s*r+o)),m=d>0?r:Math.min(Math.max(-r,-c),r),g=-d*d+m*(m+2*c)+h);else m=s>0?-r:r,d=Math.max(0,-(s*m+o)),g=-d*d+m*(m+2*c)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,d),a&&a.copy(NT).addScaledVector(qg,m),g}intersectSphere(e,t){wo.subVectors(e.center,this.origin);const i=wo.dot(this.direction),a=wo.dot(wo)-i*i,r=e.radius*e.radius;if(a>r)return null;const s=Math.sqrt(r-a),o=i-s,c=i+s;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,a,r,s,o,c;const h=1/this.direction.x,f=1/this.direction.y,d=1/this.direction.z,m=this.origin;return h>=0?(i=(e.min.x-m.x)*h,a=(e.max.x-m.x)*h):(i=(e.max.x-m.x)*h,a=(e.min.x-m.x)*h),f>=0?(r=(e.min.y-m.y)*f,s=(e.max.y-m.y)*f):(r=(e.max.y-m.y)*f,s=(e.min.y-m.y)*f),i>s||r>a||((r>i||isNaN(i))&&(i=r),(s<a||isNaN(a))&&(a=s),d>=0?(o=(e.min.z-m.z)*d,c=(e.max.z-m.z)*d):(o=(e.max.z-m.z)*d,c=(e.min.z-m.z)*d),i>c||o>a)||((o>i||i!==i)&&(i=o),(c<a||a!==a)&&(a=c),a<0)?null:this.at(i>=0?i:a,t)}intersectsBox(e){return this.intersectBox(e,wo)!==null}intersectTriangle(e,t,i,a,r){DT.subVectors(t,e),jg.subVectors(i,e),OT.crossVectors(DT,jg);let s=this.direction.dot(OT),o;if(s>0){if(a)return null;o=1}else if(s<0)o=-1,s=-s;else return null;Rl.subVectors(this.origin,e);const c=o*this.direction.dot(jg.crossVectors(Rl,jg));if(c<0)return null;const h=o*this.direction.dot(DT.cross(Rl));if(h<0||c+h>s)return null;const f=-o*Rl.dot(OT);return f<0?null:this.at(f/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ke{constructor(e,t,i,a,r,s,o,c,h,f,d,m,g,x,T,S){ke.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,a,r,s,o,c,h,f,d,m,g,x,T,S)}set(e,t,i,a,r,s,o,c,h,f,d,m,g,x,T,S){const v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=a,v[1]=r,v[5]=s,v[9]=o,v[13]=c,v[2]=h,v[6]=f,v[10]=d,v[14]=m,v[3]=g,v[7]=x,v[11]=T,v[15]=S,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ke().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,a=1/qh.setFromMatrixColumn(e,0).length(),r=1/qh.setFromMatrixColumn(e,1).length(),s=1/qh.setFromMatrixColumn(e,2).length();return t[0]=i[0]*a,t[1]=i[1]*a,t[2]=i[2]*a,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,a=e.y,r=e.z,s=Math.cos(i),o=Math.sin(i),c=Math.cos(a),h=Math.sin(a),f=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const m=s*f,g=s*d,x=o*f,T=o*d;t[0]=c*f,t[4]=-c*d,t[8]=h,t[1]=g+x*h,t[5]=m-T*h,t[9]=-o*c,t[2]=T-m*h,t[6]=x+g*h,t[10]=s*c}else if(e.order==="YXZ"){const m=c*f,g=c*d,x=h*f,T=h*d;t[0]=m+T*o,t[4]=x*o-g,t[8]=s*h,t[1]=s*d,t[5]=s*f,t[9]=-o,t[2]=g*o-x,t[6]=T+m*o,t[10]=s*c}else if(e.order==="ZXY"){const m=c*f,g=c*d,x=h*f,T=h*d;t[0]=m-T*o,t[4]=-s*d,t[8]=x+g*o,t[1]=g+x*o,t[5]=s*f,t[9]=T-m*o,t[2]=-s*h,t[6]=o,t[10]=s*c}else if(e.order==="ZYX"){const m=s*f,g=s*d,x=o*f,T=o*d;t[0]=c*f,t[4]=x*h-g,t[8]=m*h+T,t[1]=c*d,t[5]=T*h+m,t[9]=g*h-x,t[2]=-h,t[6]=o*c,t[10]=s*c}else if(e.order==="YZX"){const m=s*c,g=s*h,x=o*c,T=o*h;t[0]=c*f,t[4]=T-m*d,t[8]=x*d+g,t[1]=d,t[5]=s*f,t[9]=-o*f,t[2]=-h*f,t[6]=g*d+x,t[10]=m-T*d}else if(e.order==="XZY"){const m=s*c,g=s*h,x=o*c,T=o*h;t[0]=c*f,t[4]=-d,t[8]=h*f,t[1]=m*d+T,t[5]=s*f,t[9]=g*d-x,t[2]=x*d-g,t[6]=o*f,t[10]=T*d+m}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(uG,e,hG)}lookAt(e,t,i){const a=this.elements;return gr.subVectors(e,t),gr.lengthSq()===0&&(gr.z=1),gr.normalize(),wl.crossVectors(i,gr),wl.lengthSq()===0&&(Math.abs(i.z)===1?gr.x+=1e-4:gr.z+=1e-4,gr.normalize(),wl.crossVectors(i,gr)),wl.normalize(),Zg.crossVectors(gr,wl),a[0]=wl.x,a[4]=Zg.x,a[8]=gr.x,a[1]=wl.y,a[5]=Zg.y,a[9]=gr.y,a[2]=wl.z,a[6]=Zg.z,a[10]=gr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,a=t.elements,r=this.elements,s=i[0],o=i[4],c=i[8],h=i[12],f=i[1],d=i[5],m=i[9],g=i[13],x=i[2],T=i[6],S=i[10],v=i[14],y=i[3],E=i[7],b=i[11],D=i[15],C=a[0],I=a[4],P=a[8],O=a[12],R=a[1],B=a[5],j=a[9],ee=a[13],se=a[2],re=a[6],W=a[10],te=a[14],K=a[3],oe=a[7],ie=a[11],Ce=a[15];return r[0]=s*C+o*R+c*se+h*K,r[4]=s*I+o*B+c*re+h*oe,r[8]=s*P+o*j+c*W+h*ie,r[12]=s*O+o*ee+c*te+h*Ce,r[1]=f*C+d*R+m*se+g*K,r[5]=f*I+d*B+m*re+g*oe,r[9]=f*P+d*j+m*W+g*ie,r[13]=f*O+d*ee+m*te+g*Ce,r[2]=x*C+T*R+S*se+v*K,r[6]=x*I+T*B+S*re+v*oe,r[10]=x*P+T*j+S*W+v*ie,r[14]=x*O+T*ee+S*te+v*Ce,r[3]=y*C+E*R+b*se+D*K,r[7]=y*I+E*B+b*re+D*oe,r[11]=y*P+E*j+b*W+D*ie,r[15]=y*O+E*ee+b*te+D*Ce,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],a=e[8],r=e[12],s=e[1],o=e[5],c=e[9],h=e[13],f=e[2],d=e[6],m=e[10],g=e[14],x=e[3],T=e[7],S=e[11],v=e[15];return x*(+r*c*d-a*h*d-r*o*m+i*h*m+a*o*g-i*c*g)+T*(+t*c*g-t*h*m+r*s*m-a*s*g+a*h*f-r*c*f)+S*(+t*h*d-t*o*g-r*s*d+i*s*g+r*o*f-i*h*f)+v*(-a*o*f-t*c*d+t*o*m+a*s*d-i*s*m+i*c*f)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const a=this.elements;return e.isVector3?(a[12]=e.x,a[13]=e.y,a[14]=e.z):(a[12]=e,a[13]=t,a[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],h=e[7],f=e[8],d=e[9],m=e[10],g=e[11],x=e[12],T=e[13],S=e[14],v=e[15],y=d*S*h-T*m*h+T*c*g-o*S*g-d*c*v+o*m*v,E=x*m*h-f*S*h-x*c*g+s*S*g+f*c*v-s*m*v,b=f*T*h-x*d*h+x*o*g-s*T*g-f*o*v+s*d*v,D=x*d*c-f*T*c-x*o*m+s*T*m+f*o*S-s*d*S,C=t*y+i*E+a*b+r*D;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/C;return e[0]=y*I,e[1]=(T*m*r-d*S*r-T*a*g+i*S*g+d*a*v-i*m*v)*I,e[2]=(o*S*r-T*c*r+T*a*h-i*S*h-o*a*v+i*c*v)*I,e[3]=(d*c*r-o*m*r-d*a*h+i*m*h+o*a*g-i*c*g)*I,e[4]=E*I,e[5]=(f*S*r-x*m*r+x*a*g-t*S*g-f*a*v+t*m*v)*I,e[6]=(x*c*r-s*S*r-x*a*h+t*S*h+s*a*v-t*c*v)*I,e[7]=(s*m*r-f*c*r+f*a*h-t*m*h-s*a*g+t*c*g)*I,e[8]=b*I,e[9]=(x*d*r-f*T*r-x*i*g+t*T*g+f*i*v-t*d*v)*I,e[10]=(s*T*r-x*o*r+x*i*h-t*T*h-s*i*v+t*o*v)*I,e[11]=(f*o*r-s*d*r-f*i*h+t*d*h+s*i*g-t*o*g)*I,e[12]=D*I,e[13]=(f*T*a-x*d*a+x*i*m-t*T*m-f*i*S+t*d*S)*I,e[14]=(x*o*a-s*T*a-x*i*c+t*T*c+s*i*S-t*o*S)*I,e[15]=(s*d*a-f*o*a+f*i*c-t*d*c-s*i*m+t*o*m)*I,this}scale(e){const t=this.elements,i=e.x,a=e.y,r=e.z;return t[0]*=i,t[4]*=a,t[8]*=r,t[1]*=i,t[5]*=a,t[9]*=r,t[2]*=i,t[6]*=a,t[10]*=r,t[3]*=i,t[7]*=a,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],a=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,a))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),a=Math.sin(t),r=1-i,s=e.x,o=e.y,c=e.z,h=r*s,f=r*o;return this.set(h*s+i,h*o-a*c,h*c+a*o,0,h*o+a*c,f*o+i,f*c-a*s,0,h*c-a*o,f*c+a*s,r*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,a,r,s){return this.set(1,i,r,0,e,1,s,0,t,a,1,0,0,0,0,1),this}compose(e,t,i){const a=this.elements,r=t._x,s=t._y,o=t._z,c=t._w,h=r+r,f=s+s,d=o+o,m=r*h,g=r*f,x=r*d,T=s*f,S=s*d,v=o*d,y=c*h,E=c*f,b=c*d,D=i.x,C=i.y,I=i.z;return a[0]=(1-(T+v))*D,a[1]=(g+b)*D,a[2]=(x-E)*D,a[3]=0,a[4]=(g-b)*C,a[5]=(1-(m+v))*C,a[6]=(S+y)*C,a[7]=0,a[8]=(x+E)*I,a[9]=(S-y)*I,a[10]=(1-(m+T))*I,a[11]=0,a[12]=e.x,a[13]=e.y,a[14]=e.z,a[15]=1,this}decompose(e,t,i){const a=this.elements;let r=qh.set(a[0],a[1],a[2]).length();const s=qh.set(a[4],a[5],a[6]).length(),o=qh.set(a[8],a[9],a[10]).length();this.determinant()<0&&(r=-r),e.x=a[12],e.y=a[13],e.z=a[14],ms.copy(this);const h=1/r,f=1/s,d=1/o;return ms.elements[0]*=h,ms.elements[1]*=h,ms.elements[2]*=h,ms.elements[4]*=f,ms.elements[5]*=f,ms.elements[6]*=f,ms.elements[8]*=d,ms.elements[9]*=d,ms.elements[10]*=d,t.setFromRotationMatrix(ms),i.x=r,i.y=s,i.z=o,this}makePerspective(e,t,i,a,r,s,o=Mr,c=!1){const h=this.elements,f=2*r/(t-e),d=2*r/(i-a),m=(t+e)/(t-e),g=(i+a)/(i-a);let x,T;if(c)x=r/(s-r),T=s*r/(s-r);else if(o===Mr)x=-(s+r)/(s-r),T=-2*s*r/(s-r);else if(o===Sd)x=-s/(s-r),T=-s*r/(s-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=f,h[4]=0,h[8]=m,h[12]=0,h[1]=0,h[5]=d,h[9]=g,h[13]=0,h[2]=0,h[6]=0,h[10]=x,h[14]=T,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,a,r,s,o=Mr,c=!1){const h=this.elements,f=2/(t-e),d=2/(i-a),m=-(t+e)/(t-e),g=-(i+a)/(i-a);let x,T;if(c)x=1/(s-r),T=s/(s-r);else if(o===Mr)x=-2/(s-r),T=-(s+r)/(s-r);else if(o===Sd)x=-1/(s-r),T=-r/(s-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=f,h[4]=0,h[8]=0,h[12]=m,h[1]=0,h[5]=d,h[9]=0,h[13]=g,h[2]=0,h[6]=0,h[10]=x,h[14]=T,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let a=0;a<16;a++)if(t[a]!==i[a])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const qh=new L,ms=new ke,uG=new L(0,0,0),hG=new L(1,1,1),wl=new L,Zg=new L,gr=new L,h4=new ke,f4=new Tt;class Ui{constructor(e=0,t=0,i=0,a=Ui.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=a}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,a=this._order){return this._x=e,this._y=t,this._z=i,this._order=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const a=e.elements,r=a[0],s=a[4],o=a[8],c=a[1],h=a[5],f=a[9],d=a[2],m=a[6],g=a[10];switch(t){case"XYZ":this._y=Math.asin(Lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Lt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Lt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-d,g),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Lt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(Lt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,h),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Lt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-f,g),this._y=0);break;default:ut("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return h4.makeRotationFromQuaternion(e),this.setFromRotationMatrix(h4,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return f4.setFromEuler(this),this.setFromQuaternion(f4,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ui.DEFAULT_ORDER="XYZ";class Md{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let fG=0;const d4=new L,jh=new Tt,Co=new ke,Kg=new L,Lp=new L,dG=new L,pG=new Tt,p4=new L(1,0,0),m4=new L(0,1,0),g4=new L(0,0,1),v4={type:"added"},mG={type:"removed"},Zh={type:"childadded",child:null},LT={type:"childremoved",child:null};class Zt extends tr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:fG++}),this.uuid=Cr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zt.DEFAULT_UP.clone();const e=new L,t=new Ui,i=new Tt,a=new L(1,1,1);function r(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:a},modelViewMatrix:{value:new ke},normalMatrix:{value:new Et}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=Zt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Md,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return jh.setFromAxisAngle(e,t),this.quaternion.multiply(jh),this}rotateOnWorldAxis(e,t){return jh.setFromAxisAngle(e,t),this.quaternion.premultiply(jh),this}rotateX(e){return this.rotateOnAxis(p4,e)}rotateY(e){return this.rotateOnAxis(m4,e)}rotateZ(e){return this.rotateOnAxis(g4,e)}translateOnAxis(e,t){return d4.copy(e).applyQuaternion(this.quaternion),this.position.add(d4.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(p4,e)}translateY(e){return this.translateOnAxis(m4,e)}translateZ(e){return this.translateOnAxis(g4,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Co.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Kg.copy(e):Kg.set(e,t,i);const a=this.parent;this.updateWorldMatrix(!0,!1),Lp.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Co.lookAt(Lp,Kg,this.up):Co.lookAt(Kg,Lp,this.up),this.quaternion.setFromRotationMatrix(Co),a&&(Co.extractRotation(a.matrixWorld),jh.setFromRotationMatrix(Co),this.quaternion.premultiply(jh.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Bt("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(v4),Zh.child=e,this.dispatchEvent(Zh),Zh.child=null):Bt("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(mG),LT.child=e,this.dispatchEvent(LT),LT.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Co.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Co.multiply(e.parent.matrixWorld)),e.applyMatrix4(Co),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(v4),Zh.child=e,this.dispatchEvent(Zh),Zh.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,a=this.children.length;i<a;i++){const s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const a=this.children;for(let r=0,s=a.length;r<s;r++)a[r].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lp,e,dG),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lp,pG,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,a=t.length;i<a;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,a=t.length;i<a;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,a=t.length;i<a;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const a=this.children;for(let r=0,s=a.length;r<s;r++)a[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const a={};a.uuid=this.uuid,a.type=this.type,this.name!==""&&(a.name=this.name),this.castShadow===!0&&(a.castShadow=!0),this.receiveShadow===!0&&(a.receiveShadow=!0),this.visible===!1&&(a.visible=!1),this.frustumCulled===!1&&(a.frustumCulled=!1),this.renderOrder!==0&&(a.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(a.userData=this.userData),a.layers=this.layers.mask,a.matrix=this.matrix.toArray(),a.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(a.matrixAutoUpdate=!1),this.isInstancedMesh&&(a.type="InstancedMesh",a.count=this.count,a.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(a.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(a.type="BatchedMesh",a.perObjectFrustumCulled=this.perObjectFrustumCulled,a.sortObjects=this.sortObjects,a.drawRanges=this._drawRanges,a.reservedRanges=this._reservedRanges,a.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),a.instanceInfo=this._instanceInfo.map(o=>({...o})),a.availableInstanceIds=this._availableInstanceIds.slice(),a.availableGeometryIds=this._availableGeometryIds.slice(),a.nextIndexStart=this._nextIndexStart,a.nextVertexStart=this._nextVertexStart,a.geometryCount=this._geometryCount,a.maxInstanceCount=this._maxInstanceCount,a.maxVertexCount=this._maxVertexCount,a.maxIndexCount=this._maxIndexCount,a.geometryInitialized=this._geometryInitialized,a.matricesTexture=this._matricesTexture.toJSON(e),a.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(a.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(a.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(a.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?a.background=this.background.toJSON():this.background.isTexture&&(a.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(a.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){a.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let h=0,f=c.length;h<f;h++){const d=c[h];r(e.shapes,d)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(a.bindMode=this.bindMode,a.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),a.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,h=this.material.length;c<h;c++)o.push(r(e.materials,this.material[c]));a.material=o}else a.material=r(e.materials,this.material);if(this.children.length>0){a.children=[];for(let o=0;o<this.children.length;o++)a.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){a.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];a.animations.push(r(e.animations,c))}}if(t){const o=s(e.geometries),c=s(e.materials),h=s(e.textures),f=s(e.images),d=s(e.shapes),m=s(e.skeletons),g=s(e.animations),x=s(e.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),h.length>0&&(i.textures=h),f.length>0&&(i.images=f),d.length>0&&(i.shapes=d),m.length>0&&(i.skeletons=m),g.length>0&&(i.animations=g),x.length>0&&(i.nodes=x)}return i.object=a,i;function s(o){const c=[];for(const h in o){const f=o[h];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const a=e.children[i];this.add(a.clone())}return this}}Zt.DEFAULT_UP=new L(0,1,0);Zt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const gs=new L,No=new L,IT=new L,Do=new L,Kh=new L,Qh=new L,_4=new L,UT=new L,PT=new L,zT=new L,BT=new zt,HT=new zt,FT=new zt;class Ka{constructor(e=new L,t=new L,i=new L){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,a){a.subVectors(i,t),gs.subVectors(e,t),a.cross(gs);const r=a.lengthSq();return r>0?a.multiplyScalar(1/Math.sqrt(r)):a.set(0,0,0)}static getBarycoord(e,t,i,a,r){gs.subVectors(a,t),No.subVectors(i,t),IT.subVectors(e,t);const s=gs.dot(gs),o=gs.dot(No),c=gs.dot(IT),h=No.dot(No),f=No.dot(IT),d=s*h-o*o;if(d===0)return r.set(0,0,0),null;const m=1/d,g=(h*c-o*f)*m,x=(s*f-o*c)*m;return r.set(1-g-x,x,g)}static containsPoint(e,t,i,a){return this.getBarycoord(e,t,i,a,Do)===null?!1:Do.x>=0&&Do.y>=0&&Do.x+Do.y<=1}static getInterpolation(e,t,i,a,r,s,o,c){return this.getBarycoord(e,t,i,a,Do)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Do.x),c.addScaledVector(s,Do.y),c.addScaledVector(o,Do.z),c)}static getInterpolatedAttribute(e,t,i,a,r,s){return BT.setScalar(0),HT.setScalar(0),FT.setScalar(0),BT.fromBufferAttribute(e,t),HT.fromBufferAttribute(e,i),FT.fromBufferAttribute(e,a),s.setScalar(0),s.addScaledVector(BT,r.x),s.addScaledVector(HT,r.y),s.addScaledVector(FT,r.z),s}static isFrontFacing(e,t,i,a){return gs.subVectors(i,t),No.subVectors(e,t),gs.cross(No).dot(a)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,a){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[a]),this}setFromAttributeAndIndices(e,t,i,a){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,a),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return gs.subVectors(this.c,this.b),No.subVectors(this.a,this.b),gs.cross(No).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ka.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ka.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,a,r){return Ka.getInterpolation(e,this.a,this.b,this.c,t,i,a,r)}containsPoint(e){return Ka.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ka.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,a=this.b,r=this.c;let s,o;Kh.subVectors(a,i),Qh.subVectors(r,i),UT.subVectors(e,i);const c=Kh.dot(UT),h=Qh.dot(UT);if(c<=0&&h<=0)return t.copy(i);PT.subVectors(e,a);const f=Kh.dot(PT),d=Qh.dot(PT);if(f>=0&&d<=f)return t.copy(a);const m=c*d-f*h;if(m<=0&&c>=0&&f<=0)return s=c/(c-f),t.copy(i).addScaledVector(Kh,s);zT.subVectors(e,r);const g=Kh.dot(zT),x=Qh.dot(zT);if(x>=0&&g<=x)return t.copy(r);const T=g*h-c*x;if(T<=0&&h>=0&&x<=0)return o=h/(h-x),t.copy(i).addScaledVector(Qh,o);const S=f*x-g*d;if(S<=0&&d-f>=0&&g-x>=0)return _4.subVectors(r,a),o=(d-f)/(d-f+(g-x)),t.copy(a).addScaledVector(_4,o);const v=1/(S+T+m);return s=T*v,o=m*v,t.copy(i).addScaledVector(Kh,s).addScaledVector(Qh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const BU={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Cl={h:0,s:0,l:0},Qg={h:0,s:0,l:0};function GT(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class je{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const a=e;a&&a.isColor?this.copy(a):typeof a=="number"?this.setHex(a):typeof a=="string"&&this.setStyle(a)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=En){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,rn.colorSpaceToWorking(this,t),this}setRGB(e,t,i,a=rn.workingColorSpace){return this.r=e,this.g=t,this.b=i,rn.colorSpaceToWorking(this,a),this}setHSL(e,t,i,a=rn.workingColorSpace){if(e=vb(e,1),t=Lt(t,0,1),i=Lt(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,s=2*i-r;this.r=GT(s,r,e+1/3),this.g=GT(s,r,e),this.b=GT(s,r,e-1/3)}return rn.colorSpaceToWorking(this,a),this}setStyle(e,t=En){function i(r){r!==void 0&&parseFloat(r)<1&&ut("Color: Alpha component of "+e+" will be ignored.")}let a;if(a=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=a[1],o=a[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:ut("Color: Unknown color model "+e)}}else if(a=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=a[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(r,16),t);ut("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=En){const i=BU[e.toLowerCase()];return i!==void 0?this.setHex(i,t):ut("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Qo(e.r),this.g=Qo(e.g),this.b=Qo(e.b),this}copyLinearToSRGB(e){return this.r=nd(e.r),this.g=nd(e.g),this.b=nd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=En){return rn.workingToColorSpace(_a.copy(this),e),Math.round(Lt(_a.r*255,0,255))*65536+Math.round(Lt(_a.g*255,0,255))*256+Math.round(Lt(_a.b*255,0,255))}getHexString(e=En){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=rn.workingColorSpace){rn.workingToColorSpace(_a.copy(this),t);const i=_a.r,a=_a.g,r=_a.b,s=Math.max(i,a,r),o=Math.min(i,a,r);let c,h;const f=(o+s)/2;if(o===s)c=0,h=0;else{const d=s-o;switch(h=f<=.5?d/(s+o):d/(2-s-o),s){case i:c=(a-r)/d+(a<r?6:0);break;case a:c=(r-i)/d+2;break;case r:c=(i-a)/d+4;break}c/=6}return e.h=c,e.s=h,e.l=f,e}getRGB(e,t=rn.workingColorSpace){return rn.workingToColorSpace(_a.copy(this),t),e.r=_a.r,e.g=_a.g,e.b=_a.b,e}getStyle(e=En){rn.workingToColorSpace(_a.copy(this),e);const t=_a.r,i=_a.g,a=_a.b;return e!==En?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${a.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(a*255)})`}offsetHSL(e,t,i){return this.getHSL(Cl),this.setHSL(Cl.h+e,Cl.s+t,Cl.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Cl),e.getHSL(Qg);const i=Im(Cl.h,Qg.h,t),a=Im(Cl.s,Qg.s,t),r=Im(Cl.l,Qg.l,t);return this.setHSL(i,a,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,a=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*a,this.g=r[1]*t+r[4]*i+r[7]*a,this.b=r[2]*t+r[5]*i+r[8]*a,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const _a=new je;je.NAMES=BU;let gG=0;class qn extends tr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:gG++}),this.uuid=Cr(),this.name="",this.type="Material",this.blending=Ou,this.side=Cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Q_,this.blendDst=J_,this.blendEquation=Qs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new je(0,0,0),this.blendAlpha=0,this.depthFunc=ku,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=iE,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=vu,this.stencilZFail=vu,this.stencilZPass=vu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){ut(`Material: parameter '${t}' has value of undefined.`);continue}const a=this[t];if(a===void 0){ut(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}a&&a.isColor?a.set(i):a&&a.isVector3&&i&&i.isVector3?a.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ou&&(i.blending=this.blending),this.side!==Cs&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Q_&&(i.blendSrc=this.blendSrc),this.blendDst!==J_&&(i.blendDst=this.blendDst),this.blendEquation!==Qs&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ku&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==iE&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==vu&&(i.stencilFail=this.stencilFail),this.stencilZFail!==vu&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==vu&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function a(r){const s=[];for(const o in r){const c=r[o];delete c.metadata,s.push(c)}return s}if(t){const r=a(e.textures),s=a(e.images);r.length>0&&(i.textures=r),s.length>0&&(i.images=s)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const a=t.length;i=new Array(a);for(let r=0;r!==a;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class La extends qn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.combine=N0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ko=vG();function vG(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),a=new Uint32Array(512);for(let c=0;c<256;++c){const h=c-127;h<-27?(i[c]=0,i[c|256]=32768,a[c]=24,a[c|256]=24):h<-14?(i[c]=1024>>-h-14,i[c|256]=1024>>-h-14|32768,a[c]=-h-1,a[c|256]=-h-1):h<=15?(i[c]=h+15<<10,i[c|256]=h+15<<10|32768,a[c]=13,a[c|256]=13):h<128?(i[c]=31744,i[c|256]=64512,a[c]=24,a[c|256]=24):(i[c]=31744,i[c|256]=64512,a[c]=13,a[c|256]=13)}const r=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let h=c<<13,f=0;for(;!(h&8388608);)h<<=1,f-=8388608;h&=-8388609,f+=947912704,r[c]=h|f}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)s[c]=c<<23;s[31]=1199570944,s[32]=2147483648;for(let c=33;c<63;++c)s[c]=2147483648+(c-32<<23);s[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:a,mantissaTable:r,exponentTable:s,offsetTable:o}}function Xa(n){Math.abs(n)>65504&&ut("DataUtils.toHalfFloat(): Value out of range."),n=Lt(n,-65504,65504),ko.floatView[0]=n;const e=ko.uint32View[0],t=e>>23&511;return ko.baseTable[t]+((e&8388607)>>ko.shiftTable[t])}function om(n){const e=n>>10;return ko.uint32View[0]=ko.mantissaTable[ko.offsetTable[e]+(n&1023)]+ko.exponentTable[e],ko.floatView[0]}class aE{static toHalfFloat(e){return Xa(e)}static fromHalfFloat(e){return om(e)}}const Ri=new L,Jg=new de;let _G=0;class Ot{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:_G++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=l0,this.updateRanges=[],this.gpuType=ri,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let a=0,r=this.itemSize;a<r;a++)this.array[e+a]=t.array[i+a];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Jg.fromBufferAttribute(this,t),Jg.applyMatrix3(e),this.setXY(t,Jg.x,Jg.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.applyMatrix3(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.applyMatrix4(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.applyNormalMatrix(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.transformDirection(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Da(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=qt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Da(t,this.array)),t}setX(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Da(t,this.array)),t}setY(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Da(t,this.array)),t}setZ(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Da(t,this.array)),t}setW(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,a){return e*=this.itemSize,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),a=qt(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=a,this}setXYZW(e,t,i,a,r){return e*=this.itemSize,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),a=qt(a,this.array),r=qt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=a,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==l0&&(e.usage=this.usage),e}}class xG extends Ot{constructor(e,t,i){super(new Int8Array(e),t,i)}}class yG extends Ot{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class SG extends Ot{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class TG extends Ot{constructor(e,t,i){super(new Int16Array(e),t,i)}}class xb extends Ot{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class EG extends Ot{constructor(e,t,i){super(new Int32Array(e),t,i)}}class yb extends Ot{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class MG extends Ot{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=om(this.array[e*this.itemSize]);return this.normalized&&(t=Da(t,this.array)),t}setX(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize]=Xa(t),this}getY(e){let t=om(this.array[e*this.itemSize+1]);return this.normalized&&(t=Da(t,this.array)),t}setY(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize+1]=Xa(t),this}getZ(e){let t=om(this.array[e*this.itemSize+2]);return this.normalized&&(t=Da(t,this.array)),t}setZ(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize+2]=Xa(t),this}getW(e){let t=om(this.array[e*this.itemSize+3]);return this.normalized&&(t=Da(t,this.array)),t}setW(e,t){return this.normalized&&(t=qt(t,this.array)),this.array[e*this.itemSize+3]=Xa(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array)),this.array[e+0]=Xa(t),this.array[e+1]=Xa(i),this}setXYZ(e,t,i,a){return e*=this.itemSize,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),a=qt(a,this.array)),this.array[e+0]=Xa(t),this.array[e+1]=Xa(i),this.array[e+2]=Xa(a),this}setXYZW(e,t,i,a,r){return e*=this.itemSize,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),a=qt(a,this.array),r=qt(r,this.array)),this.array[e+0]=Xa(t),this.array[e+1]=Xa(i),this.array[e+2]=Xa(a),this.array[e+3]=Xa(r),this}}class xt extends Ot{constructor(e,t,i){super(new Float32Array(e),t,i)}}let bG=0;const Vr=new ke,VT=new Zt,Jh=new L,vr=new ea,Ip=new ea,qi=new L;class wt extends tr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:bG++}),this.uuid=Cr(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(LU(e)?yb:xb)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new Et().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const a=this.attributes.tangent;return a!==void 0&&(a.transformDirection(e),a.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Vr.makeRotationFromQuaternion(e),this.applyMatrix4(Vr),this}rotateX(e){return Vr.makeRotationX(e),this.applyMatrix4(Vr),this}rotateY(e){return Vr.makeRotationY(e),this.applyMatrix4(Vr),this}rotateZ(e){return Vr.makeRotationZ(e),this.applyMatrix4(Vr),this}translate(e,t,i){return Vr.makeTranslation(e,t,i),this.applyMatrix4(Vr),this}scale(e,t,i){return Vr.makeScale(e,t,i),this.applyMatrix4(Vr),this}lookAt(e){return VT.lookAt(e),VT.updateMatrix(),this.applyMatrix4(VT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jh).negate(),this.translate(Jh.x,Jh.y,Jh.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let a=0,r=e.length;a<r;a++){const s=e[a];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new xt(i,3))}else{const i=Math.min(e.length,t.count);for(let a=0;a<i;a++){const r=e[a];t.setXYZ(a,r.x,r.y,r.z||0)}e.length>t.count&&ut("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ea);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Bt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,a=t.length;i<a;i++){const r=t[i];vr.setFromBufferAttribute(r),this.morphTargetsRelative?(qi.addVectors(this.boundingBox.min,vr.min),this.boundingBox.expandByPoint(qi),qi.addVectors(this.boundingBox.max,vr.max),this.boundingBox.expandByPoint(qi)):(this.boundingBox.expandByPoint(vr.min),this.boundingBox.expandByPoint(vr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Bt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ta);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Bt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(e){const i=this.boundingSphere.center;if(vr.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){const o=t[r];Ip.setFromBufferAttribute(o),this.morphTargetsRelative?(qi.addVectors(vr.min,Ip.min),vr.expandByPoint(qi),qi.addVectors(vr.max,Ip.max),vr.expandByPoint(qi)):(vr.expandByPoint(Ip.min),vr.expandByPoint(Ip.max))}vr.getCenter(i);let a=0;for(let r=0,s=e.count;r<s;r++)qi.fromBufferAttribute(e,r),a=Math.max(a,i.distanceToSquared(qi));if(t)for(let r=0,s=t.length;r<s;r++){const o=t[r],c=this.morphTargetsRelative;for(let h=0,f=o.count;h<f;h++)qi.fromBufferAttribute(o,h),c&&(Jh.fromBufferAttribute(e,h),qi.add(Jh)),a=Math.max(a,i.distanceToSquared(qi))}this.boundingSphere.radius=Math.sqrt(a),isNaN(this.boundingSphere.radius)&&Bt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Bt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,a=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ot(new Float32Array(4*i.count),4));const s=this.getAttribute("tangent"),o=[],c=[];for(let P=0;P<i.count;P++)o[P]=new L,c[P]=new L;const h=new L,f=new L,d=new L,m=new de,g=new de,x=new de,T=new L,S=new L;function v(P,O,R){h.fromBufferAttribute(i,P),f.fromBufferAttribute(i,O),d.fromBufferAttribute(i,R),m.fromBufferAttribute(r,P),g.fromBufferAttribute(r,O),x.fromBufferAttribute(r,R),f.sub(h),d.sub(h),g.sub(m),x.sub(m);const B=1/(g.x*x.y-x.x*g.y);isFinite(B)&&(T.copy(f).multiplyScalar(x.y).addScaledVector(d,-g.y).multiplyScalar(B),S.copy(d).multiplyScalar(g.x).addScaledVector(f,-x.x).multiplyScalar(B),o[P].add(T),o[O].add(T),o[R].add(T),c[P].add(S),c[O].add(S),c[R].add(S))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let P=0,O=y.length;P<O;++P){const R=y[P],B=R.start,j=R.count;for(let ee=B,se=B+j;ee<se;ee+=3)v(e.getX(ee+0),e.getX(ee+1),e.getX(ee+2))}const E=new L,b=new L,D=new L,C=new L;function I(P){D.fromBufferAttribute(a,P),C.copy(D);const O=o[P];E.copy(O),E.sub(D.multiplyScalar(D.dot(O))).normalize(),b.crossVectors(C,O);const B=b.dot(c[P])<0?-1:1;s.setXYZW(P,E.x,E.y,E.z,B)}for(let P=0,O=y.length;P<O;++P){const R=y[P],B=R.start,j=R.count;for(let ee=B,se=B+j;ee<se;ee+=3)I(e.getX(ee+0)),I(e.getX(ee+1)),I(e.getX(ee+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ot(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let m=0,g=i.count;m<g;m++)i.setXYZ(m,0,0,0);const a=new L,r=new L,s=new L,o=new L,c=new L,h=new L,f=new L,d=new L;if(e)for(let m=0,g=e.count;m<g;m+=3){const x=e.getX(m+0),T=e.getX(m+1),S=e.getX(m+2);a.fromBufferAttribute(t,x),r.fromBufferAttribute(t,T),s.fromBufferAttribute(t,S),f.subVectors(s,r),d.subVectors(a,r),f.cross(d),o.fromBufferAttribute(i,x),c.fromBufferAttribute(i,T),h.fromBufferAttribute(i,S),o.add(f),c.add(f),h.add(f),i.setXYZ(x,o.x,o.y,o.z),i.setXYZ(T,c.x,c.y,c.z),i.setXYZ(S,h.x,h.y,h.z)}else for(let m=0,g=t.count;m<g;m+=3)a.fromBufferAttribute(t,m+0),r.fromBufferAttribute(t,m+1),s.fromBufferAttribute(t,m+2),f.subVectors(s,r),d.subVectors(a,r),f.cross(d),i.setXYZ(m+0,f.x,f.y,f.z),i.setXYZ(m+1,f.x,f.y,f.z),i.setXYZ(m+2,f.x,f.y,f.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)qi.fromBufferAttribute(e,t),qi.normalize(),e.setXYZ(t,qi.x,qi.y,qi.z)}toNonIndexed(){function e(o,c){const h=o.array,f=o.itemSize,d=o.normalized,m=new h.constructor(c.length*f);let g=0,x=0;for(let T=0,S=c.length;T<S;T++){o.isInterleavedBufferAttribute?g=c[T]*o.data.stride+o.offset:g=c[T]*f;for(let v=0;v<f;v++)m[x++]=h[g++]}return new Ot(m,f,d)}if(this.index===null)return ut("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new wt,i=this.index.array,a=this.attributes;for(const o in a){const c=a[o],h=e(c,i);t.setAttribute(o,h)}const r=this.morphAttributes;for(const o in r){const c=[],h=r[o];for(let f=0,d=h.length;f<d;f++){const m=h[f],g=e(m,i);c.push(g)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const h=s[o];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const h in c)c[h]!==void 0&&(e[h]=c[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const h=i[c];e.data.attributes[c]=h.toJSON(e.data)}const a={};let r=!1;for(const c in this.morphAttributes){const h=this.morphAttributes[c],f=[];for(let d=0,m=h.length;d<m;d++){const g=h[d];f.push(g.toJSON(e.data))}f.length>0&&(a[c]=f,r=!0)}r&&(e.data.morphAttributes=a,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const a=e.attributes;for(const h in a){const f=a[h];this.setAttribute(h,f.clone(t))}const r=e.morphAttributes;for(const h in r){const f=[],d=r[h];for(let m=0,g=d.length;m<g;m++)f.push(d[m].clone(t));this.morphAttributes[h]=f}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let h=0,f=s.length;h<f;h++){const d=s[h];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const x4=new ke,jc=new sh,$g=new ta,y4=new L,ev=new L,tv=new L,nv=new L,kT=new L,iv=new L,S4=new L,av=new L;class si extends Zt{constructor(e=new wt,t=new La){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=a.length;r<s;r++){const o=a[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const i=this.geometry,a=i.attributes.position,r=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(a,e);const o=this.morphTargetInfluences;if(r&&o){iv.set(0,0,0);for(let c=0,h=r.length;c<h;c++){const f=o[c],d=r[c];f!==0&&(kT.fromBufferAttribute(d,e),s?iv.addScaledVector(kT,f):iv.addScaledVector(kT.sub(t),f))}t.add(iv)}return t}raycast(e,t){const i=this.geometry,a=this.material,r=this.matrixWorld;a!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),$g.copy(i.boundingSphere),$g.applyMatrix4(r),jc.copy(e.ray).recast(e.near),!($g.containsPoint(jc.origin)===!1&&(jc.intersectSphere($g,y4)===null||jc.origin.distanceToSquared(y4)>(e.far-e.near)**2))&&(x4.copy(r).invert(),jc.copy(e.ray).applyMatrix4(x4),!(i.boundingBox!==null&&jc.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,jc)))}_computeIntersections(e,t,i){let a;const r=this.geometry,s=this.material,o=r.index,c=r.attributes.position,h=r.attributes.uv,f=r.attributes.uv1,d=r.attributes.normal,m=r.groups,g=r.drawRange;if(o!==null)if(Array.isArray(s))for(let x=0,T=m.length;x<T;x++){const S=m[x],v=s[S.materialIndex],y=Math.max(S.start,g.start),E=Math.min(o.count,Math.min(S.start+S.count,g.start+g.count));for(let b=y,D=E;b<D;b+=3){const C=o.getX(b),I=o.getX(b+1),P=o.getX(b+2);a=rv(this,v,e,i,h,f,d,C,I,P),a&&(a.faceIndex=Math.floor(b/3),a.face.materialIndex=S.materialIndex,t.push(a))}}else{const x=Math.max(0,g.start),T=Math.min(o.count,g.start+g.count);for(let S=x,v=T;S<v;S+=3){const y=o.getX(S),E=o.getX(S+1),b=o.getX(S+2);a=rv(this,s,e,i,h,f,d,y,E,b),a&&(a.faceIndex=Math.floor(S/3),t.push(a))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,T=m.length;x<T;x++){const S=m[x],v=s[S.materialIndex],y=Math.max(S.start,g.start),E=Math.min(c.count,Math.min(S.start+S.count,g.start+g.count));for(let b=y,D=E;b<D;b+=3){const C=b,I=b+1,P=b+2;a=rv(this,v,e,i,h,f,d,C,I,P),a&&(a.faceIndex=Math.floor(b/3),a.face.materialIndex=S.materialIndex,t.push(a))}}else{const x=Math.max(0,g.start),T=Math.min(c.count,g.start+g.count);for(let S=x,v=T;S<v;S+=3){const y=S,E=S+1,b=S+2;a=rv(this,s,e,i,h,f,d,y,E,b),a&&(a.faceIndex=Math.floor(S/3),t.push(a))}}}}function AG(n,e,t,i,a,r,s,o){let c;if(e.side===Oi?c=i.intersectTriangle(s,r,a,!0,o):c=i.intersectTriangle(a,r,s,e.side===Cs,o),c===null)return null;av.copy(o),av.applyMatrix4(n.matrixWorld);const h=t.ray.origin.distanceTo(av);return h<t.near||h>t.far?null:{distance:h,point:av.clone(),object:n}}function rv(n,e,t,i,a,r,s,o,c,h){n.getVertexPosition(o,ev),n.getVertexPosition(c,tv),n.getVertexPosition(h,nv);const f=AG(n,e,t,i,ev,tv,nv,S4);if(f){const d=new L;Ka.getBarycoord(S4,ev,tv,nv,d),a&&(f.uv=Ka.getInterpolatedAttribute(a,o,c,h,d,new de)),r&&(f.uv1=Ka.getInterpolatedAttribute(r,o,c,h,d,new de)),s&&(f.normal=Ka.getInterpolatedAttribute(s,o,c,h,d,new L),f.normal.dot(i.direction)>0&&f.normal.multiplyScalar(-1));const m={a:o,b:c,c:h,normal:new L,materialIndex:0};Ka.getNormal(ev,tv,nv,m.normal),f.face=m,f.barycoord=d}return f}class oh extends wt{constructor(e=1,t=1,i=1,a=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:a,heightSegments:r,depthSegments:s};const o=this;a=Math.floor(a),r=Math.floor(r),s=Math.floor(s);const c=[],h=[],f=[],d=[];let m=0,g=0;x("z","y","x",-1,-1,i,t,e,s,r,0),x("z","y","x",1,-1,i,t,-e,s,r,1),x("x","z","y",1,1,e,i,t,a,s,2),x("x","z","y",1,-1,e,i,-t,a,s,3),x("x","y","z",1,-1,e,t,i,a,r,4),x("x","y","z",-1,-1,e,t,-i,a,r,5),this.setIndex(c),this.setAttribute("position",new xt(h,3)),this.setAttribute("normal",new xt(f,3)),this.setAttribute("uv",new xt(d,2));function x(T,S,v,y,E,b,D,C,I,P,O){const R=b/I,B=D/P,j=b/2,ee=D/2,se=C/2,re=I+1,W=P+1;let te=0,K=0;const oe=new L;for(let ie=0;ie<W;ie++){const Ce=ie*B-ee;for(let Xe=0;Xe<re;Xe++){const nt=Xe*R-j;oe[T]=nt*y,oe[S]=Ce*E,oe[v]=se,h.push(oe.x,oe.y,oe.z),oe[T]=0,oe[S]=0,oe[v]=C>0?1:-1,f.push(oe.x,oe.y,oe.z),d.push(Xe/I),d.push(1-ie/P),te+=1}}for(let ie=0;ie<P;ie++)for(let Ce=0;Ce<I;Ce++){const Xe=m+Ce+re*ie,nt=m+Ce+re*(ie+1),tt=m+(Ce+1)+re*(ie+1),gt=m+(Ce+1)+re*ie;c.push(Xe,nt,gt),c.push(nt,tt,gt),K+=6}o.addGroup(g,K,O),g+=K,m+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oh(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function bd(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const a=n[t][i];a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)?a.isRenderTargetTexture?(ut("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=a.clone():Array.isArray(a)?e[t][i]=a.slice():e[t][i]=a}}return e}function Aa(n){const e={};for(let t=0;t<n.length;t++){const i=bd(n[t]);for(const a in i)e[a]=i[a]}return e}function RG(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function HU(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:rn.workingColorSpace}const Sb={clone:bd,merge:Aa};var wG=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,CG=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Fi extends qn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=wG,this.fragmentShader=CG,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=bd(e.uniforms),this.uniformsGroups=RG(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const a in this.uniforms){const s=this.uniforms[a].value;s&&s.isTexture?t.uniforms[a]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[a]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[a]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[a]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[a]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[a]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[a]={type:"m4",value:s.toArray()}:t.uniforms[a]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const a in this.extensions)this.extensions[a]===!0&&(i[a]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Tc extends Zt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ke,this.projectionMatrix=new ke,this.projectionMatrixInverse=new ke,this.coordinateSystem=Mr,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Nl=new L,T4=new de,E4=new de;let ui=class extends Tc{constructor(e=50,t=1,i=.1,a=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=a,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Ed*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Lu*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ed*2*Math.atan(Math.tan(Lu*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Nl.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Nl.x,Nl.y).multiplyScalar(-e/Nl.z),Nl.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Nl.x,Nl.y).multiplyScalar(-e/Nl.z)}getViewSize(e,t){return this.getViewBounds(e,T4,E4),t.subVectors(E4,T4)}setViewOffset(e,t,i,a,r,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=a,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Lu*.5*this.fov)/this.zoom,i=2*t,a=this.aspect*i,r=-.5*a;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,h=s.fullHeight;r+=s.offsetX*a/c,t-=s.offsetY*i/h,a*=s.width/c,i*=s.height/h}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+a,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};const $h=-90,ef=1;class FU extends Zt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const a=new ui($h,ef,e,t);a.layers=this.layers,this.add(a);const r=new ui($h,ef,e,t);r.layers=this.layers,this.add(r);const s=new ui($h,ef,e,t);s.layers=this.layers,this.add(s);const o=new ui($h,ef,e,t);o.layers=this.layers,this.add(o);const c=new ui($h,ef,e,t);c.layers=this.layers,this.add(c);const h=new ui($h,ef,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,a,r,s,o,c]=t;for(const h of t)this.remove(h);if(e===Mr)i.up.set(0,1,0),i.lookAt(1,0,0),a.up.set(0,1,0),a.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Sd)i.up.set(0,-1,0),i.lookAt(-1,0,0),a.up.set(0,-1,0),a.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:a}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,s,o,c,h,f]=this.children,d=e.getRenderTarget(),m=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const T=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,a),e.render(t,r),e.setRenderTarget(i,1,a),e.render(t,s),e.setRenderTarget(i,2,a),e.render(t,o),e.setRenderTarget(i,3,a),e.render(t,c),e.setRenderTarget(i,4,a),e.render(t,h),i.texture.generateMipmaps=T,e.setRenderTarget(i,5,a),e.render(t,f),e.setRenderTarget(d,m,g),e.xr.enabled=x,i.texture.needsPMREMUpdate=!0}}class L0 extends Nn{constructor(e=[],t=al,i,a,r,s,o,c,h,f){super(e,t,i,a,r,s,o,c,h,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class GU extends _i{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},a=[i,i,i,i,i,i];this.texture=new L0(a),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},a=new oh(5,5,5),r=new Fi({name:"CubemapFromEquirect",uniforms:bd(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Oi,blending:Sa});r.uniforms.tEquirect.value=t;const s=new si(a,r),o=t.minFilter;return t.minFilter===Er&&(t.minFilter=Ht),new FU(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,i=!0,a=!0){const r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,a);e.setRenderTarget(r)}}class Ia extends Zt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const NG={type:"move"};class p_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ia,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ia,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ia,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let a=null,r=null,s=null;const o=this._targetRay,c=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){s=!0;for(const T of e.hand.values()){const S=t.getJointPose(T,i),v=this._getHandJoint(h,T);S!==null&&(v.matrix.fromArray(S.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=S.radius),v.visible=S!==null}const f=h.joints["index-finger-tip"],d=h.joints["thumb-tip"],m=f.position.distanceTo(d.position),g=.02,x=.005;h.inputState.pinching&&m>g+x?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&m<=g-x&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(a=t.getPose(e.targetRaySpace,i),a===null&&r!==null&&(a=r),a!==null&&(o.matrix.fromArray(a.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,a.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(a.linearVelocity)):o.hasLinearVelocity=!1,a.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(a.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(NG)))}return o!==null&&(o.visible=a!==null),c!==null&&(c.visible=r!==null),h!==null&&(h.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Ia;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class P1{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new je(e),this.density=t}clone(){return new P1(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class z1{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new je(e),this.near=t,this.far=i}clone(){return new z1(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ad extends Zt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ui,this.environmentIntensity=1,this.environmentRotation=new Ui,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class I0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=l0,this.updateRanges=[],this.version=0,this.uuid=Cr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let a=0,r=this.stride;a<r;a++)this.array[e+a]=t.array[i+a];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ba=new L;class mc{constructor(e,t,i,a=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=a}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)ba.fromBufferAttribute(this,t),ba.applyMatrix4(e),this.setXYZ(t,ba.x,ba.y,ba.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ba.fromBufferAttribute(this,t),ba.applyNormalMatrix(e),this.setXYZ(t,ba.x,ba.y,ba.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ba.fromBufferAttribute(this,t),ba.transformDirection(e),this.setXYZ(t,ba.x,ba.y,ba.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Da(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=qt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Da(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Da(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Da(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Da(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),a=qt(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=a,this}setXYZW(e,t,i,a,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),a=qt(a,this.array),r=qt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=a,this.data.array[e+3]=r,this}clone(e){if(e===void 0){u0("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const a=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[a+r])}return new Ot(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new mc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){u0("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const a=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[a+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Tb extends qn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new je(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let tf;const Up=new L,nf=new L,af=new L,rf=new de,Pp=new de,VU=new ke,sv=new L,zp=new L,ov=new L,M4=new de,WT=new de,b4=new de;class kU extends Zt{constructor(e=new Tb){if(super(),this.isSprite=!0,this.type="Sprite",tf===void 0){tf=new wt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new I0(t,5);tf.setIndex([0,1,2,0,2,3]),tf.setAttribute("position",new mc(i,3,0,!1)),tf.setAttribute("uv",new mc(i,2,3,!1))}this.geometry=tf,this.material=e,this.center=new de(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Bt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),nf.setFromMatrixScale(this.matrixWorld),VU.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),af.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&nf.multiplyScalar(-af.z);const i=this.material.rotation;let a,r;i!==0&&(r=Math.cos(i),a=Math.sin(i));const s=this.center;lv(sv.set(-.5,-.5,0),af,s,nf,a,r),lv(zp.set(.5,-.5,0),af,s,nf,a,r),lv(ov.set(.5,.5,0),af,s,nf,a,r),M4.set(0,0),WT.set(1,0),b4.set(1,1);let o=e.ray.intersectTriangle(sv,zp,ov,!1,Up);if(o===null&&(lv(zp.set(-.5,.5,0),af,s,nf,a,r),WT.set(0,1),o=e.ray.intersectTriangle(sv,ov,zp,!1,Up),o===null))return;const c=e.ray.origin.distanceTo(Up);c<e.near||c>e.far||t.push({distance:c,point:Up.clone(),uv:Ka.getInterpolation(Up,sv,zp,ov,M4,WT,b4,new de),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function lv(n,e,t,i,a,r){rf.subVectors(n,t).addScalar(.5).multiply(i),a!==void 0?(Pp.x=r*rf.x-a*rf.y,Pp.y=a*rf.x+r*rf.y):Pp.copy(rf),n.copy(e),n.x+=Pp.x,n.y+=Pp.y,n.applyMatrix4(VU)}const cv=new L,A4=new L;class WU extends Zt{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,a=t.length;i<a;i++){const r=t[i];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const a=this.levels;let r;for(r=0;r<a.length&&!(t<a[r].distance);r++);return a.splice(r,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const a=t.splice(i,1);return this.remove(a[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,a;for(i=1,a=t.length;i<a;i++){let r=t[i].distance;if(t[i].object.visible&&(r-=r*t[i].hysteresis),e<r)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){cv.setFromMatrixPosition(this.matrixWorld);const a=e.ray.origin.distanceTo(cv);this.getObjectForDistance(a).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){cv.setFromMatrixPosition(e.matrixWorld),A4.setFromMatrixPosition(this.matrixWorld);const i=cv.distanceTo(A4)/e.zoom;t[0].object.visible=!0;let a,r;for(a=1,r=t.length;a<r;a++){let s=t[a].distance;if(t[a].object.visible&&(s-=s*t[a].hysteresis),i>=s)t[a-1].object.visible=!1,t[a].object.visible=!0;else break}for(this._currentLevel=a-1;a<r;a++)t[a].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let a=0,r=i.length;a<r;a++){const s=i[a];t.object.levels.push({object:s.object.uuid,distance:s.distance,hysteresis:s.hysteresis})}return t}}const R4=new L,w4=new zt,C4=new zt,DG=new L,N4=new ke,uv=new L,XT=new ta,D4=new ke,YT=new sh;class B1 extends si{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=nE,this.bindMatrix=new ke,this.bindMatrixInverse=new ke,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ea),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,uv),this.boundingBox.expandByPoint(uv)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ta),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,uv),this.boundingSphere.expandByPoint(uv)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,a=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),XT.copy(this.boundingSphere),XT.applyMatrix4(a),e.ray.intersectsSphere(XT)!==!1&&(D4.copy(a).invert(),YT.copy(e.ray).applyMatrix4(D4),!(this.boundingBox!==null&&YT.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,YT)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new zt,t=this.geometry.attributes.skinWeight;for(let i=0,a=t.count;i<a;i++){e.fromBufferAttribute(t,i);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===nE?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===vU?this.bindMatrixInverse.copy(this.bindMatrix).invert():ut("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,a=this.geometry;w4.fromBufferAttribute(a.attributes.skinIndex,e),C4.fromBufferAttribute(a.attributes.skinWeight,e),R4.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const s=C4.getComponent(r);if(s!==0){const o=w4.getComponent(r);N4.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(DG.copy(R4).applyMatrix4(N4),s)}}return t.applyMatrix4(this.bindMatrixInverse)}}class H1 extends Zt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ja extends Nn{constructor(e=null,t=1,i=1,a,r,s,o,c,h=Fn,f=Fn,d,m){super(null,s,o,c,h,f,a,r,d,m),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const O4=new ke,OG=new ke;class Ec{constructor(e=[],t=[]){this.uuid=Cr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){ut("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,a=this.bones.length;i<a;i++)this.boneInverses.push(new ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new ke;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,a=this.boneTexture;for(let r=0,s=e.length;r<s;r++){const o=e[r]?e[r].matrixWorld:OG;O4.multiplyMatrices(o,t[r]),O4.toArray(i,r*16)}a!==null&&(a.needsUpdate=!0)}clone(){return new Ec(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Ja(t,e,e,Jn,ri);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const a=this.bones[t];if(a.name===e)return a}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,a=e.bones.length;i<a;i++){const r=e.bones[i];let s=t[r];s===void 0&&(ut("Skeleton: No bone found with UUID:",r),s=new H1),this.bones.push(s),this.boneInverses.push(new ke().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let a=0,r=t.length;a<r;a++){const s=t[a];e.bones.push(s.uuid);const o=i[a];e.boneInverses.push(o.toArray())}return e}}class qu extends Ot{constructor(e,t,i,a=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=a}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const sf=new ke,L4=new ke,hv=[],I4=new ea,LG=new ke,Bp=new si,Hp=new ta;class Eb extends si{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qu(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let a=0;a<i;a++)this.setMatrixAt(a,LG)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ea),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,sf),I4.copy(e.boundingBox).applyMatrix4(sf),this.boundingBox.union(I4)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ta),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,sf),Hp.copy(e.boundingSphere).applyMatrix4(sf),this.boundingSphere.union(Hp)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,a=this.morphTexture.source.data.data,r=i.length+1,s=e*r+1;for(let o=0;o<i.length;o++)i[o]=a[s+o]}raycast(e,t){const i=this.matrixWorld,a=this.count;if(Bp.geometry=this.geometry,Bp.material=this.material,Bp.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Hp.copy(this.boundingSphere),Hp.applyMatrix4(i),e.ray.intersectsSphere(Hp)!==!1))for(let r=0;r<a;r++){this.getMatrixAt(r,sf),L4.multiplyMatrices(i,sf),Bp.matrixWorld=L4,Bp.raycast(e,hv);for(let s=0,o=hv.length;s<o;s++){const c=hv[s];c.instanceId=r,c.object=this,t.push(c)}hv.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new qu(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,a=i.length+1;this.morphTexture===null&&(this.morphTexture=new Ja(new Float32Array(a*this.count),a,this.count,bs,ri));const r=this.morphTexture.source.data.data;let s=0;for(let h=0;h<i.length;h++)s+=i[h];const o=this.geometry.morphTargetsRelative?1:1-s,c=a*e;r[c]=o,r.set(i,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const qT=new L,IG=new L,UG=new Et;class Fo{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,a){return this.normal.set(e,t,i),this.constant=a,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const a=qT.subVectors(i,t).cross(IG.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(a,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(qT),a=this.normal.dot(i);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/a;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||UG.getNormalMatrix(e),a=this.coplanarPoint(qT).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-a.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Zc=new ta,PG=new de(.5,.5),fv=new L;class Wd{constructor(e=new Fo,t=new Fo,i=new Fo,a=new Fo,r=new Fo,s=new Fo){this.planes=[e,t,i,a,r,s]}set(e,t,i,a,r,s){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(a),o[4].copy(r),o[5].copy(s),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Mr,i=!1){const a=this.planes,r=e.elements,s=r[0],o=r[1],c=r[2],h=r[3],f=r[4],d=r[5],m=r[6],g=r[7],x=r[8],T=r[9],S=r[10],v=r[11],y=r[12],E=r[13],b=r[14],D=r[15];if(a[0].setComponents(h-s,g-f,v-x,D-y).normalize(),a[1].setComponents(h+s,g+f,v+x,D+y).normalize(),a[2].setComponents(h+o,g+d,v+T,D+E).normalize(),a[3].setComponents(h-o,g-d,v-T,D-E).normalize(),i)a[4].setComponents(c,m,S,b).normalize(),a[5].setComponents(h-c,g-m,v-S,D-b).normalize();else if(a[4].setComponents(h-c,g-m,v-S,D-b).normalize(),t===Mr)a[5].setComponents(h+c,g+m,v+S,D+b).normalize();else if(t===Sd)a[5].setComponents(c,m,S,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Zc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Zc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zc)}intersectsSprite(e){Zc.center.set(0,0,0);const t=PG.distanceTo(e.center);return Zc.radius=.7071067811865476+t,Zc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zc)}intersectsSphere(e){const t=this.planes,i=e.center,a=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<a)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const a=t[i];if(fv.x=a.normal.x>0?e.max.x:e.min.x,fv.y=a.normal.y>0?e.max.y:e.min.y,fv.z=a.normal.z>0?e.max.z:e.min.z,a.distanceToPoint(fv)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Vs=new ke,ks=new Wd;class F1{constructor(){this.coordinateSystem=Mr}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.containsPoint(e))return!0}return!1}clone(){return new F1}}function jT(n,e){return n-e}function zG(n,e){return n.z-e.z}function BG(n,e){return e.z-n.z}class HG{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,a){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const o=r[this.index];s.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=a}reset(){this.list.length=0,this.index=0}}const Wa=new ke,FG=new je(1,1,1),U4=new Wd,GG=new F1,dv=new ea,Kc=new ta,Fp=new L,P4=new L,VG=new L,ZT=new HG,xa=new si,pv=[];function kG(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const a=n.count;for(let r=0;r<a;r++)for(let s=0;s<i;s++)e.setComponent(r+t,s,n.getComponent(r,s))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function Qc(n,e){if(n.constructor!==e.constructor){const t=Math.min(n.length,e.length);for(let i=0;i<t;i++)e[i]=n[i]}else{const t=Math.min(n.length,e.length);e.set(new n.constructor(n.buffer,0,t))}}class XU extends si{constructor(e,t,i=t*2,a){super(new wt,a),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new Ja(t,e,e,Jn,ri);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Ja(t,e,e,O0,Ns);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new Ja(t,e,e,Jn,ri);i.colorSpace=rn.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const r in e.attributes){const s=e.getAttribute(r),{array:o,itemSize:c,normalized:h}=s,f=new o.constructor(i*c),d=new Ot(f,c,h);t.setAttribute(r,d)}if(e.getIndex()!==null){const r=i>65535?new Uint32Array(a):new Uint16Array(a);t.setIndex(new Ot(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const a=e.getAttribute(i),r=t.getAttribute(i);if(a.itemSize!==r.itemSize||a.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ea);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,a=t.length;i<a;i++){if(t[i].active===!1)continue;const r=t[i].geometryIndex;this.getMatrixAt(i,Wa),this.getBoundingBoxAt(r,dv).applyMatrix4(Wa),e.union(dv)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ta);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let i=0,a=t.length;i<a;i++){if(t[i].active===!1)continue;const r=t[i].geometryIndex;this.getMatrixAt(i,Wa),this.getBoundingSphereAt(r,Kc).applyMatrix4(Wa),e.union(Kc)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let a=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(jT),a=this._availableInstanceIds.shift(),this._instanceInfo[a]=i):(a=this._instanceInfo.length,this._instanceInfo.push(i));const r=this._matricesTexture;Wa.identity().toArray(r.image.data,a*16),r.needsUpdate=!0;const s=this._colorsTexture;return s&&(FG.toArray(s.image.data,a*4),s.needsUpdate=!0),this._visibilityChanged=!0,a}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const a={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;a.vertexStart=this._nextVertexStart,a.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const s=e.getIndex();if(s!==null&&(a.indexStart=this._nextIndexStart,a.reservedIndexCount=i===-1?s.count:i),a.indexStart!==-1&&a.indexStart+a.reservedIndexCount>this._maxIndexCount||a.vertexStart+a.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(jT),c=this._availableGeometryIds.shift(),r[c]=a):(c=this._geometryCount,this._geometryCount++,r.push(a)),this.setGeometryAt(c,e),this._nextIndexStart=a.indexStart+a.reservedIndexCount,this._nextVertexStart=a.vertexStart+a.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,a=i.getIndex()!==null,r=i.getIndex(),s=t.getIndex(),o=this._geometryInfo[e];if(a&&s.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const c=o.vertexStart,h=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const f in i.attributes){const d=t.getAttribute(f),m=i.getAttribute(f);kG(d,m,c);const g=d.itemSize;for(let x=d.count,T=h;x<T;x++){const S=c+x;for(let v=0;v<g;v++)m.setComponent(S,v,0)}m.needsUpdate=!0,m.addUpdateRange(c*g,h*g)}if(a){const f=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let m=0;m<s.count;m++)r.setX(f+m,c+s.getX(m));for(let m=s.count,g=d;m<g;m++)r.setX(f+m,c);r.needsUpdate=!0,r.addUpdateRange(f,o.reservedIndexCount)}return o.start=a?o.indexStart:o.vertexStart,o.count=a?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let a=0,r=i.length;a<r;a++)i[a].active&&i[a].geometryIndex===e&&this.deleteInstance(a);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const i=this._geometryInfo,a=i.map((s,o)=>o).sort((s,o)=>i[s].vertexStart-i[o].vertexStart),r=this.geometry;for(let s=0,o=i.length;s<o;s++){const c=a[s],h=i[c];if(h.active!==!1){if(r.index!==null){if(h.indexStart!==t){const{indexStart:f,vertexStart:d,reservedIndexCount:m}=h,g=r.index,x=g.array,T=e-d;for(let S=f;S<f+m;S++)x[S]=x[S]+T;g.array.copyWithin(t,f,f+m),g.addUpdateRange(t,m),h.indexStart=t}t+=h.reservedIndexCount}if(h.vertexStart!==e){const{vertexStart:f,reservedVertexCount:d}=h,m=r.attributes;for(const g in m){const x=m[g],{array:T,itemSize:S}=x;T.copyWithin(e*S,f*S,(f+d)*S),x.addUpdateRange(e*S,d*S)}h.vertexStart=e}e+=h.reservedVertexCount,h.start=r.index?h.indexStart:h.vertexStart,this._nextIndexStart=r.index?h.indexStart+h.reservedIndexCount:0,this._nextVertexStart=h.vertexStart+h.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,a=this._geometryInfo[e];if(a.boundingBox===null){const r=new ea,s=i.index,o=i.attributes.position;for(let c=a.start,h=a.start+a.count;c<h;c++){let f=c;s&&(f=s.getX(f)),r.expandByPoint(Fp.fromBufferAttribute(o,f))}a.boundingBox=r}return t.copy(a.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,a=this._geometryInfo[e];if(a.boundingSphere===null){const r=new ta;this.getBoundingBoxAt(e,dv),dv.getCenter(r.center);const s=i.index,o=i.attributes.position;let c=0;for(let h=a.start,f=a.start+a.count;h<f;h++){let d=h;s&&(d=s.getX(d)),Fp.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(Fp))}r.radius=Math.sqrt(c),a.boundingSphere=r}return t.copy(a.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,a=this._matricesTexture.image.data;return t.toArray(a,e*16),i.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(jT);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(e<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const a=new Int32Array(e),r=new Int32Array(e);Qc(this._multiDrawCounts,a),Qc(this._multiDrawStarts,r),this._multiDrawCounts=a,this._multiDrawStarts=r,this._maxInstanceCount=e;const s=this._indirectTexture,o=this._matricesTexture,c=this._colorsTexture;s.dispose(),this._initIndirectTexture(),Qc(s.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Qc(o.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),Qc(c.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const i=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...i.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new wt,this._initializeGeometry(r));const s=this.geometry;r.index&&Qc(r.index.array,s.index.array);for(const o in r.attributes)Qc(r.attributes[o].array,s.attributes[o].array)}raycast(e,t){const i=this._instanceInfo,a=this._geometryInfo,r=this.matrixWorld,s=this.geometry;xa.material=this.material,xa.geometry.index=s.index,xa.geometry.attributes=s.attributes,xa.geometry.boundingBox===null&&(xa.geometry.boundingBox=new ea),xa.geometry.boundingSphere===null&&(xa.geometry.boundingSphere=new ta);for(let o=0,c=i.length;o<c;o++){if(!i[o].visible||!i[o].active)continue;const h=i[o].geometryIndex,f=a[h];xa.geometry.setDrawRange(f.start,f.count),this.getMatrixAt(o,xa.matrixWorld).premultiply(r),this.getBoundingBoxAt(h,xa.geometry.boundingBox),this.getBoundingSphereAt(h,xa.geometry.boundingSphere),xa.raycast(e,pv);for(let d=0,m=pv.length;d<m;d++){const g=pv[d];g.object=this,g.batchId=o,t.push(g)}pv.length=0}xa.material=null,xa.geometry.index=null,xa.geometry.attributes={},xa.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,a,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=a.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,c=this._instanceInfo,h=this._multiDrawStarts,f=this._multiDrawCounts,d=this._geometryInfo,m=this.perObjectFrustumCulled,g=this._indirectTexture,x=g.image.data,T=i.isArrayCamera?GG:U4;m&&!i.isArrayCamera&&(Wa.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),U4.setFromProjectionMatrix(Wa,i.coordinateSystem,i.reversedDepth));let S=0;if(this.sortObjects){Wa.copy(this.matrixWorld).invert(),Fp.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Wa),P4.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Wa);for(let E=0,b=c.length;E<b;E++)if(c[E].visible&&c[E].active){const D=c[E].geometryIndex;this.getMatrixAt(E,Wa),this.getBoundingSphereAt(D,Kc).applyMatrix4(Wa);let C=!1;if(m&&(C=!T.intersectsSphere(Kc,i)),!C){const I=d[D],P=VG.subVectors(Kc.center,Fp).dot(P4);ZT.push(I.start,I.count,P,E)}}const v=ZT.list,y=this.customSort;y===null?v.sort(r.transparent?BG:zG):y.call(this,v,i);for(let E=0,b=v.length;E<b;E++){const D=v[E];h[S]=D.start*o,f[S]=D.count,x[S]=D.index,S++}ZT.reset()}else for(let v=0,y=c.length;v<y;v++)if(c[v].visible&&c[v].active){const E=c[v].geometryIndex;let b=!1;if(m&&(this.getMatrixAt(v,Wa),this.getBoundingSphereAt(E,Kc).applyMatrix4(Wa),b=!T.intersectsSphere(Kc,i)),!b){const D=d[E];h[S]=D.start*o,f[S]=D.count,x[S]=v,S++}}g.needsUpdate=!0,this._multiDrawCount=S,this._visibilityChanged=!1}onBeforeShadow(e,t,i,a,r,s){this.onBeforeRender(e,null,a,r,s)}}class Pi extends qn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new je(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Ix=new L,Ux=new L,z4=new ke,Gp=new sh,mv=new ta,KT=new L,B4=new L;class ro extends Zt{constructor(e=new wt,t=new Pi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let a=1,r=t.count;a<r;a++)Ix.fromBufferAttribute(t,a-1),Ux.fromBufferAttribute(t,a),i[a]=i[a-1],i[a]+=Ix.distanceTo(Ux);e.setAttribute("lineDistance",new xt(i,1))}else ut("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,a=this.matrixWorld,r=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),mv.copy(i.boundingSphere),mv.applyMatrix4(a),mv.radius+=r,e.ray.intersectsSphere(mv)===!1)return;z4.copy(a).invert(),Gp.copy(e.ray).applyMatrix4(z4);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,h=this.isLineSegments?2:1,f=i.index,m=i.attributes.position;if(f!==null){const g=Math.max(0,s.start),x=Math.min(f.count,s.start+s.count);for(let T=g,S=x-1;T<S;T+=h){const v=f.getX(T),y=f.getX(T+1),E=gv(this,e,Gp,c,v,y,T);E&&t.push(E)}if(this.isLineLoop){const T=f.getX(x-1),S=f.getX(g),v=gv(this,e,Gp,c,T,S,x-1);v&&t.push(v)}}else{const g=Math.max(0,s.start),x=Math.min(m.count,s.start+s.count);for(let T=g,S=x-1;T<S;T+=h){const v=gv(this,e,Gp,c,T,T+1,T);v&&t.push(v)}if(this.isLineLoop){const T=gv(this,e,Gp,c,x-1,g,x-1);T&&t.push(T)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=a.length;r<s;r++){const o=a[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function gv(n,e,t,i,a,r,s){const o=n.geometry.attributes.position;if(Ix.fromBufferAttribute(o,a),Ux.fromBufferAttribute(o,r),t.distanceSqToSegment(Ix,Ux,KT,B4)>i)return;KT.applyMatrix4(n.matrixWorld);const h=e.ray.origin.distanceTo(KT);if(!(h<e.near||h>e.far))return{distance:h,point:B4.clone().applyMatrix4(n.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:n}}const H4=new L,F4=new L;class nr extends ro{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let a=0,r=t.count;a<r;a+=2)H4.fromBufferAttribute(t,a),F4.fromBufferAttribute(t,a+1),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+H4.distanceTo(F4);e.setAttribute("lineDistance",new xt(i,1))}else ut("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Mb extends ro{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class G1 extends qn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new je(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const G4=new ke,rE=new sh,vv=new ta,_v=new L;class bb extends Zt{constructor(e=new wt,t=new G1){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,a=this.matrixWorld,r=e.params.Points.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),vv.copy(i.boundingSphere),vv.applyMatrix4(a),vv.radius+=r,e.ray.intersectsSphere(vv)===!1)return;G4.copy(a).invert(),rE.copy(e.ray).applyMatrix4(G4);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,h=i.index,d=i.attributes.position;if(h!==null){const m=Math.max(0,s.start),g=Math.min(h.count,s.start+s.count);for(let x=m,T=g;x<T;x++){const S=h.getX(x);_v.fromBufferAttribute(d,S),V4(_v,S,c,a,e,t,this)}}else{const m=Math.max(0,s.start),g=Math.min(d.count,s.start+s.count);for(let x=m,T=g;x<T;x++)_v.fromBufferAttribute(d,x),V4(_v,x,c,a,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=a.length;r<s;r++){const o=a[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function V4(n,e,t,i,a,r,s){const o=rE.distanceSqToPoint(n);if(o<t){const c=new L;rE.closestPointToPoint(n,c),c.applyMatrix4(i);const h=a.ray.origin.distanceTo(c);if(h<a.near||h>a.far)return;r.push({distance:h,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:s})}}class YU extends Nn{constructor(e,t,i,a,r=Ht,s=Ht,o,c,h){super(e,t,i,a,r,s,o,c,h),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const f=this;function d(){f.needsUpdate=!0,f._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class WG extends YU{constructor(e,t,i,a,r,s,o,c){super({},e,t,i,a,r,s,o,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class XG extends Nn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Fn,this.minFilter=Fn,this.generateMipmaps=!1,this.needsUpdate=!0}}class V1 extends Nn{constructor(e,t,i,a,r,s,o,c,h,f,d,m){super(null,s,o,c,h,f,a,r,d,m),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class YG extends V1{constructor(e,t,i,a,r,s){super(e,t,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=a,this.wrapR=Li,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class qG extends V1{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,al),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class jG extends Nn{constructor(e,t,i,a,r,s,o,c,h){super(e,t,i,a,r,s,o,c,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class U0 extends Nn{constructor(e,t,i=Ns,a,r,s,o=Fn,c=Fn,h,f=_d,d=1){if(f!==_d&&f!==Yu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:t,depth:d};super(m,a,r,s,o,c,f,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Zl(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Ab extends Nn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class k1 extends wt{constructor(e=1,t=1,i=4,a=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:a,heightSegments:r},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),a=Math.max(3,Math.floor(a)),r=Math.max(1,Math.floor(r));const s=[],o=[],c=[],h=[],f=t/2,d=Math.PI/2*e,m=t,g=2*d+m,x=i*2+r,T=a+1,S=new L,v=new L;for(let y=0;y<=x;y++){let E=0,b=0,D=0,C=0;if(y<=i){const O=y/i,R=O*Math.PI/2;b=-f-e*Math.cos(R),D=e*Math.sin(R),C=-e*Math.cos(R),E=O*d}else if(y<=i+r){const O=(y-i)/r;b=-f+O*t,D=e,C=0,E=d+O*m}else{const O=(y-i-r)/i,R=O*Math.PI/2;b=f+e*Math.sin(R),D=e*Math.cos(R),C=e*Math.sin(R),E=d+m+O*d}const I=Math.max(0,Math.min(1,E/g));let P=0;y===0?P=.5/a:y===x&&(P=-.5/a);for(let O=0;O<=a;O++){const R=O/a,B=R*Math.PI*2,j=Math.sin(B),ee=Math.cos(B);v.x=-D*ee,v.y=b,v.z=D*j,o.push(v.x,v.y,v.z),S.set(-D*ee,C,D*j),S.normalize(),c.push(S.x,S.y,S.z),h.push(R+P,I)}if(y>0){const O=(y-1)*T;for(let R=0;R<a;R++){const B=O+R,j=O+R+1,ee=y*T+R,se=y*T+R+1;s.push(B,j,ee),s.push(j,se,ee)}}}this.setIndex(s),this.setAttribute("position",new xt(o,3)),this.setAttribute("normal",new xt(c,3)),this.setAttribute("uv",new xt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new k1(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class W1 extends wt{constructor(e=1,t=32,i=0,a=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:a},t=Math.max(3,t);const r=[],s=[],o=[],c=[],h=new L,f=new de;s.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let d=0,m=3;d<=t;d++,m+=3){const g=i+d/t*a;h.x=e*Math.cos(g),h.y=e*Math.sin(g),s.push(h.x,h.y,h.z),o.push(0,0,1),f.x=(s[m]/e+1)/2,f.y=(s[m+1]/e+1)/2,c.push(f.x,f.y)}for(let d=1;d<=t;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new xt(s,3)),this.setAttribute("normal",new xt(o,3)),this.setAttribute("uv",new xt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new W1(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class P0 extends wt{constructor(e=1,t=1,i=1,a=32,r=1,s=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:a,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:c};const h=this;a=Math.floor(a),r=Math.floor(r);const f=[],d=[],m=[],g=[];let x=0;const T=[],S=i/2;let v=0;y(),s===!1&&(e>0&&E(!0),t>0&&E(!1)),this.setIndex(f),this.setAttribute("position",new xt(d,3)),this.setAttribute("normal",new xt(m,3)),this.setAttribute("uv",new xt(g,2));function y(){const b=new L,D=new L;let C=0;const I=(t-e)/i;for(let P=0;P<=r;P++){const O=[],R=P/r,B=R*(t-e)+e;for(let j=0;j<=a;j++){const ee=j/a,se=ee*c+o,re=Math.sin(se),W=Math.cos(se);D.x=B*re,D.y=-R*i+S,D.z=B*W,d.push(D.x,D.y,D.z),b.set(re,I,W).normalize(),m.push(b.x,b.y,b.z),g.push(ee,1-R),O.push(x++)}T.push(O)}for(let P=0;P<a;P++)for(let O=0;O<r;O++){const R=T[O][P],B=T[O+1][P],j=T[O+1][P+1],ee=T[O][P+1];(e>0||O!==0)&&(f.push(R,B,ee),C+=3),(t>0||O!==r-1)&&(f.push(B,j,ee),C+=3)}h.addGroup(v,C,0),v+=C}function E(b){const D=x,C=new de,I=new L;let P=0;const O=b===!0?e:t,R=b===!0?1:-1;for(let j=1;j<=a;j++)d.push(0,S*R,0),m.push(0,R,0),g.push(.5,.5),x++;const B=x;for(let j=0;j<=a;j++){const se=j/a*c+o,re=Math.cos(se),W=Math.sin(se);I.x=O*W,I.y=S*R,I.z=O*re,d.push(I.x,I.y,I.z),m.push(0,R,0),C.x=re*.5+.5,C.y=W*.5*R+.5,g.push(C.x,C.y),x++}for(let j=0;j<a;j++){const ee=D+j,se=B+j;b===!0?f.push(se,se+1,ee):f.push(se+1,se,ee),P+=3}h.addGroup(v,P,b===!0?1:2),v+=P}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new P0(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class z0 extends P0{constructor(e=1,t=1,i=32,a=1,r=!1,s=0,o=Math.PI*2){super(0,e,t,i,a,r,s,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:a,openEnded:r,thetaStart:s,thetaLength:o}}static fromJSON(e){return new z0(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Mc extends wt{constructor(e=[],t=[],i=1,a=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:a};const r=[],s=[];o(a),h(i),f(),this.setAttribute("position",new xt(r,3)),this.setAttribute("normal",new xt(r.slice(),3)),this.setAttribute("uv",new xt(s,2)),a===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const E=new L,b=new L,D=new L;for(let C=0;C<t.length;C+=3)g(t[C+0],E),g(t[C+1],b),g(t[C+2],D),c(E,b,D,y)}function c(y,E,b,D){const C=D+1,I=[];for(let P=0;P<=C;P++){I[P]=[];const O=y.clone().lerp(b,P/C),R=E.clone().lerp(b,P/C),B=C-P;for(let j=0;j<=B;j++)j===0&&P===C?I[P][j]=O:I[P][j]=O.clone().lerp(R,j/B)}for(let P=0;P<C;P++)for(let O=0;O<2*(C-P)-1;O++){const R=Math.floor(O/2);O%2===0?(m(I[P][R+1]),m(I[P+1][R]),m(I[P][R])):(m(I[P][R+1]),m(I[P+1][R+1]),m(I[P+1][R]))}}function h(y){const E=new L;for(let b=0;b<r.length;b+=3)E.x=r[b+0],E.y=r[b+1],E.z=r[b+2],E.normalize().multiplyScalar(y),r[b+0]=E.x,r[b+1]=E.y,r[b+2]=E.z}function f(){const y=new L;for(let E=0;E<r.length;E+=3){y.x=r[E+0],y.y=r[E+1],y.z=r[E+2];const b=S(y)/2/Math.PI+.5,D=v(y)/Math.PI+.5;s.push(b,1-D)}x(),d()}function d(){for(let y=0;y<s.length;y+=6){const E=s[y+0],b=s[y+2],D=s[y+4],C=Math.max(E,b,D),I=Math.min(E,b,D);C>.9&&I<.1&&(E<.2&&(s[y+0]+=1),b<.2&&(s[y+2]+=1),D<.2&&(s[y+4]+=1))}}function m(y){r.push(y.x,y.y,y.z)}function g(y,E){const b=y*3;E.x=e[b+0],E.y=e[b+1],E.z=e[b+2]}function x(){const y=new L,E=new L,b=new L,D=new L,C=new de,I=new de,P=new de;for(let O=0,R=0;O<r.length;O+=9,R+=6){y.set(r[O+0],r[O+1],r[O+2]),E.set(r[O+3],r[O+4],r[O+5]),b.set(r[O+6],r[O+7],r[O+8]),C.set(s[R+0],s[R+1]),I.set(s[R+2],s[R+3]),P.set(s[R+4],s[R+5]),D.copy(y).add(E).add(b).divideScalar(3);const B=S(D);T(C,R+0,y,B),T(I,R+2,E,B),T(P,R+4,b,B)}}function T(y,E,b,D){D<0&&y.x===1&&(s[E]=y.x-1),b.x===0&&b.z===0&&(s[E]=D/2/Math.PI+.5)}function S(y){return Math.atan2(y.z,-y.x)}function v(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mc(e.vertices,e.indices,e.radius,e.details)}}class X1 extends Mc{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,a=1/i,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-a,-i,0,-a,i,0,a,-i,0,a,i,-a,-i,0,-a,i,0,a,-i,0,a,i,0,-i,0,-a,i,0,-a,-i,0,a,i,0,a],s=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(r,s,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new X1(e.radius,e.detail)}}const xv=new L,yv=new L,QT=new L,Sv=new Ka;class qU extends wt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const a=Math.pow(10,4),r=Math.cos(Lu*t),s=e.getIndex(),o=e.getAttribute("position"),c=s?s.count:o.count,h=[0,0,0],f=["a","b","c"],d=new Array(3),m={},g=[];for(let x=0;x<c;x+=3){s?(h[0]=s.getX(x),h[1]=s.getX(x+1),h[2]=s.getX(x+2)):(h[0]=x,h[1]=x+1,h[2]=x+2);const{a:T,b:S,c:v}=Sv;if(T.fromBufferAttribute(o,h[0]),S.fromBufferAttribute(o,h[1]),v.fromBufferAttribute(o,h[2]),Sv.getNormal(QT),d[0]=`${Math.round(T.x*a)},${Math.round(T.y*a)},${Math.round(T.z*a)}`,d[1]=`${Math.round(S.x*a)},${Math.round(S.y*a)},${Math.round(S.z*a)}`,d[2]=`${Math.round(v.x*a)},${Math.round(v.y*a)},${Math.round(v.z*a)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let y=0;y<3;y++){const E=(y+1)%3,b=d[y],D=d[E],C=Sv[f[y]],I=Sv[f[E]],P=`${b}_${D}`,O=`${D}_${b}`;O in m&&m[O]?(QT.dot(m[O].normal)<=r&&(g.push(C.x,C.y,C.z),g.push(I.x,I.y,I.z)),m[O]=null):P in m||(m[P]={index0:h[y],index1:h[E],normal:QT.clone()})}}for(const x in m)if(m[x]){const{index0:T,index1:S}=m[x];xv.fromBufferAttribute(o,T),yv.fromBufferAttribute(o,S),g.push(xv.x,xv.y,xv.z),g.push(yv.x,yv.y,yv.z)}this.setAttribute("position",new xt(g,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Os{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){ut("Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,a=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),r+=i.distanceTo(a),t.push(r),a=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let a=0;const r=i.length;let s;t?s=t:s=e*i[r-1];let o=0,c=r-1,h;for(;o<=c;)if(a=Math.floor(o+(c-o)/2),h=i[a]-s,h<0)o=a+1;else if(h>0)c=a-1;else{c=a;break}if(a=c,i[a]===s)return a/(r-1);const f=i[a],m=i[a+1]-f,g=(s-f)/m;return(a+g)/(r-1)}getTangent(e,t){let a=e-1e-4,r=e+1e-4;a<0&&(a=0),r>1&&(r=1);const s=this.getPoint(a),o=this.getPoint(r),c=t||(s.isVector2?new de:new L);return c.copy(o).sub(s).normalize(),c}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new L,a=[],r=[],s=[],o=new L,c=new ke;for(let g=0;g<=e;g++){const x=g/e;a[g]=this.getTangentAt(x,new L)}r[0]=new L,s[0]=new L;let h=Number.MAX_VALUE;const f=Math.abs(a[0].x),d=Math.abs(a[0].y),m=Math.abs(a[0].z);f<=h&&(h=f,i.set(1,0,0)),d<=h&&(h=d,i.set(0,1,0)),m<=h&&i.set(0,0,1),o.crossVectors(a[0],i).normalize(),r[0].crossVectors(a[0],o),s[0].crossVectors(a[0],r[0]);for(let g=1;g<=e;g++){if(r[g]=r[g-1].clone(),s[g]=s[g-1].clone(),o.crossVectors(a[g-1],a[g]),o.length()>Number.EPSILON){o.normalize();const x=Math.acos(Lt(a[g-1].dot(a[g]),-1,1));r[g].applyMatrix4(c.makeRotationAxis(o,x))}s[g].crossVectors(a[g],r[g])}if(t===!0){let g=Math.acos(Lt(r[0].dot(r[e]),-1,1));g/=e,a[0].dot(o.crossVectors(r[0],r[e]))>0&&(g=-g);for(let x=1;x<=e;x++)r[x].applyMatrix4(c.makeRotationAxis(a[x],g*x)),s[x].crossVectors(a[x],r[x])}return{tangents:a,normals:r,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Y1 extends Os{constructor(e=0,t=0,i=1,a=1,r=0,s=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=a,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=o,this.aRotation=c}getPoint(e,t=new de){const i=t,a=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=a;for(;r>a;)r-=a;r<Number.EPSILON&&(s?r=0:r=a),this.aClockwise===!0&&!s&&(r===a?r=-a:r=r-a);const o=this.aStartAngle+e*r;let c=this.aX+this.xRadius*Math.cos(o),h=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const f=Math.cos(this.aRotation),d=Math.sin(this.aRotation),m=c-this.aX,g=h-this.aY;c=m*f-g*d+this.aX,h=m*d+g*f+this.aY}return i.set(c,h)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class jU extends Y1{constructor(e,t,i,a,r,s){super(e,t,i,i,a,r,s),this.isArcCurve=!0,this.type="ArcCurve"}}function Rb(){let n=0,e=0,t=0,i=0;function a(r,s,o,c){n=r,e=o,t=-3*r+3*s-2*o-c,i=2*r-2*s+o+c}return{initCatmullRom:function(r,s,o,c,h){a(s,o,h*(o-r),h*(c-s))},initNonuniformCatmullRom:function(r,s,o,c,h,f,d){let m=(s-r)/h-(o-r)/(h+f)+(o-s)/f,g=(o-s)/f-(c-s)/(f+d)+(c-o)/d;m*=f,g*=f,a(s,o,m,g)},calc:function(r){const s=r*r,o=s*r;return n+e*r+t*s+i*o}}}const Tv=new L,JT=new Rb,$T=new Rb,e2=new Rb;class ZU extends Os{constructor(e=[],t=!1,i="centripetal",a=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=a}getPoint(e,t=new L){const i=t,a=this.points,r=a.length,s=(r-(this.closed?0:1))*e;let o=Math.floor(s),c=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:c===0&&o===r-1&&(o=r-2,c=1);let h,f;this.closed||o>0?h=a[(o-1)%r]:(Tv.subVectors(a[0],a[1]).add(a[0]),h=Tv);const d=a[o%r],m=a[(o+1)%r];if(this.closed||o+2<r?f=a[(o+2)%r]:(Tv.subVectors(a[r-1],a[r-2]).add(a[r-1]),f=Tv),this.curveType==="centripetal"||this.curveType==="chordal"){const g=this.curveType==="chordal"?.5:.25;let x=Math.pow(h.distanceToSquared(d),g),T=Math.pow(d.distanceToSquared(m),g),S=Math.pow(m.distanceToSquared(f),g);T<1e-4&&(T=1),x<1e-4&&(x=T),S<1e-4&&(S=T),JT.initNonuniformCatmullRom(h.x,d.x,m.x,f.x,x,T,S),$T.initNonuniformCatmullRom(h.y,d.y,m.y,f.y,x,T,S),e2.initNonuniformCatmullRom(h.z,d.z,m.z,f.z,x,T,S)}else this.curveType==="catmullrom"&&(JT.initCatmullRom(h.x,d.x,m.x,f.x,this.tension),$T.initCatmullRom(h.y,d.y,m.y,f.y,this.tension),e2.initCatmullRom(h.z,d.z,m.z,f.z,this.tension));return i.set(JT.calc(c),$T.calc(c),e2.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const a=e.points[t];this.points.push(a.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const a=this.points[t];e.points.push(a.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const a=e.points[t];this.points.push(new L().fromArray(a))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function k4(n,e,t,i,a){const r=(i-e)*.5,s=(a-t)*.5,o=n*n,c=n*o;return(2*t-2*i+r+s)*c+(-3*t+3*i-2*r-s)*o+r*n+t}function ZG(n,e){const t=1-n;return t*t*e}function KG(n,e){return 2*(1-n)*n*e}function QG(n,e){return n*n*e}function Um(n,e,t,i){return ZG(n,e)+KG(n,t)+QG(n,i)}function JG(n,e){const t=1-n;return t*t*t*e}function $G(n,e){const t=1-n;return 3*t*t*n*e}function eV(n,e){return 3*(1-n)*n*n*e}function tV(n,e){return n*n*n*e}function Pm(n,e,t,i,a){return JG(n,e)+$G(n,t)+eV(n,i)+tV(n,a)}class wb extends Os{constructor(e=new de,t=new de,i=new de,a=new de){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=a}getPoint(e,t=new de){const i=t,a=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(Pm(e,a.x,r.x,s.x,o.x),Pm(e,a.y,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class KU extends Os{constructor(e=new L,t=new L,i=new L,a=new L){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=a}getPoint(e,t=new L){const i=t,a=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(Pm(e,a.x,r.x,s.x,o.x),Pm(e,a.y,r.y,s.y,o.y),Pm(e,a.z,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Cb extends Os{constructor(e=new de,t=new de){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new de){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new de){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class QU extends Os{constructor(e=new L,t=new L){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new L){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new L){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Nb extends Os{constructor(e=new de,t=new de,i=new de){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new de){const i=t,a=this.v0,r=this.v1,s=this.v2;return i.set(Um(e,a.x,r.x,s.x),Um(e,a.y,r.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Db extends Os{constructor(e=new L,t=new L,i=new L){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new L){const i=t,a=this.v0,r=this.v1,s=this.v2;return i.set(Um(e,a.x,r.x,s.x),Um(e,a.y,r.y,s.y),Um(e,a.z,r.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ob extends Os{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new de){const i=t,a=this.points,r=(a.length-1)*e,s=Math.floor(r),o=r-s,c=a[s===0?s:s-1],h=a[s],f=a[s>a.length-2?a.length-1:s+1],d=a[s>a.length-3?a.length-1:s+2];return i.set(k4(o,c.x,h.x,f.x,d.x),k4(o,c.y,h.y,f.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const a=e.points[t];this.points.push(a.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const a=this.points[t];e.points.push(a.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const a=e.points[t];this.points.push(new de().fromArray(a))}return this}}var Px=Object.freeze({__proto__:null,ArcCurve:jU,CatmullRomCurve3:ZU,CubicBezierCurve:wb,CubicBezierCurve3:KU,EllipseCurve:Y1,LineCurve:Cb,LineCurve3:QU,QuadraticBezierCurve:Nb,QuadraticBezierCurve3:Db,SplineCurve:Ob});class JU extends Os{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Px[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),a=this.getCurveLengths();let r=0;for(;r<a.length;){if(a[r]>=i){const s=a[r]-i,o=this.curves[r],c=o.getLength(),h=c===0?0:1-s/c;return o.getPointAt(h,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,a=this.curves.length;i<a;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let a=0,r=this.curves;a<r.length;a++){const s=r[a],o=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,c=s.getPoints(o);for(let h=0;h<c.length;h++){const f=c[h];i&&i.equals(f)||(t.push(f),i=f)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const a=e.curves[t];this.curves.push(a.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const a=this.curves[t];e.curves.push(a.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const a=e.curves[t];this.curves.push(new Px[a.type]().fromJSON(a))}return this}}class zx extends JU{constructor(e){super(),this.type="Path",this.currentPoint=new de,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new Cb(this.currentPoint.clone(),new de(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,a){const r=new Nb(this.currentPoint.clone(),new de(e,t),new de(i,a));return this.curves.push(r),this.currentPoint.set(i,a),this}bezierCurveTo(e,t,i,a,r,s){const o=new wb(this.currentPoint.clone(),new de(e,t),new de(i,a),new de(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Ob(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,a,r,s){const o=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+o,t+c,i,a,r,s),this}absarc(e,t,i,a,r,s){return this.absellipse(e,t,i,i,a,r,s),this}ellipse(e,t,i,a,r,s,o,c){const h=this.currentPoint.x,f=this.currentPoint.y;return this.absellipse(e+h,t+f,i,a,r,s,o,c),this}absellipse(e,t,i,a,r,s,o,c){const h=new Y1(e,t,i,a,r,s,o,c);if(this.curves.length>0){const d=h.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(h);const f=h.getPoint(1);return this.currentPoint.copy(f),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Iu extends zx{constructor(e){super(e),this.uuid=Cr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,a=this.holes.length;i<a;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const a=e.holes[t];this.holes.push(a.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const a=this.holes[t];e.holes.push(a.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const a=e.holes[t];this.holes.push(new zx().fromJSON(a))}return this}}function nV(n,e,t=2){const i=e&&e.length,a=i?e[0]*t:n.length;let r=$U(n,0,a,t,!0);const s=[];if(!r||r.next===r.prev)return s;let o,c,h;if(i&&(r=oV(n,e,r,t)),n.length>80*t){o=n[0],c=n[1];let f=o,d=c;for(let m=t;m<a;m+=t){const g=n[m],x=n[m+1];g<o&&(o=g),x<c&&(c=x),g>f&&(f=g),x>d&&(d=x)}h=Math.max(f-o,d-c),h=h!==0?32767/h:0}return h0(r,s,t,o,c,h,0),s}function $U(n,e,t,i,a){let r;if(a===_V(n,e,t,i)>0)for(let s=e;s<t;s+=i)r=W4(s/i|0,n[s],n[s+1],r);else for(let s=t-i;s>=e;s-=i)r=W4(s/i|0,n[s],n[s+1],r);return r&&Rd(r,r.next)&&(d0(r),r=r.next),r}function ju(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Rd(t,t.next)||hi(t.prev,t,t.next)===0)){if(d0(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function h0(n,e,t,i,a,r,s){if(!n)return;!s&&r&&fV(n,i,a,r);let o=n;for(;n.prev!==n.next;){const c=n.prev,h=n.next;if(r?aV(n,i,a,r):iV(n)){e.push(c.i,n.i,h.i),d0(n),n=h.next,o=h.next;continue}if(n=h,n===o){s?s===1?(n=rV(ju(n),e),h0(n,e,t,i,a,r,2)):s===2&&sV(n,e,t,i,a,r):h0(ju(n),e,t,i,a,r,1);break}}}function iV(n){const e=n.prev,t=n,i=n.next;if(hi(e,t,i)>=0)return!1;const a=e.x,r=t.x,s=i.x,o=e.y,c=t.y,h=i.y,f=Math.min(a,r,s),d=Math.min(o,c,h),m=Math.max(a,r,s),g=Math.max(o,c,h);let x=i.next;for(;x!==e;){if(x.x>=f&&x.x<=m&&x.y>=d&&x.y<=g&&lm(a,o,r,c,s,h,x.x,x.y)&&hi(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function aV(n,e,t,i){const a=n.prev,r=n,s=n.next;if(hi(a,r,s)>=0)return!1;const o=a.x,c=r.x,h=s.x,f=a.y,d=r.y,m=s.y,g=Math.min(o,c,h),x=Math.min(f,d,m),T=Math.max(o,c,h),S=Math.max(f,d,m),v=sE(g,x,e,t,i),y=sE(T,S,e,t,i);let E=n.prevZ,b=n.nextZ;for(;E&&E.z>=v&&b&&b.z<=y;){if(E.x>=g&&E.x<=T&&E.y>=x&&E.y<=S&&E!==a&&E!==s&&lm(o,f,c,d,h,m,E.x,E.y)&&hi(E.prev,E,E.next)>=0||(E=E.prevZ,b.x>=g&&b.x<=T&&b.y>=x&&b.y<=S&&b!==a&&b!==s&&lm(o,f,c,d,h,m,b.x,b.y)&&hi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;E&&E.z>=v;){if(E.x>=g&&E.x<=T&&E.y>=x&&E.y<=S&&E!==a&&E!==s&&lm(o,f,c,d,h,m,E.x,E.y)&&hi(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;b&&b.z<=y;){if(b.x>=g&&b.x<=T&&b.y>=x&&b.y<=S&&b!==a&&b!==s&&lm(o,f,c,d,h,m,b.x,b.y)&&hi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function rV(n,e){let t=n;do{const i=t.prev,a=t.next.next;!Rd(i,a)&&t6(i,t,t.next,a)&&f0(i,a)&&f0(a,i)&&(e.push(i.i,t.i,a.i),d0(t),d0(t.next),t=n=a),t=t.next}while(t!==n);return ju(t)}function sV(n,e,t,i,a,r){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&mV(s,o)){let c=n6(s,o);s=ju(s,s.next),c=ju(c,c.next),h0(s,e,t,i,a,r,0),h0(c,e,t,i,a,r,0);return}o=o.next}s=s.next}while(s!==n)}function oV(n,e,t,i){const a=[];for(let r=0,s=e.length;r<s;r++){const o=e[r]*i,c=r<s-1?e[r+1]*i:n.length,h=$U(n,o,c,i,!1);h===h.next&&(h.steiner=!0),a.push(pV(h))}a.sort(lV);for(let r=0;r<a.length;r++)t=cV(a[r],t);return t}function lV(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){const i=(n.next.y-n.y)/(n.next.x-n.x),a=(e.next.y-e.y)/(e.next.x-e.x);t=i-a}return t}function cV(n,e){const t=uV(n,e);if(!t)return e;const i=n6(t,n);return ju(i,i.next),ju(t,t.next)}function uV(n,e){let t=e;const i=n.x,a=n.y;let r=-1/0,s;if(Rd(n,t))return t;do{if(Rd(n,t.next))return t.next;if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,s=t.x<t.next.x?t:t.next,d===i))return s}t=t.next}while(t!==e);if(!s)return null;const o=s,c=s.x,h=s.y;let f=1/0;t=s;do{if(i>=t.x&&t.x>=c&&i!==t.x&&e6(a<h?i:r,a,c,h,a<h?r:i,a,t.x,t.y)){const d=Math.abs(a-t.y)/(i-t.x);f0(t,n)&&(d<f||d===f&&(t.x>s.x||t.x===s.x&&hV(s,t)))&&(s=t,f=d)}t=t.next}while(t!==o);return s}function hV(n,e){return hi(n.prev,n,e.prev)<0&&hi(e.next,n,n.next)<0}function fV(n,e,t,i){let a=n;do a.z===0&&(a.z=sE(a.x,a.y,e,t,i)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==n);a.prevZ.nextZ=null,a.prevZ=null,dV(a)}function dV(n){let e,t=1;do{let i=n,a;n=null;let r=null;for(e=0;i;){e++;let s=i,o=0;for(let h=0;h<t&&(o++,s=s.nextZ,!!s);h++);let c=t;for(;o>0||c>0&&s;)o!==0&&(c===0||!s||i.z<=s.z)?(a=i,i=i.nextZ,o--):(a=s,s=s.nextZ,c--),r?r.nextZ=a:n=a,a.prevZ=r,r=a;i=s}r.nextZ=null,t*=2}while(e>1);return n}function sE(n,e,t,i,a){return n=(n-t)*a|0,e=(e-i)*a|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function pV(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function e6(n,e,t,i,a,r,s,o){return(a-s)*(e-o)>=(n-s)*(r-o)&&(n-s)*(i-o)>=(t-s)*(e-o)&&(t-s)*(r-o)>=(a-s)*(i-o)}function lm(n,e,t,i,a,r,s,o){return!(n===s&&e===o)&&e6(n,e,t,i,a,r,s,o)}function mV(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!gV(n,e)&&(f0(n,e)&&f0(e,n)&&vV(n,e)&&(hi(n.prev,n,e.prev)||hi(n,e.prev,e))||Rd(n,e)&&hi(n.prev,n,n.next)>0&&hi(e.prev,e,e.next)>0)}function hi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Rd(n,e){return n.x===e.x&&n.y===e.y}function t6(n,e,t,i){const a=Mv(hi(n,e,t)),r=Mv(hi(n,e,i)),s=Mv(hi(t,i,n)),o=Mv(hi(t,i,e));return!!(a!==r&&s!==o||a===0&&Ev(n,t,e)||r===0&&Ev(n,i,e)||s===0&&Ev(t,n,i)||o===0&&Ev(t,e,i))}function Ev(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Mv(n){return n>0?1:n<0?-1:0}function gV(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&t6(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function f0(n,e){return hi(n.prev,n,n.next)<0?hi(n,e,n.next)>=0&&hi(n,n.prev,e)>=0:hi(n,e,n.prev)<0||hi(n,n.next,e)<0}function vV(n,e){let t=n,i=!1;const a=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&a<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function n6(n,e){const t=oE(n.i,n.x,n.y),i=oE(e.i,e.x,e.y),a=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=a,a.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function W4(n,e,t,i){const a=oE(n,e,t);return i?(a.next=i.next,a.prev=i,i.next.prev=a,i.next=a):(a.prev=a,a.next=a),a}function d0(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function oE(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function _V(n,e,t,i){let a=0;for(let r=e,s=t-i;r<t;r+=i)a+=(n[s]-n[r])*(n[r+1]+n[s+1]),s=r;return a}class xV{static triangulate(e,t,i=2){return nV(e,t,i)}}class As{static area(e){const t=e.length;let i=0;for(let a=t-1,r=0;r<t;a=r++)i+=e[a].x*e[r].y-e[r].x*e[a].y;return i*.5}static isClockWise(e){return As.area(e)<0}static triangulateShape(e,t){const i=[],a=[],r=[];X4(e),Y4(i,e);let s=e.length;t.forEach(X4);for(let c=0;c<t.length;c++)a.push(s),s+=t[c].length,Y4(i,t[c]);const o=xV.triangulate(i,a);for(let c=0;c<o.length;c+=3)r.push(o.slice(c,c+3));return r}}function X4(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Y4(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class q1 extends wt{constructor(e=new Iu([new de(.5,.5),new de(-.5,.5),new de(-.5,-.5),new de(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,a=[],r=[];for(let o=0,c=e.length;o<c;o++){const h=e[o];s(h)}this.setAttribute("position",new xt(a,3)),this.setAttribute("uv",new xt(r,2)),this.computeVertexNormals();function s(o){const c=[],h=t.curveSegments!==void 0?t.curveSegments:12,f=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let m=t.bevelEnabled!==void 0?t.bevelEnabled:!0,g=t.bevelThickness!==void 0?t.bevelThickness:.2,x=t.bevelSize!==void 0?t.bevelSize:g-.1,T=t.bevelOffset!==void 0?t.bevelOffset:0,S=t.bevelSegments!==void 0?t.bevelSegments:3;const v=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:yV;let E,b=!1,D,C,I,P;v&&(E=v.getSpacedPoints(f),b=!0,m=!1,D=v.computeFrenetFrames(f,!1),C=new L,I=new L,P=new L),m||(S=0,g=0,x=0,T=0);const O=o.extractPoints(h);let R=O.shape;const B=O.holes;if(!As.isClockWise(R)){R=R.reverse();for(let Te=0,G=B.length;Te<G;Te++){const Me=B[Te];As.isClockWise(Me)&&(B[Te]=Me.reverse())}}function ee(Te){const Me=10000000000000001e-36;let De=Te[0];for(let Fe=1;Fe<=Te.length;Fe++){const Be=Fe%Te.length,$e=Te[Be],Je=$e.x-De.x,ct=$e.y-De.y,k=Je*Je+ct*ct,U=Math.max(Math.abs($e.x),Math.abs($e.y),Math.abs(De.x),Math.abs(De.y)),ce=Me*U*U;if(k<=ce){Te.splice(Be,1),Fe--;continue}De=$e}}ee(R),B.forEach(ee);const se=B.length,re=R;for(let Te=0;Te<se;Te++){const G=B[Te];R=R.concat(G)}function W(Te,G,Me){return G||Bt("ExtrudeGeometry: vec does not exist"),Te.clone().addScaledVector(G,Me)}const te=R.length;function K(Te,G,Me){let De,Fe,Be;const $e=Te.x-G.x,Je=Te.y-G.y,ct=Me.x-Te.x,k=Me.y-Te.y,U=$e*$e+Je*Je,ce=$e*k-Je*ct;if(Math.abs(ce)>Number.EPSILON){const Ee=Math.sqrt(U),Le=Math.sqrt(ct*ct+k*k),ye=G.x-Je/Ee,vt=G.y+$e/Ee,qe=Me.x-k/Le,_t=Me.y+ct/Le,pt=((qe-ye)*k-(_t-vt)*ct)/($e*k-Je*ct);De=ye+$e*pt-Te.x,Fe=vt+Je*pt-Te.y;const Ie=De*De+Fe*Fe;if(Ie<=2)return new de(De,Fe);Be=Math.sqrt(Ie/2)}else{let Ee=!1;$e>Number.EPSILON?ct>Number.EPSILON&&(Ee=!0):$e<-Number.EPSILON?ct<-Number.EPSILON&&(Ee=!0):Math.sign(Je)===Math.sign(k)&&(Ee=!0),Ee?(De=-Je,Fe=$e,Be=Math.sqrt(U)):(De=$e,Fe=Je,Be=Math.sqrt(U/2))}return new de(De/Be,Fe/Be)}const oe=[];for(let Te=0,G=re.length,Me=G-1,De=Te+1;Te<G;Te++,Me++,De++)Me===G&&(Me=0),De===G&&(De=0),oe[Te]=K(re[Te],re[Me],re[De]);const ie=[];let Ce,Xe=oe.concat();for(let Te=0,G=se;Te<G;Te++){const Me=B[Te];Ce=[];for(let De=0,Fe=Me.length,Be=Fe-1,$e=De+1;De<Fe;De++,Be++,$e++)Be===Fe&&(Be=0),$e===Fe&&($e=0),Ce[De]=K(Me[De],Me[Be],Me[$e]);ie.push(Ce),Xe=Xe.concat(Ce)}let nt;if(S===0)nt=As.triangulateShape(re,B);else{const Te=[],G=[];for(let Me=0;Me<S;Me++){const De=Me/S,Fe=g*Math.cos(De*Math.PI/2),Be=x*Math.sin(De*Math.PI/2)+T;for(let $e=0,Je=re.length;$e<Je;$e++){const ct=W(re[$e],oe[$e],Be);ue(ct.x,ct.y,-Fe),De===0&&Te.push(ct)}for(let $e=0,Je=se;$e<Je;$e++){const ct=B[$e];Ce=ie[$e];const k=[];for(let U=0,ce=ct.length;U<ce;U++){const Ee=W(ct[U],Ce[U],Be);ue(Ee.x,Ee.y,-Fe),De===0&&k.push(Ee)}De===0&&G.push(k)}}nt=As.triangulateShape(Te,G)}const tt=nt.length,gt=x+T;for(let Te=0;Te<te;Te++){const G=m?W(R[Te],Xe[Te],gt):R[Te];b?(I.copy(D.normals[0]).multiplyScalar(G.x),C.copy(D.binormals[0]).multiplyScalar(G.y),P.copy(E[0]).add(I).add(C),ue(P.x,P.y,P.z)):ue(G.x,G.y,0)}for(let Te=1;Te<=f;Te++)for(let G=0;G<te;G++){const Me=m?W(R[G],Xe[G],gt):R[G];b?(I.copy(D.normals[Te]).multiplyScalar(Me.x),C.copy(D.binormals[Te]).multiplyScalar(Me.y),P.copy(E[Te]).add(I).add(C),ue(P.x,P.y,P.z)):ue(Me.x,Me.y,d/f*Te)}for(let Te=S-1;Te>=0;Te--){const G=Te/S,Me=g*Math.cos(G*Math.PI/2),De=x*Math.sin(G*Math.PI/2)+T;for(let Fe=0,Be=re.length;Fe<Be;Fe++){const $e=W(re[Fe],oe[Fe],De);ue($e.x,$e.y,d+Me)}for(let Fe=0,Be=B.length;Fe<Be;Fe++){const $e=B[Fe];Ce=ie[Fe];for(let Je=0,ct=$e.length;Je<ct;Je++){const k=W($e[Je],Ce[Je],De);b?ue(k.x,k.y+E[f-1].y,E[f-1].x+Me):ue(k.x,k.y,d+Me)}}}ge(),Ae();function ge(){const Te=a.length/3;if(m){let G=0,Me=te*G;for(let De=0;De<tt;De++){const Fe=nt[De];it(Fe[2]+Me,Fe[1]+Me,Fe[0]+Me)}G=f+S*2,Me=te*G;for(let De=0;De<tt;De++){const Fe=nt[De];it(Fe[0]+Me,Fe[1]+Me,Fe[2]+Me)}}else{for(let G=0;G<tt;G++){const Me=nt[G];it(Me[2],Me[1],Me[0])}for(let G=0;G<tt;G++){const Me=nt[G];it(Me[0]+te*f,Me[1]+te*f,Me[2]+te*f)}}i.addGroup(Te,a.length/3-Te,0)}function Ae(){const Te=a.length/3;let G=0;Ze(re,G),G+=re.length;for(let Me=0,De=B.length;Me<De;Me++){const Fe=B[Me];Ze(Fe,G),G+=Fe.length}i.addGroup(Te,a.length/3-Te,1)}function Ze(Te,G){let Me=Te.length;for(;--Me>=0;){const De=Me;let Fe=Me-1;Fe<0&&(Fe=Te.length-1);for(let Be=0,$e=f+S*2;Be<$e;Be++){const Je=te*Be,ct=te*(Be+1),k=G+De+Je,U=G+Fe+Je,ce=G+Fe+ct,Ee=G+De+ct;Mt(k,U,ce,Ee)}}}function ue(Te,G,Me){c.push(Te),c.push(G),c.push(Me)}function it(Te,G,Me){ot(Te),ot(G),ot(Me);const De=a.length/3,Fe=y.generateTopUV(i,a,De-3,De-2,De-1);Ke(Fe[0]),Ke(Fe[1]),Ke(Fe[2])}function Mt(Te,G,Me,De){ot(Te),ot(G),ot(De),ot(G),ot(Me),ot(De);const Fe=a.length/3,Be=y.generateSideWallUV(i,a,Fe-6,Fe-3,Fe-2,Fe-1);Ke(Be[0]),Ke(Be[1]),Ke(Be[3]),Ke(Be[1]),Ke(Be[2]),Ke(Be[3])}function ot(Te){a.push(c[Te*3+0]),a.push(c[Te*3+1]),a.push(c[Te*3+2])}function Ke(Te){r.push(Te.x),r.push(Te.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return SV(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const o=t[e.shapes[r]];i.push(o)}const a=e.options.extrudePath;return a!==void 0&&(e.options.extrudePath=new Px[a.type]().fromJSON(a)),new q1(i,e.options)}}const yV={generateTopUV:function(n,e,t,i,a){const r=e[t*3],s=e[t*3+1],o=e[i*3],c=e[i*3+1],h=e[a*3],f=e[a*3+1];return[new de(r,s),new de(o,c),new de(h,f)]},generateSideWallUV:function(n,e,t,i,a,r){const s=e[t*3],o=e[t*3+1],c=e[t*3+2],h=e[i*3],f=e[i*3+1],d=e[i*3+2],m=e[a*3],g=e[a*3+1],x=e[a*3+2],T=e[r*3],S=e[r*3+1],v=e[r*3+2];return Math.abs(o-f)<Math.abs(s-h)?[new de(s,1-c),new de(h,1-d),new de(m,1-x),new de(T,1-v)]:[new de(o,1-c),new de(f,1-d),new de(g,1-x),new de(S,1-v)]}};function SV(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,a=n.length;i<a;i++){const r=n[i];t.shapes.push(r.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class j1 extends Mc{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,a=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(a,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new j1(e.radius,e.detail)}}class Z1 extends wt{constructor(e=[new de(0,-.5),new de(.5,0),new de(0,.5)],t=12,i=0,a=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:a},t=Math.floor(t),a=Lt(a,0,Math.PI*2);const r=[],s=[],o=[],c=[],h=[],f=1/t,d=new L,m=new de,g=new L,x=new L,T=new L;let S=0,v=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:S=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,g.x=v*1,g.y=-S,g.z=v*0,T.copy(g),g.normalize(),c.push(g.x,g.y,g.z);break;case e.length-1:c.push(T.x,T.y,T.z);break;default:S=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,g.x=v*1,g.y=-S,g.z=v*0,x.copy(g),g.x+=T.x,g.y+=T.y,g.z+=T.z,g.normalize(),c.push(g.x,g.y,g.z),T.copy(x)}for(let y=0;y<=t;y++){const E=i+y*f*a,b=Math.sin(E),D=Math.cos(E);for(let C=0;C<=e.length-1;C++){d.x=e[C].x*b,d.y=e[C].y,d.z=e[C].x*D,s.push(d.x,d.y,d.z),m.x=y/t,m.y=C/(e.length-1),o.push(m.x,m.y);const I=c[3*C+0]*b,P=c[3*C+1],O=c[3*C+0]*D;h.push(I,P,O)}}for(let y=0;y<t;y++)for(let E=0;E<e.length-1;E++){const b=E+y*e.length,D=b,C=b+e.length,I=b+e.length+1,P=b+1;r.push(D,C,P),r.push(I,P,C)}this.setIndex(r),this.setAttribute("position",new xt(s,3)),this.setAttribute("uv",new xt(o,2)),this.setAttribute("normal",new xt(h,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Z1(e.points,e.segments,e.phiStart,e.phiLength)}}class B0 extends Mc{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],a=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,a,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new B0(e.radius,e.detail)}}class lh extends wt{constructor(e=1,t=1,i=1,a=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:a};const r=e/2,s=t/2,o=Math.floor(i),c=Math.floor(a),h=o+1,f=c+1,d=e/o,m=t/c,g=[],x=[],T=[],S=[];for(let v=0;v<f;v++){const y=v*m-s;for(let E=0;E<h;E++){const b=E*d-r;x.push(b,-y,0),T.push(0,0,1),S.push(E/o),S.push(1-v/c)}}for(let v=0;v<c;v++)for(let y=0;y<o;y++){const E=y+h*v,b=y+h*(v+1),D=y+1+h*(v+1),C=y+1+h*v;g.push(E,b,C),g.push(b,D,C)}this.setIndex(g),this.setAttribute("position",new xt(x,3)),this.setAttribute("normal",new xt(T,3)),this.setAttribute("uv",new xt(S,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new lh(e.width,e.height,e.widthSegments,e.heightSegments)}}class K1 extends wt{constructor(e=.5,t=1,i=32,a=1,r=0,s=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:a,thetaStart:r,thetaLength:s},i=Math.max(3,i),a=Math.max(1,a);const o=[],c=[],h=[],f=[];let d=e;const m=(t-e)/a,g=new L,x=new de;for(let T=0;T<=a;T++){for(let S=0;S<=i;S++){const v=r+S/i*s;g.x=d*Math.cos(v),g.y=d*Math.sin(v),c.push(g.x,g.y,g.z),h.push(0,0,1),x.x=(g.x/t+1)/2,x.y=(g.y/t+1)/2,f.push(x.x,x.y)}d+=m}for(let T=0;T<a;T++){const S=T*(i+1);for(let v=0;v<i;v++){const y=v+S,E=y,b=y+i+1,D=y+i+2,C=y+1;o.push(E,b,C),o.push(b,D,C)}}this.setIndex(o),this.setAttribute("position",new xt(c,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new K1(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Q1 extends wt{constructor(e=new Iu([new de(0,.5),new de(-.5,-.5),new de(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],a=[],r=[],s=[];let o=0,c=0;if(Array.isArray(e)===!1)h(e);else for(let f=0;f<e.length;f++)h(e[f]),this.addGroup(o,c,f),o+=c,c=0;this.setIndex(i),this.setAttribute("position",new xt(a,3)),this.setAttribute("normal",new xt(r,3)),this.setAttribute("uv",new xt(s,2));function h(f){const d=a.length/3,m=f.extractPoints(t);let g=m.shape;const x=m.holes;As.isClockWise(g)===!1&&(g=g.reverse());for(let S=0,v=x.length;S<v;S++){const y=x[S];As.isClockWise(y)===!0&&(x[S]=y.reverse())}const T=As.triangulateShape(g,x);for(let S=0,v=x.length;S<v;S++){const y=x[S];g=g.concat(y)}for(let S=0,v=g.length;S<v;S++){const y=g[S];a.push(y.x,y.y,0),r.push(0,0,1),s.push(y.x,y.y)}for(let S=0,v=T.length;S<v;S++){const y=T[S],E=y[0]+d,b=y[1]+d,D=y[2]+d;i.push(E,b,D),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return TV(t,e)}static fromJSON(e,t){const i=[];for(let a=0,r=e.shapes.length;a<r;a++){const s=t[e.shapes[a]];i.push(s)}return new Q1(i,e.curveSegments)}}function TV(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const a=n[t];e.shapes.push(a.uuid)}else e.shapes.push(n.uuid);return e}class H0 extends wt{constructor(e=1,t=32,i=16,a=0,r=Math.PI*2,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:a,phiLength:r,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const c=Math.min(s+o,Math.PI);let h=0;const f=[],d=new L,m=new L,g=[],x=[],T=[],S=[];for(let v=0;v<=i;v++){const y=[],E=v/i;let b=0;v===0&&s===0?b=.5/t:v===i&&c===Math.PI&&(b=-.5/t);for(let D=0;D<=t;D++){const C=D/t;d.x=-e*Math.cos(a+C*r)*Math.sin(s+E*o),d.y=e*Math.cos(s+E*o),d.z=e*Math.sin(a+C*r)*Math.sin(s+E*o),x.push(d.x,d.y,d.z),m.copy(d).normalize(),T.push(m.x,m.y,m.z),S.push(C+b,1-E),y.push(h++)}f.push(y)}for(let v=0;v<i;v++)for(let y=0;y<t;y++){const E=f[v][y+1],b=f[v][y],D=f[v+1][y],C=f[v+1][y+1];(v!==0||s>0)&&g.push(E,b,C),(v!==i-1||c<Math.PI)&&g.push(b,D,C)}this.setIndex(g),this.setAttribute("position",new xt(x,3)),this.setAttribute("normal",new xt(T,3)),this.setAttribute("uv",new xt(S,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new H0(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class J1 extends Mc{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],a=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,a,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new J1(e.radius,e.detail)}}class $1 extends wt{constructor(e=1,t=.4,i=12,a=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:a,arc:r},i=Math.floor(i),a=Math.floor(a);const s=[],o=[],c=[],h=[],f=new L,d=new L,m=new L;for(let g=0;g<=i;g++)for(let x=0;x<=a;x++){const T=x/a*r,S=g/i*Math.PI*2;d.x=(e+t*Math.cos(S))*Math.cos(T),d.y=(e+t*Math.cos(S))*Math.sin(T),d.z=t*Math.sin(S),o.push(d.x,d.y,d.z),f.x=e*Math.cos(T),f.y=e*Math.sin(T),m.subVectors(d,f).normalize(),c.push(m.x,m.y,m.z),h.push(x/a),h.push(g/i)}for(let g=1;g<=i;g++)for(let x=1;x<=a;x++){const T=(a+1)*g+x-1,S=(a+1)*(g-1)+x-1,v=(a+1)*(g-1)+x,y=(a+1)*g+x;s.push(T,S,y),s.push(S,v,y)}this.setIndex(s),this.setAttribute("position",new xt(o,3)),this.setAttribute("normal",new xt(c,3)),this.setAttribute("uv",new xt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $1(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class ey extends wt{constructor(e=1,t=.4,i=64,a=8,r=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:a,p:r,q:s},i=Math.floor(i),a=Math.floor(a);const o=[],c=[],h=[],f=[],d=new L,m=new L,g=new L,x=new L,T=new L,S=new L,v=new L;for(let E=0;E<=i;++E){const b=E/i*r*Math.PI*2;y(b,r,s,e,g),y(b+.01,r,s,e,x),S.subVectors(x,g),v.addVectors(x,g),T.crossVectors(S,v),v.crossVectors(T,S),T.normalize(),v.normalize();for(let D=0;D<=a;++D){const C=D/a*Math.PI*2,I=-t*Math.cos(C),P=t*Math.sin(C);d.x=g.x+(I*v.x+P*T.x),d.y=g.y+(I*v.y+P*T.y),d.z=g.z+(I*v.z+P*T.z),c.push(d.x,d.y,d.z),m.subVectors(d,g).normalize(),h.push(m.x,m.y,m.z),f.push(E/i),f.push(D/a)}}for(let E=1;E<=i;E++)for(let b=1;b<=a;b++){const D=(a+1)*(E-1)+(b-1),C=(a+1)*E+(b-1),I=(a+1)*E+b,P=(a+1)*(E-1)+b;o.push(D,C,P),o.push(C,I,P)}this.setIndex(o),this.setAttribute("position",new xt(c,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(f,2));function y(E,b,D,C,I){const P=Math.cos(E),O=Math.sin(E),R=D/b*E,B=Math.cos(R);I.x=C*(2+B)*.5*P,I.y=C*(2+B)*O*.5,I.z=C*Math.sin(R)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ey(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ty extends wt{constructor(e=new Db(new L(-1,-1,0),new L(-1,1,0),new L(1,1,0)),t=64,i=1,a=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:a,closed:r};const s=e.computeFrenetFrames(t,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const o=new L,c=new L,h=new de;let f=new L;const d=[],m=[],g=[],x=[];T(),this.setIndex(x),this.setAttribute("position",new xt(d,3)),this.setAttribute("normal",new xt(m,3)),this.setAttribute("uv",new xt(g,2));function T(){for(let E=0;E<t;E++)S(E);S(r===!1?t:0),y(),v()}function S(E){f=e.getPointAt(E/t,f);const b=s.normals[E],D=s.binormals[E];for(let C=0;C<=a;C++){const I=C/a*Math.PI*2,P=Math.sin(I),O=-Math.cos(I);c.x=O*b.x+P*D.x,c.y=O*b.y+P*D.y,c.z=O*b.z+P*D.z,c.normalize(),m.push(c.x,c.y,c.z),o.x=f.x+i*c.x,o.y=f.y+i*c.y,o.z=f.z+i*c.z,d.push(o.x,o.y,o.z)}}function v(){for(let E=1;E<=t;E++)for(let b=1;b<=a;b++){const D=(a+1)*(E-1)+(b-1),C=(a+1)*E+(b-1),I=(a+1)*E+b,P=(a+1)*(E-1)+b;x.push(D,C,P),x.push(C,I,P)}}function y(){for(let E=0;E<=t;E++)for(let b=0;b<=a;b++)h.x=E/t,h.y=b/a,g.push(h.x,h.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ty(new Px[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class i6 extends wt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,a=new L,r=new L;if(e.index!==null){const s=e.attributes.position,o=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let h=0,f=c.length;h<f;++h){const d=c[h],m=d.start,g=d.count;for(let x=m,T=m+g;x<T;x+=3)for(let S=0;S<3;S++){const v=o.getX(x+S),y=o.getX(x+(S+1)%3);a.fromBufferAttribute(s,v),r.fromBufferAttribute(s,y),q4(a,r,i)===!0&&(t.push(a.x,a.y,a.z),t.push(r.x,r.y,r.z))}}}else{const s=e.attributes.position;for(let o=0,c=s.count/3;o<c;o++)for(let h=0;h<3;h++){const f=3*o+h,d=3*o+(h+1)%3;a.fromBufferAttribute(s,f),r.fromBufferAttribute(s,d),q4(a,r,i)===!0&&(t.push(a.x,a.y,a.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new xt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function q4(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,a=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(a)===!0?!1:(t.add(i),t.add(a),!0)}var j4=Object.freeze({__proto__:null,BoxGeometry:oh,CapsuleGeometry:k1,CircleGeometry:W1,ConeGeometry:z0,CylinderGeometry:P0,DodecahedronGeometry:X1,EdgesGeometry:qU,ExtrudeGeometry:q1,IcosahedronGeometry:j1,LatheGeometry:Z1,OctahedronGeometry:B0,PlaneGeometry:lh,PolyhedronGeometry:Mc,RingGeometry:K1,ShapeGeometry:Q1,SphereGeometry:H0,TetrahedronGeometry:J1,TorusGeometry:$1,TorusKnotGeometry:ey,TubeGeometry:ty,WireframeGeometry:i6});class a6 extends qn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new je(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class ch extends Fi{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class F0 extends qn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new je(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class os extends F0{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new de(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Lt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new je(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new je(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new je(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class r6 extends qn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new je(16777215),this.specular=new je(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.combine=N0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class s6 extends qn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new je(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Lb extends qn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class o6 extends qn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ui,this.combine=N0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ib extends qn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Sc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ub extends qn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class l6 extends qn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new je(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class c6 extends Pi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Eu(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function u6(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function h6(n){function e(a,r){return n[a]-n[r]}const t=n.length,i=new Array(t);for(let a=0;a!==t;++a)i[a]=a;return i.sort(e),i}function lE(n,e,t){const i=n.length,a=new n.constructor(i);for(let r=0,s=0;s!==i;++r){const o=t[r]*e;for(let c=0;c!==e;++c)a[s++]=n[o+c]}return a}function Pb(n,e,t,i){let a=1,r=n[0];for(;r!==void 0&&r[i]===void 0;)r=n[a++];if(r===void 0)return;let s=r[i];if(s!==void 0)if(Array.isArray(s))do s=r[i],s!==void 0&&(e.push(r.time),t.push(...s)),r=n[a++];while(r!==void 0);else if(s.toArray!==void 0)do s=r[i],s!==void 0&&(e.push(r.time),s.toArray(t,t.length)),r=n[a++];while(r!==void 0);else do s=r[i],s!==void 0&&(e.push(r.time),t.push(s)),r=n[a++];while(r!==void 0)}function EV(n,e,t,i,a=30){const r=n.clone();r.name=e;const s=[];for(let c=0;c<r.tracks.length;++c){const h=r.tracks[c],f=h.getValueSize(),d=[],m=[];for(let g=0;g<h.times.length;++g){const x=h.times[g]*a;if(!(x<t||x>=i)){d.push(h.times[g]);for(let T=0;T<f;++T)m.push(h.values[g*f+T])}}d.length!==0&&(h.times=Eu(d,h.times.constructor),h.values=Eu(m,h.values.constructor),s.push(h))}r.tracks=s;let o=1/0;for(let c=0;c<r.tracks.length;++c)o>r.tracks[c].times[0]&&(o=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*o);return r.resetDuration(),r}function MV(n,e=0,t=n,i=30){i<=0&&(i=30);const a=t.tracks.length,r=e/i;for(let s=0;s<a;++s){const o=t.tracks[s],c=o.ValueTypeName;if(c==="bool"||c==="string")continue;const h=n.tracks.find(function(v){return v.name===o.name&&v.ValueTypeName===c});if(h===void 0)continue;let f=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let m=0;const g=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(m=g/3);const x=o.times.length-1;let T;if(r<=o.times[0]){const v=f,y=d-f;T=o.values.slice(v,y)}else if(r>=o.times[x]){const v=x*d+f,y=v+d-f;T=o.values.slice(v,y)}else{const v=o.createInterpolant(),y=f,E=d-f;v.evaluate(r),T=v.resultBuffer.slice(y,E)}c==="quaternion"&&new Tt().fromArray(T).normalize().conjugate().toArray(T);const S=h.times.length;for(let v=0;v<S;++v){const y=v*g+m;if(c==="quaternion")Tt.multiplyQuaternionsFlat(h.values,y,T,0,h.values,y);else{const E=g-m*2;for(let b=0;b<E;++b)h.values[y+b]-=T[b]}}}return n.blendMode=pb,n}class bV{static convertArray(e,t){return Eu(e,t)}static isTypedArray(e){return u6(e)}static getKeyframeOrder(e){return h6(e)}static sortedArray(e,t,i){return lE(e,t,i)}static flattenJSON(e,t,i,a){Pb(e,t,i,a)}static subclip(e,t,i,a,r=30){return EV(e,t,i,a,r)}static makeClipAdditive(e,t=0,i=e,a=30){return MV(e,t,i,a)}}class Xd{constructor(e,t,i,a){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=a!==void 0?a:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,a=t[i],r=t[i-1];e:{t:{let s;n:{i:if(!(e<a)){for(let o=i+2;;){if(a===void 0){if(e<r)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(r=a,a=t[++i],e<a)break t}s=t.length;break n}if(!(e>=r)){const o=t[1];e<o&&(i=2,r=o);for(let c=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(a=r,r=t[--i-1],e>=r)break t}s=i,i=0;break n}break e}for(;i<s;){const o=i+s>>>1;e<t[o]?s=o:i=o+1}if(a=t[i],r=t[i-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(a===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,a)}return this.interpolate_(i,r,e,a)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,a=this.valueSize,r=e*a;for(let s=0;s!==a;++s)t[s]=i[r+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class f6 extends Xd{constructor(e,t,i,a){super(e,t,i,a),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Su,endingEnd:Su}}intervalChanged_(e,t,i){const a=this.parameterPositions;let r=e-2,s=e+1,o=a[r],c=a[s];if(o===void 0)switch(this.getSettings_().endingStart){case Tu:r=e,o=2*t-i;break;case s0:r=a.length-2,o=t+a[r]-a[r+1];break;default:r=e,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Tu:s=e,c=2*i-t;break;case s0:s=1,c=i+a[1]-a[0];break;default:s=e-1,c=t}const h=(i-t)*.5,f=this.valueSize;this._weightPrev=h/(t-o),this._weightNext=h/(c-i),this._offsetPrev=r*f,this._offsetNext=s*f}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=e*o,h=c-o,f=this._offsetPrev,d=this._offsetNext,m=this._weightPrev,g=this._weightNext,x=(i-t)/(a-t),T=x*x,S=T*x,v=-m*S+2*m*T-m*x,y=(1+m)*S+(-1.5-2*m)*T+(-.5+m)*x+1,E=(-1-g)*S+(1.5+g)*T+.5*x,b=g*S-g*T;for(let D=0;D!==o;++D)r[D]=v*s[f+D]+y*s[h+D]+E*s[c+D]+b*s[d+D];return r}}class zb extends Xd{constructor(e,t,i,a){super(e,t,i,a)}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=e*o,h=c-o,f=(i-t)/(a-t),d=1-f;for(let m=0;m!==o;++m)r[m]=s[h+m]*d+s[c+m]*f;return r}}class d6 extends Xd{constructor(e,t,i,a){super(e,t,i,a)}interpolate_(e){return this.copySampleValue_(e-1)}}class ls{constructor(e,t,i,a){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Eu(t,this.TimeBufferType),this.values=Eu(i,this.ValueBufferType),this.setInterpolation(a||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Eu(e.times,Array),values:Eu(e.values,Array)};const a=e.getInterpolation();a!==e.DefaultInterpolation&&(i.interpolation=a)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new d6(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new zb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new f6(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case xd:t=this.InterpolantFactoryMethodDiscrete;break;case yd:t=this.InterpolantFactoryMethodLinear;break;case d_:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return ut("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return xd;case this.InterpolantFactoryMethodLinear:return yd;case this.InterpolantFactoryMethodSmooth:return d_}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,a=t.length;i!==a;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,a=t.length;i!==a;++i)t[i]*=e}return this}trim(e,t){const i=this.times,a=i.length;let r=0,s=a-1;for(;r!==a&&i[r]<e;)++r;for(;s!==-1&&i[s]>t;)--s;if(++s,r!==0||s!==a){r>=s&&(s=Math.max(s,1),r=s-1);const o=this.getValueSize();this.times=i.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Bt("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,a=this.values,r=i.length;r===0&&(Bt("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let o=0;o!==r;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){Bt("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(s!==null&&s>c){Bt("KeyframeTrack: Out of order keys.",this,o,c,s),e=!1;break}s=c}if(a!==void 0&&u6(a))for(let o=0,c=a.length;o!==c;++o){const h=a[o];if(isNaN(h)){Bt("KeyframeTrack: Value is not a valid number.",this,o,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),a=this.getInterpolation()===d_,r=e.length-1;let s=1;for(let o=1;o<r;++o){let c=!1;const h=e[o],f=e[o+1];if(h!==f&&(o!==1||h!==e[0]))if(a)c=!0;else{const d=o*i,m=d-i,g=d+i;for(let x=0;x!==i;++x){const T=t[d+x];if(T!==t[m+x]||T!==t[g+x]){c=!0;break}}}if(c){if(o!==s){e[s]=e[o];const d=o*i,m=s*i;for(let g=0;g!==i;++g)t[m+g]=t[d+g]}++s}}if(r>0){e[s]=e[r];for(let o=r*i,c=s*i,h=0;h!==i;++h)t[c+h]=t[o+h];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,a=new i(this.name,e,t);return a.createInterpolant=this.createInterpolant,a}}ls.prototype.ValueTypeName="";ls.prototype.TimeBufferType=Float32Array;ls.prototype.ValueBufferType=Float32Array;ls.prototype.DefaultInterpolation=yd;class uh extends ls{constructor(e,t,i){super(e,t,i)}}uh.prototype.ValueTypeName="bool";uh.prototype.ValueBufferType=Array;uh.prototype.DefaultInterpolation=xd;uh.prototype.InterpolantFactoryMethodLinear=void 0;uh.prototype.InterpolantFactoryMethodSmooth=void 0;class Bb extends ls{constructor(e,t,i,a){super(e,t,i,a)}}Bb.prototype.ValueTypeName="color";class gc extends ls{constructor(e,t,i,a){super(e,t,i,a)}}gc.prototype.ValueTypeName="number";class p6 extends Xd{constructor(e,t,i,a){super(e,t,i,a)}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=(i-t)/(a-t);let h=e*o;for(let f=h+o;h!==f;h+=4)Tt.slerpFlat(r,0,s,h-o,s,h,c);return r}}class vc extends ls{constructor(e,t,i,a){super(e,t,i,a)}InterpolantFactoryMethodLinear(e){return new p6(this.times,this.values,this.getValueSize(),e)}}vc.prototype.ValueTypeName="quaternion";vc.prototype.InterpolantFactoryMethodSmooth=void 0;class hh extends ls{constructor(e,t,i){super(e,t,i)}}hh.prototype.ValueTypeName="string";hh.prototype.ValueBufferType=Array;hh.prototype.DefaultInterpolation=xd;hh.prototype.InterpolantFactoryMethodLinear=void 0;hh.prototype.InterpolantFactoryMethodSmooth=void 0;class Zu extends ls{constructor(e,t,i,a){super(e,t,i,a)}}Zu.prototype.ValueTypeName="vector";class Ku{constructor(e="",t=-1,i=[],a=I1){this.name=e,this.tracks=i,this.duration=t,this.blendMode=a,this.uuid=Cr(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,a=1/(e.fps||1);for(let s=0,o=i.length;s!==o;++s)t.push(RV(i[s]).scale(a));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],i=e.tracks,a={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=i.length;r!==s;++r)t.push(ls.toJSON(i[r]));return a}static CreateFromMorphTargetSequence(e,t,i,a){const r=t.length,s=[];for(let o=0;o<r;o++){let c=[],h=[];c.push((o+r-1)%r,o,(o+1)%r),h.push(0,1,0);const f=h6(c);c=lE(c,1,f),h=lE(h,1,f),!a&&c[0]===0&&(c.push(r),h.push(h[0])),s.push(new gc(".morphTargetInfluences["+t[o].name+"]",c,h).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const a=e;i=a.geometry&&a.geometry.animations||a.animations}for(let a=0;a<i.length;a++)if(i[a].name===t)return i[a];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const a={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const h=e[o],f=h.name.match(r);if(f&&f.length>1){const d=f[1];let m=a[d];m||(a[d]=m=[]),m.push(h)}}const s=[];for(const o in a)s.push(this.CreateFromMorphTargetSequence(o,a[o],t,i));return s}static parseAnimation(e,t){if(ut("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Bt("AnimationClip: No animation in JSONLoader data."),null;const i=function(d,m,g,x,T){if(g.length!==0){const S=[],v=[];Pb(g,S,v,x),S.length!==0&&T.push(new d(m,S,v))}},a=[],r=e.name||"default",s=e.fps||30,o=e.blendMode;let c=e.length||-1;const h=e.hierarchy||[];for(let d=0;d<h.length;d++){const m=h[d].keys;if(!(!m||m.length===0))if(m[0].morphTargets){const g={};let x;for(x=0;x<m.length;x++)if(m[x].morphTargets)for(let T=0;T<m[x].morphTargets.length;T++)g[m[x].morphTargets[T]]=-1;for(const T in g){const S=[],v=[];for(let y=0;y!==m[x].morphTargets.length;++y){const E=m[x];S.push(E.time),v.push(E.morphTarget===T?1:0)}a.push(new gc(".morphTargetInfluence["+T+"]",S,v))}c=g.length*s}else{const g=".bones["+t[d].name+"]";i(Zu,g+".position",m,"pos",a),i(vc,g+".quaternion",m,"rot",a),i(Zu,g+".scale",m,"scl",a)}}return a.length===0?null:new this(r,c,a,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,a=e.length;i!==a;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function AV(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gc;case"vector":case"vector2":case"vector3":case"vector4":return Zu;case"color":return Bb;case"quaternion":return vc;case"bool":case"boolean":return uh;case"string":return hh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function RV(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=AV(n.type);if(n.times===void 0){const t=[],i=[];Pb(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const to={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class Hb{constructor(e,t,i){const a=this;let r=!1,s=0,o=0,c;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(f){o++,r===!1&&a.onStart!==void 0&&a.onStart(f,s,o),r=!0},this.itemEnd=function(f){s++,a.onProgress!==void 0&&a.onProgress(f,s,o),s===o&&(r=!1,a.onLoad!==void 0&&a.onLoad())},this.itemError=function(f){a.onError!==void 0&&a.onError(f)},this.resolveURL=function(f){return c?c(f):f},this.setURLModifier=function(f){return c=f,this},this.addHandler=function(f,d){return h.push(f,d),this},this.removeHandler=function(f){const d=h.indexOf(f);return d!==-1&&h.splice(d,2),this},this.getHandler=function(f){for(let d=0,m=h.length;d<m;d+=2){const g=h[d],x=h[d+1];if(g.global&&(g.lastIndex=0),g.test(f))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const m6=new Hb;class Ti{constructor(e){this.manager=e!==void 0?e:m6,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(a,r){i.load(e,a,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Ti.DEFAULT_MATERIAL_NAME="__DEFAULT";const Oo={};class wV extends Error{constructor(e,t){super(e),this.response=t}}class ss extends Ti{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,a){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=to.get(`file:${e}`);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Oo[e]!==void 0){Oo[e].push({onLoad:t,onProgress:i,onError:a});return}Oo[e]=[],Oo[e].push({onLoad:t,onProgress:i,onError:a});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(s).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&ut("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const f=Oo[e],d=h.body.getReader(),m=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),g=m?parseInt(m):0,x=g!==0;let T=0;const S=new ReadableStream({start(v){y();function y(){d.read().then(({done:E,value:b})=>{if(E)v.close();else{T+=b.byteLength;const D=new ProgressEvent("progress",{lengthComputable:x,loaded:T,total:g});for(let C=0,I=f.length;C<I;C++){const P=f[C];P.onProgress&&P.onProgress(D)}v.enqueue(b),y()}},E=>{v.error(E)})}}});return new Response(S)}else throw new wV(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(c){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(f=>new DOMParser().parseFromString(f,o));case"json":return h.json();default:if(o==="")return h.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),m=d&&d[1]?d[1].toLowerCase():void 0,g=new TextDecoder(m);return h.arrayBuffer().then(x=>g.decode(x))}}}).then(h=>{to.add(`file:${e}`,h);const f=Oo[e];delete Oo[e];for(let d=0,m=f.length;d<m;d++){const g=f[d];g.onLoad&&g.onLoad(h)}}).catch(h=>{const f=Oo[e];if(f===void 0)throw this.manager.itemError(e),h;delete Oo[e];for(let d=0,m=f.length;d<m;d++){const g=f[d];g.onError&&g.onError(h)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class CV extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new ss(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){a?a(c):Bt(c),r.manager.itemError(e)}},i,a)}parse(e){const t=[];for(let i=0;i<e.length;i++){const a=Ku.parse(e[i]);t.push(a)}return t}}class NV extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=this,s=[],o=new V1,c=new ss(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(r.withCredentials);let h=0;function f(d){c.load(e[d],function(m){const g=r.parse(m,!0);s[d]={width:g.width,height:g.height,format:g.format,mipmaps:g.mipmaps},h+=1,h===6&&(g.mipmapCount===1&&(o.minFilter=Ht),o.image=s,o.format=g.format,o.needsUpdate=!0,t&&t(o))},i,a)}if(Array.isArray(e))for(let d=0,m=e.length;d<m;++d)f(d);else c.load(e,function(d){const m=r.parse(d,!0);if(m.isCubemap){const g=m.mipmaps.length/m.mipmapCount;for(let x=0;x<g;x++){s[x]={mipmaps:[]};for(let T=0;T<m.mipmapCount;T++)s[x].mipmaps.push(m.mipmaps[x*m.mipmapCount+T]),s[x].format=m.format,s[x].width=m.width,s[x].height=m.height}o.image=s}else o.image.width=m.width,o.image.height=m.height,o.mipmaps=m.mipmaps;m.mipmapCount===1&&(o.minFilter=Ht),o.format=m.format,o.needsUpdate=!0,t&&t(o)},i,a);return o}}const of=new WeakMap;class wd extends Ti{constructor(e){super(e)}load(e,t,i,a){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=to.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(s),r.manager.itemEnd(e)},0);else{let d=of.get(s);d===void 0&&(d=[],of.set(s,d)),d.push({onLoad:t,onError:a})}return s}const o=c0("img");function c(){f(),t&&t(this);const d=of.get(this)||[];for(let m=0;m<d.length;m++){const g=d[m];g.onLoad&&g.onLoad(this)}of.delete(this),r.manager.itemEnd(e)}function h(d){f(),a&&a(d),to.remove(`image:${e}`);const m=of.get(this)||[];for(let g=0;g<m.length;g++){const x=m[g];x.onError&&x.onError(d)}of.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function f(){o.removeEventListener("load",c,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),to.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class DV extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=new L0;r.colorSpace=En;const s=new wd(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function c(h){s.load(e[h],function(f){r.images[h]=f,o++,o===6&&(r.needsUpdate=!0,t&&t(r))},void 0,a)}for(let h=0;h<e.length;++h)c(h);return r}}class g6 extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new Ja,o=new ss(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(c){let h;try{h=r.parse(c)}catch(f){if(a!==void 0)a(f);else{f(f);return}}h.image!==void 0?s.image=h.image:h.data!==void 0&&(s.image.width=h.width,s.image.height=h.height,s.image.data=h.data),s.wrapS=h.wrapS!==void 0?h.wrapS:Li,s.wrapT=h.wrapT!==void 0?h.wrapT:Li,s.magFilter=h.magFilter!==void 0?h.magFilter:Ht,s.minFilter=h.minFilter!==void 0?h.minFilter:Ht,s.anisotropy=h.anisotropy!==void 0?h.anisotropy:1,h.colorSpace!==void 0&&(s.colorSpace=h.colorSpace),h.flipY!==void 0&&(s.flipY=h.flipY),h.format!==void 0&&(s.format=h.format),h.type!==void 0&&(s.type=h.type),h.mipmaps!==void 0&&(s.mipmaps=h.mipmaps,s.minFilter=Er),h.mipmapCount===1&&(s.minFilter=Ht),h.generateMipmaps!==void 0&&(s.generateMipmaps=h.generateMipmaps),s.needsUpdate=!0,t&&t(s,h)},i,a),s}}class Fb extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=new Nn,s=new wd(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},i,a),r}}class bc extends Zt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new je(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class v6 extends bc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Zt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const t2=new ke,Z4=new L,K4=new L;class Gb{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new de(512,512),this.mapType=Ii,this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wd,this._frameExtents=new de(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Z4.setFromMatrixPosition(e.matrixWorld),t.position.copy(Z4),K4.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(K4),t.updateMatrixWorld(),t2.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(t2,t.coordinateSystem,t.reversedDepth),t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t2)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class OV extends Gb{constructor(){super(new ui(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Ed*2*e.angle*this.focus,a=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(i!==t.fov||a!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=a,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Vb extends bc{constructor(e,t,i=0,a=Math.PI/3,r=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Zt.DEFAULT_UP),this.updateMatrix(),this.target=new Zt,this.distance=i,this.angle=a,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new OV}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Q4=new ke,Vp=new L,n2=new L;class LV extends Gb{constructor(){super(new ui(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new de(4,2),this._viewportCount=6,this._viewports=[new zt(2,1,1,1),new zt(0,1,1,1),new zt(3,1,1,1),new zt(1,1,1,1),new zt(3,0,1,1),new zt(1,0,1,1)],this._cubeDirections=[new L(1,0,0),new L(-1,0,0),new L(0,0,1),new L(0,0,-1),new L(0,1,0),new L(0,-1,0)],this._cubeUps=[new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,0,1),new L(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,a=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),Vp.setFromMatrixPosition(e.matrixWorld),i.position.copy(Vp),n2.copy(i.position),n2.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(n2),i.updateMatrixWorld(),a.makeTranslation(-Vp.x,-Vp.y,-Vp.z),Q4.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Q4,i.coordinateSystem,i.reversedDepth)}}class kb extends bc{constructor(e,t,i=0,a=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=a,this.shadow=new LV}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class io extends Tc{constructor(e=-1,t=1,i=1,a=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=a,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,a,r,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=a,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,a=(this.top+this.bottom)/2;let r=i-e,s=i+e,o=a+t,c=a-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=h*this.view.offsetX,s=r+h*this.view.width,o-=f*this.view.offsetY,c=o-f*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class IV extends Gb{constructor(){super(new io(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Wb extends bc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Zt.DEFAULT_UP),this.updateMatrix(),this.target=new Zt,this.shadow=new IV}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _6 extends bc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class x6 extends bc{constructor(e,t,i=10,a=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=a}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class y6{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new L)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,a=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*a),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*i),t.addScaledVector(s[4],1.092548*(i*a)),t.addScaledVector(s[5],1.092548*(a*r)),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],1.092548*(i*r)),t.addScaledVector(s[8],.546274*(i*i-a*a)),t}getIrradianceAt(e,t){const i=e.x,a=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],2*.511664*a),t.addScaledVector(s[2],2*.511664*r),t.addScaledVector(s[3],2*.511664*i),t.addScaledVector(s[4],2*.429043*i*a),t.addScaledVector(s[5],2*.429043*a*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],2*.429043*i*r),t.addScaledVector(s[8],.429043*(i*i-a*a)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let a=0;a<9;a++)i[a].fromArray(e,t+a*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let a=0;a<9;a++)i[a].toArray(e,t+a*3);return e}static getBasisAt(e,t){const i=e.x,a=e.y,r=e.z;t[0]=.282095,t[1]=.488603*a,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*a,t[5]=1.092548*a*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-a*a)}}class S6 extends bc{constructor(e=new y6,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class ny extends Ti{constructor(e){super(e),this.textures={}}load(e,t,i,a){const r=this,s=new ss(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){a?a(c):Bt(c),r.manager.itemError(e)}},i,a)}parse(e){const t=this.textures;function i(r){return t[r]===void 0&&ut("MaterialLoader: Undefined texture",r),t[r]}const a=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(a.uuid=e.uuid),e.name!==void 0&&(a.name=e.name),e.color!==void 0&&a.color!==void 0&&a.color.setHex(e.color),e.roughness!==void 0&&(a.roughness=e.roughness),e.metalness!==void 0&&(a.metalness=e.metalness),e.sheen!==void 0&&(a.sheen=e.sheen),e.sheenColor!==void 0&&(a.sheenColor=new je().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(a.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&a.emissive!==void 0&&a.emissive.setHex(e.emissive),e.specular!==void 0&&a.specular!==void 0&&a.specular.setHex(e.specular),e.specularIntensity!==void 0&&(a.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&a.specularColor!==void 0&&a.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(a.shininess=e.shininess),e.clearcoat!==void 0&&(a.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(a.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(a.dispersion=e.dispersion),e.iridescence!==void 0&&(a.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(a.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(a.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(a.transmission=e.transmission),e.thickness!==void 0&&(a.thickness=e.thickness),e.attenuationDistance!==void 0&&(a.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&a.attenuationColor!==void 0&&a.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(a.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(a.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(a.fog=e.fog),e.flatShading!==void 0&&(a.flatShading=e.flatShading),e.blending!==void 0&&(a.blending=e.blending),e.combine!==void 0&&(a.combine=e.combine),e.side!==void 0&&(a.side=e.side),e.shadowSide!==void 0&&(a.shadowSide=e.shadowSide),e.opacity!==void 0&&(a.opacity=e.opacity),e.transparent!==void 0&&(a.transparent=e.transparent),e.alphaTest!==void 0&&(a.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(a.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(a.depthFunc=e.depthFunc),e.depthTest!==void 0&&(a.depthTest=e.depthTest),e.depthWrite!==void 0&&(a.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(a.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(a.blendSrc=e.blendSrc),e.blendDst!==void 0&&(a.blendDst=e.blendDst),e.blendEquation!==void 0&&(a.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(a.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(a.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(a.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&a.blendColor!==void 0&&a.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(a.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(a.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(a.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(a.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(a.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(a.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(a.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(a.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(a.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(a.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(a.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(a.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(a.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(a.rotation=e.rotation),e.linewidth!==void 0&&(a.linewidth=e.linewidth),e.dashSize!==void 0&&(a.dashSize=e.dashSize),e.gapSize!==void 0&&(a.gapSize=e.gapSize),e.scale!==void 0&&(a.scale=e.scale),e.polygonOffset!==void 0&&(a.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(a.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(a.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(a.dithering=e.dithering),e.alphaToCoverage!==void 0&&(a.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(a.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(a.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(a.visible=e.visible),e.toneMapped!==void 0&&(a.toneMapped=e.toneMapped),e.userData!==void 0&&(a.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?a.vertexColors=e.vertexColors>0:a.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const s=e.uniforms[r];switch(a.uniforms[r]={},s.type){case"t":a.uniforms[r].value=i(s.value);break;case"c":a.uniforms[r].value=new je().setHex(s.value);break;case"v2":a.uniforms[r].value=new de().fromArray(s.value);break;case"v3":a.uniforms[r].value=new L().fromArray(s.value);break;case"v4":a.uniforms[r].value=new zt().fromArray(s.value);break;case"m3":a.uniforms[r].value=new Et().fromArray(s.value);break;case"m4":a.uniforms[r].value=new ke().fromArray(s.value);break;default:a.uniforms[r].value=s.value}}if(e.defines!==void 0&&(a.defines=e.defines),e.vertexShader!==void 0&&(a.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(a.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(a.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)a.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(a.lights=e.lights),e.clipping!==void 0&&(a.clipping=e.clipping),e.size!==void 0&&(a.size=e.size),e.sizeAttenuation!==void 0&&(a.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(a.map=i(e.map)),e.matcap!==void 0&&(a.matcap=i(e.matcap)),e.alphaMap!==void 0&&(a.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(a.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(a.bumpScale=e.bumpScale),e.normalMap!==void 0&&(a.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(a.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),a.normalScale=new de().fromArray(r)}return e.displacementMap!==void 0&&(a.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(a.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(a.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(a.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(a.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(a.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(a.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(a.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(a.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(a.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(a.envMap=i(e.envMap)),e.envMapRotation!==void 0&&a.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(a.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(a.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(a.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(a.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(a.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(a.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(a.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(a.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(a.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(a.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(a.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(a.clearcoatNormalScale=new de().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(a.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(a.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(a.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(a.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(a.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(a.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(a.sheenRoughnessMap=i(e.sheenRoughnessMap)),a}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return ny.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:a6,SpriteMaterial:Tb,RawShaderMaterial:ch,ShaderMaterial:Fi,PointsMaterial:G1,MeshPhysicalMaterial:os,MeshStandardMaterial:F0,MeshPhongMaterial:r6,MeshToonMaterial:s6,MeshNormalMaterial:Lb,MeshLambertMaterial:o6,MeshDepthMaterial:Ib,MeshDistanceMaterial:Ub,MeshBasicMaterial:La,MeshMatcapMaterial:l6,LineDashedMaterial:c6,LineBasicMaterial:Pi,Material:qn};return new t[e]}}class oc{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class T6 extends wt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class E6 extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new ss(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){a?a(c):Bt(c),r.manager.itemError(e)}},i,a)}parse(e){const t={},i={};function a(g,x){if(t[x]!==void 0)return t[x];const S=g.interleavedBuffers[x],v=r(g,S.buffer),y=Vf(S.type,v),E=new I0(y,S.stride);return E.uuid=S.uuid,t[x]=E,E}function r(g,x){if(i[x]!==void 0)return i[x];const S=g.arrayBuffers[x],v=new Uint32Array(S).buffer;return i[x]=v,v}const s=e.isInstancedBufferGeometry?new T6:new wt,o=e.data.index;if(o!==void 0){const g=Vf(o.type,o.array);s.setIndex(new Ot(g,1))}const c=e.data.attributes;for(const g in c){const x=c[g];let T;if(x.isInterleavedBufferAttribute){const S=a(e.data,x.data);T=new mc(S,x.itemSize,x.offset,x.normalized)}else{const S=Vf(x.type,x.array),v=x.isInstancedBufferAttribute?qu:Ot;T=new v(S,x.itemSize,x.normalized)}x.name!==void 0&&(T.name=x.name),x.usage!==void 0&&T.setUsage(x.usage),s.setAttribute(g,T)}const h=e.data.morphAttributes;if(h)for(const g in h){const x=h[g],T=[];for(let S=0,v=x.length;S<v;S++){const y=x[S];let E;if(y.isInterleavedBufferAttribute){const b=a(e.data,y.data);E=new mc(b,y.itemSize,y.offset,y.normalized)}else{const b=Vf(y.type,y.array);E=new Ot(b,y.itemSize,y.normalized)}y.name!==void 0&&(E.name=y.name),T.push(E)}s.morphAttributes[g]=T}e.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let g=0,x=d.length;g!==x;++g){const T=d[g];s.addGroup(T.start,T.count,T.materialIndex)}const m=e.data.boundingSphere;return m!==void 0&&(s.boundingSphere=new ta().fromJSON(m)),e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}}class UV extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=this,s=this.path===""?oc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const o=new ss(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){let h=null;try{h=JSON.parse(c)}catch(d){a!==void 0&&a(d),d("ObjectLoader: Can't parse "+e+".",d.message);return}const f=h.metadata;if(f===void 0||f.type===void 0||f.type.toLowerCase()==="geometry"){a!==void 0&&a(new Error("THREE.ObjectLoader: Can't load "+e)),Bt("ObjectLoader: Can't load "+e);return}r.parse(h,t)},i,a)}async loadAsync(e,t){const i=this,a=this.path===""?oc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const r=new ss(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const s=await r.loadAsync(e,t),o=JSON.parse(s),c=o.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),a=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,a),s=this.parseImages(e.images,function(){t!==void 0&&t(h)}),o=this.parseTextures(e.textures,s),c=this.parseMaterials(e.materials,o),h=this.parseObject(e.object,r,c,o,i),f=this.parseSkeletons(e.skeletons,h);if(this.bindSkeletons(h,f),this.bindLightTargets(h),t!==void 0){let d=!1;for(const m in s)if(s[m].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(h)}return h}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),a=this.parseGeometries(e.geometries,i),r=await this.parseImagesAsync(e.images),s=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,s),c=this.parseObject(e.object,a,o,s,t),h=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,h),this.bindLightTargets(c),c}parseShapes(e){const t={};if(e!==void 0)for(let i=0,a=e.length;i<a;i++){const r=new Iu().fromJSON(e[i]);t[r.uuid]=r}return t}parseSkeletons(e,t){const i={},a={};if(t.traverse(function(r){r.isBone&&(a[r.uuid]=r)}),e!==void 0)for(let r=0,s=e.length;r<s;r++){const o=new Ec().fromJSON(e[r],a);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const a=new E6;for(let r=0,s=e.length;r<s;r++){let o;const c=e[r];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":o=a.parse(c);break;default:c.type in j4?o=j4[c.type].fromJSON(c,t):ut(`ObjectLoader: Unsupported geometry type "${c.type}"`)}o.uuid=c.uuid,c.name!==void 0&&(o.name=c.name),c.userData!==void 0&&(o.userData=c.userData),i[c.uuid]=o}}return i}parseMaterials(e,t){const i={},a={};if(e!==void 0){const r=new ny;r.setTextures(t);for(let s=0,o=e.length;s<o;s++){const c=e[s];i[c.uuid]===void 0&&(i[c.uuid]=r.parse(c)),a[c.uuid]=i[c.uuid]}}return a}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const a=e[i],r=Ku.parse(a);t[r.uuid]=r}return t}parseImages(e,t){const i=this,a={};let r;function s(c){return i.manager.itemStart(c),r.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function o(c){if(typeof c=="string"){const h=c,f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h)?h:i.resourcePath+h;return s(f)}else return c.data?{data:Vf(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){const c=new Hb(t);r=new wd(c),r.setCrossOrigin(this.crossOrigin);for(let h=0,f=e.length;h<f;h++){const d=e[h],m=d.url;if(Array.isArray(m)){const g=[];for(let x=0,T=m.length;x<T;x++){const S=m[x],v=o(S);v!==null&&(v instanceof HTMLImageElement?g.push(v):g.push(new Ja(v.data,v.width,v.height)))}a[d.uuid]=new Zl(g)}else{const g=o(d.url);a[d.uuid]=new Zl(g)}}}return a}async parseImagesAsync(e){const t=this,i={};let a;async function r(s){if(typeof s=="string"){const o=s,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await a.loadAsync(c)}else return s.data?{data:Vf(s.type,s.data),width:s.width,height:s.height}:null}if(e!==void 0&&e.length>0){a=new wd(this.manager),a.setCrossOrigin(this.crossOrigin);for(let s=0,o=e.length;s<o;s++){const c=e[s],h=c.url;if(Array.isArray(h)){const f=[];for(let d=0,m=h.length;d<m;d++){const g=h[d],x=await r(g);x!==null&&(x instanceof HTMLImageElement?f.push(x):f.push(new Ja(x.data,x.width,x.height)))}i[c.uuid]=new Zl(f)}else{const f=await r(c.url);i[c.uuid]=new Zl(f)}}}return i}parseTextures(e,t){function i(r,s){return typeof r=="number"?r:(ut("ObjectLoader.parseTexture: Constant should be in numeric form.",r),s[r])}const a={};if(e!==void 0)for(let r=0,s=e.length;r<s;r++){const o=e[r];o.image===void 0&&ut('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&ut("ObjectLoader: Undefined image",o.image);const c=t[o.image],h=c.data;let f;Array.isArray(h)?(f=new L0,h.length===6&&(f.needsUpdate=!0)):(h&&h.data?f=new Ja:f=new Nn,h&&(f.needsUpdate=!0)),f.source=c,f.uuid=o.uuid,o.name!==void 0&&(f.name=o.name),o.mapping!==void 0&&(f.mapping=i(o.mapping,PV)),o.channel!==void 0&&(f.channel=o.channel),o.offset!==void 0&&f.offset.fromArray(o.offset),o.repeat!==void 0&&f.repeat.fromArray(o.repeat),o.center!==void 0&&f.center.fromArray(o.center),o.rotation!==void 0&&(f.rotation=o.rotation),o.wrap!==void 0&&(f.wrapS=i(o.wrap[0],J4),f.wrapT=i(o.wrap[1],J4)),o.format!==void 0&&(f.format=o.format),o.internalFormat!==void 0&&(f.internalFormat=o.internalFormat),o.type!==void 0&&(f.type=o.type),o.colorSpace!==void 0&&(f.colorSpace=o.colorSpace),o.minFilter!==void 0&&(f.minFilter=i(o.minFilter,$4)),o.magFilter!==void 0&&(f.magFilter=i(o.magFilter,$4)),o.anisotropy!==void 0&&(f.anisotropy=o.anisotropy),o.flipY!==void 0&&(f.flipY=o.flipY),o.generateMipmaps!==void 0&&(f.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(f.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(f.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(f.compareFunction=o.compareFunction),o.userData!==void 0&&(f.userData=o.userData),a[o.uuid]=f}return a}parseObject(e,t,i,a,r){let s;function o(m){return t[m]===void 0&&ut("ObjectLoader: Undefined geometry",m),t[m]}function c(m){if(m!==void 0){if(Array.isArray(m)){const g=[];for(let x=0,T=m.length;x<T;x++){const S=m[x];i[S]===void 0&&ut("ObjectLoader: Undefined material",S),g.push(i[S])}return g}return i[m]===void 0&&ut("ObjectLoader: Undefined material",m),i[m]}}function h(m){return a[m]===void 0&&ut("ObjectLoader: Undefined texture",m),a[m]}let f,d;switch(e.type){case"Scene":s=new Ad,e.background!==void 0&&(Number.isInteger(e.background)?s.background=new je(e.background):s.background=h(e.background)),e.environment!==void 0&&(s.environment=h(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?s.fog=new z1(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(s.fog=new P1(e.fog.color,e.fog.density)),e.fog.name!==""&&(s.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(s.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(s.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&s.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(s.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&s.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":s=new ui(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(s.focus=e.focus),e.zoom!==void 0&&(s.zoom=e.zoom),e.filmGauge!==void 0&&(s.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(s.filmOffset=e.filmOffset),e.view!==void 0&&(s.view=Object.assign({},e.view));break;case"OrthographicCamera":s=new io(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(s.zoom=e.zoom),e.view!==void 0&&(s.view=Object.assign({},e.view));break;case"AmbientLight":s=new _6(e.color,e.intensity);break;case"DirectionalLight":s=new Wb(e.color,e.intensity),s.target=e.target||"";break;case"PointLight":s=new kb(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":s=new x6(e.color,e.intensity,e.width,e.height);break;case"SpotLight":s=new Vb(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),s.target=e.target||"";break;case"HemisphereLight":s=new v6(e.color,e.groundColor,e.intensity);break;case"LightProbe":s=new S6().fromJSON(e);break;case"SkinnedMesh":f=o(e.geometry),d=c(e.material),s=new B1(f,d),e.bindMode!==void 0&&(s.bindMode=e.bindMode),e.bindMatrix!==void 0&&s.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(s.skeleton=e.skeleton);break;case"Mesh":f=o(e.geometry),d=c(e.material),s=new si(f,d);break;case"InstancedMesh":f=o(e.geometry),d=c(e.material);const m=e.count,g=e.instanceMatrix,x=e.instanceColor;s=new Eb(f,d,m),s.instanceMatrix=new qu(new Float32Array(g.array),16),x!==void 0&&(s.instanceColor=new qu(new Float32Array(x.array),x.itemSize));break;case"BatchedMesh":f=o(e.geometry),d=c(e.material),s=new XU(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),s.geometry=f,s.perObjectFrustumCulled=e.perObjectFrustumCulled,s.sortObjects=e.sortObjects,s._drawRanges=e.drawRanges,s._reservedRanges=e.reservedRanges,s._geometryInfo=e.geometryInfo.map(T=>{let S=null,v=null;return T.boundingBox!==void 0&&(S=new ea().fromJSON(T.boundingBox)),T.boundingSphere!==void 0&&(v=new ta().fromJSON(T.boundingSphere)),{...T,boundingBox:S,boundingSphere:v}}),s._instanceInfo=e.instanceInfo,s._availableInstanceIds=e._availableInstanceIds,s._availableGeometryIds=e._availableGeometryIds,s._nextIndexStart=e.nextIndexStart,s._nextVertexStart=e.nextVertexStart,s._geometryCount=e.geometryCount,s._maxInstanceCount=e.maxInstanceCount,s._maxVertexCount=e.maxVertexCount,s._maxIndexCount=e.maxIndexCount,s._geometryInitialized=e.geometryInitialized,s._matricesTexture=h(e.matricesTexture.uuid),s._indirectTexture=h(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(s._colorsTexture=h(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(s.boundingSphere=new ta().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(s.boundingBox=new ea().fromJSON(e.boundingBox));break;case"LOD":s=new WU;break;case"Line":s=new ro(o(e.geometry),c(e.material));break;case"LineLoop":s=new Mb(o(e.geometry),c(e.material));break;case"LineSegments":s=new nr(o(e.geometry),c(e.material));break;case"PointCloud":case"Points":s=new bb(o(e.geometry),c(e.material));break;case"Sprite":s=new kU(c(e.material));break;case"Group":s=new Ia;break;case"Bone":s=new H1;break;default:s=new Zt}if(s.uuid=e.uuid,e.name!==void 0&&(s.name=e.name),e.matrix!==void 0?(s.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(e.position!==void 0&&s.position.fromArray(e.position),e.rotation!==void 0&&s.rotation.fromArray(e.rotation),e.quaternion!==void 0&&s.quaternion.fromArray(e.quaternion),e.scale!==void 0&&s.scale.fromArray(e.scale)),e.up!==void 0&&s.up.fromArray(e.up),e.castShadow!==void 0&&(s.castShadow=e.castShadow),e.receiveShadow!==void 0&&(s.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(s.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(s.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(s.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(s.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&s.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(s.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(s.visible=e.visible),e.frustumCulled!==void 0&&(s.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(s.renderOrder=e.renderOrder),e.userData!==void 0&&(s.userData=e.userData),e.layers!==void 0&&(s.layers.mask=e.layers),e.children!==void 0){const m=e.children;for(let g=0;g<m.length;g++)s.add(this.parseObject(m[g],t,i,a,r))}if(e.animations!==void 0){const m=e.animations;for(let g=0;g<m.length;g++){const x=m[g];s.animations.push(r[x])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(s.autoUpdate=e.autoUpdate);const m=e.levels;for(let g=0;g<m.length;g++){const x=m[g],T=s.getObjectByProperty("uuid",x.object);T!==void 0&&s.addLevel(T,x.distance,x.hysteresis)}}return s}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const a=t[i.skeleton];a===void 0?ut("ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(a,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,a=e.getObjectByProperty("uuid",i);a!==void 0?t.target=a:t.target=new Zt}})}}const PV={UVMapping:A1,CubeReflectionMapping:al,CubeRefractionMapping:dc,EquirectangularReflectionMapping:a0,EquirectangularRefractionMapping:r0,CubeUVReflectionMapping:kd},J4={RepeatWrapping:Ta,ClampToEdgeWrapping:Li,MirroredRepeatWrapping:vd},$4={NearestFilter:Fn,NearestMipmapNearestFilter:R1,NearestMipmapLinearFilter:yu,LinearFilter:Ht,LinearMipmapNearestFilter:td,LinearMipmapLinearFilter:Er},i2=new WeakMap;class M6 extends Ti{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&ut("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&ut("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,a){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=to.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then(h=>{if(i2.has(s)===!0)a&&a(i2.get(s)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(h),r.manager.itemEnd(e),h});return}return setTimeout(function(){t&&t(s),r.manager.itemEnd(e)},0),s}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(h){return to.add(`image-bitmap:${e}`,h),t&&t(h),r.manager.itemEnd(e),h}).catch(function(h){a&&a(h),i2.set(c,h),to.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});to.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let bv;class Xb{static getContext(){return bv===void 0&&(bv=new(window.AudioContext||window.webkitAudioContext)),bv}static setContext(e){bv=e}}class zV extends Ti{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new ss(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(c){try{const h=c.slice(0);Xb.getContext().decodeAudioData(h,function(d){t(d)}).catch(o)}catch(h){o(h)}},i,a);function o(c){a?a(c):Bt(c),r.manager.itemError(e)}}}const eN=new ke,tN=new ke,Jc=new ke;class BV{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ui,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ui,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Jc.copy(e.projectionMatrix);const a=t.eyeSep/2,r=a*t.near/t.focus,s=t.near*Math.tan(Lu*t.fov*.5)/t.zoom;let o,c;tN.elements[12]=-a,eN.elements[12]=a,o=-s*t.aspect+r,c=s*t.aspect+r,Jc.elements[0]=2*t.near/(c-o),Jc.elements[8]=(c+o)/(c-o),this.cameraL.projectionMatrix.copy(Jc),o=-s*t.aspect-r,c=s*t.aspect-r,Jc.elements[0]=2*t.near/(c-o),Jc.elements[8]=(c+o)/(c-o),this.cameraR.projectionMatrix.copy(Jc)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(tN),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(eN)}}class b6 extends ui{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Yb{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const $c=new L,a2=new Tt,HV=new L,eu=new L,tu=new L;class FV extends Zt{constructor(){super(),this.type="AudioListener",this.context=Xb.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Yb}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose($c,a2,HV),eu.set(0,0,-1).applyQuaternion(a2),tu.set(0,1,0).applyQuaternion(a2),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime($c.x,i),t.positionY.linearRampToValueAtTime($c.y,i),t.positionZ.linearRampToValueAtTime($c.z,i),t.forwardX.linearRampToValueAtTime(eu.x,i),t.forwardY.linearRampToValueAtTime(eu.y,i),t.forwardZ.linearRampToValueAtTime(eu.z,i),t.upX.linearRampToValueAtTime(tu.x,i),t.upY.linearRampToValueAtTime(tu.y,i),t.upZ.linearRampToValueAtTime(tu.z,i)}else t.setPosition($c.x,$c.y,$c.z),t.setOrientation(eu.x,eu.y,eu.z,tu.x,tu.y,tu.z)}}class A6 extends Zt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){ut("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(ut("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(ut("Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const nu=new L,nN=new Tt,GV=new L,iu=new L;class VV extends A6{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(nu,nN,GV),iu.set(0,0,1).applyQuaternion(nN);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(nu.x,i),t.positionY.linearRampToValueAtTime(nu.y,i),t.positionZ.linearRampToValueAtTime(nu.z,i),t.orientationX.linearRampToValueAtTime(iu.x,i),t.orientationY.linearRampToValueAtTime(iu.y,i),t.orientationZ.linearRampToValueAtTime(iu.z,i)}else t.setPosition(nu.x,nu.y,nu.z),t.setOrientation(iu.x,iu.y,iu.z)}}class kV{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class R6{constructor(e,t,i){this.binding=e,this.valueSize=i;let a,r,s;switch(t){case"quaternion":a=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":a=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:a=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=a,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,a=this.valueSize,r=e*a+a;let s=this.cumulativeWeight;if(s===0){for(let o=0;o!==a;++o)i[r+o]=i[o];s=t}else{s+=t;const o=t/s;this._mixBufferRegion(i,r,0,o,a)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,a=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,a,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,a=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(i,a,c,1-r,t)}s>0&&this._mixBufferRegionAdditive(i,a,this._addIndex*t,1,t);for(let c=t,h=t+t;c!==h;++c)if(i[c]!==i[c+t]){o.setValue(i,a);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,a=i*this._origIndex;e.getValue(t,a);for(let r=i,s=a;r!==s;++r)t[r]=t[a+r%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,a,r){if(a>=.5)for(let s=0;s!==r;++s)e[t+s]=e[i+s]}_slerp(e,t,i,a){Tt.slerpFlat(e,t,e,t,e,i,a)}_slerpAdditive(e,t,i,a,r){const s=this._workIndex*r;Tt.multiplyQuaternionsFlat(e,s,e,t,e,i),Tt.slerpFlat(e,t,e,t,e,s,a)}_lerp(e,t,i,a,r){const s=1-a;for(let o=0;o!==r;++o){const c=t+o;e[c]=e[c]*s+e[i+o]*a}}_lerpAdditive(e,t,i,a,r){for(let s=0;s!==r;++s){const o=t+s;e[o]=e[o]+e[i+s]*a}}}const qb="\\[\\]\\.:\\/",WV=new RegExp("["+qb+"]","g"),jb="[^"+qb+"]",XV="[^"+qb.replace("\\.","")+"]",YV=/((?:WC+[\/:])*)/.source.replace("WC",jb),qV=/(WCOD+)?/.source.replace("WCOD",XV),jV=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jb),ZV=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jb),KV=new RegExp("^"+YV+qV+jV+ZV+"$"),QV=["material","materials","bones","map"];class JV{constructor(e,t,i){const a=i||fn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,a)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,a=this._bindings[i];a!==void 0&&a.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let a=this._targetGroup.nCachedObjects_,r=i.length;a!==r;++a)i[a].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class fn{constructor(e,t,i){this.path=t,this.parsedPath=i||fn.parseTrackName(t),this.node=fn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new fn.Composite(e,t,i):new fn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(WV,"")}static parseTrackName(e){const t=KV.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},a=i.nodeName&&i.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){const r=i.nodeName.substring(a+1);QV.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,a),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let s=0;s<r.length;s++){const o=r[s];if(o.name===t||o.uuid===t)return o;const c=i(o.children);if(c)return c}return null},a=i(e.children);if(a)return a}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let a=0,r=i.length;a!==r;++a)e[t++]=i[a]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let a=0,r=i.length;a!==r;++a)i[a]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let a=0,r=i.length;a!==r;++a)i[a]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let a=0,r=i.length;a!==r;++a)i[a]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,a=t.propertyName;let r=t.propertyIndex;if(e||(e=fn.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){ut("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let h=t.objectIndex;switch(i){case"materials":if(!e.material){Bt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Bt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Bt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let f=0;f<e.length;f++)if(e[f].name===h){h=f;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Bt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Bt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Bt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(h!==void 0){if(e[h]===void 0){Bt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const s=e[a];if(s===void 0){const h=t.nodeName;Bt("PropertyBinding: Trying to update property for track: "+h+"."+a+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(a==="morphTargetInfluences"){if(!e.geometry){Bt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Bt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else s.fromArray!==void 0&&s.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(c=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=a;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}fn.Composite=JV;fn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};fn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};fn.prototype.GetterByBindingType=[fn.prototype._getValue_direct,fn.prototype._getValue_array,fn.prototype._getValue_arrayElement,fn.prototype._getValue_toArray];fn.prototype.SetterByBindingTypeAndVersioning=[[fn.prototype._setValue_direct,fn.prototype._setValue_direct_setNeedsUpdate,fn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[fn.prototype._setValue_array,fn.prototype._setValue_array_setNeedsUpdate,fn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[fn.prototype._setValue_arrayElement,fn.prototype._setValue_arrayElement_setNeedsUpdate,fn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[fn.prototype._setValue_fromArray,fn.prototype._setValue_fromArray_setNeedsUpdate,fn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class $V{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Cr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,a=arguments.length;i!==a;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,a=this._parsedPaths,r=this._bindings,s=r.length;let o,c=e.length,h=this.nCachedObjects_;for(let f=0,d=arguments.length;f!==d;++f){const m=arguments[f],g=m.uuid;let x=t[g];if(x===void 0){x=c++,t[g]=x,e.push(m);for(let T=0,S=s;T!==S;++T)r[T].push(new fn(m,i[T],a[T]))}else if(x<h){o=e[x];const T=--h,S=e[T];t[S.uuid]=x,e[x]=S,t[g]=T,e[T]=m;for(let v=0,y=s;v!==y;++v){const E=r[v],b=E[T];let D=E[x];E[x]=b,D===void 0&&(D=new fn(m,i[v],a[v])),E[T]=D}}else e[x]!==o&&Bt("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,a=i.length;let r=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){const c=arguments[s],h=c.uuid,f=t[h];if(f!==void 0&&f>=r){const d=r++,m=e[d];t[m.uuid]=f,e[f]=m,t[h]=d,e[d]=c;for(let g=0,x=a;g!==x;++g){const T=i[g],S=T[d],v=T[f];T[f]=S,T[d]=v}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,a=i.length;let r=this.nCachedObjects_,s=e.length;for(let o=0,c=arguments.length;o!==c;++o){const h=arguments[o],f=h.uuid,d=t[f];if(d!==void 0)if(delete t[f],d<r){const m=--r,g=e[m],x=--s,T=e[x];t[g.uuid]=d,e[d]=g,t[T.uuid]=m,e[m]=T,e.pop();for(let S=0,v=a;S!==v;++S){const y=i[S],E=y[m],b=y[x];y[d]=E,y[m]=b,y.pop()}}else{const m=--s,g=e[m];m>0&&(t[g.uuid]=d),e[d]=g,e.pop();for(let x=0,T=a;x!==T;++x){const S=i[x];S[d]=S[m],S.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let a=i[e];const r=this._bindings;if(a!==void 0)return r[a];const s=this._paths,o=this._parsedPaths,c=this._objects,h=c.length,f=this.nCachedObjects_,d=new Array(h);a=r.length,i[e]=a,s.push(e),o.push(t),r.push(d);for(let m=f,g=c.length;m!==g;++m){const x=c[m];d[m]=new fn(x,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const a=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,c=s[o],h=e[o];t[h]=i,s[i]=c,s.pop(),r[i]=r[o],r.pop(),a[i]=a[o],a.pop()}}}class w6{constructor(e,t,i=null,a=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=a;const r=t.tracks,s=r.length,o=new Array(s),c={endingStart:Su,endingEnd:Su};for(let h=0;h!==s;++h){const f=r[h].createInterpolant(null);o[h]=f,f.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=yU,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const a=this._clip.duration,r=e._clip.duration,s=r/a,o=a/r;e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const a=this._mixer,r=a.time,s=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=a._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,h=o.sampleValues;return c[0]=r,c[1]=r+i,h[0]=e/s,h[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,a){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);const s=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case pb:for(let f=0,d=c.length;f!==d;++f)c[f].evaluate(s),h[f].accumulateAdditive(o);break;case I1:default:for(let f=0,d=c.length;f!==d;++f)c[f].evaluate(s),h[f].accumulate(a,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const a=i.evaluate(e)[0];t*=a,e>i.parameterPositions[1]&&(this.stopFading(),a===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const a=i.evaluate(e)[0];t*=a,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let a=this.time+e,r=this._loopCount;const s=i===SU;if(e===0)return r===-1?a:s&&(r&1)===1?t-a:a;if(i===xU){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(a>=t)a=t;else if(a<0)a=0;else{this.time=a;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),a>=t||a<0){const o=Math.floor(a/t);a-=t*o,r+=Math.abs(o);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a=e>0?t:0,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const h=e<0;this._setEndings(h,!h,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=a;if(s&&(r&1)===1)return t-a}return a}_setEndings(e,t,i){const a=this._interpolantSettings;i?(a.endingStart=Tu,a.endingEnd=Tu):(e?a.endingStart=this.zeroSlopeAtStart?Tu:Su:a.endingStart=s0,t?a.endingEnd=this.zeroSlopeAtEnd?Tu:Su:a.endingEnd=s0)}_scheduleFading(e,t,i){const a=this._mixer,r=a.time;let s=this._weightInterpolant;s===null&&(s=a._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,c=s.sampleValues;return o[0]=r,c[0]=t,o[1]=r+e,c[1]=i,this}}const ek=new Float32Array(1);class C6 extends tr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,a=e._clip.tracks,r=a.length,s=e._propertyBindings,o=e._interpolants,c=i.uuid,h=this._bindingsByRootAndName;let f=h[c];f===void 0&&(f={},h[c]=f);for(let d=0;d!==r;++d){const m=a[d],g=m.name;let x=f[g];if(x!==void 0)++x.referenceCount,s[d]=x;else{if(x=s[d],x!==void 0){x._cacheIndex===null&&(++x.referenceCount,this._addInactiveBinding(x,c,g));continue}const T=t&&t._propertyBindings[d].binding.parsedPath;x=new R6(fn.create(i,g,T),m.ValueTypeName,m.getValueSize()),++x.referenceCount,this._addInactiveBinding(x,c,g),s[d]=x}o[d].resultBuffer=x.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,a=e._clip.uuid,r=this._actionsByClip[a];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,a,i)}const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const a=this._actions,r=this._actionsByClip;let s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{const o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=a.length,a.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],a=e._cacheIndex;i._cacheIndex=a,t[a]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,s=this._actionsByClip,o=s[r],c=o.knownActions,h=c[c.length-1],f=e._byClipCacheIndex;h._byClipCacheIndex=f,c[f]=h,c.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,m=(e._localRoot||this._root).uuid;delete d[m],c.length===0&&delete s[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const r=t[i];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,a=this._nActiveActions++,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,a=--this._nActiveActions,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const a=this._bindingsByRootAndName,r=this._bindings;let s=a[t];s===void 0&&(s={},a[t]=s),s[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,a=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,o=s[a],c=t[t.length-1],h=e._cacheIndex;c._cacheIndex=h,t[h]=c,t.pop(),delete o[r],Object.keys(o).length===0&&delete s[a]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,a=this._nActiveBindings++,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,a=--this._nActiveBindings,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new zb(new Float32Array(2),new Float32Array(2),1,ek),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,a=--this._nActiveControlInterpolants,r=t[a];e.__cacheIndex=a,t[a]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const a=t||this._root,r=a.uuid;let s=typeof e=="string"?Ku.findByName(a,e):e;const o=s!==null?s.uuid:e,c=this._actionsByClip[o];let h=null;if(i===void 0&&(s!==null?i=s.blendMode:i=I1),c!==void 0){const d=c.actionByRoot[r];if(d!==void 0&&d.blendMode===i)return d;h=c.knownActions[0],s===null&&(s=h._clip)}if(s===null)return null;const f=new w6(this,s,t,i);return this._bindAction(f,h),this._addInactiveAction(f,o,r),f}existingAction(e,t){const i=t||this._root,a=i.uuid,r=typeof e=="string"?Ku.findByName(i,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];return o!==void 0&&o.actionByRoot[a]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,a=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let h=0;h!==i;++h)t[h]._update(a,e,r,s);const o=this._bindings,c=this._nActiveBindings;for(let h=0;h!==c;++h)o[h].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,a=this._actionsByClip,r=a[i];if(r!==void 0){const s=r.knownActions;for(let o=0,c=s.length;o!==c;++o){const h=s[o];this._deactivateAction(h);const f=h._cacheIndex,d=t[t.length-1];h._cacheIndex=null,h._byClipCacheIndex=null,d._cacheIndex=f,t[f]=d,t.pop(),this._removeInactiveBindingsForAction(h)}delete a[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const s in i){const o=i[s].actionByRoot,c=o[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const a=this._bindingsByRootAndName,r=a[t];if(r!==void 0)for(const s in r){const o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class tk extends _b{constructor(e=1,t=1,i=1,a={}){super(e,t,a),this.isRenderTarget3D=!0,this.depth=i,this.texture=new is(null,e,t,i),this._setTextureOptions(a),this.texture.isRenderTargetTexture=!0}}class J{constructor(e){this.value=e}clone(){return new J(this.value.clone===void 0?this.value:this.value.clone())}}let nk=0;class ik extends tr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:nk++}),this.name="",this.usage=l0,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,a=t.length;i<a;i++){const r=Array.isArray(t[i])?t[i]:[t[i]];for(let s=0;s<r.length;s++)this.uniforms.push(r[s].clone())}return this}clone(){return new this.constructor().copy(this)}}class ak extends I0{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class cE{constructor(e,t,i,a,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=a,this.count=r,this.normalized=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const iN=new ke;class N6{constructor(e,t,i=0,a=1/0){this.ray=new sh(e,t),this.near=i,this.far=a,this.camera=null,this.layers=new Md,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Bt("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return iN.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(iN),this}intersectObject(e,t=!0,i=[]){return uE(e,this,i,t),i.sort(aN),i}intersectObjects(e,t=!0,i=[]){for(let a=0,r=e.length;a<r;a++)uE(e[a],this,i,t);return i.sort(aN),i}}function aN(n,e){return n.distance-e.distance}function uE(n,e,t,i){let a=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(a=!1),a===!0&&i===!0){const r=n.children;for(let s=0,o=r.length;s<o;s++)uE(r[s],e,t,!0)}}let rk=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=sk.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function sk(){this._document.hidden===!1&&this.reset()}class hE{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Lt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Lt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class ok{constructor(e=1,t=0,i=0){this.radius=e,this.theta=t,this.y=i}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class Zb{constructor(e,t,i,a){Zb.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,a)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,a){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=a,this}}const rN=new de;class lk{constructor(e=new de(1/0,1/0),t=new de(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=rN.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,rN).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const sN=new L,Av=new L,lf=new L,cf=new L,r2=new L,ck=new L,uk=new L;class hk{constructor(e=new L,t=new L){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){sN.subVectors(e,this.start),Av.subVectors(this.end,this.start);const i=Av.dot(Av);let r=Av.dot(sN)/i;return t&&(r=Lt(r,0,1)),r}closestPointToPoint(e,t,i){const a=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(a).add(this.start)}distanceSqToLine3(e,t=ck,i=uk){const a=10000000000000001e-32;let r,s;const o=this.start,c=e.start,h=this.end,f=e.end;lf.subVectors(h,o),cf.subVectors(f,c),r2.subVectors(o,c);const d=lf.dot(lf),m=cf.dot(cf),g=cf.dot(r2);if(d<=a&&m<=a)return t.copy(o),i.copy(c),t.sub(i),t.dot(t);if(d<=a)r=0,s=g/m,s=Lt(s,0,1);else{const x=lf.dot(r2);if(m<=a)s=0,r=Lt(-x/d,0,1);else{const T=lf.dot(cf),S=d*m-T*T;S!==0?r=Lt((T*g-x*m)/S,0,1):r=0,s=(T*r+g)/m,s<0?(s=0,r=Lt(-x/d,0,1)):s>1&&(s=1,r=Lt((T-x)/d,0,1))}}return t.copy(o).add(lf.multiplyScalar(r)),i.copy(c).add(cf.multiplyScalar(s)),t.sub(i),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const oN=new L;class fk extends Zt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new wt,a=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,o=1,c=32;s<c;s++,o++){const h=s/c*Math.PI*2,f=o/c*Math.PI*2;a.push(Math.cos(h),Math.sin(h),1,Math.cos(f),Math.sin(f),1)}i.setAttribute("position",new xt(a,3));const r=new Pi({fog:!1,toneMapped:!1});this.cone=new nr(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),oN.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(oN),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Dl=new L,Rv=new ke,s2=new ke;class dk extends nr{constructor(e){const t=D6(e),i=new wt,a=[],r=[];for(let h=0;h<t.length;h++){const f=t[h];f.parent&&f.parent.isBone&&(a.push(0,0,0),a.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}i.setAttribute("position",new xt(a,3)),i.setAttribute("color",new xt(r,3));const s=new Pi({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,s),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const o=new je(255),c=new je(65280);this.setColors(o,c)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,a=i.getAttribute("position");s2.copy(this.root.matrixWorld).invert();for(let r=0,s=0;r<t.length;r++){const o=t[r];o.parent&&o.parent.isBone&&(Rv.multiplyMatrices(s2,o.matrixWorld),Dl.setFromMatrixPosition(Rv),a.setXYZ(s,Dl.x,Dl.y,Dl.z),Rv.multiplyMatrices(s2,o.parent.matrixWorld),Dl.setFromMatrixPosition(Rv),a.setXYZ(s+1,Dl.x,Dl.y,Dl.z),s+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const a=this.geometry.getAttribute("color");for(let r=0;r<a.count;r+=2)a.setXYZ(r,e.r,e.g,e.b),a.setXYZ(r+1,t.r,t.g,t.b);return a.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function D6(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push(...D6(n.children[t]));return e}class pk extends si{constructor(e,t,i){const a=new H0(t,4,2),r=new La({wireframe:!0,fog:!1,toneMapped:!1});super(a,r),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const mk=new L,lN=new je,cN=new je;class gk extends Zt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const a=new B0(t);a.rotateY(Math.PI*.5),this.material=new La({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=a.getAttribute("position"),s=new Float32Array(r.count*3);a.setAttribute("color",new Ot(s,3)),this.add(new si(a,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");lN.copy(this.light.color),cN.copy(this.light.groundColor);for(let i=0,a=t.count;i<a;i++){const r=i<a/2?lN:cN;t.setXYZ(i,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(mk.setFromMatrixPosition(this.light.matrixWorld).negate())}}class vk extends nr{constructor(e=10,t=10,i=4473924,a=8947848){i=new je(i),a=new je(a);const r=t/2,s=e/t,o=e/2,c=[],h=[];for(let m=0,g=0,x=-o;m<=t;m++,x+=s){c.push(-o,0,x,o,0,x),c.push(x,0,-o,x,0,o);const T=m===r?i:a;T.toArray(h,g),g+=3,T.toArray(h,g),g+=3,T.toArray(h,g),g+=3,T.toArray(h,g),g+=3}const f=new wt;f.setAttribute("position",new xt(c,3)),f.setAttribute("color",new xt(h,3));const d=new Pi({vertexColors:!0,toneMapped:!1});super(f,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class _k extends nr{constructor(e=10,t=16,i=8,a=64,r=4473924,s=8947848){r=new je(r),s=new je(s);const o=[],c=[];if(t>1)for(let d=0;d<t;d++){const m=d/t*(Math.PI*2),g=Math.sin(m)*e,x=Math.cos(m)*e;o.push(0,0,0),o.push(g,0,x);const T=d&1?r:s;c.push(T.r,T.g,T.b),c.push(T.r,T.g,T.b)}for(let d=0;d<i;d++){const m=d&1?r:s,g=e-e/i*d;for(let x=0;x<a;x++){let T=x/a*(Math.PI*2),S=Math.sin(T)*g,v=Math.cos(T)*g;o.push(S,0,v),c.push(m.r,m.g,m.b),T=(x+1)/a*(Math.PI*2),S=Math.sin(T)*g,v=Math.cos(T)*g,o.push(S,0,v),c.push(m.r,m.g,m.b)}}const h=new wt;h.setAttribute("position",new xt(o,3)),h.setAttribute("color",new xt(c,3));const f=new Pi({vertexColors:!0,toneMapped:!1});super(h,f),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const uN=new L,wv=new L,hN=new L;class xk extends Zt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let a=new wt;a.setAttribute("position",new xt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Pi({fog:!1,toneMapped:!1});this.lightPlane=new ro(a,r),this.add(this.lightPlane),a=new wt,a.setAttribute("position",new xt([0,0,0,0,0,1],3)),this.targetLine=new ro(a,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),uN.setFromMatrixPosition(this.light.matrixWorld),wv.setFromMatrixPosition(this.light.target.matrixWorld),hN.subVectors(wv,uN),this.lightPlane.lookAt(wv),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(wv),this.targetLine.scale.z=hN.length()}}const Cv=new L,mi=new Tc;class yk extends nr{constructor(e){const t=new wt,i=new Pi({color:16777215,vertexColors:!0,toneMapped:!1}),a=[],r=[],s={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(x,T){c(x),c(T)}function c(x){a.push(0,0,0),r.push(0,0,0),s[x]===void 0&&(s[x]=[]),s[x].push(a.length/3-1)}t.setAttribute("position",new xt(a,3)),t.setAttribute("color",new xt(r,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const h=new je(16755200),f=new je(16711680),d=new je(43775),m=new je(16777215),g=new je(3355443);this.setColors(h,f,d,m,g)}setColors(e,t,i,a,r){const o=this.geometry.getAttribute("color");return o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,i.r,i.g,i.b),o.setXYZ(33,i.r,i.g,i.b),o.setXYZ(34,i.r,i.g,i.b),o.setXYZ(35,i.r,i.g,i.b),o.setXYZ(36,i.r,i.g,i.b),o.setXYZ(37,i.r,i.g,i.b),o.setXYZ(38,a.r,a.g,a.b),o.setXYZ(39,a.r,a.g,a.b),o.setXYZ(40,r.r,r.g,r.b),o.setXYZ(41,r.r,r.g,r.b),o.setXYZ(42,r.r,r.g,r.b),o.setXYZ(43,r.r,r.g,r.b),o.setXYZ(44,r.r,r.g,r.b),o.setXYZ(45,r.r,r.g,r.b),o.setXYZ(46,r.r,r.g,r.b),o.setXYZ(47,r.r,r.g,r.b),o.setXYZ(48,r.r,r.g,r.b),o.setXYZ(49,r.r,r.g,r.b),o.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,i=1,a=1;let r,s;if(mi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)r=1,s=0;else if(this.camera.coordinateSystem===Mr)r=-1,s=1;else if(this.camera.coordinateSystem===Sd)r=0,s=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);xi("c",t,e,mi,0,0,r),xi("t",t,e,mi,0,0,s),xi("n1",t,e,mi,-i,-a,r),xi("n2",t,e,mi,i,-a,r),xi("n3",t,e,mi,-i,a,r),xi("n4",t,e,mi,i,a,r),xi("f1",t,e,mi,-i,-a,s),xi("f2",t,e,mi,i,-a,s),xi("f3",t,e,mi,-i,a,s),xi("f4",t,e,mi,i,a,s),xi("u1",t,e,mi,i*.7,a*1.1,r),xi("u2",t,e,mi,-i*.7,a*1.1,r),xi("u3",t,e,mi,0,a*2,r),xi("cf1",t,e,mi,-i,0,s),xi("cf2",t,e,mi,i,0,s),xi("cf3",t,e,mi,0,-a,s),xi("cf4",t,e,mi,0,a,s),xi("cn1",t,e,mi,-i,0,r),xi("cn2",t,e,mi,i,0,r),xi("cn3",t,e,mi,0,-a,r),xi("cn4",t,e,mi,0,a,r),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function xi(n,e,t,i,a,r,s){Cv.set(a,r,s).unproject(i);const o=e[n];if(o!==void 0){const c=t.getAttribute("position");for(let h=0,f=o.length;h<f;h++)c.setXYZ(o[h],Cv.x,Cv.y,Cv.z)}}const Nv=new ea;class Sk extends nr{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),a=new Float32Array(8*3),r=new wt;r.setIndex(new Ot(i,1)),r.setAttribute("position",new Ot(a,3)),super(r,new Pi({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Nv.setFromObject(this.object),Nv.isEmpty())return;const e=Nv.min,t=Nv.max,i=this.geometry.attributes.position,a=i.array;a[0]=t.x,a[1]=t.y,a[2]=t.z,a[3]=e.x,a[4]=t.y,a[5]=t.z,a[6]=e.x,a[7]=e.y,a[8]=t.z,a[9]=t.x,a[10]=e.y,a[11]=t.z,a[12]=t.x,a[13]=t.y,a[14]=e.z,a[15]=e.x,a[16]=t.y,a[17]=e.z,a[18]=e.x,a[19]=e.y,a[20]=e.z,a[21]=t.x,a[22]=e.y,a[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Tk extends nr{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),a=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new wt;r.setIndex(new Ot(i,1)),r.setAttribute("position",new xt(a,3)),super(r,new Pi({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ek extends ro{constructor(e,t=1,i=16776960){const a=i,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],s=new wt;s.setAttribute("position",new xt(r,3)),s.computeBoundingSphere(),super(s,new Pi({color:a,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new wt;c.setAttribute("position",new xt(o,3)),c.computeBoundingSphere(),this.add(new si(c,new La({color:a,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const fN=new L;let Dv,o2;class Mk extends Zt{constructor(e=new L(0,0,1),t=new L(0,0,0),i=1,a=16776960,r=i*.2,s=r*.2){super(),this.type="ArrowHelper",Dv===void 0&&(Dv=new wt,Dv.setAttribute("position",new xt([0,0,0,0,1,0],3)),o2=new z0(.5,1,5,1),o2.translate(0,-.5,0)),this.position.copy(t),this.line=new ro(Dv,new Pi({color:a,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new si(o2,new La({color:a,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,r,s)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{fN.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(fN,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class O6 extends nr{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],a=new wt;a.setAttribute("position",new xt(t,3)),a.setAttribute("color",new xt(i,3));const r=new Pi({vertexColors:!0,toneMapped:!1});super(a,r),this.type="AxesHelper"}setColors(e,t,i){const a=new je,r=this.geometry.attributes.color.array;return a.set(e),a.toArray(r,0),a.toArray(r,3),a.set(t),a.toArray(r,6),a.toArray(r,9),a.set(i),a.toArray(r,12),a.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class bk{constructor(){this.type="ShapePath",this.color=new je,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new zx,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,a){return this.currentPath.quadraticCurveTo(e,t,i,a),this}bezierCurveTo(e,t,i,a,r,s){return this.currentPath.bezierCurveTo(e,t,i,a,r,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(v){const y=[];for(let E=0,b=v.length;E<b;E++){const D=v[E],C=new Iu;C.curves=D.curves,y.push(C)}return y}function i(v,y){const E=y.length;let b=!1;for(let D=E-1,C=0;C<E;D=C++){let I=y[D],P=y[C],O=P.x-I.x,R=P.y-I.y;if(Math.abs(R)>Number.EPSILON){if(R<0&&(I=y[C],O=-O,P=y[D],R=-R),v.y<I.y||v.y>P.y)continue;if(v.y===I.y){if(v.x===I.x)return!0}else{const B=R*(v.x-I.x)-O*(v.y-I.y);if(B===0)return!0;if(B<0)continue;b=!b}}else{if(v.y!==I.y)continue;if(P.x<=v.x&&v.x<=I.x||I.x<=v.x&&v.x<=P.x)return!0}}return b}const a=As.isClockWise,r=this.subPaths;if(r.length===0)return[];let s,o,c;const h=[];if(r.length===1)return o=r[0],c=new Iu,c.curves=o.curves,h.push(c),h;let f=!a(r[0].getPoints());f=e?!f:f;const d=[],m=[];let g=[],x=0,T;m[x]=void 0,g[x]=[];for(let v=0,y=r.length;v<y;v++)o=r[v],T=o.getPoints(),s=a(T),s=e?!s:s,s?(!f&&m[x]&&x++,m[x]={s:new Iu,p:T},m[x].s.curves=o.curves,f&&x++,g[x]=[]):g[x].push({h:o,p:T[0]});if(!m[0])return t(r);if(m.length>1){let v=!1,y=0;for(let E=0,b=m.length;E<b;E++)d[E]=[];for(let E=0,b=m.length;E<b;E++){const D=g[E];for(let C=0;C<D.length;C++){const I=D[C];let P=!0;for(let O=0;O<m.length;O++)i(I.p,m[O].p)&&(E!==O&&y++,P?(P=!1,d[O].push(I)):v=!0);P&&d[E].push(I)}}y>0&&v===!1&&(g=d)}let S;for(let v=0,y=m.length;v<y;v++){c=m[v].s,h.push(c),S=g[v];for(let E=0,b=S.length;E<b;E++)c.holes.push(S[E].h)}return h}}class Ak extends tr{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){ut("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Rk(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function wk(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function Ck(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function fE(n,e,t,i){const a=Nk(i);switch(t){case fb:return n*e;case bs:return n*e/a.components*a.byteLength;case O0:return n*e/a.components*a.byteLength;case Vo:return n*e*2/a.components*a.byteLength;case O1:return n*e*2/a.components*a.byteLength;case db:return n*e*3/a.components*a.byteLength;case Jn:return n*e*4/a.components*a.byteLength;case L1:return n*e*4/a.components*a.byteLength;case Nm:case Dm:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Om:case Lm:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case sx:case lx:return Math.max(n,16)*Math.max(e,8)/4;case rx:case ox:return Math.max(n,8)*Math.max(e,8)/2;case cx:case ux:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case hx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case fx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case dx:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case px:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case mx:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case gx:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case vx:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case _x:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case xx:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case yx:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Sx:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Tx:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Ex:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Mx:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case bx:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Ax:case Rx:case wx:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Cx:case Nx:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Dx:case Ox:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Nk(n){switch(n){case Ii:case w1:return{byteLength:1,components:1};case Wu:case C1:case Xn:return{byteLength:2,components:1};case N1:case D1:return{byteLength:2,components:4};case Ns:case D0:case ri:return{byteLength:4,components:1};case ub:case hb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}class Dk{static contain(e,t){return Rk(e,t)}static cover(e,t){return wk(e,t)}static fill(e){return Ck(e)}static getByteLength(e,t,i,a){return fE(e,t,i,a)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ws}}));typeof window<"u"&&(window.__THREE__?ut("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ws);/**
* @license
* Copyright 2010-2025 Three.js Authors
* SPDX-License-Identifier: MIT
*/function L6(){let n=null,e=!1,t=null,i=null;function a(r,s){t(r,s),i=n.requestAnimationFrame(a)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(a),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function Ok(n){const e=new WeakMap;function t(o,c){const h=o.array,f=o.usage,d=h.byteLength,m=n.createBuffer();n.bindBuffer(c,m),n.bufferData(c,h,f),o.onUploadCallback();let g;if(h instanceof Float32Array)g=n.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)g=n.HALF_FLOAT;else if(h instanceof Uint16Array)o.isFloat16BufferAttribute?g=n.HALF_FLOAT:g=n.UNSIGNED_SHORT;else if(h instanceof Int16Array)g=n.SHORT;else if(h instanceof Uint32Array)g=n.UNSIGNED_INT;else if(h instanceof Int32Array)g=n.INT;else if(h instanceof Int8Array)g=n.BYTE;else if(h instanceof Uint8Array)g=n.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)g=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:m,type:g,bytesPerElement:h.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,c,h){const f=c.array,d=c.updateRanges;if(n.bindBuffer(h,o),d.length===0)n.bufferSubData(h,0,f);else{d.sort((g,x)=>g.start-x.start);let m=0;for(let g=1;g<d.length;g++){const x=d[m],T=d[g];T.start<=x.start+x.count+1?x.count=Math.max(x.count,T.start+T.count-x.start):(++m,d[m]=T)}d.length=m+1;for(let g=0,x=d.length;g<x;g++){const T=d[g];n.bufferSubData(h,T.start*f.BYTES_PER_ELEMENT,f,T.start,T.count)}c.clearUpdateRanges()}c.onUploadCallback()}function a(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(n.deleteBuffer(c.buffer),e.delete(o))}function s(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const f=e.get(o);(!f||f.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const h=e.get(o);if(h===void 0)e.set(o,t(o,c));else if(h.version<o.version){if(h.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(h.buffer,o,c),h.version=o.version}}return{get:a,remove:r,update:s}}var Lk=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,Ik=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
}
float hash3D( vec3 value ) {
return hash2D( vec2( hash2D( value.xy ), value.z ) );
}
float getAlphaHashThreshold( vec3 position ) {
float maxDeriv = max(
length( dFdx( position.xyz ) ),
length( dFdy( position.xyz ) )
);
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
vec2 pixScales = vec2(
exp2( floor( log2( pixScale ) ) ),
exp2( ceil( log2( pixScale ) ) )
);
vec2 alpha = vec2(
hash3D( floor( pixScales.x * position.xyz ) ),
hash3D( floor( pixScales.y * position.xyz ) )
);
float lerpFactor = fract( log2( pixScale ) );
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
float a = min( lerpFactor, 1.0 - lerpFactor );
vec3 cases = vec3(
x * x / ( 2.0 * a * ( 1.0 - a ) ),
( x - 0.5 * a ) / ( 1.0 - a ),
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
);
float threshold = ( x < ( 1.0 - a ) )
? ( ( x < a ) ? cases.x : cases.y )
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
#endif`,Uk=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,Pk=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,zk=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
#endif`,Bk=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,Hk=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
clearcoatSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_SHEEN )
sheenSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
#endif`,Fk=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,Gk=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
#endif
uniform highp sampler2D batchingTexture;
uniform highp usampler2D batchingIdTexture;
mat4 getBatchingMatrix( const in float i ) {
int size = textureSize( batchingTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
float getIndirectIndex( const in int i ) {
int size = textureSize( batchingIdTexture, 0 ).x;
int x = i % size;
int y = i / size;
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
}
#endif
#ifdef USE_BATCHING_COLOR
uniform sampler2D batchingColorTexture;
vec3 getBatchingColor( const in float i ) {
int size = textureSize( batchingColorTexture, 0 ).x;
int j = int( i );
int x = j % size;
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
}
#endif`,Vk=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,kk=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,Wk=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,Xk=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
} // validated`,Yk=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
-0.4985314, 0.0415560, 1.0572252
);
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
vec3 sqrtF0 = sqrt( fresnel0 );
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
}
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
}
float IorToFresnel0( float transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
}
vec3 evalSensitivity( float OPD, vec3 shift ) {
float phase = 2.0 * PI * OPD * 1.0e-9;
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
xyz /= 1.0685e-7;
vec3 rgb = XYZ_TO_REC709 * xyz;
return rgb;
}
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
vec3 I;
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
float cosTheta2Sq = 1.0 - sinTheta2Sq;
if ( cosTheta2Sq < 0.0 ) {
return vec3( 1.0 );
}
float cosTheta2 = sqrt( cosTheta2Sq );
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
float T121 = 1.0 - R12;
float phi12 = 0.0;
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
float phi21 = PI - phi12;
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
vec3 phi23 = vec3( 0.0 );
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
vec3 phi = vec3( phi21 ) + phi23;
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
vec3 r123 = sqrt( R123 );
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
vec3 C0 = R12 + Rs;
I = C0;
vec3 Cm = Rs - T121;
for ( int m = 1; m <= 2; ++ m ) {
Cm *= r123;
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
I += Cm * Sm;
}
return max( I, vec3( 0.0 ) );
}
#endif`,qk=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
vec2 dSTdx = dFdx( vBumpMapUv );
vec2 dSTdy = dFdy( vBumpMapUv );
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
return vec2( dBx, dBy );
}
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
vec3 vN = surf_norm;
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
#endif`,jk=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
float clipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
if ( clipOpacity == 0.0 ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
float unionClipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
}
#pragma unroll_loop_end
clipOpacity *= 1.0 - unionClipOpacity;
#endif
diffuseColor.a *= clipOpacity;
if ( diffuseColor.a == 0.0 ) discard;
#else
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
}
#pragma unroll_loop_end
if ( clipped ) discard;
#endif
#endif
#endif`,Zk=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,Kk=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,Qk=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,Jk=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,$k=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,eW=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,tW=`#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
vColor.xyz *= batchingColor.xyz;
#endif`,nW=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,iW=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
vec3 absDirection = abs( direction );
float face = - 1.0;
if ( absDirection.x > absDirection.z ) {
if ( absDirection.x > absDirection.y )
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if ( absDirection.z > absDirection.y )
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x );
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z );
}
return 0.5 * ( uv + 1.0 );
}
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
float face = getFace( direction );
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
mipInt = max( mipInt, cubeUV_minMipLevel );
float faceSize = exp2( mipInt );
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
if ( face > 2.0 ) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
uv.x *= CUBEUV_TEXEL_WIDTH;
uv.y *= CUBEUV_TEXEL_HEIGHT;
#ifdef texture2DGradEXT
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
#else
return texture2D( envMap, uv ).rgb;
#endif
}
#define cubeUV_r0 1.0
#define cubeUV_m0 - 2.0
#define cubeUV_r1 0.8
#define cubeUV_m1 - 1.0
#define cubeUV_r4 0.4
#define cubeUV_m4 2.0
#define cubeUV_r5 0.305
#define cubeUV_m5 3.0
#define cubeUV_r6 0.21
#define cubeUV_m6 4.0
float roughnessToMip( float roughness ) {
float mip = 0.0;
if ( roughness >= cubeUV_r1 ) {
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
} else if ( roughness >= cubeUV_r4 ) {
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
} else if ( roughness >= cubeUV_r5 ) {
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
} else if ( roughness >= cubeUV_r6 ) {
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
} else {
mip = - 2.0 * log2( 1.16 * roughness ); }
return mip;
}
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
float mipF = fract( mip );
float mipInt = floor( mip );
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
if ( mipF == 0.0 ) {
return vec4( color0, 1.0 );
} else {
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
#endif`,aW=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
mat3 bm = mat3( batchingMatrix );
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
transformedNormal = bm * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = bm * transformedTangent;
#endif
#endif
#ifdef USE_INSTANCING
mat3 im = mat3( instanceMatrix );
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
transformedNormal = im * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = im * transformedTangent;
#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
#endif`,rW=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,sW=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,oW=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,lW=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,cW="gl_FragColor = linearToOutputTexel( gl_FragColor );",uW=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,hW=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
#else
vec4 envColor = vec4( 0.0 );
#endif
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif`,fW=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,dW=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif`,pW=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
varying vec3 vReflect;
uniform float refractionRatio;
#endif
#endif`,mW=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,gW=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,vW=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,_W=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,xW=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,yW=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
float dotNL = dot( normal, lightDirection );
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
#ifdef USE_GRADIENTMAP
return vec3( texture2D( gradientMap, coord ).r );
#else
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
}`,SW=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,TW=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,EW=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,MW=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometryPosition;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometryPosition;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif`,bW=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 bentNormal = cross( bitangent, viewDir );
bentNormal = normalize( cross( bentNormal, bitangent ) );
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
return getIBLRadiance( viewDir, bentNormal, roughness );
#else
return vec3( 0.0 );
#endif
}
#endif
#endif`,AW=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,RW=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,wW=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,CW=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,NW=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef USE_SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULAR_COLORMAP
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEEN_COLORMAP
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
#ifdef USE_SHEEN_ROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
#endif
#endif
#ifdef USE_ANISOTROPY
#ifdef USE_ANISOTROPYMAP
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
#else
vec2 anisotropyV = anisotropyVector;
#endif
material.anisotropy = length( anisotropyV );
if( material.anisotropy == 0.0 ) {
anisotropyV = vec2( 1.0, 0.0 );
} else {
anisotropyV /= material.anisotropy;
material.anisotropy = saturate( material.anisotropy );
}
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,DW=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
#ifdef USE_ANISOTROPY
float anisotropy;
float alphaT;
vec3 anisotropyT;
vec3 anisotropyB;
#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
float v = 0.5 / ( gv + gl );
return saturate(v);
}
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
float a2 = alphaT * alphaB;
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
highp float v2 = dot( v, v );
float w2 = a2 / v2;
return RECIPROCAL_PI * a2 * pow2 ( w2 );
}
#endif
#ifdef USE_CLEARCOAT
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
vec3 f0 = material.clearcoatF0;
float f90 = material.clearcoatF90;
float roughness = material.clearcoatRoughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 f0 = material.specularColor;
float f90 = material.specularF90;
float roughness = material.roughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
#ifdef USE_IRIDESCENCE
F = mix( F, material.iridescenceFresnel, material.iridescence );
#endif
#ifdef USE_ANISOTROPY
float dotTL = dot( material.anisotropyT, lightDir );
float dotTV = dot( material.anisotropyT, viewDir );
float dotTH = dot( material.anisotropyT, halfDir );
float dotBL = dot( material.anisotropyB, lightDir );
float dotBV = dot( material.anisotropyB, viewDir );
float dotBH = dot( material.anisotropyB, halfDir );
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
#else
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
#endif
return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
vec2 uv = vec2( roughness, dotNV );
return texture2D( dfgLUT, uv ).rg;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
vec2 fab = DFGApprox( normal, viewDir, roughness );
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
float Ess_V = dfgV.x + dfgV.y;
float Ess_L = dfgL.x + dfgL.y;
float Ems_V = 1.0 - Ess_V;
float Ems_L = 1.0 - Ess_L;
vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
float compensationFactor = Ems_V * Ems_L;
vec3 multiScatter = Fms * compensationFactor;
return singleScatter + multiScatter;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
vec3 viewDir = geometryViewDir;
vec3 position = geometryPosition;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
#endif
#ifdef USE_SHEEN
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
#endif
vec3 singleScattering = vec3( 0.0 );
vec3 multiScattering = vec3( 0.0 );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
#endif
vec3 totalScattering = singleScattering + multiScattering;
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
reflectedLight.indirectSpecular += radiance * singleScattering;
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,OW=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometryViewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
vec4 spotColor;
vec3 spotLightCoord;
bool inSpotLightMap;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometryPosition, directLight );
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
#else
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#endif
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
#endif
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
}
#pragma unroll_loop_end
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,LW=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,IW=`#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,UW=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,PW=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,zW=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,BW=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,HW=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,FW=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,GW=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#endif
#ifdef USE_MAP
diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,VW=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,kW=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,WW=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,XW=`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
#endif`,YW=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
#elif defined( USE_COLOR )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
#endif`,qW=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
#endif`,jW=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
#endif
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
#endif`,ZW=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
#endif`,KW=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal,
#if defined( USE_NORMALMAP )
vNormalMapUv
#elif defined( USE_CLEARCOAT_NORMALMAP )
vClearcoatNormalMapUv
#else
vUv
#endif
);
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,QW=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,JW=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,$W=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,eX=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,tX=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
vec3 q0 = dFdx( eye_pos.xyz );
vec3 q1 = dFdy( eye_pos.xyz );
vec2 st0 = dFdx( uv.st );
vec2 st1 = dFdy( uv.st );
vec3 N = surf_norm;
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
#endif`,nX=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,iX=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,aX=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif`,rX=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,sX=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,oX=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
if( v <= 0.0 )
return vec4( 0., 0., 0., 0. );
if( v >= 1.0 )
return vec4( 1., 1., 1., 1. );
float vuf;
float af = modf( v * PackFactors.a, vuf );
float bf = modf( vuf * ShiftRight8, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
if( v <= 0.0 )
return vec3( 0., 0., 0. );
if( v >= 1.0 )
return vec3( 1., 1., 1. );
float vuf;
float bf = modf( v * PackFactors.b, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
if( v <= 0.0 )
return vec2( 0., 0. );
if( v >= 1.0 )
return vec2( 1., 1. );
float vuf;
float gf = modf( v * 256., vuf );
return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
return ( near * far ) / ( ( far - near ) * depth - far );
}`,lX=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,cX=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,uX=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,hX=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
#endif`,fX=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,dX=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,pX=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
#ifdef USE_REVERSED_DEPTH_BUFFER
return step( depth, compare );
#else
return step( compare, depth );
#endif
}
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
return unpackRGBATo2Half( texture2D( shadow, uv ) );
}
float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
float occlusion = 1.0;
vec2 distribution = texture2DDistribution( shadow, uv );
#ifdef USE_REVERSED_DEPTH_BUFFER
float hard_shadow = step( distribution.x, compare );
#else
float hard_shadow = step( compare, distribution.x );
#endif
if ( hard_shadow != 1.0 ) {
float distance = compare - distribution.x;
float variance = max( 0.00000, distribution.y * distribution.y );
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
}
return occlusion;
}
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
#if defined( SHADOWMAP_TYPE_PCF )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx0 = - texelSize.x * shadowRadius;
float dy0 = - texelSize.y * shadowRadius;
float dx1 = + texelSize.x * shadowRadius;
float dy1 = + texelSize.y * shadowRadius;
float dx2 = dx0 / 2.0;
float dy2 = dy0 / 2.0;
float dx3 = dx1 / 2.0;
float dy3 = dy1 / 2.0;
shadow = (
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
) * ( 1.0 / 17.0 );
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx = texelSize.x;
float dy = texelSize.y;
vec2 uv = shadowCoord.xy;
vec2 f = fract( uv * shadowMapSize + 0.5 );
uv -= f * texelSize;
shadow = (
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
f.x ),
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
f.x ),
f.y )
) * ( 1.0 / 9.0 );
#elif defined( SHADOWMAP_TYPE_VSM )
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
#else
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
vec2 cubeToUV( vec3 v, float texelSizeY ) {
vec3 absV = abs( v );
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
vec2 planar = v.xy;
float almostATexel = 1.5 * texelSizeY;
float almostOne = 1.0 - almostATexel;
if ( absV.z >= almostOne ) {
if ( v.z > 0.0 )
planar.x = 4.0 - v.x;
} else if ( absV.x >= almostOne ) {
float signX = sign( v.x );
planar.x = v.z * signX + 2.0 * signX;
} else if ( absV.y >= almostOne ) {
float signY = sign( v.y );
planar.x = v.x + 2.0 * signY + 2.0;
planar.y = v.z * signY - 2.0;
}
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
float lightToPositionLength = length( lightToPosition );
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
shadow = (
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
) * ( 1.0 / 9.0 );
#else
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif`,mX=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#endif`,gX=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,vX=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,_X=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,xX=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
mat4 getBoneMatrix( const in float i ) {
int size = textureSize( boneTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
#endif`,yX=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatY * skinVertex * skinWeight.y;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,SX=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
skinMatrix += skinWeight.z * boneMatZ;
skinMatrix += skinWeight.w * boneMatW;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
#endif`,TX=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,EX=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,MX=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,bX=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
vec3( 1.6605, - 0.1246, - 0.0182 ),
vec3( - 0.5876, 1.1329, - 0.1006 ),
vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
vec3( 0.6274, 0.0691, 0.0164 ),
vec3( 0.3293, 0.9195, 0.0880 ),
vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
vec3 x2 = x * x;
vec3 x4 = x2 * x2;
return + 15.5 * x4 * x2
- 40.14 * x4 * x
+ 31.96 * x4
- 6.868 * x2 * x
+ 0.4298 * x2
+ 0.1191 * x
- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
const mat3 AgXInsetMatrix = mat3(
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
);
const mat3 AgXOutsetMatrix = mat3(
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
);
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
color *= toneMappingExposure;
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
color = AgXInsetMatrix * color;
color = max( color, 1e-10 ); color = log2( color );
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
color = clamp( color, 0.0, 1.0 );
color = agxDefaultContrastApprox( color );
color = AgXOutsetMatrix * color;
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
color = clamp( color, 0.0, 1.0 );
return color;
}
vec3 NeutralToneMapping( vec3 color ) {
const float StartCompression = 0.8 - 0.04;
const float Desaturation = 0.15;
color *= toneMappingExposure;
float x = min( color.r, min( color.g, color.b ) );
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
color -= offset;
float peak = max( color.r, max( color.g, color.b ) );
if ( peak < StartCompression ) return color;
float d = 1. - StartCompression;
float newPeak = 1. - d * d / ( peak + d - StartCompression );
color *= newPeak / peak;
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,AX=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = inverseTransformDirection( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,RX=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
uniform vec3 attenuationColor;
#ifdef USE_TRANSMISSIONMAP
uniform sampler2D transmissionMap;
#endif
#ifdef USE_THICKNESSMAP
uniform sampler2D thicknessMap;
#endif
uniform vec2 transmissionSamplerSize;
uniform sampler2D transmissionSamplerMap;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
varying vec3 vWorldPosition;
float w0( float a ) {
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
}
float w1( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
}
float w2( float a ){
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
}
float w3( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * a );
}
float g0( float a ) {
return w0( a ) + w1( a );
}
float g1( float a ) {
return w2( a ) + w3( a );
}
float h0( float a ) {
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
}
float h1( float a ) {
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
}
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
uv = uv * texelSize.zw + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
float g0x = g0( fuv.x );
float g1x = g1( fuv.x );
float h0x = h0( fuv.x );
float h1x = h1( fuv.x );
float h0y = h0( fuv.y );
float h1y = h1( fuv.y );
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
}
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
vec2 fLodSizeInv = 1.0 / fLodSize;
vec2 cLodSizeInv = 1.0 / cLodSize;
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
return mix( fSample, cSample, fract( lod ) );
}
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
}
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
if ( isinf( attenuationDistance ) ) {
return vec3( 1.0 );
} else {
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
}
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
vec4 transmittedLight;
vec3 transmittance;
#ifdef USE_DISPERSION
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
for ( int i = 0; i < 3; i ++ ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
transmittedLight[ i ] = transmissionSample[ i ];
transmittedLight.a += transmissionSample.a;
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
}
transmittedLight.a /= 3.0;
#else
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
#endif
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
#endif`,wX=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,CX=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
uniform mat3 mapTransform;
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
uniform mat3 alphaMapTransform;
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
uniform mat3 lightMapTransform;
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
uniform mat3 aoMapTransform;
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
uniform mat3 bumpMapTransform;
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
uniform mat3 normalMapTransform;
varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
uniform mat3 displacementMapTransform;
varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
uniform mat3 emissiveMapTransform;
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
uniform mat3 metalnessMapTransform;
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
uniform mat3 roughnessMapTransform;
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
uniform mat3 anisotropyMapTransform;
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
uniform mat3 clearcoatMapTransform;
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform mat3 clearcoatNormalMapTransform;
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform mat3 clearcoatRoughnessMapTransform;
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
uniform mat3 sheenColorMapTransform;
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform mat3 sheenRoughnessMapTransform;
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
uniform mat3 iridescenceMapTransform;
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform mat3 iridescenceThicknessMapTransform;
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
uniform mat3 specularMapTransform;
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
uniform mat3 specularColorMapTransform;
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform mat3 specularIntensityMapTransform;
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,NX=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,DX=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
#endif
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
#endif`;const OX=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,LX=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,IX=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,UX=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,PX=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,zX=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
gl_FragColor = texColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,BX=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}`,HX=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <logdepthbuf_fragment>
#ifdef USE_REVERSED_DEPTH_BUFFER
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
#else
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
#endif
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#elif DEPTH_PACKING == 3202
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
}`,FX=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}`,GX=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = packDepthToRGBA( dist );
}`,VX=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,kX=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,WX=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,XX=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,YX=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}`,qX=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,jX=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,ZX=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,KX=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}`,QX=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
#endif
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,JX=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
}`,$X=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,eY=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,tY=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,nY=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}`,iY=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef USE_SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULAR_COLORMAP
uniform sampler2D specularColorMap;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
uniform float iridescenceThicknessMinimum;
uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEEN_COLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
#ifdef USE_ANISOTROPY
uniform vec2 anisotropyVector;
#ifdef USE_ANISOTROPYMAP
uniform sampler2D anisotropyMap;
#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
#ifdef USE_SHEEN
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
#endif
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,aY=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,rY=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,sY=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
varying vec2 vUv;
uniform mat3 uvTransform;
#endif
void main() {
#ifdef USE_POINTS_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}`,oY=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,lY=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,cY=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
#include <logdepthbuf_fragment>
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,uY=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
vec4 mvPosition = modelViewMatrix[ 3 ];
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#endif
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,hY=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,Qt={alphahash_fragment:Lk,alphahash_pars_fragment:Ik,alphamap_fragment:Uk,alphamap_pars_fragment:Pk,alphatest_fragment:zk,alphatest_pars_fragment:Bk,aomap_fragment:Hk,aomap_pars_fragment:Fk,batching_pars_vertex:Gk,batching_vertex:Vk,begin_vertex:kk,beginnormal_vertex:Wk,bsdfs:Xk,iridescence_fragment:Yk,bumpmap_pars_fragment:qk,clipping_planes_fragment:jk,clipping_planes_pars_fragment:Zk,clipping_planes_pars_vertex:Kk,clipping_planes_vertex:Qk,color_fragment:Jk,color_pars_fragment:$k,color_pars_vertex:eW,color_vertex:tW,common:nW,cube_uv_reflection_fragment:iW,defaultnormal_vertex:aW,displacementmap_pars_vertex:rW,displacementmap_vertex:sW,emissivemap_fragment:oW,emissivemap_pars_fragment:lW,colorspace_fragment:cW,colorspace_pars_fragment:uW,envmap_fragment:hW,envmap_common_pars_fragment:fW,envmap_pars_fragment:dW,envmap_pars_vertex:pW,envmap_physical_pars_fragment:bW,envmap_vertex:mW,fog_vertex:gW,fog_pars_vertex:vW,fog_fragment:_W,fog_pars_fragment:xW,gradientmap_pars_fragment:yW,lightmap_pars_fragment:SW,lights_lambert_fragment:TW,lights_lambert_pars_fragment:EW,lights_pars_begin:MW,lights_toon_fragment:AW,lights_toon_pars_fragment:RW,lights_phong_fragment:wW,lights_phong_pars_fragment:CW,lights_physical_fragment:NW,lights_physical_pars_fragment:DW,lights_fragment_begin:OW,lights_fragment_maps:LW,lights_fragment_end:IW,logdepthbuf_fragment:UW,logdepthbuf_pars_fragment:PW,logdepthbuf_pars_vertex:zW,logdepthbuf_vertex:BW,map_fragment:HW,map_pars_fragment:FW,map_particle_fragment:GW,map_particle_pars_fragment:VW,metalnessmap_fragment:kW,metalnessmap_pars_fragment:WW,morphinstance_vertex:XW,morphcolor_vertex:YW,morphnormal_vertex:qW,morphtarget_pars_vertex:jW,morphtarget_vertex:ZW,normal_fragment_begin:KW,normal_fragment_maps:QW,normal_pars_fragment:JW,normal_pars_vertex:$W,normal_vertex:eX,normalmap_pars_fragment:tX,clearcoat_normal_fragment_begin:nX,clearcoat_normal_fragment_maps:iX,clearcoat_pars_fragment:aX,iridescence_pars_fragment:rX,opaque_fragment:sX,packing:oX,premultiplied_alpha_fragment:lX,project_vertex:cX,dithering_fragment:uX,dithering_pars_fragment:hX,roughnessmap_fragment:fX,roughnessmap_pars_fragment:dX,shadowmap_pars_fragment:pX,shadowmap_pars_vertex:mX,shadowmap_vertex:gX,shadowmask_pars_fragment:vX,skinbase_vertex:_X,skinning_pars_vertex:xX,skinning_vertex:yX,skinnormal_vertex:SX,specularmap_fragment:TX,specularmap_pars_fragment:EX,tonemapping_fragment:MX,tonemapping_pars_fragment:bX,transmission_fragment:AX,transmission_pars_fragment:RX,uv_pars_fragment:wX,uv_pars_vertex:CX,uv_vertex:NX,worldpos_vertex:DX,background_vert:OX,background_frag:LX,backgroundCube_vert:IX,backgroundCube_frag:UX,cube_vert:PX,cube_frag:zX,depth_vert:BX,depth_frag:HX,distanceRGBA_vert:FX,distanceRGBA_frag:GX,equirect_vert:VX,equirect_frag:kX,linedashed_vert:WX,linedashed_frag:XX,meshbasic_vert:YX,meshbasic_frag:qX,meshlambert_vert:jX,meshlambert_frag:ZX,meshmatcap_vert:KX,meshmatcap_frag:QX,meshnormal_vert:JX,meshnormal_frag:$X,meshphong_vert:eY,meshphong_frag:tY,meshphysical_vert:nY,meshphysical_frag:iY,meshtoon_vert:aY,meshtoon_frag:rY,points_vert:sY,points_frag:oY,shadow_vert:lY,shadow_frag:cY,sprite_vert:uY,sprite_frag:hY},at={common:{diffuse:{value:new je(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Et},alphaMap:{value:null},alphaMapTransform:{value:new Et},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Et}},envmap:{envMap:{value:null},envMapRotation:{value:new Et},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Et}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Et}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Et},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Et},normalScale:{value:new de(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Et},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Et}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Et}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Et}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new je(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new je(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Et},alphaTest:{value:0},uvTransform:{value:new Et}},sprite:{diffuse:{value:new je(16777215)},opacity:{value:1},center:{value:new de(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Et},alphaMap:{value:null},alphaMapTransform:{value:new Et},alphaTest:{value:0}}},Ms={basic:{uniforms:Aa([at.common,at.specularmap,at.envmap,at.aomap,at.lightmap,at.fog]),vertexShader:Qt.meshbasic_vert,fragmentShader:Qt.meshbasic_frag},lambert:{uniforms:Aa([at.common,at.specularmap,at.envmap,at.aomap,at.lightmap,at.emissivemap,at.bumpmap,at.normalmap,at.displacementmap,at.fog,at.lights,{emissive:{value:new je(0)}}]),vertexShader:Qt.meshlambert_vert,fragmentShader:Qt.meshlambert_frag},phong:{uniforms:Aa([at.common,at.specularmap,at.envmap,at.aomap,at.lightmap,at.emissivemap,at.bumpmap,at.normalmap,at.displacementmap,at.fog,at.lights,{emissive:{value:new je(0)},specular:{value:new je(1118481)},shininess:{value:30}}]),vertexShader:Qt.meshphong_vert,fragmentShader:Qt.meshphong_frag},standard:{uniforms:Aa([at.common,at.envmap,at.aomap,at.lightmap,at.emissivemap,at.bumpmap,at.normalmap,at.displacementmap,at.roughnessmap,at.metalnessmap,at.fog,at.lights,{emissive:{value:new je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag},toon:{uniforms:Aa([at.common,at.aomap,at.lightmap,at.emissivemap,at.bumpmap,at.normalmap,at.displacementmap,at.gradientmap,at.fog,at.lights,{emissive:{value:new je(0)}}]),vertexShader:Qt.meshtoon_vert,fragmentShader:Qt.meshtoon_frag},matcap:{uniforms:Aa([at.common,at.bumpmap,at.normalmap,at.displacementmap,at.fog,{matcap:{value:null}}]),vertexShader:Qt.meshmatcap_vert,fragmentShader:Qt.meshmatcap_frag},points:{uniforms:Aa([at.points,at.fog]),vertexShader:Qt.points_vert,fragmentShader:Qt.points_frag},dashed:{uniforms:Aa([at.common,at.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qt.linedashed_vert,fragmentShader:Qt.linedashed_frag},depth:{uniforms:Aa([at.common,at.displacementmap]),vertexShader:Qt.depth_vert,fragmentShader:Qt.depth_frag},normal:{uniforms:Aa([at.common,at.bumpmap,at.normalmap,at.displacementmap,{opacity:{value:1}}]),vertexShader:Qt.meshnormal_vert,fragmentShader:Qt.meshnormal_frag},sprite:{uniforms:Aa([at.sprite,at.fog]),vertexShader:Qt.sprite_vert,fragmentShader:Qt.sprite_frag},background:{uniforms:{uvTransform:{value:new Et},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qt.background_vert,fragmentShader:Qt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Et}},vertexShader:Qt.backgroundCube_vert,fragmentShader:Qt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qt.cube_vert,fragmentShader:Qt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qt.equirect_vert,fragmentShader:Qt.equirect_frag},distanceRGBA:{uniforms:Aa([at.common,at.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qt.distanceRGBA_vert,fragmentShader:Qt.distanceRGBA_frag},shadow:{uniforms:Aa([at.lights,at.fog,{color:{value:new je(0)},opacity:{value:1}}]),vertexShader:Qt.shadow_vert,fragmentShader:Qt.shadow_frag}};Ms.physical={uniforms:Aa([Ms.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Et},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Et},clearcoatNormalScale:{value:new de(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Et},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Et},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Et},sheen:{value:0},sheenColor:{value:new je(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Et},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Et},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Et},transmissionSamplerSize:{value:new de},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Et},attenuationDistance:{value:0},attenuationColor:{value:new je(0)},specularColor:{value:new je(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Et},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Et},anisotropyVector:{value:new de},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Et}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag};const Ov={r:0,b:0,g:0},au=new Ui,fY=new ke;function dY(n,e,t,i,a,r,s){const o=new je(0);let c=r===!0?0:1,h,f,d=null,m=0,g=null;function x(E){let b=E.isScene===!0?E.background:null;return b&&b.isTexture&&(b=(E.backgroundBlurriness>0?t:e).get(b)),b}function T(E){let b=!1;const D=x(E);D===null?v(o,c):D&&D.isColor&&(v(D,1),b=!0);const C=n.xr.getEnvironmentBlendMode();C==="additive"?i.buffers.color.setClear(0,0,0,1,s):C==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,s),(n.autoClear||b)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function S(E,b){const D=x(b);D&&(D.isCubeTexture||D.mapping===kd)?(f===void 0&&(f=new si(new oh(1,1,1),new Fi({name:"BackgroundCubeMaterial",uniforms:bd(Ms.backgroundCube.uniforms),vertexShader:Ms.backgroundCube.vertexShader,fragmentShader:Ms.backgroundCube.fragmentShader,side:Oi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),f.geometry.deleteAttribute("normal"),f.geometry.deleteAttribute("uv"),f.onBeforeRender=function(C,I,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(f.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(f)),au.copy(b.backgroundRotation),au.x*=-1,au.y*=-1,au.z*=-1,D.isCubeTexture&&D.isRenderTargetTexture===!1&&(au.y*=-1,au.z*=-1),f.material.uniforms.envMap.value=D,f.material.uniforms.flipEnvMap.value=D.isCubeTexture&&D.isRenderTargetTexture===!1?-1:1,f.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,f.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,f.material.uniforms.backgroundRotation.value.setFromMatrix4(fY.makeRotationFromEuler(au)),f.material.toneMapped=rn.getTransfer(D.colorSpace)!==Rn,(d!==D||m!==D.version||g!==n.toneMapping)&&(f.material.needsUpdate=!0,d=D,m=D.version,g=n.toneMapping),f.layers.enableAll(),E.unshift(f,f.geometry,f.material,0,0,null)):D&&D.isTexture&&(h===void 0&&(h=new si(new lh(2,2),new Fi({name:"BackgroundMaterial",uniforms:bd(Ms.background.uniforms),vertexShader:Ms.background.vertexShader,fragmentShader:Ms.background.fragmentShader,side:Cs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(h)),h.material.uniforms.t2D.value=D,h.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,h.material.toneMapped=rn.getTransfer(D.colorSpace)!==Rn,D.matrixAutoUpdate===!0&&D.updateMatrix(),h.material.uniforms.uvTransform.value.copy(D.matrix),(d!==D||m!==D.version||g!==n.toneMapping)&&(h.material.needsUpdate=!0,d=D,m=D.version,g=n.toneMapping),h.layers.enableAll(),E.unshift(h,h.geometry,h.material,0,0,null))}function v(E,b){E.getRGB(Ov,HU(n)),i.buffers.color.setClear(Ov.r,Ov.g,Ov.b,b,s)}function y(){f!==void 0&&(f.geometry.dispose(),f.material.dispose(),f=void 0),h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}return{getClearColor:function(){return o},setClearColor:function(E,b=1){o.set(E),c=b,v(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(E){c=E,v(o,c)},render:T,addToRenderList:S,dispose:y}}function pY(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},a=m(null);let r=a,s=!1;function o(R,B,j,ee,se){let re=!1;const W=d(ee,j,B);r!==W&&(r=W,h(r.object)),re=g(R,ee,j,se),re&&x(R,ee,j,se),se!==null&&e.update(se,n.ELEMENT_ARRAY_BUFFER),(re||s)&&(s=!1,b(R,B,j,ee),se!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(se).buffer))}function c(){return n.createVertexArray()}function h(R){return n.bindVertexArray(R)}function f(R){return n.deleteVertexArray(R)}function d(R,B,j){const ee=j.wireframe===!0;let se=i[R.id];se===void 0&&(se={},i[R.id]=se);let re=se[B.id];re===void 0&&(re={},se[B.id]=re);let W=re[ee];return W===void 0&&(W=m(c()),re[ee]=W),W}function m(R){const B=[],j=[],ee=[];for(let se=0;se<t;se++)B[se]=0,j[se]=0,ee[se]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:j,attributeDivisors:ee,object:R,attributes:{},index:null}}function g(R,B,j,ee){const se=r.attributes,re=B.attributes;let W=0;const te=j.getAttributes();for(const K in te)if(te[K].location>=0){const ie=se[K];let Ce=re[K];if(Ce===void 0&&(K==="instanceMatrix"&&R.instanceMatrix&&(Ce=R.instanceMatrix),K==="instanceColor"&&R.instanceColor&&(Ce=R.instanceColor)),ie===void 0||ie.attribute!==Ce||Ce&&ie.data!==Ce.data)return!0;W++}return r.attributesNum!==W||r.index!==ee}function x(R,B,j,ee){const se={},re=B.attributes;let W=0;const te=j.getAttributes();for(const K in te)if(te[K].location>=0){let ie=re[K];ie===void 0&&(K==="instanceMatrix"&&R.instanceMatrix&&(ie=R.instanceMatrix),K==="instanceColor"&&R.instanceColor&&(ie=R.instanceColor));const Ce={};Ce.attribute=ie,ie&&ie.data&&(Ce.data=ie.data),se[K]=Ce,W++}r.attributes=se,r.attributesNum=W,r.index=ee}function T(){const R=r.newAttributes;for(let B=0,j=R.length;B<j;B++)R[B]=0}function S(R){v(R,0)}function v(R,B){const j=r.newAttributes,ee=r.enabledAttributes,se=r.attributeDivisors;j[R]=1,ee[R]===0&&(n.enableVertexAttribArray(R),ee[R]=1),se[R]!==B&&(n.vertexAttribDivisor(R,B),se[R]=B)}function y(){const R=r.newAttributes,B=r.enabledAttributes;for(let j=0,ee=B.length;j<ee;j++)B[j]!==R[j]&&(n.disableVertexAttribArray(j),B[j]=0)}function E(R,B,j,ee,se,re,W){W===!0?n.vertexAttribIPointer(R,B,j,se,re):n.vertexAttribPointer(R,B,j,ee,se,re)}function b(R,B,j,ee){T();const se=ee.attributes,re=j.getAttributes(),W=B.defaultAttributeValues;for(const te in re){const K=re[te];if(K.location>=0){let oe=se[te];if(oe===void 0&&(te==="instanceMatrix"&&R.instanceMatrix&&(oe=R.instanceMatrix),te==="instanceColor"&&R.instanceColor&&(oe=R.instanceColor)),oe!==void 0){const ie=oe.normalized,Ce=oe.itemSize,Xe=e.get(oe);if(Xe===void 0)continue;const nt=Xe.buffer,tt=Xe.type,gt=Xe.bytesPerElement,ge=tt===n.INT||tt===n.UNSIGNED_INT||oe.gpuType===D0;if(oe.isInterleavedBufferAttribute){const Ae=oe.data,Ze=Ae.stride,ue=oe.offset;if(Ae.isInstancedInterleavedBuffer){for(let it=0;it<K.locationSize;it++)v(K.location+it,Ae.meshPerAttribute);R.isInstancedMesh!==!0&&ee._maxInstanceCount===void 0&&(ee._maxInstanceCount=Ae.meshPerAttribute*Ae.count)}else for(let it=0;it<K.locationSize;it++)S(K.location+it);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let it=0;it<K.locationSize;it++)E(K.location+it,Ce/K.locationSize,tt,ie,Ze*gt,(ue+Ce/K.locationSize*it)*gt,ge)}else{if(oe.isInstancedBufferAttribute){for(let Ae=0;Ae<K.locationSize;Ae++)v(K.location+Ae,oe.meshPerAttribute);R.isInstancedMesh!==!0&&ee._maxInstanceCount===void 0&&(ee._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Ae=0;Ae<K.locationSize;Ae++)S(K.location+Ae);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let Ae=0;Ae<K.locationSize;Ae++)E(K.location+Ae,Ce/K.locationSize,tt,ie,Ce*gt,Ce/K.locationSize*Ae*gt,ge)}}else if(W!==void 0){const ie=W[te];if(ie!==void 0)switch(ie.length){case 2:n.vertexAttrib2fv(K.location,ie);break;case 3:n.vertexAttrib3fv(K.location,ie);break;case 4:n.vertexAttrib4fv(K.location,ie);break;default:n.vertexAttrib1fv(K.location,ie)}}}}y()}function D(){P();for(const R in i){const B=i[R];for(const j in B){const ee=B[j];for(const se in ee)f(ee[se].object),delete ee[se];delete B[j]}delete i[R]}}function C(R){if(i[R.id]===void 0)return;const B=i[R.id];for(const j in B){const ee=B[j];for(const se in ee)f(ee[se].object),delete ee[se];delete B[j]}delete i[R.id]}function I(R){for(const B in i){const j=i[B];if(j[R.id]===void 0)continue;const ee=j[R.id];for(const se in ee)f(ee[se].object),delete ee[se];delete j[R.id]}}function P(){O(),s=!0,r!==a&&(r=a,h(r.object))}function O(){a.geometry=null,a.program=null,a.wireframe=!1}return{setup:o,reset:P,resetDefaultState:O,dispose:D,releaseStatesOfGeometry:C,releaseStatesOfProgram:I,initAttributes:T,enableAttribute:S,disableUnusedAttributes:y}}function mY(n,e,t){let i;function a(h){i=h}function r(h,f){n.drawArrays(i,h,f),t.update(f,i,1)}function s(h,f,d){d!==0&&(n.drawArraysInstanced(i,h,f,d),t.update(f,i,d))}function o(h,f,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,h,0,f,0,d);let g=0;for(let x=0;x<d;x++)g+=f[x];t.update(g,i,1)}function c(h,f,d,m){if(d===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let x=0;x<h.length;x++)s(h[x],f[x],m[x]);else{g.multiDrawArraysInstancedWEBGL(i,h,0,f,0,m,0,d);let x=0;for(let T=0;T<d;T++)x+=f[T]*m[T];t.update(x,i,1)}}this.setMode=a,this.render=r,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function gY(n,e,t,i){let a;function r(){if(a!==void 0)return a;if(e.has("EXT_texture_filter_anisotropic")===!0){const I=e.get("EXT_texture_filter_anisotropic");a=n.getParameter(I.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else a=0;return a}function s(I){return!(I!==Jn&&i.convert(I)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(I){const P=I===Xn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(I!==Ii&&i.convert(I)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&I!==ri&&!P)}function c(I){if(I==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";I="mediump"}return I==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const f=c(h);f!==h&&(ut("WebGLRenderer:",h,"not supported, using",f,"instead."),h=f);const d=t.logarithmicDepthBuffer===!0,m=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),g=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=n.getParameter(n.MAX_TEXTURE_SIZE),S=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),v=n.getParameter(n.MAX_VERTEX_ATTRIBS),y=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),b=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),D=x>0,C=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:o,precision:h,logarithmicDepthBuffer:d,reversedDepthBuffer:m,maxTextures:g,maxVertexTextures:x,maxTextureSize:T,maxCubemapSize:S,maxAttributes:v,maxVertexUniforms:y,maxVaryings:E,maxFragmentUniforms:b,vertexTextures:D,maxSamples:C}}function vY(n){const e=this;let t=null,i=0,a=!1,r=!1;const s=new Fo,o=new Et,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,m){const g=d.length!==0||m||i!==0||a;return a=m,i=d.length,g},this.beginShadows=function(){r=!0,f(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,m){t=f(d,m,0)},this.setState=function(d,m,g){const x=d.clippingPlanes,T=d.clipIntersection,S=d.clipShadows,v=n.get(d);if(!a||x===null||x.length===0||r&&!S)r?f(null):h();else{const y=r?0:i,E=y*4;let b=v.clippingState||null;c.value=b,b=f(x,m,E,g);for(let D=0;D!==E;++D)b[D]=t[D];v.clippingState=b,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=y}};function h(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function f(d,m,g,x){const T=d!==null?d.length:0;let S=null;if(T!==0){if(S=c.value,x!==!0||S===null){const v=g+T*4,y=m.matrixWorldInverse;o.getNormalMatrix(y),(S===null||S.length<v)&&(S=new Float32Array(v));for(let E=0,b=g;E!==T;++E,b+=4)s.copy(d[E]).applyMatrix4(y,o),s.normal.toArray(S,b),S[b+3]=s.constant}c.value=S,c.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,S}}function _Y(n){let e=new WeakMap;function t(s,o){return o===a0?s.mapping=al:o===r0&&(s.mapping=dc),s}function i(s){if(s&&s.isTexture){const o=s.mapping;if(o===a0||o===r0)if(e.has(s)){const c=e.get(s).texture;return t(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const h=new GU(c.height);return h.fromEquirectangularTexture(n,s),e.set(s,h),s.addEventListener("dispose",a),t(h.texture,s.mapping)}else return null}}return s}function a(s){const o=s.target;o.removeEventListener("dispose",a);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}const Kl=4,dN=[.125,.215,.35,.446,.526,.582],_u=20,xY=256,kp=new io,pN=new je;let l2=null,c2=0,u2=0,h2=!1;const yY=new L;class dE{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,a=100,r={}){const{size:s=256,position:o=yY}=r;l2=this._renderer.getRenderTarget(),c2=this._renderer.getActiveCubeFace(),u2=this._renderer.getActiveMipmapLevel(),h2=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,i,a,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=vN(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=gN(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(l2,c2,u2),this._renderer.xr.enabled=h2,e.scissorTest=!1,uf(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===al||e.mapping===dc?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),l2=this._renderer.getRenderTarget(),c2=this._renderer.getActiveCubeFace(),u2=this._renderer.getActiveMipmapLevel(),h2=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Ht,minFilter:Ht,generateMipmaps:!1,type:Xn,format:Jn,colorSpace:Wn,depthBuffer:!1},a=mN(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=mN(e,t,i);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=SY(r)),this._blurMaterial=EY(r,e,t),this._ggxMaterial=TY(r,e,t)}return a}_compileMaterial(e){const t=new si(new wt,e);this._renderer.compile(t,kp)}_sceneToCubeUV(e,t,i,a,r){const c=new ui(90,1,t,i),h=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],d=this._renderer,m=d.autoClear,g=d.toneMapping;d.getClearColor(pN),d.toneMapping=ns,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(a),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new si(new oh,new La({name:"PMREM.Background",side:Oi,depthWrite:!1,depthTest:!1})));const T=this._backgroundBox,S=T.material;let v=!1;const y=e.background;y?y.isColor&&(S.color.copy(y),e.background=null,v=!0):(S.color.copy(pN),v=!0);for(let E=0;E<6;E++){const b=E%3;b===0?(c.up.set(0,h[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+f[E],r.y,r.z)):b===1?(c.up.set(0,0,h[E]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+f[E],r.z)):(c.up.set(0,h[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+f[E]));const D=this._cubeSize;uf(a,b*D,E>2?D:0,D,D),d.setRenderTarget(a),v&&d.render(T,c),d.render(e,c)}d.toneMapping=g,d.autoClear=m,e.background=y}_textureToCubeUV(e,t){const i=this._renderer,a=e.mapping===al||e.mapping===dc;a?(this._cubemapMaterial===null&&(this._cubemapMaterial=vN()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=gN());const r=a?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;uf(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(s,kp)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const a=this._lodMeshes.length;for(let r=1;r<a;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=i}_applyGGXFilter(e,t,i){const a=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;const c=s.uniforms,h=i/(this._lodMeshes.length-1),f=t/(this._lodMeshes.length-1),d=Math.sqrt(h*h-f*f),m=.05+h*.95,g=d*m,{_lodMax:x}=this,T=this._sizeLods[i],S=3*T*(i>x-Kl?i-x+Kl:0),v=4*(this._cubeSize-T);c.envMap.value=e.texture,c.roughness.value=g,c.mipInt.value=x-t,uf(r,S,v,3*T,2*T),a.setRenderTarget(r),a.render(o,kp),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=x-i,uf(e,S,v,3*T,2*T),a.setRenderTarget(e),a.render(o,kp)}_blur(e,t,i,a,r){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,a,"latitudinal",r),this._halfBlur(s,e,i,i,a,"longitudinal",r)}_halfBlur(e,t,i,a,r,s,o){const c=this._renderer,h=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&Bt("blur direction must be either latitudinal or longitudinal!");const f=3,d=this._lodMeshes[a];d.material=h;const m=h.uniforms,g=this._sizeLods[i]-1,x=isFinite(r)?Math.PI/(2*g):2*Math.PI/(2*_u-1),T=r/x,S=isFinite(r)?1+Math.floor(f*T):_u;S>_u&&ut(`sigmaRadians, ${r}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${_u}`);const v=[];let y=0;for(let I=0;I<_u;++I){const P=I/T,O=Math.exp(-P*P/2);v.push(O),I===0?y+=O:I<S&&(y+=2*O)}for(let I=0;I<v.length;I++)v[I]=v[I]/y;m.envMap.value=e.texture,m.samples.value=S,m.weights.value=v,m.latitudinal.value=s==="latitudinal",o&&(m.poleAxis.value=o);const{_lodMax:E}=this;m.dTheta.value=x,m.mipInt.value=E-i;const b=this._sizeLods[a],D=3*b*(a>E-Kl?a-E+Kl:0),C=4*(this._cubeSize-b);uf(t,D,C,3*b,2*b),c.setRenderTarget(t),c.render(d,kp)}}function SY(n){const e=[],t=[],i=[];let a=n;const r=n-Kl+1+dN.length;for(let s=0;s<r;s++){const o=Math.pow(2,a);e.push(o);let c=1/o;s>n-Kl?c=dN[s-n+Kl-1]:s===0&&(c=0),t.push(c);const h=1/(o-2),f=-h,d=1+h,m=[f,f,d,f,d,d,f,f,d,d,f,d],g=6,x=6,T=3,S=2,v=1,y=new Float32Array(T*x*g),E=new Float32Array(S*x*g),b=new Float32Array(v*x*g);for(let C=0;C<g;C++){const I=C%3*2/3-1,P=C>2?0:-1,O=[I,P,0,I+2/3,P,0,I+2/3,P+1,0,I,P,0,I+2/3,P+1,0,I,P+1,0];y.set(O,T*x*C),E.set(m,S*x*C);const R=[C,C,C,C,C,C];b.set(R,v*x*C)}const D=new wt;D.setAttribute("position",new Ot(y,T)),D.setAttribute("uv",new Ot(E,S)),D.setAttribute("faceIndex",new Ot(b,v)),i.push(new si(D,null)),a>Kl&&a--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function mN(n,e,t){const i=new _i(n,e,t);return i.texture.mapping=kd,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function uf(n,e,t,i,a){n.viewport.set(e,t,i,a),n.scissor.set(e,t,i,a)}function TY(n,e,t){return new Fi({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:xY,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:iy(),fragmentShader:`
precision highp float;
precision highp int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform float roughness;
uniform float mipInt;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
#define PI 3.14159265359
// Van der Corput radical inverse
float radicalInverse_VdC(uint bits) {
bits = (bits << 16u) | (bits >> 16u);
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
}
// Hammersley sequence
vec2 hammersley(uint i, uint N) {
return vec2(float(i) / float(N), radicalInverse_VdC(i));
}
// GGX VNDF importance sampling (Eric Heitz 2018)
// "Sampling the GGX Distribution of Visible Normals"
// https://jcgt.org/published/0007/04/01/
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
float alpha = roughness * roughness;
// Section 3.2: Transform view direction to hemisphere configuration
vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
// Section 4.1: Orthonormal basis
float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(Vh, T1);
// Section 4.2: Parameterization of projected area
float r = sqrt(Xi.x);
float phi = 2.0 * PI * Xi.y;
float t1 = r * cos(phi);
float t2 = r * sin(phi);
float s = 0.5 * (1.0 + Vh.z);
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
// Section 4.3: Reprojection onto hemisphere
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
// Section 3.4: Transform back to ellipsoid configuration
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
}
void main() {
vec3 N = normalize(vOutputDirection);
vec3 V = N; // Assume view direction equals normal for pre-filtering
vec3 prefilteredColor = vec3(0.0);
float totalWeight = 0.0;
// For very low roughness, just sample the environment directly
if (roughness < 0.001) {
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
return;
}
// Tangent space basis for VNDF sampling
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(up, N));
vec3 bitangent = cross(N, tangent);
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
// Transform H back to world space
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
vec3 L = normalize(2.0 * dot(V, H) * H - V);
float NdotL = max(dot(N, L), 0.0);
if(NdotL > 0.0) {
// Sample environment at fixed mip level
// VNDF importance sampling handles the distribution filtering
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
// Weight by NdotL for the split-sum approximation
// VNDF PDF naturally accounts for the visible microfacet distribution
prefilteredColor += sampleColor * NdotL;
totalWeight += NdotL;
}
}
if (totalWeight > 0.0) {
prefilteredColor = prefilteredColor / totalWeight;
}
gl_FragColor = vec4(prefilteredColor, 1.0);
}
`,blending:Sa,depthTest:!1,depthWrite:!1})}function EY(n,e,t){const i=new Float32Array(_u),a=new L(0,1,0);return new Fi({name:"SphericalGaussianBlur",defines:{n:_u,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:iy(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform int samples;
uniform float weights[ n ];
uniform bool latitudinal;
uniform float dTheta;
uniform float mipInt;
uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
vec3 getSample( float theta, vec3 axis ) {
float cosTheta = cos( theta );
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross( axis, vOutputDirection ) * sin( theta )
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
return bilinearCubeUV( envMap, sampleDirection, mipInt );
}
void main() {
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
}
axis = normalize( axis );
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
for ( int i = 1; i < n; i++ ) {
if ( i >= samples ) {
break;
}
float theta = dTheta * float( i );
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
}
}
`,blending:Sa,depthTest:!1,depthWrite:!1})}function gN(){return new Fi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:iy(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
#include <common>
void main() {
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
`,blending:Sa,depthTest:!1,depthWrite:!1})}function vN(){return new Fi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:iy(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:Sa,depthTest:!1,depthWrite:!1})}function iy(){return`
precision mediump float;
precision mediump int;
attribute float faceIndex;
varying vec3 vOutputDirection;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection( vec2 uv, float face ) {
uv = 2.0 * uv - 1.0;
vec3 direction = vec3( uv, 1.0 );
if ( face == 0.0 ) {
direction = direction.zyx; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction.xzy;
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction.x *= -1.0; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction.zyx;
direction.xz *= -1.0; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction.xzy;
direction.xy *= -1.0; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction.z *= -1.0; // ( u, v, -1 ) neg z
}
return direction;
}
void main() {
vOutputDirection = getDirection( uv, faceIndex );
gl_Position = vec4( position, 1.0 );
}
`}function MY(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const c=o.mapping,h=c===a0||c===r0,f=c===al||c===dc;if(h||f){let d=e.get(o);const m=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==m)return t===null&&(t=new dE(n)),d=h?t.fromEquirectangular(o,d):t.fromCubemap(o,d),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),d.texture;if(d!==void 0)return d.texture;{const g=o.image;return h&&g&&g.height>0||f&&g&&a(g)?(t===null&&(t=new dE(n)),d=h?t.fromEquirectangular(o):t.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),o.addEventListener("dispose",r),d.texture):null}}}return o}function a(o){let c=0;const h=6;for(let f=0;f<h;f++)o[f]!==void 0&&c++;return c===h}function r(o){const c=o.target;c.removeEventListener("dispose",r);const h=e.get(c);h!==void 0&&(e.delete(c),h.dispose())}function s(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:s}}function bY(n){const e={};function t(i){if(e[i]!==void 0)return e[i];const a=n.getExtension(i);return e[i]=a,a}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const a=t(i);return a===null&&Td("WebGLRenderer: "+i+" extension not supported."),a}}}function AY(n,e,t,i){const a={},r=new WeakMap;function s(d){const m=d.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);m.removeEventListener("dispose",s),delete a[m.id];const g=r.get(m);g&&(e.remove(g),r.delete(m)),i.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,t.memory.geometries--}function o(d,m){return a[m.id]===!0||(m.addEventListener("dispose",s),a[m.id]=!0,t.memory.geometries++),m}function c(d){const m=d.attributes;for(const g in m)e.update(m[g],n.ARRAY_BUFFER)}function h(d){const m=[],g=d.index,x=d.attributes.position;let T=0;if(g!==null){const y=g.array;T=g.version;for(let E=0,b=y.length;E<b;E+=3){const D=y[E+0],C=y[E+1],I=y[E+2];m.push(D,C,C,I,I,D)}}else if(x!==void 0){const y=x.array;T=x.version;for(let E=0,b=y.length/3-1;E<b;E+=3){const D=E+0,C=E+1,I=E+2;m.push(D,C,C,I,I,D)}}else return;const S=new(LU(m)?yb:xb)(m,1);S.version=T;const v=r.get(d);v&&e.remove(v),r.set(d,S)}function f(d){const m=r.get(d);if(m){const g=d.index;g!==null&&m.version<g.version&&h(d)}else h(d);return r.get(d)}return{get:o,update:c,getWireframeAttribute:f}}function RY(n,e,t){let i;function a(m){i=m}let r,s;function o(m){r=m.type,s=m.bytesPerElement}function c(m,g){n.drawElements(i,g,r,m*s),t.update(g,i,1)}function h(m,g,x){x!==0&&(n.drawElementsInstanced(i,g,r,m*s,x),t.update(g,i,x))}function f(m,g,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,g,0,r,m,0,x);let S=0;for(let v=0;v<x;v++)S+=g[v];t.update(S,i,1)}function d(m,g,x,T){if(x===0)return;const S=e.get("WEBGL_multi_draw");if(S===null)for(let v=0;v<m.length;v++)h(m[v]/s,g[v],T[v]);else{S.multiDrawElementsInstancedWEBGL(i,g,0,r,m,0,T,0,x);let v=0;for(let y=0;y<x;y++)v+=g[y]*T[y];t.update(v,i,1)}}this.setMode=a,this.setIndex=o,this.render=c,this.renderInstances=h,this.renderMultiDraw=f,this.renderMultiDrawInstances=d}function wY(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,s,o){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=o*(r/3);break;case n.LINES:t.lines+=o*(r/2);break;case n.LINE_STRIP:t.lines+=o*(r-1);break;case n.LINE_LOOP:t.lines+=o*r;break;case n.POINTS:t.points+=o*r;break;default:Bt("WebGLInfo: Unknown draw mode:",s);break}}function a(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:a,update:i}}function CY(n,e,t){const i=new WeakMap,a=new zt;function r(s,o,c){const h=s.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=f!==void 0?f.length:0;let m=i.get(o);if(m===void 0||m.count!==d){let R=function(){P.dispose(),i.delete(o),o.removeEventListener("dispose",R)};var g=R;m!==void 0&&m.texture.dispose();const x=o.morphAttributes.position!==void 0,T=o.morphAttributes.normal!==void 0,S=o.morphAttributes.color!==void 0,v=o.morphAttributes.position||[],y=o.morphAttributes.normal||[],E=o.morphAttributes.color||[];let b=0;x===!0&&(b=1),T===!0&&(b=2),S===!0&&(b=3);let D=o.attributes.position.count*b,C=1;D>e.maxTextureSize&&(C=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const I=new Float32Array(D*C*4*d),P=new U1(I,D,C,d);P.type=ri,P.needsUpdate=!0;const O=b*4;for(let B=0;B<d;B++){const j=v[B],ee=y[B],se=E[B],re=D*C*4*B;for(let W=0;W<j.count;W++){const te=W*O;x===!0&&(a.fromBufferAttribute(j,W),I[re+te+0]=a.x,I[re+te+1]=a.y,I[re+te+2]=a.z,I[re+te+3]=0),T===!0&&(a.fromBufferAttribute(ee,W),I[re+te+4]=a.x,I[re+te+5]=a.y,I[re+te+6]=a.z,I[re+te+7]=0),S===!0&&(a.fromBufferAttribute(se,W),I[re+te+8]=a.x,I[re+te+9]=a.y,I[re+te+10]=a.z,I[re+te+11]=se.itemSize===4?a.w:1)}}m={count:d,texture:P,size:new de(D,C)},i.set(o,m),o.addEventListener("dispose",R)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(n,"morphTexture",s.morphTexture,t);else{let x=0;for(let S=0;S<h.length;S++)x+=h[S];const T=o.morphTargetsRelative?1:1-x;c.getUniforms().setValue(n,"morphTargetBaseInfluence",T),c.getUniforms().setValue(n,"morphTargetInfluences",h)}c.getUniforms().setValue(n,"morphTargetsTexture",m.texture,t),c.getUniforms().setValue(n,"morphTargetsTextureSize",m.size)}return{update:r}}function NY(n,e,t,i){let a=new WeakMap;function r(c){const h=i.render.frame,f=c.geometry,d=e.get(c,f);if(a.get(d)!==h&&(e.update(d),a.set(d,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),a.get(c)!==h&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),a.set(c,h))),c.isSkinnedMesh){const m=c.skeleton;a.get(m)!==h&&(m.update(),a.set(m,h))}return d}function s(){a=new WeakMap}function o(c){const h=c.target;h.removeEventListener("dispose",o),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:r,dispose:s}}const I6=new Nn,_N=new U0(1,1),U6=new U1,P6=new is,z6=new L0,xN=[],yN=[],SN=new Float32Array(16),TN=new Float32Array(9),EN=new Float32Array(4);function Yd(n,e,t){const i=n[0];if(i<=0||i>0)return n;const a=e*t;let r=xN[a];if(r===void 0&&(r=new Float32Array(a),xN[a]=r),e!==0){i.toArray(r,0);for(let s=1,o=0;s!==e;++s)o+=t,n[s].toArray(r,o)}return r}function Gi(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Vi(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function ay(n,e){let t=yN[e];t===void 0&&(t=new Int32Array(e),yN[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function DY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function OY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Gi(t,e))return;n.uniform2fv(this.addr,e),Vi(t,e)}}function LY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Gi(t,e))return;n.uniform3fv(this.addr,e),Vi(t,e)}}function IY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Gi(t,e))return;n.uniform4fv(this.addr,e),Vi(t,e)}}function UY(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Gi(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Vi(t,e)}else{if(Gi(t,i))return;EN.set(i),n.uniformMatrix2fv(this.addr,!1,EN),Vi(t,i)}}function PY(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Gi(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Vi(t,e)}else{if(Gi(t,i))return;TN.set(i),n.uniformMatrix3fv(this.addr,!1,TN),Vi(t,i)}}function zY(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Gi(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Vi(t,e)}else{if(Gi(t,i))return;SN.set(i),n.uniformMatrix4fv(this.addr,!1,SN),Vi(t,i)}}function BY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function HY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Gi(t,e))return;n.uniform2iv(this.addr,e),Vi(t,e)}}function FY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Gi(t,e))return;n.uniform3iv(this.addr,e),Vi(t,e)}}function GY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Gi(t,e))return;n.uniform4iv(this.addr,e),Vi(t,e)}}function VY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function kY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Gi(t,e))return;n.uniform2uiv(this.addr,e),Vi(t,e)}}function WY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Gi(t,e))return;n.uniform3uiv(this.addr,e),Vi(t,e)}}function XY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Gi(t,e))return;n.uniform4uiv(this.addr,e),Vi(t,e)}}function YY(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a);let r;this.type===n.SAMPLER_2D_SHADOW?(_N.compareFunction=gb,r=_N):r=I6,t.setTexture2D(e||r,a)}function qY(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTexture3D(e||P6,a)}function jY(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTextureCube(e||z6,a)}function ZY(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTexture2DArray(e||U6,a)}function KY(n){switch(n){case 5126:return DY;case 35664:return OY;case 35665:return LY;case 35666:return IY;case 35674:return UY;case 35675:return PY;case 35676:return zY;case 5124:case 35670:return BY;case 35667:case 35671:return HY;case 35668:case 35672:return FY;case 35669:case 35673:return GY;case 5125:return VY;case 36294:return kY;case 36295:return WY;case 36296:return XY;case 35678:case 36198:case 36298:case 36306:case 35682:return YY;case 35679:case 36299:case 36307:return qY;case 35680:case 36300:case 36308:case 36293:return jY;case 36289:case 36303:case 36311:case 36292:return ZY}}function QY(n,e){n.uniform1fv(this.addr,e)}function JY(n,e){const t=Yd(e,this.size,2);n.uniform2fv(this.addr,t)}function $Y(n,e){const t=Yd(e,this.size,3);n.uniform3fv(this.addr,t)}function eq(n,e){const t=Yd(e,this.size,4);n.uniform4fv(this.addr,t)}function tq(n,e){const t=Yd(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function nq(n,e){const t=Yd(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function iq(n,e){const t=Yd(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function aq(n,e){n.uniform1iv(this.addr,e)}function rq(n,e){n.uniform2iv(this.addr,e)}function sq(n,e){n.uniform3iv(this.addr,e)}function oq(n,e){n.uniform4iv(this.addr,e)}function lq(n,e){n.uniform1uiv(this.addr,e)}function cq(n,e){n.uniform2uiv(this.addr,e)}function uq(n,e){n.uniform3uiv(this.addr,e)}function hq(n,e){n.uniform4uiv(this.addr,e)}function fq(n,e,t){const i=this.cache,a=e.length,r=ay(t,a);Gi(i,r)||(n.uniform1iv(this.addr,r),Vi(i,r));for(let s=0;s!==a;++s)t.setTexture2D(e[s]||I6,r[s])}function dq(n,e,t){const i=this.cache,a=e.length,r=ay(t,a);Gi(i,r)||(n.uniform1iv(this.addr,r),Vi(i,r));for(let s=0;s!==a;++s)t.setTexture3D(e[s]||P6,r[s])}function pq(n,e,t){const i=this.cache,a=e.length,r=ay(t,a);Gi(i,r)||(n.uniform1iv(this.addr,r),Vi(i,r));for(let s=0;s!==a;++s)t.setTextureCube(e[s]||z6,r[s])}function mq(n,e,t){const i=this.cache,a=e.length,r=ay(t,a);Gi(i,r)||(n.uniform1iv(this.addr,r),Vi(i,r));for(let s=0;s!==a;++s)t.setTexture2DArray(e[s]||U6,r[s])}function gq(n){switch(n){case 5126:return QY;case 35664:return JY;case 35665:return $Y;case 35666:return eq;case 35674:return tq;case 35675:return nq;case 35676:return iq;case 5124:case 35670:return aq;case 35667:case 35671:return rq;case 35668:case 35672:return sq;case 35669:case 35673:return oq;case 5125:return lq;case 36294:return cq;case 36295:return uq;case 36296:return hq;case 35678:case 36198:case 36298:case 36306:case 35682:return fq;case 35679:case 36299:case 36307:return dq;case 35680:case 36300:case 36308:case 36293:return pq;case 36289:case 36303:case 36311:case 36292:return mq}}class vq{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=KY(t.type)}}class _q{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=gq(t.type)}}class xq{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const a=this.seq;for(let r=0,s=a.length;r!==s;++r){const o=a[r];o.setValue(e,t[o.id],i)}}}const f2=/(\w+)(\])?(\[|\.)?/g;function MN(n,e){n.seq.push(e),n.map[e.id]=e}function yq(n,e,t){const i=n.name,a=i.length;for(f2.lastIndex=0;;){const r=f2.exec(i),s=f2.lastIndex;let o=r[1];const c=r[2]==="]",h=r[3];if(c&&(o=o|0),h===void 0||h==="["&&s+2===a){MN(t,h===void 0?new vq(o,n,e):new _q(o,n,e));break}else{let d=t.map[o];d===void 0&&(d=new xq(o),MN(t,d)),t=d}}}class m_{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const r=e.getActiveUniform(t,a),s=e.getUniformLocation(t,r.name);yq(r,s,this)}}setValue(e,t,i,a){const r=this.map[t];r!==void 0&&r.setValue(e,i,a)}setOptional(e,t,i){const a=t[i];a!==void 0&&this.setValue(e,i,a)}static upload(e,t,i,a){for(let r=0,s=t.length;r!==s;++r){const o=t[r],c=i[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,a)}}static seqWithValue(e,t){const i=[];for(let a=0,r=e.length;a!==r;++a){const s=e[a];s.id in t&&i.push(s)}return i}}function bN(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const Sq=37297;let Tq=0;function Eq(n,e){const t=n.split(`
`),i=[],a=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let s=a;s<r;s++){const o=s+1;i.push(`${o===e?">":" "} ${o}: ${t[s]}`)}return i.join(`
`)}const AN=new Et;function Mq(n){rn._getMatrix(AN,rn.workingColorSpace,n);const e=`mat3( ${AN.elements.map(t=>t.toFixed(4))} )`;switch(rn.getTransfer(n)){case o0:return[e,"LinearTransferOETF"];case Rn:return[e,"sRGBTransferOETF"];default:return ut("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function RN(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return t.toUpperCase()+`
`+r+`
`+Eq(n.getShaderSource(e),o)}else return r}function bq(n,e){const t=Mq(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function Aq(n,e){let t;switch(e){case hU:t="Linear";break;case fU:t="Reinhard";break;case dU:t="Cineon";break;case cb:t="ACESFilmic";break;case mU:t="AgX";break;case gU:t="Neutral";break;case pU:t="Custom";break;default:ut("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Lv=new L;function Rq(){rn.getLuminanceCoefficients(Lv);const n=Lv.x.toFixed(4),e=Lv.y.toFixed(4),t=Lv.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function wq(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(cm).join(`
`)}function Cq(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function Nq(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let a=0;a<i;a++){const r=n.getActiveAttrib(e,a),s=r.name;let o=1;r.type===n.FLOAT_MAT2&&(o=2),r.type===n.FLOAT_MAT3&&(o=3),r.type===n.FLOAT_MAT4&&(o=4),t[s]={type:r.type,location:n.getAttribLocation(e,s),locationSize:o}}return t}function cm(n){return n!==""}function wN(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function CN(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Dq=/^[ \t]*#include +<([\w\d./]+)>/gm;function pE(n){return n.replace(Dq,Lq)}const Oq=new Map;function Lq(n,e){let t=Qt[e];if(t===void 0){const i=Oq.get(e);if(i!==void 0)t=Qt[i],ut('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return pE(t)}const Iq=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function NN(n){return n.replace(Iq,Uq)}function Uq(n,e,t,i){let a="";for(let r=parseInt(e);r<parseInt(t);r++)a+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return a}function DN(n){let e=`precision ${n.precision} float;
precision ${n.precision} int;
precision ${n.precision} sampler2D;
precision ${n.precision} samplerCube;
precision ${n.precision} sampler3D;
precision ${n.precision} sampler2DArray;
precision ${n.precision} sampler2DShadow;
precision ${n.precision} samplerCubeShadow;
precision ${n.precision} sampler2DArrayShadow;
precision ${n.precision} isampler2D;
precision ${n.precision} isampler3D;
precision ${n.precision} isamplerCube;
precision ${n.precision} isampler2DArray;
precision ${n.precision} usampler2D;
precision ${n.precision} usampler3D;
precision ${n.precision} usamplerCube;
precision ${n.precision} usampler2DArray;
`;return n.precision==="highp"?e+=`
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function Pq(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===b1?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Cm?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===ys&&(e="SHADOWMAP_TYPE_VSM"),e}function zq(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case al:case dc:e="ENVMAP_TYPE_CUBE";break;case kd:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Bq(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case dc:e="ENVMAP_MODE_REFRACTION";break}return e}function Hq(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case N0:e="ENVMAP_BLENDING_MULTIPLY";break;case cU:e="ENVMAP_BLENDING_MIX";break;case uU:e="ENVMAP_BLENDING_ADD";break}return e}function Fq(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function Gq(n,e,t,i){const a=n.getContext(),r=t.defines;let s=t.vertexShader,o=t.fragmentShader;const c=Pq(t),h=zq(t),f=Bq(t),d=Hq(t),m=Fq(t),g=wq(t),x=Cq(r),T=a.createProgram();let S,v,y=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(S=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(cm).join(`
`),S.length>0&&(S+=`
`),v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(cm).join(`
`),v.length>0&&(v+=`
`)):(S=[DN(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(cm).join(`
`),v=[DN(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+f:"",t.envMap?"#define "+d:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ns?"#define TONE_MAPPING":"",t.toneMapping!==ns?Qt.tonemapping_pars_fragment:"",t.toneMapping!==ns?Aq("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Qt.colorspace_pars_fragment,bq("linearToOutputTexel",t.outputColorSpace),Rq(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(cm).join(`
`)),s=pE(s),s=wN(s,t),s=CN(s,t),o=pE(o),o=wN(o,t),o=CN(o,t),s=NN(s),o=NN(o),t.isRawShaderMaterial!==!0&&(y=`#version 300 es
`,S=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+S,v=["#define varying in",t.glslVersion===ao?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ao?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+v);const E=y+S+s,b=y+v+o,D=bN(a,a.VERTEX_SHADER,E),C=bN(a,a.FRAGMENT_SHADER,b);a.attachShader(T,D),a.attachShader(T,C),t.index0AttributeName!==void 0?a.bindAttribLocation(T,0,t.index0AttributeName):t.morphTargets===!0&&a.bindAttribLocation(T,0,"position"),a.linkProgram(T);function I(B){if(n.debug.checkShaderErrors){const j=a.getProgramInfoLog(T)||"",ee=a.getShaderInfoLog(D)||"",se=a.getShaderInfoLog(C)||"",re=j.trim(),W=ee.trim(),te=se.trim();let K=!0,oe=!0;if(a.getProgramParameter(T,a.LINK_STATUS)===!1)if(K=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(a,T,D,C);else{const ie=RN(a,D,"vertex"),Ce=RN(a,C,"fragment");Bt("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(T,a.VALIDATE_STATUS)+`
Material Name: `+B.name+`
Material Type: `+B.type+`
Program Info Log: `+re+`
`+ie+`
`+Ce)}else re!==""?ut("WebGLProgram: Program Info Log:",re):(W===""||te==="")&&(oe=!1);oe&&(B.diagnostics={runnable:K,programLog:re,vertexShader:{log:W,prefix:S},fragmentShader:{log:te,prefix:v}})}a.deleteShader(D),a.deleteShader(C),P=new m_(a,T),O=Nq(a,T)}let P;this.getUniforms=function(){return P===void 0&&I(this),P};let O;this.getAttributes=function(){return O===void 0&&I(this),O};let R=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=a.getProgramParameter(T,Sq)),R},this.destroy=function(){i.releaseStatesOfProgram(this),a.deleteProgram(T),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Tq++,this.cacheKey=e,this.usedTimes=1,this.program=T,this.vertexShader=D,this.fragmentShader=C,this}let Vq=0;class kq{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,a=this._getShaderStage(t),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(a)===!1&&(s.add(a),a.usedTimes++),s.has(r)===!1&&(s.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new Wq(e),t.set(e,i)),i}}class Wq{constructor(e){this.id=Vq++,this.code=e,this.usedTimes=0}}function Xq(n,e,t,i,a,r,s){const o=new Md,c=new kq,h=new Set,f=[],d=a.logarithmicDepthBuffer,m=a.vertexTextures;let g=a.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function T(O){return h.add(O),O===0?"uv":`uv${O}`}function S(O,R,B,j,ee){const se=j.fog,re=ee.geometry,W=O.isMeshStandardMaterial?j.environment:null,te=(O.isMeshStandardMaterial?t:e).get(O.envMap||W),K=te&&te.mapping===kd?te.image.height:null,oe=x[O.type];O.precision!==null&&(g=a.getMaxPrecision(O.precision),g!==O.precision&&ut("WebGLProgram.getParameters:",O.precision,"not supported, using",g,"instead."));const ie=re.morphAttributes.position||re.morphAttributes.normal||re.morphAttributes.color,Ce=ie!==void 0?ie.length:0;let Xe=0;re.morphAttributes.position!==void 0&&(Xe=1),re.morphAttributes.normal!==void 0&&(Xe=2),re.morphAttributes.color!==void 0&&(Xe=3);let nt,tt,gt,ge;if(oe){const Vt=Ms[oe];nt=Vt.vertexShader,tt=Vt.fragmentShader}else nt=O.vertexShader,tt=O.fragmentShader,c.update(O),gt=c.getVertexShaderID(O),ge=c.getFragmentShaderID(O);const Ae=n.getRenderTarget(),Ze=n.state.buffers.depth.getReversed(),ue=ee.isInstancedMesh===!0,it=ee.isBatchedMesh===!0,Mt=!!O.map,ot=!!O.matcap,Ke=!!te,Te=!!O.aoMap,G=!!O.lightMap,Me=!!O.bumpMap,De=!!O.normalMap,Fe=!!O.displacementMap,Be=!!O.emissiveMap,$e=!!O.metalnessMap,Je=!!O.roughnessMap,ct=O.anisotropy>0,k=O.clearcoat>0,U=O.dispersion>0,ce=O.iridescence>0,Ee=O.sheen>0,Le=O.transmission>0,ye=ct&&!!O.anisotropyMap,vt=k&&!!O.clearcoatMap,qe=k&&!!O.clearcoatNormalMap,_t=k&&!!O.clearcoatRoughnessMap,pt=ce&&!!O.iridescenceMap,Ie=ce&&!!O.iridescenceThicknessMap,He=Ee&&!!O.sheenColorMap,ht=Ee&&!!O.sheenRoughnessMap,Q=!!O.specularMap,pe=!!O.specularColorMap,Oe=!!O.specularIntensityMap,q=Le&&!!O.transmissionMap,Ve=Le&&!!O.thicknessMap,me=!!O.gradientMap,We=!!O.alphaMap,Ge=O.alphaTest>0,Re=!!O.alphaHash,rt=!!O.extensions;let yt=ns;O.toneMapped&&(Ae===null||Ae.isXRRenderTarget===!0)&&(yt=n.toneMapping);const Gt={shaderID:oe,shaderType:O.type,shaderName:O.name,vertexShader:nt,fragmentShader:tt,defines:O.defines,customVertexShaderID:gt,customFragmentShaderID:ge,isRawShaderMaterial:O.isRawShaderMaterial===!0,glslVersion:O.glslVersion,precision:g,batching:it,batchingColor:it&&ee._colorsTexture!==null,instancing:ue,instancingColor:ue&&ee.instanceColor!==null,instancingMorph:ue&&ee.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:Ae===null?n.outputColorSpace:Ae.isXRRenderTarget===!0?Ae.texture.colorSpace:Wn,alphaToCoverage:!!O.alphaToCoverage,map:Mt,matcap:ot,envMap:Ke,envMapMode:Ke&&te.mapping,envMapCubeUVHeight:K,aoMap:Te,lightMap:G,bumpMap:Me,normalMap:De,displacementMap:m&&Fe,emissiveMap:Be,normalMapObjectSpace:De&&O.normalMapType===MU,normalMapTangentSpace:De&&O.normalMapType===ol,metalnessMap:$e,roughnessMap:Je,anisotropy:ct,anisotropyMap:ye,clearcoat:k,clearcoatMap:vt,clearcoatNormalMap:qe,clearcoatRoughnessMap:_t,dispersion:U,iridescence:ce,iridescenceMap:pt,iridescenceThicknessMap:Ie,sheen:Ee,sheenColorMap:He,sheenRoughnessMap:ht,specularMap:Q,specularColorMap:pe,specularIntensityMap:Oe,transmission:Le,transmissionMap:q,thicknessMap:Ve,gradientMap:me,opaque:O.transparent===!1&&O.blending===Ou&&O.alphaToCoverage===!1,alphaMap:We,alphaTest:Ge,alphaHash:Re,combine:O.combine,mapUv:Mt&&T(O.map.channel),aoMapUv:Te&&T(O.aoMap.channel),lightMapUv:G&&T(O.lightMap.channel),bumpMapUv:Me&&T(O.bumpMap.channel),normalMapUv:De&&T(O.normalMap.channel),displacementMapUv:Fe&&T(O.displacementMap.channel),emissiveMapUv:Be&&T(O.emissiveMap.channel),metalnessMapUv:$e&&T(O.metalnessMap.channel),roughnessMapUv:Je&&T(O.roughnessMap.channel),anisotropyMapUv:ye&&T(O.anisotropyMap.channel),clearcoatMapUv:vt&&T(O.clearcoatMap.channel),clearcoatNormalMapUv:qe&&T(O.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_t&&T(O.clearcoatRoughnessMap.channel),iridescenceMapUv:pt&&T(O.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&T(O.iridescenceThicknessMap.channel),sheenColorMapUv:He&&T(O.sheenColorMap.channel),sheenRoughnessMapUv:ht&&T(O.sheenRoughnessMap.channel),specularMapUv:Q&&T(O.specularMap.channel),specularColorMapUv:pe&&T(O.specularColorMap.channel),specularIntensityMapUv:Oe&&T(O.specularIntensityMap.channel),transmissionMapUv:q&&T(O.transmissionMap.channel),thicknessMapUv:Ve&&T(O.thicknessMap.channel),alphaMapUv:We&&T(O.alphaMap.channel),vertexTangents:!!re.attributes.tangent&&(De||ct),vertexColors:O.vertexColors,vertexAlphas:O.vertexColors===!0&&!!re.attributes.color&&re.attributes.color.itemSize===4,pointsUvs:ee.isPoints===!0&&!!re.attributes.uv&&(Mt||We),fog:!!se,useFog:O.fog===!0,fogExp2:!!se&&se.isFogExp2,flatShading:O.flatShading===!0&&O.wireframe===!1,sizeAttenuation:O.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ze,skinning:ee.isSkinnedMesh===!0,morphTargets:re.morphAttributes.position!==void 0,morphNormals:re.morphAttributes.normal!==void 0,morphColors:re.morphAttributes.color!==void 0,morphTargetsCount:Ce,morphTextureStride:Xe,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:O.dithering,shadowMapEnabled:n.shadowMap.enabled&&B.length>0,shadowMapType:n.shadowMap.type,toneMapping:yt,decodeVideoTexture:Mt&&O.map.isVideoTexture===!0&&rn.getTransfer(O.map.colorSpace)===Rn,decodeVideoTextureEmissive:Be&&O.emissiveMap.isVideoTexture===!0&&rn.getTransfer(O.emissiveMap.colorSpace)===Rn,premultipliedAlpha:O.premultipliedAlpha,doubleSided:O.side===la,flipSided:O.side===Oi,useDepthPacking:O.depthPacking>=0,depthPacking:O.depthPacking||0,index0AttributeName:O.index0AttributeName,extensionClipCullDistance:rt&&O.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(rt&&O.extensions.multiDraw===!0||it)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:O.customProgramCacheKey()};return Gt.vertexUv1s=h.has(1),Gt.vertexUv2s=h.has(2),Gt.vertexUv3s=h.has(3),h.clear(),Gt}function v(O){const R=[];if(O.shaderID?R.push(O.shaderID):(R.push(O.customVertexShaderID),R.push(O.customFragmentShaderID)),O.defines!==void 0)for(const B in O.defines)R.push(B),R.push(O.defines[B]);return O.isRawShaderMaterial===!1&&(y(R,O),E(R,O),R.push(n.outputColorSpace)),R.push(O.customProgramCacheKey),R.join()}function y(O,R){O.push(R.precision),O.push(R.outputColorSpace),O.push(R.envMapMode),O.push(R.envMapCubeUVHeight),O.push(R.mapUv),O.push(R.alphaMapUv),O.push(R.lightMapUv),O.push(R.aoMapUv),O.push(R.bumpMapUv),O.push(R.normalMapUv),O.push(R.displacementMapUv),O.push(R.emissiveMapUv),O.push(R.metalnessMapUv),O.push(R.roughnessMapUv),O.push(R.anisotropyMapUv),O.push(R.clearcoatMapUv),O.push(R.clearcoatNormalMapUv),O.push(R.clearcoatRoughnessMapUv),O.push(R.iridescenceMapUv),O.push(R.iridescenceThicknessMapUv),O.push(R.sheenColorMapUv),O.push(R.sheenRoughnessMapUv),O.push(R.specularMapUv),O.push(R.specularColorMapUv),O.push(R.specularIntensityMapUv),O.push(R.transmissionMapUv),O.push(R.thicknessMapUv),O.push(R.combine),O.push(R.fogExp2),O.push(R.sizeAttenuation),O.push(R.morphTargetsCount),O.push(R.morphAttributeCount),O.push(R.numDirLights),O.push(R.numPointLights),O.push(R.numSpotLights),O.push(R.numSpotLightMaps),O.push(R.numHemiLights),O.push(R.numRectAreaLights),O.push(R.numDirLightShadows),O.push(R.numPointLightShadows),O.push(R.numSpotLightShadows),O.push(R.numSpotLightShadowsWithMaps),O.push(R.numLightProbes),O.push(R.shadowMapType),O.push(R.toneMapping),O.push(R.numClippingPlanes),O.push(R.numClipIntersection),O.push(R.depthPacking)}function E(O,R){o.disableAll(),R.supportsVertexTextures&&o.enable(0),R.instancing&&o.enable(1),R.instancingColor&&o.enable(2),R.instancingMorph&&o.enable(3),R.matcap&&o.enable(4),R.envMap&&o.enable(5),R.normalMapObjectSpace&&o.enable(6),R.normalMapTangentSpace&&o.enable(7),R.clearcoat&&o.enable(8),R.iridescence&&o.enable(9),R.alphaTest&&o.enable(10),R.vertexColors&&o.enable(11),R.vertexAlphas&&o.enable(12),R.vertexUv1s&&o.enable(13),R.vertexUv2s&&o.enable(14),R.vertexUv3s&&o.enable(15),R.vertexTangents&&o.enable(16),R.anisotropy&&o.enable(17),R.alphaHash&&o.enable(18),R.batching&&o.enable(19),R.dispersion&&o.enable(20),R.batchingColor&&o.enable(21),R.gradientMap&&o.enable(22),O.push(o.mask),o.disableAll(),R.fog&&o.enable(0),R.useFog&&o.enable(1),R.flatShading&&o.enable(2),R.logarithmicDepthBuffer&&o.enable(3),R.reversedDepthBuffer&&o.enable(4),R.skinning&&o.enable(5),R.morphTargets&&o.enable(6),R.morphNormals&&o.enable(7),R.morphColors&&o.enable(8),R.premultipliedAlpha&&o.enable(9),R.shadowMapEnabled&&o.enable(10),R.doubleSided&&o.enable(11),R.flipSided&&o.enable(12),R.useDepthPacking&&o.enable(13),R.dithering&&o.enable(14),R.transmission&&o.enable(15),R.sheen&&o.enable(16),R.opaque&&o.enable(17),R.pointsUvs&&o.enable(18),R.decodeVideoTexture&&o.enable(19),R.decodeVideoTextureEmissive&&o.enable(20),R.alphaToCoverage&&o.enable(21),O.push(o.mask)}function b(O){const R=x[O.type];let B;if(R){const j=Ms[R];B=Sb.clone(j.uniforms)}else B=O.uniforms;return B}function D(O,R){let B;for(let j=0,ee=f.length;j<ee;j++){const se=f[j];if(se.cacheKey===R){B=se,++B.usedTimes;break}}return B===void 0&&(B=new Gq(n,R,O,r),f.push(B)),B}function C(O){if(--O.usedTimes===0){const R=f.indexOf(O);f[R]=f[f.length-1],f.pop(),O.destroy()}}function I(O){c.remove(O)}function P(){c.dispose()}return{getParameters:S,getProgramCacheKey:v,getUniforms:b,acquireProgram:D,releaseProgram:C,releaseShaderCache:I,programs:f,dispose:P}}function Yq(){let n=new WeakMap;function e(s){return n.has(s)}function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function i(s){n.delete(s)}function a(s,o,c){n.get(s)[o]=c}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:a,dispose:r}}function qq(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function ON(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function LN(){const n=[];let e=0;const t=[],i=[],a=[];function r(){e=0,t.length=0,i.length=0,a.length=0}function s(d,m,g,x,T,S){let v=n[e];return v===void 0?(v={id:d.id,object:d,geometry:m,material:g,groupOrder:x,renderOrder:d.renderOrder,z:T,group:S},n[e]=v):(v.id=d.id,v.object=d,v.geometry=m,v.material=g,v.groupOrder=x,v.renderOrder=d.renderOrder,v.z=T,v.group=S),e++,v}function o(d,m,g,x,T,S){const v=s(d,m,g,x,T,S);g.transmission>0?i.push(v):g.transparent===!0?a.push(v):t.push(v)}function c(d,m,g,x,T,S){const v=s(d,m,g,x,T,S);g.transmission>0?i.unshift(v):g.transparent===!0?a.unshift(v):t.unshift(v)}function h(d,m){t.length>1&&t.sort(d||qq),i.length>1&&i.sort(m||ON),a.length>1&&a.sort(m||ON)}function f(){for(let d=e,m=n.length;d<m;d++){const g=n[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:i,transparent:a,init:r,push:o,unshift:c,finish:f,sort:h}}function jq(){let n=new WeakMap;function e(i,a){const r=n.get(i);let s;return r===void 0?(s=new LN,n.set(i,[s])):a>=r.length?(s=new LN,r.push(s)):s=r[a],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function Zq(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new L,color:new je};break;case"SpotLight":t={position:new L,direction:new L,color:new je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new L,color:new je,distance:0,decay:0};break;case"HemisphereLight":t={direction:new L,skyColor:new je,groundColor:new je};break;case"RectAreaLight":t={color:new je,position:new L,halfWidth:new L,halfHeight:new L};break}return n[e.id]=t,t}}}function Kq(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Qq=0;function Jq(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function $q(n){const e=new Zq,t=Kq(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)i.probe.push(new L);const a=new L,r=new ke,s=new ke;function o(h){let f=0,d=0,m=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let g=0,x=0,T=0,S=0,v=0,y=0,E=0,b=0,D=0,C=0,I=0;h.sort(Jq);for(let O=0,R=h.length;O<R;O++){const B=h[O],j=B.color,ee=B.intensity,se=B.distance,re=B.shadow&&B.shadow.map?B.shadow.map.texture:null;if(B.isAmbientLight)f+=j.r*ee,d+=j.g*ee,m+=j.b*ee;else if(B.isLightProbe){for(let W=0;W<9;W++)i.probe[W].addScaledVector(B.sh.coefficients[W],ee);I++}else if(B.isDirectionalLight){const W=e.get(B);if(W.color.copy(B.color).multiplyScalar(B.intensity),B.castShadow){const te=B.shadow,K=t.get(B);K.shadowIntensity=te.intensity,K.shadowBias=te.bias,K.shadowNormalBias=te.normalBias,K.shadowRadius=te.radius,K.shadowMapSize=te.mapSize,i.directionalShadow[g]=K,i.directionalShadowMap[g]=re,i.directionalShadowMatrix[g]=B.shadow.matrix,y++}i.directional[g]=W,g++}else if(B.isSpotLight){const W=e.get(B);W.position.setFromMatrixPosition(B.matrixWorld),W.color.copy(j).multiplyScalar(ee),W.distance=se,W.coneCos=Math.cos(B.angle),W.penumbraCos=Math.cos(B.angle*(1-B.penumbra)),W.decay=B.decay,i.spot[T]=W;const te=B.shadow;if(B.map&&(i.spotLightMap[D]=B.map,D++,te.updateMatrices(B),B.castShadow&&C++),i.spotLightMatrix[T]=te.matrix,B.castShadow){const K=t.get(B);K.shadowIntensity=te.intensity,K.shadowBias=te.bias,K.shadowNormalBias=te.normalBias,K.shadowRadius=te.radius,K.shadowMapSize=te.mapSize,i.spotShadow[T]=K,i.spotShadowMap[T]=re,b++}T++}else if(B.isRectAreaLight){const W=e.get(B);W.color.copy(j).multiplyScalar(ee),W.halfWidth.set(B.width*.5,0,0),W.halfHeight.set(0,B.height*.5,0),i.rectArea[S]=W,S++}else if(B.isPointLight){const W=e.get(B);if(W.color.copy(B.color).multiplyScalar(B.intensity),W.distance=B.distance,W.decay=B.decay,B.castShadow){const te=B.shadow,K=t.get(B);K.shadowIntensity=te.intensity,K.shadowBias=te.bias,K.shadowNormalBias=te.normalBias,K.shadowRadius=te.radius,K.shadowMapSize=te.mapSize,K.shadowCameraNear=te.camera.near,K.shadowCameraFar=te.camera.far,i.pointShadow[x]=K,i.pointShadowMap[x]=re,i.pointShadowMatrix[x]=B.shadow.matrix,E++}i.point[x]=W,x++}else if(B.isHemisphereLight){const W=e.get(B);W.skyColor.copy(B.color).multiplyScalar(ee),W.groundColor.copy(B.groundColor).multiplyScalar(ee),i.hemi[v]=W,v++}}S>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=at.LTC_FLOAT_1,i.rectAreaLTC2=at.LTC_FLOAT_2):(i.rectAreaLTC1=at.LTC_HALF_1,i.rectAreaLTC2=at.LTC_HALF_2)),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=m;const P=i.hash;(P.directionalLength!==g||P.pointLength!==x||P.spotLength!==T||P.rectAreaLength!==S||P.hemiLength!==v||P.numDirectionalShadows!==y||P.numPointShadows!==E||P.numSpotShadows!==b||P.numSpotMaps!==D||P.numLightProbes!==I)&&(i.directional.length=g,i.spot.length=T,i.rectArea.length=S,i.point.length=x,i.hemi.length=v,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=b,i.spotShadowMap.length=b,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=b+D-C,i.spotLightMap.length=D,i.numSpotLightShadowsWithMaps=C,i.numLightProbes=I,P.directionalLength=g,P.pointLength=x,P.spotLength=T,P.rectAreaLength=S,P.hemiLength=v,P.numDirectionalShadows=y,P.numPointShadows=E,P.numSpotShadows=b,P.numSpotMaps=D,P.numLightProbes=I,i.version=Qq++)}function c(h,f){let d=0,m=0,g=0,x=0,T=0;const S=f.matrixWorldInverse;for(let v=0,y=h.length;v<y;v++){const E=h[v];if(E.isDirectionalLight){const b=i.directional[d];b.direction.setFromMatrixPosition(E.matrixWorld),a.setFromMatrixPosition(E.target.matrixWorld),b.direction.sub(a),b.direction.transformDirection(S),d++}else if(E.isSpotLight){const b=i.spot[g];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(S),b.direction.setFromMatrixPosition(E.matrixWorld),a.setFromMatrixPosition(E.target.matrixWorld),b.direction.sub(a),b.direction.transformDirection(S),g++}else if(E.isRectAreaLight){const b=i.rectArea[x];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(S),s.identity(),r.copy(E.matrixWorld),r.premultiply(S),s.extractRotation(r),b.halfWidth.set(E.width*.5,0,0),b.halfHeight.set(0,E.height*.5,0),b.halfWidth.applyMatrix4(s),b.halfHeight.applyMatrix4(s),x++}else if(E.isPointLight){const b=i.point[m];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(S),m++}else if(E.isHemisphereLight){const b=i.hemi[T];b.direction.setFromMatrixPosition(E.matrixWorld),b.direction.transformDirection(S),T++}}}return{setup:o,setupView:c,state:i}}function IN(n){const e=new $q(n),t=[],i=[];function a(f){h.camera=f,t.length=0,i.length=0}function r(f){t.push(f)}function s(f){i.push(f)}function o(){e.setup(t)}function c(f){e.setupView(t,f)}const h={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:a,state:h,setupLights:o,setupLightsView:c,pushLight:r,pushShadow:s}}function ej(n){let e=new WeakMap;function t(a,r=0){const s=e.get(a);let o;return s===void 0?(o=new IN(n),e.set(a,[o])):r>=s.length?(o=new IN(n),s.push(o)):o=s[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const tj=`void main() {
gl_Position = vec4( position, 1.0 );
}`,nj=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( squared_mean - mean * mean );
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function ij(n,e,t){let i=new Wd;const a=new de,r=new de,s=new zt,o=new Ib({depthPacking:EU}),c=new Ub,h={},f=t.maxTextureSize,d={[Cs]:Oi,[Oi]:Cs,[la]:la},m=new Fi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new de},radius:{value:4}},vertexShader:tj,fragmentShader:nj}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const x=new wt;x.setAttribute("position",new Ot(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const T=new si(x,m),S=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=b1;let v=this.type;this.render=function(C,I,P){if(S.enabled===!1||S.autoUpdate===!1&&S.needsUpdate===!1||C.length===0)return;const O=n.getRenderTarget(),R=n.getActiveCubeFace(),B=n.getActiveMipmapLevel(),j=n.state;j.setBlending(Sa),j.buffers.depth.getReversed()===!0?j.buffers.color.setClear(0,0,0,0):j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);const ee=v!==ys&&this.type===ys,se=v===ys&&this.type!==ys;for(let re=0,W=C.length;re<W;re++){const te=C[re],K=te.shadow;if(K===void 0){ut("WebGLShadowMap:",te,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;a.copy(K.mapSize);const oe=K.getFrameExtents();if(a.multiply(oe),r.copy(K.mapSize),(a.x>f||a.y>f)&&(a.x>f&&(r.x=Math.floor(f/oe.x),a.x=r.x*oe.x,K.mapSize.x=r.x),a.y>f&&(r.y=Math.floor(f/oe.y),a.y=r.y*oe.y,K.mapSize.y=r.y)),K.map===null||ee===!0||se===!0){const Ce=this.type!==ys?{minFilter:Fn,magFilter:Fn}:{};K.map!==null&&K.map.dispose(),K.map=new _i(a.x,a.y,Ce),K.map.texture.name=te.name+".shadowMap",K.camera.updateProjectionMatrix()}n.setRenderTarget(K.map),n.clear();const ie=K.getViewportCount();for(let Ce=0;Ce<ie;Ce++){const Xe=K.getViewport(Ce);s.set(r.x*Xe.x,r.y*Xe.y,r.x*Xe.z,r.y*Xe.w),j.viewport(s),K.updateMatrices(te,Ce),i=K.getFrustum(),b(I,P,K.camera,te,this.type)}K.isPointLightShadow!==!0&&this.type===ys&&y(K,P),K.needsUpdate=!1}v=this.type,S.needsUpdate=!1,n.setRenderTarget(O,R,B)};function y(C,I){const P=e.update(T);m.defines.VSM_SAMPLES!==C.blurSamples&&(m.defines.VSM_SAMPLES=C.blurSamples,g.defines.VSM_SAMPLES=C.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new _i(a.x,a.y)),m.uniforms.shadow_pass.value=C.map.texture,m.uniforms.resolution.value=C.mapSize,m.uniforms.radius.value=C.radius,n.setRenderTarget(C.mapPass),n.clear(),n.renderBufferDirect(I,null,P,m,T,null),g.uniforms.shadow_pass.value=C.mapPass.texture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,n.setRenderTarget(C.map),n.clear(),n.renderBufferDirect(I,null,P,g,T,null)}function E(C,I,P,O){let R=null;const B=P.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(B!==void 0)R=B;else if(R=P.isPointLight===!0?c:o,n.localClippingEnabled&&I.clipShadows===!0&&Array.isArray(I.clippingPlanes)&&I.clippingPlanes.length!==0||I.displacementMap&&I.displacementScale!==0||I.alphaMap&&I.alphaTest>0||I.map&&I.alphaTest>0||I.alphaToCoverage===!0){const j=R.uuid,ee=I.uuid;let se=h[j];se===void 0&&(se={},h[j]=se);let re=se[ee];re===void 0&&(re=R.clone(),se[ee]=re,I.addEventListener("dispose",D)),R=re}if(R.visible=I.visible,R.wireframe=I.wireframe,O===ys?R.side=I.shadowSide!==null?I.shadowSide:I.side:R.side=I.shadowSide!==null?I.shadowSide:d[I.side],R.alphaMap=I.alphaMap,R.alphaTest=I.alphaToCoverage===!0?.5:I.alphaTest,R.map=I.map,R.clipShadows=I.clipShadows,R.clippingPlanes=I.clippingPlanes,R.clipIntersection=I.clipIntersection,R.displacementMap=I.displacementMap,R.displacementScale=I.displacementScale,R.displacementBias=I.displacementBias,R.wireframeLinewidth=I.wireframeLinewidth,R.linewidth=I.linewidth,P.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const j=n.properties.get(R);j.light=P}return R}function b(C,I,P,O,R){if(C.visible===!1)return;if(C.layers.test(I.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&R===ys)&&(!C.frustumCulled||i.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,C.matrixWorld);const ee=e.update(C),se=C.material;if(Array.isArray(se)){const re=ee.groups;for(let W=0,te=re.length;W<te;W++){const K=re[W],oe=se[K.materialIndex];if(oe&&oe.visible){const ie=E(C,oe,O,R);C.onBeforeShadow(n,C,I,P,ee,ie,K),n.renderBufferDirect(P,null,ee,ie,C,K),C.onAfterShadow(n,C,I,P,ee,ie,K)}}}else if(se.visible){const re=E(C,se,O,R);C.onBeforeShadow(n,C,I,P,ee,re,null),n.renderBufferDirect(P,null,ee,re,C,null),C.onAfterShadow(n,C,I,P,ee,re,null)}}const j=C.children;for(let ee=0,se=j.length;ee<se;ee++)b(j[ee],I,P,O,R)}function D(C){C.target.removeEventListener("dispose",D);for(const P in h){const O=h[P],R=C.target.uuid;R in O&&(O[R].dispose(),delete O[R])}}}const aj={[$_]:i0,[ex]:ix,[tx]:ax,[ku]:nx,[i0]:$_,[ix]:ex,[ax]:tx,[nx]:ku};function rj(n,e){function t(){let q=!1;const Ve=new zt;let me=null;const We=new zt(0,0,0,0);return{setMask:function(Ge){me!==Ge&&!q&&(n.colorMask(Ge,Ge,Ge,Ge),me=Ge)},setLocked:function(Ge){q=Ge},setClear:function(Ge,Re,rt,yt,Gt){Gt===!0&&(Ge*=yt,Re*=yt,rt*=yt),Ve.set(Ge,Re,rt,yt),We.equals(Ve)===!1&&(n.clearColor(Ge,Re,rt,yt),We.copy(Ve))},reset:function(){q=!1,me=null,We.set(-1,0,0,0)}}}function i(){let q=!1,Ve=!1,me=null,We=null,Ge=null;return{setReversed:function(Re){if(Ve!==Re){const rt=e.get("EXT_clip_control");Re?rt.clipControlEXT(rt.LOWER_LEFT_EXT,rt.ZERO_TO_ONE_EXT):rt.clipControlEXT(rt.LOWER_LEFT_EXT,rt.NEGATIVE_ONE_TO_ONE_EXT),Ve=Re;const yt=Ge;Ge=null,this.setClear(yt)}},getReversed:function(){return Ve},setTest:function(Re){Re?Ae(n.DEPTH_TEST):Ze(n.DEPTH_TEST)},setMask:function(Re){me!==Re&&!q&&(n.depthMask(Re),me=Re)},setFunc:function(Re){if(Ve&&(Re=aj[Re]),We!==Re){switch(Re){case $_:n.depthFunc(n.NEVER);break;case i0:n.depthFunc(n.ALWAYS);break;case ex:n.depthFunc(n.LESS);break;case ku:n.depthFunc(n.LEQUAL);break;case tx:n.depthFunc(n.EQUAL);break;case nx:n.depthFunc(n.GEQUAL);break;case ix:n.depthFunc(n.GREATER);break;case ax:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}We=Re}},setLocked:function(Re){q=Re},setClear:function(Re){Ge!==Re&&(Ve&&(Re=1-Re),n.clearDepth(Re),Ge=Re)},reset:function(){q=!1,me=null,We=null,Ge=null,Ve=!1}}}function a(){let q=!1,Ve=null,me=null,We=null,Ge=null,Re=null,rt=null,yt=null,Gt=null;return{setTest:function(Vt){q||(Vt?Ae(n.STENCIL_TEST):Ze(n.STENCIL_TEST))},setMask:function(Vt){Ve!==Vt&&!q&&(n.stencilMask(Vt),Ve=Vt)},setFunc:function(Vt,oi,li){(me!==Vt||We!==oi||Ge!==li)&&(n.stencilFunc(Vt,oi,li),me=Vt,We=oi,Ge=li)},setOp:function(Vt,oi,li){(Re!==Vt||rt!==oi||yt!==li)&&(n.stencilOp(Vt,oi,li),Re=Vt,rt=oi,yt=li)},setLocked:function(Vt){q=Vt},setClear:function(Vt){Gt!==Vt&&(n.clearStencil(Vt),Gt=Vt)},reset:function(){q=!1,Ve=null,me=null,We=null,Ge=null,Re=null,rt=null,yt=null,Gt=null}}}const r=new t,s=new i,o=new a,c=new WeakMap,h=new WeakMap;let f={},d={},m=new WeakMap,g=[],x=null,T=!1,S=null,v=null,y=null,E=null,b=null,D=null,C=null,I=new je(0,0,0),P=0,O=!1,R=null,B=null,j=null,ee=null,se=null;const re=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,te=0;const K=n.getParameter(n.VERSION);K.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(K)[1]),W=te>=1):K.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),W=te>=2);let oe=null,ie={};const Ce=n.getParameter(n.SCISSOR_BOX),Xe=n.getParameter(n.VIEWPORT),nt=new zt().fromArray(Ce),tt=new zt().fromArray(Xe);function gt(q,Ve,me,We){const Ge=new Uint8Array(4),Re=n.createTexture();n.bindTexture(q,Re),n.texParameteri(q,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(q,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let rt=0;rt<me;rt++)q===n.TEXTURE_3D||q===n.TEXTURE_2D_ARRAY?n.texImage3D(Ve,0,n.RGBA,1,1,We,0,n.RGBA,n.UNSIGNED_BYTE,Ge):n.texImage2D(Ve+rt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ge);return Re}const ge={};ge[n.TEXTURE_2D]=gt(n.TEXTURE_2D,n.TEXTURE_2D,1),ge[n.TEXTURE_CUBE_MAP]=gt(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ge[n.TEXTURE_2D_ARRAY]=gt(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ge[n.TEXTURE_3D]=gt(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),Ae(n.DEPTH_TEST),s.setFunc(ku),Me(!1),De(J3),Ae(n.CULL_FACE),Te(Sa);function Ae(q){f[q]!==!0&&(n.enable(q),f[q]=!0)}function Ze(q){f[q]!==!1&&(n.disable(q),f[q]=!1)}function ue(q,Ve){return d[q]!==Ve?(n.bindFramebuffer(q,Ve),d[q]=Ve,q===n.DRAW_FRAMEBUFFER&&(d[n.FRAMEBUFFER]=Ve),q===n.FRAMEBUFFER&&(d[n.DRAW_FRAMEBUFFER]=Ve),!0):!1}function it(q,Ve){let me=g,We=!1;if(q){me=m.get(Ve),me===void 0&&(me=[],m.set(Ve,me));const Ge=q.textures;if(me.length!==Ge.length||me[0]!==n.COLOR_ATTACHMENT0){for(let Re=0,rt=Ge.length;Re<rt;Re++)me[Re]=n.COLOR_ATTACHMENT0+Re;me.length=Ge.length,We=!0}}else me[0]!==n.BACK&&(me[0]=n.BACK,We=!0);We&&n.drawBuffers(me)}function Mt(q){return x!==q?(n.useProgram(q),x=q,!0):!1}const ot={[Qs]:n.FUNC_ADD,[qI]:n.FUNC_SUBTRACT,[jI]:n.FUNC_REVERSE_SUBTRACT};ot[ZI]=n.MIN,ot[KI]=n.MAX;const Ke={[QI]:n.ZERO,[Gf]:n.ONE,[JI]:n.SRC_COLOR,[Q_]:n.SRC_ALPHA,[aU]:n.SRC_ALPHA_SATURATE,[nU]:n.DST_COLOR,[eU]:n.DST_ALPHA,[$I]:n.ONE_MINUS_SRC_COLOR,[J_]:n.ONE_MINUS_SRC_ALPHA,[iU]:n.ONE_MINUS_DST_COLOR,[tU]:n.ONE_MINUS_DST_ALPHA,[rU]:n.CONSTANT_COLOR,[sU]:n.ONE_MINUS_CONSTANT_COLOR,[oU]:n.CONSTANT_ALPHA,[lU]:n.ONE_MINUS_CONSTANT_ALPHA};function Te(q,Ve,me,We,Ge,Re,rt,yt,Gt,Vt){if(q===Sa){T===!0&&(Ze(n.BLEND),T=!1);return}if(T===!1&&(Ae(n.BLEND),T=!0),q!==lb){if(q!==S||Vt!==O){if((v!==Qs||b!==Qs)&&(n.blendEquation(n.FUNC_ADD),v=Qs,b=Qs),Vt)switch(q){case Ou:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case $3:n.blendFunc(n.ONE,n.ONE);break;case eE:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case tE:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:Bt("WebGLState: Invalid blending: ",q);break}else switch(q){case Ou:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case $3:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case eE:Bt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case tE:Bt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Bt("WebGLState: Invalid blending: ",q);break}y=null,E=null,D=null,C=null,I.set(0,0,0),P=0,S=q,O=Vt}return}Ge=Ge||Ve,Re=Re||me,rt=rt||We,(Ve!==v||Ge!==b)&&(n.blendEquationSeparate(ot[Ve],ot[Ge]),v=Ve,b=Ge),(me!==y||We!==E||Re!==D||rt!==C)&&(n.blendFuncSeparate(Ke[me],Ke[We],Ke[Re],Ke[rt]),y=me,E=We,D=Re,C=rt),(yt.equals(I)===!1||Gt!==P)&&(n.blendColor(yt.r,yt.g,yt.b,Gt),I.copy(yt),P=Gt),S=q,O=!1}function G(q,Ve){q.side===la?Ze(n.CULL_FACE):Ae(n.CULL_FACE);let me=q.side===Oi;Ve&&(me=!me),Me(me),q.blending===Ou&&q.transparent===!1?Te(Sa):Te(q.blending,q.blendEquation,q.blendSrc,q.blendDst,q.blendEquationAlpha,q.blendSrcAlpha,q.blendDstAlpha,q.blendColor,q.blendAlpha,q.premultipliedAlpha),s.setFunc(q.depthFunc),s.setTest(q.depthTest),s.setMask(q.depthWrite),r.setMask(q.colorWrite);const We=q.stencilWrite;o.setTest(We),We&&(o.setMask(q.stencilWriteMask),o.setFunc(q.stencilFunc,q.stencilRef,q.stencilFuncMask),o.setOp(q.stencilFail,q.stencilZFail,q.stencilZPass)),Be(q.polygonOffset,q.polygonOffsetFactor,q.polygonOffsetUnits),q.alphaToCoverage===!0?Ae(n.SAMPLE_ALPHA_TO_COVERAGE):Ze(n.SAMPLE_ALPHA_TO_COVERAGE)}function Me(q){R!==q&&(q?n.frontFace(n.CW):n.frontFace(n.CCW),R=q)}function De(q){q!==WI?(Ae(n.CULL_FACE),q!==B&&(q===J3?n.cullFace(n.BACK):q===XI?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Ze(n.CULL_FACE),B=q}function Fe(q){q!==j&&(W&&n.lineWidth(q),j=q)}function Be(q,Ve,me){q?(Ae(n.POLYGON_OFFSET_FILL),(ee!==Ve||se!==me)&&(n.polygonOffset(Ve,me),ee=Ve,se=me)):Ze(n.POLYGON_OFFSET_FILL)}function $e(q){q?Ae(n.SCISSOR_TEST):Ze(n.SCISSOR_TEST)}function Je(q){q===void 0&&(q=n.TEXTURE0+re-1),oe!==q&&(n.activeTexture(q),oe=q)}function ct(q,Ve,me){me===void 0&&(oe===null?me=n.TEXTURE0+re-1:me=oe);let We=ie[me];We===void 0&&(We={type:void 0,texture:void 0},ie[me]=We),(We.type!==q||We.texture!==Ve)&&(oe!==me&&(n.activeTexture(me),oe=me),n.bindTexture(q,Ve||ge[q]),We.type=q,We.texture=Ve)}function k(){const q=ie[oe];q!==void 0&&q.type!==void 0&&(n.bindTexture(q.type,null),q.type=void 0,q.texture=void 0)}function U(){try{n.compressedTexImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function ce(){try{n.compressedTexImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function Ee(){try{n.texSubImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function Le(){try{n.texSubImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function ye(){try{n.compressedTexSubImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function vt(){try{n.compressedTexSubImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function qe(){try{n.texStorage2D(...arguments)}catch(q){q("WebGLState:",q)}}function _t(){try{n.texStorage3D(...arguments)}catch(q){q("WebGLState:",q)}}function pt(){try{n.texImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function Ie(){try{n.texImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function He(q){nt.equals(q)===!1&&(n.scissor(q.x,q.y,q.z,q.w),nt.copy(q))}function ht(q){tt.equals(q)===!1&&(n.viewport(q.x,q.y,q.z,q.w),tt.copy(q))}function Q(q,Ve){let me=h.get(Ve);me===void 0&&(me=new WeakMap,h.set(Ve,me));let We=me.get(q);We===void 0&&(We=n.getUniformBlockIndex(Ve,q.name),me.set(q,We))}function pe(q,Ve){const We=h.get(Ve).get(q);c.get(Ve)!==We&&(n.uniformBlockBinding(Ve,We,q.__bindingPointIndex),c.set(Ve,We))}function Oe(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),s.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),f={},oe=null,ie={},d={},m=new WeakMap,g=[],x=null,T=!1,S=null,v=null,y=null,E=null,b=null,D=null,C=null,I=new je(0,0,0),P=0,O=!1,R=null,B=null,j=null,ee=null,se=null,nt.set(0,0,n.canvas.width,n.canvas.height),tt.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:Ae,disable:Ze,bindFramebuffer:ue,drawBuffers:it,useProgram:Mt,setBlending:Te,setMaterial:G,setFlipSided:Me,setCullFace:De,setLineWidth:Fe,setPolygonOffset:Be,setScissorTest:$e,activeTexture:Je,bindTexture:ct,unbindTexture:k,compressedTexImage2D:U,compressedTexImage3D:ce,texImage2D:pt,texImage3D:Ie,updateUBOMapping:Q,uniformBlockBinding:pe,texStorage2D:qe,texStorage3D:_t,texSubImage2D:Ee,texSubImage3D:Le,compressedTexSubImage2D:ye,compressedTexSubImage3D:vt,scissor:He,viewport:ht,reset:Oe}}function sj(n,e,t,i,a,r,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new de,f=new WeakMap;let d;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(k,U){return g?new OffscreenCanvas(k,U):c0("canvas")}function T(k,U,ce){let Ee=1;const Le=ct(k);if((Le.width>ce||Le.height>ce)&&(Ee=ce/Math.max(Le.width,Le.height)),Ee<1)if(typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&k instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&k instanceof ImageBitmap||typeof VideoFrame<"u"&&k instanceof VideoFrame){const ye=Math.floor(Ee*Le.width),vt=Math.floor(Ee*Le.height);d===void 0&&(d=x(ye,vt));const qe=U?x(ye,vt):d;return qe.width=ye,qe.height=vt,qe.getContext("2d").drawImage(k,0,0,ye,vt),ut("WebGLRenderer: Texture has been resized from ("+Le.width+"x"+Le.height+") to ("+ye+"x"+vt+")."),qe}else return"data"in k&&ut("WebGLRenderer: Image in DataTexture is too big ("+Le.width+"x"+Le.height+")."),k;return k}function S(k){return k.generateMipmaps}function v(k){n.generateMipmap(k)}function y(k){return k.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:k.isWebGL3DRenderTarget?n.TEXTURE_3D:k.isWebGLArrayRenderTarget||k.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function E(k,U,ce,Ee,Le=!1){if(k!==null){if(n[k]!==void 0)return n[k];ut("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+k+"'")}let ye=U;if(U===n.RED&&(ce===n.FLOAT&&(ye=n.R32F),ce===n.HALF_FLOAT&&(ye=n.R16F),ce===n.UNSIGNED_BYTE&&(ye=n.R8)),U===n.RED_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.R8UI),ce===n.UNSIGNED_SHORT&&(ye=n.R16UI),ce===n.UNSIGNED_INT&&(ye=n.R32UI),ce===n.BYTE&&(ye=n.R8I),ce===n.SHORT&&(ye=n.R16I),ce===n.INT&&(ye=n.R32I)),U===n.RG&&(ce===n.FLOAT&&(ye=n.RG32F),ce===n.HALF_FLOAT&&(ye=n.RG16F),ce===n.UNSIGNED_BYTE&&(ye=n.RG8)),U===n.RG_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.RG8UI),ce===n.UNSIGNED_SHORT&&(ye=n.RG16UI),ce===n.UNSIGNED_INT&&(ye=n.RG32UI),ce===n.BYTE&&(ye=n.RG8I),ce===n.SHORT&&(ye=n.RG16I),ce===n.INT&&(ye=n.RG32I)),U===n.RGB_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.RGB8UI),ce===n.UNSIGNED_SHORT&&(ye=n.RGB16UI),ce===n.UNSIGNED_INT&&(ye=n.RGB32UI),ce===n.BYTE&&(ye=n.RGB8I),ce===n.SHORT&&(ye=n.RGB16I),ce===n.INT&&(ye=n.RGB32I)),U===n.RGBA_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.RGBA8UI),ce===n.UNSIGNED_SHORT&&(ye=n.RGBA16UI),ce===n.UNSIGNED_INT&&(ye=n.RGBA32UI),ce===n.BYTE&&(ye=n.RGBA8I),ce===n.SHORT&&(ye=n.RGBA16I),ce===n.INT&&(ye=n.RGBA32I)),U===n.RGB&&(ce===n.UNSIGNED_INT_5_9_9_9_REV&&(ye=n.RGB9_E5),ce===n.UNSIGNED_INT_10F_11F_11F_REV&&(ye=n.R11F_G11F_B10F)),U===n.RGBA){const vt=Le?o0:rn.getTransfer(Ee);ce===n.FLOAT&&(ye=n.RGBA32F),ce===n.HALF_FLOAT&&(ye=n.RGBA16F),ce===n.UNSIGNED_BYTE&&(ye=vt===Rn?n.SRGB8_ALPHA8:n.RGBA8),ce===n.UNSIGNED_SHORT_4_4_4_4&&(ye=n.RGBA4),ce===n.UNSIGNED_SHORT_5_5_5_1&&(ye=n.RGB5_A1)}return(ye===n.R16F||ye===n.R32F||ye===n.RG16F||ye===n.RG32F||ye===n.RGBA16F||ye===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function b(k,U){let ce;return k?U===null||U===Ns||U===Xu?ce=n.DEPTH24_STENCIL8:U===ri?ce=n.DEPTH32F_STENCIL8:U===Wu&&(ce=n.DEPTH24_STENCIL8,ut("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):U===null||U===Ns||U===Xu?ce=n.DEPTH_COMPONENT24:U===ri?ce=n.DEPTH_COMPONENT32F:U===Wu&&(ce=n.DEPTH_COMPONENT16),ce}function D(k,U){return S(k)===!0||k.isFramebufferTexture&&k.minFilter!==Fn&&k.minFilter!==Ht?Math.log2(Math.max(U.width,U.height))+1:k.mipmaps!==void 0&&k.mipmaps.length>0?k.mipmaps.length:k.isCompressedTexture&&Array.isArray(k.image)?U.mipmaps.length:1}function C(k){const U=k.target;U.removeEventListener("dispose",C),P(U),U.isVideoTexture&&f.delete(U)}function I(k){const U=k.target;U.removeEventListener("dispose",I),R(U)}function P(k){const U=i.get(k);if(U.__webglInit===void 0)return;const ce=k.source,Ee=m.get(ce);if(Ee){const Le=Ee[U.__cacheKey];Le.usedTimes--,Le.usedTimes===0&&O(k),Object.keys(Ee).length===0&&m.delete(ce)}i.remove(k)}function O(k){const U=i.get(k);n.deleteTexture(U.__webglTexture);const ce=k.source,Ee=m.get(ce);delete Ee[U.__cacheKey],s.memory.textures--}function R(k){const U=i.get(k);if(k.depthTexture&&(k.depthTexture.dispose(),i.remove(k.depthTexture)),k.isWebGLCubeRenderTarget)for(let Ee=0;Ee<6;Ee++){if(Array.isArray(U.__webglFramebuffer[Ee]))for(let Le=0;Le<U.__webglFramebuffer[Ee].length;Le++)n.deleteFramebuffer(U.__webglFramebuffer[Ee][Le]);else n.deleteFramebuffer(U.__webglFramebuffer[Ee]);U.__webglDepthbuffer&&n.deleteRenderbuffer(U.__webglDepthbuffer[Ee])}else{if(Array.isArray(U.__webglFramebuffer))for(let Ee=0;Ee<U.__webglFramebuffer.length;Ee++)n.deleteFramebuffer(U.__webglFramebuffer[Ee]);else n.deleteFramebuffer(U.__webglFramebuffer);if(U.__webglDepthbuffer&&n.deleteRenderbuffer(U.__webglDepthbuffer),U.__webglMultisampledFramebuffer&&n.deleteFramebuffer(U.__webglMultisampledFramebuffer),U.__webglColorRenderbuffer)for(let Ee=0;Ee<U.__webglColorRenderbuffer.length;Ee++)U.__webglColorRenderbuffer[Ee]&&n.deleteRenderbuffer(U.__webglColorRenderbuffer[Ee]);U.__webglDepthRenderbuffer&&n.deleteRenderbuffer(U.__webglDepthRenderbuffer)}const ce=k.textures;for(let Ee=0,Le=ce.length;Ee<Le;Ee++){const ye=i.get(ce[Ee]);ye.__webglTexture&&(n.deleteTexture(ye.__webglTexture),s.memory.textures--),i.remove(ce[Ee])}i.remove(k)}let B=0;function j(){B=0}function ee(){const k=B;return k>=a.maxTextures&&ut("WebGLTextures: Trying to use "+k+" texture units while this GPU supports only "+a.maxTextures),B+=1,k}function se(k){const U=[];return U.push(k.wrapS),U.push(k.wrapT),U.push(k.wrapR||0),U.push(k.magFilter),U.push(k.minFilter),U.push(k.anisotropy),U.push(k.internalFormat),U.push(k.format),U.push(k.type),U.push(k.generateMipmaps),U.push(k.premultiplyAlpha),U.push(k.flipY),U.push(k.unpackAlignment),U.push(k.colorSpace),U.join()}function re(k,U){const ce=i.get(k);if(k.isVideoTexture&&$e(k),k.isRenderTargetTexture===!1&&k.isExternalTexture!==!0&&k.version>0&&ce.__version!==k.version){const Ee=k.image;if(Ee===null)ut("WebGLRenderer: Texture marked for update but no image data found.");else if(Ee.complete===!1)ut("WebGLRenderer: Texture marked for update but image is incomplete");else{ge(ce,k,U);return}}else k.isExternalTexture&&(ce.__webglTexture=k.sourceTexture?k.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ce.__webglTexture,n.TEXTURE0+U)}function W(k,U){const ce=i.get(k);if(k.isRenderTargetTexture===!1&&k.version>0&&ce.__version!==k.version){ge(ce,k,U);return}else k.isExternalTexture&&(ce.__webglTexture=k.sourceTexture?k.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ce.__webglTexture,n.TEXTURE0+U)}function te(k,U){const ce=i.get(k);if(k.isRenderTargetTexture===!1&&k.version>0&&ce.__version!==k.version){ge(ce,k,U);return}t.bindTexture(n.TEXTURE_3D,ce.__webglTexture,n.TEXTURE0+U)}function K(k,U){const ce=i.get(k);if(k.version>0&&ce.__version!==k.version){Ae(ce,k,U);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ce.__webglTexture,n.TEXTURE0+U)}const oe={[Ta]:n.REPEAT,[Li]:n.CLAMP_TO_EDGE,[vd]:n.MIRRORED_REPEAT},ie={[Fn]:n.NEAREST,[R1]:n.NEAREST_MIPMAP_NEAREST,[yu]:n.NEAREST_MIPMAP_LINEAR,[Ht]:n.LINEAR,[td]:n.LINEAR_MIPMAP_NEAREST,[Er]:n.LINEAR_MIPMAP_LINEAR},Ce={[bU]:n.NEVER,[DU]:n.ALWAYS,[AU]:n.LESS,[gb]:n.LEQUAL,[RU]:n.EQUAL,[NU]:n.GEQUAL,[wU]:n.GREATER,[CU]:n.NOTEQUAL};function Xe(k,U){if(U.type===ri&&e.has("OES_texture_float_linear")===!1&&(U.magFilter===Ht||U.magFilter===td||U.magFilter===yu||U.magFilter===Er||U.minFilter===Ht||U.minFilter===td||U.minFilter===yu||U.minFilter===Er)&&ut("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(k,n.TEXTURE_WRAP_S,oe[U.wrapS]),n.texParameteri(k,n.TEXTURE_WRAP_T,oe[U.wrapT]),(k===n.TEXTURE_3D||k===n.TEXTURE_2D_ARRAY)&&n.texParameteri(k,n.TEXTURE_WRAP_R,oe[U.wrapR]),n.texParameteri(k,n.TEXTURE_MAG_FILTER,ie[U.magFilter]),n.texParameteri(k,n.TEXTURE_MIN_FILTER,ie[U.minFilter]),U.compareFunction&&(n.texParameteri(k,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(k,n.TEXTURE_COMPARE_FUNC,Ce[U.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(U.magFilter===Fn||U.minFilter!==yu&&U.minFilter!==Er||U.type===ri&&e.has("OES_texture_float_linear")===!1)return;if(U.anisotropy>1||i.get(U).__currentAnisotropy){const ce=e.get("EXT_texture_filter_anisotropic");n.texParameterf(k,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(U.anisotropy,a.getMaxAnisotropy())),i.get(U).__currentAnisotropy=U.anisotropy}}}function nt(k,U){let ce=!1;k.__webglInit===void 0&&(k.__webglInit=!0,U.addEventListener("dispose",C));const Ee=U.source;let Le=m.get(Ee);Le===void 0&&(Le={},m.set(Ee,Le));const ye=se(U);if(ye!==k.__cacheKey){Le[ye]===void 0&&(Le[ye]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ce=!0),Le[ye].usedTimes++;const vt=Le[k.__cacheKey];vt!==void 0&&(Le[k.__cacheKey].usedTimes--,vt.usedTimes===0&&O(U)),k.__cacheKey=ye,k.__webglTexture=Le[ye].texture}return ce}function tt(k,U,ce){return Math.floor(Math.floor(k/ce)/U)}function gt(k,U,ce,Ee){const ye=k.updateRanges;if(ye.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,U.width,U.height,ce,Ee,U.data);else{ye.sort((Ie,He)=>Ie.start-He.start);let vt=0;for(let Ie=1;Ie<ye.length;Ie++){const He=ye[vt],ht=ye[Ie],Q=He.start+He.count,pe=tt(ht.start,U.width,4),Oe=tt(He.start,U.width,4);ht.start<=Q+1&&pe===Oe&&tt(ht.start+ht.count-1,U.width,4)===pe?He.count=Math.max(He.count,ht.start+ht.count-He.start):(++vt,ye[vt]=ht)}ye.length=vt+1;const qe=n.getParameter(n.UNPACK_ROW_LENGTH),_t=n.getParameter(n.UNPACK_SKIP_PIXELS),pt=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,U.width);for(let Ie=0,He=ye.length;Ie<He;Ie++){const ht=ye[Ie],Q=Math.floor(ht.start/4),pe=Math.ceil(ht.count/4),Oe=Q%U.width,q=Math.floor(Q/U.width),Ve=pe,me=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,Oe),n.pixelStorei(n.UNPACK_SKIP_ROWS,q),t.texSubImage2D(n.TEXTURE_2D,0,Oe,q,Ve,me,ce,Ee,U.data)}k.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,qe),n.pixelStorei(n.UNPACK_SKIP_PIXELS,_t),n.pixelStorei(n.UNPACK_SKIP_ROWS,pt)}}function ge(k,U,ce){let Ee=n.TEXTURE_2D;(U.isDataArrayTexture||U.isCompressedArrayTexture)&&(Ee=n.TEXTURE_2D_ARRAY),U.isData3DTexture&&(Ee=n.TEXTURE_3D);const Le=nt(k,U),ye=U.source;t.bindTexture(Ee,k.__webglTexture,n.TEXTURE0+ce);const vt=i.get(ye);if(ye.version!==vt.__version||Le===!0){t.activeTexture(n.TEXTURE0+ce);const qe=rn.getPrimaries(rn.workingColorSpace),_t=U.colorSpace===Na?null:rn.getPrimaries(U.colorSpace),pt=U.colorSpace===Na||qe===_t?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,U.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,U.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,pt);let Ie=T(U.image,!1,a.maxTextureSize);Ie=Je(U,Ie);const He=r.convert(U.format,U.colorSpace),ht=r.convert(U.type);let Q=E(U.internalFormat,He,ht,U.colorSpace,U.isVideoTexture);Xe(Ee,U);let pe;const Oe=U.mipmaps,q=U.isVideoTexture!==!0,Ve=vt.__version===void 0||Le===!0,me=ye.dataReady,We=D(U,Ie);if(U.isDepthTexture)Q=b(U.format===Yu,U.type),Ve&&(q?t.texStorage2D(n.TEXTURE_2D,1,Q,Ie.width,Ie.height):t.texImage2D(n.TEXTURE_2D,0,Q,Ie.width,Ie.height,0,He,ht,null));else if(U.isDataTexture)if(Oe.length>0){q&&Ve&&t.texStorage2D(n.TEXTURE_2D,We,Q,Oe[0].width,Oe[0].height);for(let Ge=0,Re=Oe.length;Ge<Re;Ge++)pe=Oe[Ge],q?me&&t.texSubImage2D(n.TEXTURE_2D,Ge,0,0,pe.width,pe.height,He,ht,pe.data):t.texImage2D(n.TEXTURE_2D,Ge,Q,pe.width,pe.height,0,He,ht,pe.data);U.generateMipmaps=!1}else q?(Ve&&t.texStorage2D(n.TEXTURE_2D,We,Q,Ie.width,Ie.height),me&&gt(U,Ie,He,ht)):t.texImage2D(n.TEXTURE_2D,0,Q,Ie.width,Ie.height,0,He,ht,Ie.data);else if(U.isCompressedTexture)if(U.isCompressedArrayTexture){q&&Ve&&t.texStorage3D(n.TEXTURE_2D_ARRAY,We,Q,Oe[0].width,Oe[0].height,Ie.depth);for(let Ge=0,Re=Oe.length;Ge<Re;Ge++)if(pe=Oe[Ge],U.format!==Jn)if(He!==null)if(q){if(me)if(U.layerUpdates.size>0){const rt=fE(pe.width,pe.height,U.format,U.type);for(const yt of U.layerUpdates){const Gt=pe.data.subarray(yt*rt/pe.data.BYTES_PER_ELEMENT,(yt+1)*rt/pe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ge,0,0,yt,pe.width,pe.height,1,He,Gt)}U.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ge,0,0,0,pe.width,pe.height,Ie.depth,He,pe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Ge,Q,pe.width,pe.height,Ie.depth,0,pe.data,0,0);else ut("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else q?me&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Ge,0,0,0,pe.width,pe.height,Ie.depth,He,ht,pe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Ge,Q,pe.width,pe.height,Ie.depth,0,He,ht,pe.data)}else{q&&Ve&&t.texStorage2D(n.TEXTURE_2D,We,Q,Oe[0].width,Oe[0].height);for(let Ge=0,Re=Oe.length;Ge<Re;Ge++)pe=Oe[Ge],U.format!==Jn?He!==null?q?me&&t.compressedTexSubImage2D(n.TEXTURE_2D,Ge,0,0,pe.width,pe.height,He,pe.data):t.compressedTexImage2D(n.TEXTURE_2D,Ge,Q,pe.width,pe.height,0,pe.data):ut("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):q?me&&t.texSubImage2D(n.TEXTURE_2D,Ge,0,0,pe.width,pe.height,He,ht,pe.data):t.texImage2D(n.TEXTURE_2D,Ge,Q,pe.width,pe.height,0,He,ht,pe.data)}else if(U.isDataArrayTexture)if(q){if(Ve&&t.texStorage3D(n.TEXTURE_2D_ARRAY,We,Q,Ie.width,Ie.height,Ie.depth),me)if(U.layerUpdates.size>0){const Ge=fE(Ie.width,Ie.height,U.format,U.type);for(const Re of U.layerUpdates){const rt=Ie.data.subarray(Re*Ge/Ie.data.BYTES_PER_ELEMENT,(Re+1)*Ge/Ie.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Re,Ie.width,Ie.height,1,He,ht,rt)}U.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ie.width,Ie.height,Ie.depth,He,ht,Ie.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Q,Ie.width,Ie.height,Ie.depth,0,He,ht,Ie.data);else if(U.isData3DTexture)q?(Ve&&t.texStorage3D(n.TEXTURE_3D,We,Q,Ie.width,Ie.height,Ie.depth),me&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ie.width,Ie.height,Ie.depth,He,ht,Ie.data)):t.texImage3D(n.TEXTURE_3D,0,Q,Ie.width,Ie.height,Ie.depth,0,He,ht,Ie.data);else if(U.isFramebufferTexture){if(Ve)if(q)t.texStorage2D(n.TEXTURE_2D,We,Q,Ie.width,Ie.height);else{let Ge=Ie.width,Re=Ie.height;for(let rt=0;rt<We;rt++)t.texImage2D(n.TEXTURE_2D,rt,Q,Ge,Re,0,He,ht,null),Ge>>=1,Re>>=1}}else if(Oe.length>0){if(q&&Ve){const Ge=ct(Oe[0]);t.texStorage2D(n.TEXTURE_2D,We,Q,Ge.width,Ge.height)}for(let Ge=0,Re=Oe.length;Ge<Re;Ge++)pe=Oe[Ge],q?me&&t.texSubImage2D(n.TEXTURE_2D,Ge,0,0,He,ht,pe):t.texImage2D(n.TEXTURE_2D,Ge,Q,He,ht,pe);U.generateMipmaps=!1}else if(q){if(Ve){const Ge=ct(Ie);t.texStorage2D(n.TEXTURE_2D,We,Q,Ge.width,Ge.height)}me&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,He,ht,Ie)}else t.texImage2D(n.TEXTURE_2D,0,Q,He,ht,Ie);S(U)&&v(Ee),vt.__version=ye.version,U.onUpdate&&U.onUpdate(U)}k.__version=U.version}function Ae(k,U,ce){if(U.image.length!==6)return;const Ee=nt(k,U),Le=U.source;t.bindTexture(n.TEXTURE_CUBE_MAP,k.__webglTexture,n.TEXTURE0+ce);const ye=i.get(Le);if(Le.version!==ye.__version||Ee===!0){t.activeTexture(n.TEXTURE0+ce);const vt=rn.getPrimaries(rn.workingColorSpace),qe=U.colorSpace===Na?null:rn.getPrimaries(U.colorSpace),_t=U.colorSpace===Na||vt===qe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,U.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,U.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,_t);const pt=U.isCompressedTexture||U.image[0].isCompressedTexture,Ie=U.image[0]&&U.image[0].isDataTexture,He=[];for(let Re=0;Re<6;Re++)!pt&&!Ie?He[Re]=T(U.image[Re],!0,a.maxCubemapSize):He[Re]=Ie?U.image[Re].image:U.image[Re],He[Re]=Je(U,He[Re]);const ht=He[0],Q=r.convert(U.format,U.colorSpace),pe=r.convert(U.type),Oe=E(U.internalFormat,Q,pe,U.colorSpace),q=U.isVideoTexture!==!0,Ve=ye.__version===void 0||Ee===!0,me=Le.dataReady;let We=D(U,ht);Xe(n.TEXTURE_CUBE_MAP,U);let Ge;if(pt){q&&Ve&&t.texStorage2D(n.TEXTURE_CUBE_MAP,We,Oe,ht.width,ht.height);for(let Re=0;Re<6;Re++){Ge=He[Re].mipmaps;for(let rt=0;rt<Ge.length;rt++){const yt=Ge[rt];U.format!==Jn?Q!==null?q?me&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt,0,0,yt.width,yt.height,Q,yt.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt,Oe,yt.width,yt.height,0,yt.data):ut("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt,0,0,yt.width,yt.height,Q,pe,yt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt,Oe,yt.width,yt.height,0,Q,pe,yt.data)}}}else{if(Ge=U.mipmaps,q&&Ve){Ge.length>0&&We++;const Re=ct(He[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,We,Oe,Re.width,Re.height)}for(let Re=0;Re<6;Re++)if(Ie){q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,He[Re].width,He[Re].height,Q,pe,He[Re].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,Oe,He[Re].width,He[Re].height,0,Q,pe,He[Re].data);for(let rt=0;rt<Ge.length;rt++){const Gt=Ge[rt].image[Re].image;q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt+1,0,0,Gt.width,Gt.height,Q,pe,Gt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt+1,Oe,Gt.width,Gt.height,0,Q,pe,Gt.data)}}else{q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,Q,pe,He[Re]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,Oe,Q,pe,He[Re]);for(let rt=0;rt<Ge.length;rt++){const yt=Ge[rt];q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt+1,0,0,Q,pe,yt.image[Re]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,rt+1,Oe,Q,pe,yt.image[Re])}}}S(U)&&v(n.TEXTURE_CUBE_MAP),ye.__version=Le.version,U.onUpdate&&U.onUpdate(U)}k.__version=U.version}function Ze(k,U,ce,Ee,Le,ye){const vt=r.convert(ce.format,ce.colorSpace),qe=r.convert(ce.type),_t=E(ce.internalFormat,vt,qe,ce.colorSpace),pt=i.get(U),Ie=i.get(ce);if(Ie.__renderTarget=U,!pt.__hasExternalTextures){const He=Math.max(1,U.width>>ye),ht=Math.max(1,U.height>>ye);Le===n.TEXTURE_3D||Le===n.TEXTURE_2D_ARRAY?t.texImage3D(Le,ye,_t,He,ht,U.depth,0,vt,qe,null):t.texImage2D(Le,ye,_t,He,ht,0,vt,qe,null)}t.bindFramebuffer(n.FRAMEBUFFER,k),Be(U)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ee,Le,Ie.__webglTexture,0,Fe(U)):(Le===n.TEXTURE_2D||Le>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Le<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Ee,Le,Ie.__webglTexture,ye),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ue(k,U,ce){if(n.bindRenderbuffer(n.RENDERBUFFER,k),U.depthBuffer){const Ee=U.depthTexture,Le=Ee&&Ee.isDepthTexture?Ee.type:null,ye=b(U.stencilBuffer,Le),vt=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,qe=Fe(U);Be(U)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,qe,ye,U.width,U.height):ce?n.renderbufferStorageMultisample(n.RENDERBUFFER,qe,ye,U.width,U.height):n.renderbufferStorage(n.RENDERBUFFER,ye,U.width,U.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,vt,n.RENDERBUFFER,k)}else{const Ee=U.textures;for(let Le=0;Le<Ee.length;Le++){const ye=Ee[Le],vt=r.convert(ye.format,ye.colorSpace),qe=r.convert(ye.type),_t=E(ye.internalFormat,vt,qe,ye.colorSpace),pt=Fe(U);ce&&Be(U)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,pt,_t,U.width,U.height):Be(U)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,pt,_t,U.width,U.height):n.renderbufferStorage(n.RENDERBUFFER,_t,U.width,U.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function it(k,U){if(U&&U.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,k),!(U.depthTexture&&U.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Ee=i.get(U.depthTexture);Ee.__renderTarget=U,(!Ee.__webglTexture||U.depthTexture.image.width!==U.width||U.depthTexture.image.height!==U.height)&&(U.depthTexture.image.width=U.width,U.depthTexture.image.height=U.height,U.depthTexture.needsUpdate=!0),re(U.depthTexture,0);const Le=Ee.__webglTexture,ye=Fe(U);if(U.depthTexture.format===_d)Be(U)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Le,0,ye):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Le,0);else if(U.depthTexture.format===Yu)Be(U)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Le,0,ye):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Le,0);else throw new Error("Unknown depthTexture format")}function Mt(k){const U=i.get(k),ce=k.isWebGLCubeRenderTarget===!0;if(U.__boundDepthTexture!==k.depthTexture){const Ee=k.depthTexture;if(U.__depthDisposeCallback&&U.__depthDisposeCallback(),Ee){const Le=()=>{delete U.__boundDepthTexture,delete U.__depthDisposeCallback,Ee.removeEventListener("dispose",Le)};Ee.addEventListener("dispose",Le),U.__depthDisposeCallback=Le}U.__boundDepthTexture=Ee}if(k.depthTexture&&!U.__autoAllocateDepthBuffer){if(ce)throw new Error("target.depthTexture not supported in Cube render targets");const Ee=k.texture.mipmaps;Ee&&Ee.length>0?it(U.__webglFramebuffer[0],k):it(U.__webglFramebuffer,k)}else if(ce){U.__webglDepthbuffer=[];for(let Ee=0;Ee<6;Ee++)if(t.bindFramebuffer(n.FRAMEBUFFER,U.__webglFramebuffer[Ee]),U.__webglDepthbuffer[Ee]===void 0)U.__webglDepthbuffer[Ee]=n.createRenderbuffer(),ue(U.__webglDepthbuffer[Ee],k,!1);else{const Le=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ye=U.__webglDepthbuffer[Ee];n.bindRenderbuffer(n.RENDERBUFFER,ye),n.framebufferRenderbuffer(n.FRAMEBUFFER,Le,n.RENDERBUFFER,ye)}}else{const Ee=k.texture.mipmaps;if(Ee&&Ee.length>0?t.bindFramebuffer(n.FRAMEBUFFER,U.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,U.__webglFramebuffer),U.__webglDepthbuffer===void 0)U.__webglDepthbuffer=n.createRenderbuffer(),ue(U.__webglDepthbuffer,k,!1);else{const Le=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ye=U.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,ye),n.framebufferRenderbuffer(n.FRAMEBUFFER,Le,n.RENDERBUFFER,ye)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function ot(k,U,ce){const Ee=i.get(k);U!==void 0&&Ze(Ee.__webglFramebuffer,k,k.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ce!==void 0&&Mt(k)}function Ke(k){const U=k.texture,ce=i.get(k),Ee=i.get(U);k.addEventListener("dispose",I);const Le=k.textures,ye=k.isWebGLCubeRenderTarget===!0,vt=Le.length>1;if(vt||(Ee.__webglTexture===void 0&&(Ee.__webglTexture=n.createTexture()),Ee.__version=U.version,s.memory.textures++),ye){ce.__webglFramebuffer=[];for(let qe=0;qe<6;qe++)if(U.mipmaps&&U.mipmaps.length>0){ce.__webglFramebuffer[qe]=[];for(let _t=0;_t<U.mipmaps.length;_t++)ce.__webglFramebuffer[qe][_t]=n.createFramebuffer()}else ce.__webglFramebuffer[qe]=n.createFramebuffer()}else{if(U.mipmaps&&U.mipmaps.length>0){ce.__webglFramebuffer=[];for(let qe=0;qe<U.mipmaps.length;qe++)ce.__webglFramebuffer[qe]=n.createFramebuffer()}else ce.__webglFramebuffer=n.createFramebuffer();if(vt)for(let qe=0,_t=Le.length;qe<_t;qe++){const pt=i.get(Le[qe]);pt.__webglTexture===void 0&&(pt.__webglTexture=n.createTexture(),s.memory.textures++)}if(k.samples>0&&Be(k)===!1){ce.__webglMultisampledFramebuffer=n.createFramebuffer(),ce.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ce.__webglMultisampledFramebuffer);for(let qe=0;qe<Le.length;qe++){const _t=Le[qe];ce.__webglColorRenderbuffer[qe]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ce.__webglColorRenderbuffer[qe]);const pt=r.convert(_t.format,_t.colorSpace),Ie=r.convert(_t.type),He=E(_t.internalFormat,pt,Ie,_t.colorSpace,k.isXRRenderTarget===!0),ht=Fe(k);n.renderbufferStorageMultisample(n.RENDERBUFFER,ht,He,k.width,k.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+qe,n.RENDERBUFFER,ce.__webglColorRenderbuffer[qe])}n.bindRenderbuffer(n.RENDERBUFFER,null),k.depthBuffer&&(ce.__webglDepthRenderbuffer=n.createRenderbuffer(),ue(ce.__webglDepthRenderbuffer,k,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(ye){t.bindTexture(n.TEXTURE_CUBE_MAP,Ee.__webglTexture),Xe(n.TEXTURE_CUBE_MAP,U);for(let qe=0;qe<6;qe++)if(U.mipmaps&&U.mipmaps.length>0)for(let _t=0;_t<U.mipmaps.length;_t++)Ze(ce.__webglFramebuffer[qe][_t],k,U,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+qe,_t);else Ze(ce.__webglFramebuffer[qe],k,U,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+qe,0);S(U)&&v(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(vt){for(let qe=0,_t=Le.length;qe<_t;qe++){const pt=Le[qe],Ie=i.get(pt);let He=n.TEXTURE_2D;(k.isWebGL3DRenderTarget||k.isWebGLArrayRenderTarget)&&(He=k.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(He,Ie.__webglTexture),Xe(He,pt),Ze(ce.__webglFramebuffer,k,pt,n.COLOR_ATTACHMENT0+qe,He,0),S(pt)&&v(He)}t.unbindTexture()}else{let qe=n.TEXTURE_2D;if((k.isWebGL3DRenderTarget||k.isWebGLArrayRenderTarget)&&(qe=k.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(qe,Ee.__webglTexture),Xe(qe,U),U.mipmaps&&U.mipmaps.length>0)for(let _t=0;_t<U.mipmaps.length;_t++)Ze(ce.__webglFramebuffer[_t],k,U,n.COLOR_ATTACHMENT0,qe,_t);else Ze(ce.__webglFramebuffer,k,U,n.COLOR_ATTACHMENT0,qe,0);S(U)&&v(qe),t.unbindTexture()}k.depthBuffer&&Mt(k)}function Te(k){const U=k.textures;for(let ce=0,Ee=U.length;ce<Ee;ce++){const Le=U[ce];if(S(Le)){const ye=y(k),vt=i.get(Le).__webglTexture;t.bindTexture(ye,vt),v(ye),t.unbindTexture()}}}const G=[],Me=[];function De(k){if(k.samples>0){if(Be(k)===!1){const U=k.textures,ce=k.width,Ee=k.height;let Le=n.COLOR_BUFFER_BIT;const ye=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,vt=i.get(k),qe=U.length>1;if(qe)for(let pt=0;pt<U.length;pt++)t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,vt.__webglMultisampledFramebuffer);const _t=k.texture.mipmaps;_t&&_t.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,vt.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,vt.__webglFramebuffer);for(let pt=0;pt<U.length;pt++){if(k.resolveDepthBuffer&&(k.depthBuffer&&(Le|=n.DEPTH_BUFFER_BIT),k.stencilBuffer&&k.resolveStencilBuffer&&(Le|=n.STENCIL_BUFFER_BIT)),qe){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,vt.__webglColorRenderbuffer[pt]);const Ie=i.get(U[pt]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ie,0)}n.blitFramebuffer(0,0,ce,Ee,0,0,ce,Ee,Le,n.NEAREST),c===!0&&(G.length=0,Me.length=0,G.push(n.COLOR_ATTACHMENT0+pt),k.depthBuffer&&k.resolveDepthBuffer===!1&&(G.push(ye),Me.push(ye),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Me)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,G))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),qe)for(let pt=0;pt<U.length;pt++){t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.RENDERBUFFER,vt.__webglColorRenderbuffer[pt]);const Ie=i.get(U[pt]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.TEXTURE_2D,Ie,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,vt.__webglMultisampledFramebuffer)}else if(k.depthBuffer&&k.resolveDepthBuffer===!1&&c){const U=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[U])}}}function Fe(k){return Math.min(a.maxSamples,k.samples)}function Be(k){const U=i.get(k);return k.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&U.__useRenderToTexture!==!1}function $e(k){const U=s.render.frame;f.get(k)!==U&&(f.set(k,U),k.update())}function Je(k,U){const ce=k.colorSpace,Ee=k.format,Le=k.type;return k.isCompressedTexture===!0||k.isVideoTexture===!0||ce!==Wn&&ce!==Na&&(rn.getTransfer(ce)===Rn?(Ee!==Jn||Le!==Ii)&&ut("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Bt("WebGLTextures: Unsupported texture color space:",ce)),U}function ct(k){return typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement?(h.width=k.naturalWidth||k.width,h.height=k.naturalHeight||k.height):typeof VideoFrame<"u"&&k instanceof VideoFrame?(h.width=k.displayWidth,h.height=k.displayHeight):(h.width=k.width,h.height=k.height),h}this.allocateTextureUnit=ee,this.resetTextureUnits=j,this.setTexture2D=re,this.setTexture2DArray=W,this.setTexture3D=te,this.setTextureCube=K,this.rebindTextures=ot,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=De,this.setupDepthRenderbuffer=Mt,this.setupFrameBufferTexture=Ze,this.useMultisampledRTT=Be}function B6(n,e){function t(i,a=Na){let r;const s=rn.getTransfer(a);if(i===Ii)return n.UNSIGNED_BYTE;if(i===N1)return n.UNSIGNED_SHORT_4_4_4_4;if(i===D1)return n.UNSIGNED_SHORT_5_5_5_1;if(i===ub)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===hb)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===w1)return n.BYTE;if(i===C1)return n.SHORT;if(i===Wu)return n.UNSIGNED_SHORT;if(i===D0)return n.INT;if(i===Ns)return n.UNSIGNED_INT;if(i===ri)return n.FLOAT;if(i===Xn)return n.HALF_FLOAT;if(i===fb)return n.ALPHA;if(i===db)return n.RGB;if(i===Jn)return n.RGBA;if(i===_d)return n.DEPTH_COMPONENT;if(i===Yu)return n.DEPTH_STENCIL;if(i===bs)return n.RED;if(i===O0)return n.RED_INTEGER;if(i===Vo)return n.RG;if(i===O1)return n.RG_INTEGER;if(i===L1)return n.RGBA_INTEGER;if(i===Nm||i===Dm||i===Om||i===Lm)if(s===Rn)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Nm)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Dm)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Om)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Lm)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Nm)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Dm)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Om)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Lm)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===rx||i===sx||i===ox||i===lx)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===rx)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===sx)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ox)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===lx)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===cx||i===ux||i===hx)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===cx||i===ux)return s===Rn?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===hx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===fx||i===dx||i===px||i===mx||i===gx||i===vx||i===_x||i===xx||i===yx||i===Sx||i===Tx||i===Ex||i===Mx||i===bx)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===fx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===dx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===px)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===mx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===gx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===vx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===_x)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===xx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===yx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Sx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Tx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ex)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Mx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===bx)return s===Rn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ax||i===Rx||i===wx)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Ax)return s===Rn?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Rx)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===wx)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Cx||i===Nx||i===Dx||i===Ox)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Cx)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Nx)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Dx)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Ox)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Xu?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const oj=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,lj=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
void main() {
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
if ( coord.x >= 1.0 ) {
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
} else {
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
}
}`;class cj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Ab(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Fi({vertexShader:oj,fragmentShader:lj,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new si(new lh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class uj extends tr{constructor(e,t){super();const i=this;let a=null,r=1,s=null,o="local-floor",c=1,h=null,f=null,d=null,m=null,g=null,x=null;const T=typeof XRWebGLBinding<"u",S=new cj,v={},y=t.getContextAttributes();let E=null,b=null;const D=[],C=[],I=new de;let P=null;const O=new ui;O.viewport=new zt;const R=new ui;R.viewport=new zt;const B=[O,R],j=new b6;let ee=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ge){let Ae=D[ge];return Ae===void 0&&(Ae=new p_,D[ge]=Ae),Ae.getTargetRaySpace()},this.getControllerGrip=function(ge){let Ae=D[ge];return Ae===void 0&&(Ae=new p_,D[ge]=Ae),Ae.getGripSpace()},this.getHand=function(ge){let Ae=D[ge];return Ae===void 0&&(Ae=new p_,D[ge]=Ae),Ae.getHandSpace()};function re(ge){const Ae=C.indexOf(ge.inputSource);if(Ae===-1)return;const Ze=D[Ae];Ze!==void 0&&(Ze.update(ge.inputSource,ge.frame,h||s),Ze.dispatchEvent({type:ge.type,data:ge.inputSource}))}function W(){a.removeEventListener("select",re),a.removeEventListener("selectstart",re),a.removeEventListener("selectend",re),a.removeEventListener("squeeze",re),a.removeEventListener("squeezestart",re),a.removeEventListener("squeezeend",re),a.removeEventListener("end",W),a.removeEventListener("inputsourceschange",te);for(let ge=0;ge<D.length;ge++){const Ae=C[ge];Ae!==null&&(C[ge]=null,D[ge].disconnect(Ae))}ee=null,se=null,S.reset();for(const ge in v)delete v[ge];e.setRenderTarget(E),g=null,m=null,d=null,a=null,b=null,gt.stop(),i.isPresenting=!1,e.setPixelRatio(P),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ge){r=ge,i.isPresenting===!0&&ut("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ge){o=ge,i.isPresenting===!0&&ut("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||s},this.setReferenceSpace=function(ge){h=ge},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return d===null&&T&&(d=new XRWebGLBinding(a,t)),d},this.getFrame=function(){return x},this.getSession=function(){return a},this.setSession=async function(ge){if(a=ge,a!==null){if(E=e.getRenderTarget(),a.addEventListener("select",re),a.addEventListener("selectstart",re),a.addEventListener("selectend",re),a.addEventListener("squeeze",re),a.addEventListener("squeezestart",re),a.addEventListener("squeezeend",re),a.addEventListener("end",W),a.addEventListener("inputsourceschange",te),y.xrCompatible!==!0&&await t.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(I),T&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ze=null,ue=null,it=null;y.depth&&(it=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ze=y.stencil?Yu:_d,ue=y.stencil?Xu:Ns);const Mt={colorFormat:t.RGBA8,depthFormat:it,scaleFactor:r};d=this.getBinding(),m=d.createProjectionLayer(Mt),a.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),b=new _i(m.textureWidth,m.textureHeight,{format:Jn,type:Ii,depthTexture:new U0(m.textureWidth,m.textureHeight,ue,void 0,void 0,void 0,void 0,void 0,void 0,Ze),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Ze={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:r};g=new XRWebGLLayer(a,t,Ze),a.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),b=new _i(g.framebufferWidth,g.framebufferHeight,{format:Jn,type:Ii,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(c),h=null,s=await a.requestReferenceSpace(o),gt.setContext(a),gt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(a!==null)return a.environmentBlendMode},this.getDepthTexture=function(){return S.getDepthTexture()};function te(ge){for(let Ae=0;Ae<ge.removed.length;Ae++){const Ze=ge.removed[Ae],ue=C.indexOf(Ze);ue>=0&&(C[ue]=null,D[ue].disconnect(Ze))}for(let Ae=0;Ae<ge.added.length;Ae++){const Ze=ge.added[Ae];let ue=C.indexOf(Ze);if(ue===-1){for(let Mt=0;Mt<D.length;Mt++)if(Mt>=C.length){C.push(Ze),ue=Mt;break}else if(C[Mt]===null){C[Mt]=Ze,ue=Mt;break}if(ue===-1)break}const it=D[ue];it&&it.connect(Ze)}}const K=new L,oe=new L;function ie(ge,Ae,Ze){K.setFromMatrixPosition(Ae.matrixWorld),oe.setFromMatrixPosition(Ze.matrixWorld);const ue=K.distanceTo(oe),it=Ae.projectionMatrix.elements,Mt=Ze.projectionMatrix.elements,ot=it[14]/(it[10]-1),Ke=it[14]/(it[10]+1),Te=(it[9]+1)/it[5],G=(it[9]-1)/it[5],Me=(it[8]-1)/it[0],De=(Mt[8]+1)/Mt[0],Fe=ot*Me,Be=ot*De,$e=ue/(-Me+De),Je=$e*-Me;if(Ae.matrixWorld.decompose(ge.position,ge.quaternion,ge.scale),ge.translateX(Je),ge.translateZ($e),ge.matrixWorld.compose(ge.position,ge.quaternion,ge.scale),ge.matrixWorldInverse.copy(ge.matrixWorld).invert(),it[10]===-1)ge.projectionMatrix.copy(Ae.projectionMatrix),ge.projectionMatrixInverse.copy(Ae.projectionMatrixInverse);else{const ct=ot+$e,k=Ke+$e,U=Fe-Je,ce=Be+(ue-Je),Ee=Te*Ke/k*ct,Le=G*Ke/k*ct;ge.projectionMatrix.makePerspective(U,ce,Ee,Le,ct,k),ge.projectionMatrixInverse.copy(ge.projectionMatrix).invert()}}function Ce(ge,Ae){Ae===null?ge.matrixWorld.copy(ge.matrix):ge.matrixWorld.multiplyMatrices(Ae.matrixWorld,ge.matrix),ge.matrixWorldInverse.copy(ge.matrixWorld).invert()}this.updateCamera=function(ge){if(a===null)return;let Ae=ge.near,Ze=ge.far;S.texture!==null&&(S.depthNear>0&&(Ae=S.depthNear),S.depthFar>0&&(Ze=S.depthFar)),j.near=R.near=O.near=Ae,j.far=R.far=O.far=Ze,(ee!==j.near||se!==j.far)&&(a.updateRenderState({depthNear:j.near,depthFar:j.far}),ee=j.near,se=j.far),j.layers.mask=ge.layers.mask|6,O.layers.mask=j.layers.mask&3,R.layers.mask=j.layers.mask&5;const ue=ge.parent,it=j.cameras;Ce(j,ue);for(let Mt=0;Mt<it.length;Mt++)Ce(it[Mt],ue);it.length===2?ie(j,O,R):j.projectionMatrix.copy(O.projectionMatrix),Xe(ge,j,ue)};function Xe(ge,Ae,Ze){Ze===null?ge.matrix.copy(Ae.matrixWorld):(ge.matrix.copy(Ze.matrixWorld),ge.matrix.invert(),ge.matrix.multiply(Ae.matrixWorld)),ge.matrix.decompose(ge.position,ge.quaternion,ge.scale),ge.updateMatrixWorld(!0),ge.projectionMatrix.copy(Ae.projectionMatrix),ge.projectionMatrixInverse.copy(Ae.projectionMatrixInverse),ge.isPerspectiveCamera&&(ge.fov=Ed*2*Math.atan(1/ge.projectionMatrix.elements[5]),ge.zoom=1)}this.getCamera=function(){return j},this.getFoveation=function(){if(!(m===null&&g===null))return c},this.setFoveation=function(ge){c=ge,m!==null&&(m.fixedFoveation=ge),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=ge)},this.hasDepthSensing=function(){return S.texture!==null},this.getDepthSensingMesh=function(){return S.getMesh(j)},this.getCameraTexture=function(ge){return v[ge]};let nt=null;function tt(ge,Ae){if(f=Ae.getViewerPose(h||s),x=Ae,f!==null){const Ze=f.views;g!==null&&(e.setRenderTargetFramebuffer(b,g.framebuffer),e.setRenderTarget(b));let ue=!1;Ze.length!==j.cameras.length&&(j.cameras.length=0,ue=!0);for(let Ke=0;Ke<Ze.length;Ke++){const Te=Ze[Ke];let G=null;if(g!==null)G=g.getViewport(Te);else{const De=d.getViewSubImage(m,Te);G=De.viewport,Ke===0&&(e.setRenderTargetTextures(b,De.colorTexture,De.depthStencilTexture),e.setRenderTarget(b))}let Me=B[Ke];Me===void 0&&(Me=new ui,Me.layers.enable(Ke),Me.viewport=new zt,B[Ke]=Me),Me.matrix.fromArray(Te.transform.matrix),Me.matrix.decompose(Me.position,Me.quaternion,Me.scale),Me.projectionMatrix.fromArray(Te.projectionMatrix),Me.projectionMatrixInverse.copy(Me.projectionMatrix).invert(),Me.viewport.set(G.x,G.y,G.width,G.height),Ke===0&&(j.matrix.copy(Me.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale)),ue===!0&&j.cameras.push(Me)}const it=a.enabledFeatures;if(it&&it.includes("depth-sensing")&&a.depthUsage=="gpu-optimized"&&T){d=i.getBinding();const Ke=d.getDepthInformation(Ze[0]);Ke&&Ke.isValid&&Ke.texture&&S.init(Ke,a.renderState)}if(it&&it.includes("camera-access")&&T){e.state.unbindTexture(),d=i.getBinding();for(let Ke=0;Ke<Ze.length;Ke++){const Te=Ze[Ke].camera;if(Te){let G=v[Te];G||(G=new Ab,v[Te]=G);const Me=d.getCameraImage(Te);G.sourceTexture=Me}}}}for(let Ze=0;Ze<D.length;Ze++){const ue=C[Ze],it=D[Ze];ue!==null&&it!==void 0&&it.update(ue,Ae,h||s)}nt&&nt(ge,Ae),Ae.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Ae}),x=null}const gt=new L6;gt.setAnimationLoop(tt),this.setAnimationLoop=function(ge){nt=ge},this.dispose=function(){}}}const ru=new Ui,hj=new ke;function fj(n,e){function t(S,v){S.matrixAutoUpdate===!0&&S.updateMatrix(),v.value.copy(S.matrix)}function i(S,v){v.color.getRGB(S.fogColor.value,HU(n)),v.isFog?(S.fogNear.value=v.near,S.fogFar.value=v.far):v.isFogExp2&&(S.fogDensity.value=v.density)}function a(S,v,y,E,b){v.isMeshBasicMaterial||v.isMeshLambertMaterial?r(S,v):v.isMeshToonMaterial?(r(S,v),d(S,v)):v.isMeshPhongMaterial?(r(S,v),f(S,v)):v.isMeshStandardMaterial?(r(S,v),m(S,v),v.isMeshPhysicalMaterial&&g(S,v,b)):v.isMeshMatcapMaterial?(r(S,v),x(S,v)):v.isMeshDepthMaterial?r(S,v):v.isMeshDistanceMaterial?(r(S,v),T(S,v)):v.isMeshNormalMaterial?r(S,v):v.isLineBasicMaterial?(s(S,v),v.isLineDashedMaterial&&o(S,v)):v.isPointsMaterial?c(S,v,y,E):v.isSpriteMaterial?h(S,v):v.isShadowMaterial?(S.color.value.copy(v.color),S.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function r(S,v){S.opacity.value=v.opacity,v.color&&S.diffuse.value.copy(v.color),v.emissive&&S.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(S.map.value=v.map,t(v.map,S.mapTransform)),v.alphaMap&&(S.alphaMap.value=v.alphaMap,t(v.alphaMap,S.alphaMapTransform)),v.bumpMap&&(S.bumpMap.value=v.bumpMap,t(v.bumpMap,S.bumpMapTransform),S.bumpScale.value=v.bumpScale,v.side===Oi&&(S.bumpScale.value*=-1)),v.normalMap&&(S.normalMap.value=v.normalMap,t(v.normalMap,S.normalMapTransform),S.normalScale.value.copy(v.normalScale),v.side===Oi&&S.normalScale.value.negate()),v.displacementMap&&(S.displacementMap.value=v.displacementMap,t(v.displacementMap,S.displacementMapTransform),S.displacementScale.value=v.displacementScale,S.displacementBias.value=v.displacementBias),v.emissiveMap&&(S.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,S.emissiveMapTransform)),v.specularMap&&(S.specularMap.value=v.specularMap,t(v.specularMap,S.specularMapTransform)),v.alphaTest>0&&(S.alphaTest.value=v.alphaTest);const y=e.get(v),E=y.envMap,b=y.envMapRotation;E&&(S.envMap.value=E,ru.copy(b),ru.x*=-1,ru.y*=-1,ru.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(ru.y*=-1,ru.z*=-1),S.envMapRotation.value.setFromMatrix4(hj.makeRotationFromEuler(ru)),S.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=v.reflectivity,S.ior.value=v.ior,S.refractionRatio.value=v.refractionRatio),v.lightMap&&(S.lightMap.value=v.lightMap,S.lightMapIntensity.value=v.lightMapIntensity,t(v.lightMap,S.lightMapTransform)),v.aoMap&&(S.aoMap.value=v.aoMap,S.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,S.aoMapTransform))}function s(S,v){S.diffuse.value.copy(v.color),S.opacity.value=v.opacity,v.map&&(S.map.value=v.map,t(v.map,S.mapTransform))}function o(S,v){S.dashSize.value=v.dashSize,S.totalSize.value=v.dashSize+v.gapSize,S.scale.value=v.scale}function c(S,v,y,E){S.diffuse.value.copy(v.color),S.opacity.value=v.opacity,S.size.value=v.size*y,S.scale.value=E*.5,v.map&&(S.map.value=v.map,t(v.map,S.uvTransform)),v.alphaMap&&(S.alphaMap.value=v.alphaMap,t(v.alphaMap,S.alphaMapTransform)),v.alphaTest>0&&(S.alphaTest.value=v.alphaTest)}function h(S,v){S.diffuse.value.copy(v.color),S.opacity.value=v.opacity,S.rotation.value=v.rotation,v.map&&(S.map.value=v.map,t(v.map,S.mapTransform)),v.alphaMap&&(S.alphaMap.value=v.alphaMap,t(v.alphaMap,S.alphaMapTransform)),v.alphaTest>0&&(S.alphaTest.value=v.alphaTest)}function f(S,v){S.specular.value.copy(v.specular),S.shininess.value=Math.max(v.shininess,1e-4)}function d(S,v){v.gradientMap&&(S.gradientMap.value=v.gradientMap)}function m(S,v){S.metalness.value=v.metalness,v.metalnessMap&&(S.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,S.metalnessMapTransform)),S.roughness.value=v.roughness,v.roughnessMap&&(S.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,S.roughnessMapTransform)),v.envMap&&(S.envMapIntensity.value=v.envMapIntensity)}function g(S,v,y){S.ior.value=v.ior,v.sheen>0&&(S.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),S.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(S.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,S.sheenColorMapTransform)),v.sheenRoughnessMap&&(S.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,S.sheenRoughnessMapTransform))),v.clearcoat>0&&(S.clearcoat.value=v.clearcoat,S.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(S.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,S.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(S.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Oi&&S.clearcoatNormalScale.value.negate())),v.dispersion>0&&(S.dispersion.value=v.dispersion),v.iridescence>0&&(S.iridescence.value=v.iridescence,S.iridescenceIOR.value=v.iridescenceIOR,S.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(S.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,S.iridescenceMapTransform)),v.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),v.transmission>0&&(S.transmission.value=v.transmission,S.transmissionSamplerMap.value=y.texture,S.transmissionSamplerSize.value.set(y.width,y.height),v.transmissionMap&&(S.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,S.transmissionMapTransform)),S.thickness.value=v.thickness,v.thicknessMap&&(S.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=v.attenuationDistance,S.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(S.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(S.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,S.anisotropyMapTransform))),S.specularIntensity.value=v.specularIntensity,S.specularColor.value.copy(v.specularColor),v.specularColorMap&&(S.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,S.specularColorMapTransform)),v.specularIntensityMap&&(S.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,S.specularIntensityMapTransform))}function x(S,v){v.matcap&&(S.matcap.value=v.matcap)}function T(S,v){const y=e.get(v).light;S.referencePosition.value.setFromMatrixPosition(y.matrixWorld),S.nearDistance.value=y.shadow.camera.near,S.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:a}}function dj(n,e,t,i){let a={},r={},s=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,E){const b=E.program;i.uniformBlockBinding(y,b)}function h(y,E){let b=a[y.id];b===void 0&&(x(y),b=f(y),a[y.id]=b,y.addEventListener("dispose",S));const D=E.program;i.updateUBOMapping(y,D);const C=e.render.frame;r[y.id]!==C&&(m(y),r[y.id]=C)}function f(y){const E=d();y.__bindingPointIndex=E;const b=n.createBuffer(),D=y.__size,C=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,D,C),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,E,b),b}function d(){for(let y=0;y<o;y++)if(s.indexOf(y)===-1)return s.push(y),y;return Bt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(y){const E=a[y.id],b=y.uniforms,D=y.__cache;n.bindBuffer(n.UNIFORM_BUFFER,E);for(let C=0,I=b.length;C<I;C++){const P=Array.isArray(b[C])?b[C]:[b[C]];for(let O=0,R=P.length;O<R;O++){const B=P[O];if(g(B,C,O,D)===!0){const j=B.__offset,ee=Array.isArray(B.value)?B.value:[B.value];let se=0;for(let re=0;re<ee.length;re++){const W=ee[re],te=T(W);typeof W=="number"||typeof W=="boolean"?(B.__data[0]=W,n.bufferSubData(n.UNIFORM_BUFFER,j+se,B.__data)):W.isMatrix3?(B.__data[0]=W.elements[0],B.__data[1]=W.elements[1],B.__data[2]=W.elements[2],B.__data[3]=0,B.__data[4]=W.elements[3],B.__data[5]=W.elements[4],B.__data[6]=W.elements[5],B.__data[7]=0,B.__data[8]=W.elements[6],B.__data[9]=W.elements[7],B.__data[10]=W.elements[8],B.__data[11]=0):(W.toArray(B.__data,se),se+=te.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,j,B.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function g(y,E,b,D){const C=y.value,I=E+"_"+b;if(D[I]===void 0)return typeof C=="number"||typeof C=="boolean"?D[I]=C:D[I]=C.clone(),!0;{const P=D[I];if(typeof C=="number"||typeof C=="boolean"){if(P!==C)return D[I]=C,!0}else if(P.equals(C)===!1)return P.copy(C),!0}return!1}function x(y){const E=y.uniforms;let b=0;const D=16;for(let I=0,P=E.length;I<P;I++){const O=Array.isArray(E[I])?E[I]:[E[I]];for(let R=0,B=O.length;R<B;R++){const j=O[R],ee=Array.isArray(j.value)?j.value:[j.value];for(let se=0,re=ee.length;se<re;se++){const W=ee[se],te=T(W),K=b%D,oe=K%te.boundary,ie=K+oe;b+=oe,ie!==0&&D-ie<te.storage&&(b+=D-ie),j.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=b,b+=te.storage}}}const C=b%D;return C>0&&(b+=D-C),y.__size=b,y.__cache={},this}function T(y){const E={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(E.boundary=4,E.storage=4):y.isVector2?(E.boundary=8,E.storage=8):y.isVector3||y.isColor?(E.boundary=16,E.storage=12):y.isVector4?(E.boundary=16,E.storage=16):y.isMatrix3?(E.boundary=48,E.storage=48):y.isMatrix4?(E.boundary=64,E.storage=64):y.isTexture?ut("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ut("WebGLRenderer: Unsupported uniform value type.",y),E}function S(y){const E=y.target;E.removeEventListener("dispose",S);const b=s.indexOf(E.__bindingPointIndex);s.splice(b,1),n.deleteBuffer(a[E.id]),delete a[E.id],delete r[E.id]}function v(){for(const y in a)n.deleteBuffer(a[y]);s=[],a={},r={}}return{bind:c,update:h,dispose:v}}const pj=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Lo=null;function mj(){return Lo===null&&(Lo=new Ja(pj,32,32,Vo,Xn),Lo.minFilter=Ht,Lo.magFilter=Ht,Lo.wrapS=Li,Lo.wrapT=Li,Lo.generateMipmaps=!1,Lo.needsUpdate=!0),Lo}class Kb{constructor(e={}){const{canvas:t=IU(),context:i=null,depth:a=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:h=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:m=!1}=e;this.isWebGLRenderer=!0;let g;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=i.getContextAttributes().alpha}else g=s;const x=new Set([L1,O1,O0]),T=new Set([Ii,Ns,Wu,Xu,N1,D1]),S=new Uint32Array(4),v=new Int32Array(4);let y=null,E=null;const b=[],D=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ns,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let I=!1;this._outputColorSpace=En;let P=0,O=0,R=null,B=-1,j=null;const ee=new zt,se=new zt;let re=null;const W=new je(0);let te=0,K=t.width,oe=t.height,ie=1,Ce=null,Xe=null;const nt=new zt(0,0,K,oe),tt=new zt(0,0,K,oe);let gt=!1;const ge=new Wd;let Ae=!1,Ze=!1;const ue=new ke,it=new L,Mt=new zt,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function Te(){return R===null?ie:1}let G=i;function Me(N,V){return t.getContext(N,V)}try{const N={alpha:!0,depth:a,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:h,powerPreference:f,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ws}`),t.addEventListener("webglcontextlost",Ge,!1),t.addEventListener("webglcontextrestored",Re,!1),t.addEventListener("webglcontextcreationerror",rt,!1),G===null){const V="webgl2";if(G=Me(V,N),G===null)throw Me(V)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(N){throw N("WebGLRenderer: "+N.message),N}let De,Fe,Be,$e,Je,ct,k,U,ce,Ee,Le,ye,vt,qe,_t,pt,Ie,He,ht,Q,pe,Oe,q,Ve;function me(){De=new bY(G),De.init(),Oe=new B6(G,De),Fe=new gY(G,De,e,Oe),Be=new rj(G,De),Fe.reversedDepthBuffer&&m&&Be.buffers.depth.setReversed(!0),$e=new wY(G),Je=new Yq,ct=new sj(G,De,Be,Je,Fe,Oe,$e),k=new _Y(C),U=new MY(C),ce=new Ok(G),q=new pY(G,ce),Ee=new AY(G,ce,$e,q),Le=new NY(G,Ee,ce,$e),ht=new CY(G,Fe,ct),pt=new vY(Je),ye=new Xq(C,k,U,De,Fe,q,pt),vt=new fj(C,Je),qe=new jq,_t=new ej(De),He=new dY(C,k,U,Be,Le,g,c),Ie=new ij(C,Le,Fe),Ve=new dj(G,$e,Fe,Be),Q=new mY(G,De,$e),pe=new RY(G,De,$e),$e.programs=ye.programs,C.capabilities=Fe,C.extensions=De,C.properties=Je,C.renderLists=qe,C.shadowMap=Ie,C.state=Be,C.info=$e}me();const We=new uj(C,G);this.xr=We,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){const N=De.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){const N=De.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(N){N!==void 0&&(ie=N,this.setSize(K,oe,!1))},this.getSize=function(N){return N.set(K,oe)},this.setSize=function(N,V,Z=!0){if(We.isPresenting){ut("WebGLRenderer: Can't change size while VR device is presenting.");return}K=N,oe=V,t.width=Math.floor(N*ie),t.height=Math.floor(V*ie),Z===!0&&(t.style.width=N+"px",t.style.height=V+"px"),this.setViewport(0,0,N,V)},this.getDrawingBufferSize=function(N){return N.set(K*ie,oe*ie).floor()},this.setDrawingBufferSize=function(N,V,Z){K=N,oe=V,ie=Z,t.width=Math.floor(N*Z),t.height=Math.floor(V*Z),this.setViewport(0,0,N,V)},this.getCurrentViewport=function(N){return N.copy(ee)},this.getViewport=function(N){return N.copy(nt)},this.setViewport=function(N,V,Z,H){N.isVector4?nt.set(N.x,N.y,N.z,N.w):nt.set(N,V,Z,H),Be.viewport(ee.copy(nt).multiplyScalar(ie).round())},this.getScissor=function(N){return N.copy(tt)},this.setScissor=function(N,V,Z,H){N.isVector4?tt.set(N.x,N.y,N.z,N.w):tt.set(N,V,Z,H),Be.scissor(se.copy(tt).multiplyScalar(ie).round())},this.getScissorTest=function(){return gt},this.setScissorTest=function(N){Be.setScissorTest(gt=N)},this.setOpaqueSort=function(N){Ce=N},this.setTransparentSort=function(N){Xe=N},this.getClearColor=function(N){return N.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor(...arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha(...arguments)},this.clear=function(N=!0,V=!0,Z=!0){let H=0;if(N){let X=!1;if(R!==null){const ne=R.texture.format;X=x.has(ne)}if(X){const ne=R.texture.type,ae=T.has(ne),fe=He.getClearColor(),_e=He.getClearAlpha(),Se=fe.r,we=fe.g,Pe=fe.b;ae?(S[0]=Se,S[1]=we,S[2]=Pe,S[3]=_e,G.clearBufferuiv(G.COLOR,0,S)):(v[0]=Se,v[1]=we,v[2]=Pe,v[3]=_e,G.clearBufferiv(G.COLOR,0,v))}else H|=G.COLOR_BUFFER_BIT}V&&(H|=G.DEPTH_BUFFER_BIT),Z&&(H|=G.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ge,!1),t.removeEventListener("webglcontextrestored",Re,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),He.dispose(),qe.dispose(),_t.dispose(),Je.dispose(),k.dispose(),U.dispose(),Le.dispose(),q.dispose(),Ve.dispose(),ye.dispose(),We.dispose(),We.removeEventListener("sessionstart",Ls),We.removeEventListener("sessionend",Is),Ei.stop()};function Ge(N){N.preventDefault(),u0("WebGLRenderer: Context Lost."),I=!0}function Re(){u0("WebGLRenderer: Context Restored."),I=!1;const N=$e.autoReset,V=Ie.enabled,Z=Ie.autoUpdate,H=Ie.needsUpdate,X=Ie.type;me(),$e.autoReset=N,Ie.enabled=V,Ie.autoUpdate=Z,Ie.needsUpdate=H,Ie.type=X}function rt(N){Bt("WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function yt(N){const V=N.target;V.removeEventListener("dispose",yt),Gt(V)}function Gt(N){Vt(N),Je.remove(N)}function Vt(N){const V=Je.get(N).programs;V!==void 0&&(V.forEach(function(Z){ye.releaseProgram(Z)}),N.isShaderMaterial&&ye.releaseShaderCache(N))}this.renderBufferDirect=function(N,V,Z,H,X,ne){V===null&&(V=ot);const ae=X.isMesh&&X.matrixWorld.determinant()<0,fe=uo(N,V,Z,H,X);Be.setMaterial(H,ae);let _e=Z.index,Se=1;if(H.wireframe===!0){if(_e=Ee.getWireframeAttribute(Z),_e===void 0)return;Se=2}const we=Z.drawRange,Pe=Z.attributes.position;let ze=we.start*Se,Ye=(we.start+we.count)*Se;ne!==null&&(ze=Math.max(ze,ne.start*Se),Ye=Math.min(Ye,(ne.start+ne.count)*Se)),_e!==null?(ze=Math.max(ze,0),Ye=Math.min(Ye,_e.count)):Pe!=null&&(ze=Math.max(ze,0),Ye=Math.min(Ye,Pe.count));const lt=Ye-ze;if(lt<0||lt===1/0)return;q.setup(X,H,fe,Z,_e);let St,bt=Q;if(_e!==null&&(St=ce.get(_e),bt=pe,bt.setIndex(St)),X.isMesh)H.wireframe===!0?(Be.setLineWidth(H.wireframeLinewidth*Te()),bt.setMode(G.LINES)):bt.setMode(G.TRIANGLES);else if(X.isLine){let ft=H.linewidth;ft===void 0&&(ft=1),Be.setLineWidth(ft*Te()),X.isLineSegments?bt.setMode(G.LINES):X.isLineLoop?bt.setMode(G.LINE_LOOP):bt.setMode(G.LINE_STRIP)}else X.isPoints?bt.setMode(G.POINTS):X.isSprite&&bt.setMode(G.TRIANGLES);if(X.isBatchedMesh)if(X._multiDrawInstances!==null)Td("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bt.renderMultiDrawInstances(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount,X._multiDrawInstances);else if(De.get("WEBGL_multi_draw"))bt.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{const ft=X._multiDrawStarts,At=X._multiDrawCounts,st=X._multiDrawCount,Kt=_e?ce.get(_e).bytesPerElement:1,On=Je.get(H).currentProgram.getUniforms();for(let Xt=0;Xt<st;Xt++)On.setValue(G,"_gl_DrawID",Xt),bt.render(ft[Xt]/Kt,At[Xt])}else if(X.isInstancedMesh)bt.renderInstances(ze,lt,X.count);else if(Z.isInstancedBufferGeometry){const ft=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,At=Math.min(Z.instanceCount,ft);bt.renderInstances(ze,lt,At)}else bt.render(ze,lt)};function oi(N,V,Z){N.transparent===!0&&N.side===la&&N.forceSinglePass===!1?(N.side=Oi,N.needsUpdate=!0,Or(N,V,Z),N.side=Cs,N.needsUpdate=!0,Or(N,V,Z),N.side=la):Or(N,V,Z)}this.compile=function(N,V,Z=null){Z===null&&(Z=N),E=_t.get(Z),E.init(V),D.push(E),Z.traverseVisible(function(X){X.isLight&&X.layers.test(V.layers)&&(E.pushLight(X),X.castShadow&&E.pushShadow(X))}),N!==Z&&N.traverseVisible(function(X){X.isLight&&X.layers.test(V.layers)&&(E.pushLight(X),X.castShadow&&E.pushShadow(X))}),E.setupLights();const H=new Set;return N.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;const ne=X.material;if(ne)if(Array.isArray(ne))for(let ae=0;ae<ne.length;ae++){const fe=ne[ae];oi(fe,Z,X),H.add(fe)}else oi(ne,Z,X),H.add(ne)}),E=D.pop(),H},this.compileAsync=function(N,V,Z=null){const H=this.compile(N,V,Z);return new Promise(X=>{function ne(){if(H.forEach(function(ae){Je.get(ae).currentProgram.isReady()&&H.delete(ae)}),H.size===0){X(N);return}setTimeout(ne,10)}De.get("KHR_parallel_shader_compile")!==null?ne():setTimeout(ne,10)})};let li=null;function co(N){li&&li(N)}function Ls(){Ei.stop()}function Is(){Ei.start()}const Ei=new L6;Ei.setAnimationLoop(co),typeof self<"u"&&Ei.setContext(self),this.setAnimationLoop=function(N){li=N,We.setAnimationLoop(N),N===null?Ei.stop():Ei.start()},We.addEventListener("sessionstart",Ls),We.addEventListener("sessionend",Is),this.render=function(N,V){if(V!==void 0&&V.isCamera!==!0){Bt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;if(N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(V),V=We.getCamera()),N.isScene===!0&&N.onBeforeRender(C,N,V,R),E=_t.get(N,D.length),E.init(V),D.push(E),ue.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),ge.setFromProjectionMatrix(ue,Mr,V.reversedDepth),Ze=this.localClippingEnabled,Ae=pt.init(this.clippingPlanes,Ze),y=qe.get(N,b.length),y.init(),b.push(y),We.enabled===!0&&We.isPresenting===!0){const ne=C.xr.getDepthSensingMesh();ne!==null&&Us(ne,V,-1/0,C.sortObjects)}Us(N,V,0,C.sortObjects),y.finish(),C.sortObjects===!0&&y.sort(Ce,Xe),Ke=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,Ke&&He.addToRenderList(y,N),this.info.render.frame++,Ae===!0&&pt.beginShadows();const Z=E.state.shadowsArray;Ie.render(Z,N,V),Ae===!0&&pt.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=y.opaque,X=y.transmissive;if(E.setupLights(),V.isArrayCamera){const ne=V.cameras;if(X.length>0)for(let ae=0,fe=ne.length;ae<fe;ae++){const _e=ne[ae];ki(H,X,N,_e)}Ke&&He.render(N);for(let ae=0,fe=ne.length;ae<fe;ae++){const _e=ne[ae];ha(y,N,_e,_e.viewport)}}else X.length>0&&ki(H,X,N,V),Ke&&He.render(N),ha(y,N,V);R!==null&&O===0&&(ct.updateMultisampleRenderTarget(R),ct.updateRenderTargetMipmap(R)),N.isScene===!0&&N.onAfterRender(C,N,V),q.resetDefaultState(),B=-1,j=null,D.pop(),D.length>0?(E=D[D.length-1],Ae===!0&&pt.setGlobalState(C.clippingPlanes,E.state.camera)):E=null,b.pop(),b.length>0?y=b[b.length-1]:y=null};function Us(N,V,Z,H){if(N.visible===!1)return;if(N.layers.test(V.layers)){if(N.isGroup)Z=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(V);else if(N.isLight)E.pushLight(N),N.castShadow&&E.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||ge.intersectsSprite(N)){H&&Mt.setFromMatrixPosition(N.matrixWorld).applyMatrix4(ue);const ae=Le.update(N),fe=N.material;fe.visible&&y.push(N,ae,fe,Z,Mt.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||ge.intersectsObject(N))){const ae=Le.update(N),fe=N.material;if(H&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),Mt.copy(N.boundingSphere.center)):(ae.boundingSphere===null&&ae.computeBoundingSphere(),Mt.copy(ae.boundingSphere.center)),Mt.applyMatrix4(N.matrixWorld).applyMatrix4(ue)),Array.isArray(fe)){const _e=ae.groups;for(let Se=0,we=_e.length;Se<we;Se++){const Pe=_e[Se],ze=fe[Pe.materialIndex];ze&&ze.visible&&y.push(N,ae,ze,Z,Mt.z,Pe)}}else fe.visible&&y.push(N,ae,fe,Z,Mt.z,null)}}const ne=N.children;for(let ae=0,fe=ne.length;ae<fe;ae++)Us(ne[ae],V,Z,H)}function ha(N,V,Z,H){const{opaque:X,transmissive:ne,transparent:ae}=N;E.setupLightsView(Z),Ae===!0&&pt.setGlobalState(C.clippingPlanes,Z),H&&Be.viewport(ee.copy(H)),X.length>0&&Ha(X,V,Z),ne.length>0&&Ha(ne,V,Z),ae.length>0&&Ha(ae,V,Z),Be.buffers.depth.setTest(!0),Be.buffers.depth.setMask(!0),Be.buffers.color.setMask(!0),Be.setPolygonOffset(!1)}function ki(N,V,Z,H){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[H.id]===void 0&&(E.state.transmissionRenderTarget[H.id]=new _i(1,1,{generateMipmaps:!0,type:De.has("EXT_color_buffer_half_float")||De.has("EXT_color_buffer_float")?Xn:Ii,minFilter:Er,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:rn.workingColorSpace}));const ne=E.state.transmissionRenderTarget[H.id],ae=H.viewport||ee;ne.setSize(ae.z*C.transmissionResolutionScale,ae.w*C.transmissionResolutionScale);const fe=C.getRenderTarget(),_e=C.getActiveCubeFace(),Se=C.getActiveMipmapLevel();C.setRenderTarget(ne),C.getClearColor(W),te=C.getClearAlpha(),te<1&&C.setClearColor(16777215,.5),C.clear(),Ke&&He.render(Z);const we=C.toneMapping;C.toneMapping=ns;const Pe=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),E.setupLightsView(H),Ae===!0&&pt.setGlobalState(C.clippingPlanes,H),Ha(N,Z,H),ct.updateMultisampleRenderTarget(ne),ct.updateRenderTargetMipmap(ne),De.has("WEBGL_multisampled_render_to_texture")===!1){let ze=!1;for(let Ye=0,lt=V.length;Ye<lt;Ye++){const St=V[Ye],{object:bt,geometry:ft,material:At,group:st}=St;if(At.side===la&&bt.layers.test(H.layers)){const Kt=At.side;At.side=Oi,At.needsUpdate=!0,Dn(bt,Z,H,ft,At,st),At.side=Kt,At.needsUpdate=!0,ze=!0}}ze===!0&&(ct.updateMultisampleRenderTarget(ne),ct.updateRenderTargetMipmap(ne))}C.setRenderTarget(fe,_e,Se),C.setClearColor(W,te),Pe!==void 0&&(H.viewport=Pe),C.toneMapping=we}function Ha(N,V,Z){const H=V.isScene===!0?V.overrideMaterial:null;for(let X=0,ne=N.length;X<ne;X++){const ae=N[X],{object:fe,geometry:_e,group:Se}=ae;let we=ae.material;we.allowOverride===!0&&H!==null&&(we=H),fe.layers.test(Z.layers)&&Dn(fe,V,Z,_e,we,Se)}}function Dn(N,V,Z,H,X,ne){N.onBeforeRender(C,V,Z,H,X,ne),N.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),X.onBeforeRender(C,V,Z,H,N,ne),X.transparent===!0&&X.side===la&&X.forceSinglePass===!1?(X.side=Oi,X.needsUpdate=!0,C.renderBufferDirect(Z,V,H,X,N,ne),X.side=Cs,X.needsUpdate=!0,C.renderBufferDirect(Z,V,H,X,N,ne),X.side=la):C.renderBufferDirect(Z,V,H,X,N,ne),N.onAfterRender(C,V,Z,H,X,ne)}function Or(N,V,Z){V.isScene!==!0&&(V=ot);const H=Je.get(N),X=E.state.lights,ne=E.state.shadowsArray,ae=X.state.version,fe=ye.getParameters(N,X.state,ne,V,Z),_e=ye.getProgramCacheKey(fe);let Se=H.programs;H.environment=N.isMeshStandardMaterial?V.environment:null,H.fog=V.fog,H.envMap=(N.isMeshStandardMaterial?U:k).get(N.envMap||H.environment),H.envMapRotation=H.environment!==null&&N.envMap===null?V.environmentRotation:N.envMapRotation,Se===void 0&&(N.addEventListener("dispose",yt),Se=new Map,H.programs=Se);let we=Se.get(_e);if(we!==void 0){if(H.currentProgram===we&&H.lightsStateVersion===ae)return zs(N,fe),we}else fe.uniforms=ye.getUniforms(N),N.onBeforeCompile(fe,C),we=ye.acquireProgram(fe,_e),Se.set(_e,we),H.uniforms=fe.uniforms;const Pe=H.uniforms;return(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(Pe.clippingPlanes=pt.uniform),zs(N,fe),H.needsLights=fa(N),H.lightsStateVersion=ae,H.needsLights&&(Pe.ambientLightColor.value=X.state.ambient,Pe.lightProbe.value=X.state.probe,Pe.directionalLights.value=X.state.directional,Pe.directionalLightShadows.value=X.state.directionalShadow,Pe.spotLights.value=X.state.spot,Pe.spotLightShadows.value=X.state.spotShadow,Pe.rectAreaLights.value=X.state.rectArea,Pe.ltc_1.value=X.state.rectAreaLTC1,Pe.ltc_2.value=X.state.rectAreaLTC2,Pe.pointLights.value=X.state.point,Pe.pointLightShadows.value=X.state.pointShadow,Pe.hemisphereLights.value=X.state.hemi,Pe.directionalShadowMap.value=X.state.directionalShadowMap,Pe.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Pe.spotShadowMap.value=X.state.spotShadowMap,Pe.spotLightMatrix.value=X.state.spotLightMatrix,Pe.spotLightMap.value=X.state.spotLightMap,Pe.pointShadowMap.value=X.state.pointShadowMap,Pe.pointShadowMatrix.value=X.state.pointShadowMatrix),H.currentProgram=we,H.uniformsList=null,we}function Ps(N){if(N.uniformsList===null){const V=N.currentProgram.getUniforms();N.uniformsList=m_.seqWithValue(V.seq,N.uniforms)}return N.uniformsList}function zs(N,V){const Z=Je.get(N);Z.outputColorSpace=V.outputColorSpace,Z.batching=V.batching,Z.batchingColor=V.batchingColor,Z.instancing=V.instancing,Z.instancingColor=V.instancingColor,Z.instancingMorph=V.instancingMorph,Z.skinning=V.skinning,Z.morphTargets=V.morphTargets,Z.morphNormals=V.morphNormals,Z.morphColors=V.morphColors,Z.morphTargetsCount=V.morphTargetsCount,Z.numClippingPlanes=V.numClippingPlanes,Z.numIntersection=V.numClipIntersection,Z.vertexAlphas=V.vertexAlphas,Z.vertexTangents=V.vertexTangents,Z.toneMapping=V.toneMapping}function uo(N,V,Z,H,X){V.isScene!==!0&&(V=ot),ct.resetTextureUnits();const ne=V.fog,ae=H.isMeshStandardMaterial?V.environment:null,fe=R===null?C.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Wn,_e=(H.isMeshStandardMaterial?U:k).get(H.envMap||ae),Se=H.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,we=!!Z.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Pe=!!Z.morphAttributes.position,ze=!!Z.morphAttributes.normal,Ye=!!Z.morphAttributes.color;let lt=ns;H.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(lt=C.toneMapping);const St=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,bt=St!==void 0?St.length:0,ft=Je.get(H),At=E.state.lights;if(Ae===!0&&(Ze===!0||N!==j)){const Mn=N===j&&H.id===B;pt.setState(H,N,Mn)}let st=!1;H.version===ft.__version?(ft.needsLights&&ft.lightsStateVersion!==At.state.version||ft.outputColorSpace!==fe||X.isBatchedMesh&&ft.batching===!1||!X.isBatchedMesh&&ft.batching===!0||X.isBatchedMesh&&ft.batchingColor===!0&&X.colorTexture===null||X.isBatchedMesh&&ft.batchingColor===!1&&X.colorTexture!==null||X.isInstancedMesh&&ft.instancing===!1||!X.isInstancedMesh&&ft.instancing===!0||X.isSkinnedMesh&&ft.skinning===!1||!X.isSkinnedMesh&&ft.skinning===!0||X.isInstancedMesh&&ft.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&ft.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&ft.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&ft.instancingMorph===!1&&X.morphTexture!==null||ft.envMap!==_e||H.fog===!0&&ft.fog!==ne||ft.numClippingPlanes!==void 0&&(ft.numClippingPlanes!==pt.numPlanes||ft.numIntersection!==pt.numIntersection)||ft.vertexAlphas!==Se||ft.vertexTangents!==we||ft.morphTargets!==Pe||ft.morphNormals!==ze||ft.morphColors!==Ye||ft.toneMapping!==lt||ft.morphTargetsCount!==bt)&&(st=!0):(st=!0,ft.__version=H.version);let Kt=ft.currentProgram;st===!0&&(Kt=Or(H,V,X));let On=!1,Xt=!1,kt=!1;const Ct=Kt.getUniforms(),Bn=ft.uniforms;if(Be.useProgram(Kt.program)&&(On=!0,Xt=!0,kt=!0),H.id!==B&&(B=H.id,Xt=!0),On||j!==N){Be.buffers.depth.getReversed()&&N.reversedDepth!==!0&&(N._reversedDepth=!0,N.updateProjectionMatrix()),Ct.setValue(G,"projectionMatrix",N.projectionMatrix),Ct.setValue(G,"viewMatrix",N.matrixWorldInverse);const Gn=Ct.map.cameraPosition;Gn!==void 0&&Gn.setValue(G,it.setFromMatrixPosition(N.matrixWorld)),Fe.logarithmicDepthBuffer&&Ct.setValue(G,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Ct.setValue(G,"isOrthographic",N.isOrthographicCamera===!0),j!==N&&(j=N,Xt=!0,kt=!0)}if(X.isSkinnedMesh){Ct.setOptional(G,X,"bindMatrix"),Ct.setOptional(G,X,"bindMatrixInverse");const Mn=X.skeleton;Mn&&(Mn.boneTexture===null&&Mn.computeBoneTexture(),Ct.setValue(G,"boneTexture",Mn.boneTexture,ct))}X.isBatchedMesh&&(Ct.setOptional(G,X,"batchingTexture"),Ct.setValue(G,"batchingTexture",X._matricesTexture,ct),Ct.setOptional(G,X,"batchingIdTexture"),Ct.setValue(G,"batchingIdTexture",X._indirectTexture,ct),Ct.setOptional(G,X,"batchingColorTexture"),X._colorsTexture!==null&&Ct.setValue(G,"batchingColorTexture",X._colorsTexture,ct));const Mi=Z.morphAttributes;if((Mi.position!==void 0||Mi.normal!==void 0||Mi.color!==void 0)&&ht.update(X,Z,Kt),(Xt||ft.receiveShadow!==X.receiveShadow)&&(ft.receiveShadow=X.receiveShadow,Ct.setValue(G,"receiveShadow",X.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Bn.envMap.value=_e,Bn.flipEnvMap.value=_e.isCubeTexture&&_e.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&V.environment!==null&&(Bn.envMapIntensity.value=V.environmentIntensity),Bn.dfgLUT!==void 0&&(Bn.dfgLUT.value=mj()),Xt&&(Ct.setValue(G,"toneMappingExposure",C.toneMappingExposure),ft.needsLights&&rr(Bn,kt),ne&&H.fog===!0&&vt.refreshFogUniforms(Bn,ne),vt.refreshMaterialUniforms(Bn,H,ie,oe,E.state.transmissionRenderTarget[N.id]),m_.upload(G,Ps(ft),Bn,ct)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(m_.upload(G,Ps(ft),Bn,ct),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Ct.setValue(G,"center",X.center),Ct.setValue(G,"modelViewMatrix",X.modelViewMatrix),Ct.setValue(G,"normalMatrix",X.normalMatrix),Ct.setValue(G,"modelMatrix",X.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const Mn=H.uniformsGroups;for(let Gn=0,gh=Mn.length;Gn<gh;Gn++){const Lr=Mn[Gn];Ve.update(Lr,Kt),Ve.bind(Lr,Kt)}}return Kt}function rr(N,V){N.ambientLightColor.needsUpdate=V,N.lightProbe.needsUpdate=V,N.directionalLights.needsUpdate=V,N.directionalLightShadows.needsUpdate=V,N.pointLights.needsUpdate=V,N.pointLightShadows.needsUpdate=V,N.spotLights.needsUpdate=V,N.spotLightShadows.needsUpdate=V,N.rectAreaLights.needsUpdate=V,N.hemisphereLights.needsUpdate=V}function fa(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return O},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(N,V,Z){const H=Je.get(N);H.__autoAllocateDepthBuffer=N.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),Je.get(N.texture).__webglTexture=V,Je.get(N.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:Z,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(N,V){const Z=Je.get(N);Z.__webglFramebuffer=V,Z.__useDefaultFramebuffer=V===void 0};const w=G.createFramebuffer();this.setRenderTarget=function(N,V=0,Z=0){R=N,P=V,O=Z;let H=!0,X=null,ne=!1,ae=!1;if(N){const _e=Je.get(N);if(_e.__useDefaultFramebuffer!==void 0)Be.bindFramebuffer(G.FRAMEBUFFER,null),H=!1;else if(_e.__webglFramebuffer===void 0)ct.setupRenderTarget(N);else if(_e.__hasExternalTextures)ct.rebindTextures(N,Je.get(N.texture).__webglTexture,Je.get(N.depthTexture).__webglTexture);else if(N.depthBuffer){const Pe=N.depthTexture;if(_e.__boundDepthTexture!==Pe){if(Pe!==null&&Je.has(Pe)&&(N.width!==Pe.image.width||N.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ct.setupDepthRenderbuffer(N)}}const Se=N.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(ae=!0);const we=Je.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(Array.isArray(we[V])?X=we[V][Z]:X=we[V],ne=!0):N.samples>0&&ct.useMultisampledRTT(N)===!1?X=Je.get(N).__webglMultisampledFramebuffer:Array.isArray(we)?X=we[Z]:X=we,ee.copy(N.viewport),se.copy(N.scissor),re=N.scissorTest}else ee.copy(nt).multiplyScalar(ie).floor(),se.copy(tt).multiplyScalar(ie).floor(),re=gt;if(Z!==0&&(X=w),Be.bindFramebuffer(G.FRAMEBUFFER,X)&&H&&Be.drawBuffers(N,X),Be.viewport(ee),Be.scissor(se),Be.setScissorTest(re),ne){const _e=Je.get(N.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+V,_e.__webglTexture,Z)}else if(ae){const _e=V;for(let Se=0;Se<N.textures.length;Se++){const we=Je.get(N.textures[Se]);G.framebufferTextureLayer(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0+Se,we.__webglTexture,Z,_e)}}else if(N!==null&&Z!==0){const _e=Je.get(N.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,_e.__webglTexture,Z)}B=-1},this.readRenderTargetPixels=function(N,V,Z,H,X,ne,ae,fe=0){if(!(N&&N.isWebGLRenderTarget)){Bt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=Je.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&ae!==void 0&&(_e=_e[ae]),_e){Be.bindFramebuffer(G.FRAMEBUFFER,_e);try{const Se=N.textures[fe],we=Se.format,Pe=Se.type;if(!Fe.textureFormatReadable(we)){Bt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Fe.textureTypeReadable(Pe)){Bt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=N.width-H&&Z>=0&&Z<=N.height-X&&(N.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+fe),G.readPixels(V,Z,H,X,Oe.convert(we),Oe.convert(Pe),ne))}finally{const Se=R!==null?Je.get(R).__webglFramebuffer:null;Be.bindFramebuffer(G.FRAMEBUFFER,Se)}}},this.readRenderTargetPixelsAsync=async function(N,V,Z,H,X,ne,ae,fe=0){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let _e=Je.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&ae!==void 0&&(_e=_e[ae]),_e)if(V>=0&&V<=N.width-H&&Z>=0&&Z<=N.height-X){Be.bindFramebuffer(G.FRAMEBUFFER,_e);const Se=N.textures[fe],we=Se.format,Pe=Se.type;if(!Fe.textureFormatReadable(we))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Fe.textureTypeReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ze=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,ze),G.bufferData(G.PIXEL_PACK_BUFFER,ne.byteLength,G.STREAM_READ),N.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+fe),G.readPixels(V,Z,H,X,Oe.convert(we),Oe.convert(Pe),0);const Ye=R!==null?Je.get(R).__webglFramebuffer:null;Be.bindFramebuffer(G.FRAMEBUFFER,Ye);const lt=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await kF(G,lt,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,ze),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,ne),G.deleteBuffer(ze),G.deleteSync(lt),ne}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(N,V=null,Z=0){const H=Math.pow(2,-Z),X=Math.floor(N.image.width*H),ne=Math.floor(N.image.height*H),ae=V!==null?V.x:0,fe=V!==null?V.y:0;ct.setTexture2D(N,0),G.copyTexSubImage2D(G.TEXTURE_2D,Z,0,0,ae,fe,X,ne),Be.unbindTexture()};const z=G.createFramebuffer(),Y=G.createFramebuffer();this.copyTextureToTexture=function(N,V,Z=null,H=null,X=0,ne=null){ne===null&&(X!==0?(Td("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ne=X,X=0):ne=0);let ae,fe,_e,Se,we,Pe,ze,Ye,lt;const St=N.isCompressedTexture?N.mipmaps[ne]:N.image;if(Z!==null)ae=Z.max.x-Z.min.x,fe=Z.max.y-Z.min.y,_e=Z.isBox3?Z.max.z-Z.min.z:1,Se=Z.min.x,we=Z.min.y,Pe=Z.isBox3?Z.min.z:0;else{const Mi=Math.pow(2,-X);ae=Math.floor(St.width*Mi),fe=Math.floor(St.height*Mi),N.isDataArrayTexture?_e=St.depth:N.isData3DTexture?_e=Math.floor(St.depth*Mi):_e=1,Se=0,we=0,Pe=0}H!==null?(ze=H.x,Ye=H.y,lt=H.z):(ze=0,Ye=0,lt=0);const bt=Oe.convert(V.format),ft=Oe.convert(V.type);let At;V.isData3DTexture?(ct.setTexture3D(V,0),At=G.TEXTURE_3D):V.isDataArrayTexture||V.isCompressedArrayTexture?(ct.setTexture2DArray(V,0),At=G.TEXTURE_2D_ARRAY):(ct.setTexture2D(V,0),At=G.TEXTURE_2D),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,V.flipY),G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),G.pixelStorei(G.UNPACK_ALIGNMENT,V.unpackAlignment);const st=G.getParameter(G.UNPACK_ROW_LENGTH),Kt=G.getParameter(G.UNPACK_IMAGE_HEIGHT),On=G.getParameter(G.UNPACK_SKIP_PIXELS),Xt=G.getParameter(G.UNPACK_SKIP_ROWS),kt=G.getParameter(G.UNPACK_SKIP_IMAGES);G.pixelStorei(G.UNPACK_ROW_LENGTH,St.width),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,St.height),G.pixelStorei(G.UNPACK_SKIP_PIXELS,Se),G.pixelStorei(G.UNPACK_SKIP_ROWS,we),G.pixelStorei(G.UNPACK_SKIP_IMAGES,Pe);const Ct=N.isDataArrayTexture||N.isData3DTexture,Bn=V.isDataArrayTexture||V.isData3DTexture;if(N.isDepthTexture){const Mi=Je.get(N),Mn=Je.get(V),Gn=Je.get(Mi.__renderTarget),gh=Je.get(Mn.__renderTarget);Be.bindFramebuffer(G.READ_FRAMEBUFFER,Gn.__webglFramebuffer),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,gh.__webglFramebuffer);for(let Lr=0;Lr<_e;Lr++)Ct&&(G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Je.get(N).__webglTexture,X,Pe+Lr),G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Je.get(V).__webglTexture,ne,lt+Lr)),G.blitFramebuffer(Se,we,ae,fe,ze,Ye,ae,fe,G.DEPTH_BUFFER_BIT,G.NEAREST);Be.bindFramebuffer(G.READ_FRAMEBUFFER,null),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else if(X!==0||N.isRenderTargetTexture||Je.has(N)){const Mi=Je.get(N),Mn=Je.get(V);Be.bindFramebuffer(G.READ_FRAMEBUFFER,z),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,Y);for(let Gn=0;Gn<_e;Gn++)Ct?G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Mi.__webglTexture,X,Pe+Gn):G.framebufferTexture2D(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Mi.__webglTexture,X),Bn?G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Mn.__webglTexture,ne,lt+Gn):G.framebufferTexture2D(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Mn.__webglTexture,ne),X!==0?G.blitFramebuffer(Se,we,ae,fe,ze,Ye,ae,fe,G.COLOR_BUFFER_BIT,G.NEAREST):Bn?G.copyTexSubImage3D(At,ne,ze,Ye,lt+Gn,Se,we,ae,fe):G.copyTexSubImage2D(At,ne,ze,Ye,Se,we,ae,fe);Be.bindFramebuffer(G.READ_FRAMEBUFFER,null),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else Bn?N.isDataTexture||N.isData3DTexture?G.texSubImage3D(At,ne,ze,Ye,lt,ae,fe,_e,bt,ft,St.data):V.isCompressedArrayTexture?G.compressedTexSubImage3D(At,ne,ze,Ye,lt,ae,fe,_e,bt,St.data):G.texSubImage3D(At,ne,ze,Ye,lt,ae,fe,_e,bt,ft,St):N.isDataTexture?G.texSubImage2D(G.TEXTURE_2D,ne,ze,Ye,ae,fe,bt,ft,St.data):N.isCompressedTexture?G.compressedTexSubImage2D(G.TEXTURE_2D,ne,ze,Ye,St.width,St.height,bt,St.data):G.texSubImage2D(G.TEXTURE_2D,ne,ze,Ye,ae,fe,bt,ft,St);G.pixelStorei(G.UNPACK_ROW_LENGTH,st),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Kt),G.pixelStorei(G.UNPACK_SKIP_PIXELS,On),G.pixelStorei(G.UNPACK_SKIP_ROWS,Xt),G.pixelStorei(G.UNPACK_SKIP_IMAGES,kt),ne===0&&V.generateMipmaps&&G.generateMipmap(At),Be.unbindTexture()},this.initRenderTarget=function(N){Je.get(N).__webglFramebuffer===void 0&&ct.setupRenderTarget(N)},this.initTexture=function(N){N.isCubeTexture?ct.setTextureCube(N,0):N.isData3DTexture?ct.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ct.setTexture2DArray(N,0):ct.setTexture2D(N,0),Be.unbindTexture()},this.resetState=function(){P=0,O=0,R=null,Be.reset(),q.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Mr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=rn._getDrawingBufferColorSpace(e),t.unpackColorSpace=rn._getUnpackColorSpace()}}const gj=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:cb,AddEquation:Qs,AddOperation:uU,AdditiveAnimationBlendMode:pb,AdditiveBlending:$3,AgXToneMapping:mU,AlphaFormat:fb,AlwaysCompare:DU,AlwaysDepth:i0,AlwaysStencilFunc:iE,AmbientLight:_6,AnimationAction:w6,AnimationClip:Ku,AnimationLoader:CV,AnimationMixer:C6,AnimationObjectGroup:$V,AnimationUtils:bV,ArcCurve:jU,ArrayCamera:b6,ArrowHelper:Mk,AttachedBindMode:nE,Audio:A6,AudioAnalyser:kV,AudioContext:Xb,AudioListener:FV,AudioLoader:zV,AxesHelper:O6,BackSide:Oi,BasicDepthPacking:Sc,BasicShadowMap:YI,BatchedMesh:XU,Bone:H1,BooleanKeyframeTrack:uh,Box2:lk,Box3:ea,Box3Helper:Tk,BoxGeometry:oh,BoxHelper:Sk,BufferAttribute:Ot,BufferGeometry:wt,BufferGeometryLoader:E6,ByteType:w1,Cache:to,Camera:Tc,CameraHelper:yk,CanvasTexture:jG,CapsuleGeometry:k1,CatmullRomCurve3:ZU,CineonToneMapping:dU,CircleGeometry:W1,ClampToEdgeWrapping:Li,Clock:Yb,Color:je,ColorKeyframeTrack:Bb,ColorManagement:rn,CompressedArrayTexture:YG,CompressedCubeTexture:qG,CompressedTexture:V1,CompressedTextureLoader:NV,ConeGeometry:z0,ConstantAlphaFactor:oU,ConstantColorFactor:rU,Controls:Ak,CubeCamera:FU,CubeReflectionMapping:al,CubeRefractionMapping:dc,CubeTexture:L0,CubeTextureLoader:DV,CubeUVReflectionMapping:kd,CubicBezierCurve:wb,CubicBezierCurve3:KU,CubicInterpolant:f6,CullFaceBack:J3,CullFaceFront:XI,CullFaceFrontBack:lF,CullFaceNone:WI,Curve:Os,CurvePath:JU,CustomBlending:lb,CustomToneMapping:pU,CylinderGeometry:P0,Cylindrical:ok,Data3DTexture:is,DataArrayTexture:U1,DataTexture:Ja,DataTextureLoader:g6,DataUtils:aE,DecrementStencilOp:_F,DecrementWrapStencilOp:yF,DefaultLoadingManager:m6,DepthFormat:_d,DepthStencilFormat:Yu,DepthTexture:U0,DetachedBindMode:vU,DirectionalLight:Wb,DirectionalLightHelper:xk,DiscreteInterpolant:d6,DodecahedronGeometry:X1,DoubleSide:la,DstAlphaFactor:eU,DstColorFactor:nU,DynamicCopyUsage:IF,DynamicDrawUsage:OU,DynamicReadUsage:DF,EdgesGeometry:qU,EllipseCurve:Y1,EqualCompare:RU,EqualDepth:tx,EqualStencilFunc:MF,EquirectangularReflectionMapping:a0,EquirectangularRefractionMapping:r0,Euler:Ui,EventDispatcher:tr,ExternalTexture:Ab,ExtrudeGeometry:q1,FileLoader:ss,Float16BufferAttribute:MG,Float32BufferAttribute:xt,FloatType:ri,Fog:z1,FogExp2:P1,FramebufferTexture:XG,FrontSide:Cs,Frustum:Wd,FrustumArray:F1,GLBufferAttribute:cE,GLSL1:PF,GLSL3:ao,GreaterCompare:wU,GreaterDepth:ix,GreaterEqualCompare:NU,GreaterEqualDepth:nx,GreaterEqualStencilFunc:wF,GreaterStencilFunc:AF,GridHelper:vk,Group:Ia,HalfFloatType:Xn,HemisphereLight:v6,HemisphereLightHelper:gk,IcosahedronGeometry:j1,ImageBitmapLoader:M6,ImageLoader:wd,ImageUtils:UU,IncrementStencilOp:vF,IncrementWrapStencilOp:xF,InstancedBufferAttribute:qu,InstancedBufferGeometry:T6,InstancedInterleavedBuffer:ak,InstancedMesh:Eb,Int16BufferAttribute:TG,Int32BufferAttribute:EG,Int8BufferAttribute:xG,IntType:D0,InterleavedBuffer:I0,InterleavedBufferAttribute:mc,Interpolant:Xd,InterpolateDiscrete:xd,InterpolateLinear:yd,InterpolateSmooth:d_,InterpolationSamplingMode:HF,InterpolationSamplingType:BF,InvertStencilOp:SF,KeepStencilOp:vu,KeyframeTrack:ls,LOD:WU,LatheGeometry:Z1,Layers:Md,LessCompare:AU,LessDepth:ex,LessEqualCompare:gb,LessEqualDepth:ku,LessEqualStencilFunc:bF,LessStencilFunc:EF,Light:bc,LightProbe:S6,Line:ro,Line3:hk,LineBasicMaterial:Pi,LineCurve:Cb,LineCurve3:QU,LineDashedMaterial:c6,LineLoop:Mb,LineSegments:nr,LinearFilter:Ht,LinearInterpolant:zb,LinearMipMapLinearFilter:_U,LinearMipMapNearestFilter:hF,LinearMipmapLinearFilter:Er,LinearMipmapNearestFilter:td,LinearSRGBColorSpace:Wn,LinearToneMapping:hU,LinearTransfer:o0,Loader:Ti,LoaderUtils:oc,LoadingManager:Hb,LoopOnce:xU,LoopPingPong:SU,LoopRepeat:yU,MOUSE:mu,Material:qn,MaterialLoader:ny,MathUtils:$t,Matrix2:Zb,Matrix3:Et,Matrix4:ke,MaxEquation:KI,Mesh:si,MeshBasicMaterial:La,MeshDepthMaterial:Ib,MeshDistanceMaterial:Ub,MeshLambertMaterial:o6,MeshMatcapMaterial:l6,MeshNormalMaterial:Lb,MeshPhongMaterial:r6,MeshPhysicalMaterial:os,MeshStandardMaterial:F0,MeshToonMaterial:s6,MinEquation:ZI,MirroredRepeatWrapping:vd,MixOperation:cU,MultiplyBlending:tE,MultiplyOperation:N0,NearestFilter:Fn,NearestMipMapLinearFilter:uF,NearestMipMapNearestFilter:cF,NearestMipmapLinearFilter:yu,NearestMipmapNearestFilter:R1,NeutralToneMapping:gU,NeverCompare:bU,NeverDepth:$_,NeverStencilFunc:TF,NoBlending:Sa,NoColorSpace:Na,NoToneMapping:ns,NormalAnimationBlendMode:I1,NormalBlending:Ou,NotEqualCompare:CU,NotEqualDepth:ax,NotEqualStencilFunc:RF,NumberKeyframeTrack:gc,Object3D:Zt,ObjectLoader:UV,ObjectSpaceNormalMap:MU,OctahedronGeometry:B0,OneFactor:Gf,OneMinusConstantAlphaFactor:lU,OneMinusConstantColorFactor:sU,OneMinusDstAlphaFactor:tU,OneMinusDstColorFactor:iU,OneMinusSrcAlphaFactor:J_,OneMinusSrcColorFactor:$I,OrthographicCamera:io,PCFShadowMap:b1,PCFSoftShadowMap:Cm,PMREMGenerator:dE,Path:zx,PerspectiveCamera:ui,Plane:Fo,PlaneGeometry:lh,PlaneHelper:Ek,PointLight:kb,PointLightHelper:pk,Points:bb,PointsMaterial:G1,PolarGridHelper:_k,PolyhedronGeometry:Mc,PositionalAudio:VV,PropertyBinding:fn,PropertyMixer:R6,QuadraticBezierCurve:Nb,QuadraticBezierCurve3:Db,Quaternion:Tt,QuaternionKeyframeTrack:vc,QuaternionLinearInterpolant:p6,RED_GREEN_RGTC2_Format:Dx,RED_RGTC1_Format:Cx,REVISION:ws,RGBADepthPacking:EU,RGBAFormat:Jn,RGBAIntegerFormat:L1,RGBA_ASTC_10x10_Format:Ex,RGBA_ASTC_10x5_Format:yx,RGBA_ASTC_10x6_Format:Sx,RGBA_ASTC_10x8_Format:Tx,RGBA_ASTC_12x10_Format:Mx,RGBA_ASTC_12x12_Format:bx,RGBA_ASTC_4x4_Format:fx,RGBA_ASTC_5x4_Format:dx,RGBA_ASTC_5x5_Format:px,RGBA_ASTC_6x5_Format:mx,RGBA_ASTC_6x6_Format:gx,RGBA_ASTC_8x5_Format:vx,RGBA_ASTC_8x6_Format:_x,RGBA_ASTC_8x8_Format:xx,RGBA_BPTC_Format:Ax,RGBA_ETC2_EAC_Format:hx,RGBA_PVRTC_2BPPV1_Format:lx,RGBA_PVRTC_4BPPV1_Format:ox,RGBA_S3TC_DXT1_Format:Dm,RGBA_S3TC_DXT3_Format:Om,RGBA_S3TC_DXT5_Format:Lm,RGBDepthPacking:dF,RGBFormat:db,RGBIntegerFormat:fF,RGB_BPTC_SIGNED_Format:Rx,RGB_BPTC_UNSIGNED_Format:wx,RGB_ETC1_Format:cx,RGB_ETC2_Format:ux,RGB_PVRTC_2BPPV1_Format:sx,RGB_PVRTC_4BPPV1_Format:rx,RGB_S3TC_DXT1_Format:Nm,RGDepthPacking:pF,RGFormat:Vo,RGIntegerFormat:O1,RawShaderMaterial:ch,Ray:sh,Raycaster:N6,RectAreaLight:x6,RedFormat:bs,RedIntegerFormat:O0,ReinhardToneMapping:fU,RenderTarget:_b,RenderTarget3D:tk,RepeatWrapping:Ta,ReplaceStencilOp:gF,ReverseSubtractEquation:jI,RingGeometry:K1,SIGNED_RED_GREEN_RGTC2_Format:Ox,SIGNED_RED_RGTC1_Format:Nx,SRGBColorSpace:En,SRGBTransfer:Rn,Scene:Ad,ShaderChunk:Qt,ShaderLib:Ms,ShaderMaterial:Fi,ShadowMaterial:a6,Shape:Iu,ShapeGeometry:Q1,ShapePath:bk,ShapeUtils:As,ShortType:C1,Skeleton:Ec,SkeletonHelper:dk,SkinnedMesh:B1,Source:Zl,Sphere:ta,SphereGeometry:H0,Spherical:hE,SphericalHarmonics3:y6,SplineCurve:Ob,SpotLight:Vb,SpotLightHelper:fk,Sprite:kU,SpriteMaterial:Tb,SrcAlphaFactor:Q_,SrcAlphaSaturateFactor:aU,SrcColorFactor:JI,StaticCopyUsage:LF,StaticDrawUsage:l0,StaticReadUsage:NF,StereoCamera:BV,StreamCopyUsage:UF,StreamDrawUsage:CF,StreamReadUsage:OF,StringKeyframeTrack:hh,SubtractEquation:qI,SubtractiveBlending:eE,TOUCH:gu,TangentSpaceNormalMap:ol,TetrahedronGeometry:J1,Texture:Nn,TextureLoader:Fb,TextureUtils:Dk,Timer:rk,TimestampQuery:zF,TorusGeometry:$1,TorusKnotGeometry:ey,Triangle:Ka,TriangleFanDrawMode:Lx,TriangleStripDrawMode:mb,TrianglesDrawMode:TU,TubeGeometry:ty,UVMapping:A1,Uint16BufferAttribute:xb,Uint32BufferAttribute:yb,Uint8BufferAttribute:yG,Uint8ClampedBufferAttribute:SG,Uniform:J,UniformsGroup:ik,UniformsLib:at,UniformsUtils:Sb,UnsignedByteType:Ii,UnsignedInt101111Type:hb,UnsignedInt248Type:Xu,UnsignedInt5999Type:ub,UnsignedIntType:Ns,UnsignedShort4444Type:N1,UnsignedShort5551Type:D1,UnsignedShortType:Wu,VSMShadowMap:ys,Vector2:de,Vector3:L,Vector4:zt,VectorKeyframeTrack:Zu,VideoFrameTexture:WG,VideoTexture:YU,WebGL3DRenderTarget:zU,WebGLArrayRenderTarget:PU,WebGLCoordinateSystem:Mr,WebGLCubeRenderTarget:GU,WebGLRenderTarget:_i,WebGLRenderer:Kb,WebGLUtils:B6,WebGPUCoordinateSystem:Sd,WebXRController:p_,WireframeGeometry:i6,WrapAroundEnding:s0,ZeroCurvatureEnding:Su,ZeroFactor:QI,ZeroSlopeEnding:Tu,ZeroStencilOp:mF,createCanvasElement:IU,error:Bt,getConsoleFunction:VF,log:u0,setConsoleFunction:GF,warn:ut,warnOnce:Td},Symbol.toStringTag,{value:"Module"}));var H6={exports:{}},F6={},G6={exports:{}},V6={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Cd=be;function vj(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var _j=typeof Object.is=="function"?Object.is:vj,xj=Cd.useState,yj=Cd.useEffect,Sj=Cd.useLayoutEffect,Tj=Cd.useDebugValue;function Ej(n,e){var t=e(),i=xj({inst:{value:t,getSnapshot:e}}),a=i[0].inst,r=i[1];return Sj(function(){a.value=t,a.getSnapshot=e,d2(a)&&r({inst:a})},[n,t,e]),yj(function(){return d2(a)&&r({inst:a}),n(function(){d2(a)&&r({inst:a})})},[n]),Tj(t),t}function d2(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!_j(n,t)}catch{return!0}}function Mj(n,e){return e()}var bj=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Mj:Ej;V6.useSyncExternalStore=Cd.useSyncExternalStore!==void 0?Cd.useSyncExternalStore:bj;G6.exports=V6;var Aj=G6.exports;/**
* @license React
* use-sync-external-store-shim/with-selector.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ry=be,Rj=Aj;function wj(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var Cj=typeof Object.is=="function"?Object.is:wj,Nj=Rj.useSyncExternalStore,Dj=ry.useRef,Oj=ry.useEffect,Lj=ry.useMemo,Ij=ry.useDebugValue;F6.useSyncExternalStoreWithSelector=function(n,e,t,i,a){var r=Dj(null);if(r.current===null){var s={hasValue:!1,value:null};r.current=s}else s=r.current;r=Lj(function(){function c(g){if(!h){if(h=!0,f=g,g=i(g),a!==void 0&&s.hasValue){var x=s.value;if(a(x,g))return d=x}return d=g}if(x=d,Cj(f,g))return x;var T=i(g);return a!==void 0&&a(x,T)?(f=g,x):(f=g,d=T)}var h=!1,f,d,m=t===void 0?null:t;return[function(){return c(e())},m===null?void 0:function(){return c(m())}]},[e,t,i,a]);var o=Nj(n,r[0],r[1]);return Oj(function(){s.hasValue=!0,s.value=o},[o]),Ij(o),o};H6.exports=F6;var Uj=H6.exports;const Pj=r1(Uj),UN=n=>{let e;const t=new Set,i=(h,f)=>{const d=typeof h=="function"?h(e):h;if(!Object.is(d,e)){const m=e;e=f??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(g=>g(e,m))}},a=()=>e,o={setState:i,getState:a,getInitialState:()=>c,subscribe:h=>(t.add(h),()=>t.delete(h))},c=e=n(i,a,o);return o},zj=n=>n?UN(n):UN,{useSyncExternalStoreWithSelector:Bj}=Pj,Hj=n=>n;function Fj(n,e=Hj,t){const i=Bj(n.subscribe,n.getState,n.getInitialState,e,t);return hM.useDebugValue(i),i}const PN=(n,e)=>{const t=zj(n),i=(a,r=e)=>Fj(t,a,r);return Object.assign(i,t),i},Gj=(n,e)=>n?PN(n,e):PN,Vj=n=>typeof n=="object"&&typeof n.then=="function",Mu=[];function k6(n,e,t=(i,a)=>i===a){if(n===e)return!0;if(!n||!e)return!1;const i=n.length;if(e.length!==i)return!1;for(let a=0;a<i;a++)if(!t(n[a],e[a]))return!1;return!0}function W6(n,e=null,t=!1,i={}){e===null&&(e=[n]);for(const r of Mu)if(k6(e,r.keys,r.equal)){if(t)return;if(Object.prototype.hasOwnProperty.call(r,"error"))throw r.error;if(Object.prototype.hasOwnProperty.call(r,"response"))return i.lifespan&&i.lifespan>0&&(r.timeout&&clearTimeout(r.timeout),r.timeout=setTimeout(r.remove,i.lifespan)),r.response;if(!t)throw r.promise}const a={keys:e,equal:i.equal,remove:()=>{const r=Mu.indexOf(a);r!==-1&&Mu.splice(r,1)},promise:(Vj(n)?n:n(...e)).then(r=>{a.response=r,i.lifespan&&i.lifespan>0&&(a.timeout=setTimeout(a.remove,i.lifespan))}).catch(r=>a.error=r)};if(Mu.push(a),!t)throw a.promise}const kj=(n,e,t)=>W6(n,e,!1,t),Wj=(n,e,t)=>void W6(n,e,!0,t),Xj=n=>{if(n===void 0||n.length===0)Mu.splice(0,Mu.length);else{const e=Mu.find(t=>k6(n,t.keys,t.equal));e&&e.remove()}};var X6={exports:{}},Y6={exports:{}},q6={exports:{}},j6={};/**
* @license React
* scheduler.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(n){function e(W,te){var K=W.length;W.push(te);e:for(;0<K;){var oe=K-1>>>1,ie=W[oe];if(0<a(ie,te))W[oe]=te,W[K]=ie,K=oe;else break e}}function t(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var te=W[0],K=W.pop();if(K!==te){W[0]=K;e:for(var oe=0,ie=W.length,Ce=ie>>>1;oe<Ce;){var Xe=2*(oe+1)-1,nt=W[Xe],tt=Xe+1,gt=W[tt];if(0>a(nt,K))tt<ie&&0>a(gt,nt)?(W[oe]=gt,W[tt]=K,oe=tt):(W[oe]=nt,W[Xe]=K,oe=Xe);else if(tt<ie&&0>a(gt,K))W[oe]=gt,W[tt]=K,oe=tt;else break e}}return te}function a(W,te){var K=W.sortIndex-te.sortIndex;return K!==0?K:W.id-te.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;n.unstable_now=function(){return r.now()}}else{var s=Date,o=s.now();n.unstable_now=function(){return s.now()-o}}var c=[],h=[],f=1,d=null,m=3,g=!1,x=!1,T=!1,S=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;function E(W){for(var te=t(h);te!==null;){if(te.callback===null)i(h);else if(te.startTime<=W)i(h),te.sortIndex=te.expirationTime,e(c,te);else break;te=t(h)}}function b(W){if(T=!1,E(W),!x)if(t(c)!==null)x=!0,se();else{var te=t(h);te!==null&&re(b,te.startTime-W)}}var D=!1,C=-1,I=5,P=-1;function O(){return!(n.unstable_now()-P<I)}function R(){if(D){var W=n.unstable_now();P=W;var te=!0;try{e:{x=!1,T&&(T=!1,v(C),C=-1),g=!0;var K=m;try{t:{for(E(W),d=t(c);d!==null&&!(d.expirationTime>W&&O());){var oe=d.callback;if(typeof oe=="function"){d.callback=null,m=d.priorityLevel;var ie=oe(d.expirationTime<=W);if(W=n.unstable_now(),typeof ie=="function"){d.callback=ie,E(W),te=!0;break t}d===t(c)&&i(c),E(W)}else i(c);d=t(c)}if(d!==null)te=!0;else{var Ce=t(h);Ce!==null&&re(b,Ce.startTime-W),te=!1}}break e}finally{d=null,m=K,g=!1}te=void 0}}finally{te?B():D=!1}}}var B;if(typeof y=="function")B=function(){y(R)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,ee=j.port2;j.port1.onmessage=R,B=function(){ee.postMessage(null)}}else B=function(){S(R,0)};function se(){D||(D=!0,B())}function re(W,te){C=S(function(){W(n.unstable_now())},te)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(W){W.callback=null},n.unstable_continueExecution=function(){x||g||(x=!0,se())},n.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<W?Math.floor(1e3/W):5},n.unstable_getCurrentPriorityLevel=function(){return m},n.unstable_getFirstCallbackNode=function(){return t(c)},n.unstable_next=function(W){switch(m){case 1:case 2:case 3:var te=3;break;default:te=m}var K=m;m=te;try{return W()}finally{m=K}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(W,te){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var K=m;m=W;try{return te()}finally{m=K}},n.unstable_scheduleCallback=function(W,te,K){var oe=n.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?oe+K:oe):K=oe,W){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=K+ie,W={id:f++,callback:te,priorityLevel:W,startTime:K,expirationTime:ie,sortIndex:-1},K>oe?(W.sortIndex=K,e(h,W),t(c)===null&&W===t(h)&&(T?(v(C),C=-1):T=!0,re(b,K-oe))):(W.sortIndex=ie,e(c,W),x||g||(x=!0,se())),W},n.unstable_shouldYield=O,n.unstable_wrapCallback=function(W){var te=m;return function(){var K=m;m=te;try{return W.apply(this,arguments)}finally{m=K}}}})(j6);q6.exports=j6;var mE=q6.exports;/**
* @license React
* react-reconciler.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(n){n.exports=function(e){function t(l,u,p,_){return new R9(l,u,p,_)}function i(){}function a(l){var u="https://react.dev/errors/"+l;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)u+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(l){return l===null||typeof l!="object"?null:(l=JR&&l[JR]||l["@@iterator"],typeof l=="function"?l:null)}function s(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===L9?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case Th:return"Fragment";case Sh:return"Portal";case lS:return"Profiler";case ZR:return"StrictMode";case uS:return"Suspense";case hS:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case pl:return(l.displayName||"Context")+".Provider";case KR:return(l._context.displayName||"Context")+".Consumer";case cS:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case fS:return u=l.displayName||null,u!==null?u:s(l.type)||"Memo";case ml:u=l._payload,l=l._init;try{return s(l(u))}catch{}}return null}function o(l){if(dS===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);dS=u&&u[1]||"",$R=-1<p.stack.indexOf(`
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
`+dS+l+$R}function c(l,u){if(!l||pS)return"";pS=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var _={DetermineComponentFrameRoot:function(){try{if(u){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(Yt){var mt=Yt}Reflect.construct(l,[],dt)}else{try{dt.call()}catch(Yt){mt=Yt}l.call(dt.prototype)}}else{try{throw Error()}catch(Yt){mt=Yt}(dt=l())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(Yt){if(Yt&&mt&&typeof Yt.stack=="string")return[Yt.stack,mt.stack]}return[null,null]}};_.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var M=Object.getOwnPropertyDescriptor(_.DetermineComponentFrameRoot,"name");M&&M.configurable&&Object.defineProperty(_.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var A=_.DetermineComponentFrameRoot(),F=A[0],$=A[1];if(F&&$){var he=F.split(`
`),Ne=$.split(`
`);for(M=_=0;_<he.length&&!he[_].includes("DetermineComponentFrameRoot");)_++;for(;M<Ne.length&&!Ne[M].includes("DetermineComponentFrameRoot");)M++;if(_===he.length||M===Ne.length)for(_=he.length-1,M=Ne.length-1;1<=_&&0<=M&&he[_]!==Ne[M];)M--;for(;1<=_&&0<=M;_--,M--)if(he[_]!==Ne[M]){if(_!==1||M!==1)do if(_--,M--,0>M||he[_]!==Ne[M]){var et=`
`+he[_].replace(" at new "," at ");return l.displayName&&et.includes("<anonymous>")&&(et=et.replace("<anonymous>",l.displayName)),et}while(1<=_&&0<=M);break}}}finally{pS=!1,Error.prepareStackTrace=p}return(p=l?l.displayName||l.name:"")?o(p):""}function h(l){switch(l.tag){case 26:case 27:case 5:return o(l.type);case 16:return o("Lazy");case 13:return o("Suspense");case 19:return o("SuspenseList");case 0:case 15:return l=c(l.type,!1),l;case 11:return l=c(l.type.render,!1),l;case 1:return l=c(l.type,!0),l;default:return""}}function f(l){try{var u="";do u+=h(l),l=l.return;while(l);return u}catch(p){return`
Error generating stack: `+p.message+`
`+p.stack}}function d(l){var u=l,p=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,u.flags&4098&&(p=u.return),l=u.return;while(l)}return u.tag===3?p:null}function m(l){if(d(l)!==l)throw Error(a(188))}function g(l){var u=l.alternate;if(!u){if(u=d(l),u===null)throw Error(a(188));return u!==l?null:l}for(var p=l,_=u;;){var M=p.return;if(M===null)break;var A=M.alternate;if(A===null){if(_=M.return,_!==null){p=_;continue}break}if(M.child===A.child){for(A=M.child;A;){if(A===p)return m(M),l;if(A===_)return m(M),u;A=A.sibling}throw Error(a(188))}if(p.return!==_.return)p=M,_=A;else{for(var F=!1,$=M.child;$;){if($===p){F=!0,p=M,_=A;break}if($===_){F=!0,_=M,p=A;break}$=$.sibling}if(!F){for($=A.child;$;){if($===p){F=!0,p=A,_=M;break}if($===_){F=!0,_=A,p=M;break}$=$.sibling}if(!F)throw Error(a(189))}}if(p.alternate!==_)throw Error(a(190))}if(p.tag!==3)throw Error(a(188));return p.stateNode.current===p?l:u}function x(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l;for(l=l.child;l!==null;){if(u=x(l),u!==null)return u;l=l.sibling}return null}function T(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l;for(l=l.child;l!==null;){if(l.tag!==4&&(u=T(l),u!==null))return u;l=l.sibling}return null}function S(l){return{current:l}}function v(l){0>Mh||(l.current=yS[Mh],yS[Mh]=null,Mh--)}function y(l,u){Mh++,yS[Mh]=l.current,l.current=u}function E(l){return l>>>=0,l===0?32:31-(j7(l)/Z7|0)|0}function b(l){var u=l&42;if(u!==0)return u;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194176;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function D(l,u){var p=l.pendingLanes;if(p===0)return 0;var _=0,M=l.suspendedLanes,A=l.pingedLanes,F=l.warmLanes;l=l.finishedLanes!==0;var $=p&134217727;return $!==0?(p=$&~M,p!==0?_=b(p):(A&=$,A!==0?_=b(A):l||(F=$&~F,F!==0&&(_=b(F))))):($=p&~M,$!==0?_=b($):A!==0?_=b(A):l||(F=p&~F,F!==0&&(_=b(F)))),_===0?0:u!==0&&u!==_&&!(u&M)&&(M=_&-_,F=u&-u,M>=F||M===32&&(F&4194176)!==0)?u:_}function C(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function I(l,u){switch(l){case 1:case 2:case 4:case 8:return u+250;case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function P(){var l=lg;return lg<<=1,!(lg&4194176)&&(lg=128),l}function O(){var l=cg;return cg<<=1,!(cg&62914560)&&(cg=4194304),l}function R(l){for(var u=[],p=0;31>p;p++)u.push(l);return u}function B(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function j(l,u,p,_,M,A){var F=l.pendingLanes;l.pendingLanes=p,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=p,l.entangledLanes&=p,l.errorRecoveryDisabledLanes&=p,l.shellSuspendCounter=0;var $=l.entanglements,he=l.expirationTimes,Ne=l.hiddenUpdates;for(p=F&~p;0<p;){var et=31-hr(p),dt=1<<et;$[et]=0,he[et]=-1;var mt=Ne[et];if(mt!==null)for(Ne[et]=null,et=0;et<mt.length;et++){var Yt=mt[et];Yt!==null&&(Yt.lane&=-536870913)}p&=~dt}_!==0&&ee(l,_,0),A!==0&&M===0&&l.tag!==0&&(l.suspendedLanes|=A&~(F&~u))}function ee(l,u,p){l.pendingLanes|=u,l.suspendedLanes&=~u;var _=31-hr(u);l.entangledLanes|=u,l.entanglements[_]=l.entanglements[_]|1073741824|p&4194218}function se(l,u){var p=l.entangledLanes|=u;for(l=l.entanglements;p;){var _=31-hr(p),M=1<<_;M&u|l[_]&u&&(l[_]|=u),p&=~M}}function re(l){return l&=-l,2<l?8<l?l&134217727?32:268435456:8:2}function W(l){if(fr&&typeof fr.onCommitFiberRoot=="function")try{fr.onCommitFiberRoot(fp,l,void 0,(l.current.flags&128)===128)}catch{}}function te(l){if(typeof ez=="function"&&tz(l),fr&&typeof fr.setStrictMode=="function")try{fr.setStrictMode(fp,l)}catch{}}function K(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}function oe(l,u){if(typeof l=="object"&&l!==null){var p=bw.get(l);return p!==void 0?p:(u={value:l,source:u,stack:f(u)},bw.set(l,u),u)}return{value:l,source:u,stack:f(u)}}function ie(l,u){Ah[Rh++]=fg,Ah[Rh++]=hg,hg=l,fg=u}function Ce(l,u,p){Pr[zr++]=vo,Pr[zr++]=_o,Pr[zr++]=Uc,Uc=l;var _=vo;l=_o;var M=32-hr(_)-1;_&=~(1<<M),p+=1;var A=32-hr(u)+M;if(30<A){var F=M-M%5;A=(_&(1<<F)-1).toString(32),_>>=F,M-=F,vo=1<<32-hr(u)+M|p<<M|_,_o=A+l}else vo=1<<A|p<<M|_,_o=l}function Xe(l){l.return!==null&&(ie(l,1),Ce(l,1,0))}function nt(l){for(;l===hg;)hg=Ah[--Rh],Ah[Rh]=null,fg=Ah[--Rh],Ah[Rh]=null;for(;l===Uc;)Uc=Pr[--zr],Pr[zr]=null,_o=Pr[--zr],Pr[zr]=null,vo=Pr[--zr],Pr[zr]=null}function tt(l,u){y(vl,u),y(dp,l),y(aa,null),l=P9(u),v(aa),y(aa,l)}function gt(){v(aa),v(dp),v(vl)}function ge(l){l.memoizedState!==null&&y(dg,l);var u=aa.current,p=z9(u,l.type);u!==p&&(y(dp,l),y(aa,p))}function Ae(l){dp.current===l&&(v(aa),v(dp)),dg.current===l&&(v(dg),go?Ic._currentValue=Eh:Ic._currentValue2=Eh)}function Ze(l){var u=Error(a(418,""));throw Ke(oe(u,l)),ES}function ue(l,u){if(!Ir)throw Error(a(175));N7(l.stateNode,l.type,l.memoizedProps,u,l)||Ze(l)}function it(l){for(Ma=l.return;Ma;)switch(Ma.tag){case 3:case 27:Bs=!0;return;case 5:case 13:Bs=!1;return;default:Ma=Ma.return}}function Mt(l){if(!Ir||l!==Ma)return!1;if(!pn)return it(l),pn=!0,!1;var u=!1;if(ma?l.tag!==3&&l.tag!==27&&(l.tag!==5||pw(l.type)&&!og(l.type,l.memoizedProps))&&(u=!0):l.tag!==3&&(l.tag!==5||pw(l.type)&&!og(l.type,l.memoizedProps))&&(u=!0),u&&ga&&Ze(l),it(l),l.tag===13){if(!Ir)throw Error(a(316));if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(a(317));ga=L7(l)}else ga=Ma?fw(l.stateNode):null;return!0}function ot(){Ir&&(ga=Ma=null,pn=!1)}function Ke(l){hs===null?hs=[l]:hs.push(l)}function Te(){for(var l=wh,u=MS=wh=0;u<l;){var p=Br[u];Br[u++]=null;var _=Br[u];Br[u++]=null;var M=Br[u];Br[u++]=null;var A=Br[u];if(Br[u++]=null,_!==null&&M!==null){var F=_.pending;F===null?M.next=M:(M.next=F.next,F.next=M),_.pending=M}A!==0&&Fe(p,M,A)}}function G(l,u,p,_){Br[wh++]=l,Br[wh++]=u,Br[wh++]=p,Br[wh++]=_,MS|=_,l.lanes|=_,l=l.alternate,l!==null&&(l.lanes|=_)}function Me(l,u,p,_){return G(l,u,p,_),Be(l)}function De(l,u){return G(l,null,null,u),Be(l)}function Fe(l,u,p){l.lanes|=p;var _=l.alternate;_!==null&&(_.lanes|=p);for(var M=!1,A=l.return;A!==null;)A.childLanes|=p,_=A.alternate,_!==null&&(_.childLanes|=p),A.tag===22&&(l=A.stateNode,l===null||l._visibility&1||(M=!0)),l=A,A=A.return;M&&u!==null&&l.tag===3&&(A=l.stateNode,M=31-hr(p),A=A.hiddenUpdates,l=A[M],l===null?A[M]=[u]:l.push(u),u.lane=p|536870912)}function Be(l){if(50<Tp)throw Tp=0,FS=null,Error(a(185));for(var u=l.return;u!==null;)l=u,u=l.return;return l.tag===3?l.stateNode:null}function $e(l){l!==Ch&&l.next===null&&(Ch===null?pg=Ch=l:Ch=Ch.next=l),mg=!0,bS||(bS=!0,Ee(ct))}function Je(l,u){if(!AS&&mg){AS=!0;do for(var p=!1,_=pg;_!==null;){if(l!==0){var M=_.pendingLanes;if(M===0)var A=0;else{var F=_.suspendedLanes,$=_.pingedLanes;A=(1<<31-hr(42|l)+1)-1,A&=M&~(F&~$),A=A&201326677?A&201326677|1:A?A|2:0}A!==0&&(p=!0,ce(_,A))}else A=hn,A=D(_,_===Vn?A:0),!(A&3)||C(_,A)||(p=!0,ce(_,A));_=_.next}while(p);AS=!1}}function ct(){mg=bS=!1;var l=0;Nh!==0&&(X9()&&(l=Nh),Nh=0);for(var u=us(),p=null,_=pg;_!==null;){var M=_.next,A=k(_,u);A===0?(_.next=null,p===null?pg=M:p.next=M,M===null&&(Ch=p)):(p=_,(l!==0||A&3)&&(mg=!0)),_=M}Je(l)}function k(l,u){for(var p=l.suspendedLanes,_=l.pingedLanes,M=l.expirationTimes,A=l.pendingLanes&-62914561;0<A;){var F=31-hr(A),$=1<<F,he=M[F];he===-1?(!($&p)||$&_)&&(M[F]=I($,u)):he<=u&&(l.expiredLanes|=$),A&=~$}if(u=Vn,p=hn,p=D(l,l===u?p:0),_=l.callbackNode,p===0||l===u&&kn===2||l.cancelPendingCommit!==null)return _!==null&&_!==null&&SS(_),l.callbackNode=null,l.callbackPriority=0;if(!(p&3)||C(l,p)){if(u=p&-p,u===l.callbackPriority)return u;switch(_!==null&&SS(_),re(p)){case 2:case 8:p=J7;break;case 32:p=TS;break;case 268435456:p=$7;break;default:p=TS}return _=U.bind(null,l),p=ug(p,_),l.callbackPriority=u,l.callbackNode=p,u}return _!==null&&_!==null&&SS(_),l.callbackPriority=2,l.callbackNode=null,2}function U(l,u){var p=l.callbackNode;if(Dc()&&l.callbackNode!==p)return null;var _=hn;return _=D(l,l===Vn?_:0),_===0?null:(wR(l,_,u),k(l,us()),l.callbackNode!=null&&l.callbackNode===p?U.bind(null,l):null)}function ce(l,u){if(Dc())return null;wR(l,u,!0)}function Ee(l){Q9?J9(function(){In&6?ug(Mw,l):l()}):ug(Mw,l)}function Le(){return Nh===0&&(Nh=P()),Nh}function ye(l,u){if(pp===null){var p=pp=[];RS=0,Dh=Le(),Oh={status:"pending",value:void 0,then:function(_){p.push(_)}}}return RS++,u.then(vt,vt),u}function vt(){if(--RS===0&&pp!==null){Oh!==null&&(Oh.status="fulfilled");var l=pp;pp=null,Dh=0,Oh=null;for(var u=0;u<l.length;u++)(0,l[u])()}}function qe(l,u){var p=[],_={status:"pending",value:null,reason:null,then:function(M){p.push(M)}};return l.then(function(){_.status="fulfilled",_.value=u;for(var M=0;M<p.length;M++)(0,p[M])(u)},function(M){for(_.status="rejected",_.reason=M,M=0;M<p.length;M++)(0,p[M])(void 0)}),_}function _t(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function pt(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function Ie(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function He(l,u,p){var _=l.updateQueue;if(_===null)return null;if(_=_.shared,In&2){var M=_.pending;return M===null?u.next=u:(u.next=M.next,M.next=u),_.pending=u,u=Be(l),Fe(l,null,p),u}return G(l,_,u,p),Be(l)}function ht(l,u,p){if(u=u.updateQueue,u!==null&&(u=u.shared,(p&4194176)!==0)){var _=u.lanes;_&=l.pendingLanes,p|=_,u.lanes=p,se(l,p)}}function Q(l,u){var p=l.updateQueue,_=l.alternate;if(_!==null&&(_=_.updateQueue,p===_)){var M=null,A=null;if(p=p.firstBaseUpdate,p!==null){do{var F={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};A===null?M=A=F:A=A.next=F,p=p.next}while(p!==null);A===null?M=A=u:A=A.next=u}else M=A=u;p={baseState:_.baseState,firstBaseUpdate:M,lastBaseUpdate:A,shared:_.shared,callbacks:_.callbacks},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=u}function pe(){if(wS){var l=Oh;if(l!==null)throw l}}function Oe(l,u,p,_){wS=!1;var M=l.updateQueue;_l=!1;var A=M.firstBaseUpdate,F=M.lastBaseUpdate,$=M.shared.pending;if($!==null){M.shared.pending=null;var he=$,Ne=he.next;he.next=null,F===null?A=Ne:F.next=Ne,F=he;var et=l.alternate;et!==null&&(et=et.updateQueue,$=et.lastBaseUpdate,$!==F&&($===null?et.firstBaseUpdate=Ne:$.next=Ne,et.lastBaseUpdate=he))}if(A!==null){var dt=M.baseState;F=0,et=Ne=he=null,$=A;do{var mt=$.lane&-536870913,Yt=mt!==$.lane;if(Yt?(hn&mt)===mt:(_&mt)===mt){mt!==0&&mt===Dh&&(wS=!0),et!==null&&(et=et.next={lane:0,tag:$.tag,payload:$.payload,callback:null,next:null});e:{var Gr=l,Ep=$;mt=u;var Wc=p;switch(Ep.tag){case 1:if(Gr=Ep.payload,typeof Gr=="function"){dt=Gr.call(Wc,dt,mt);break e}dt=Gr;break e;case 3:Gr.flags=Gr.flags&-65537|128;case 0:if(Gr=Ep.payload,mt=typeof Gr=="function"?Gr.call(Wc,dt,mt):Gr,mt==null)break e;dt=oS({},dt,mt);break e;case 2:_l=!0}}mt=$.callback,mt!==null&&(l.flags|=64,Yt&&(l.flags|=8192),Yt=M.callbacks,Yt===null?M.callbacks=[mt]:Yt.push(mt))}else Yt={lane:mt,tag:$.tag,payload:$.payload,callback:$.callback,next:null},et===null?(Ne=et=Yt,he=dt):et=et.next=Yt,F|=mt;if($=$.next,$===null){if($=M.shared.pending,$===null)break;Yt=$,$=Yt.next,Yt.next=null,M.lastBaseUpdate=Yt,M.shared.pending=null}}while(!0);et===null&&(he=dt),M.baseState=he,M.firstBaseUpdate=Ne,M.lastBaseUpdate=et,A===null&&(M.shared.lanes=0),Sl|=F,l.lanes=F,l.memoizedState=dt}}function q(l,u){if(typeof l!="function")throw Error(a(191,l));l.call(u)}function Ve(l,u){var p=l.callbacks;if(p!==null)for(l.callbacks=null,l=0;l<p.length;l++)q(p[l],u)}function me(l,u){if(dr(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var p=Object.keys(l),_=Object.keys(u);if(p.length!==_.length)return!1;for(_=0;_<p.length;_++){var M=p[_];if(!nz.call(u,M)||!dr(l[M],u[M]))return!1}return!0}function We(l){return l=l.status,l==="fulfilled"||l==="rejected"}function Ge(){}function Re(l,u,p){switch(p=l[p],p===void 0?l.push(u):p!==u&&(u.then(Ge,Ge),u=p),u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,l===mp?Error(a(483)):l;default:if(typeof u.status=="string")u.then(Ge,Ge);else{if(l=Vn,l!==null&&100<l.shellSuspendCounter)throw Error(a(482));l=u,l.status="pending",l.then(function(_){if(u.status==="pending"){var M=u;M.status="fulfilled",M.value=_}},function(_){if(u.status==="pending"){var M=u;M.status="rejected",M.reason=_}})}switch(u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,l===mp?Error(a(483)):l}throw Lh=u,mp}}function rt(){if(Lh===null)throw Error(a(459));var l=Lh;return Lh=null,l}function yt(l){var u=gp;return gp+=1,Ih===null&&(Ih=[]),Re(Ih,l,u)}function Gt(l,u){u=u.props.ref,l.ref=u!==void 0?u:null}function Vt(l,u){throw u.$$typeof===N9?Error(a(525)):(l=Object.prototype.toString.call(u),Error(a(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l)))}function oi(l){var u=l._init;return u(l._payload)}function li(l){function u(ve,le){if(l){var xe=ve.deletions;xe===null?(ve.deletions=[le],ve.flags|=16):xe.push(le)}}function p(ve,le){if(!l)return null;for(;le!==null;)u(ve,le),le=le.sibling;return null}function _(ve){for(var le=new Map;ve!==null;)ve.key!==null?le.set(ve.key,ve):le.set(ve.index,ve),ve=ve.sibling;return le}function M(ve,le){return ve=dl(ve,le),ve.index=0,ve.sibling=null,ve}function A(ve,le,xe){return ve.index=xe,l?(xe=ve.alternate,xe!==null?(xe=xe.index,xe<le?(ve.flags|=33554434,le):xe):(ve.flags|=33554434,le)):(ve.flags|=1048576,le)}function F(ve){return l&&ve.alternate===null&&(ve.flags|=33554434),ve}function $(ve,le,xe,Qe){return le===null||le.tag!==6?(le=aS(xe,ve.mode,Qe),le.return=ve,le):(le=M(le,xe),le.return=ve,le)}function he(ve,le,xe,Qe){var Rt=xe.type;return Rt===Th?et(ve,le,xe.props.children,Qe,xe.key):le!==null&&(le.elementType===Rt||typeof Rt=="object"&&Rt!==null&&Rt.$$typeof===ml&&oi(Rt)===le.type)?(le=M(le,xe.props),Gt(le,xe),le.return=ve,le):(le=ag(xe.type,xe.key,xe.props,null,ve.mode,Qe),Gt(le,xe),le.return=ve,le)}function Ne(ve,le,xe,Qe){return le===null||le.tag!==4||le.stateNode.containerInfo!==xe.containerInfo||le.stateNode.implementation!==xe.implementation?(le=rS(xe,ve.mode,Qe),le.return=ve,le):(le=M(le,xe.children||[]),le.return=ve,le)}function et(ve,le,xe,Qe,Rt){return le===null||le.tag!==7?(le=Oc(xe,ve.mode,Qe,Rt),le.return=ve,le):(le=M(le,xe),le.return=ve,le)}function dt(ve,le,xe){if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return le=aS(""+le,ve.mode,xe),le.return=ve,le;if(typeof le=="object"&&le!==null){switch(le.$$typeof){case rg:return xe=ag(le.type,le.key,le.props,null,ve.mode,xe),Gt(xe,le),xe.return=ve,xe;case Sh:return le=rS(le,ve.mode,xe),le.return=ve,le;case ml:var Qe=le._init;return le=Qe(le._payload),dt(ve,le,xe)}if(sg(le)||r(le))return le=Oc(le,ve.mode,xe,null),le.return=ve,le;if(typeof le.then=="function")return dt(ve,yt(le),xe);if(le.$$typeof===pl)return dt(ve,J0(ve,le),xe);Vt(ve,le)}return null}function mt(ve,le,xe,Qe){var Rt=le!==null?le.key:null;if(typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint")return Rt!==null?null:$(ve,le,""+xe,Qe);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case rg:return xe.key===Rt?he(ve,le,xe,Qe):null;case Sh:return xe.key===Rt?Ne(ve,le,xe,Qe):null;case ml:return Rt=xe._init,xe=Rt(xe._payload),mt(ve,le,xe,Qe)}if(sg(xe)||r(xe))return Rt!==null?null:et(ve,le,xe,Qe,null);if(typeof xe.then=="function")return mt(ve,le,yt(xe),Qe);if(xe.$$typeof===pl)return mt(ve,le,J0(ve,xe),Qe);Vt(ve,xe)}return null}function Yt(ve,le,xe,Qe,Rt){if(typeof Qe=="string"&&Qe!==""||typeof Qe=="number"||typeof Qe=="bigint")return ve=ve.get(xe)||null,$(le,ve,""+Qe,Rt);if(typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case rg:return ve=ve.get(Qe.key===null?xe:Qe.key)||null,he(le,ve,Qe,Rt);case Sh:return ve=ve.get(Qe.key===null?xe:Qe.key)||null,Ne(le,ve,Qe,Rt);case ml:var Zn=Qe._init;return Qe=Zn(Qe._payload),Yt(ve,le,xe,Qe,Rt)}if(sg(Qe)||r(Qe))return ve=ve.get(xe)||null,et(le,ve,Qe,Rt,null);if(typeof Qe.then=="function")return Yt(ve,le,xe,yt(Qe),Rt);if(Qe.$$typeof===pl)return Yt(ve,le,xe,J0(le,Qe),Rt);Vt(le,Qe)}return null}function Gr(ve,le,xe,Qe){for(var Rt=null,Zn=null,Pt=le,mn=le=0,Yi=null;Pt!==null&&mn<xe.length;mn++){Pt.index>mn?(Yi=Pt,Pt=null):Yi=Pt.sibling;var gn=mt(ve,Pt,xe[mn],Qe);if(gn===null){Pt===null&&(Pt=Yi);break}l&&Pt&&gn.alternate===null&&u(ve,Pt),le=A(gn,le,mn),Zn===null?Rt=gn:Zn.sibling=gn,Zn=gn,Pt=Yi}if(mn===xe.length)return p(ve,Pt),pn&&ie(ve,mn),Rt;if(Pt===null){for(;mn<xe.length;mn++)Pt=dt(ve,xe[mn],Qe),Pt!==null&&(le=A(Pt,le,mn),Zn===null?Rt=Pt:Zn.sibling=Pt,Zn=Pt);return pn&&ie(ve,mn),Rt}for(Pt=_(Pt);mn<xe.length;mn++)Yi=Yt(Pt,ve,mn,xe[mn],Qe),Yi!==null&&(l&&Yi.alternate!==null&&Pt.delete(Yi.key===null?mn:Yi.key),le=A(Yi,le,mn),Zn===null?Rt=Yi:Zn.sibling=Yi,Zn=Yi);return l&&Pt.forEach(function(El){return u(ve,El)}),pn&&ie(ve,mn),Rt}function Ep(ve,le,xe,Qe){if(xe==null)throw Error(a(151));for(var Rt=null,Zn=null,Pt=le,mn=le=0,Yi=null,gn=xe.next();Pt!==null&&!gn.done;mn++,gn=xe.next()){Pt.index>mn?(Yi=Pt,Pt=null):Yi=Pt.sibling;var El=mt(ve,Pt,gn.value,Qe);if(El===null){Pt===null&&(Pt=Yi);break}l&&Pt&&El.alternate===null&&u(ve,Pt),le=A(El,le,mn),Zn===null?Rt=El:Zn.sibling=El,Zn=El,Pt=Yi}if(gn.done)return p(ve,Pt),pn&&ie(ve,mn),Rt;if(Pt===null){for(;!gn.done;mn++,gn=xe.next())gn=dt(ve,gn.value,Qe),gn!==null&&(le=A(gn,le,mn),Zn===null?Rt=gn:Zn.sibling=gn,Zn=gn);return pn&&ie(ve,mn),Rt}for(Pt=_(Pt);!gn.done;mn++,gn=xe.next())gn=Yt(Pt,ve,mn,gn.value,Qe),gn!==null&&(l&&gn.alternate!==null&&Pt.delete(gn.key===null?mn:gn.key),le=A(gn,le,mn),Zn===null?Rt=gn:Zn.sibling=gn,Zn=gn);return l&&Pt.forEach(function(cz){return u(ve,cz)}),pn&&ie(ve,mn),Rt}function Wc(ve,le,xe,Qe){if(typeof xe=="object"&&xe!==null&&xe.type===Th&&xe.key===null&&(xe=xe.props.children),typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case rg:e:{for(var Rt=xe.key;le!==null;){if(le.key===Rt){if(Rt=xe.type,Rt===Th){if(le.tag===7){p(ve,le.sibling),Qe=M(le,xe.props.children),Qe.return=ve,ve=Qe;break e}}else if(le.elementType===Rt||typeof Rt=="object"&&Rt!==null&&Rt.$$typeof===ml&&oi(Rt)===le.type){p(ve,le.sibling),Qe=M(le,xe.props),Gt(Qe,xe),Qe.return=ve,ve=Qe;break e}p(ve,le);break}else u(ve,le);le=le.sibling}xe.type===Th?(Qe=Oc(xe.props.children,ve.mode,Qe,xe.key),Qe.return=ve,ve=Qe):(Qe=ag(xe.type,xe.key,xe.props,null,ve.mode,Qe),Gt(Qe,xe),Qe.return=ve,ve=Qe)}return F(ve);case Sh:e:{for(Rt=xe.key;le!==null;){if(le.key===Rt)if(le.tag===4&&le.stateNode.containerInfo===xe.containerInfo&&le.stateNode.implementation===xe.implementation){p(ve,le.sibling),Qe=M(le,xe.children||[]),Qe.return=ve,ve=Qe;break e}else{p(ve,le);break}else u(ve,le);le=le.sibling}Qe=rS(xe,ve.mode,Qe),Qe.return=ve,ve=Qe}return F(ve);case ml:return Rt=xe._init,xe=Rt(xe._payload),Wc(ve,le,xe,Qe)}if(sg(xe))return Gr(ve,le,xe,Qe);if(r(xe)){if(Rt=r(xe),typeof Rt!="function")throw Error(a(150));return xe=Rt.call(xe),Ep(ve,le,xe,Qe)}if(typeof xe.then=="function")return Wc(ve,le,yt(xe),Qe);if(xe.$$typeof===pl)return Wc(ve,le,J0(ve,xe),Qe);Vt(ve,xe)}return typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint"?(xe=""+xe,le!==null&&le.tag===6?(p(ve,le.sibling),Qe=M(le,xe),Qe.return=ve,ve=Qe):(p(ve,le),Qe=aS(xe,ve.mode,Qe),Qe.return=ve,ve=Qe),F(ve)):p(ve,le)}return function(ve,le,xe,Qe){try{gp=0;var Rt=Wc(ve,le,xe,Qe);return Ih=null,Rt}catch(Pt){if(Pt===mp)throw Pt;var Zn=t(29,Pt,null,ve.mode);return Zn.lanes=Qe,Zn.return=ve,Zn}finally{}}}function co(l,u){l=To,y(vg,l),y(Uh,u),To=l|u.baseLanes}function Ls(){y(vg,To),y(Uh,Uh.current)}function Is(){To=vg.current,v(Uh),v(vg)}function Ei(l){var u=l.alternate;y(zi,zi.current&1),y(Hr,l),Hs===null&&(u===null||Uh.current!==null||u.memoizedState!==null)&&(Hs=l)}function Us(l){if(l.tag===22){if(y(zi,zi.current),y(Hr,l),Hs===null){var u=l.alternate;u!==null&&u.memoizedState!==null&&(Hs=l)}}else ha()}function ha(){y(zi,zi.current),y(Hr,Hr.current)}function ki(l){v(Hr),Hs===l&&(Hs=null),v(zi)}function Ha(l){for(var u=l;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||vS(p)||_S(p)))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if(u.flags&128)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}function Dn(){throw Error(a(321))}function Or(l,u){if(u===null)return!1;for(var p=0;p<u.length&&p<l.length;p++)if(!dr(l[p],u[p]))return!1;return!0}function Ps(l,u,p,_,M,A){return xl=A,en=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Ft.H=l===null||l.memoizedState===null?Bc:yl,zc=!1,A=p(_,M),zc=!1,Ph&&(A=uo(u,p,_,M)),zs(l),A}function zs(l){Ft.H=Fs;var u=Ln!==null&&Ln.next!==null;if(xl=0,bi=Ln=en=null,_g=!1,vp=0,zh=null,u)throw Error(a(300));l===null||Wi||(l=l.dependencies,l!==null&&Q0(l)&&(Wi=!0))}function uo(l,u,p,_){en=l;var M=0;do{if(Ph&&(zh=null),vp=0,Ph=!1,25<=M)throw Error(a(301));if(M+=1,bi=Ln=null,l.updateQueue!=null){var A=l.updateQueue;A.lastEffect=null,A.events=null,A.stores=null,A.memoCache!=null&&(A.memoCache.index=0)}Ft.H=Hc,A=u(p,_)}while(Ph);return A}function rr(){var l=Ft.H,u=l.useState()[0];return u=typeof u.then=="function"?V(u):u,l=l.useState()[0],(Ln!==null?Ln.memoizedState:null)!==l&&(en.flags|=1024),u}function fa(){var l=xg!==0;return xg=0,l}function w(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function z(l){if(_g){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}_g=!1}xl=0,bi=Ln=en=null,Ph=!1,vp=xg=0,zh=null}function Y(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bi===null?en.memoizedState=bi=l:bi=bi.next=l,bi}function N(){if(Ln===null){var l=en.alternate;l=l!==null?l.memoizedState:null}else l=Ln.next;var u=bi===null?en.memoizedState:bi.next;if(u!==null)bi=u,Ln=l;else{if(l===null)throw en.alternate===null?Error(a(467)):Error(a(310));Ln=l,l={memoizedState:Ln.memoizedState,baseState:Ln.baseState,baseQueue:Ln.baseQueue,queue:Ln.queue,next:null},bi===null?en.memoizedState=bi=l:bi=bi.next=l}return bi}function V(l){var u=vp;return vp+=1,zh===null&&(zh=[]),l=Re(zh,l,u),u=en,(bi===null?u.memoizedState:bi.next)===null&&(u=u.alternate,Ft.H=u===null||u.memoizedState===null?Bc:yl),l}function Z(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return V(l);if(l.$$typeof===pl)return da(l)}throw Error(a(438,String(l)))}function H(l){var u=null,p=en.updateQueue;if(p!==null&&(u=p.memoCache),u==null){var _=en.alternate;_!==null&&(_=_.updateQueue,_!==null&&(_=_.memoCache,_!=null&&(u={data:_.data.map(function(M){return M.slice()}),index:0})))}if(u==null&&(u={data:[],index:0}),p===null&&(p=NS(),en.updateQueue=p),p.memoCache=u,p=u.data[u.index],p===void 0)for(p=u.data[u.index]=Array(l),_=0;_<l;_++)p[_]=O9;return u.index++,p}function X(l,u){return typeof u=="function"?u(l):u}function ne(l){var u=N();return ae(u,Ln,l)}function ae(l,u,p){var _=l.queue;if(_===null)throw Error(a(311));_.lastRenderedReducer=p;var M=l.baseQueue,A=_.pending;if(A!==null){if(M!==null){var F=M.next;M.next=A.next,A.next=F}u.baseQueue=M=A,_.pending=null}if(A=l.baseState,M===null)l.memoizedState=A;else{u=M.next;var $=F=null,he=null,Ne=u,et=!1;do{var dt=Ne.lane&-536870913;if(dt!==Ne.lane?(hn&dt)===dt:(xl&dt)===dt){var mt=Ne.revertLane;if(mt===0)he!==null&&(he=he.next={lane:0,revertLane:0,action:Ne.action,hasEagerState:Ne.hasEagerState,eagerState:Ne.eagerState,next:null}),dt===Dh&&(et=!0);else if((xl&mt)===mt){Ne=Ne.next,mt===Dh&&(et=!0);continue}else dt={lane:0,revertLane:Ne.revertLane,action:Ne.action,hasEagerState:Ne.hasEagerState,eagerState:Ne.eagerState,next:null},he===null?($=he=dt,F=A):he=he.next=dt,en.lanes|=mt,Sl|=mt;dt=Ne.action,zc&&p(A,dt),A=Ne.hasEagerState?Ne.eagerState:p(A,dt)}else mt={lane:dt,revertLane:Ne.revertLane,action:Ne.action,hasEagerState:Ne.hasEagerState,eagerState:Ne.eagerState,next:null},he===null?($=he=mt,F=A):he=he.next=mt,en.lanes|=dt,Sl|=dt;Ne=Ne.next}while(Ne!==null&&Ne!==u);if(he===null?F=A:he.next=$,!dr(A,l.memoizedState)&&(Wi=!0,et&&(p=Oh,p!==null)))throw p;l.memoizedState=A,l.baseState=F,l.baseQueue=he,_.lastRenderedState=A}return M===null&&(_.lanes=0),[l.memoizedState,_.dispatch]}function fe(l){var u=N(),p=u.queue;if(p===null)throw Error(a(311));p.lastRenderedReducer=l;var _=p.dispatch,M=p.pending,A=u.memoizedState;if(M!==null){p.pending=null;var F=M=M.next;do A=l(A,F.action),F=F.next;while(F!==M);dr(A,u.memoizedState)||(Wi=!0),u.memoizedState=A,u.baseQueue===null&&(u.baseState=A),p.lastRenderedState=A}return[A,_]}function _e(l,u,p){var _=en,M=N(),A=pn;if(A){if(p===void 0)throw Error(a(407));p=p()}else p=u();var F=!dr((Ln||M).memoizedState,p);if(F&&(M.memoizedState=p,Wi=!0),M=M.queue,yy(Pe.bind(null,_,M,l),[l]),M.getSnapshot!==u||F||bi!==null&&bi.memoizedState.tag&1){if(_.flags|=2048,Gn(9,we.bind(null,_,M,p,u),{destroy:void 0},null),Vn===null)throw Error(a(349));A||xl&60||Se(_,u,p)}return p}function Se(l,u,p){l.flags|=16384,l={getSnapshot:u,value:p},u=en.updateQueue,u===null?(u=NS(),en.updateQueue=u,u.stores=[l]):(p=u.stores,p===null?u.stores=[l]:p.push(l))}function we(l,u,p,_){u.value=p,u.getSnapshot=_,ze(u)&&Ye(l)}function Pe(l,u,p){return p(function(){ze(u)&&Ye(l)})}function ze(l){var u=l.getSnapshot;l=l.value;try{var p=u();return!dr(l,p)}catch{return!0}}function Ye(l){var u=De(l,2);u!==null&&Ea(u,l,2)}function lt(l){var u=Y();if(typeof l=="function"){var p=l;if(l=p(),zc){te(!0);try{p()}finally{te(!1)}}}return u.memoizedState=u.baseState=l,u.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:X,lastRenderedState:l},u}function St(l,u,p,_){return l.baseState=p,ae(l,Ln,typeof _=="function"?_:X)}function bt(l,u,p,_,M){if(Z0(l))throw Error(a(485));if(l=u.action,l!==null){var A={payload:M,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(F){A.listeners.push(F)}};Ft.T!==null?p(!0):A.isTransition=!1,_(A),p=u.pending,p===null?(A.next=u.pending=A,ft(u,A)):(A.next=p.next,u.pending=p.next=A)}}function ft(l,u){var p=u.action,_=u.payload,M=l.state;if(u.isTransition){var A=Ft.T,F={};Ft.T=F;try{var $=p(M,_),he=Ft.S;he!==null&&he(F,$),At(l,u,$)}catch(Ne){Kt(l,u,Ne)}finally{Ft.T=A}}else try{A=p(M,_),At(l,u,A)}catch(Ne){Kt(l,u,Ne)}}function At(l,u,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(_){st(l,u,_)},function(_){return Kt(l,u,_)}):st(l,u,p)}function st(l,u,p){u.status="fulfilled",u.value=p,On(u),l.state=p,u=l.pending,u!==null&&(p=u.next,p===u?l.pending=null:(p=p.next,u.next=p,ft(l,p)))}function Kt(l,u,p){var _=l.pending;if(l.pending=null,_!==null){_=_.next;do u.status="rejected",u.reason=p,On(u),u=u.next;while(u!==_)}l.action=null}function On(l){l=l.listeners;for(var u=0;u<l.length;u++)(0,l[u])()}function Xt(l,u){return u}function kt(l,u){if(pn){var p=Vn.formState;if(p!==null){e:{var _=en;if(pn){if(ga){var M=E7(ga,Bs);if(M){ga=fw(M),_=M7(M);break e}}Ze(_)}_=!1}_&&(u=p[0])}}p=Y(),p.memoizedState=p.baseState=u,_={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xt,lastRenderedState:u},p.queue=_,p=zA.bind(null,en,_),_.dispatch=p,_=lt(!1);var A=My.bind(null,en,!1,_.queue);return _=Y(),M={state:u,dispatch:null,action:l,pending:null},_.queue=M,p=bt.bind(null,en,M,A,p),M.dispatch=p,_.memoizedState=l,[u,p,!1]}function Ct(l){var u=N();return Bn(u,Ln,l)}function Bn(l,u,p){u=ae(l,u,Xt)[0],l=ne(X)[0],u=typeof u=="object"&&u!==null&&typeof u.then=="function"?V(u):u;var _=N(),M=_.queue,A=M.dispatch;return p!==_.memoizedState&&(en.flags|=2048,Gn(9,Mi.bind(null,M,p),{destroy:void 0},null)),[u,A,l]}function Mi(l,u){l.action=u}function Mn(l){var u=N(),p=Ln;if(p!==null)return Bn(u,p,l);N(),u=u.memoizedState,p=N();var _=p.queue.dispatch;return p.memoizedState=l,[u,_,!1]}function Gn(l,u,p,_){return l={tag:l,create:u,inst:p,deps:_,next:null},u=en.updateQueue,u===null&&(u=NS(),en.updateQueue=u),p=u.lastEffect,p===null?u.lastEffect=l.next=l:(_=p.next,p.next=l,l.next=_,u.lastEffect=l),l}function gh(){return N().memoizedState}function Lr(l,u,p,_){var M=Y();en.flags|=l,M.memoizedState=Gn(1|u,p,{destroy:void 0},_===void 0?null:_)}function j0(l,u,p,_){var M=N();_=_===void 0?null:_;var A=M.memoizedState.inst;Ln!==null&&_!==null&&Or(_,Ln.memoizedState.deps)?M.memoizedState=Gn(u,p,A,_):(en.flags|=l,M.memoizedState=Gn(1|u,p,A,_))}function bA(l,u){Lr(8390656,8,l,u)}function yy(l,u){j0(2048,8,l,u)}function AA(l,u){return j0(4,2,l,u)}function RA(l,u){return j0(4,4,l,u)}function wA(l,u){if(typeof u=="function"){l=l();var p=u(l);return function(){typeof p=="function"?p():u(null)}}if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function CA(l,u,p){p=p!=null?p.concat([l]):null,j0(4,4,wA.bind(null,u,l),p)}function Sy(){}function NA(l,u){var p=N();u=u===void 0?null:u;var _=p.memoizedState;return u!==null&&Or(u,_[1])?_[0]:(p.memoizedState=[l,u],l)}function DA(l,u){var p=N();u=u===void 0?null:u;var _=p.memoizedState;if(u!==null&&Or(u,_[1]))return _[0];if(_=l(),zc){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[_,u],_}function Ty(l,u,p){return p===void 0||xl&1073741824?l.memoizedState=u:(l.memoizedState=p,l=RR(),en.lanes|=l,Sl|=l,p)}function OA(l,u,p,_){return dr(p,u)?p:Uh.current!==null?(l=Ty(l,p,_),dr(l,u)||(Wi=!0),l):xl&42?(l=RR(),en.lanes|=l,Sl|=l,u):(Wi=!0,l.memoizedState=p)}function LA(l,u,p,_,M){var A=Lc();Ga(A!==0&&8>A?A:8);var F=Ft.T,$={};Ft.T=$,My(l,!1,u,p);try{var he=M(),Ne=Ft.S;if(Ne!==null&&Ne($,he),he!==null&&typeof he=="object"&&typeof he.then=="function"){var et=qe(he,_);tp(l,u,et,cr(l))}else tp(l,u,_,cr(l))}catch(dt){tp(l,u,{then:function(){},status:"rejected",reason:dt},cr())}finally{Ga(A),Ft.T=F}}function IA(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:Eh,baseState:Eh,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:X,lastRenderedState:Eh},next:null};var p={};return u.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:X,lastRenderedState:p},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function Ey(){return da(Ic)}function UA(){return N().memoizedState}function PA(){return N().memoizedState}function u9(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var p=cr();l=Ie(p);var _=He(u,l,p);_!==null&&(Ea(_,u,p),ht(_,u,p)),u={cache:zy()},l.payload=u;return}u=u.return}}function h9(l,u,p){var _=cr();p={lane:_,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null},Z0(l)?BA(u,p):(p=Me(l,u,p,_),p!==null&&(Ea(p,l,_),HA(p,u,_)))}function zA(l,u,p){var _=cr();tp(l,u,p,_)}function tp(l,u,p,_){var M={lane:_,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null};if(Z0(l))BA(u,M);else{var A=l.alternate;if(l.lanes===0&&(A===null||A.lanes===0)&&(A=u.lastRenderedReducer,A!==null))try{var F=u.lastRenderedState,$=A(F,p);if(M.hasEagerState=!0,M.eagerState=$,dr($,F))return G(l,u,M,0),Vn===null&&Te(),!1}catch{}finally{}if(p=Me(l,u,M,_),p!==null)return Ea(p,l,_),HA(p,u,_),!0}return!1}function My(l,u,p,_){if(_={lane:2,revertLane:Le(),action:_,hasEagerState:!1,eagerState:null,next:null},Z0(l)){if(u)throw Error(a(479))}else u=Me(l,p,_,2),u!==null&&Ea(u,l,2)}function Z0(l){var u=l.alternate;return l===en||u!==null&&u===en}function BA(l,u){Ph=_g=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function HA(l,u,p){if(p&4194176){var _=u.lanes;_&=l.pendingLanes,p|=_,u.lanes=p,se(l,p)}}function by(l,u,p,_){u=l.memoizedState,p=p(_,u),p=p==null?u:oS({},u,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}function FA(l,u,p,_,M,A,F){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(_,A,F):u.prototype&&u.prototype.isPureReactComponent?!me(p,_)||!me(M,A):!0}function GA(l,u,p,_){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(p,_),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(p,_),u.state!==l&&DS.enqueueReplaceState(u,u.state,null)}function Rc(l,u){var p=u;if("ref"in u){p={};for(var _ in u)_!=="ref"&&(p[_]=u[_])}if(l=l.defaultProps){p===u&&(p=oS({},p));for(var M in l)p[M]===void 0&&(p[M]=l[M])}return p}function K0(l,u){try{var p=l.onUncaughtError;p(u.value,{componentStack:u.stack})}catch(_){setTimeout(function(){throw _})}}function VA(l,u,p){try{var _=l.onCaughtError;_(p.value,{componentStack:p.stack,errorBoundary:u.tag===1?u.stateNode:null})}catch(M){setTimeout(function(){throw M})}}function Ay(l,u,p){return p=Ie(p),p.tag=3,p.payload={element:null},p.callback=function(){K0(l,u)},p}function kA(l){return l=Ie(l),l.tag=3,l}function WA(l,u,p,_){var M=p.type.getDerivedStateFromError;if(typeof M=="function"){var A=_.value;l.payload=function(){return M(A)},l.callback=function(){VA(u,p,_)}}var F=p.stateNode;F!==null&&typeof F.componentDidCatch=="function"&&(l.callback=function(){VA(u,p,_),typeof M!="function"&&(Tl===null?Tl=new Set([this]):Tl.add(this));var $=_.stack;this.componentDidCatch(_.value,{componentStack:$!==null?$:""})})}function f9(l,u,p,_,M){if(p.flags|=32768,_!==null&&typeof _=="object"&&typeof _.then=="function"){if(u=p.alternate,u!==null&&ip(u,p,M,!0),p=Hr.current,p!==null){switch(p.tag){case 13:return Hs===null?eS():p.alternate===null&&pi===0&&(pi=3),p.flags&=-257,p.flags|=65536,p.lanes=M,_===gg?p.flags|=16384:(u=p.updateQueue,u===null?p.updateQueue=new Set([_]):u.add(_),nS(l,_,M)),!1;case 22:return p.flags|=65536,_===gg?p.flags|=16384:(u=p.updateQueue,u===null?(u={transitions:null,markerInstances:null,retryQueue:new Set([_])},p.updateQueue=u):(p=u.retryQueue,p===null?u.retryQueue=new Set([_]):p.add(_)),nS(l,_,M)),!1}throw Error(a(435,p.tag))}return nS(l,_,M),eS(),!1}if(pn)return u=Hr.current,u!==null?(!(u.flags&65536)&&(u.flags|=256),u.flags|=65536,u.lanes=M,_!==ES&&(l=Error(a(422),{cause:_}),Ke(oe(l,p)))):(_!==ES&&(u=Error(a(423),{cause:_}),Ke(oe(u,p))),l=l.current.alternate,l.flags|=65536,M&=-M,l.lanes|=M,_=oe(_,p),M=Ay(l.stateNode,_,M),Q(l,M),pi!==4&&(pi=2)),!1;var A=Error(a(520),{cause:_});if(A=oe(A,p),xp===null?xp=[A]:xp.push(A),pi!==4&&(pi=2),u===null)return!0;_=oe(_,p),p=u;do{switch(p.tag){case 3:return p.flags|=65536,l=M&-M,p.lanes|=l,l=Ay(p.stateNode,_,l),Q(p,l),!1;case 1:if(u=p.type,A=p.stateNode,(p.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(Tl===null||!Tl.has(A))))return p.flags|=65536,M&=-M,p.lanes|=M,M=kA(M),WA(M,l,p,_),Q(p,M),!1}p=p.return}while(p!==null);return!1}function ia(l,u,p,_){u.child=l===null?Aw(u,null,p,_):Pc(u,l.child,p,_)}function XA(l,u,p,_,M){p=p.render;var A=u.ref;if("ref"in _){var F={};for(var $ in _)$!=="ref"&&(F[$]=_[$])}else F=_;return wc(u),_=Ps(l,u,p,F,A,M),$=fa(),l!==null&&!Wi?(w(l,u,M),ho(l,u,M)):(pn&&$&&Xe(u),u.flags|=1,ia(l,u,_,M),u.child)}function YA(l,u,p,_,M){if(l===null){var A=p.type;return typeof A=="function"&&!iS(A)&&A.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=A,qA(l,u,A,_,M)):(l=ag(p.type,null,_,u,u.mode,M),l.ref=u.ref,l.return=u,u.child=l)}if(A=l.child,!Iy(l,M)){var F=A.memoizedProps;if(p=p.compare,p=p!==null?p:me,p(F,_)&&l.ref===u.ref)return ho(l,u,M)}return u.flags|=1,l=dl(A,_),l.ref=u.ref,l.return=u,u.child=l}function qA(l,u,p,_,M){if(l!==null){var A=l.memoizedProps;if(me(A,_)&&l.ref===u.ref)if(Wi=!1,u.pendingProps=_=A,Iy(l,M))l.flags&131072&&(Wi=!0);else return u.lanes=l.lanes,ho(l,u,M)}return Ry(l,u,p,_,M)}function jA(l,u,p){var _=u.pendingProps,M=_.children,A=(u.stateNode._pendingVisibility&2)!==0,F=l!==null?l.memoizedState:null;if(np(l,u),_.mode==="hidden"||A){if(u.flags&128){if(_=F!==null?F.baseLanes|p:p,l!==null){for(M=u.child=l.child,A=0;M!==null;)A=A|M.lanes|M.childLanes,M=M.sibling;u.childLanes=A&~_}else u.childLanes=0,u.child=null;return ZA(l,u,_,p)}if(p&536870912)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&$0(u,F!==null?F.cachePool:null),F!==null?co(u,F):Ls(),Us(u);else return u.lanes=u.childLanes=536870912,ZA(l,u,F!==null?F.baseLanes|p:p,p)}else F!==null?($0(u,F.cachePool),co(u,F),ha(),u.memoizedState=null):(l!==null&&$0(u,null),Ls(),ha());return ia(l,u,M,p),u.child}function ZA(l,u,p,_){var M=By();return M=M===null?null:{parent:go?fi._currentValue:fi._currentValue2,pool:M},u.memoizedState={baseLanes:p,cachePool:M},l!==null&&$0(u,null),Ls(),Us(u),l!==null&&ip(l,u,_,!0),null}function np(l,u){var p=u.ref;if(p===null)l!==null&&l.ref!==null&&(u.flags|=2097664);else{if(typeof p!="function"&&typeof p!="object")throw Error(a(284));(l===null||l.ref!==p)&&(u.flags|=2097664)}}function Ry(l,u,p,_,M){return wc(u),p=Ps(l,u,p,_,void 0,M),_=fa(),l!==null&&!Wi?(w(l,u,M),ho(l,u,M)):(pn&&_&&Xe(u),u.flags|=1,ia(l,u,p,M),u.child)}function KA(l,u,p,_,M,A){return wc(u),u.updateQueue=null,p=uo(u,_,p,M),zs(l),_=fa(),l!==null&&!Wi?(w(l,u,A),ho(l,u,A)):(pn&&_&&Xe(u),u.flags|=1,ia(l,u,p,A),u.child)}function QA(l,u,p,_,M){if(wc(u),u.stateNode===null){var A=bh,F=p.contextType;typeof F=="object"&&F!==null&&(A=da(F)),A=new p(_,A),u.memoizedState=A.state!==null&&A.state!==void 0?A.state:null,A.updater=DS,u.stateNode=A,A._reactInternals=u,A=u.stateNode,A.props=_,A.state=u.memoizedState,A.refs={},_t(u),F=p.contextType,A.context=typeof F=="object"&&F!==null?da(F):bh,A.state=u.memoizedState,F=p.getDerivedStateFromProps,typeof F=="function"&&(by(u,p,F,_),A.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof A.getSnapshotBeforeUpdate=="function"||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(F=A.state,typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount(),F!==A.state&&DS.enqueueReplaceState(A,A.state,null),Oe(u,_,A,M),pe(),A.state=u.memoizedState),typeof A.componentDidMount=="function"&&(u.flags|=4194308),_=!0}else if(l===null){A=u.stateNode;var $=u.memoizedProps,he=Rc(p,$);A.props=he;var Ne=A.context,et=p.contextType;F=bh,typeof et=="object"&&et!==null&&(F=da(et));var dt=p.getDerivedStateFromProps;et=typeof dt=="function"||typeof A.getSnapshotBeforeUpdate=="function",$=u.pendingProps!==$,et||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||($||Ne!==F)&&GA(u,A,_,F),_l=!1;var mt=u.memoizedState;A.state=mt,Oe(u,_,A,M),pe(),Ne=u.memoizedState,$||mt!==Ne||_l?(typeof dt=="function"&&(by(u,p,dt,_),Ne=u.memoizedState),(he=_l||FA(u,p,he,_,mt,Ne,F))?(et||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(u.flags|=4194308)):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=_,u.memoizedState=Ne),A.props=_,A.state=Ne,A.context=F,_=he):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),_=!1)}else{A=u.stateNode,pt(l,u),F=u.memoizedProps,et=Rc(p,F),A.props=et,dt=u.pendingProps,mt=A.context,Ne=p.contextType,he=bh,typeof Ne=="object"&&Ne!==null&&(he=da(Ne)),$=p.getDerivedStateFromProps,(Ne=typeof $=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(F!==dt||mt!==he)&&GA(u,A,_,he),_l=!1,mt=u.memoizedState,A.state=mt,Oe(u,_,A,M),pe();var Yt=u.memoizedState;F!==dt||mt!==Yt||_l||l!==null&&l.dependencies!==null&&Q0(l.dependencies)?(typeof $=="function"&&(by(u,p,$,_),Yt=u.memoizedState),(et=_l||FA(u,p,et,_,mt,Yt,he)||l!==null&&l.dependencies!==null&&Q0(l.dependencies))?(Ne||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(_,Yt,he),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(_,Yt,he)),typeof A.componentDidUpdate=="function"&&(u.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof A.componentDidUpdate!="function"||F===l.memoizedProps&&mt===l.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||F===l.memoizedProps&&mt===l.memoizedState||(u.flags|=1024),u.memoizedProps=_,u.memoizedState=Yt),A.props=_,A.state=Yt,A.context=he,_=et):(typeof A.componentDidUpdate!="function"||F===l.memoizedProps&&mt===l.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||F===l.memoizedProps&&mt===l.memoizedState||(u.flags|=1024),_=!1)}return A=_,np(l,u),_=(u.flags&128)!==0,A||_?(A=u.stateNode,p=_&&typeof p.getDerivedStateFromError!="function"?null:A.render(),u.flags|=1,l!==null&&_?(u.child=Pc(u,l.child,null,M),u.child=Pc(u,null,p,M)):ia(l,u,p,M),u.memoizedState=A.state,l=u.child):l=ho(l,u,M),l}function JA(l,u,p,_){return ot(),u.flags|=256,ia(l,u,p,_),u.child}function wy(l){return{baseLanes:l,cachePool:aR()}}function Cy(l,u,p){return l=l!==null?l.childLanes&~p:0,u&&(l|=Fr),l}function $A(l,u,p){var _=u.pendingProps,M=!1,A=(u.flags&128)!==0,F;if((F=A)||(F=l!==null&&l.memoizedState===null?!1:(zi.current&2)!==0),F&&(M=!0,u.flags&=-129),F=(u.flags&32)!==0,u.flags&=-33,l===null){if(pn){if(M?Ei(u):ha(),pn){var $=ga,he;(he=$)&&($=C7($,Bs),$!==null?(u.memoizedState={dehydrated:$,treeContext:Uc!==null?{id:vo,overflow:_o}:null,retryLane:536870912},he=t(18,null,null,0),he.stateNode=$,he.return=u,u.child=he,Ma=u,ga=null,he=!0):he=!1),he||Ze(u)}if($=u.memoizedState,$!==null&&($=$.dehydrated,$!==null))return _S($)?u.lanes=16:u.lanes=536870912,null;ki(u)}return $=_.children,_=_.fallback,M?(ha(),M=u.mode,$=Dy({mode:"hidden",children:$},M),_=Oc(_,M,p,null),$.return=u,_.return=u,$.sibling=_,u.child=$,M=u.child,M.memoizedState=wy(p),M.childLanes=Cy(l,F,p),u.memoizedState=OS,_):(Ei(u),Ny(u,$))}if(he=l.memoizedState,he!==null&&($=he.dehydrated,$!==null)){if(A)u.flags&256?(Ei(u),u.flags&=-257,u=Oy(l,u,p)):u.memoizedState!==null?(ha(),u.child=l.child,u.flags|=128,u=null):(ha(),M=_.fallback,$=u.mode,_=Dy({mode:"visible",children:_.children},$),M=Oc(M,$,p,null),M.flags|=2,_.return=u,M.return=u,_.sibling=M,u.child=_,Pc(u,l.child,null,p),_=u.child,_.memoizedState=wy(p),_.childLanes=Cy(l,F,p),u.memoizedState=OS,u=M);else if(Ei(u),_S($))F=S7($).digest,_=Error(a(419)),_.stack="",_.digest=F,Ke({value:_,source:null,stack:null}),u=Oy(l,u,p);else if(Wi||ip(l,u,p,!1),F=(p&l.childLanes)!==0,Wi||F){if(F=Vn,F!==null){if(_=p&-p,_&42)_=1;else switch(_){case 2:_=1;break;case 8:_=4;break;case 32:_=16;break;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:_=64;break;case 268435456:_=134217728;break;default:_=0}if(_=_&(F.suspendedLanes|p)?0:_,_!==0&&_!==he.retryLane)throw he.retryLane=_,De(l,_),Ea(F,l,_),ww}vS($)||eS(),u=Oy(l,u,p)}else vS($)?(u.flags|=128,u.child=l.child,u=M9.bind(null,l),T7($,u),u=null):(l=he.treeContext,Ir&&(ga=A7($),Ma=u,pn=!0,hs=null,Bs=!1,l!==null&&(Pr[zr++]=vo,Pr[zr++]=_o,Pr[zr++]=Uc,vo=l.id,_o=l.overflow,Uc=u)),u=Ny(u,_.children),u.flags|=4096);return u}return M?(ha(),M=_.fallback,$=u.mode,he=l.child,A=he.sibling,_=dl(he,{mode:"hidden",children:_.children}),_.subtreeFlags=he.subtreeFlags&31457280,A!==null?M=dl(A,M):(M=Oc(M,$,p,null),M.flags|=2),M.return=u,_.return=u,_.sibling=M,u.child=_,_=M,M=u.child,$=l.child.memoizedState,$===null?$=wy(p):(he=$.cachePool,he!==null?(A=go?fi._currentValue:fi._currentValue2,he=he.parent!==A?{parent:A,pool:A}:he):he=aR(),$={baseLanes:$.baseLanes|p,cachePool:he}),M.memoizedState=$,M.childLanes=Cy(l,F,p),u.memoizedState=OS,_):(Ei(u),p=l.child,l=p.sibling,p=dl(p,{mode:"visible",children:_.children}),p.return=u,p.sibling=null,l!==null&&(F=u.deletions,F===null?(u.deletions=[l],u.flags|=16):F.push(l)),u.child=p,u.memoizedState=null,p)}function Ny(l,u){return u=Dy({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function Dy(l,u){return kR(l,u,0,null)}function Oy(l,u,p){return Pc(u,l.child,null,p),l=Ny(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function eR(l,u,p){l.lanes|=u;var _=l.alternate;_!==null&&(_.lanes|=u),Uy(l.return,u,p)}function Ly(l,u,p,_,M){var A=l.memoizedState;A===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:_,tail:p,tailMode:M}:(A.isBackwards=u,A.rendering=null,A.renderingStartTime=0,A.last=_,A.tail=p,A.tailMode=M)}function tR(l,u,p){var _=u.pendingProps,M=_.revealOrder,A=_.tail;if(ia(l,u,_.children,p),_=zi.current,_&2)_=_&1|2,u.flags|=128;else{if(l!==null&&l.flags&128)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&eR(l,p,u);else if(l.tag===19)eR(l,p,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}_&=1}switch(y(zi,_),M){case"forwards":for(p=u.child,M=null;p!==null;)l=p.alternate,l!==null&&Ha(l)===null&&(M=p),p=p.sibling;p=M,p===null?(M=u.child,u.child=null):(M=p.sibling,p.sibling=null),Ly(u,!1,M,p,A);break;case"backwards":for(p=null,M=u.child,u.child=null;M!==null;){if(l=M.alternate,l!==null&&Ha(l)===null){u.child=M;break}l=M.sibling,M.sibling=p,p=M,M=l}Ly(u,!0,p,null,A);break;case"together":Ly(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function ho(l,u,p){if(l!==null&&(u.dependencies=l.dependencies),Sl|=u.lanes,!(p&u.childLanes))if(l!==null){if(ip(l,u,p,!1),(p&u.childLanes)===0)return null}else return null;if(l!==null&&u.child!==l.child)throw Error(a(153));if(u.child!==null){for(l=u.child,p=dl(l,l.pendingProps),u.child=p,p.return=u;l.sibling!==null;)l=l.sibling,p=p.sibling=dl(l,l.pendingProps),p.return=u;p.sibling=null}return u.child}function Iy(l,u){return l.lanes&u?!0:(l=l.dependencies,!!(l!==null&&Q0(l)))}function d9(l,u,p){switch(u.tag){case 3:tt(u,u.stateNode.containerInfo),cl(u,fi,l.memoizedState.cache),ot();break;case 27:case 5:ge(u);break;case 4:tt(u,u.stateNode.containerInfo);break;case 10:cl(u,u.type,u.memoizedProps.value);break;case 13:var _=u.memoizedState;if(_!==null)return _.dehydrated!==null?(Ei(u),u.flags|=128,null):p&u.child.childLanes?$A(l,u,p):(Ei(u),l=ho(l,u,p),l!==null?l.sibling:null);Ei(u);break;case 19:var M=(l.flags&128)!==0;if(_=(p&u.childLanes)!==0,_||(ip(l,u,p,!1),_=(p&u.childLanes)!==0),M){if(_)return tR(l,u,p);u.flags|=128}if(M=u.memoizedState,M!==null&&(M.rendering=null,M.tail=null,M.lastEffect=null),y(zi,zi.current),_)break;return null;case 22:case 23:return u.lanes=0,jA(l,u,p);case 24:cl(u,fi,l.memoizedState.cache)}return ho(l,u,p)}function nR(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps)Wi=!0;else{if(!Iy(l,p)&&!(u.flags&128))return Wi=!1,d9(l,u,p);Wi=!!(l.flags&131072)}else Wi=!1,pn&&u.flags&1048576&&Ce(u,fg,u.index);switch(u.lanes=0,u.tag){case 16:e:{l=u.pendingProps;var _=u.elementType,M=_._init;if(_=M(_._payload),u.type=_,typeof _=="function")iS(_)?(l=Rc(_,l),u.tag=1,u=QA(null,u,_,l,p)):(u.tag=0,u=Ry(null,u,_,l,p));else{if(_!=null){if(M=_.$$typeof,M===cS){u.tag=11,u=XA(null,u,_,l,p);break e}else if(M===fS){u.tag=14,u=YA(null,u,_,l,p);break e}}throw u=s(_)||_,Error(a(306,u,""))}}return u;case 0:return Ry(l,u,u.type,u.pendingProps,p);case 1:return _=u.type,M=Rc(_,u.pendingProps),QA(l,u,_,M,p);case 3:e:{if(tt(u,u.stateNode.containerInfo),l===null)throw Error(a(387));var A=u.pendingProps;M=u.memoizedState,_=M.element,pt(l,u),Oe(u,A,null,p);var F=u.memoizedState;if(A=F.cache,cl(u,fi,A),A!==M.cache&&Py(u,[fi],p,!0),pe(),A=F.element,Ir&&M.isDehydrated)if(M={element:A,isDehydrated:!1,cache:F.cache},u.updateQueue.baseState=M,u.memoizedState=M,u.flags&256){u=JA(l,u,A,p);break e}else if(A!==_){_=oe(Error(a(424)),u),Ke(_),u=JA(l,u,A,p);break e}else for(Ir&&(ga=b7(u.stateNode.containerInfo),Ma=u,pn=!0,hs=null,Bs=!0),p=Aw(u,null,A,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(ot(),A===_){u=ho(l,u,p);break e}ia(l,u,A,p)}u=u.child}return u;case 26:if(Ur)return np(l,u),l===null?(p=gw(u.type,null,u.pendingProps,null))?u.memoizedState=p:pn||(u.stateNode=G7(u.type,u.pendingProps,vl.current,u)):u.memoizedState=gw(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:if(ma)return ge(u),l===null&&ma&&pn&&(_=u.stateNode=Tw(u.type,u.pendingProps,vl.current,aa.current,!1),Ma=u,Bs=!0,ga=dw(_)),_=u.pendingProps.children,l!==null||pn?ia(l,u,_,p):u.child=Pc(u,null,_,p),np(l,u),u.child;case 5:return l===null&&pn&&(B7(u.type,u.pendingProps,aa.current),(M=_=ga)&&(_=R7(_,u.type,u.pendingProps,Bs),_!==null?(u.stateNode=_,Ma=u,ga=dw(_),Bs=!1,M=!0):M=!1),M||Ze(u)),ge(u),M=u.type,A=u.pendingProps,F=l!==null?l.memoizedProps:null,_=A.children,og(M,A)?_=null:F!==null&&og(M,F)&&(u.flags|=32),u.memoizedState!==null&&(M=Ps(l,u,rr,null,null,p),go?Ic._currentValue=M:Ic._currentValue2=M),np(l,u),ia(l,u,_,p),u.child;case 6:return l===null&&pn&&(H7(u.pendingProps,aa.current),(l=p=ga)&&(p=w7(p,u.pendingProps,Bs),p!==null?(u.stateNode=p,Ma=u,ga=null,l=!0):l=!1),l||Ze(u)),null;case 13:return $A(l,u,p);case 4:return tt(u,u.stateNode.containerInfo),_=u.pendingProps,l===null?u.child=Pc(u,null,_,p):ia(l,u,_,p),u.child;case 11:return XA(l,u,u.type,u.pendingProps,p);case 7:return ia(l,u,u.pendingProps,p),u.child;case 8:return ia(l,u,u.pendingProps.children,p),u.child;case 12:return ia(l,u,u.pendingProps.children,p),u.child;case 10:return _=u.pendingProps,cl(u,u.type,_.value),ia(l,u,_.children,p),u.child;case 9:return M=u.type._context,_=u.pendingProps.children,wc(u),M=da(M),_=_(M),u.flags|=1,ia(l,u,_,p),u.child;case 14:return YA(l,u,u.type,u.pendingProps,p);case 15:return qA(l,u,u.type,u.pendingProps,p);case 19:return tR(l,u,p);case 22:return jA(l,u,p);case 24:return wc(u),_=da(fi),l===null?(M=By(),M===null&&(M=Vn,A=zy(),M.pooledCache=A,A.refCount++,A!==null&&(M.pooledCacheLanes|=p),M=A),u.memoizedState={parent:_,cache:M},_t(u),cl(u,fi,M)):(l.lanes&p&&(pt(l,u),Oe(u,null,null,p),pe()),M=l.memoizedState,A=u.memoizedState,M.parent!==_?(M={parent:_,cache:_},u.memoizedState=M,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=M),cl(u,fi,_)):(_=A.cache,cl(u,fi,_),_!==M.cache&&Py(u,[fi],p,!0))),ia(l,u,u.pendingProps.children,p),u.child;case 29:throw u.pendingProps}throw Error(a(156,u.tag))}function cl(l,u,p){go?(y(yg,u._currentValue),u._currentValue=p):(y(yg,u._currentValue2),u._currentValue2=p)}function fo(l){var u=yg.current;go?l._currentValue=u:l._currentValue2=u,v(yg)}function Uy(l,u,p){for(;l!==null;){var _=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,_!==null&&(_.childLanes|=u)):_!==null&&(_.childLanes&u)!==u&&(_.childLanes|=u),l===p)break;l=l.return}}function Py(l,u,p,_){var M=l.child;for(M!==null&&(M.return=l);M!==null;){var A=M.dependencies;if(A!==null){var F=M.child;A=A.firstContext;e:for(;A!==null;){var $=A;A=M;for(var he=0;he<u.length;he++)if($.context===u[he]){A.lanes|=p,$=A.alternate,$!==null&&($.lanes|=p),Uy(A.return,p,l),_||(F=null);break e}A=$.next}}else if(M.tag===18){if(F=M.return,F===null)throw Error(a(341));F.lanes|=p,A=F.alternate,A!==null&&(A.lanes|=p),Uy(F,p,l),F=null}else F=M.child;if(F!==null)F.return=M;else for(F=M;F!==null;){if(F===l){F=null;break}if(M=F.sibling,M!==null){M.return=F.return,F=M;break}F=F.return}M=F}}function ip(l,u,p,_){l=null;for(var M=u,A=!1;M!==null;){if(!A){if(M.flags&524288)A=!0;else if(M.flags&262144)break}if(M.tag===10){var F=M.alternate;if(F===null)throw Error(a(387));if(F=F.memoizedProps,F!==null){var $=M.type;dr(M.pendingProps.value,F.value)||(l!==null?l.push($):l=[$])}}else if(M===dg.current){if(F=M.alternate,F===null)throw Error(a(387));F.memoizedState.memoizedState!==M.memoizedState.memoizedState&&(l!==null?l.push(Ic):l=[Ic])}M=M.return}l!==null&&Py(u,l,p,_),u.flags|=262144}function Q0(l){for(l=l.firstContext;l!==null;){var u=l.context;if(!dr(go?u._currentValue:u._currentValue2,l.memoizedValue))return!0;l=l.next}return!1}function wc(l){Fc=l,xo=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function da(l){return iR(Fc,l)}function J0(l,u){return Fc===null&&wc(l),iR(l,u)}function iR(l,u){var p=go?u._currentValue:u._currentValue2;if(u={context:u,memoizedValue:p,next:null},xo===null){if(l===null)throw Error(a(308));xo=u,l.dependencies={lanes:0,firstContext:u},l.flags|=524288}else xo=xo.next=u;return p}function zy(){return{controller:new az,data:new Map,refCount:0}}function ap(l){l.refCount--,l.refCount===0&&rz(sz,function(){l.controller.abort()})}function By(){var l=Gc.current;return l!==null?l:Vn.pooledCache}function $0(l,u){u===null?y(Gc,Gc.current):y(Gc,u.pool)}function aR(){var l=By();return l===null?null:{parent:go?fi._currentValue:fi._currentValue2,pool:l}}function sr(l){l.flags|=4}function rR(l,u){if(l!==null&&l.child===u.child)return!1;if(u.flags&16)return!0;for(l=u.child;l!==null;){if(l.flags&13878||l.subtreeFlags&13878)return!0;l=l.sibling}return!1}function Hy(l,u,p,_){if(pa)for(p=u.child;p!==null;){if(p.tag===5||p.tag===6)mS(l,p.stateNode);else if(!(p.tag===4||ma&&p.tag===27)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===u)break;for(;p.sibling===null;){if(p.return===null||p.return===u)return;p=p.return}p.sibling.return=p.return,p=p.sibling}else if(gl)for(var M=u.child;M!==null;){if(M.tag===5){var A=M.stateNode;p&&_&&(A=uw(A,M.type,M.memoizedProps)),mS(l,A)}else if(M.tag===6)A=M.stateNode,p&&_&&(A=hw(A,M.memoizedProps)),mS(l,A);else if(M.tag!==4){if(M.tag===22&&M.memoizedState!==null)A=M.child,A!==null&&(A.return=M),Hy(l,M,!0,!0);else if(M.child!==null){M.child.return=M,M=M.child;continue}}if(M===u)break;for(;M.sibling===null;){if(M.return===null||M.return===u)return;M=M.return}M.sibling.return=M.return,M=M.sibling}}function sR(l,u,p,_){if(gl)for(var M=u.child;M!==null;){if(M.tag===5){var A=M.stateNode;p&&_&&(A=uw(A,M.type,M.memoizedProps)),lw(l,A)}else if(M.tag===6)A=M.stateNode,p&&_&&(A=hw(A,M.memoizedProps)),lw(l,A);else if(M.tag!==4){if(M.tag===22&&M.memoizedState!==null)A=M.child,A!==null&&(A.return=M),sR(l,M,!(M.memoizedProps!==null&&M.memoizedProps.mode==="manual"),!0);else if(M.child!==null){M.child.return=M,M=M.child;continue}}if(M===u)break;for(;M.sibling===null;){if(M.return===null||M.return===u)return;M=M.return}M.sibling.return=M.return,M=M.sibling}}function oR(l,u){if(gl&&rR(l,u)){l=u.stateNode;var p=l.containerInfo,_=ow();sR(_,u,!1,!1),l.pendingChildren=_,sr(u),y7(p,_)}}function Fy(l,u,p,_){if(pa)l.memoizedProps!==_&&sr(u);else if(gl){var M=l.stateNode,A=l.memoizedProps;if((l=rR(l,u))||A!==_){var F=aa.current;A=x7(M,p,A,_,!l,null),A===M?u.stateNode=M:(tw(A,p,_,F)&&sr(u),u.stateNode=A,l?Hy(A,u,!1,!1):sr(u))}else u.stateNode=M}}function Gy(l,u,p){if(q9(u,p)){if(l.flags|=16777216,!aw(u,p))if(OR())l.flags|=8192;else throw Lh=gg,CS}else l.flags&=-16777217}function lR(l,u){if(k7(u)){if(l.flags|=16777216,!Sw(u))if(OR())l.flags|=8192;else throw Lh=gg,CS}else l.flags&=-16777217}function eg(l,u){u!==null&&(l.flags|=4),l.flags&16384&&(u=l.tag!==22?O():536870912,l.lanes|=u,Fh|=u)}function rp(l,u){if(!pn)switch(l.tailMode){case"hidden":u=l.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:_.sibling=null}}function ci(l){var u=l.alternate!==null&&l.alternate.child===l.child,p=0,_=0;if(u)for(var M=l.child;M!==null;)p|=M.lanes|M.childLanes,_|=M.subtreeFlags&31457280,_|=M.flags&31457280,M.return=l,M=M.sibling;else for(M=l.child;M!==null;)p|=M.lanes|M.childLanes,_|=M.subtreeFlags,_|=M.flags,M.return=l,M=M.sibling;return l.subtreeFlags|=_,l.childLanes=p,u}function p9(l,u,p){var _=u.pendingProps;switch(nt(u),u.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ci(u),null;case 1:return ci(u),null;case 3:return p=u.stateNode,_=null,l!==null&&(_=l.memoizedState.cache),u.memoizedState.cache!==_&&(u.flags|=2048),fo(fi),gt(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(l===null||l.child===null)&&(Mt(u)?sr(u):l===null||l.memoizedState.isDehydrated&&!(u.flags&256)||(u.flags|=1024,hs!==null&&(Jy(hs),hs=null))),oR(l,u),ci(u),null;case 26:if(Ur){p=u.type;var M=u.memoizedState;return l===null?(sr(u),M!==null?(ci(u),lR(u,M)):(ci(u),Gy(u,p,_))):M?M!==l.memoizedState?(sr(u),ci(u),lR(u,M)):(ci(u),u.flags&=-16777217):(pa?l.memoizedProps!==_&&sr(u):Fy(l,u,p,_),ci(u),Gy(u,p,_)),null}case 27:if(ma){if(Ae(u),p=vl.current,M=u.type,l!==null&&u.stateNode!=null)pa?l.memoizedProps!==_&&sr(u):Fy(l,u,M,_);else{if(!_){if(u.stateNode===null)throw Error(a(166));return ci(u),null}l=aa.current,Mt(u)?ue(u,l):(l=Tw(M,_,p,l,!0),u.stateNode=l,sr(u))}return ci(u),null}case 5:if(Ae(u),p=u.type,l!==null&&u.stateNode!=null)Fy(l,u,p,_);else{if(!_){if(u.stateNode===null)throw Error(a(166));return ci(u),null}l=aa.current,Mt(u)?ue(u,l):(M=F9(p,_,vl.current,l,u),Hy(M,u,!1,!1),u.stateNode=M,tw(M,p,_,l)&&sr(u))}return ci(u),Gy(u,u.type,u.pendingProps),null;case 6:if(l&&u.stateNode!=null)p=l.memoizedProps,pa?p!==_&&sr(u):gl&&(p!==_?(u.stateNode=nw(_,vl.current,aa.current,u),sr(u)):u.stateNode=l.stateNode);else{if(typeof _!="string"&&u.stateNode===null)throw Error(a(166));if(l=vl.current,p=aa.current,Mt(u)){if(!Ir)throw Error(a(176));if(l=u.stateNode,p=u.memoizedProps,_=null,M=Ma,M!==null)switch(M.tag){case 27:case 5:_=M.memoizedProps}D7(l,p,u,_)||Ze(u)}else u.stateNode=nw(_,l,p,u)}return ci(u),null;case 13:if(_=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(M=Mt(u),_!==null&&_.dehydrated!==null){if(l===null){if(!M)throw Error(a(318));if(!Ir)throw Error(a(344));if(M=u.memoizedState,M=M!==null?M.dehydrated:null,!M)throw Error(a(317));O7(M,u)}else ot(),!(u.flags&128)&&(u.memoizedState=null),u.flags|=4;ci(u),M=!1}else hs!==null&&(Jy(hs),hs=null),M=!0;if(!M)return u.flags&256?(ki(u),u):(ki(u),null)}if(ki(u),u.flags&128)return u.lanes=p,u;if(p=_!==null,l=l!==null&&l.memoizedState!==null,p){_=u.child,M=null,_.alternate!==null&&_.alternate.memoizedState!==null&&_.alternate.memoizedState.cachePool!==null&&(M=_.alternate.memoizedState.cachePool.pool);var A=null;_.memoizedState!==null&&_.memoizedState.cachePool!==null&&(A=_.memoizedState.cachePool.pool),A!==M&&(_.flags|=2048)}return p!==l&&p&&(u.child.flags|=8192),eg(u,u.updateQueue),ci(u),null;case 4:return gt(),oR(l,u),l===null&&k9(u.stateNode.containerInfo),ci(u),null;case 10:return fo(u.type),ci(u),null;case 19:if(v(zi),M=u.memoizedState,M===null)return ci(u),null;if(_=(u.flags&128)!==0,A=M.rendering,A===null)if(_)rp(M,!1);else{if(pi!==0||l!==null&&l.flags&128)for(l=u.child;l!==null;){if(A=Ha(l),A!==null){for(u.flags|=128,rp(M,!1),l=A.updateQueue,u.updateQueue=l,eg(u,l),u.subtreeFlags=0,l=p,p=u.child;p!==null;)VR(p,l),p=p.sibling;return y(zi,zi.current&1|2),u.child}l=l.sibling}M.tail!==null&&us()>yp&&(u.flags|=128,_=!0,rp(M,!1),u.lanes=4194304)}else{if(!_)if(l=Ha(A),l!==null){if(u.flags|=128,_=!0,l=l.updateQueue,u.updateQueue=l,eg(u,l),rp(M,!0),M.tail===null&&M.tailMode==="hidden"&&!A.alternate&&!pn)return ci(u),null}else 2*us()-M.renderingStartTime>yp&&p!==536870912&&(u.flags|=128,_=!0,rp(M,!1),u.lanes=4194304);M.isBackwards?(A.sibling=u.child,u.child=A):(l=M.last,l!==null?l.sibling=A:u.child=A,M.last=A)}return M.tail!==null?(u=M.tail,M.rendering=u,M.tail=u.sibling,M.renderingStartTime=us(),u.sibling=null,l=zi.current,y(zi,_?l&1|2:l&1),u):(ci(u),null);case 22:case 23:return ki(u),Is(),_=u.memoizedState!==null,l!==null?l.memoizedState!==null!==_&&(u.flags|=8192):_&&(u.flags|=8192),_?p&536870912&&!(u.flags&128)&&(ci(u),u.subtreeFlags&6&&(u.flags|=8192)):ci(u),p=u.updateQueue,p!==null&&eg(u,p.retryQueue),p=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),_=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(_=u.memoizedState.cachePool.pool),_!==p&&(u.flags|=2048),l!==null&&v(Gc),null;case 24:return p=null,l!==null&&(p=l.memoizedState.cache),u.memoizedState.cache!==p&&(u.flags|=2048),fo(fi),ci(u),null;case 25:return null}throw Error(a(156,u.tag))}function m9(l,u){switch(nt(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return fo(fi),gt(),l=u.flags,l&65536&&!(l&128)?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return Ae(u),null;case 13:if(ki(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(a(340));ot()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return v(zi),null;case 4:return gt(),null;case 10:return fo(u.type),null;case 22:case 23:return ki(u),Is(),l!==null&&v(Gc),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return fo(fi),null;case 25:return null;default:return null}}function cR(l,u){switch(nt(u),u.tag){case 3:fo(fi),gt();break;case 26:case 27:case 5:Ae(u);break;case 4:gt();break;case 13:ki(u);break;case 19:v(zi);break;case 10:fo(u.type);break;case 22:case 23:ki(u),Is(),l!==null&&v(Gc);break;case 24:fo(fi)}}function sp(l,u){try{var p=u.updateQueue,_=p!==null?p.lastEffect:null;if(_!==null){var M=_.next;p=M;do{if((p.tag&l)===l){_=void 0;var A=p.create,F=p.inst;_=A(),F.destroy=_}p=p.next}while(p!==M)}}catch($){bn(u,u.return,$)}}function ul(l,u,p){try{var _=u.updateQueue,M=_!==null?_.lastEffect:null;if(M!==null){var A=M.next;_=A;do{if((_.tag&l)===l){var F=_.inst,$=F.destroy;if($!==void 0){F.destroy=void 0,M=u;var he=p;try{$()}catch(Ne){bn(M,he,Ne)}}}_=_.next}while(_!==A)}}catch(Ne){bn(u,u.return,Ne)}}function uR(l){var u=l.updateQueue;if(u!==null){var p=l.stateNode;try{Ve(u,p)}catch(_){bn(l,l.return,_)}}}function hR(l,u,p){p.props=Rc(l.type,l.memoizedProps),p.state=l.memoizedState;try{p.componentWillUnmount()}catch(_){bn(l,u,_)}}function Cc(l,u){try{var p=l.ref;if(p!==null){var _=l.stateNode;switch(l.tag){case 26:case 27:case 5:var M=cp(_);break;default:M=_}typeof p=="function"?l.refCleanup=p(M):p.current=M}}catch(A){bn(l,u,A)}}function or(l,u){var p=l.ref,_=l.refCleanup;if(p!==null)if(typeof _=="function")try{_()}catch(M){bn(l,u,M)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(M){bn(l,u,M)}else p.current=null}function fR(l){var u=l.type,p=l.memoizedProps,_=l.stateNode;try{l7(_,u,p,l)}catch(M){bn(l,l.return,M)}}function dR(l,u,p){try{c7(l.stateNode,l.type,p,u,l)}catch(_){bn(l,l.return,_)}}function pR(l){return l.tag===5||l.tag===3||(Ur?l.tag===26:!1)||(ma?l.tag===27:!1)||l.tag===4}function Vy(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||pR(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&(!ma||l.tag!==27)&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function ky(l,u,p){var _=l.tag;if(_===5||_===6)l=l.stateNode,u?h7(p,l,u):s7(p,l);else if(!(_===4||ma&&_===27)&&(l=l.child,l!==null))for(ky(l,u,p),l=l.sibling;l!==null;)ky(l,u,p),l=l.sibling}function tg(l,u,p){var _=l.tag;if(_===5||_===6)l=l.stateNode,u?u7(p,l,u):r7(p,l);else if(!(_===4||ma&&_===27)&&(l=l.child,l!==null))for(tg(l,u,p),l=l.sibling;l!==null;)tg(l,u,p),l=l.sibling}function mR(l,u,p){l=l.containerInfo;try{cw(l,p)}catch(_){bn(u,u.return,_)}}function g9(l,u){for(B9(l.containerInfo),Xi=u;Xi!==null;)if(l=Xi,u=l.child,(l.subtreeFlags&1028)!==0&&u!==null)u.return=l,Xi=u;else for(;Xi!==null;){l=Xi;var p=l.alternate;switch(u=l.flags,l.tag){case 0:break;case 11:case 15:break;case 1:if(u&1024&&p!==null){u=void 0;var _=l,M=p.memoizedProps;p=p.memoizedState;var A=_.stateNode;try{var F=Rc(_.type,M,_.elementType===_.type);u=A.getSnapshotBeforeUpdate(F,p),A.__reactInternalSnapshotBeforeUpdate=u}catch($){bn(_,_.return,$)}}break;case 3:u&1024&&pa&&_7(l.stateNode.containerInfo);break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(u&1024)throw Error(a(163))}if(u=l.sibling,u!==null){u.return=l.return,Xi=u;break}Xi=l.return}return F=Dw,Dw=!1,F}function gR(l,u,p){var _=p.flags;switch(p.tag){case 0:case 11:case 15:po(l,p),_&4&&sp(5,p);break;case 1:if(po(l,p),_&4)if(l=p.stateNode,u===null)try{l.componentDidMount()}catch($){bn(p,p.return,$)}else{var M=Rc(p.type,u.memoizedProps);u=u.memoizedState;try{l.componentDidUpdate(M,u,l.__reactInternalSnapshotBeforeUpdate)}catch($){bn(p,p.return,$)}}_&64&&uR(p),_&512&&Cc(p,p.return);break;case 3:if(po(l,p),_&64&&(_=p.updateQueue,_!==null)){if(l=null,p.child!==null)switch(p.child.tag){case 27:case 5:l=cp(p.child.stateNode);break;case 1:l=p.child.stateNode}try{Ve(_,l)}catch($){bn(p,p.return,$)}}break;case 26:if(Ur){po(l,p),_&512&&Cc(p,p.return);break}case 27:case 5:po(l,p),u===null&&_&4&&fR(p),_&512&&Cc(p,p.return);break;case 12:po(l,p);break;case 13:po(l,p),_&4&&_R(l,p);break;case 22:if(M=p.memoizedState!==null||yo,!M){u=u!==null&&u.memoizedState!==null||di;var A=yo,F=di;yo=M,(di=u)&&!F?hl(l,p,(p.subtreeFlags&8772)!==0):po(l,p),yo=A,di=F}_&512&&(p.memoizedProps.mode==="manual"?Cc(p,p.return):or(p,p.return));break;default:po(l,p)}}function vR(l){var u=l.alternate;u!==null&&(l.alternate=null,vR(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&Y9(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function cs(l,u,p){for(p=p.child;p!==null;)Wy(l,u,p),p=p.sibling}function Wy(l,u,p){if(fr&&typeof fr.onCommitFiberUnmount=="function")try{fr.onCommitFiberUnmount(fp,p)}catch{}switch(p.tag){case 26:if(Ur){di||or(p,u),cs(l,u,p),p.memoizedState?_w(p.memoizedState):p.stateNode&&yw(p.stateNode);break}case 27:if(ma){di||or(p,u);var _=Ai,M=pr;Ai=p.stateNode,cs(l,u,p),q7(p.stateNode),Ai=_,pr=M;break}case 5:di||or(p,u);case 6:if(pa){if(_=Ai,M=pr,Ai=null,cs(l,u,p),Ai=_,pr=M,Ai!==null)if(pr)try{d7(Ai,p.stateNode)}catch(A){bn(p,u,A)}else try{f7(Ai,p.stateNode)}catch(A){bn(p,u,A)}}else cs(l,u,p);break;case 18:pa&&Ai!==null&&(pr?z7(Ai,p.stateNode):P7(Ai,p.stateNode));break;case 4:pa?(_=Ai,M=pr,Ai=p.stateNode.containerInfo,pr=!0,cs(l,u,p),Ai=_,pr=M):(gl&&mR(p.stateNode,p,ow()),cs(l,u,p));break;case 0:case 11:case 14:case 15:di||ul(2,p,u),di||ul(4,p,u),cs(l,u,p);break;case 1:di||(or(p,u),_=p.stateNode,typeof _.componentWillUnmount=="function"&&hR(p,u,_)),cs(l,u,p);break;case 21:cs(l,u,p);break;case 22:di||or(p,u),di=(_=di)||p.memoizedState!==null,cs(l,u,p),di=_;break;default:cs(l,u,p)}}function _R(l,u){if(Ir&&u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{U7(l)}catch(p){bn(u,u.return,p)}}function v9(l){switch(l.tag){case 13:case 19:var u=l.stateNode;return u===null&&(u=l.stateNode=new Nw),u;case 22:return l=l.stateNode,u=l._retryCache,u===null&&(u=l._retryCache=new Nw),u;default:throw Error(a(435,l.tag))}}function Xy(l,u){var p=v9(l);u.forEach(function(_){var M=b9.bind(null,l,_);p.has(_)||(p.add(_),_.then(M,M))})}function Fa(l,u){var p=u.deletions;if(p!==null)for(var _=0;_<p.length;_++){var M=p[_],A=l,F=u;if(pa){var $=F;e:for(;$!==null;){switch($.tag){case 27:case 5:Ai=$.stateNode,pr=!1;break e;case 3:Ai=$.stateNode.containerInfo,pr=!0;break e;case 4:Ai=$.stateNode.containerInfo,pr=!0;break e}$=$.return}if(Ai===null)throw Error(a(160));Wy(A,F,M),Ai=null,pr=!1}else Wy(A,F,M);A=M.alternate,A!==null&&(A.return=null),M.return=null}if(u.subtreeFlags&13878)for(u=u.child;u!==null;)xR(u,l),u=u.sibling}function xR(l,u){var p=l.alternate,_=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:Fa(u,l),lr(l),_&4&&(ul(3,l,l.return),sp(3,l),ul(5,l,l.return));break;case 1:Fa(u,l),lr(l),_&512&&(di||p===null||or(p,p.return)),_&64&&yo&&(l=l.updateQueue,l!==null&&(_=l.callbacks,_!==null&&(p=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=p===null?_:p.concat(_))));break;case 26:if(Ur){var M=fs;Fa(u,l),lr(l),_&512&&(di||p===null||or(p,p.return)),_&4&&(_=p!==null?p.memoizedState:null,u=l.memoizedState,p===null?u===null?l.stateNode===null?l.stateNode=F7(M,l.type,l.memoizedProps,l):xw(M,l.type,l.stateNode):l.stateNode=vw(M,u,l.memoizedProps):_!==u?(_===null?p.stateNode!==null&&yw(p.stateNode):_w(_),u===null?xw(M,l.type,l.stateNode):vw(M,u,l.memoizedProps)):u===null&&l.stateNode!==null&&dR(l,l.memoizedProps,p.memoizedProps));break}case 27:if(ma&&_&4&&l.alternate===null){M=l.stateNode;var A=l.memoizedProps;try{X7(M),Y7(l.type,A,M,l)}catch(et){bn(l,l.return,et)}}case 5:if(Fa(u,l),lr(l),_&512&&(di||p===null||or(p,p.return)),pa){if(l.flags&32){u=l.stateNode;try{sw(u)}catch(et){bn(l,l.return,et)}}_&4&&l.stateNode!=null&&(u=l.memoizedProps,dR(l,u,p!==null?p.memoizedProps:u)),_&1024&&(LS=!0)}break;case 6:if(Fa(u,l),lr(l),_&4&&pa){if(l.stateNode===null)throw Error(a(162));_=l.memoizedProps,p=p!==null?p.memoizedProps:_,u=l.stateNode;try{o7(u,p,_)}catch(et){bn(l,l.return,et)}}break;case 3:if(Ur?(V7(),M=fs,fs=xS(u.containerInfo),Fa(u,l),fs=M):Fa(u,l),lr(l),_&4){if(pa&&Ir&&p!==null&&p.memoizedState.isDehydrated)try{I7(u.containerInfo)}catch(et){bn(l,l.return,et)}if(gl){_=u.containerInfo,p=u.pendingChildren;try{cw(_,p)}catch(et){bn(l,l.return,et)}}}LS&&(LS=!1,yR(l));break;case 4:Ur?(p=fs,fs=xS(l.stateNode.containerInfo),Fa(u,l),lr(l),fs=p):(Fa(u,l),lr(l)),_&4&&gl&&mR(l.stateNode,l,l.stateNode.pendingChildren);break;case 12:Fa(u,l),lr(l);break;case 13:Fa(u,l),lr(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(zS=us()),_&4&&(_=l.updateQueue,_!==null&&(l.updateQueue=null,Xy(l,_)));break;case 22:_&512&&(di||p===null||or(p,p.return)),M=l.memoizedState!==null;var F=p!==null&&p.memoizedState!==null,$=yo,he=di;if(yo=$||M,di=he||F,Fa(u,l),di=he,yo=$,lr(l),u=l.stateNode,u._current=l,u._visibility&=-3,u._visibility|=u._pendingVisibility&2,_&8192&&(u._visibility=M?u._visibility&-2:u._visibility|1,M&&(u=yo||di,p===null||F||u||vh(l)),pa&&(l.memoizedProps===null||l.memoizedProps.mode!=="manual"))){e:if(p=null,pa)for(u=l;;){if(u.tag===5||Ur&&u.tag===26||ma&&u.tag===27){if(p===null){F=p=u;try{A=F.stateNode,M?p7(A):g7(F.stateNode,F.memoizedProps)}catch(et){bn(F,F.return,et)}}}else if(u.tag===6){if(p===null){F=u;try{var Ne=F.stateNode;M?m7(Ne):v7(Ne,F.memoizedProps)}catch(et){bn(F,F.return,et)}}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===l)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break e;for(;u.sibling===null;){if(u.return===null||u.return===l)break e;p===u&&(p=null),u=u.return}p===u&&(p=null),u.sibling.return=u.return,u=u.sibling}}_&4&&(_=l.updateQueue,_!==null&&(p=_.retryQueue,p!==null&&(_.retryQueue=null,Xy(l,p))));break;case 19:Fa(u,l),lr(l),_&4&&(_=l.updateQueue,_!==null&&(l.updateQueue=null,Xy(l,_)));break;case 21:break;default:Fa(u,l),lr(l)}}function lr(l){var u=l.flags;if(u&2){try{if(pa&&(!ma||l.tag!==27)){e:{for(var p=l.return;p!==null;){if(pR(p)){var _=p;break e}p=p.return}throw Error(a(160))}switch(_.tag){case 27:if(ma){var M=_.stateNode,A=Vy(l);tg(l,A,M);break}case 5:var F=_.stateNode;_.flags&32&&(sw(F),_.flags&=-33);var $=Vy(l);tg(l,$,F);break;case 3:case 4:var he=_.stateNode.containerInfo,Ne=Vy(l);ky(l,Ne,he);break;default:throw Error(a(161))}}}catch(et){bn(l,l.return,et)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function yR(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var u=l;yR(u),u.tag===5&&u.flags&1024&&K9(u.stateNode),l=l.sibling}}function po(l,u){if(u.subtreeFlags&8772)for(u=u.child;u!==null;)gR(l,u.alternate,u),u=u.sibling}function vh(l){for(l=l.child;l!==null;){var u=l;switch(u.tag){case 0:case 11:case 14:case 15:ul(4,u,u.return),vh(u);break;case 1:or(u,u.return);var p=u.stateNode;typeof p.componentWillUnmount=="function"&&hR(u,u.return,p),vh(u);break;case 26:case 27:case 5:or(u,u.return),vh(u);break;case 22:or(u,u.return),u.memoizedState===null&&vh(u);break;default:vh(u)}l=l.sibling}}function hl(l,u,p){for(p=p&&(u.subtreeFlags&8772)!==0,u=u.child;u!==null;){var _=u.alternate,M=l,A=u,F=A.flags;switch(A.tag){case 0:case 11:case 15:hl(M,A,p),sp(4,A);break;case 1:if(hl(M,A,p),_=A,M=_.stateNode,typeof M.componentDidMount=="function")try{M.componentDidMount()}catch(Ne){bn(_,_.return,Ne)}if(_=A,M=_.updateQueue,M!==null){var $=_.stateNode;try{var he=M.shared.hiddenCallbacks;if(he!==null)for(M.shared.hiddenCallbacks=null,M=0;M<he.length;M++)q(he[M],$)}catch(Ne){bn(_,_.return,Ne)}}p&&F&64&&uR(A),Cc(A,A.return);break;case 26:case 27:case 5:hl(M,A,p),p&&_===null&&F&4&&fR(A),Cc(A,A.return);break;case 12:hl(M,A,p);break;case 13:hl(M,A,p),p&&F&4&&_R(M,A);break;case 22:A.memoizedState===null&&hl(M,A,p),Cc(A,A.return);break;default:hl(M,A,p)}u=u.sibling}}function Yy(l,u){var p=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),l=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(l=u.memoizedState.cachePool.pool),l!==p&&(l!=null&&l.refCount++,p!=null&&ap(p))}function qy(l,u){l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&ap(l))}function fl(l,u,p,_){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)SR(l,u,p,_),u=u.sibling}function SR(l,u,p,_){var M=u.flags;switch(u.tag){case 0:case 11:case 15:fl(l,u,p,_),M&2048&&sp(9,u);break;case 3:fl(l,u,p,_),M&2048&&(l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&ap(l)));break;case 12:if(M&2048){fl(l,u,p,_),l=u.stateNode;try{var A=u.memoizedProps,F=A.id,$=A.onPostCommit;typeof $=="function"&&$(F,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(he){bn(u,u.return,he)}}else fl(l,u,p,_);break;case 23:break;case 22:A=u.stateNode,u.memoizedState!==null?A._visibility&4?fl(l,u,p,_):op(l,u):A._visibility&4?fl(l,u,p,_):(A._visibility|=4,_h(l,u,p,_,(u.subtreeFlags&10256)!==0)),M&2048&&Yy(u.alternate,u);break;case 24:fl(l,u,p,_),M&2048&&qy(u.alternate,u);break;default:fl(l,u,p,_)}}function _h(l,u,p,_,M){for(M=M&&(u.subtreeFlags&10256)!==0,u=u.child;u!==null;){var A=l,F=u,$=p,he=_,Ne=F.flags;switch(F.tag){case 0:case 11:case 15:_h(A,F,$,he,M),sp(8,F);break;case 23:break;case 22:var et=F.stateNode;F.memoizedState!==null?et._visibility&4?_h(A,F,$,he,M):op(A,F):(et._visibility|=4,_h(A,F,$,he,M)),M&&Ne&2048&&Yy(F.alternate,F);break;case 24:_h(A,F,$,he,M),M&&Ne&2048&&qy(F.alternate,F);break;default:_h(A,F,$,he,M)}u=u.sibling}}function op(l,u){if(u.subtreeFlags&10256)for(u=u.child;u!==null;){var p=l,_=u,M=_.flags;switch(_.tag){case 22:op(p,_),M&2048&&Yy(_.alternate,_);break;case 24:op(p,_),M&2048&&qy(_.alternate,_);break;default:op(p,_)}u=u.sibling}}function Nc(l){if(l.subtreeFlags&Bh)for(l=l.child;l!==null;)TR(l),l=l.sibling}function TR(l){switch(l.tag){case 26:Nc(l),l.flags&Bh&&(l.memoizedState!==null?W7(fs,l.memoizedState,l.memoizedProps):rw(l.type,l.memoizedProps));break;case 5:Nc(l),l.flags&Bh&&rw(l.type,l.memoizedProps);break;case 3:case 4:if(Ur){var u=fs;fs=xS(l.stateNode.containerInfo),Nc(l),fs=u}else Nc(l);break;case 22:l.memoizedState===null&&(u=l.alternate,u!==null&&u.memoizedState!==null?(u=Bh,Bh=16777216,Nc(l),Bh=u):Nc(l));break;default:Nc(l)}}function ER(l){var u=l.alternate;if(u!==null&&(l=u.child,l!==null)){u.child=null;do u=l.sibling,l.sibling=null,l=u;while(l!==null)}}function lp(l){var u=l.deletions;if(l.flags&16){if(u!==null)for(var p=0;p<u.length;p++){var _=u[p];Xi=_,bR(_,l)}ER(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)MR(l),l=l.sibling}function MR(l){switch(l.tag){case 0:case 11:case 15:lp(l),l.flags&2048&&ul(9,l,l.return);break;case 3:lp(l);break;case 12:lp(l);break;case 22:var u=l.stateNode;l.memoizedState!==null&&u._visibility&4&&(l.return===null||l.return.tag!==13)?(u._visibility&=-5,ng(l)):lp(l);break;default:lp(l)}}function ng(l){var u=l.deletions;if(l.flags&16){if(u!==null)for(var p=0;p<u.length;p++){var _=u[p];Xi=_,bR(_,l)}ER(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:ul(8,u,u.return),ng(u);break;case 22:p=u.stateNode,p._visibility&4&&(p._visibility&=-5,ng(u));break;default:ng(u)}l=l.sibling}}function bR(l,u){for(;Xi!==null;){var p=Xi;switch(p.tag){case 0:case 11:case 15:ul(8,p,u);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var _=p.memoizedState.cachePool.pool;_!=null&&_.refCount++}break;case 24:ap(p.memoizedState.cache)}if(_=p.child,_!==null)_.return=p,Xi=_;else e:for(p=l;Xi!==null;){_=Xi;var M=_.sibling,A=_.return;if(vR(_),_===p){Xi=null;break e}if(M!==null){M.return=A,Xi=M;break e}Xi=A}}}function jy(l){var u=iw(l);if(u!=null){if(typeof u.memoizedProps["data-testname"]!="string")throw Error(a(364));return u}if(l=$9(l),l===null)throw Error(a(362));return l.stateNode.current}function Zy(l,u){var p=l.tag;switch(u.$$typeof){case Sg:if(l.type===u.value)return!0;break;case Tg:e:{for(u=u.value,l=[l,0],p=0;p<l.length;){var _=l[p++],M=_.tag,A=l[p++],F=u[A];if(M!==5&&M!==26&&M!==27||!hp(_)){for(;F!=null&&Zy(_,F);)A++,F=u[A];if(A===u.length){u=!0;break e}else for(_=_.child;_!==null;)l.push(_,A),_=_.sibling}}u=!1}return u;case Eg:if((p===5||p===26||p===27)&&n7(l.stateNode,u.value))return!0;break;case bg:if((p===5||p===6||p===26||p===27)&&(l=t7(l),l!==null&&0<=l.indexOf(u.value)))return!0;break;case Mg:if((p===5||p===26||p===27)&&(l=l.memoizedProps["data-testname"],typeof l=="string"&&l.toLowerCase()===u.value.toLowerCase()))return!0;break;default:throw Error(a(365))}return!1}function Ky(l){switch(l.$$typeof){case Sg:return"<"+(s(l.value)||"Unknown")+">";case Tg:return":has("+(Ky(l)||"")+")";case Eg:return'[role="'+l.value+'"]';case bg:return'"'+l.value+'"';case Mg:return'[data-testname="'+l.value+'"]';default:throw Error(a(365))}}function AR(l,u){var p=[];l=[l,0];for(var _=0;_<l.length;){var M=l[_++],A=M.tag,F=l[_++],$=u[F];if(A!==5&&A!==26&&A!==27||!hp(M)){for(;$!=null&&Zy(M,$);)F++,$=u[F];if(F===u.length)p.push(M);else for(M=M.child;M!==null;)l.push(M,F),M=M.sibling}}return p}function Qy(l,u){if(!up)throw Error(a(363));l=jy(l),l=AR(l,u),u=[],l=Array.from(l);for(var p=0;p<l.length;){var _=l[p++],M=_.tag;if(M===5||M===26||M===27)hp(_)||u.push(_.stateNode);else for(_=_.child;_!==null;)l.push(_),_=_.sibling}return u}function cr(){if(In&2&&hn!==0)return hn&-hn;if(Ft.T!==null){var l=Dh;return l!==0?l:Le()}return W9()}function RR(){Fr===0&&(Fr=!(hn&536870912)||pn?P():536870912);var l=Hr.current;return l!==null&&(l.flags|=32),Fr}function Ea(l,u,p){(l===Vn&&kn===2||l.cancelPendingCommit!==null)&&(xh(l,0),mo(l,hn,Fr,!1)),B(l,p),(!(In&2)||l!==Vn)&&(l===Vn&&(!(In&2)&&(Vc|=p),pi===4&&mo(l,hn,Fr,!1)),$e(l))}function wR(l,u,p){if(In&6)throw Error(a(327));var _=!p&&(u&60)===0&&(u&l.expiredLanes)===0||C(l,u),M=_?y9(l,u):tS(l,u,!0),A=_;do{if(M===0){Hh&&!_&&mo(l,u,0,!1);break}else if(M===6)mo(l,u,0,!So);else{if(p=l.current.alternate,A&&!_9(p)){M=tS(l,u,!1),A=!1;continue}if(M===2){if(A=u,l.errorRecoveryDisabledLanes&A)var F=0;else F=l.pendingLanes&-536870913,F=F!==0?F:F&536870912?536870912:0;if(F!==0){u=F;e:{var $=l;M=xp;var he=Ir&&$.current.memoizedState.isDehydrated;if(he&&(xh($,F).flags|=256),F=tS($,F,!1),F!==2){if(IS&&!he){$.errorRecoveryDisabledLanes|=A,Vc|=A,M=4;break e}A=Gs,Gs=M,A!==null&&Jy(A)}M=F}if(A=!1,M!==2)continue}}if(M===1){xh(l,0),mo(l,u,0,!0);break}e:{switch(_=l,M){case 0:case 1:throw Error(a(345));case 4:if((u&4194176)===u){mo(_,u,Fr,!So);break e}break;case 2:Gs=null;break;case 3:case 5:break;default:throw Error(a(329))}if(_.finishedWork=p,_.finishedLanes=u,(u&62914560)===u&&(A=zS+300-us(),10<A)){if(mo(_,u,Fr,!So),D(_,0)!==0)break e;_.timeoutHandle=G9(CR.bind(null,_,p,Gs,Ag,PS,u,Fr,Vc,Fh,So,2,-0,0),A);break e}CR(_,p,Gs,Ag,PS,u,Fr,Vc,Fh,So,0,-0,0)}}break}while(!0);$e(l)}function Jy(l){Gs===null?Gs=l:Gs.push.apply(Gs,l)}function CR(l,u,p,_,M,A,F,$,he,Ne,et,dt,mt){var Yt=u.subtreeFlags;if((Yt&8192||(Yt&16785408)===16785408)&&(j9(),TR(u),u=Z9(),u!==null)){l.cancelPendingCommit=u(BR.bind(null,l,p,_,M,F,$,he,1,dt,mt)),mo(l,A,F,!Ne);return}BR(l,p,_,M,F,$,he,et,dt,mt)}function _9(l){for(var u=l;;){var p=u.tag;if((p===0||p===11||p===15)&&u.flags&16384&&(p=u.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var _=0;_<p.length;_++){var M=p[_],A=M.getSnapshot;M=M.value;try{if(!dr(A(),M))return!1}catch{return!1}}if(p=u.child,u.subtreeFlags&16384&&p!==null)p.return=u,u=p;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function mo(l,u,p,_){u&=~US,u&=~Vc,l.suspendedLanes|=u,l.pingedLanes&=~u,_&&(l.warmLanes|=u),_=l.expirationTimes;for(var M=u;0<M;){var A=31-hr(M),F=1<<A;_[A]=-1,M&=~F}p!==0&&ee(l,p,u)}function NR(){return In&6?!0:(Je(0),!1)}function $y(){if(nn!==null){if(kn===0)var l=nn.return;else l=nn,xo=Fc=null,z(l),Ih=null,gp=0,l=nn;for(;l!==null;)cR(l.alternate,l),l=l.return;nn=null}}function xh(l,u){l.finishedWork=null,l.finishedLanes=0;var p=l.timeoutHandle;p!==gS&&(l.timeoutHandle=gS,V9(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),$y(),Vn=l,nn=p=dl(l.current,null),hn=u,kn=0,mr=null,So=!1,Hh=C(l,u),IS=!1,Fh=Fr=US=Vc=Sl=pi=0,Gs=xp=null,PS=!1,u&8&&(u|=u&32);var _=l.entangledLanes;if(_!==0)for(l=l.entanglements,_&=u;0<_;){var M=31-hr(_),A=1<<M;u|=l[M],_&=~A}return To=u,Te(),p}function DR(l,u){en=null,Ft.H=Fs,u===mp?(u=rt(),kn=3):u===CS?(u=rt(),kn=4):kn=u===ww?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,mr=u,nn===null&&(pi=1,K0(l,oe(u,l.current)))}function OR(){var l=Hr.current;return l===null?!0:(hn&4194176)===hn?Hs===null:(hn&62914560)===hn||hn&536870912?l===Hs:!1}function LR(){var l=Ft.H;return Ft.H=Fs,l===null?Fs:l}function IR(){var l=Ft.A;return Ft.A=oz,l}function eS(){pi=4,So||(hn&4194176)!==hn&&Hr.current!==null||(Hh=!0),!(Sl&134217727)&&!(Vc&134217727)||Vn===null||mo(Vn,hn,Fr,!1)}function tS(l,u,p){var _=In;In|=2;var M=LR(),A=IR();(Vn!==l||hn!==u)&&(Ag=null,xh(l,u)),u=!1;var F=pi;e:do try{if(kn!==0&&nn!==null){var $=nn,he=mr;switch(kn){case 8:$y(),F=6;break e;case 3:case 2:case 6:Hr.current===null&&(u=!0);var Ne=kn;if(kn=0,mr=null,yh(l,$,he,Ne),p&&Hh){F=0;break e}break;default:Ne=kn,kn=0,mr=null,yh(l,$,he,Ne)}}x9(),F=pi;break}catch(et){DR(l,et)}while(!0);return u&&l.shellSuspendCounter++,xo=Fc=null,In=_,Ft.H=M,Ft.A=A,nn===null&&(Vn=null,hn=0,Te()),F}function x9(){for(;nn!==null;)UR(nn)}function y9(l,u){var p=In;In|=2;var _=LR(),M=IR();Vn!==l||hn!==u?(Ag=null,yp=us()+500,xh(l,u)):Hh=C(l,u);e:do try{if(kn!==0&&nn!==null){u=nn;var A=mr;t:switch(kn){case 1:kn=0,mr=null,yh(l,u,A,1);break;case 2:if(We(A)){kn=0,mr=null,PR(u);break}u=function(){kn===2&&Vn===l&&(kn=7),$e(l)},A.then(u,u);break e;case 3:kn=7;break e;case 4:kn=5;break e;case 7:We(A)?(kn=0,mr=null,PR(u)):(kn=0,mr=null,yh(l,u,A,7));break;case 5:var F=null;switch(nn.tag){case 26:F=nn.memoizedState;case 5:case 27:var $=nn,he=$.type,Ne=$.pendingProps;if(F?Sw(F):aw(he,Ne)){kn=0,mr=null;var et=$.sibling;if(et!==null)nn=et;else{var dt=$.return;dt!==null?(nn=dt,ig(dt)):nn=null}break t}}kn=0,mr=null,yh(l,u,A,5);break;case 6:kn=0,mr=null,yh(l,u,A,6);break;case 8:$y(),pi=6;break e;default:throw Error(a(462))}}S9();break}catch(mt){DR(l,mt)}while(!0);return xo=Fc=null,Ft.H=_,Ft.A=M,In=p,nn!==null?0:(Vn=null,hn=0,Te(),pi)}function S9(){for(;nn!==null&&!K7();)UR(nn)}function UR(l){var u=nR(l.alternate,l,To);l.memoizedProps=l.pendingProps,u===null?ig(l):nn=u}function PR(l){var u=l,p=u.alternate;switch(u.tag){case 15:case 0:u=KA(p,u,u.pendingProps,u.type,void 0,hn);break;case 11:u=KA(p,u,u.pendingProps,u.type.render,u.ref,hn);break;case 5:z(u);default:cR(p,u),u=nn=VR(u,To),u=nR(p,u,To)}l.memoizedProps=l.pendingProps,u===null?ig(l):nn=u}function yh(l,u,p,_){xo=Fc=null,z(u),Ih=null,gp=0;var M=u.return;try{if(f9(l,M,u,p,hn)){pi=1,K0(l,oe(p,l.current)),nn=null;return}}catch(A){if(M!==null)throw nn=M,A;pi=1,K0(l,oe(p,l.current)),nn=null;return}u.flags&32768?(pn||_===1?l=!0:Hh||hn&536870912?l=!1:(So=l=!0,(_===2||_===3||_===6)&&(_=Hr.current,_!==null&&_.tag===13&&(_.flags|=16384))),zR(u,l)):ig(u)}function ig(l){var u=l;do{if(u.flags&32768){zR(u,So);return}l=u.return;var p=p9(u.alternate,u,To);if(p!==null){nn=p;return}if(u=u.sibling,u!==null){nn=u;return}nn=u=l}while(u!==null);pi===0&&(pi=5)}function zR(l,u){do{var p=m9(l.alternate,l);if(p!==null){p.flags&=32767,nn=p;return}if(p=l.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!u&&(l=l.sibling,l!==null)){nn=l;return}nn=l=p}while(l!==null);pi=6,nn=null}function BR(l,u,p,_,M,A,F,$,he,Ne){var et=Ft.T,dt=Lc();try{Ga(2),Ft.T=null,T9(l,u,p,_,dt,M,A,F,$,he,Ne)}finally{Ft.T=et,Ga(dt)}}function T9(l,u,p,_,M,A,F,$){do Dc();while(kc!==null);if(In&6)throw Error(a(327));var he=l.finishedWork;if(_=l.finishedLanes,he===null)return null;if(l.finishedWork=null,l.finishedLanes=0,he===l.current)throw Error(a(177));l.callbackNode=null,l.callbackPriority=0,l.cancelPendingCommit=null;var Ne=he.lanes|he.childLanes;if(Ne|=MS,j(l,_,Ne,A,F,$),l===Vn&&(nn=Vn=null,hn=0),!(he.subtreeFlags&10256)&&!(he.flags&10256)||Rg||(Rg=!0,BS=Ne,HS=p,A9(TS,function(){return Dc(),null})),p=(he.flags&15990)!==0,he.subtreeFlags&15990||p?(p=Ft.T,Ft.T=null,A=Lc(),Ga(2),F=In,In|=4,g9(l,he),xR(he,l),H9(l.containerInfo),l.current=he,gR(l,he.alternate,he),Q7(),In=F,Ga(A),Ft.T=p):l.current=he,Rg?(Rg=!1,kc=l,Sp=_):HR(l,Ne),Ne=l.pendingLanes,Ne===0&&(Tl=null),W(he.stateNode),$e(l),u!==null)for(M=l.onRecoverableError,he=0;he<u.length;he++)Ne=u[he],M(Ne.value,{componentStack:Ne.stack});return Sp&3&&Dc(),Ne=l.pendingLanes,_&4194218&&Ne&42?l===FS?Tp++:(Tp=0,FS=l):Tp=0,Je(0),null}function HR(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,ap(u)))}function Dc(){if(kc!==null){var l=kc,u=BS;BS=0;var p=re(Sp),_=32>p?32:p;p=Ft.T;var M=Lc();try{if(Ga(_),Ft.T=null,kc===null)var A=!1;else{_=HS,HS=null;var F=kc,$=Sp;if(kc=null,Sp=0,In&6)throw Error(a(331));var he=In;if(In|=4,MR(F.current),SR(F,F.current,$,_),In=he,Je(0,!1),fr&&typeof fr.onPostCommitFiberRoot=="function")try{fr.onPostCommitFiberRoot(fp,F)}catch{}A=!0}return A}finally{Ga(M),Ft.T=p,HR(l,u)}}return!1}function FR(l,u,p){u=oe(p,u),u=Ay(l.stateNode,u,2),l=He(l,u,2),l!==null&&(B(l,2),$e(l))}function bn(l,u,p){if(l.tag===3)FR(l,l,p);else for(;u!==null;){if(u.tag===3){FR(u,l,p);break}else if(u.tag===1){var _=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof _.componentDidCatch=="function"&&(Tl===null||!Tl.has(_))){l=oe(p,l),p=kA(2),_=He(u,p,2),_!==null&&(WA(p,_,u,l),B(_,2),$e(_));break}}u=u.return}}function nS(l,u,p){var _=l.pingCache;if(_===null){_=l.pingCache=new lz;var M=new Set;_.set(u,M)}else M=_.get(u),M===void 0&&(M=new Set,_.set(u,M));M.has(p)||(IS=!0,M.add(p),l=E9.bind(null,l,u,p),u.then(l,l))}function E9(l,u,p){var _=l.pingCache;_!==null&&_.delete(u),l.pingedLanes|=l.suspendedLanes&p,l.warmLanes&=~p,Vn===l&&(hn&p)===p&&(pi===4||pi===3&&(hn&62914560)===hn&&300>us()-zS?!(In&2)&&xh(l,0):US|=p,Fh===hn&&(Fh=0)),$e(l)}function GR(l,u){u===0&&(u=O()),l=De(l,u),l!==null&&(B(l,u),$e(l))}function M9(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),GR(l,p)}function b9(l,u){var p=0;switch(l.tag){case 13:var _=l.stateNode,M=l.memoizedState;M!==null&&(p=M.retryLane);break;case 19:_=l.stateNode;break;case 22:_=l.stateNode._retryCache;break;default:throw Error(a(314))}_!==null&&_.delete(u),GR(l,p)}function A9(l,u){return ug(l,u)}function R9(l,u,p,_){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=_,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function iS(l){return l=l.prototype,!(!l||!l.isReactComponent)}function dl(l,u){var p=l.alternate;return p===null?(p=t(l.tag,u,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=u,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&31457280,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,u=l.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p.refCleanup=l.refCleanup,p}function VR(l,u){l.flags&=31457282;var p=l.alternate;return p===null?(l.childLanes=0,l.lanes=u,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=p.childLanes,l.lanes=p.lanes,l.child=p.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=p.memoizedProps,l.memoizedState=p.memoizedState,l.updateQueue=p.updateQueue,l.type=p.type,u=p.dependencies,l.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),l}function ag(l,u,p,_,M,A){var F=0;if(_=l,typeof l=="function")iS(l)&&(F=1);else if(typeof l=="string")F=Ur&&ma?mw(l,p,aa.current)?26:Ew(l)?27:5:Ur?mw(l,p,aa.current)?26:5:ma&&Ew(l)?27:5;else e:switch(l){case Th:return Oc(p.children,M,A,u);case ZR:F=8,M|=24;break;case lS:return l=t(12,p,u,M|2),l.elementType=lS,l.lanes=A,l;case uS:return l=t(13,p,u,M),l.elementType=uS,l.lanes=A,l;case hS:return l=t(19,p,u,M),l.elementType=hS,l.lanes=A,l;case QR:return kR(p,M,A,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case D9:case pl:F=10;break e;case KR:F=9;break e;case cS:F=11;break e;case fS:F=14;break e;case ml:F=16,_=null;break e}F=29,p=Error(a(130,l===null?"null":typeof l,"")),_=null}return u=t(F,p,u,M),u.elementType=l,u.type=_,u.lanes=A,u}function Oc(l,u,p,_){return l=t(7,l,_,u),l.lanes=p,l}function kR(l,u,p,_){l=t(22,l,_,u),l.elementType=QR,l.lanes=p;var M={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var A=M._current;if(A===null)throw Error(a(456));if(!(M._pendingVisibility&2)){var F=De(A,2);F!==null&&(M._pendingVisibility|=2,Ea(F,A,2))}},attach:function(){var A=M._current;if(A===null)throw Error(a(456));if(M._pendingVisibility&2){var F=De(A,2);F!==null&&(M._pendingVisibility&=-3,Ea(F,A,2))}}};return l.stateNode=M,l}function aS(l,u,p){return l=t(6,l,null,u),l.lanes=p,l}function rS(l,u,p){return u=t(4,l.children!==null?l.children:[],l.key,u),u.lanes=p,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function w9(l,u,p,_,M,A,F,$){this.tag=1,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=gS,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=R(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=R(0),this.hiddenUpdates=R(null),this.identifierPrefix=_,this.onUncaughtError=M,this.onCaughtError=A,this.onRecoverableError=F,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=$,this.incompleteTransitions=new Map}function WR(l,u,p,_,M,A,F,$,he,Ne,et,dt){return l=new w9(l,u,p,F,$,he,Ne,dt),u=1,A===!0&&(u|=24),A=t(3,null,null,u),l.current=A,A.stateNode=l,u=zy(),u.refCount++,l.pooledCache=u,u.refCount++,A.memoizedState={element:_,isDehydrated:p,cache:u},_t(A),l}function XR(l){return l?(l=bh,l):bh}function YR(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(a(188)):(l=Object.keys(l).join(","),Error(a(268,l)));return l=g(u),l=l!==null?x(l):null,l===null?null:cp(l.stateNode)}function qR(l,u,p,_,M,A){M=XR(M),_.context===null?_.context=M:_.pendingContext=M,_=Ie(u),_.payload={element:p},A=A===void 0?null:A,A!==null&&(_.callback=A),p=He(l,_,u),p!==null&&(Ea(p,l,u),ht(p,l,u))}function jR(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<u?p:u}}function sS(l,u){jR(l,u),(l=l.alternate)&&jR(l,u)}var tn={},C9=be,ur=mE,oS=Object.assign,N9=Symbol.for("react.element"),rg=Symbol.for("react.transitional.element"),Sh=Symbol.for("react.portal"),Th=Symbol.for("react.fragment"),ZR=Symbol.for("react.strict_mode"),lS=Symbol.for("react.profiler"),D9=Symbol.for("react.provider"),KR=Symbol.for("react.consumer"),pl=Symbol.for("react.context"),cS=Symbol.for("react.forward_ref"),uS=Symbol.for("react.suspense"),hS=Symbol.for("react.suspense_list"),fS=Symbol.for("react.memo"),ml=Symbol.for("react.lazy"),QR=Symbol.for("react.offscreen"),O9=Symbol.for("react.memo_cache_sentinel"),JR=Symbol.iterator,L9=Symbol.for("react.client.reference"),Ft=C9.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,dS,$R,pS=!1,sg=Array.isArray,I9=e.rendererVersion,U9=e.rendererPackageName,ew=e.extraDevToolsConfig,cp=e.getPublicInstance,P9=e.getRootHostContext,z9=e.getChildHostContext,B9=e.prepareForCommit,H9=e.resetAfterCommit,F9=e.createInstance,mS=e.appendInitialChild,tw=e.finalizeInitialChildren,og=e.shouldSetTextContent,nw=e.createTextInstance,G9=e.scheduleTimeout,V9=e.cancelTimeout,gS=e.noTimeout,go=e.isPrimaryRenderer;e.warnsIfNotActing;var pa=e.supportsMutation,gl=e.supportsPersistence,Ir=e.supportsHydration,iw=e.getInstanceFromNode;e.beforeActiveInstanceBlur,e.afterActiveInstanceBlur;var k9=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var Ga=e.setCurrentUpdatePriority,Lc=e.getCurrentUpdatePriority,W9=e.resolveUpdatePriority;e.resolveEventType,e.resolveEventTimeStamp;var X9=e.shouldAttemptEagerTransition,Y9=e.detachDeletedInstance;e.requestPostPaintCallback;var q9=e.maySuspendCommit,aw=e.preloadInstance,j9=e.startSuspendingCommit,rw=e.suspendInstance,Z9=e.waitForCommitToBeReady,Eh=e.NotPendingTransition,Ic=e.HostTransitionContext,K9=e.resetFormInstance;e.bindToConsole;var Q9=e.supportsMicrotasks,J9=e.scheduleMicrotask,up=e.supportsTestSelectors,$9=e.findFiberRoot,e7=e.getBoundingRect,t7=e.getTextContent,hp=e.isHiddenSubtree,n7=e.matchAccessibilityRole,i7=e.setFocusIfFocusable,a7=e.setupIntersectionObserver,r7=e.appendChild,s7=e.appendChildToContainer,o7=e.commitTextUpdate,l7=e.commitMount,c7=e.commitUpdate,u7=e.insertBefore,h7=e.insertInContainerBefore,f7=e.removeChild,d7=e.removeChildFromContainer,sw=e.resetTextContent,p7=e.hideInstance,m7=e.hideTextInstance,g7=e.unhideInstance,v7=e.unhideTextInstance,_7=e.clearContainer,x7=e.cloneInstance,ow=e.createContainerChildSet,lw=e.appendChildToContainerChildSet,y7=e.finalizeContainerChildren,cw=e.replaceContainerChildren,uw=e.cloneHiddenInstance,hw=e.cloneHiddenTextInstance,vS=e.isSuspenseInstancePending,_S=e.isSuspenseInstanceFallback,S7=e.getSuspenseInstanceFallbackErrorDetails,T7=e.registerSuspenseInstanceRetry,E7=e.canHydrateFormStateMarker,M7=e.isFormStateMarkerMatching,fw=e.getNextHydratableSibling,dw=e.getFirstHydratableChild,b7=e.getFirstHydratableChildWithinContainer,A7=e.getFirstHydratableChildWithinSuspenseInstance,R7=e.canHydrateInstance,w7=e.canHydrateTextInstance,C7=e.canHydrateSuspenseInstance,N7=e.hydrateInstance,D7=e.hydrateTextInstance,O7=e.hydrateSuspenseInstance,L7=e.getNextHydratableInstanceAfterSuspenseInstance,I7=e.commitHydratedContainer,U7=e.commitHydratedSuspenseInstance,P7=e.clearSuspenseBoundary,z7=e.clearSuspenseBoundaryFromContainer,pw=e.shouldDeleteUnhydratedTailInstances;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var B7=e.validateHydratableInstance,H7=e.validateHydratableTextInstance,Ur=e.supportsResources,mw=e.isHostHoistableType,xS=e.getHoistableRoot,gw=e.getResource,vw=e.acquireResource,_w=e.releaseResource,F7=e.hydrateHoistable,xw=e.mountHoistable,yw=e.unmountHoistable,G7=e.createHoistableInstance,V7=e.prepareToCommitHoistables,k7=e.mayResourceSuspendCommit,Sw=e.preloadResource,W7=e.suspendResource,ma=e.supportsSingletons,Tw=e.resolveSingletonInstance,X7=e.clearSingleton,Y7=e.acquireSingletonInstance,q7=e.releaseSingletonInstance,Ew=e.isHostSingletonType,yS=[],Mh=-1,bh={},hr=Math.clz32?Math.clz32:E,j7=Math.log,Z7=Math.LN2,lg=128,cg=4194304,ug=ur.unstable_scheduleCallback,SS=ur.unstable_cancelCallback,K7=ur.unstable_shouldYield,Q7=ur.unstable_requestPaint,us=ur.unstable_now,Mw=ur.unstable_ImmediatePriority,J7=ur.unstable_UserBlockingPriority,TS=ur.unstable_NormalPriority,$7=ur.unstable_IdlePriority,ez=ur.log,tz=ur.unstable_setDisableYieldValue,fp=null,fr=null,dr=typeof Object.is=="function"?Object.is:K,bw=new WeakMap,Ah=[],Rh=0,hg=null,fg=0,Pr=[],zr=0,Uc=null,vo=1,_o="",aa=S(null),dp=S(null),vl=S(null),dg=S(null),Ma=null,ga=null,pn=!1,hs=null,Bs=!1,ES=Error(a(519)),Br=[],wh=0,MS=0,pg=null,Ch=null,bS=!1,mg=!1,AS=!1,Nh=0,pp=null,RS=0,Dh=0,Oh=null,_l=!1,wS=!1,nz=Object.prototype.hasOwnProperty,mp=Error(a(460)),CS=Error(a(474)),gg={then:function(){}},Lh=null,Ih=null,gp=0,Pc=li(!0),Aw=li(!1),Uh=S(null),vg=S(0),Hr=S(null),Hs=null,zi=S(0),xl=0,en=null,Ln=null,bi=null,_g=!1,Ph=!1,zc=!1,xg=0,vp=0,zh=null,iz=0,NS=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}},Fs={readContext:da,use:Z,useCallback:Dn,useContext:Dn,useEffect:Dn,useImperativeHandle:Dn,useLayoutEffect:Dn,useInsertionEffect:Dn,useMemo:Dn,useReducer:Dn,useRef:Dn,useState:Dn,useDebugValue:Dn,useDeferredValue:Dn,useTransition:Dn,useSyncExternalStore:Dn,useId:Dn};Fs.useCacheRefresh=Dn,Fs.useMemoCache=Dn,Fs.useHostTransitionStatus=Dn,Fs.useFormState=Dn,Fs.useActionState=Dn,Fs.useOptimistic=Dn;var Bc={readContext:da,use:Z,useCallback:function(l,u){return Y().memoizedState=[l,u===void 0?null:u],l},useContext:da,useEffect:bA,useImperativeHandle:function(l,u,p){p=p!=null?p.concat([l]):null,Lr(4194308,4,wA.bind(null,u,l),p)},useLayoutEffect:function(l,u){return Lr(4194308,4,l,u)},useInsertionEffect:function(l,u){Lr(4,2,l,u)},useMemo:function(l,u){var p=Y();u=u===void 0?null:u;var _=l();if(zc){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[_,u],_},useReducer:function(l,u,p){var _=Y();if(p!==void 0){var M=p(u);if(zc){te(!0);try{p(u)}finally{te(!1)}}}else M=u;return _.memoizedState=_.baseState=M,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:M},_.queue=l,l=l.dispatch=h9.bind(null,en,l),[_.memoizedState,l]},useRef:function(l){var u=Y();return l={current:l},u.memoizedState=l},useState:function(l){l=lt(l);var u=l.queue,p=zA.bind(null,en,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:Sy,useDeferredValue:function(l,u){var p=Y();return Ty(p,l,u)},useTransition:function(){var l=lt(!1);return l=LA.bind(null,en,l.queue,!0,!1),Y().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,p){var _=en,M=Y();if(pn){if(p===void 0)throw Error(a(407));p=p()}else{if(p=u(),Vn===null)throw Error(a(349));hn&60||Se(_,u,p)}M.memoizedState=p;var A={value:p,getSnapshot:u};return M.queue=A,bA(Pe.bind(null,_,A,l),[l]),_.flags|=2048,Gn(9,we.bind(null,_,A,p,u),{destroy:void 0},null),p},useId:function(){var l=Y(),u=Vn.identifierPrefix;if(pn){var p=_o,_=vo;p=(_&~(1<<32-hr(_)-1)).toString(32)+p,u=":"+u+"R"+p,p=xg++,0<p&&(u+="H"+p.toString(32)),u+=":"}else p=iz++,u=":"+u+"r"+p.toString(32)+":";return l.memoizedState=u},useCacheRefresh:function(){return Y().memoizedState=u9.bind(null,en)}};Bc.useMemoCache=H,Bc.useHostTransitionStatus=Ey,Bc.useFormState=kt,Bc.useActionState=kt,Bc.useOptimistic=function(l){var u=Y();u.memoizedState=u.baseState=l;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=p,u=My.bind(null,en,!0,p),p.dispatch=u,[l,u]};var yl={readContext:da,use:Z,useCallback:NA,useContext:da,useEffect:yy,useImperativeHandle:CA,useInsertionEffect:AA,useLayoutEffect:RA,useMemo:DA,useReducer:ne,useRef:gh,useState:function(){return ne(X)},useDebugValue:Sy,useDeferredValue:function(l,u){var p=N();return OA(p,Ln.memoizedState,l,u)},useTransition:function(){var l=ne(X)[0],u=N().memoizedState;return[typeof l=="boolean"?l:V(l),u]},useSyncExternalStore:_e,useId:UA};yl.useCacheRefresh=PA,yl.useMemoCache=H,yl.useHostTransitionStatus=Ey,yl.useFormState=Ct,yl.useActionState=Ct,yl.useOptimistic=function(l,u){var p=N();return St(p,Ln,l,u)};var Hc={readContext:da,use:Z,useCallback:NA,useContext:da,useEffect:yy,useImperativeHandle:CA,useInsertionEffect:AA,useLayoutEffect:RA,useMemo:DA,useReducer:fe,useRef:gh,useState:function(){return fe(X)},useDebugValue:Sy,useDeferredValue:function(l,u){var p=N();return Ln===null?Ty(p,l,u):OA(p,Ln.memoizedState,l,u)},useTransition:function(){var l=fe(X)[0],u=N().memoizedState;return[typeof l=="boolean"?l:V(l),u]},useSyncExternalStore:_e,useId:UA};Hc.useCacheRefresh=PA,Hc.useMemoCache=H,Hc.useHostTransitionStatus=Ey,Hc.useFormState=Mn,Hc.useActionState=Mn,Hc.useOptimistic=function(l,u){var p=N();return Ln!==null?St(p,Ln,l,u):(p.baseState=l,[l,p.queue.dispatch])};var DS={isMounted:function(l){return(l=l._reactInternals)?d(l)===l:!1},enqueueSetState:function(l,u,p){l=l._reactInternals;var _=cr(),M=Ie(_);M.payload=u,p!=null&&(M.callback=p),u=He(l,M,_),u!==null&&(Ea(u,l,_),ht(u,l,_))},enqueueReplaceState:function(l,u,p){l=l._reactInternals;var _=cr(),M=Ie(_);M.tag=1,M.payload=u,p!=null&&(M.callback=p),u=He(l,M,_),u!==null&&(Ea(u,l,_),ht(u,l,_))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var p=cr(),_=Ie(p);_.tag=2,u!=null&&(_.callback=u),u=He(l,_,p),u!==null&&(Ea(u,l,p),ht(u,l,p))}},Rw=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)},ww=Error(a(461)),Wi=!1,OS={dehydrated:null,treeContext:null,retryLane:0},yg=S(null),Fc=null,xo=null,az=typeof AbortController<"u"?AbortController:function(){var l=[],u=this.signal={aborted:!1,addEventListener:function(p,_){l.push(_)}};this.abort=function(){u.aborted=!0,l.forEach(function(p){return p()})}},rz=ur.unstable_scheduleCallback,sz=ur.unstable_NormalPriority,fi={$$typeof:pl,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},Cw=Ft.S;Ft.S=function(l,u){typeof u=="object"&&u!==null&&typeof u.then=="function"&&ye(l,u),Cw!==null&&Cw(l,u)};var Gc=S(null),yo=!1,di=!1,LS=!1,Nw=typeof WeakSet=="function"?WeakSet:Set,Xi=null,Dw=!1,Ai=null,pr=!1,fs=null,Bh=8192,oz={getCacheForType:function(l){var u=da(fi),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p}},Sg=0,Tg=1,Eg=2,Mg=3,bg=4;if(typeof Symbol=="function"&&Symbol.for){var _p=Symbol.for;Sg=_p("selector.component"),Tg=_p("selector.has_pseudo_class"),Eg=_p("selector.role"),Mg=_p("selector.test_id"),bg=_p("selector.text")}var lz=typeof WeakMap=="function"?WeakMap:Map,In=0,Vn=null,nn=null,hn=0,kn=0,mr=null,So=!1,Hh=!1,IS=!1,To=0,pi=0,Sl=0,Vc=0,US=0,Fr=0,Fh=0,xp=null,Gs=null,PS=!1,zS=0,yp=1/0,Ag=null,Tl=null,Rg=!1,kc=null,Sp=0,BS=0,HS=null,Tp=0,FS=null;return tn.attemptContinuousHydration=function(l){if(l.tag===13){var u=De(l,67108864);u!==null&&Ea(u,l,67108864),sS(l,67108864)}},tn.attemptHydrationAtCurrentPriority=function(l){if(l.tag===13){var u=cr(),p=De(l,u);p!==null&&Ea(p,l,u),sS(l,u)}},tn.attemptSynchronousHydration=function(l){switch(l.tag){case 3:if(l=l.stateNode,l.current.memoizedState.isDehydrated){var u=b(l.pendingLanes);if(u!==0){for(l.pendingLanes|=2,l.entangledLanes|=2;u;){var p=1<<31-hr(u);l.entanglements[1]|=p,u&=~p}$e(l),!(In&6)&&(yp=us()+500,Je(0))}}break;case 13:u=De(l,2),u!==null&&Ea(u,l,2),NR(),sS(l,2)}},tn.batchedUpdates=function(l,u){return l(u)},tn.createComponentSelector=function(l){return{$$typeof:Sg,value:l}},tn.createContainer=function(l,u,p,_,M,A,F,$,he,Ne){return WR(l,u,!1,null,p,_,A,F,$,he,Ne,null)},tn.createHasPseudoClassSelector=function(l){return{$$typeof:Tg,value:l}},tn.createHydrationContainer=function(l,u,p,_,M,A,F,$,he,Ne,et,dt,mt){return l=WR(p,_,!0,l,M,A,$,he,Ne,et,dt,mt),l.context=XR(null),p=l.current,_=cr(),M=Ie(_),M.callback=u??null,He(p,M,_),l.current.lanes=_,B(l,_),$e(l),l},tn.createPortal=function(l,u,p){var _=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Sh,key:_==null?null:""+_,children:l,containerInfo:u,implementation:p}},tn.createRoleSelector=function(l){return{$$typeof:Eg,value:l}},tn.createTestNameSelector=function(l){return{$$typeof:Mg,value:l}},tn.createTextSelector=function(l){return{$$typeof:bg,value:l}},tn.defaultOnCaughtError=function(l){console.error(l)},tn.defaultOnRecoverableError=function(l){Rw(l)},tn.defaultOnUncaughtError=function(l){Rw(l)},tn.deferredUpdates=function(l){var u=Ft.T,p=Lc();try{return Ga(32),Ft.T=null,l()}finally{Ga(p),Ft.T=u}},tn.discreteUpdates=function(l,u,p,_,M){var A=Ft.T,F=Lc();try{return Ga(2),Ft.T=null,l(u,p,_,M)}finally{Ga(F),Ft.T=A,In===0&&(yp=us()+500)}},tn.findAllNodes=Qy,tn.findBoundingRects=function(l,u){if(!up)throw Error(a(363));u=Qy(l,u),l=[];for(var p=0;p<u.length;p++)l.push(e7(u[p]));for(u=l.length-1;0<u;u--){p=l[u];for(var _=p.x,M=_+p.width,A=p.y,F=A+p.height,$=u-1;0<=$;$--)if(u!==$){var he=l[$],Ne=he.x,et=Ne+he.width,dt=he.y,mt=dt+he.height;if(_>=Ne&&A>=dt&&M<=et&&F<=mt){l.splice(u,1);break}else if(_!==Ne||p.width!==he.width||mt<A||dt>F){if(!(A!==dt||p.height!==he.height||et<_||Ne>M)){Ne>_&&(he.width+=Ne-_,he.x=_),et<M&&(he.width=M-Ne),l.splice(u,1);break}}else{dt>A&&(he.height+=dt-A,he.y=A),mt<F&&(he.height=F-dt),l.splice(u,1);break}}}return l},tn.findHostInstance=YR,tn.findHostInstanceWithNoPortals=function(l){return l=g(l),l=l!==null?T(l):null,l===null?null:cp(l.stateNode)},tn.findHostInstanceWithWarning=function(l){return YR(l)},tn.flushPassiveEffects=Dc,tn.flushSyncFromReconciler=function(l){var u=In;In|=1;var p=Ft.T,_=Lc();try{if(Ga(2),Ft.T=null,l)return l()}finally{Ga(_),Ft.T=p,In=u,!(In&6)&&Je(0)}},tn.flushSyncWork=NR,tn.focusWithin=function(l,u){if(!up)throw Error(a(363));for(l=jy(l),u=AR(l,u),u=Array.from(u),l=0;l<u.length;){var p=u[l++],_=p.tag;if(!hp(p)){if((_===5||_===26||_===27)&&i7(p.stateNode))return!0;for(p=p.child;p!==null;)u.push(p),p=p.sibling}}return!1},tn.getFindAllNodesFailureDescription=function(l,u){if(!up)throw Error(a(363));var p=0,_=[];l=[jy(l),0];for(var M=0;M<l.length;){var A=l[M++],F=A.tag,$=l[M++],he=u[$];if((F!==5&&F!==26&&F!==27||!hp(A))&&(Zy(A,he)&&(_.push(Ky(he)),$++,$>p&&(p=$)),$<u.length))for(A=A.child;A!==null;)l.push(A,$),A=A.sibling}if(p<u.length){for(l=[];p<u.length;p++)l.push(Ky(u[p]));return`findAllNodes was able to match part of the selector:
`+(_.join(" > ")+`
No matching component was found for:
`)+l.join(" > ")}return null},tn.getPublicRootInstance=function(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 27:case 5:return cp(l.child.stateNode);default:return l.child.stateNode}},tn.injectIntoDevTools=function(){var l={bundleType:0,version:I9,rendererPackageName:U9,currentDispatcherRef:Ft,findFiberByHostInstance:iw,reconcilerVersion:"19.0.0"};if(ew!==null&&(l.rendererConfig=ew),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")l=!1;else{var u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(u.isDisabled||!u.supportsFiber)l=!0;else{try{fp=u.inject(l),fr=u}catch{}l=!!u.checkDCE}}return l},tn.isAlreadyRendering=function(){return!1},tn.observeVisibleRects=function(l,u,p,_){if(!up)throw Error(a(363));l=Qy(l,u);var M=a7(l,p,_).disconnect;return{disconnect:function(){M()}}},tn.shouldError=function(){return null},tn.shouldSuspend=function(){return!1},tn.startHostTransition=function(l,u,p,_){if(l.tag!==5)throw Error(a(476));var M=IA(l).queue;LA(l,M,u,Eh,p===null?i:function(){var A=IA(l).next.queue;return tp(l,A,{},cr()),p(_)})},tn.updateContainer=function(l,u,p,_){var M=u.current,A=cr();return qR(M,A,l,u,p,_),A},tn.updateContainerSync=function(l,u,p,_){return u.tag===0&&Dc(),qR(u.current,2,l,u,p,_),2},tn},n.exports.default=n.exports,Object.defineProperty(n.exports,"__esModule",{value:!0})})(Y6);var Yj=Y6.exports;X6.exports=Yj;var qj=X6.exports;const jj=r1(qj);function Qb(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const a=Qb(i,e,t);if(a)return a;i=e?null:i.sibling}}function Z6(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const Jb=Z6(be.createContext(null));let K6=class extends be.Component{render(){return be.createElement(Jb.Provider,{value:this._reactInternals},this.props.children)}};function Q6(){const n=be.useContext(Jb);if(n===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=be.useId();return be.useMemo(()=>{for(const t of[n,n==null?void 0:n.alternate]){if(!t)continue;const i=Qb(t,!1,a=>{let r=a.memoizedState;for(;r;){if(r.memoizedState===e)return!0;r=r.next}});if(i)return i}},[n,e])}const Zj=Symbol.for("react.context"),Kj=n=>n!==null&&typeof n=="object"&&"$$typeof"in n&&n.$$typeof===Zj;function Qj(){const n=Q6(),[e]=be.useState(()=>new Map);e.clear();let t=n;for(;t;){const i=t.type;Kj(i)&&i!==Jb&&!e.has(i)&&e.set(i,be.use(Z6(i))),t=t.return}return e}function Jj(){const n=Qj();return be.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>be.createElement(e,null,be.createElement(t.Provider,{...i,value:n.get(t)})),e=>be.createElement(K6,{...e})),[n])}function J6(n){let e=n.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const $6=n=>n&&n.isOrthographicCamera,$j=n=>n&&n.hasOwnProperty("current"),eZ=n=>n!=null&&(typeof n=="string"||typeof n=="number"||n.isColor),G0=((n,e)=>typeof window<"u"&&(((n=window.document)==null?void 0:n.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?be.useLayoutEffect:be.useEffect;function e8(n){const e=be.useRef(n);return G0(()=>void(e.current=n),[n]),e}function tZ(){const n=Q6(),e=Jj();return be.useMemo(()=>({children:t})=>{const a=!!Qb(n,!0,r=>r.type===be.StrictMode)?be.StrictMode:be.Fragment;return Nt.jsx(a,{children:Nt.jsx(e,{children:t})})},[n,e])}function nZ({set:n}){return G0(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}const iZ=(n=>(n=class extends be.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}},n.getDerivedStateFromError=()=>({error:!0}),n))();function t8(n){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(n)?Math.min(Math.max(n[0],t),n[1]):n}function hf(n){var e;return(e=n.__r3f)==null?void 0:e.root.getState()}const ai={obj:n=>n===Object(n)&&!ai.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,nul:n=>n===null,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:i="reference",strict:a=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(ai.str(n)||ai.num(n)||ai.boo(n))return n===e;const r=ai.obj(n);if(r&&i==="reference")return n===e;const s=ai.arr(n);if(s&&t==="reference")return n===e;if((s||r)&&n===e)return!0;let o;for(o in n)if(!(o in e))return!1;if(r&&t==="shallow"&&i==="shallow"){for(o in a?e:n)if(!ai.equ(n[o],e[o],{strict:a,objects:"reference"}))return!1}else for(o in a?e:n)if(n[o]!==e[o])return!1;if(ai.und(o)){if(s&&n.length===0&&e.length===0||r&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function aZ(n){const e={nodes:{},materials:{},meshes:{}};return n&&n.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material),t.isMesh&&!e.meshes[t.name]&&(e.meshes[t.name]=t)}),e}function rZ(n){n.type!=="Scene"&&(n.dispose==null||n.dispose());for(const e in n){const t=n[e];(t==null?void 0:t.type)!=="Scene"&&(t==null||t.dispose==null||t.dispose())}}const n8=["children","key","ref"];function sZ(n){const e={};for(const t in n)n8.includes(t)||(e[t]=n[t]);return e}function Bx(n,e,t,i){const a=n;let r=a==null?void 0:a.__r3f;return r||(r={root:e,type:t,parent:null,children:[],props:sZ(i),object:a,eventCount:0,handlers:{},isHidden:!1},a&&(a.__r3f=r)),r}function p0(n,e){if(!e.includes("-"))return{root:n,key:e,target:n[e]};if(e in n)return{root:n,key:e,target:n[e]};let t=n;const i=e.split("-");for(const a of i){if(typeof t!="object"||t===null){if(t!==void 0){const r=i.slice(i.indexOf(a)).join("-");return{root:t,key:r,target:void 0}}return{root:n,key:e,target:void 0}}e=a,n=t,t=t[e]}return{root:n,key:e,target:t}}const zN=/-\d+$/;function Hx(n,e){if(ai.str(e.props.attach)){if(zN.test(e.props.attach)){const a=e.props.attach.replace(zN,""),{root:r,key:s}=p0(n.object,a);Array.isArray(r[s])||(r[s]=[])}const{root:t,key:i}=p0(n.object,e.props.attach);e.previousAttach=t[i],t[i]=e.object}else ai.fun(e.props.attach)&&(e.previousAttach=e.props.attach(n.object,e.object))}function Fx(n,e){if(ai.str(e.props.attach)){const{root:t,key:i}=p0(n.object,e.props.attach),a=e.previousAttach;a===void 0?delete t[i]:t[i]=a}else e.previousAttach==null||e.previousAttach(n.object,e.object);delete e.previousAttach}const gE=[...n8,"args","dispose","attach","object","onUpdate","dispose"],BN=new Map;function oZ(n){let e=BN.get(n.constructor);try{e||(e=new n.constructor,BN.set(n.constructor,e))}catch{}return e}function lZ(n,e){const t={};for(const i in e)if(!gE.includes(i)&&!ai.equ(e[i],n.props[i])){t[i]=e[i];for(const a in e)a.startsWith(`${i}-`)&&(t[a]=e[a])}for(const i in n.props){if(gE.includes(i)||e.hasOwnProperty(i))continue;const{root:a,key:r}=p0(n.object,i);if(a.constructor&&a.constructor.length===0){const s=oZ(a);ai.und(s)||(t[r]=s[r])}else t[r]=0}return t}const cZ=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],uZ=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function kl(n,e){var t;const i=n.__r3f,a=i&&J6(i).getState(),r=i==null?void 0:i.eventCount;for(const o in e){let c=e[o];if(gE.includes(o))continue;if(i&&uZ.test(o)){typeof c=="function"?i.handlers[o]=c:delete i.handlers[o],i.eventCount=Object.keys(i.handlers).length;continue}if(c===void 0)continue;let{root:h,key:f,target:d}=p0(n,o);if(d===void 0&&(typeof h!="object"||h===null))throw Error(`R3F: Cannot set "${o}". Ensure it is an object before setting "${f}".`);if(d instanceof Md&&c instanceof Md)d.mask=c.mask;else if(d instanceof je&&eZ(c))d.set(c);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&typeof d.copy=="function"&&c!=null&&c.constructor&&d.constructor===c.constructor)d.copy(c);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&Array.isArray(c))typeof d.fromArray=="function"?d.fromArray(c):d.set(...c);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&typeof c=="number")typeof d.setScalar=="function"?d.setScalar(c):d.set(c);else{var s;h[f]=c,a&&!a.linear&&cZ.includes(f)&&(s=h[f])!=null&&s.isTexture&&h[f].format===Jn&&h[f].type===Ii&&(h[f].colorSpace=En)}}if(i!=null&&i.parent&&a!=null&&a.internal&&(t=i.object)!=null&&t.isObject3D&&r!==i.eventCount){const o=i.object,c=a.internal.interaction.indexOf(o);c>-1&&a.internal.interaction.splice(c,1),i.eventCount&&o.raycast!==null&&a.internal.interaction.push(o)}return i&&i.props.attach===void 0&&(i.object.isBufferGeometry?i.props.attach="geometry":i.object.isMaterial&&(i.props.attach="material")),i&&qd(i),n}function qd(n){var e;if(!n.parent)return;n.props.onUpdate==null||n.props.onUpdate(n.object);const t=(e=n.root)==null||e.getState==null?void 0:e.getState();t&&t.internal.frames===0&&t.invalidate()}function hZ(n,e){n.manual||($6(n)?(n.left=e.width/-2,n.right=e.width/2,n.top=e.height/2,n.bottom=e.height/-2):n.aspect=e.width/e.height,n.updateProjectionMatrix())}const wa=n=>n==null?void 0:n.isObject3D;function Iv(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function i8(n,e,t,i){const a=t.get(e);a&&(t.delete(e),t.size===0&&(n.delete(i),a.target.releasePointerCapture(i)))}function fZ(n,e){const{internal:t}=n.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,a)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(a)}),t.capturedMap.forEach((i,a)=>{i8(t.capturedMap,e,i,a)})}function dZ(n){function e(c){const{internal:h}=n.getState(),f=c.offsetX-h.initialClick[0],d=c.offsetY-h.initialClick[1];return Math.round(Math.sqrt(f*f+d*d))}function t(c){return c.filter(h=>["Move","Over","Enter","Out","Leave"].some(f=>{var d;return(d=h.__r3f)==null?void 0:d.handlers["onPointer"+f]}))}function i(c,h){const f=n.getState(),d=new Set,m=[],g=h?h(f.internal.interaction):f.internal.interaction;for(let v=0;v<g.length;v++){const y=hf(g[v]);y&&(y.raycaster.camera=void 0)}f.previousRoot||f.events.compute==null||f.events.compute(c,f);function x(v){const y=hf(v);if(!y||!y.events.enabled||y.raycaster.camera===null)return[];if(y.raycaster.camera===void 0){var E;y.events.compute==null||y.events.compute(c,y,(E=y.previousRoot)==null?void 0:E.getState()),y.raycaster.camera===void 0&&(y.raycaster.camera=null)}return y.raycaster.camera?y.raycaster.intersectObject(v,!0):[]}let T=g.flatMap(x).sort((v,y)=>{const E=hf(v.object),b=hf(y.object);return!E||!b?v.distance-y.distance:b.events.priority-E.events.priority||v.distance-y.distance}).filter(v=>{const y=Iv(v);return d.has(y)?!1:(d.add(y),!0)});f.events.filter&&(T=f.events.filter(T,f));for(const v of T){let y=v.object;for(;y;){var S;(S=y.__r3f)!=null&&S.eventCount&&m.push({...v,eventObject:y}),y=y.parent}}if("pointerId"in c&&f.internal.capturedMap.has(c.pointerId))for(let v of f.internal.capturedMap.get(c.pointerId).values())d.has(Iv(v.intersection))||m.push(v.intersection);return m}function a(c,h,f,d){if(c.length){const m={stopped:!1};for(const g of c){let x=hf(g.object);if(x||g.object.traverseAncestors(T=>{const S=hf(T);if(S)return x=S,!1}),x){const{raycaster:T,pointer:S,camera:v,internal:y}=x,E=new L(S.x,S.y,0).unproject(v),b=O=>{var R,B;return(R=(B=y.capturedMap.get(O))==null?void 0:B.has(g.eventObject))!=null?R:!1},D=O=>{const R={intersection:g,target:h.target};y.capturedMap.has(O)?y.capturedMap.get(O).set(g.eventObject,R):y.capturedMap.set(O,new Map([[g.eventObject,R]])),h.target.setPointerCapture(O)},C=O=>{const R=y.capturedMap.get(O);R&&i8(y.capturedMap,g.eventObject,R,O)};let I={};for(let O in h){let R=h[O];typeof R!="function"&&(I[O]=R)}let P={...g,...I,pointer:S,intersections:c,stopped:m.stopped,delta:f,unprojectedPoint:E,ray:T.ray,camera:v,stopPropagation(){const O="pointerId"in h&&y.capturedMap.get(h.pointerId);if((!O||O.has(g.eventObject))&&(P.stopped=m.stopped=!0,y.hovered.size&&Array.from(y.hovered.values()).find(R=>R.eventObject===g.eventObject))){const R=c.slice(0,c.indexOf(g));r([...R,g])}},target:{hasPointerCapture:b,setPointerCapture:D,releasePointerCapture:C},currentTarget:{hasPointerCapture:b,setPointerCapture:D,releasePointerCapture:C},nativeEvent:h};if(d(P),m.stopped===!0)break}}}return c}function r(c){const{internal:h}=n.getState();for(const f of h.hovered.values())if(!c.length||!c.find(d=>d.object===f.object&&d.index===f.index&&d.instanceId===f.instanceId)){const m=f.eventObject.__r3f;if(h.hovered.delete(Iv(f)),m!=null&&m.eventCount){const g=m.handlers,x={...f,intersections:c};g.onPointerOut==null||g.onPointerOut(x),g.onPointerLeave==null||g.onPointerLeave(x)}}}function s(c,h){for(let f=0;f<h.length;f++){const d=h[f].__r3f;d==null||d.handlers.onPointerMissed==null||d.handlers.onPointerMissed(c)}}function o(c){switch(c){case"onPointerLeave":case"onPointerCancel":return()=>r([]);case"onLostPointerCapture":return h=>{const{internal:f}=n.getState();"pointerId"in h&&f.capturedMap.has(h.pointerId)&&requestAnimationFrame(()=>{f.capturedMap.has(h.pointerId)&&(f.capturedMap.delete(h.pointerId),r([]))})}}return function(f){const{onPointerMissed:d,internal:m}=n.getState();m.lastEvent.current=f;const g=c==="onPointerMove",x=c==="onClick"||c==="onContextMenu"||c==="onDoubleClick",S=i(f,g?t:void 0),v=x?e(f):0;c==="onPointerDown"&&(m.initialClick=[f.offsetX,f.offsetY],m.initialHits=S.map(E=>E.eventObject)),x&&!S.length&&v<=2&&(s(f,m.interaction),d&&d(f)),g&&r(S);function y(E){const b=E.eventObject,D=b.__r3f;if(!(D!=null&&D.eventCount))return;const C=D.handlers;if(g){if(C.onPointerOver||C.onPointerEnter||C.onPointerOut||C.onPointerLeave){const I=Iv(E),P=m.hovered.get(I);P?P.stopped&&E.stopPropagation():(m.hovered.set(I,E),C.onPointerOver==null||C.onPointerOver(E),C.onPointerEnter==null||C.onPointerEnter(E))}C.onPointerMove==null||C.onPointerMove(E)}else{const I=C[c];I?(!x||m.initialHits.includes(b))&&(s(f,m.interaction.filter(P=>!m.initialHits.includes(P))),I(E)):x&&m.initialHits.includes(b)&&s(f,m.interaction.filter(P=>!m.initialHits.includes(P)))}}a(S,f,v,y)}}return{handlePointer:o}}const HN=n=>!!(n!=null&&n.render),a8=be.createContext(null),pZ=(n,e)=>{const t=Gj((o,c)=>{const h=new L,f=new L,d=new L;function m(v=c().camera,y=f,E=c().size){const{width:b,height:D,top:C,left:I}=E,P=b/D;y.isVector3?d.copy(y):d.set(...y);const O=v.getWorldPosition(h).distanceTo(d);if($6(v))return{width:b/v.zoom,height:D/v.zoom,top:C,left:I,factor:1,distance:O,aspect:P};{const R=v.fov*Math.PI/180,B=2*Math.tan(R/2)*O,j=B*(b/D);return{width:j,height:B,top:C,left:I,factor:b/j,distance:O,aspect:P}}}let g;const x=v=>o(y=>({performance:{...y.performance,current:v}})),T=new de;return{set:o,get:c,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(v=1)=>n(c(),v),advance:(v,y)=>e(v,y,c()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Yb,pointer:T,mouse:T,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const v=c();g&&clearTimeout(g),v.performance.current!==v.performance.min&&x(v.performance.min),g=setTimeout(()=>x(c().performance.max),v.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:m},setEvents:v=>o(y=>({...y,events:{...y.events,...v}})),setSize:(v,y,E=0,b=0)=>{const D=c().camera,C={width:v,height:y,top:E,left:b};o(I=>({size:C,viewport:{...I.viewport,...m(D,f,C)}}))},setDpr:v=>o(y=>{const E=t8(v);return{viewport:{...y.viewport,dpr:E,initialDpr:y.viewport.initialDpr||E}}}),setFrameloop:(v="always")=>{const y=c().clock;y.stop(),y.elapsedTime=0,v!=="never"&&(y.start(),y.elapsedTime=0),o(()=>({frameloop:v}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:be.createRef(),active:!1,frames:0,priority:0,subscribe:(v,y,E)=>{const b=c().internal;return b.priority=b.priority+(y>0?1:0),b.subscribers.push({ref:v,priority:y,store:E}),b.subscribers=b.subscribers.sort((D,C)=>D.priority-C.priority),()=>{const D=c().internal;D!=null&&D.subscribers&&(D.priority=D.priority-(y>0?1:0),D.subscribers=D.subscribers.filter(C=>C.ref!==v))}}}}}),i=t.getState();let a=i.size,r=i.viewport.dpr,s=i.camera;return t.subscribe(()=>{const{camera:o,size:c,viewport:h,gl:f,set:d}=t.getState();if(c.width!==a.width||c.height!==a.height||h.dpr!==r){a=c,r=h.dpr,hZ(o,c),h.dpr>0&&f.setPixelRatio(h.dpr);const m=typeof HTMLCanvasElement<"u"&&f.domElement instanceof HTMLCanvasElement;f.setSize(c.width,c.height,m)}o!==s&&(s=o,d(m=>({viewport:{...m.viewport,...m.viewport.getCurrentViewport(o)}})))}),t.subscribe(o=>n(o)),t};function r8(){const n=be.useContext(a8);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function Qi(n=t=>t,e){return r8()(n,e)}function Ac(n,e=0){const t=r8(),i=t.getState().internal.subscribe,a=e8(n);return G0(()=>i(a,e,t),[e,i,t]),null}const FN=new WeakMap,mZ=n=>{var e;return typeof n=="function"&&(n==null||(e=n.prototype)==null?void 0:e.constructor)===n};function s8(n,e){return function(t,...i){let a;return mZ(t)?(a=FN.get(t),a||(a=new t,FN.set(t,a))):a=t,n&&n(a),Promise.all(i.map(r=>new Promise((s,o)=>a.load(r,c=>{wa(c==null?void 0:c.scene)&&Object.assign(c,aZ(c.scene)),s(c)},e,c=>o(new Error(`Could not load ${r}: ${c==null?void 0:c.message}`))))))}}function Gx(n,e,t,i){const a=Array.isArray(e)?e:[e],r=kj(s8(t,i),[n,...a],{equal:ai.equ});return Array.isArray(e)?r:r[0]}Gx.preload=function(n,e,t){const i=Array.isArray(e)?e:[e];return Wj(s8(t),[n,...i])};Gx.clear=function(n,e){const t=Array.isArray(e)?e:[e];return Xj([n,...t])};function gZ(n){const e=jj(n);return e.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:be.version}),e}const o8=0,Nd={},vZ=/^three(?=[A-Z])/,sy=n=>`${n[0].toUpperCase()}${n.slice(1)}`;let _Z=0;const xZ=n=>typeof n=="function";function l8(n){if(xZ(n)){const e=`${_Z++}`;return Nd[e]=n,e}else Object.assign(Nd,n)}function c8(n,e){const t=sy(n),i=Nd[t];if(n!=="primitive"&&!i)throw new Error(`R3F: ${t} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(n==="primitive"&&!e.object)throw new Error("R3F: Primitives without 'object' are invalid!");if(e.args!==void 0&&!Array.isArray(e.args))throw new Error("R3F: The args prop must be an array!")}function yZ(n,e,t){var i;return n=sy(n)in Nd?n:n.replace(vZ,""),c8(n,e),n==="primitive"&&(i=e.object)!=null&&i.__r3f&&delete e.object.__r3f,Bx(e.object,t,n,e)}function SZ(n){if(!n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Fx(n.parent,n):wa(n.object)&&(n.object.visible=!1),n.isHidden=!0,qd(n)}}function u8(n){if(n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Hx(n.parent,n):wa(n.object)&&n.props.visible!==!1&&(n.object.visible=!0),n.isHidden=!1,qd(n)}}function $b(n,e,t){const i=e.root.getState();if(!(!n.parent&&n.object!==i.scene)){if(!e.object){var a,r;const s=Nd[sy(e.type)];e.object=(a=e.props.object)!=null?a:new s(...(r=e.props.args)!=null?r:[]),e.object.__r3f=e}if(kl(e.object,e.props),e.props.attach)Hx(n,e);else if(wa(e.object)&&wa(n.object)){const s=n.object.children.indexOf(t==null?void 0:t.object);if(t&&s!==-1){const o=n.object.children.indexOf(e.object);if(o!==-1){n.object.children.splice(o,1);const c=o<s?s-1:s;n.object.children.splice(c,0,e.object)}else e.object.parent=n.object,n.object.children.splice(s,0,e.object),e.object.dispatchEvent({type:"added"}),n.object.dispatchEvent({type:"childadded",child:e.object})}else n.object.add(e.object)}for(const s of e.children)$b(e,s);qd(e)}}function p2(n,e){e&&(e.parent=n,n.children.push(e),$b(n,e))}function GN(n,e,t){if(!e||!t)return;e.parent=n;const i=n.children.indexOf(t);i!==-1?n.children.splice(i,0,e):n.children.push(e),$b(n,e,t)}function h8(n){if(typeof n.dispose=="function"){const e=()=>{try{n.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():mE.unstable_scheduleCallback(mE.unstable_IdlePriority,e)}}function vE(n,e,t){if(!e)return;e.parent=null;const i=n.children.indexOf(e);i!==-1&&n.children.splice(i,1),e.props.attach?Fx(n,e):wa(e.object)&&wa(n.object)&&(n.object.remove(e.object),fZ(J6(e),e.object));const a=e.props.dispose!==null&&t!==!1;for(let r=e.children.length-1;r>=0;r--){const s=e.children[r];vE(e,s,a)}e.children.length=0,delete e.object.__r3f,a&&e.type!=="primitive"&&e.object.type!=="Scene"&&h8(e.object),t===void 0&&qd(e)}function TZ(n,e){for(const t of[n,n.alternate])if(t!==null)if(typeof t.ref=="function"){t.refCleanup==null||t.refCleanup();const i=t.ref(e);typeof i=="function"&&(t.refCleanup=i)}else t.ref&&(t.ref.current=e)}const g_=[];function EZ(){for(const[t]of g_){const i=t.parent;if(i){t.props.attach?Fx(i,t):wa(t.object)&&wa(i.object)&&i.object.remove(t.object);for(const a of t.children)a.props.attach?Fx(t,a):wa(a.object)&&wa(t.object)&&t.object.remove(a.object)}t.isHidden&&u8(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&h8(t.object)}for(const[t,i,a]of g_){t.props=i;const r=t.parent;if(r){var n,e;const s=Nd[sy(t.type)];t.object=(n=t.props.object)!=null?n:new s(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,TZ(a,t.object),kl(t.object,t.props),t.props.attach?Hx(r,t):wa(t.object)&&wa(r.object)&&r.object.add(t.object);for(const o of t.children)o.props.attach?Hx(t,o):wa(o.object)&&wa(t.object)&&t.object.add(o.object);qd(t)}}g_.length=0}const m2=()=>{},VN={};let Uv=o8;const MZ=0,bZ=4,_E=gZ({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:yZ,removeChild:vE,appendChild:p2,appendInitialChild:p2,insertBefore:GN,appendChildToContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||p2(t,e)},removeChildFromContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||vE(t,e)},insertInContainerBefore(n,e,t){const i=n.getState().scene.__r3f;!e||!t||!i||GN(i,e,t)},getRootHostContext:()=>VN,getChildHostContext:()=>VN,commitUpdate(n,e,t,i,a){var r,s,o;c8(e,i);let c=!1;if((n.type==="primitive"&&t.object!==i.object||((r=i.args)==null?void 0:r.length)!==((s=t.args)==null?void 0:s.length)||(o=i.args)!=null&&o.some((f,d)=>{var m;return f!==((m=t.args)==null?void 0:m[d])}))&&(c=!0),c)g_.push([n,{...i},a]);else{const f=lZ(n,i);Object.keys(f).length&&(Object.assign(n.props,f),kl(n.object,f))}(a.sibling===null||(a.flags&bZ)===MZ)&&EZ()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:n=>n==null?void 0:n.object,prepareForCommit:()=>null,preparePortalMount:n=>Bx(n.getState().scene,n,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:SZ,unhideInstance:u8,createTextInstance:m2,hideTextInstance:m2,unhideTextInstance:m2,scheduleTimeout:typeof setTimeout=="function"?setTimeout:void 0,cancelTimeout:typeof clearTimeout=="function"?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:be.createContext(null),setCurrentUpdatePriority(n){Uv=n},getCurrentUpdatePriority(){return Uv},resolveUpdatePriority(){var n;if(Uv!==o8)return Uv;switch(typeof window<"u"&&((n=window.event)==null?void 0:n.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return f_.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return f_.ContinuousEventPriority;default:return f_.DefaultEventPriority}},resetFormInstance(){}}),Qu=new Map,ff={objects:"shallow",strict:!1};function AZ(n,e){if(!e&&typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:t,height:i,top:a,left:r}=n.parentElement.getBoundingClientRect();return{width:t,height:i,top:a,left:r}}else if(!e&&typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...e}}function RZ(n){const e=Qu.get(n),t=e==null?void 0:e.fiber,i=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const a=typeof reportError=="function"?reportError:console.error,r=i||pZ(SE,WN),s=t||_E.createContainer(r,f_.ConcurrentRoot,null,!1,null,"",a,a,a,null);e||Qu.set(n,{fiber:s,store:r});let o,c,h=!1,f=null;return{async configure(d={}){let m;f=new Promise(Ce=>m=Ce);let{gl:g,size:x,scene:T,events:S,onCreated:v,shadows:y=!1,linear:E=!1,flat:b=!1,legacy:D=!1,orthographic:C=!1,frameloop:I="always",dpr:P=[1,2],performance:O,raycaster:R,camera:B,onPointerMissed:j}=d,ee=r.getState(),se=ee.gl;if(!ee.gl){const Ce={canvas:n,powerPreference:"high-performance",antialias:!0,alpha:!0},Xe=typeof g=="function"?await g(Ce):g;HN(Xe)?se=Xe:se=new Kb({...Ce,...g}),ee.set({gl:se})}let re=ee.raycaster;re||ee.set({raycaster:re=new N6});const{params:W,...te}=R||{};if(ai.equ(te,re,ff)||kl(re,{...te}),ai.equ(W,re.params,ff)||kl(re,{params:{...re.params,...W}}),!ee.camera||ee.camera===c&&!ai.equ(c,B,ff)){c=B;const Ce=B==null?void 0:B.isCamera,Xe=Ce?B:C?new io(0,0,0,0,.1,1e3):new ui(75,0,.1,1e3);Ce||(Xe.position.z=5,B&&(kl(Xe,B),Xe.manual||("aspect"in B||"left"in B||"right"in B||"bottom"in B||"top"in B)&&(Xe.manual=!0,Xe.updateProjectionMatrix())),!ee.camera&&!(B!=null&&B.rotation)&&Xe.lookAt(0,0,0)),ee.set({camera:Xe}),re.camera=Xe}if(!ee.scene){let Ce;T!=null&&T.isScene?(Ce=T,Bx(Ce,r,"",{})):(Ce=new Ad,Bx(Ce,r,"",{}),T&&kl(Ce,T)),ee.set({scene:Ce})}S&&!ee.events.handlers&&ee.set({events:S(r)});const K=AZ(n,x);if(ai.equ(K,ee.size,ff)||ee.setSize(K.width,K.height,K.top,K.left),P&&ee.viewport.dpr!==t8(P)&&ee.setDpr(P),ee.frameloop!==I&&ee.setFrameloop(I),ee.onPointerMissed||ee.set({onPointerMissed:j}),O&&!ai.equ(O,ee.performance,ff)&&ee.set(Ce=>({performance:{...Ce.performance,...O}})),!ee.xr){var oe;const Ce=(tt,gt)=>{const ge=r.getState();ge.frameloop!=="never"&&WN(tt,!0,ge,gt)},Xe=()=>{const tt=r.getState();tt.gl.xr.enabled=tt.gl.xr.isPresenting,tt.gl.xr.setAnimationLoop(tt.gl.xr.isPresenting?Ce:null),tt.gl.xr.isPresenting||SE(tt)},nt={connect(){const tt=r.getState().gl;tt.xr.addEventListener("sessionstart",Xe),tt.xr.addEventListener("sessionend",Xe)},disconnect(){const tt=r.getState().gl;tt.xr.removeEventListener("sessionstart",Xe),tt.xr.removeEventListener("sessionend",Xe)}};typeof((oe=se.xr)==null?void 0:oe.addEventListener)=="function"&&nt.connect(),ee.set({xr:nt})}if(se.shadowMap){const Ce=se.shadowMap.enabled,Xe=se.shadowMap.type;if(se.shadowMap.enabled=!!y,ai.boo(y))se.shadowMap.type=Cm;else if(ai.str(y)){var ie;const nt={basic:YI,percentage:b1,soft:Cm,variance:ys};se.shadowMap.type=(ie=nt[y])!=null?ie:Cm}else ai.obj(y)&&Object.assign(se.shadowMap,y);(Ce!==se.shadowMap.enabled||Xe!==se.shadowMap.type)&&(se.shadowMap.needsUpdate=!0)}return rn.enabled=!D,h||(se.outputColorSpace=E?Wn:En,se.toneMapping=b?ns:cb),ee.legacy!==D&&ee.set(()=>({legacy:D})),ee.linear!==E&&ee.set(()=>({linear:E})),ee.flat!==b&&ee.set(()=>({flat:b})),g&&!ai.fun(g)&&!HN(g)&&!ai.equ(g,se,ff)&&kl(se,g),o=v,h=!0,m(),this},render(d){return!h&&!f&&this.configure(),f.then(()=>{_E.updateContainer(Nt.jsx(wZ,{store:r,children:d,onCreated:o,rootElement:n}),s,null,()=>{})}),r},unmount(){f8(n)}}}function wZ({store:n,children:e,onCreated:t,rootElement:i}){return G0(()=>{const a=n.getState();a.set(r=>({internal:{...r.internal,active:!0}})),t&&t(a),n.getState().events.connected||a.events.connect==null||a.events.connect(i)},[]),Nt.jsx(a8.Provider,{value:n,children:e})}function f8(n,e){const t=Qu.get(n),i=t==null?void 0:t.fiber;if(i){const a=t==null?void 0:t.store.getState();a&&(a.internal.active=!1),_E.updateContainer(null,i,null,()=>{a&&setTimeout(()=>{try{var r,s,o,c;a.events.disconnect==null||a.events.disconnect(),(r=a.gl)==null||(s=r.renderLists)==null||s.dispose==null||s.dispose(),(o=a.gl)==null||o.forceContextLoss==null||o.forceContextLoss(),(c=a.gl)!=null&&c.xr&&a.xr.disconnect(),rZ(a.scene),Qu.delete(n)}catch{}},500)})}}const CZ=new Set,NZ=new Set,DZ=new Set;function g2(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function zm(n,e){switch(n){case"before":return g2(CZ,e);case"after":return g2(NZ,e);case"tail":return g2(DZ,e)}}let v2,_2;function xE(n,e,t){let i=e.clock.getDelta();e.frameloop==="never"&&typeof n=="number"&&(i=n-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=n),v2=e.internal.subscribers;for(let a=0;a<v2.length;a++)_2=v2[a],_2.ref.current(_2.store.getState(),i,t);return!e.internal.priority&&e.gl.render&&e.gl.render(e.scene,e.camera),e.internal.frames=Math.max(0,e.internal.frames-1),e.frameloop==="always"?1:e.internal.frames}let Vx=!1,yE=!1,x2,kN,df;function d8(n){kN=requestAnimationFrame(d8),Vx=!0,x2=0,zm("before",n),yE=!0;for(const t of Qu.values()){var e;df=t.store.getState(),df.internal.active&&(df.frameloop==="always"||df.internal.frames>0)&&!((e=df.gl.xr)!=null&&e.isPresenting)&&(x2+=xE(n,df))}if(yE=!1,zm("after",n),x2===0)return zm("tail",n),Vx=!1,cancelAnimationFrame(kN)}function SE(n,e=1){var t;if(!n)return Qu.forEach(i=>SE(i.store.getState(),e));(t=n.gl.xr)!=null&&t.isPresenting||!n.internal.active||n.frameloop==="never"||(e>1?n.internal.frames=Math.min(60,n.internal.frames+e):yE?n.internal.frames=2:n.internal.frames=1,Vx||(Vx=!0,requestAnimationFrame(d8)))}function WN(n,e=!0,t,i){if(e&&zm("before",n),t)xE(n,t,i);else for(const a of Qu.values())xE(n,a.store.getState());e&&zm("after",n)}const y2={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function OZ(n){const{handlePointer:e}=dZ(n);return{priority:1,enabled:!0,compute(t,i,a){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(y2).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:a}=n.getState();(t=a.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(a.lastEvent.current)},connect:t=>{const{set:i,events:a}=n.getState();if(a.disconnect==null||a.disconnect(),i(r=>({events:{...r.events,connected:t}})),a.handlers)for(const r in a.handlers){const s=a.handlers[r],[o,c]=y2[r];t.addEventListener(o,s,{passive:c})}},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){if(i.handlers)for(const a in i.handlers){const r=i.handlers[a],[s]=y2[a];i.connected.removeEventListener(s,r)}t(a=>({events:{...a.events,connected:void 0}}))}}}}function XN(n,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...i),e)}}function LZ({debounce:n,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const a=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[r,s]=be.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),o=be.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:r,orientationHandler:null}),c=n?typeof n=="number"?n:n.scroll:null,h=n?typeof n=="number"?n:n.resize:null,f=be.useRef(!1);be.useEffect(()=>(f.current=!0,()=>void(f.current=!1)));const[d,m,g]=be.useMemo(()=>{const v=()=>{if(!o.current.element)return;const{left:y,top:E,width:b,height:D,bottom:C,right:I,x:P,y:O}=o.current.element.getBoundingClientRect(),R={left:y,top:E,width:b,height:D,bottom:C,right:I,x:P,y:O};o.current.element instanceof HTMLElement&&i&&(R.height=o.current.element.offsetHeight,R.width=o.current.element.offsetWidth),Object.freeze(R),f.current&&!zZ(o.current.lastBounds,R)&&s(o.current.lastBounds=R)};return[v,h?XN(v,h):v,c?XN(v,c):v]},[s,i,c,h]);function x(){o.current.scrollContainers&&(o.current.scrollContainers.forEach(v=>v.removeEventListener("scroll",g,!0)),o.current.scrollContainers=null),o.current.resizeObserver&&(o.current.resizeObserver.disconnect(),o.current.resizeObserver=null),o.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",o.current.orientationHandler))}function T(){o.current.element&&(o.current.resizeObserver=new a(g),o.current.resizeObserver.observe(o.current.element),e&&o.current.scrollContainers&&o.current.scrollContainers.forEach(v=>v.addEventListener("scroll",g,{capture:!0,passive:!0})),o.current.orientationHandler=()=>{g()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",o.current.orientationHandler))}const S=v=>{!v||v===o.current.element||(x(),o.current.element=v,o.current.scrollContainers=p8(v),T())};return UZ(g,!!e),IZ(m),be.useEffect(()=>{x(),T()},[e,g,m]),be.useEffect(()=>x,[]),[S,r,d]}function IZ(n){be.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function UZ(n,e){be.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function p8(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:i,overflowY:a}=window.getComputedStyle(n);return[t,i,a].some(r=>r==="auto"||r==="scroll")&&e.push(n),[...e,...p8(n.parentElement)]}const PZ=["x","y","top","bottom","left","right","width","height"],zZ=(n,e)=>PZ.every(t=>n[t]===e[t]);function BZ({ref:n,children:e,fallback:t,resize:i,style:a,gl:r,events:s=OZ,eventSource:o,eventPrefix:c,shadows:h,linear:f,flat:d,legacy:m,orthographic:g,frameloop:x,dpr:T,performance:S,raycaster:v,camera:y,scene:E,onPointerMissed:b,onCreated:D,...C}){be.useMemo(()=>l8(gj),[]);const I=tZ(),[P,O]=LZ({scroll:!0,debounce:{scroll:50,resize:0},...i}),R=be.useRef(null),B=be.useRef(null);be.useImperativeHandle(n,()=>R.current);const j=e8(b),[ee,se]=be.useState(!1),[re,W]=be.useState(!1);if(ee)throw ee;if(re)throw re;const te=be.useRef(null);G0(()=>{const oe=R.current;if(O.width>0&&O.height>0&&oe){te.current||(te.current=RZ(oe));async function ie(){await te.current.configure({gl:r,scene:E,events:s,shadows:h,linear:f,flat:d,legacy:m,orthographic:g,frameloop:x,dpr:T,performance:S,raycaster:v,camera:y,size:O,onPointerMissed:(...Ce)=>j.current==null?void 0:j.current(...Ce),onCreated:Ce=>{Ce.events.connect==null||Ce.events.connect(o?$j(o)?o.current:o:B.current),c&&Ce.setEvents({compute:(Xe,nt)=>{const tt=Xe[c+"X"],gt=Xe[c+"Y"];nt.pointer.set(tt/nt.size.width*2-1,-(gt/nt.size.height)*2+1),nt.raycaster.setFromCamera(nt.pointer,nt.camera)}}),D==null||D(Ce)}}),te.current.render(Nt.jsx(I,{children:Nt.jsx(iZ,{set:W,children:Nt.jsx(be.Suspense,{fallback:Nt.jsx(nZ,{set:se}),children:e??null})})}))}ie()}}),be.useEffect(()=>{const oe=R.current;if(oe)return()=>f8(oe)},[]);const K=o?"none":"auto";return Nt.jsx("div",{ref:B,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:K,...a},...C,children:Nt.jsx("div",{ref:P,style:{width:"100%",height:"100%"},children:Nt.jsx("canvas",{ref:R,style:{display:"block"},children:t})})})}function m8(n){return Nt.jsx(K6,{children:Nt.jsx(BZ,{...n})})}function YN(n,e){if(e===TU)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===Lx||e===mb){let t=n.getIndex();if(t===null){const s=[],o=n.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)s.push(c);n.setIndex(s),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,a=[];if(e===Lx)for(let s=1;s<=i;s++)a.push(t.getX(0)),a.push(t.getX(s)),a.push(t.getX(s+1));else for(let s=0;s<i;s++)s%2===0?(a.push(t.getX(s)),a.push(t.getX(s+1)),a.push(t.getX(s+2))):(a.push(t.getX(s+2)),a.push(t.getX(s+1)),a.push(t.getX(s)));a.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=n.clone();return r.setIndex(a),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class qN extends Ti{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new kZ(t)}),this.register(function(t){return new WZ(t)}),this.register(function(t){return new $Z(t)}),this.register(function(t){return new eK(t)}),this.register(function(t){return new tK(t)}),this.register(function(t){return new YZ(t)}),this.register(function(t){return new qZ(t)}),this.register(function(t){return new jZ(t)}),this.register(function(t){return new ZZ(t)}),this.register(function(t){return new VZ(t)}),this.register(function(t){return new KZ(t)}),this.register(function(t){return new XZ(t)}),this.register(function(t){return new JZ(t)}),this.register(function(t){return new QZ(t)}),this.register(function(t){return new FZ(t)}),this.register(function(t){return new nK(t)}),this.register(function(t){return new iK(t)})}load(e,t,i,a){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=oc.extractUrlBase(e);s=oc.resolveURL(h,this.path)}else s=oc.extractUrlBase(e);this.manager.itemStart(e);const o=function(h){a?a(h):console.error(h),r.manager.itemError(e),r.manager.itemEnd(e)},c=new ss(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{r.parse(h,s,function(f){t(f),r.manager.itemEnd(e)},o)}catch(f){o(f)}},i,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,a){let r;const s={},o={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===g8){try{s[on.KHR_BINARY_GLTF]=new aK(e)}catch(d){a&&a(d);return}r=JSON.parse(s[on.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new vK(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const d=this.pluginCallbacks[f](h);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[d.name]=d,s[d.name]=!0}if(r.extensionsUsed)for(let f=0;f<r.extensionsUsed.length;++f){const d=r.extensionsUsed[f],m=r.extensionsRequired||[];switch(d){case on.KHR_MATERIALS_UNLIT:s[d]=new GZ;break;case on.KHR_DRACO_MESH_COMPRESSION:s[d]=new rK(r,this.dracoLoader);break;case on.KHR_TEXTURE_TRANSFORM:s[d]=new sK;break;case on.KHR_MESH_QUANTIZATION:s[d]=new oK;break;default:m.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}h.setExtensions(s),h.setPlugins(o),h.parse(i,a)}parseAsync(e,t){const i=this;return new Promise(function(a,r){i.parse(e,t,a,r)})}}function HZ(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const on={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class FZ{constructor(e){this.parser=e,this.name=on.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,a=t.length;i<a;i++){const r=t[i];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let a=t.cache.get(i);if(a)return a;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const f=new je(16777215);c.color!==void 0&&f.setRGB(c.color[0],c.color[1],c.color[2],Wn);const d=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new Wb(f),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new kb(f),h.distance=d;break;case"spot":h=new Vb(f),h.distance=d,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),qs(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),a=Promise.resolve(h),t.cache.add(i,a),a}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return i._getNodeRef(t.cache,o,c)})}}class GZ{constructor(){this.name=on.KHR_MATERIALS_UNLIT}getMaterialType(){return La}extendParams(e,t,i){const a=[];e.color=new je(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Wn),e.opacity=s[3]}r.baseColorTexture!==void 0&&a.push(i.assignTexture(e,"map",r.baseColorTexture,En))}return Promise.all(a)}}class VZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class kZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(i.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(i.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const o=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new de(o,o)}return Promise.all(r)}}class WZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class XZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(i.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&r.push(i.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class YZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new je(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=a.extensions[this.name];if(s.sheenColorFactor!==void 0){const o=s.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],Wn)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(i.assignTexture(t,"sheenColorMap",s.sheenColorTexture,En)),s.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class qZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(i.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class jZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(i.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new je().setRGB(o[0],o[1],o[2],Wn),Promise.all(r)}}class ZZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class KZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(i.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new je().setRGB(o[0],o[1],o[2],Wn),s.specularColorTexture!==void 0&&r.push(i.assignTexture(t,"specularColorMap",s.specularColorTexture,En)),Promise.all(r)}}class QZ{constructor(e){this.parser=e,this.name=on.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(i.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class JZ{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:os}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(i.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class $Z{constructor(e){this.parser=e,this.name=on.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,a=i.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const r=a.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class eK{constructor(e){this.parser=e,this.name=on.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,a=i.json,r=a.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=a.images[s.source];let c=i.textureLoader;if(o.uri){const h=i.options.manager.getHandler(o.uri);h!==null&&(c=h)}return i.loadTextureImage(e,s.source,c)}}class tK{constructor(e){this.parser=e,this.name=on.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,a=i.json,r=a.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=a.images[s.source];let c=i.textureLoader;if(o.uri){const h=i.options.manager.getHandler(o.uri);h!==null&&(c=h)}return i.loadTextureImage(e,s.source,c)}}class nK{constructor(e){this.name=on.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const a=i.extensions[this.name],r=this.parser.getDependency("buffer",a.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const c=a.byteOffset||0,h=a.byteLength||0,f=a.count,d=a.byteStride,m=new Uint8Array(o,c,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(f,d,m,a.mode,a.filter).then(function(g){return g.buffer}):s.ready.then(function(){const g=new ArrayBuffer(f*d);return s.decodeGltfBuffer(new Uint8Array(g),f,d,m,a.mode,a.filter),g})})}else return null}}class iK{constructor(e){this.name=on.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const a=t.meshes[i.mesh];for(const h of a.primitives)if(h.mode!==Xr.TRIANGLES&&h.mode!==Xr.TRIANGLE_STRIP&&h.mode!==Xr.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=i.extensions[this.name].attributes,o=[],c={};for(const h in s)o.push(this.parser.getDependency("accessor",s[h]).then(f=>(c[h]=f,c[h])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(h=>{const f=h.pop(),d=f.isGroup?f.children:[f],m=h[0].count,g=[];for(const x of d){const T=new ke,S=new L,v=new Tt,y=new L(1,1,1),E=new Eb(x.geometry,x.material,m);for(let b=0;b<m;b++)c.TRANSLATION&&S.fromBufferAttribute(c.TRANSLATION,b),c.ROTATION&&v.fromBufferAttribute(c.ROTATION,b),c.SCALE&&y.fromBufferAttribute(c.SCALE,b),E.setMatrixAt(b,T.compose(S,v,y));for(const b in c)if(b==="_COLOR_0"){const D=c[b];E.instanceColor=new qu(D.array,D.itemSize,D.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&x.geometry.setAttribute(b,c[b]);Zt.prototype.copy.call(E,x),this.parser.assignFinalMaterial(E),g.push(E)}return f.isGroup?(f.clear(),f.add(...g),f):g[0]}))}}const g8="glTF",Wp=12,jN={JSON:1313821514,BIN:5130562};class aK{constructor(e){this.name=on.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Wp),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==g8)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-Wp,r=new DataView(e,Wp);let s=0;for(;s<a;){const o=r.getUint32(s,!0);s+=4;const c=r.getUint32(s,!0);if(s+=4,c===jN.JSON){const h=new Uint8Array(e,Wp+s,o);this.content=i.decode(h)}else if(c===jN.BIN){const h=Wp+s;this.body=e.slice(h,h+o)}s+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class rK{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=on.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,a=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},c={},h={};for(const f in s){const d=TE[f]||f.toLowerCase();o[d]=s[f]}for(const f in e.attributes){const d=TE[f]||f.toLowerCase();if(s[f]!==void 0){const m=i.accessors[e.attributes[f]],g=id[m.componentType];h[d]=g.name,c[d]=m.normalized===!0}}return t.getDependency("bufferView",r).then(function(f){return new Promise(function(d,m){a.decodeDracoFile(f,function(g){for(const x in g.attributes){const T=g.attributes[x],S=c[x];S!==void 0&&(T.normalized=S)}d(g)},o,h,Wn,m)})})}}class sK{constructor(){this.name=on.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class oK{constructor(){this.name=on.KHR_MESH_QUANTIZATION}}class v8 extends Xd{constructor(e,t,i,a){super(e,t,i,a)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,a=this.valueSize,r=e*a*3+a;for(let s=0;s!==a;s++)t[s]=i[r+s];return t}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=o*2,h=o*3,f=a-t,d=(i-t)/f,m=d*d,g=m*d,x=e*h,T=x-h,S=-2*g+3*m,v=g-m,y=1-S,E=v-m+d;for(let b=0;b!==o;b++){const D=s[T+b+o],C=s[T+b+c]*f,I=s[x+b+o],P=s[x+b]*f;r[b]=y*D+E*C+S*I+v*P}return r}}const lK=new Tt;class cK extends v8{interpolate_(e,t,i,a){const r=super.interpolate_(e,t,i,a);return lK.fromArray(r).normalize().toArray(r),r}}const Xr={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},id={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ZN={9728:Fn,9729:Ht,9984:R1,9985:td,9986:yu,9987:Er},KN={33071:Li,33648:vd,10497:Ta},S2={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},TE={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ol={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},uK={CUBICSPLINE:void 0,LINEAR:yd,STEP:xd},T2={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function hK(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new F0({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Cs})),n.DefaultMaterial}function su(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function qs(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function fK(n,e,t){let i=!1,a=!1,r=!1;for(let h=0,f=e.length;h<f;h++){const d=e[h];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(a=!0),d.COLOR_0!==void 0&&(r=!0),i&&a&&r)break}if(!i&&!a&&!r)return Promise.resolve(n);const s=[],o=[],c=[];for(let h=0,f=e.length;h<f;h++){const d=e[h];if(i){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):n.attributes.position;s.push(m)}if(a){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):n.attributes.normal;o.push(m)}if(r){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):n.attributes.color;c.push(m)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(c)]).then(function(h){const f=h[0],d=h[1],m=h[2];return i&&(n.morphAttributes.position=f),a&&(n.morphAttributes.normal=d),r&&(n.morphAttributes.color=m),n.morphTargetsRelative=!0,n})}function dK(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,a=t.length;i<a;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function pK(n){let e;const t=n.extensions&&n.extensions[on.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+E2(t.attributes):e=n.indices+":"+E2(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,a=n.targets.length;i<a;i++)e+=":"+E2(n.targets[i]);return e}function E2(n){let e="";const t=Object.keys(n).sort();for(let i=0,a=t.length;i<a;i++)e+=t[i]+":"+n[t[i]]+";";return e}function EE(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function mK(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const gK=new ke;class vK{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new HZ,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,a=-1,r=!1,s=-1;if(typeof navigator<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const c=o.match(/Version\/(\d+)/);a=i&&c?parseInt(c[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&a<17||r&&s<98?this.textureLoader=new Fb(this.options.manager):this.textureLoader=new M6(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ss(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,a=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(s){const o={scene:s[0][a.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:a.asset,parser:i,userData:{}};return su(r,o,a),qs(o,a),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(const c of o.scenes)c.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let a=0,r=t.length;a<r;a++){const s=t[a].joints;for(let o=0,c=s.length;o<c;o++)e[s[o]].isBone=!0}for(let a=0,r=e.length;a<r;a++){const s=e[a];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(i[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const a=i.clone(),r=(s,o)=>{const c=this.associations.get(s);c!=null&&this.associations.set(o,c);for(const[h,f]of s.children.entries())r(f,o.children[h])};return r(i,a),a.name+="_instance_"+e.uses[t]++,a}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const a=e(t[i]);if(a)return a}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let a=0;a<t.length;a++){const r=e(t[a]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let a=this.cache.get(i);if(!a){switch(e){case"scene":a=this.loadScene(t);break;case"node":a=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":a=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":a=this.loadAccessor(t);break;case"bufferView":a=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":a=this.loadBuffer(t);break;case"material":a=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":a=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":a=this.loadSkin(t);break;case"animation":a=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":a=this.loadCamera(t);break;default:if(a=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(i,a)}return a}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(a.map(function(r,s){return i.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[on.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(r,s){i.load(oc.resolveURL(t.uri,a.path),r,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const a=t.byteLength||0,r=t.byteOffset||0;return i.slice(r,r+a)})}loadAccessor(e){const t=this,i=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const s=S2[a.type],o=id[a.componentType],c=a.normalized===!0,h=new o(a.count*s);return Promise.resolve(new Ot(h,s,c))}const r=[];return a.bufferView!==void 0?r.push(this.getDependency("bufferView",a.bufferView)):r.push(null),a.sparse!==void 0&&(r.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(r).then(function(s){const o=s[0],c=S2[a.type],h=id[a.componentType],f=h.BYTES_PER_ELEMENT,d=f*c,m=a.byteOffset||0,g=a.bufferView!==void 0?i.bufferViews[a.bufferView].byteStride:void 0,x=a.normalized===!0;let T,S;if(g&&g!==d){const v=Math.floor(m/g),y="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+v+":"+a.count;let E=t.cache.get(y);E||(T=new h(o,v*g,a.count*g/f),E=new I0(T,g/f),t.cache.add(y,E)),S=new mc(E,c,m%g/f,x)}else o===null?T=new h(a.count*c):T=new h(o,m,a.count*c),S=new Ot(T,c,x);if(a.sparse!==void 0){const v=S2.SCALAR,y=id[a.sparse.indices.componentType],E=a.sparse.indices.byteOffset||0,b=a.sparse.values.byteOffset||0,D=new y(s[1],E,a.sparse.count*v),C=new h(s[2],b,a.sparse.count*c);o!==null&&(S=new Ot(S.array.slice(),S.itemSize,S.normalized)),S.normalized=!1;for(let I=0,P=D.length;I<P;I++){const O=D[I];if(S.setX(O,C[I*c]),c>=2&&S.setY(O,C[I*c+1]),c>=3&&S.setZ(O,C[I*c+2]),c>=4&&S.setW(O,C[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}S.normalized=x}return S})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,s=t.images[r];let o=this.textureLoader;if(s.uri){const c=i.manager.getHandler(s.uri);c!==null&&(o=c)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,i){const a=this,r=this.json,s=r.textures[e],o=r.images[t],c=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,i).then(function(f){f.flipY=!1,f.name=s.name||o.name||"",f.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(f.name=o.uri);const m=(r.samplers||{})[s.sampler]||{};return f.magFilter=ZN[m.magFilter]||Ht,f.minFilter=ZN[m.minFilter]||Er,f.wrapS=KN[m.wrapS]||Ta,f.wrapT=KN[m.wrapT]||Ta,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==Fn&&f.minFilter!==Ht,a.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const i=this,a=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const s=a.images[e],o=self.URL||self.webkitURL;let c=s.uri||"",h=!1;if(s.bufferView!==void 0)c=i.getDependency("bufferView",s.bufferView).then(function(d){h=!0;const m=new Blob([d],{type:s.mimeType});return c=o.createObjectURL(m),c});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(c).then(function(d){return new Promise(function(m,g){let x=m;t.isImageBitmapLoader===!0&&(x=function(T){const S=new Nn(T);S.needsUpdate=!0,m(S)}),t.load(oc.resolveURL(d,r.path),x,void 0,g)})}).then(function(d){return h===!0&&o.revokeObjectURL(c),qs(d,s),d.userData.mimeType=s.mimeType||mK(s.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),d});return this.sourceCache[e]=f,f}assignTexture(e,t,i,a){const r=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(s=s.clone(),s.channel=i.texCoord),r.extensions[on.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[on.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=r.associations.get(s);s=r.extensions[on.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,c)}}return a!==void 0&&(s.colorSpace=a),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const a=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let c=this.cache.get(o);c||(c=new G1,qn.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(o,c)),i=c}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let c=this.cache.get(o);c||(c=new Pi,qn.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(o,c)),i=c}if(a||r||s){let o="ClonedMaterial:"+i.uuid+":";a&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),s&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=i.clone(),r&&(c.vertexColors=!0),s&&(c.flatShading=!0),a&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return F0}loadMaterial(e){const t=this,i=this.json,a=this.extensions,r=i.materials[e];let s;const o={},c=r.extensions||{},h=[];if(c[on.KHR_MATERIALS_UNLIT]){const d=a[on.KHR_MATERIALS_UNLIT];s=d.getMaterialType(),h.push(d.extendParams(o,r,t))}else{const d=r.pbrMetallicRoughness||{};if(o.color=new je(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;o.color.setRGB(m[0],m[1],m[2],Wn),o.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(o,"map",d.baseColorTexture,En)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),s=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=la);const f=r.alphaMode||T2.OPAQUE;if(f===T2.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,f===T2.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==La&&(h.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new de(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;o.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&s!==La&&(h.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==La){const d=r.emissiveFactor;o.emissive=new je().setRGB(d[0],d[1],d[2],Wn)}return r.emissiveTexture!==void 0&&s!==La&&h.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,En)),Promise.all(h).then(function(){const d=new s(o);return r.name&&(d.name=r.name),qs(d,r),t.associations.set(d,{materials:e}),r.extensions&&su(a,d,r),d})}createUniqueName(e){const t=fn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,a=this.primitiveCache;function r(o){return i[on.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return QN(c,o,t)})}const s=[];for(let o=0,c=e.length;o<c;o++){const h=e[o],f=pK(h),d=a[f];if(d)s.push(d.promise);else{let m;h.extensions&&h.extensions[on.KHR_DRACO_MESH_COMPRESSION]?m=r(h):m=QN(new wt,h,t),a[f]={primitive:h,promise:m},s.push(m)}}return Promise.all(s)}loadMesh(e){const t=this,i=this.json,a=this.extensions,r=i.meshes[e],s=r.primitives,o=[];for(let c=0,h=s.length;c<h;c++){const f=s[c].material===void 0?hK(this.cache):this.getDependency("material",s[c].material);o.push(f)}return o.push(t.loadGeometries(s)),Promise.all(o).then(function(c){const h=c.slice(0,c.length-1),f=c[c.length-1],d=[];for(let g=0,x=f.length;g<x;g++){const T=f[g],S=s[g];let v;const y=h[g];if(S.mode===Xr.TRIANGLES||S.mode===Xr.TRIANGLE_STRIP||S.mode===Xr.TRIANGLE_FAN||S.mode===void 0)v=r.isSkinnedMesh===!0?new B1(T,y):new si(T,y),v.isSkinnedMesh===!0&&v.normalizeSkinWeights(),S.mode===Xr.TRIANGLE_STRIP?v.geometry=YN(v.geometry,mb):S.mode===Xr.TRIANGLE_FAN&&(v.geometry=YN(v.geometry,Lx));else if(S.mode===Xr.LINES)v=new nr(T,y);else if(S.mode===Xr.LINE_STRIP)v=new ro(T,y);else if(S.mode===Xr.LINE_LOOP)v=new Mb(T,y);else if(S.mode===Xr.POINTS)v=new bb(T,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+S.mode);Object.keys(v.geometry.morphAttributes).length>0&&dK(v,r),v.name=t.createUniqueName(r.name||"mesh_"+e),qs(v,r),S.extensions&&su(a,v,S),t.assignFinalMaterial(v),d.push(v)}for(let g=0,x=d.length;g<x;g++)t.associations.set(d[g],{meshes:e,primitives:g});if(d.length===1)return r.extensions&&su(a,d[0],r),d[0];const m=new Ia;r.extensions&&su(a,m,r),t.associations.set(m,{meshes:e});for(let g=0,x=d.length;g<x;g++)m.add(d[g]);return m})}loadCamera(e){let t;const i=this.json.cameras[e],a=i[i.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new ui($t.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):i.type==="orthographic"&&(t=new io(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),qs(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let a=0,r=t.joints.length;a<r;a++)i.push(this._loadNodeShallow(t.joints[a]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(a){const r=a.pop(),s=a,o=[],c=[];for(let h=0,f=s.length;h<f;h++){const d=s[h];if(d){o.push(d);const m=new ke;r!==null&&m.fromArray(r.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new Ec(o,c)})}loadAnimation(e){const t=this.json,i=this,a=t.animations[e],r=a.name?a.name:"animation_"+e,s=[],o=[],c=[],h=[],f=[];for(let d=0,m=a.channels.length;d<m;d++){const g=a.channels[d],x=a.samplers[g.sampler],T=g.target,S=T.node,v=a.parameters!==void 0?a.parameters[x.input]:x.input,y=a.parameters!==void 0?a.parameters[x.output]:x.output;T.node!==void 0&&(s.push(this.getDependency("node",S)),o.push(this.getDependency("accessor",v)),c.push(this.getDependency("accessor",y)),h.push(x),f.push(T))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(c),Promise.all(h),Promise.all(f)]).then(function(d){const m=d[0],g=d[1],x=d[2],T=d[3],S=d[4],v=[];for(let E=0,b=m.length;E<b;E++){const D=m[E],C=g[E],I=x[E],P=T[E],O=S[E];if(D===void 0)continue;D.updateMatrix&&D.updateMatrix();const R=i._createAnimationTracks(D,C,I,P,O);if(R)for(let B=0;B<R.length;B++)v.push(R[B])}const y=new Ku(r,void 0,v);return qs(y,a),y})}createNodeMesh(e){const t=this.json,i=this,a=t.nodes[e];return a.mesh===void 0?null:i.getDependency("mesh",a.mesh).then(function(r){const s=i._getNodeRef(i.meshCache,a.mesh,r);return a.weights!==void 0&&s.traverse(function(o){if(o.isMesh)for(let c=0,h=a.weights.length;c<h;c++)o.morphTargetInfluences[c]=a.weights[c]}),s})}loadNode(e){const t=this.json,i=this,a=t.nodes[e],r=i._loadNodeShallow(e),s=[],o=a.children||[];for(let h=0,f=o.length;h<f;h++)s.push(i.getDependency("node",o[h]));const c=a.skin===void 0?Promise.resolve(null):i.getDependency("skin",a.skin);return Promise.all([r,Promise.all(s),c]).then(function(h){const f=h[0],d=h[1],m=h[2];m!==null&&f.traverse(function(g){g.isSkinnedMesh&&g.bind(m,gK)});for(let g=0,x=d.length;g<x;g++)f.add(d[g]);return f})}_loadNodeShallow(e){const t=this.json,i=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],s=r.name?a.createUniqueName(r.name):"",o=[],c=a._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&o.push(c),r.camera!==void 0&&o.push(a.getDependency("camera",r.camera).then(function(h){return a._getNodeRef(a.cameraCache,r.camera,h)})),a._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){o.push(h)}),this.nodeCache[e]=Promise.all(o).then(function(h){let f;if(r.isBone===!0?f=new H1:h.length>1?f=new Ia:h.length===1?f=h[0]:f=new Zt,f!==h[0])for(let d=0,m=h.length;d<m;d++)f.add(h[d]);if(r.name&&(f.userData.name=r.name,f.name=s),qs(f,r),r.extensions&&su(i,f,r),r.matrix!==void 0){const d=new ke;d.fromArray(r.matrix),f.applyMatrix4(d)}else r.translation!==void 0&&f.position.fromArray(r.translation),r.rotation!==void 0&&f.quaternion.fromArray(r.rotation),r.scale!==void 0&&f.scale.fromArray(r.scale);if(!a.associations.has(f))a.associations.set(f,{});else if(r.mesh!==void 0&&a.meshCache.refs[r.mesh]>1){const d=a.associations.get(f);a.associations.set(f,{...d})}return a.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],a=this,r=new Ia;i.name&&(r.name=a.createUniqueName(i.name)),qs(r,i),i.extensions&&su(t,r,i);const s=i.nodes||[],o=[];for(let c=0,h=s.length;c<h;c++)o.push(a.getDependency("node",s[c]));return Promise.all(o).then(function(c){for(let f=0,d=c.length;f<d;f++)r.add(c[f]);const h=f=>{const d=new Map;for(const[m,g]of a.associations)(m instanceof qn||m instanceof Nn)&&d.set(m,g);return f.traverse(m=>{const g=a.associations.get(m);g!=null&&d.set(m,g)}),d};return a.associations=h(r),r})}_createAnimationTracks(e,t,i,a,r){const s=[],o=e.name?e.name:e.uuid,c=[];Ol[r.path]===Ol.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(o);let h;switch(Ol[r.path]){case Ol.weights:h=gc;break;case Ol.rotation:h=vc;break;case Ol.translation:case Ol.scale:h=Zu;break;default:switch(i.itemSize){case 1:h=gc;break;case 2:case 3:default:h=Zu;break}break}const f=a.interpolation!==void 0?uK[a.interpolation]:yd,d=this._getArrayFromAccessor(i);for(let m=0,g=c.length;m<g;m++){const x=new h(c[m]+"."+Ol[r.path],t.array,d,f);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),s.push(x)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=EE(t.constructor),a=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)a[r]=t[r]*i;t=a}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const a=this instanceof vc?cK:v8;return new a(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function _K(n,e,t){const i=e.attributes,a=new ea;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],c=o.min,h=o.max;if(c!==void 0&&h!==void 0){if(a.set(new L(c[0],c[1],c[2]),new L(h[0],h[1],h[2])),o.normalized){const f=EE(id[o.componentType]);a.min.multiplyScalar(f),a.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new L,c=new L;for(let h=0,f=r.length;h<f;h++){const d=r[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],g=m.min,x=m.max;if(g!==void 0&&x!==void 0){if(c.setX(Math.max(Math.abs(g[0]),Math.abs(x[0]))),c.setY(Math.max(Math.abs(g[1]),Math.abs(x[1]))),c.setZ(Math.max(Math.abs(g[2]),Math.abs(x[2]))),m.normalized){const T=EE(id[m.componentType]);c.multiplyScalar(T)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(o)}n.boundingBox=a;const s=new ta;a.getCenter(s.center),s.radius=a.min.distanceTo(a.max)/2,n.boundingSphere=s}function QN(n,e,t){const i=e.attributes,a=[];function r(s,o){return t.getDependency("accessor",s).then(function(c){n.setAttribute(o,c)})}for(const s in i){const o=TE[s]||s.toLowerCase();o in n.attributes||a.push(r(i[s],o))}if(e.indices!==void 0&&!n.index){const s=t.getDependency("accessor",e.indices).then(function(o){n.setIndex(o)});a.push(s)}return rn.workingColorSpace!==Wn&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${rn.workingColorSpace}" not supported.`),qs(n,e),_K(n,e,t),Promise.all(a).then(function(){return e.targets!==void 0?fK(n,e.targets,t):n})}/*!
* @pixiv/three-vrm v3.4.4
* VRM file loader for three.js.
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*/var Pv=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())}),vn=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())}),JN=class extends Zt{constructor(n){super(),this.weight=0,this.isBinary=!1,this.overrideBlink="none",this.overrideLookAt="none",this.overrideMouth="none",this._binds=[],this.name=`VRMExpression_${n}`,this.expressionName=n,this.type="VRMExpression",this.visible=!1}get binds(){return this._binds}get overrideBlinkAmount(){return this.overrideBlink==="block"?0<this.outputWeight?1:0:this.overrideBlink==="blend"?this.outputWeight:0}get overrideLookAtAmount(){return this.overrideLookAt==="block"?0<this.outputWeight?1:0:this.overrideLookAt==="blend"?this.outputWeight:0}get overrideMouthAmount(){return this.overrideMouth==="block"?0<this.outputWeight?1:0:this.overrideMouth==="blend"?this.outputWeight:0}get outputWeight(){return this.isBinary?this.weight>.5?1:0:this.weight}addBind(n){this._binds.push(n)}deleteBind(n){const e=this._binds.indexOf(n);e>=0&&this._binds.splice(e,1)}applyWeight(n){var e;let t=this.outputWeight;t*=(e=n==null?void 0:n.multiplier)!=null?e:1,this.isBinary&&t<1&&(t=0),this._binds.forEach(i=>i.applyWeight(t))}clearAppliedWeight(){this._binds.forEach(n=>n.clearAppliedWeight())}};function _8(n,e,t){var i,a;const r=n.parser.json,s=(i=r.nodes)==null?void 0:i[e];if(s==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${e}] of glTF but the node doesn't exist`),null;const o=s.mesh;if(o==null)return null;const c=(a=r.meshes)==null?void 0:a[o];if(c==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${o}] of glTF but the mesh doesn't exist`),null;const h=c.primitives.length,f=[];return t.traverse(d=>{f.length<h&&d.isMesh&&f.push(d)}),f}function $N(n,e){return vn(this,null,function*(){const t=yield n.parser.getDependency("node",e);return _8(n,e,t)})}function eD(n){return vn(this,null,function*(){const e=yield n.parser.getDependencies("node"),t=new Map;return e.forEach((i,a)=>{const r=_8(n,a,i);r!=null&&t.set(a,r)}),t})}var ME={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};function x8(n){return Math.max(Math.min(n,1),0)}var tD=class y8{constructor(){this.blinkExpressionNames=["blink","blinkLeft","blinkRight"],this.lookAtExpressionNames=["lookLeft","lookRight","lookUp","lookDown"],this.mouthExpressionNames=["aa","ee","ih","oh","ou"],this._expressions=[],this._expressionMap={}}get expressions(){return this._expressions.concat()}get expressionMap(){return Object.assign({},this._expressionMap)}get presetExpressionMap(){const e={},t=new Set(Object.values(ME));return Object.entries(this._expressionMap).forEach(([i,a])=>{t.has(i)&&(e[i]=a)}),e}get customExpressionMap(){const e={},t=new Set(Object.values(ME));return Object.entries(this._expressionMap).forEach(([i,a])=>{t.has(i)||(e[i]=a)}),e}copy(e){return this._expressions.concat().forEach(i=>{this.unregisterExpression(i)}),e._expressions.forEach(i=>{this.registerExpression(i)}),this.blinkExpressionNames=e.blinkExpressionNames.concat(),this.lookAtExpressionNames=e.lookAtExpressionNames.concat(),this.mouthExpressionNames=e.mouthExpressionNames.concat(),this}clone(){return new y8().copy(this)}getExpression(e){var t;return(t=this._expressionMap[e])!=null?t:null}registerExpression(e){this._expressions.push(e),this._expressionMap[e.expressionName]=e}unregisterExpression(e){const t=this._expressions.indexOf(e);t===-1&&console.warn("VRMExpressionManager: The specified expressions is not registered"),this._expressions.splice(t,1),delete this._expressionMap[e.expressionName]}getValue(e){var t;const i=this.getExpression(e);return(t=i==null?void 0:i.weight)!=null?t:null}setValue(e,t){const i=this.getExpression(e);i&&(i.weight=x8(t))}resetValues(){this._expressions.forEach(e=>{e.weight=0})}getExpressionTrackName(e){const t=this.getExpression(e);return t?`${t.name}.weight`:null}update(){const e=this._calculateWeightMultipliers();this._expressions.forEach(t=>{t.clearAppliedWeight()}),this._expressions.forEach(t=>{let i=1;const a=t.expressionName;this.blinkExpressionNames.indexOf(a)!==-1&&(i*=e.blink),this.lookAtExpressionNames.indexOf(a)!==-1&&(i*=e.lookAt),this.mouthExpressionNames.indexOf(a)!==-1&&(i*=e.mouth),t.applyWeight({multiplier:i})})}_calculateWeightMultipliers(){let e=1,t=1,i=1;return this._expressions.forEach(a=>{e-=a.overrideBlinkAmount,t-=a.overrideLookAtAmount,i-=a.overrideMouthAmount}),e=Math.max(0,e),t=Math.max(0,t),i=Math.max(0,i),{blink:e,lookAt:t,mouth:i}}},Xp={Color:"color",EmissionColor:"emissionColor",ShadeColor:"shadeColor",RimColor:"rimColor",OutlineColor:"outlineColor"},xK={_Color:Xp.Color,_EmissionColor:Xp.EmissionColor,_ShadeColor:Xp.ShadeColor,_RimColor:Xp.RimColor,_OutlineColor:Xp.OutlineColor},yK=new je,S8=class T8{constructor({material:e,type:t,targetValue:i,targetAlpha:a}){this.material=e,this.type=t,this.targetValue=i,this.targetAlpha=a??1;const r=this._initColorBindState(),s=this._initAlphaBindState();this._state={color:r,alpha:s}}applyWeight(e){const{color:t,alpha:i}=this._state;if(t!=null){const{propertyName:a,deltaValue:r}=t,s=this.material[a];s!=null&&s.add(yK.copy(r).multiplyScalar(e))}if(i!=null){const{propertyName:a,deltaValue:r}=i;this.material[a]!=null&&(this.material[a]+=r*e)}}clearAppliedWeight(){const{color:e,alpha:t}=this._state;if(e!=null){const{propertyName:i,initialValue:a}=e,r=this.material[i];r!=null&&r.copy(a)}if(t!=null){const{propertyName:i,initialValue:a}=t;this.material[i]!=null&&(this.material[i]=a)}}_initColorBindState(){var e,t,i;const{material:a,type:r,targetValue:s}=this,o=this._getPropertyNameMap(),c=(t=(e=o==null?void 0:o[r])==null?void 0:e[0])!=null?t:null;if(c==null)return console.warn(`Tried to add a material color bind to the material ${(i=a.name)!=null?i:"(no name)"}, the type ${r} but the material or the type is not supported.`),null;const f=a[c].clone(),d=new je(s.r-f.r,s.g-f.g,s.b-f.b);return{propertyName:c,initialValue:f,deltaValue:d}}_initAlphaBindState(){var e,t,i;const{material:a,type:r,targetAlpha:s}=this,o=this._getPropertyNameMap(),c=(t=(e=o==null?void 0:o[r])==null?void 0:e[1])!=null?t:null;if(c==null&&s!==1)return console.warn(`Tried to add a material alpha bind to the material ${(i=a.name)!=null?i:"(no name)"}, the type ${r} but the material or the type does not support alpha.`),null;if(c==null)return null;const h=a[c],f=s-h;return{propertyName:c,initialValue:h,deltaValue:f}}_getPropertyNameMap(){var e,t;return(t=(e=Object.entries(T8._propertyNameMapMap).find(([i])=>this.material[i]===!0))==null?void 0:e[1])!=null?t:null}};S8._propertyNameMapMap={isMeshStandardMaterial:{color:["color","opacity"],emissionColor:["emissive",null]},isMeshBasicMaterial:{color:["color","opacity"]},isMToonMaterial:{color:["color","opacity"],emissionColor:["emissive",null],outlineColor:["outlineColorFactor",null],matcapColor:["matcapFactor",null],rimColor:["parametricRimColorFactor",null],shadeColor:["shadeColorFactor",null]}};var nD=S8,kx=class{constructor({primitives:n,index:e,weight:t}){this.primitives=n,this.index=e,this.weight=t}applyWeight(n){this.primitives.forEach(e=>{var t;((t=e.morphTargetInfluences)==null?void 0:t[this.index])!=null&&(e.morphTargetInfluences[this.index]+=this.weight*n)})}clearAppliedWeight(){this.primitives.forEach(n=>{var e;((e=n.morphTargetInfluences)==null?void 0:e[this.index])!=null&&(n.morphTargetInfluences[this.index]=0)})}},iD=new de,E8=class M8{constructor({material:e,scale:t,offset:i}){var a,r;this.material=e,this.scale=t,this.offset=i;const s=(a=Object.entries(M8._propertyNamesMap).find(([o])=>e[o]===!0))==null?void 0:a[1];s==null?(console.warn(`Tried to add a texture transform bind to the material ${(r=e.name)!=null?r:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],s.forEach(o=>{var c;const h=(c=e[o])==null?void 0:c.clone();if(!h)return null;e[o]=h;const f=h.offset.clone(),d=h.repeat.clone(),m=i.clone().sub(f),g=t.clone().sub(d);this._properties.push({name:o,initialOffset:f,deltaOffset:m,initialScale:d,deltaScale:g})}))}applyWeight(e){this._properties.forEach(t=>{const i=this.material[t.name];i!==void 0&&(i.offset.add(iD.copy(t.deltaOffset).multiplyScalar(e)),i.repeat.add(iD.copy(t.deltaScale).multiplyScalar(e)))})}clearAppliedWeight(){this._properties.forEach(e=>{const t=this.material[e.name];t!==void 0&&(t.offset.copy(e.initialOffset),t.repeat.copy(e.initialScale))})}};E8._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var aD=E8,SK=new Set(["1.0","1.0-beta"]),b8=class A8{get name(){return"VRMExpressionLoaderPlugin"}constructor(e){this.parser=e}afterRoot(e){return vn(this,null,function*(){e.userData.vrmExpressionManager=yield this._import(e)})}_import(e){return vn(this,null,function*(){const t=yield this._v1Import(e);if(t)return t;const i=yield this._v0Import(e);return i||null})}_v1Import(e){return vn(this,null,function*(){var t,i;const a=this.parser.json;if(!(((t=a.extensionsUsed)==null?void 0:t.indexOf("VRMC_vrm"))!==-1))return null;const s=(i=a.extensions)==null?void 0:i.VRMC_vrm;if(!s)return null;const o=s.specVersion;if(!SK.has(o))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const c=s.expressions;if(!c)return null;const h=new Set(Object.values(ME)),f=new Map;c.preset!=null&&Object.entries(c.preset).forEach(([m,g])=>{if(g!=null){if(!h.has(m)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${m}" detected. Ignoring the expression`);return}f.set(m,g)}}),c.custom!=null&&Object.entries(c.custom).forEach(([m,g])=>{if(h.has(m)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${m}". Ignoring the expression`);return}f.set(m,g)});const d=new tD;return yield Promise.all(Array.from(f.entries()).map(m=>vn(this,[m],function*([g,x]){var T,S,v,y,E,b,D;const C=new JN(g);if(e.scene.add(C),C.isBinary=(T=x.isBinary)!=null?T:!1,C.overrideBlink=(S=x.overrideBlink)!=null?S:"none",C.overrideLookAt=(v=x.overrideLookAt)!=null?v:"none",C.overrideMouth=(y=x.overrideMouth)!=null?y:"none",(E=x.morphTargetBinds)==null||E.forEach(I=>vn(this,null,function*(){var P;if(I.node===void 0||I.index===void 0)return;const O=yield $N(e,I.node),R=I.index;if(!O.every(B=>Array.isArray(B.morphTargetInfluences)&&R<B.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${x.name} attempts to index morph #${R} but not found.`);return}C.addBind(new kx({primitives:O,index:R,weight:(P=I.weight)!=null?P:1}))})),x.materialColorBinds||x.textureTransformBinds){const I=[];e.scene.traverse(P=>{const O=P.material;O&&(Array.isArray(O)?I.push(...O):I.push(O))}),(b=x.materialColorBinds)==null||b.forEach(P=>vn(this,null,function*(){I.filter(R=>{var B;const j=(B=this.parser.associations.get(R))==null?void 0:B.materials;return P.material===j}).forEach(R=>{C.addBind(new nD({material:R,type:P.type,targetValue:new je().fromArray(P.targetValue),targetAlpha:P.targetValue[3]}))})})),(D=x.textureTransformBinds)==null||D.forEach(P=>vn(this,null,function*(){I.filter(R=>{var B;const j=(B=this.parser.associations.get(R))==null?void 0:B.materials;return P.material===j}).forEach(R=>{var B,j;C.addBind(new aD({material:R,offset:new de().fromArray((B=P.offset)!=null?B:[0,0]),scale:new de().fromArray((j=P.scale)!=null?j:[1,1])}))})}))}d.registerExpression(C)}))),d})}_v0Import(e){return vn(this,null,function*(){var t;const i=this.parser.json,a=(t=i.extensions)==null?void 0:t.VRM;if(!a)return null;const r=a.blendShapeMaster;if(!r)return null;const s=new tD,o=r.blendShapeGroups;if(!o)return s;const c=new Set;return yield Promise.all(o.map(h=>vn(this,null,function*(){var f;const d=h.presetName,m=d!=null&&A8.v0v1PresetNameMap[d]||null,g=m??h.name;if(g==null){console.warn("VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression");return}if(c.has(g)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${d} has duplicated entries. Ignoring the expression`);return}c.add(g);const x=new JN(g);e.scene.add(x),x.isBinary=(f=h.isBinary)!=null?f:!1,h.binds&&h.binds.forEach(S=>vn(this,null,function*(){var v;if(S.mesh===void 0||S.index===void 0)return;const y=[];(v=i.nodes)==null||v.forEach((b,D)=>{b.mesh===S.mesh&&y.push(D)});const E=S.index;yield Promise.all(y.map(b=>vn(this,null,function*(){var D;const C=yield $N(e,b);if(!C.every(I=>Array.isArray(I.morphTargetInfluences)&&E<I.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${h.name} attempts to index ${E}th morph but not found.`);return}x.addBind(new kx({primitives:C,index:E,weight:.01*((D=S.weight)!=null?D:100)}))})))}));const T=h.materialValues;T&&T.length!==0&&T.forEach(S=>{if(S.materialName===void 0||S.propertyName===void 0||S.targetValue===void 0)return;const v=[];e.scene.traverse(E=>{if(E.material){const b=E.material;Array.isArray(b)?v.push(...b.filter(D=>(D.name===S.materialName||D.name===S.materialName+" (Outline)")&&v.indexOf(D)===-1)):b.name===S.materialName&&v.indexOf(b)===-1&&v.push(b)}});const y=S.propertyName;v.forEach(E=>{if(y==="_MainTex_ST"){const D=new de(S.targetValue[0],S.targetValue[1]),C=new de(S.targetValue[2],S.targetValue[3]);C.y=1-C.y-D.y,x.addBind(new aD({material:E,scale:D,offset:C}));return}const b=xK[y];if(b){x.addBind(new nD({material:E,type:b,targetValue:new je().fromArray(S.targetValue),targetAlpha:S.targetValue[3]}));return}console.warn(y+" is not supported")})}),s.registerExpression(x)}))),s})}};b8.v0v1PresetNameMap={a:"aa",e:"ee",i:"ih",o:"oh",u:"ou",blink:"blink",joy:"happy",angry:"angry",sorrow:"sad",fun:"relaxed",lookup:"lookUp",lookdown:"lookDown",lookleft:"lookLeft",lookright:"lookRight",blink_l:"blinkLeft",blink_r:"blinkRight",neutral:"neutral"};var TK=b8,eA=class Rf{constructor(e,t){this._firstPersonOnlyLayer=Rf.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=Rf.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=e,this.meshAnnotations=t}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMFirstPerson: humanoid must be same in order to copy");return this.meshAnnotations=e.meshAnnotations.map(t=>({meshes:t.meshes.concat(),type:t.type})),this}clone(){return new Rf(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:e=Rf.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:t=Rf.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||(this._firstPersonOnlyLayer=e,this._thirdPersonOnlyLayer=t,this.meshAnnotations.forEach(i=>{i.meshes.forEach(a=>{i.type==="firstPersonOnly"?(a.layers.set(this._firstPersonOnlyLayer),a.traverse(r=>r.layers.set(this._firstPersonOnlyLayer))):i.type==="thirdPersonOnly"?(a.layers.set(this._thirdPersonOnlyLayer),a.traverse(r=>r.layers.set(this._thirdPersonOnlyLayer))):i.type==="auto"&&this._createHeadlessModel(a)})}),this._initializedLayers=!0)}_excludeTriangles(e,t,i,a){let r=0;if(t!=null&&t.length>0)for(let s=0;s<e.length;s+=3){const o=e[s],c=e[s+1],h=e[s+2],f=t[o],d=i[o];if(f[0]>0&&a.includes(d[0])||f[1]>0&&a.includes(d[1])||f[2]>0&&a.includes(d[2])||f[3]>0&&a.includes(d[3]))continue;const m=t[c],g=i[c];if(m[0]>0&&a.includes(g[0])||m[1]>0&&a.includes(g[1])||m[2]>0&&a.includes(g[2])||m[3]>0&&a.includes(g[3]))continue;const x=t[h],T=i[h];x[0]>0&&a.includes(T[0])||x[1]>0&&a.includes(T[1])||x[2]>0&&a.includes(T[2])||x[3]>0&&a.includes(T[3])||(e[r++]=o,e[r++]=c,e[r++]=h)}return r}_createErasedMesh(e,t){const i=new B1(e.geometry.clone(),e.material);i.name=`${e.name}(erase)`,i.frustumCulled=e.frustumCulled,i.layers.set(this._firstPersonOnlyLayer);const a=i.geometry,r=a.getAttribute("skinIndex"),s=r instanceof cE?[]:r.array,o=[];for(let T=0;T<s.length;T+=4)o.push([s[T],s[T+1],s[T+2],s[T+3]]);const c=a.getAttribute("skinWeight"),h=c instanceof cE?[]:c.array,f=[];for(let T=0;T<h.length;T+=4)f.push([h[T],h[T+1],h[T+2],h[T+3]]);const d=a.getIndex();if(!d)throw new Error("The geometry doesn't have an index buffer");const m=Array.from(d.array),g=this._excludeTriangles(m,f,o,t),x=[];for(let T=0;T<g;T++)x[T]=m[T];return a.setIndex(x),e.onBeforeRender&&(i.onBeforeRender=e.onBeforeRender),i.bind(new Ec(e.skeleton.bones,e.skeleton.boneInverses),new ke),i}_createHeadlessModelForSkinnedMesh(e,t){const i=[];if(t.skeleton.bones.forEach((r,s)=>{this._isEraseTarget(r)&&i.push(s)}),!i.length){t.layers.enable(this._thirdPersonOnlyLayer),t.layers.enable(this._firstPersonOnlyLayer);return}t.layers.set(this._thirdPersonOnlyLayer);const a=this._createErasedMesh(t,i);e.add(a)}_createHeadlessModel(e){if(e.type==="Group")if(e.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(e))e.traverse(t=>t.layers.set(this._thirdPersonOnlyLayer));else{const t=new Ia;t.name=`_headless_${e.name}`,t.layers.set(this._firstPersonOnlyLayer),e.parent.add(t),e.children.filter(i=>i.type==="SkinnedMesh").forEach(i=>{const a=i;this._createHeadlessModelForSkinnedMesh(t,a)})}else if(e.type==="SkinnedMesh"){const t=e;this._createHeadlessModelForSkinnedMesh(e.parent,t)}else this._isEraseTarget(e)&&(e.layers.set(this._thirdPersonOnlyLayer),e.traverse(t=>t.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(e){return e===this.humanoid.getRawBoneNode("head")?!0:e.parent?this._isEraseTarget(e.parent):!1}};eA.DEFAULT_FIRSTPERSON_ONLY_LAYER=9;eA.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var rD=eA,EK=new Set(["1.0","1.0-beta"]),MK=class{get name(){return"VRMFirstPersonLoaderPlugin"}constructor(n){this.parser=n}afterRoot(n){return vn(this,null,function*(){const e=n.userData.vrmHumanoid;if(e!==null){if(e===void 0)throw new Error("VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");n.userData.vrmFirstPerson=yield this._import(n,e)}})}_import(n,e){return vn(this,null,function*(){if(e==null)return null;const t=yield this._v1Import(n,e);if(t)return t;const i=yield this._v0Import(n,e);return i||null})}_v1Import(n,e){return vn(this,null,function*(){var t,i;const a=this.parser.json;if(!(((t=a.extensionsUsed)==null?void 0:t.indexOf("VRMC_vrm"))!==-1))return null;const s=(i=a.extensions)==null?void 0:i.VRMC_vrm;if(!s)return null;const o=s.specVersion;if(!EK.has(o))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const c=s.firstPerson,h=[],f=yield eD(n);return Array.from(f.entries()).forEach(([d,m])=>{var g,x;const T=(g=c==null?void 0:c.meshAnnotations)==null?void 0:g.find(S=>S.node===d);h.push({meshes:m,type:(x=T==null?void 0:T.type)!=null?x:"auto"})}),new rD(e,h)})}_v0Import(n,e){return vn(this,null,function*(){var t;const i=this.parser.json,a=(t=i.extensions)==null?void 0:t.VRM;if(!a)return null;const r=a.firstPerson;if(!r)return null;const s=[],o=yield eD(n);return Array.from(o.entries()).forEach(([c,h])=>{const f=i.nodes[c],d=r.meshAnnotations?r.meshAnnotations.find(m=>m.mesh===f.mesh):void 0;s.push({meshes:h,type:this._convertV0FlagToV1Type(d==null?void 0:d.firstPersonFlag)})}),new rD(e,s)})}_convertV0FlagToV1Type(n){return n==="FirstPersonOnly"?"firstPersonOnly":n==="ThirdPersonOnly"?"thirdPersonOnly":n==="Both"?"both":"auto"}},sD=new L,oD=new L,bK=new Tt,lD=class extends Ia{constructor(n){super(),this.vrmHumanoid=n,this._boneAxesMap=new Map,Object.values(n.humanBones).forEach(e=>{const t=new O6(1);t.matrixAutoUpdate=!1,t.material.depthTest=!1,t.material.depthWrite=!1,this.add(t),this._boneAxesMap.set(e,t)})}dispose(){Array.from(this._boneAxesMap.values()).forEach(n=>{n.geometry.dispose(),n.material.dispose()})}updateMatrixWorld(n){Array.from(this._boneAxesMap.entries()).forEach(([e,t])=>{e.node.updateWorldMatrix(!0,!1),e.node.matrixWorld.decompose(sD,bK,oD);const i=sD.set(.1,.1,.1).divide(oD);t.matrix.copy(e.node.matrixWorld).scale(i)}),super.updateMatrixWorld(n)}},M2=["hips","spine","chest","upperChest","neck","head","leftEye","rightEye","jaw","leftUpperLeg","leftLowerLeg","leftFoot","leftToes","rightUpperLeg","rightLowerLeg","rightFoot","rightToes","leftShoulder","leftUpperArm","leftLowerArm","leftHand","rightShoulder","rightUpperArm","rightLowerArm","rightHand","leftThumbMetacarpal","leftThumbProximal","leftThumbDistal","leftIndexProximal","leftIndexIntermediate","leftIndexDistal","leftMiddleProximal","leftMiddleIntermediate","leftMiddleDistal","leftRingProximal","leftRingIntermediate","leftRingDistal","leftLittleProximal","leftLittleIntermediate","leftLittleDistal","rightThumbMetacarpal","rightThumbProximal","rightThumbDistal","rightIndexProximal","rightIndexIntermediate","rightIndexDistal","rightMiddleProximal","rightMiddleIntermediate","rightMiddleDistal","rightRingProximal","rightRingIntermediate","rightRingDistal","rightLittleProximal","rightLittleIntermediate","rightLittleDistal"],AK={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function R8(n){return n.invert?n.invert():n.inverse(),n}var ou=new L,lu=new Tt,bE=class{constructor(n){this.humanBones=n,this.restPose=this.getAbsolutePose()}getAbsolutePose(){const n={};return Object.keys(this.humanBones).forEach(e=>{const t=e,i=this.getBoneNode(t);i&&(ou.copy(i.position),lu.copy(i.quaternion),n[t]={position:ou.toArray(),rotation:lu.toArray()})}),n}getPose(){const n={};return Object.keys(this.humanBones).forEach(e=>{const t=e,i=this.getBoneNode(t);if(!i)return;ou.set(0,0,0),lu.identity();const a=this.restPose[t];a!=null&&a.position&&ou.fromArray(a.position).negate(),a!=null&&a.rotation&&R8(lu.fromArray(a.rotation)),ou.add(i.position),lu.premultiply(i.quaternion),n[t]={position:ou.toArray(),rotation:lu.toArray()}}),n}setPose(n){Object.entries(n).forEach(([e,t])=>{const i=e,a=this.getBoneNode(i);if(!a)return;const r=this.restPose[i];r&&(t!=null&&t.position&&(a.position.fromArray(t.position),r.position&&a.position.add(ou.fromArray(r.position))),t!=null&&t.rotation&&(a.quaternion.fromArray(t.rotation),r.rotation&&a.quaternion.multiply(lu.fromArray(r.rotation))))})}resetPose(){Object.entries(this.restPose).forEach(([n,e])=>{const t=this.getBoneNode(n);t&&(e!=null&&e.position&&t.position.fromArray(e.position),e!=null&&e.rotation&&t.quaternion.fromArray(e.rotation))})}getBone(n){var e;return(e=this.humanBones[n])!=null?e:void 0}getBoneNode(n){var e,t;return(t=(e=this.humanBones[n])==null?void 0:e.node)!=null?t:null}},b2=new L,RK=new Tt,wK=new L,cD=class w8 extends bE{static _setupTransforms(e){const t=new Zt;t.name="VRMHumanoidRig";const i={},a={},r={};M2.forEach(o=>{var c;const h=e.getBoneNode(o);if(h){const f=new L,d=new Tt;h.updateWorldMatrix(!0,!1),h.matrixWorld.decompose(f,d,b2),i[o]=f,a[o]=h.quaternion.clone();const m=new Tt;(c=h.parent)==null||c.matrixWorld.decompose(b2,m,b2),r[o]=m}});const s={};return M2.forEach(o=>{var c;const h=e.getBoneNode(o);if(h){const f=i[o];let d=o,m;for(;m==null&&(d=AK[d],d!=null);)m=i[d];const g=new Zt;g.name="Normalized_"+h.name,(d?(c=s[d])==null?void 0:c.node:t).add(g),g.position.copy(f),m&&g.position.sub(m),s[o]={node:g}}}),{rigBones:s,root:t,parentWorldRotations:r,boneRotations:a}}constructor(e){const{rigBones:t,root:i,parentWorldRotations:a,boneRotations:r}=w8._setupTransforms(e);super(t),this.original=e,this.root=i,this._parentWorldRotations=a,this._boneRotations=r}update(){M2.forEach(e=>{const t=this.original.getBoneNode(e);if(t!=null){const i=this.getBoneNode(e),a=this._parentWorldRotations[e],r=RK.copy(a).invert(),s=this._boneRotations[e];if(t.quaternion.copy(i.quaternion).multiply(a).premultiply(r).multiply(s),e==="hips"){const o=i.getWorldPosition(wK);t.parent.updateWorldMatrix(!0,!1);const c=t.parent.matrixWorld,h=o.applyMatrix4(c.invert());t.position.copy(h)}}})}},uD=class C8{get restPose(){return console.warn("VRMHumanoid: restPose is deprecated. Use either rawRestPose or normalizedRestPose instead."),this.rawRestPose}get rawRestPose(){return this._rawHumanBones.restPose}get normalizedRestPose(){return this._normalizedHumanBones.restPose}get humanBones(){return this._rawHumanBones.humanBones}get rawHumanBones(){return this._rawHumanBones.humanBones}get normalizedHumanBones(){return this._normalizedHumanBones.humanBones}get normalizedHumanBonesRoot(){return this._normalizedHumanBones.root}constructor(e,t){var i;this.autoUpdateHumanBones=(i=t==null?void 0:t.autoUpdateHumanBones)!=null?i:!0,this._rawHumanBones=new bE(e),this._normalizedHumanBones=new cD(this._rawHumanBones)}copy(e){return this.autoUpdateHumanBones=e.autoUpdateHumanBones,this._rawHumanBones=new bE(e.humanBones),this._normalizedHumanBones=new cD(this._rawHumanBones),this}clone(){return new C8(this.humanBones,{autoUpdateHumanBones:this.autoUpdateHumanBones}).copy(this)}getAbsolutePose(){return console.warn("VRMHumanoid: getAbsolutePose() is deprecated. Use either getRawAbsolutePose() or getNormalizedAbsolutePose() instead."),this.getRawAbsolutePose()}getRawAbsolutePose(){return this._rawHumanBones.getAbsolutePose()}getNormalizedAbsolutePose(){return this._normalizedHumanBones.getAbsolutePose()}getPose(){return console.warn("VRMHumanoid: getPose() is deprecated. Use either getRawPose() or getNormalizedPose() instead."),this.getRawPose()}getRawPose(){return this._rawHumanBones.getPose()}getNormalizedPose(){return this._normalizedHumanBones.getPose()}setPose(e){return console.warn("VRMHumanoid: setPose() is deprecated. Use either setRawPose() or setNormalizedPose() instead."),this.setRawPose(e)}setRawPose(e){return this._rawHumanBones.setPose(e)}setNormalizedPose(e){return this._normalizedHumanBones.setPose(e)}resetPose(){return console.warn("VRMHumanoid: resetPose() is deprecated. Use either resetRawPose() or resetNormalizedPose() instead."),this.resetRawPose()}resetRawPose(){return this._rawHumanBones.resetPose()}resetNormalizedPose(){return this._normalizedHumanBones.resetPose()}getBone(e){return console.warn("VRMHumanoid: getBone() is deprecated. Use either getRawBone() or getNormalizedBone() instead."),this.getRawBone(e)}getRawBone(e){return this._rawHumanBones.getBone(e)}getNormalizedBone(e){return this._normalizedHumanBones.getBone(e)}getBoneNode(e){return console.warn("VRMHumanoid: getBoneNode() is deprecated. Use either getRawBoneNode() or getNormalizedBoneNode() instead."),this.getRawBoneNode(e)}getRawBoneNode(e){return this._rawHumanBones.getBoneNode(e)}getNormalizedBoneNode(e){return this._normalizedHumanBones.getBoneNode(e)}update(){this.autoUpdateHumanBones&&this._normalizedHumanBones.update()}},CK={Hips:"hips",Spine:"spine",Head:"head",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand"},NK=new Set(["1.0","1.0-beta"]),hD={leftThumbProximal:"leftThumbMetacarpal",leftThumbIntermediate:"leftThumbProximal",rightThumbProximal:"rightThumbMetacarpal",rightThumbIntermediate:"rightThumbProximal"},DK=class{get name(){return"VRMHumanoidLoaderPlugin"}constructor(n,e){this.parser=n,this.helperRoot=e==null?void 0:e.helperRoot,this.autoUpdateHumanBones=e==null?void 0:e.autoUpdateHumanBones}afterRoot(n){return vn(this,null,function*(){n.userData.vrmHumanoid=yield this._import(n)})}_import(n){return vn(this,null,function*(){const e=yield this._v1Import(n);if(e)return e;const t=yield this._v0Import(n);return t||null})}_v1Import(n){return vn(this,null,function*(){var e,t;const i=this.parser.json;if(!(((e=i.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;const r=(t=i.extensions)==null?void 0:t.VRMC_vrm;if(!r)return null;const s=r.specVersion;if(!NK.has(s))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${s}"`),null;const o=r.humanoid;if(!o)return null;const c=o.humanBones.leftThumbIntermediate!=null||o.humanBones.rightThumbIntermediate!=null,h={};o.humanBones!=null&&(yield Promise.all(Object.entries(o.humanBones).map(d=>vn(this,[d],function*([m,g]){let x=m;const T=g.node;if(c){const v=hD[x];v!=null&&(x=v)}const S=yield this.parser.getDependency("node",T);if(S==null){console.warn(`A glTF node bound to the humanoid bone ${x} (index = ${T}) does not exist`);return}h[x]={node:S}}))));const f=new uD(this._ensureRequiredBonesExist(h),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(n.scene.add(f.normalizedHumanBonesRoot),this.helperRoot){const d=new lD(f);this.helperRoot.add(d),d.renderOrder=this.helperRoot.renderOrder}return f})}_v0Import(n){return vn(this,null,function*(){var e;const i=(e=this.parser.json.extensions)==null?void 0:e.VRM;if(!i)return null;const a=i.humanoid;if(!a)return null;const r={};a.humanBones!=null&&(yield Promise.all(a.humanBones.map(o=>vn(this,null,function*(){const c=o.bone,h=o.node;if(c==null||h==null)return;const f=yield this.parser.getDependency("node",h);if(f==null){console.warn(`A glTF node bound to the humanoid bone ${c} (index = ${h}) does not exist`);return}const d=hD[c],m=d??c;if(r[m]!=null){console.warn(`Multiple bone entries for ${m} detected (index = ${h}), ignoring duplicated entries.`);return}r[m]={node:f}}))));const s=new uD(this._ensureRequiredBonesExist(r),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(n.scene.add(s.normalizedHumanBonesRoot),this.helperRoot){const o=new lD(s);this.helperRoot.add(o),o.renderOrder=this.helperRoot.renderOrder}return s})}_ensureRequiredBonesExist(n){const e=Object.values(CK).filter(t=>n[t]==null);if(e.length>0)throw new Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${e.join(", ")}`);return n}},fD=class extends wt{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new Ot(new Float32Array(65*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(3*63),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,n=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,n=!0),n&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let n=0;n<64;n++){const e=n/63*this._currentTheta;this._attrPos.setXYZ(n+1,this._currentRadius*Math.sin(e),0,this._currentRadius*Math.cos(e))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let n=0;n<63;n++)this._attrIndex.setXYZ(n*3,0,n+1,n+2);this._attrIndex.needsUpdate=!0}},OK=class extends wt{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new L,this._currentTail=new L,this._attrPos=new Ot(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,n=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),n=!0),n&&this._buildPosition()}_buildPosition(){for(let n=0;n<32;n++){const e=n/16*Math.PI;this._attrPos.setXYZ(n,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+n,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+n,Math.sin(e),0,Math.cos(e))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(64+n*2,32+n,32+e),this._attrIndex.setXY(128+n*2,64+n,64+e)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},zv=new Tt,dD=new Tt,Yp=new L,pD=new L,mD=Math.sqrt(2)/2,LK=new Tt(0,0,-mD,mD),IK=new L(0,1,0),UK=class extends Ia{constructor(n){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=n;{const e=new fD;e.radius=.5;const t=new La({color:65280,transparent:!0,opacity:.5,side:la,depthTest:!1,depthWrite:!1});this._meshPitch=new si(e,t),this.add(this._meshPitch)}{const e=new fD;e.radius=.5;const t=new La({color:16711680,transparent:!0,opacity:.5,side:la,depthTest:!1,depthWrite:!1});this._meshYaw=new si(e,t),this.add(this._meshYaw)}{const e=new OK;e.radius=.1;const t=new Pi({color:16777215,depthTest:!1,depthWrite:!1});this._lineTarget=new nr(e,t),this._lineTarget.frustumCulled=!1,this.add(this._lineTarget)}}dispose(){this._meshYaw.geometry.dispose(),this._meshYaw.material.dispose(),this._meshPitch.geometry.dispose(),this._meshPitch.material.dispose(),this._lineTarget.geometry.dispose(),this._lineTarget.material.dispose()}updateMatrixWorld(n){const e=$t.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=e,this._meshYaw.geometry.update();const t=$t.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=t,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition(Yp),this.vrmLookAt.getLookAtWorldQuaternion(zv),zv.multiply(this.vrmLookAt.getFaceFrontQuaternion(dD)),this._meshYaw.position.copy(Yp),this._meshYaw.quaternion.copy(zv),this._meshPitch.position.copy(Yp),this._meshPitch.quaternion.copy(zv),this._meshPitch.quaternion.multiply(dD.setFromAxisAngle(IK,e)),this._meshPitch.quaternion.multiply(LK);const{target:i,autoUpdate:a}=this.vrmLookAt;i!=null&&a&&(i.getWorldPosition(pD).sub(Yp),this._lineTarget.geometry.tail.copy(pD),this._lineTarget.geometry.update(),this._lineTarget.position.copy(Yp)),super.updateMatrixWorld(n)}},PK=new L,zK=new L;function AE(n,e){return n.matrixWorld.decompose(PK,e,zK),e}function v_(n){return[Math.atan2(-n.z,n.x),Math.atan2(n.y,Math.sqrt(n.x*n.x+n.z*n.z))]}function gD(n){const e=Math.round(n/2/Math.PI);return n-2*Math.PI*e}var vD=new L(0,0,1),BK=new L,HK=new L,FK=new L,GK=new Tt,A2=new Tt,_D=new Tt,VK=new Tt,R2=new Ui,N8=class D8{constructor(e,t){this.offsetFromHeadBone=new L,this.autoUpdate=!0,this.faceFront=new L(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new Tt)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Ui)}getEuler(e){return e.set($t.DEG2RAD*this._pitch,$t.DEG2RAD*this._yaw,0,"YXZ")}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new D8(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){const t=this.humanoid.getRawBoneNode("head");return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){const t=this.humanoid.getRawBoneNode("head");return AE(t,e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(vD)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,i]=v_(this.faceFront);return R2.set(0,.5*Math.PI+t,i,"YZX"),e.setFromEuler(R2).premultiply(VK.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(A2),this.getFaceFrontQuaternion(_D),e.copy(vD).applyQuaternion(A2).applyQuaternion(_D).applyEuler(this.getEuler(R2))}lookAt(e){const t=GK.copy(this._restHeadWorldQuaternion).multiply(R8(this.getLookAtWorldQuaternion(A2))),i=this.getLookAtWorldPosition(HK),a=FK.copy(e).sub(i).applyQuaternion(t).normalize(),[r,s]=v_(this.faceFront),[o,c]=v_(a),h=gD(o-r),f=gD(s-c);this._yaw=$t.RAD2DEG*h,this._pitch=$t.RAD2DEG*f,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(BK)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};N8.EULER_ORDER="YXZ";var kK=N8,WK=new L(0,0,1),Ws=new Tt,pf=new Tt,kr=new Ui(0,0,0,"YXZ"),__=class{constructor(n,e,t,i,a){this.humanoid=n,this.rangeMapHorizontalInner=e,this.rangeMapHorizontalOuter=t,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=a,this.faceFront=new L(0,0,1),this._restQuatLeftEye=new Tt,this._restQuatRightEye=new Tt,this._restLeftEyeParentWorldQuat=new Tt,this._restRightEyeParentWorldQuat=new Tt;const r=this.humanoid.getRawBoneNode("leftEye"),s=this.humanoid.getRawBoneNode("rightEye");r&&(this._restQuatLeftEye.copy(r.quaternion),AE(r.parent,this._restLeftEyeParentWorldQuat)),s&&(this._restQuatRightEye.copy(s.quaternion),AE(s.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(n,e){const t=this.humanoid.getRawBoneNode("leftEye"),i=this.humanoid.getRawBoneNode("rightEye"),a=this.humanoid.getNormalizedBoneNode("leftEye"),r=this.humanoid.getNormalizedBoneNode("rightEye");t&&(e<0?kr.x=-$t.DEG2RAD*this.rangeMapVerticalDown.map(-e):kr.x=$t.DEG2RAD*this.rangeMapVerticalUp.map(e),n<0?kr.y=-$t.DEG2RAD*this.rangeMapHorizontalInner.map(-n):kr.y=$t.DEG2RAD*this.rangeMapHorizontalOuter.map(n),Ws.setFromEuler(kr),this._getWorldFaceFrontQuat(pf),a.quaternion.copy(pf).multiply(Ws).multiply(pf.invert()),Ws.copy(this._restLeftEyeParentWorldQuat),t.quaternion.copy(a.quaternion).multiply(Ws).premultiply(Ws.invert()).multiply(this._restQuatLeftEye)),i&&(e<0?kr.x=-$t.DEG2RAD*this.rangeMapVerticalDown.map(-e):kr.x=$t.DEG2RAD*this.rangeMapVerticalUp.map(e),n<0?kr.y=-$t.DEG2RAD*this.rangeMapHorizontalOuter.map(-n):kr.y=$t.DEG2RAD*this.rangeMapHorizontalInner.map(n),Ws.setFromEuler(kr),this._getWorldFaceFrontQuat(pf),r.quaternion.copy(pf).multiply(Ws).multiply(pf.invert()),Ws.copy(this._restRightEyeParentWorldQuat),i.quaternion.copy(r.quaternion).multiply(Ws).premultiply(Ws.invert()).multiply(this._restQuatRightEye))}lookAt(n){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const e=$t.RAD2DEG*n.y,t=$t.RAD2DEG*n.x;this.applyYawPitch(e,t)}_getWorldFaceFrontQuat(n){if(this.faceFront.distanceToSquared(WK)<.01)return n.identity();const[e,t]=v_(this.faceFront);return kr.set(0,.5*Math.PI+e,t,"YZX"),n.setFromEuler(kr)}};__.type="bone";var RE=class{constructor(n,e,t,i,a){this.expressions=n,this.rangeMapHorizontalInner=e,this.rangeMapHorizontalOuter=t,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=a}applyYawPitch(n,e){e<0?(this.expressions.setValue("lookDown",0),this.expressions.setValue("lookUp",this.rangeMapVerticalUp.map(-e))):(this.expressions.setValue("lookUp",0),this.expressions.setValue("lookDown",this.rangeMapVerticalDown.map(e))),n<0?(this.expressions.setValue("lookLeft",0),this.expressions.setValue("lookRight",this.rangeMapHorizontalOuter.map(-n))):(this.expressions.setValue("lookRight",0),this.expressions.setValue("lookLeft",this.rangeMapHorizontalOuter.map(n)))}lookAt(n){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const e=$t.RAD2DEG*n.y,t=$t.RAD2DEG*n.x;this.applyYawPitch(e,t)}};RE.type="expression";var xD=class{constructor(n,e){this.inputMaxValue=n,this.outputScale=e}map(n){return this.outputScale*x8(n/this.inputMaxValue)}},XK=new Set(["1.0","1.0-beta"]),Bv=.01,YK=class{get name(){return"VRMLookAtLoaderPlugin"}constructor(n,e){this.parser=n,this.helperRoot=e==null?void 0:e.helperRoot}afterRoot(n){return vn(this,null,function*(){const e=n.userData.vrmHumanoid;if(e===null)return;if(e===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");const t=n.userData.vrmExpressionManager;if(t!==null){if(t===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first");n.userData.vrmLookAt=yield this._import(n,e,t)}})}_import(n,e,t){return vn(this,null,function*(){if(e==null||t==null)return null;const i=yield this._v1Import(n,e,t);if(i)return i;const a=yield this._v0Import(n,e,t);return a||null})}_v1Import(n,e,t){return vn(this,null,function*(){var i,a,r;const s=this.parser.json;if(!(((i=s.extensionsUsed)==null?void 0:i.indexOf("VRMC_vrm"))!==-1))return null;const c=(a=s.extensions)==null?void 0:a.VRMC_vrm;if(!c)return null;const h=c.specVersion;if(!XK.has(h))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${h}"`),null;const f=c.lookAt;if(!f)return null;const d=f.type==="expression"?1:10,m=this._v1ImportRangeMap(f.rangeMapHorizontalInner,d),g=this._v1ImportRangeMap(f.rangeMapHorizontalOuter,d),x=this._v1ImportRangeMap(f.rangeMapVerticalDown,d),T=this._v1ImportRangeMap(f.rangeMapVerticalUp,d);let S;f.type==="expression"?S=new RE(t,m,g,x,T):S=new __(e,m,g,x,T);const v=this._importLookAt(e,S);return v.offsetFromHeadBone.fromArray((r=f.offsetFromHeadBone)!=null?r:[0,.06,0]),v})}_v1ImportRangeMap(n,e){var t,i;let a=(t=n==null?void 0:n.inputMaxValue)!=null?t:90;const r=(i=n==null?void 0:n.outputScale)!=null?i:e;return a<Bv&&(console.warn("VRMLookAtLoaderPlugin: inputMaxValue of a range map is too small. Consider reviewing the range map!"),a=Bv),new xD(a,r)}_v0Import(n,e,t){return vn(this,null,function*(){var i,a,r,s;const c=(i=this.parser.json.extensions)==null?void 0:i.VRM;if(!c)return null;const h=c.firstPerson;if(!h)return null;const f=h.lookAtTypeName==="BlendShape"?1:10,d=this._v0ImportDegreeMap(h.lookAtHorizontalInner,f),m=this._v0ImportDegreeMap(h.lookAtHorizontalOuter,f),g=this._v0ImportDegreeMap(h.lookAtVerticalDown,f),x=this._v0ImportDegreeMap(h.lookAtVerticalUp,f);let T;h.lookAtTypeName==="BlendShape"?T=new RE(t,d,m,g,x):T=new __(e,d,m,g,x);const S=this._importLookAt(e,T);return h.firstPersonBoneOffset?S.offsetFromHeadBone.set((a=h.firstPersonBoneOffset.x)!=null?a:0,(r=h.firstPersonBoneOffset.y)!=null?r:.06,-((s=h.firstPersonBoneOffset.z)!=null?s:0)):S.offsetFromHeadBone.set(0,.06,0),S.faceFront.set(0,0,-1),T instanceof __&&T.faceFront.set(0,0,-1),S})}_v0ImportDegreeMap(n,e){var t,i;const a=n==null?void 0:n.curve;JSON.stringify(a)!=="[0,0,0,1,1,1,1,0]"&&console.warn("Curves of LookAtDegreeMap defined in VRM 0.0 are not supported");let r=(t=n==null?void 0:n.xRange)!=null?t:90;const s=(i=n==null?void 0:n.yRange)!=null?i:e;return r<Bv&&(console.warn("VRMLookAtLoaderPlugin: xRange of a degree map is too small. Consider reviewing the degree map!"),r=Bv),new xD(r,s)}_importLookAt(n,e){const t=new kK(n,e);if(this.helperRoot){const i=new UK(t);this.helperRoot.add(i),i.renderOrder=this.helperRoot.renderOrder}return t}};function qK(n,e){return typeof n!="string"||n===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(n)&&(e=e.replace(/(^https?:\/\/[^/]+).*/i,"$1")),/^(https?:)?\/\//i.test(n)||/^data:.*,.*$/i.test(n)||/^blob:.*$/i.test(n)?n:e+n)}var jK=new Set(["1.0","1.0-beta"]),ZK=class{get name(){return"VRMMetaLoaderPlugin"}constructor(n,e){var t,i,a;this.parser=n,this.needThumbnailImage=(t=e==null?void 0:e.needThumbnailImage)!=null?t:!1,this.acceptLicenseUrls=(i=e==null?void 0:e.acceptLicenseUrls)!=null?i:["https://vrm.dev/licenses/1.0/"],this.acceptV0Meta=(a=e==null?void 0:e.acceptV0Meta)!=null?a:!0}afterRoot(n){return vn(this,null,function*(){n.userData.vrmMeta=yield this._import(n)})}_import(n){return vn(this,null,function*(){const e=yield this._v1Import(n);if(e!=null)return e;const t=yield this._v0Import(n);return t??null})}_v1Import(n){return vn(this,null,function*(){var e,t,i;const a=this.parser.json;if(!(((e=a.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;const s=(t=a.extensions)==null?void 0:t.VRMC_vrm;if(s==null)return null;const o=s.specVersion;if(!jK.has(o))return console.warn(`VRMMetaLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const c=s.meta;if(!c)return null;const h=c.licenseUrl;if(!new Set(this.acceptLicenseUrls).has(h))throw new Error(`VRMMetaLoaderPlugin: The license url "${h}" is not accepted`);let d;return this.needThumbnailImage&&c.thumbnailImage!=null&&(d=(i=yield this._extractGLTFImage(c.thumbnailImage))!=null?i:void 0),{metaVersion:"1",name:c.name,version:c.version,authors:c.authors,copyrightInformation:c.copyrightInformation,contactInformation:c.contactInformation,references:c.references,thirdPartyLicenses:c.thirdPartyLicenses,thumbnailImage:d,licenseUrl:c.licenseUrl,avatarPermission:c.avatarPermission,allowExcessivelyViolentUsage:c.allowExcessivelyViolentUsage,allowExcessivelySexualUsage:c.allowExcessivelySexualUsage,commercialUsage:c.commercialUsage,allowPoliticalOrReligiousUsage:c.allowPoliticalOrReligiousUsage,allowAntisocialOrHateUsage:c.allowAntisocialOrHateUsage,creditNotation:c.creditNotation,allowRedistribution:c.allowRedistribution,modification:c.modification,otherLicenseUrl:c.otherLicenseUrl}})}_v0Import(n){return vn(this,null,function*(){var e;const i=(e=this.parser.json.extensions)==null?void 0:e.VRM;if(!i)return null;const a=i.meta;if(!a)return null;if(!this.acceptV0Meta)throw new Error("VRMMetaLoaderPlugin: Attempted to load VRM0.0 meta but acceptV0Meta is false");let r;return this.needThumbnailImage&&a.texture!=null&&a.texture!==-1&&(r=yield this.parser.getDependency("texture",a.texture)),{metaVersion:"0",allowedUserName:a.allowedUserName,author:a.author,commercialUssageName:a.commercialUssageName,contactInformation:a.contactInformation,licenseName:a.licenseName,otherLicenseUrl:a.otherLicenseUrl,otherPermissionUrl:a.otherPermissionUrl,reference:a.reference,sexualUssageName:a.sexualUssageName,texture:r??void 0,title:a.title,version:a.version,violentUssageName:a.violentUssageName}})}_extractGLTFImage(n){return vn(this,null,function*(){var e;const i=(e=this.parser.json.images)==null?void 0:e[n];if(i==null)return console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${n}] of glTF as a thumbnail but the image doesn't exist`),null;let a=i.uri;if(i.bufferView!=null){const s=yield this.parser.getDependency("bufferView",i.bufferView),o=new Blob([s],{type:i.mimeType});a=URL.createObjectURL(o)}return a==null?(console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${n}] of glTF as a thumbnail but the image couldn't load properly`),null):yield new wd().loadAsync(qK(a,this.parser.options.path)).catch(s=>(console.error(s),console.warn("VRMMetaLoaderPlugin: Failed to load a thumbnail image"),null))})}},KK=class{constructor(n){this.scene=n.scene,this.meta=n.meta,this.humanoid=n.humanoid,this.expressionManager=n.expressionManager,this.firstPerson=n.firstPerson,this.lookAt=n.lookAt}update(n){this.humanoid.update(),this.lookAt&&this.lookAt.update(n),this.expressionManager&&this.expressionManager.update()}},QK=class extends KK{constructor(n){super(n),this.materials=n.materials,this.springBoneManager=n.springBoneManager,this.nodeConstraintManager=n.nodeConstraintManager}update(n){super.update(n),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(n),this.materials&&this.materials.forEach(e=>{e.update&&e.update(n)})}},JK=Object.defineProperty,yD=Object.getOwnPropertySymbols,$K=Object.prototype.hasOwnProperty,eQ=Object.prototype.propertyIsEnumerable,SD=(n,e,t)=>e in n?JK(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,TD=(n,e)=>{for(var t in e||(e={}))$K.call(e,t)&&SD(n,t,e[t]);if(yD)for(var t of yD(e))eQ.call(e,t)&&SD(n,t,e[t]);return n},bu=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())}),tQ={"":3e3,srgb:3001};function nQ(n,e){parseInt(ws,10)>=152?n.colorSpace=e:n.encoding=tQ[e]}var iQ=class{get pending(){return Promise.all(this._pendings)}constructor(n,e){this._parser=n,this._materialParams=e,this._pendings=[]}assignPrimitive(n,e){e!=null&&(this._materialParams[n]=e)}assignColor(n,e,t){if(e!=null){const i=new je().fromArray(e);t&&i.convertSRGBToLinear(),this._materialParams[n]=i}}assignTexture(n,e,t){return bu(this,null,function*(){const i=bu(this,null,function*(){e!=null&&(yield this._parser.assignTexture(this._materialParams,n,e),t&&nQ(this._materialParams[n],"srgb"))});return this._pendings.push(i),i})}assignTextureByIndex(n,e,t){return bu(this,null,function*(){return this.assignTexture(n,e!=null?{index:e}:void 0,t)})}},aQ=`// #define PHONG
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
// #include <uv_pars_vertex>
#ifdef MTOON_USE_UV
varying vec2 vUv;
// COMPAT: pre-r151 uses a common uvTransform
#if THREE_VRM_THREE_REVISION < 151
uniform mat3 uvTransform;
#endif
#endif
// #include <uv2_pars_vertex>
// COMAPT: pre-r151 uses uv2 for lightMap and aoMap
#if THREE_VRM_THREE_REVISION < 151
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
attribute vec2 uv2;
varying vec2 vUv2;
uniform mat3 uv2Transform;
#endif
#endif
// #include <displacementmap_pars_vertex>
// #include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE
uniform sampler2D outlineWidthMultiplyTexture;
uniform mat3 outlineWidthMultiplyTextureUvTransform;
#endif
uniform float outlineWidthFactor;
void main() {
// #include <uv_vertex>
#ifdef MTOON_USE_UV
// COMPAT: pre-r151 uses a common uvTransform
#if THREE_VRM_THREE_REVISION >= 151
vUv = uv;
#else
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif
#endif
// #include <uv2_vertex>
// COMAPT: pre-r151 uses uv2 for lightMap and aoMap
#if THREE_VRM_THREE_REVISION < 151
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif
#endif
#include <color_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
// we need this to compute the outline properly
objectNormal = normalize( objectNormal );
#include <defaultnormal_vertex>
#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
vNormal = normalize( transformedNormal );
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
// #include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#ifdef OUTLINE
float worldNormalLength = length( transformedNormal );
vec3 outlineOffset = outlineWidthFactor * worldNormalLength * objectNormal;
#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE
vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy;
float outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g;
outlineOffset *= outlineTex;
#endif
#ifdef OUTLINE_WIDTH_SCREEN
outlineOffset *= vViewPosition.z / projectionMatrix[ 1 ].y;
#endif
gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 );
gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic
#endif
#include <worldpos_vertex>
// #include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,rQ=`// #define PHONG
uniform vec3 litFactor;
uniform float opacity;
uniform vec3 shadeColorFactor;
#ifdef USE_SHADEMULTIPLYTEXTURE
uniform sampler2D shadeMultiplyTexture;
uniform mat3 shadeMultiplyTextureUvTransform;
#endif
uniform float shadingShiftFactor;
uniform float shadingToonyFactor;
#ifdef USE_SHADINGSHIFTTEXTURE
uniform sampler2D shadingShiftTexture;
uniform mat3 shadingShiftTextureUvTransform;
uniform float shadingShiftTextureScale;
#endif
uniform float giEqualizationFactor;
uniform vec3 parametricRimColorFactor;
#ifdef USE_RIMMULTIPLYTEXTURE
uniform sampler2D rimMultiplyTexture;
uniform mat3 rimMultiplyTextureUvTransform;
#endif
uniform float rimLightingMixFactor;
uniform float parametricRimFresnelPowerFactor;
uniform float parametricRimLiftFactor;
#ifdef USE_MATCAPTEXTURE
uniform vec3 matcapFactor;
uniform sampler2D matcapTexture;
uniform mat3 matcapTextureUvTransform;
#endif
uniform vec3 emissive;
uniform float emissiveIntensity;
uniform vec3 outlineColorFactor;
uniform float outlineLightingMixFactor;
#ifdef USE_UVANIMATIONMASKTEXTURE
uniform sampler2D uvAnimationMaskTexture;
uniform mat3 uvAnimationMaskTextureUvTransform;
#endif
uniform float uvAnimationScrollXOffset;
uniform float uvAnimationScrollYOffset;
uniform float uvAnimationRotationPhase;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
// #include <uv_pars_fragment>
#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )
varying vec2 vUv;
#endif
// #include <uv2_pars_fragment>
// COMAPT: pre-r151 uses uv2 for lightMap and aoMap
#if THREE_VRM_THREE_REVISION < 151
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
varying vec2 vUv2;
#endif
#endif
#include <map_pars_fragment>
#ifdef USE_MAP
uniform mat3 mapUvTransform;
#endif
// #include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
// #include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#ifdef USE_EMISSIVEMAP
uniform mat3 emissiveMapUvTransform;
#endif
// #include <envmap_common_pars_fragment>
// #include <envmap_pars_fragment>
// #include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
// #include <bsdfs>
// COMPAT: pre-r151 doesn't have BRDF_Lambert in <common>
#if THREE_VRM_THREE_REVISION < 151
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
#endif
#include <lights_pars_begin>
#include <normal_pars_fragment>
// #include <lights_phong_pars_fragment>
varying vec3 vViewPosition;
struct MToonMaterial {
vec3 diffuseColor;
vec3 shadeColor;
float shadingShift;
};
float linearstep( float a, float b, float t ) {
return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 );
}
/**
* Convert NdotL into toon shading factor using shadingShift and shadingToony
*/
float getShading(
const in float dotNL,
const in float shadow,
const in float shadingShift
) {
float shading = dotNL;
shading = shading + shadingShift;
shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading );
shading *= shadow;
return shading;
}
/**
* Mix diffuseColor and shadeColor using shading factor and light color
*/
vec3 getDiffuse(
const in MToonMaterial material,
const in float shading,
in vec3 lightColor
) {
#ifdef DEBUG_LITSHADERATE
return vec3( BRDF_Lambert( shading * lightColor ) );
#endif
vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) );
// The "comment out if you want to PBR absolutely" line
#ifdef V0_COMPAT_SHADE
col = min( col, material.diffuseColor );
#endif
return col;
}
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
void RE_Direct_MToon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {
float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 );
vec3 irradiance = directLight.color;
// directSpecular will be used for rim lighting, not an actual specular
reflectedLight.directSpecular += irradiance;
irradiance *= dotNL;
float shading = getShading( dotNL, shadow, material.shadingShift );
// toon shaded diffuse
reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );
}
void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {
// indirect diffuse will use diffuseColor, no shadeColor involved
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
// directSpecular will be used for rim lighting, not an actual specular
reflectedLight.directSpecular += irradiance;
}
#else
void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {
float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 );
vec3 irradiance = directLight.color;
// directSpecular will be used for rim lighting, not an actual specular
reflectedLight.directSpecular += irradiance;
irradiance *= dotNL;
float shading = getShading( dotNL, shadow, material.shadingShift );
// toon shaded diffuse
reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );
}
void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {
// indirect diffuse will use diffuseColor, no shadeColor involved
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
// directSpecular will be used for rim lighting, not an actual specular
reflectedLight.directSpecular += irradiance;
}
#endif
#define RE_Direct RE_Direct_MToon
#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon
#define Material_LightProbeLOD( material ) (0)
#include <shadowmap_pars_fragment>
// #include <bumpmap_pars_fragment>
// #include <normalmap_pars_fragment>
#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform mat3 normalMapUvTransform;
uniform vec2 normalScale;
#endif
// COMPAT: pre-r151
// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151
#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )
uniform mat3 normalMatrix;
#endif
// COMPAT: pre-r151
// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) )
// Per-Pixel Tangent Space Normal Mapping
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
// three-vrm specific change: it requires \`uv\` as an input in order to support uv scrolls
// Temporary compat against shader change @ Three.js r126, r151
#if THREE_VRM_THREE_REVISION >= 151
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
vec3 q0 = dFdx( eye_pos.xyz );
vec3 q1 = dFdy( eye_pos.xyz );
vec2 st0 = dFdx( uv.st );
vec2 st1 = dFdy( uv.st );
vec3 N = surf_norm;
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
#else
vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
vec2 st0 = dFdx( uv.st );
vec2 st1 = dFdy( uv.st );
vec3 N = normalize( surf_norm );
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
// three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0
// TODO: Is this still required? Or shall I make a PR about it?
if ( length( T ) == 0.0 || length( B ) == 0.0 ) {
return surf_norm;
}
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
}
#endif
#endif
// #include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
// == post correction ==========================================================
void postCorrection() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
// == main procedure ===========================================================
void main() {
#include <clipping_planes_fragment>
vec2 uv = vec2(0.5, 0.5);
#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )
uv = vUv;
float uvAnimMask = 1.0;
#ifdef USE_UVANIMATIONMASKTEXTURE
vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy;
uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b;
#endif
float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask );
float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask );
uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5;
uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask;
#endif
#ifdef DEBUG_UV
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )
gl_FragColor = vec4( uv, 0.0, 1.0 );
#endif
return;
#endif
vec4 diffuseColor = vec4( litFactor, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive * emissiveIntensity;
#include <logdepthbuf_fragment>
// #include <map_fragment>
#ifdef USE_MAP
vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy;
vec4 sampledDiffuseColor = texture2D( map, mapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
#endif
diffuseColor *= sampledDiffuseColor;
#endif
// #include <color_fragment>
#if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )
diffuseColor.rgb *= vColor;
#endif
// #include <alphamap_fragment>
#include <alphatest_fragment>
// #include <specularmap_fragment>
// #include <normal_fragment_begin>
float faceDirection = gl_FrontFacing ? 1.0 : -1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#ifdef USE_NORMALMAP
vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP_TANGENTSPACE
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv );
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
// non perturbed normal for clearcoat among others
vec3 nonPerturbedNormal = normal;
#ifdef OUTLINE
normal *= -1.0;
#endif
// #include <normal_fragment_maps>
// COMPAT: pre-r151
// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151
#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )
normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
// COMPAT: pre-r151
// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151
#elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP )
vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0;
mapN.xy *= normalScale;
// COMPAT: pre-r151
#if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT )
normal = normalize( tbn * mapN );
#else
normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );
#endif
#endif
// #include <emissivemap_fragment>
#ifdef USE_EMISSIVEMAP
vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy;
totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb;
#endif
#ifdef DEBUG_NORMAL
gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 );
return;
#endif
// -- MToon: lighting --------------------------------------------------------
// accumulation
// #include <lights_phong_fragment>
MToonMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.shadeColor = shadeColorFactor;
#ifdef USE_SHADEMULTIPLYTEXTURE
vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;
material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb;
#endif
#if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )
material.shadeColor.rgb *= vColor;
#endif
material.shadingShift = shadingShiftFactor;
#ifdef USE_SHADINGSHIFTTEXTURE
vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy;
material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale;
#endif
// #include <lights_fragment_begin>
// MToon Specific changes:
// Since we want to take shadows into account of shading instead of irradiance,
// we had to modify the codes that multiplies the results of shadowmap into color of direct lights.
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal;
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#else
GeometricContext geometry;
geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
#ifdef USE_CLEARCOAT
geometry.clearcoatNormal = clearcoatNormal;
#endif
#endif
IncidentLight directLight;
// since these variables will be used in unrolled loop, we have to define in prior
float shadow;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
getPointLightInfo( pointLight, geometryPosition, directLight );
#else
getPointLightInfo( pointLight, geometry, directLight );
#endif
shadow = 1.0;
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
// COMPAT: pre-r166
// r166 introduced shadowIntensity
#if THREE_VRM_THREE_REVISION >= 166
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#else
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
#endif
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );
#else
RE_Direct( directLight, geometry, material, shadow, reflectedLight );
#endif
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
getSpotLightInfo( spotLight, geometryPosition, directLight );
#else
getSpotLightInfo( spotLight, geometry, directLight );
#endif
shadow = 1.0;
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
// COMPAT: pre-r166
// r166 introduced shadowIntensity
#if THREE_VRM_THREE_REVISION >= 166
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
#else
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
#endif
#endif
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );
#else
RE_Direct( directLight, geometry, material, shadow, reflectedLight );
#endif
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
getDirectionalLightInfo( directionalLight, directLight );
#else
getDirectionalLightInfo( directionalLight, geometry, directLight );
#endif
shadow = 1.0;
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
// COMPAT: pre-r166
// r166 introduced shadowIntensity
#if THREE_VRM_THREE_REVISION >= 166
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#else
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
#endif
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );
#else
RE_Direct( directLight, geometry, material, shadow, reflectedLight );
#endif
}
#pragma unroll_loop_end
#endif
// #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
// RectAreaLight rectAreaLight;
// #pragma unroll_loop_start
// for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
// rectAreaLight = rectAreaLights[ i ];
// RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
// }
// #pragma unroll_loop_end
// #endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
// COMPAT: pre-r156 uses a struct GeometricContext
// COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES
#if THREE_VRM_THREE_REVISION >= 157
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#else
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
#else
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
#endif
}
#pragma unroll_loop_end
#endif
#endif
// #if defined( RE_IndirectSpecular )
// vec3 radiance = vec3( 0.0 );
// vec3 clearcoatRadiance = vec3( 0.0 );
// #endif
#include <lights_fragment_maps>
#include <lights_fragment_end>
// modulation
#include <aomap_fragment>
vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
#ifdef DEBUG_LITSHADERATE
gl_FragColor = vec4( col, diffuseColor.a );
postCorrection();
return;
#endif
// -- MToon: rim lighting -----------------------------------------
vec3 viewDir = normalize( vViewPosition );
#ifndef PHYSICALLY_CORRECT_LIGHTS
reflectedLight.directSpecular /= PI;
#endif
vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, 1.0 );
vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor );
#ifdef USE_MATCAPTEXTURE
{
vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) );
vec3 y = cross( viewDir, x ); // guaranteed to be normalized
vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) );
sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy;
vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb;
rim += matcapFactor * matcap;
}
#endif
#ifdef USE_RIMMULTIPLYTEXTURE
vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;
rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb;
#endif
col += rimMix * rim;
// -- MToon: Emission --------------------------------------------------------
col += totalEmissiveRadiance;
// #include <envmap_fragment>
// -- Almost done! -----------------------------------------------------------
#if defined( OUTLINE )
col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor );
#endif
#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
gl_FragColor = vec4( col, diffuseColor.a );
postCorrection();
}
`,sQ={None:"none"},ED={None:"none",ScreenCoordinates:"screenCoordinates"},oQ={3e3:"",3001:"srgb"};function w2(n){return parseInt(ws,10)>=152?n.colorSpace:oQ[n.encoding]}var lQ=class extends Fi{constructor(n={}){var e;super({vertexShader:aQ,fragmentShader:rQ}),this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.fog=!0,this.normalMapType=ol,this._ignoreVertexColor=!0,this._v0CompatShade=!1,this._debugMode=sQ.None,this._outlineWidthMode=ED.None,this._isOutline=!1,n.transparentWithZWrite&&(n.depthWrite=!0),delete n.transparentWithZWrite,n.fog=!0,n.lights=!0,n.clipping=!0,this.uniforms=Sb.merge([at.common,at.normalmap,at.emissivemap,at.fog,at.lights,{litFactor:{value:new je(1,1,1)},mapUvTransform:{value:new Et},colorAlpha:{value:1},normalMapUvTransform:{value:new Et},shadeColorFactor:{value:new je(0,0,0)},shadeMultiplyTexture:{value:null},shadeMultiplyTextureUvTransform:{value:new Et},shadingShiftFactor:{value:0},shadingShiftTexture:{value:null},shadingShiftTextureUvTransform:{value:new Et},shadingShiftTextureScale:{value:1},shadingToonyFactor:{value:.9},giEqualizationFactor:{value:.9},matcapFactor:{value:new je(1,1,1)},matcapTexture:{value:null},matcapTextureUvTransform:{value:new Et},parametricRimColorFactor:{value:new je(0,0,0)},rimMultiplyTexture:{value:null},rimMultiplyTextureUvTransform:{value:new Et},rimLightingMixFactor:{value:1},parametricRimFresnelPowerFactor:{value:5},parametricRimLiftFactor:{value:0},emissive:{value:new je(0,0,0)},emissiveIntensity:{value:1},emissiveMapUvTransform:{value:new Et},outlineWidthMultiplyTexture:{value:null},outlineWidthMultiplyTextureUvTransform:{value:new Et},outlineWidthFactor:{value:0},outlineColorFactor:{value:new je(0,0,0)},outlineLightingMixFactor:{value:1},uvAnimationMaskTexture:{value:null},uvAnimationMaskTextureUvTransform:{value:new Et},uvAnimationScrollXOffset:{value:0},uvAnimationScrollYOffset:{value:0},uvAnimationRotationPhase:{value:0}},(e=n.uniforms)!=null?e:{}]),this.setValues(n),this._uploadUniformsWorkaround(),this.customProgramCacheKey=()=>[...Object.entries(this._generateDefines()).map(([t,i])=>`${t}:${i}`),this.matcapTexture?`matcapTextureColorSpace:${w2(this.matcapTexture)}`:"",this.shadeMultiplyTexture?`shadeMultiplyTextureColorSpace:${w2(this.shadeMultiplyTexture)}`:"",this.rimMultiplyTexture?`rimMultiplyTextureColorSpace:${w2(this.rimMultiplyTexture)}`:""].join(","),this.onBeforeCompile=t=>{const i=parseInt(ws,10),a=Object.entries(TD(TD({},this._generateDefines()),this.defines)).filter(([r,s])=>!!s).map(([r,s])=>`#define ${r} ${s}`).join(`
`)+`
`;t.vertexShader=a+t.vertexShader,t.fragmentShader=a+t.fragmentShader,i<154&&(t.fragmentShader=t.fragmentShader.replace("#include <colorspace_fragment>","#include <encodings_fragment>"))}}get color(){return this.uniforms.litFactor.value}set color(n){this.uniforms.litFactor.value=n}get map(){return this.uniforms.map.value}set map(n){this.uniforms.map.value=n}get normalMap(){return this.uniforms.normalMap.value}set normalMap(n){this.uniforms.normalMap.value=n}get normalScale(){return this.uniforms.normalScale.value}set normalScale(n){this.uniforms.normalScale.value=n}get emissive(){return this.uniforms.emissive.value}set emissive(n){this.uniforms.emissive.value=n}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(n){this.uniforms.emissiveIntensity.value=n}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(n){this.uniforms.emissiveMap.value=n}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(n){this.uniforms.shadeColorFactor.value=n}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(n){this.uniforms.shadeMultiplyTexture.value=n}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(n){this.uniforms.shadingShiftFactor.value=n}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(n){this.uniforms.shadingShiftTexture.value=n}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(n){this.uniforms.shadingShiftTextureScale.value=n}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(n){this.uniforms.shadingToonyFactor.value=n}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(n){this.uniforms.giEqualizationFactor.value=n}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(n){this.uniforms.matcapFactor.value=n}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(n){this.uniforms.matcapTexture.value=n}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(n){this.uniforms.parametricRimColorFactor.value=n}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(n){this.uniforms.rimMultiplyTexture.value=n}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(n){this.uniforms.rimLightingMixFactor.value=n}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(n){this.uniforms.parametricRimFresnelPowerFactor.value=n}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(n){this.uniforms.parametricRimLiftFactor.value=n}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(n){this.uniforms.outlineWidthMultiplyTexture.value=n}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(n){this.uniforms.outlineWidthFactor.value=n}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(n){this.uniforms.outlineColorFactor.value=n}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(n){this.uniforms.outlineLightingMixFactor.value=n}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(n){this.uniforms.uvAnimationMaskTexture.value=n}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(n){this.uniforms.uvAnimationScrollXOffset.value=n}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(n){this.uniforms.uvAnimationScrollYOffset.value=n}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(n){this.uniforms.uvAnimationRotationPhase.value=n}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(n){this._ignoreVertexColor=n,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(n){this._v0CompatShade=n,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(n){this._debugMode=n,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(n){this._outlineWidthMode=n,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(n){this._isOutline=n,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(n){this._uploadUniformsWorkaround(),this._updateUVAnimation(n)}copy(n){return super.copy(n),this.map=n.map,this.normalMap=n.normalMap,this.emissiveMap=n.emissiveMap,this.shadeMultiplyTexture=n.shadeMultiplyTexture,this.shadingShiftTexture=n.shadingShiftTexture,this.matcapTexture=n.matcapTexture,this.rimMultiplyTexture=n.rimMultiplyTexture,this.outlineWidthMultiplyTexture=n.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=n.uvAnimationMaskTexture,this.normalMapType=n.normalMapType,this.uvAnimationScrollXSpeedFactor=n.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=n.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=n.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=n.ignoreVertexColor,this.v0CompatShade=n.v0CompatShade,this.debugMode=n.debugMode,this.outlineWidthMode=n.outlineWidthMode,this.isOutline=n.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(n){this.uniforms.uvAnimationScrollXOffset.value+=n*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=n*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=n*this.uvAnimationRotationSpeedFactor,this.uniforms.alphaTest.value=this.alphaTest,this.uniformsNeedUpdate=!0}_uploadUniformsWorkaround(){this.uniforms.opacity.value=this.opacity,this._updateTextureMatrix(this.uniforms.map,this.uniforms.mapUvTransform),this._updateTextureMatrix(this.uniforms.normalMap,this.uniforms.normalMapUvTransform),this._updateTextureMatrix(this.uniforms.emissiveMap,this.uniforms.emissiveMapUvTransform),this._updateTextureMatrix(this.uniforms.shadeMultiplyTexture,this.uniforms.shadeMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.shadingShiftTexture,this.uniforms.shadingShiftTextureUvTransform),this._updateTextureMatrix(this.uniforms.matcapTexture,this.uniforms.matcapTextureUvTransform),this._updateTextureMatrix(this.uniforms.rimMultiplyTexture,this.uniforms.rimMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.outlineWidthMultiplyTexture,this.uniforms.outlineWidthMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.uvAnimationMaskTexture,this.uniforms.uvAnimationMaskTextureUvTransform),this.uniformsNeedUpdate=!0}_generateDefines(){const n=parseInt(ws,10),e=this.outlineWidthMultiplyTexture!==null,t=this.map!==null||this.normalMap!==null||this.emissiveMap!==null||this.shadeMultiplyTexture!==null||this.shadingShiftTexture!==null||this.rimMultiplyTexture!==null||this.uvAnimationMaskTexture!==null;return{THREE_VRM_THREE_REVISION:n,OUTLINE:this._isOutline,MTOON_USE_UV:e||t,MTOON_UVS_VERTEX_ONLY:e&&!t,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:this.shadeMultiplyTexture!==null,USE_SHADINGSHIFTTEXTURE:this.shadingShiftTexture!==null,USE_MATCAPTEXTURE:this.matcapTexture!==null,USE_RIMMULTIPLYTEXTURE:this.rimMultiplyTexture!==null,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&this.outlineWidthMultiplyTexture!==null,USE_UVANIMATIONMASKTEXTURE:this.uvAnimationMaskTexture!==null,IGNORE_VERTEX_COLOR:this._ignoreVertexColor===!0,DEBUG_NORMAL:this._debugMode==="normal",DEBUG_LITSHADERATE:this._debugMode==="litShadeRate",DEBUG_UV:this._debugMode==="uv",OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===ED.ScreenCoordinates}}_updateTextureMatrix(n,e){n.value&&(n.value.matrixAutoUpdate&&n.value.updateMatrix(),e.value.copy(n.value.matrix))}},cQ=new Set(["1.0","1.0-beta"]),O8=class x_{get name(){return x_.EXTENSION_NAME}constructor(e,t={}){var i,a,r,s;this.parser=e,this.materialType=(i=t.materialType)!=null?i:lQ,this.renderOrderOffset=(a=t.renderOrderOffset)!=null?a:0,this.v0CompatShade=(r=t.v0CompatShade)!=null?r:!1,this.debugMode=(s=t.debugMode)!=null?s:"none",this._mToonMaterialSet=new Set}beforeRoot(){return bu(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(e){return bu(this,null,function*(){e.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)})}getMaterialType(e){return this._getMToonExtension(e)?this.materialType:null}extendMaterialParams(e,t){const i=this._getMToonExtension(e);return i?this._extendMaterialParams(i,t):null}loadMesh(e){return bu(this,null,function*(){var t;const i=this.parser,r=(t=i.json.meshes)==null?void 0:t[e];if(r==null)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${e}] of glTF but the mesh doesn't exist`);const s=r.primitives,o=yield i.loadMesh(e);if(s.length===1){const c=o,h=s[0].material;h!=null&&this._setupPrimitive(c,h)}else{const c=o;for(let h=0;h<s.length;h++){const f=c.children[h],d=s[h].material;d!=null&&this._setupPrimitive(f,d)}}return o})}_removeUnlitExtensionIfMToonExists(){const i=this.parser.json.materials;i==null||i.map((a,r)=>{var s;this._getMToonExtension(r)&&((s=a.extensions)!=null&&s.KHR_materials_unlit)&&delete a.extensions.KHR_materials_unlit})}_getMToonExtension(e){var t,i;const s=(t=this.parser.json.materials)==null?void 0:t[e];if(s==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}const o=(i=s.extensions)==null?void 0:i[x_.EXTENSION_NAME];if(o==null)return;const c=o.specVersion;if(!cQ.has(c)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${x_.EXTENSION_NAME} specVersion "${c}"`);return}return o}_extendMaterialParams(e,t){return bu(this,null,function*(){var i;delete t.metalness,delete t.roughness;const a=new iQ(this.parser,t);a.assignPrimitive("transparentWithZWrite",e.transparentWithZWrite),a.assignColor("shadeColorFactor",e.shadeColorFactor),a.assignTexture("shadeMultiplyTexture",e.shadeMultiplyTexture,!0),a.assignPrimitive("shadingShiftFactor",e.shadingShiftFactor),a.assignTexture("shadingShiftTexture",e.shadingShiftTexture,!0),a.assignPrimitive("shadingShiftTextureScale",(i=e.shadingShiftTexture)==null?void 0:i.scale),a.assignPrimitive("shadingToonyFactor",e.shadingToonyFactor),a.assignPrimitive("giEqualizationFactor",e.giEqualizationFactor),a.assignColor("matcapFactor",e.matcapFactor),a.assignTexture("matcapTexture",e.matcapTexture,!0),a.assignColor("parametricRimColorFactor",e.parametricRimColorFactor),a.assignTexture("rimMultiplyTexture",e.rimMultiplyTexture,!0),a.assignPrimitive("rimLightingMixFactor",e.rimLightingMixFactor),a.assignPrimitive("parametricRimFresnelPowerFactor",e.parametricRimFresnelPowerFactor),a.assignPrimitive("parametricRimLiftFactor",e.parametricRimLiftFactor),a.assignPrimitive("outlineWidthMode",e.outlineWidthMode),a.assignPrimitive("outlineWidthFactor",e.outlineWidthFactor),a.assignTexture("outlineWidthMultiplyTexture",e.outlineWidthMultiplyTexture,!1),a.assignColor("outlineColorFactor",e.outlineColorFactor),a.assignPrimitive("outlineLightingMixFactor",e.outlineLightingMixFactor),a.assignTexture("uvAnimationMaskTexture",e.uvAnimationMaskTexture,!1),a.assignPrimitive("uvAnimationScrollXSpeedFactor",e.uvAnimationScrollXSpeedFactor),a.assignPrimitive("uvAnimationScrollYSpeedFactor",e.uvAnimationScrollYSpeedFactor),a.assignPrimitive("uvAnimationRotationSpeedFactor",e.uvAnimationRotationSpeedFactor),a.assignPrimitive("v0CompatShade",this.v0CompatShade),a.assignPrimitive("debugMode",this.debugMode),yield a.pending})}_setupPrimitive(e,t){const i=this._getMToonExtension(t);if(i){const a=this._parseRenderOrder(i);e.renderOrder=a+this.renderOrderOffset,this._generateOutline(e),this._addToMaterialSet(e);return}}_shouldGenerateOutline(e){return typeof e.outlineWidthMode=="string"&&e.outlineWidthMode!=="none"&&typeof e.outlineWidthFactor=="number"&&e.outlineWidthFactor>0}_generateOutline(e){const t=e.material;if(!(t instanceof qn)||!this._shouldGenerateOutline(t))return;e.material=[t];const i=t.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=Oi,e.material.push(i);const a=e.geometry,r=a.index?a.index.count:a.attributes.position.count/3;a.addGroup(0,r,0),a.addGroup(0,r,1)}_addToMaterialSet(e){const t=e.material,i=new Set;Array.isArray(t)?t.forEach(a=>i.add(a)):i.add(t);for(const a of i)this._mToonMaterialSet.add(a)}_parseRenderOrder(e){var t;return(e.transparentWithZWrite?0:19)+((t=e.renderQueueOffsetNumber)!=null?t:0)}};O8.EXTENSION_NAME="VRMC_materials_mtoon";var uQ=O8,hQ=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())}),L8=class wE{get name(){return wE.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,t){return hQ(this,null,function*(){const i=this._getHDREmissiveMultiplierExtension(e);if(i==null)return;console.warn("VRMMaterialsHDREmissiveMultiplierLoaderPlugin: `VRMC_materials_hdr_emissiveMultiplier` is archived. Use `KHR_materials_emissive_strength` instead.");const a=i.emissiveMultiplier;t.emissiveIntensity=a})}_getHDREmissiveMultiplierExtension(e){var t,i;const s=(t=this.parser.json.materials)==null?void 0:t[e];if(s==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}const o=(i=s.extensions)==null?void 0:i[wE.EXTENSION_NAME];if(o!=null)return o}};L8.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var fQ=L8,dQ=Object.defineProperty,pQ=Object.defineProperties,mQ=Object.getOwnPropertyDescriptors,MD=Object.getOwnPropertySymbols,gQ=Object.prototype.hasOwnProperty,vQ=Object.prototype.propertyIsEnumerable,bD=(n,e,t)=>e in n?dQ(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Xs=(n,e)=>{for(var t in e||(e={}))gQ.call(e,t)&&bD(n,t,e[t]);if(MD)for(var t of MD(e))vQ.call(e,t)&&bD(n,t,e[t]);return n},AD=(n,e)=>pQ(n,mQ(e)),_Q=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())});function mf(n){return Math.pow(n,2.2)}var xQ=class{get name(){return"VRMMaterialsV0CompatPlugin"}constructor(n){var e;this.parser=n,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;const t=this.parser.json;t.extensionsUsed=(e=t.extensionsUsed)!=null?e:[],t.extensionsUsed.indexOf("KHR_texture_transform")===-1&&t.extensionsUsed.push("KHR_texture_transform")}beforeRoot(){return _Q(this,null,function*(){var n;const e=this.parser.json,t=(n=e.extensions)==null?void 0:n.VRM,i=t==null?void 0:t.materialProperties;i&&(this._populateRenderQueueMap(i),i.forEach((a,r)=>{var s,o;const c=(s=e.materials)==null?void 0:s[r];if(c==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${r}] of glTF but the material doesn't exist`);return}if(a.shader==="VRM/MToon"){const h=this._parseV0MToonProperties(a,c);e.materials[r]=h}else if((o=a.shader)!=null&&o.startsWith("VRM/Unlit")){const h=this._parseV0UnlitProperties(a,c);e.materials[r]=h}else a.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${a.shader}`)}))})}_parseV0MToonProperties(n,e){var t,i,a,r,s,o,c,h,f,d,m,g,x,T,S,v,y,E,b,D,C,I,P,O,R,B,j,ee,se,re,W,te,K,oe,ie,Ce,Xe,nt,tt,gt,ge,Ae,Ze,ue,it,Mt,ot,Ke,Te,G,Me,De,Fe,Be,$e;const Je=(i=(t=n.keywordMap)==null?void 0:t._ALPHABLEND_ON)!=null?i:!1,k=((a=n.floatProperties)==null?void 0:a._ZWrite)===1&&Je,U=this._v0ParseRenderQueue(n),ce=(s=(r=n.keywordMap)==null?void 0:r._ALPHATEST_ON)!=null?s:!1,Ee=Je?"BLEND":ce?"MASK":"OPAQUE",Le=ce?(c=(o=n.floatProperties)==null?void 0:o._Cutoff)!=null?c:.5:void 0,vt=((f=(h=n.floatProperties)==null?void 0:h._CullMode)!=null?f:2)===0,qe=this._portTextureTransform(n),_t=((m=(d=n.vectorProperties)==null?void 0:d._Color)!=null?m:[1,1,1,1]).map((N,V)=>V===3?N:mf(N)),pt=(g=n.textureProperties)==null?void 0:g._MainTex,Ie=pt!=null?{index:pt,extensions:Xs({},qe)}:void 0,He=(T=(x=n.floatProperties)==null?void 0:x._BumpScale)!=null?T:1,ht=(S=n.textureProperties)==null?void 0:S._BumpMap,Q=ht!=null?{index:ht,scale:He,extensions:Xs({},qe)}:void 0,pe=((y=(v=n.vectorProperties)==null?void 0:v._EmissionColor)!=null?y:[0,0,0,1]).map(mf),Oe=(E=n.textureProperties)==null?void 0:E._EmissionMap,q=Oe!=null?{index:Oe,extensions:Xs({},qe)}:void 0,Ve=((D=(b=n.vectorProperties)==null?void 0:b._ShadeColor)!=null?D:[.97,.81,.86,1]).map(mf),me=(C=n.textureProperties)==null?void 0:C._ShadeTexture,We=me!=null?{index:me,extensions:Xs({},qe)}:void 0;let Ge=(P=(I=n.floatProperties)==null?void 0:I._ShadeShift)!=null?P:0,Re=(R=(O=n.floatProperties)==null?void 0:O._ShadeToony)!=null?R:.9;Re=$t.lerp(Re,1,.5+.5*Ge),Ge=-Ge-(1-Re);const rt=(j=(B=n.floatProperties)==null?void 0:B._IndirectLightIntensity)!=null?j:.1,yt=rt?1-rt:void 0,Gt=(ee=n.textureProperties)==null?void 0:ee._SphereAdd,Vt=Gt!=null?[1,1,1]:void 0,oi=Gt!=null?{index:Gt}:void 0,li=(re=(se=n.floatProperties)==null?void 0:se._RimLightingMix)!=null?re:0,co=(W=n.textureProperties)==null?void 0:W._RimTexture,Ls=co!=null?{index:co,extensions:Xs({},qe)}:void 0,Is=((K=(te=n.vectorProperties)==null?void 0:te._RimColor)!=null?K:[0,0,0,1]).map(mf),Ei=(ie=(oe=n.floatProperties)==null?void 0:oe._RimFresnelPower)!=null?ie:1,Us=(Xe=(Ce=n.floatProperties)==null?void 0:Ce._RimLift)!=null?Xe:0,ha=["none","worldCoordinates","screenCoordinates"][(tt=(nt=n.floatProperties)==null?void 0:nt._OutlineWidthMode)!=null?tt:0];let ki=(ge=(gt=n.floatProperties)==null?void 0:gt._OutlineWidth)!=null?ge:0;ki=.01*ki;const Ha=(Ae=n.textureProperties)==null?void 0:Ae._OutlineWidthTexture,Dn=Ha!=null?{index:Ha,extensions:Xs({},qe)}:void 0,Or=((ue=(Ze=n.vectorProperties)==null?void 0:Ze._OutlineColor)!=null?ue:[0,0,0]).map(mf),zs=((Mt=(it=n.floatProperties)==null?void 0:it._OutlineColorMode)!=null?Mt:0)===1?(Ke=(ot=n.floatProperties)==null?void 0:ot._OutlineLightingMix)!=null?Ke:1:0,uo=(Te=n.textureProperties)==null?void 0:Te._UvAnimMaskTexture,rr=uo!=null?{index:uo,extensions:Xs({},qe)}:void 0,fa=(Me=(G=n.floatProperties)==null?void 0:G._UvAnimScrollX)!=null?Me:0;let w=(Fe=(De=n.floatProperties)==null?void 0:De._UvAnimScrollY)!=null?Fe:0;w!=null&&(w=-w);const z=($e=(Be=n.floatProperties)==null?void 0:Be._UvAnimRotation)!=null?$e:0,Y={specVersion:"1.0",transparentWithZWrite:k,renderQueueOffsetNumber:U,shadeColorFactor:Ve,shadeMultiplyTexture:We,shadingShiftFactor:Ge,shadingToonyFactor:Re,giEqualizationFactor:yt,matcapFactor:Vt,matcapTexture:oi,rimLightingMixFactor:li,rimMultiplyTexture:Ls,parametricRimColorFactor:Is,parametricRimFresnelPowerFactor:Ei,parametricRimLiftFactor:Us,outlineWidthMode:ha,outlineWidthFactor:ki,outlineWidthMultiplyTexture:Dn,outlineColorFactor:Or,outlineLightingMixFactor:zs,uvAnimationMaskTexture:rr,uvAnimationScrollXSpeedFactor:fa,uvAnimationScrollYSpeedFactor:w,uvAnimationRotationSpeedFactor:z};return AD(Xs({},e),{pbrMetallicRoughness:{baseColorFactor:_t,baseColorTexture:Ie},normalTexture:Q,emissiveTexture:q,emissiveFactor:pe,alphaMode:Ee,alphaCutoff:Le,doubleSided:vt,extensions:{VRMC_materials_mtoon:Y}})}_parseV0UnlitProperties(n,e){var t,i,a,r,s;const o=n.shader==="VRM/UnlitTransparentZWrite",c=n.shader==="VRM/UnlitTransparent"||o,h=this._v0ParseRenderQueue(n),f=n.shader==="VRM/UnlitCutout",d=c?"BLEND":f?"MASK":"OPAQUE",m=f?(i=(t=n.floatProperties)==null?void 0:t._Cutoff)!=null?i:.5:void 0,g=this._portTextureTransform(n),x=((r=(a=n.vectorProperties)==null?void 0:a._Color)!=null?r:[1,1,1,1]).map(mf),T=(s=n.textureProperties)==null?void 0:s._MainTex,S=T!=null?{index:T,extensions:Xs({},g)}:void 0,v={specVersion:"1.0",transparentWithZWrite:o,renderQueueOffsetNumber:h,shadeColorFactor:x,shadeMultiplyTexture:S};return AD(Xs({},e),{pbrMetallicRoughness:{baseColorFactor:x,baseColorTexture:S},alphaMode:d,alphaCutoff:m,extensions:{VRMC_materials_mtoon:v}})}_portTextureTransform(n){var e,t,i,a,r;const s=(e=n.vectorProperties)==null?void 0:e._MainTex;if(s==null)return{};const o=[(t=s==null?void 0:s[0])!=null?t:0,(i=s==null?void 0:s[1])!=null?i:0],c=[(a=s==null?void 0:s[2])!=null?a:1,(r=s==null?void 0:s[3])!=null?r:1];return o[1]=1-c[1]-o[1],{KHR_texture_transform:{offset:o,scale:c}}}_v0ParseRenderQueue(n){var e,t;const i=n.shader==="VRM/UnlitTransparentZWrite",a=((e=n.keywordMap)==null?void 0:e._ALPHABLEND_ON)!=null||n.shader==="VRM/UnlitTransparent"||i,r=((t=n.floatProperties)==null?void 0:t._ZWrite)===1||i;let s=0;if(a){const o=n.renderQueue;o!=null&&(r?s=this._renderQueueMapTransparentZWrite.get(o):s=this._renderQueueMapTransparent.get(o))}return s}_populateRenderQueueMap(n){const e=new Set,t=new Set;n.forEach(i=>{var a,r;const s=i.shader==="VRM/UnlitTransparentZWrite",o=((a=i.keywordMap)==null?void 0:a._ALPHABLEND_ON)!=null||i.shader==="VRM/UnlitTransparent"||s,c=((r=i.floatProperties)==null?void 0:r._ZWrite)===1||s;if(o){const h=i.renderQueue;h!=null&&(c?t.add(h):e.add(h))}}),e.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${e.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(e).sort().forEach((i,a)=>{const r=Math.min(Math.max(a-e.size+1,-9),0);this._renderQueueMapTransparent.set(i,r)}),Array.from(t).sort().forEach((i,a)=>{const r=Math.min(Math.max(a,0),9);this._renderQueueMapTransparentZWrite.set(i,r)})}},RD=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())}),Ll=new L,C2=class extends Ia{constructor(n){super(),this._attrPosition=new Ot(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(OU);const e=new wt;e.setAttribute("position",this._attrPosition);const t=new Pi({color:16711935,depthTest:!1,depthWrite:!1});this._line=new ro(e,t),this.add(this._line),this.constraint=n}updateMatrixWorld(n){Ll.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,Ll.x,Ll.y,Ll.z),this.constraint.source&&Ll.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,Ll.x,Ll.y,Ll.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(n)}};function wD(n,e){return e.set(n.elements[12],n.elements[13],n.elements[14])}var yQ=new L,SQ=new L;function TQ(n,e){return n.decompose(yQ,e,SQ),e}function Wx(n){return n.invert?n.invert():n.inverse(),n}var tA=class{constructor(n,e){this.destination=n,this.source=e,this.weight=1}},EQ=new L,MQ=new L,bQ=new L,AQ=new Tt,RQ=new Tt,wQ=new Tt,CQ=class extends tA{get aimAxis(){return this._aimAxis}set aimAxis(n){this._aimAxis=n,this._v3AimAxis.set(n==="PositiveX"?1:n==="NegativeX"?-1:0,n==="PositiveY"?1:n==="NegativeY"?-1:0,n==="PositiveZ"?1:n==="NegativeZ"?-1:0)}get dependencies(){const n=new Set([this.source]);return this.destination.parent&&n.add(this.destination.parent),n}constructor(n,e){super(n,e),this._aimAxis="PositiveX",this._v3AimAxis=new L(1,0,0),this._dstRestQuat=new Tt}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);const n=AQ.identity(),e=RQ.identity();this.destination.parent&&(TQ(this.destination.parent.matrixWorld,n),Wx(e.copy(n)));const t=EQ.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(n),i=wD(this.source.matrixWorld,MQ).sub(wD(this.destination.matrixWorld,bQ)).normalize(),a=wQ.setFromUnitVectors(t,i).premultiply(e).multiply(n).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(a,this.weight)}};function NQ(n,e){const t=[n];let i=n.parent;for(;i!==null;)t.unshift(i),i=i.parent;t.forEach(a=>{e(a)})}var DQ=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(n){this._constraints.add(n);let e=this._objectConstraintsMap.get(n.destination);e==null&&(e=new Set,this._objectConstraintsMap.set(n.destination,e)),e.add(n)}deleteConstraint(n){this._constraints.delete(n),this._objectConstraintsMap.get(n.destination).delete(n)}setInitState(){const n=new Set,e=new Set;for(const t of this._constraints)this._processConstraint(t,n,e,i=>i.setInitState())}update(){const n=new Set,e=new Set;for(const t of this._constraints)this._processConstraint(t,n,e,i=>i.update())}_processConstraint(n,e,t,i){if(t.has(n))return;if(e.has(n))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");e.add(n);const a=n.dependencies;for(const r of a)NQ(r,s=>{const o=this._objectConstraintsMap.get(s);if(o)for(const c of o)this._processConstraint(c,e,t,i)});i(n),t.add(n)}},OQ=new Tt,LQ=new Tt,IQ=class extends tA{get dependencies(){return new Set([this.source])}constructor(n,e){super(n,e),this._dstRestQuat=new Tt,this._invSrcRestQuat=new Tt}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Wx(this._invSrcRestQuat.copy(this.source.quaternion))}update(){const n=OQ.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=LQ.copy(this._dstRestQuat).multiply(n);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},UQ=new L,PQ=new Tt,zQ=new Tt,BQ=class extends tA{get rollAxis(){return this._rollAxis}set rollAxis(n){this._rollAxis=n,this._v3RollAxis.set(n==="X"?1:0,n==="Y"?1:0,n==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(n,e){super(n,e),this._rollAxis="X",this._v3RollAxis=new L(1,0,0),this._dstRestQuat=new Tt,this._invDstRestQuat=new Tt,this._invSrcRestQuatMulDstRestQuat=new Tt}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Wx(this._invDstRestQuat.copy(this._dstRestQuat)),Wx(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){const n=PQ.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=UQ.copy(this._v3RollAxis).applyQuaternion(n),i=zQ.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(n);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},HQ=new Set(["1.0","1.0-beta"]),I8=class um{get name(){return um.EXTENSION_NAME}constructor(e,t){this.parser=e,this.helperRoot=t==null?void 0:t.helperRoot}afterRoot(e){return RD(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return RD(this,null,function*(){var t;const i=this.parser.json;if(!(((t=i.extensionsUsed)==null?void 0:t.indexOf(um.EXTENSION_NAME))!==-1))return null;const r=new DQ,s=yield this.parser.getDependencies("node");return s.forEach((o,c)=>{var h;const f=i.nodes[c],d=(h=f==null?void 0:f.extensions)==null?void 0:h[um.EXTENSION_NAME];if(d==null)return;const m=d.specVersion;if(!HQ.has(m)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${um.EXTENSION_NAME} specVersion "${m}"`);return}const g=d.constraint;if(g.roll!=null){const x=this._importRollConstraint(o,s,g.roll);r.addConstraint(x)}else if(g.aim!=null){const x=this._importAimConstraint(o,s,g.aim);r.addConstraint(x)}else if(g.rotation!=null){const x=this._importRotationConstraint(o,s,g.rotation);r.addConstraint(x)}}),e.scene.updateMatrixWorld(),r.setInitState(),r})}_importRollConstraint(e,t,i){const{source:a,rollAxis:r,weight:s}=i,o=t[a],c=new BQ(e,o);if(r!=null&&(c.rollAxis=r),s!=null&&(c.weight=s),this.helperRoot){const h=new C2(c);this.helperRoot.add(h)}return c}_importAimConstraint(e,t,i){const{source:a,aimAxis:r,weight:s}=i,o=t[a],c=new CQ(e,o);if(r!=null&&(c.aimAxis=r),s!=null&&(c.weight=s),this.helperRoot){const h=new C2(c);this.helperRoot.add(h)}return c}_importRotationConstraint(e,t,i){const{source:a,weight:r}=i,s=t[a],o=new IQ(e,s);if(r!=null&&(o.weight=r),this.helperRoot){const c=new C2(o);this.helperRoot.add(c)}return o}};I8.EXTENSION_NAME="VRMC_node_constraint";var FQ=I8,Hv=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())}),nA=class{},N2=new L,cu=new L,U8=class extends nA{get type(){return"capsule"}constructor(n){var e,t,i,a;super(),this.offset=(e=n==null?void 0:n.offset)!=null?e:new L(0,0,0),this.tail=(t=n==null?void 0:n.tail)!=null?t:new L(0,0,0),this.radius=(i=n==null?void 0:n.radius)!=null?i:0,this.inside=(a=n==null?void 0:n.inside)!=null?a:!1}calculateCollision(n,e,t,i){N2.setFromMatrixPosition(n),cu.subVectors(this.tail,this.offset).applyMatrix4(n),cu.sub(N2);const a=cu.lengthSq();i.copy(e).sub(N2);const r=cu.dot(i);r<=0||(a<=r||cu.multiplyScalar(r/a),i.sub(cu));const s=i.length(),o=this.inside?this.radius-t-s:s-t-this.radius;return o<0&&(i.multiplyScalar(1/s),this.inside&&i.negate()),o}},D2=new L,CD=new Et,P8=class extends nA{get type(){return"plane"}constructor(n){var e,t;super(),this.offset=(e=n==null?void 0:n.offset)!=null?e:new L(0,0,0),this.normal=(t=n==null?void 0:n.normal)!=null?t:new L(0,0,1)}calculateCollision(n,e,t,i){i.setFromMatrixPosition(n),i.negate().add(e),CD.getNormalMatrix(n),D2.copy(this.normal).applyNormalMatrix(CD).normalize();const a=i.dot(D2)-t;return i.copy(D2),a}},GQ=new L,z8=class extends nA{get type(){return"sphere"}constructor(n){var e,t,i;super(),this.offset=(e=n==null?void 0:n.offset)!=null?e:new L(0,0,0),this.radius=(t=n==null?void 0:n.radius)!=null?t:0,this.inside=(i=n==null?void 0:n.inside)!=null?i:!1}calculateCollision(n,e,t,i){i.subVectors(e,GQ.setFromMatrixPosition(n));const a=i.length(),r=this.inside?this.radius-t-a:a-t-this.radius;return r<0&&(i.multiplyScalar(1/a),this.inside&&i.negate()),r}},Ys=new L,VQ=class extends wt{constructor(n){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new L,this._currentTail=new L,this._shape=n,this._attrPos=new Ot(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;const e=this._shape.radius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,n=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),n=!0);const t=Ys.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(t)>1e-10&&(this._currentTail.copy(t),n=!0),n&&this._buildPosition()}_buildPosition(){Ys.copy(this._currentTail).sub(this._currentOffset);const n=Ys.length()/this._currentRadius;for(let i=0;i<=16;i++){const a=i/16*Math.PI;this._attrPos.setXYZ(i,-Math.sin(a),-Math.cos(a),0),this._attrPos.setXYZ(17+i,n+Math.sin(a),Math.cos(a),0),this._attrPos.setXYZ(34+i,-Math.sin(a),0,-Math.cos(a)),this._attrPos.setXYZ(51+i,n+Math.sin(a),0,Math.cos(a))}for(let i=0;i<32;i++){const a=i/16*Math.PI;this._attrPos.setXYZ(68+i,0,Math.sin(a),Math.cos(a)),this._attrPos.setXYZ(100+i,n,Math.sin(a),Math.cos(a))}const e=Math.atan2(Ys.y,Math.sqrt(Ys.x*Ys.x+Ys.z*Ys.z)),t=-Math.atan2(Ys.z,Ys.x);this.rotateZ(e),this.rotateY(t),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let n=0;n<34;n++){const e=(n+1)%34;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(68+n*2,34+n,34+e)}for(let n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(136+n*2,68+n,68+e),this._attrIndex.setXY(200+n*2,100+n,100+e)}this._attrIndex.needsUpdate=!0}},kQ=class extends wt{constructor(n){super(),this.worldScale=1,this._currentOffset=new L,this._currentNormal=new L,this._shape=n,this._attrPos=new Ot(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),n=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),n=!0),n&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}},WQ=class extends wt{constructor(n){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new L,this._shape=n,this._attrPos=new Ot(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;const e=this._shape.radius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,n=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),n=!0),n&&this._buildPosition()}_buildPosition(){for(let n=0;n<32;n++){const e=n/16*Math.PI;this._attrPos.setXYZ(n,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+n,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+n,Math.sin(e),0,Math.cos(e))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(64+n*2,32+n,32+e),this._attrIndex.setXY(128+n*2,64+n,64+e)}this._attrIndex.needsUpdate=!0}},XQ=new L,O2=class extends Ia{constructor(n){if(super(),this.matrixAutoUpdate=!1,this.collider=n,this.collider.shape instanceof z8)this._geometry=new WQ(this.collider.shape);else if(this.collider.shape instanceof U8)this._geometry=new VQ(this.collider.shape);else if(this.collider.shape instanceof P8)this._geometry=new kQ(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");const e=new Pi({color:16711935,depthTest:!1,depthWrite:!1});this._line=new nr(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(n){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);const e=this.matrix.elements;this._geometry.worldScale=XQ.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(n)}},YQ=class extends wt{constructor(n){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new L,this._springBone=n,this._attrPos=new Ot(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;const e=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,n=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),n=!0),n&&this._buildPosition()}_buildPosition(){for(let n=0;n<32;n++){const e=n/16*Math.PI;this._attrPos.setXYZ(n,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+n,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+n,Math.sin(e),0,Math.cos(e))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(64+n*2,32+n,32+e),this._attrIndex.setXY(128+n*2,64+n,64+e)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},qQ=new L,jQ=class extends Ia{constructor(n){super(),this.matrixAutoUpdate=!1,this.springBone=n,this._geometry=new YQ(this.springBone);const e=new Pi({color:16776960,depthTest:!1,depthWrite:!1});this._line=new nr(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(n){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);const e=this.matrix.elements;this._geometry.worldScale=qQ.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(n)}},L2=class extends Zt{constructor(n){super(),this.colliderMatrix=new ke,this.shape=n}updateWorldMatrix(n,e){super.updateWorldMatrix(n,e),ZQ(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function ZQ(n,e,t){const i=e.elements;n.copy(e),t&&(n.elements[12]=i[0]*t.x+i[4]*t.y+i[8]*t.z+i[12],n.elements[13]=i[1]*t.x+i[5]*t.y+i[9]*t.z+i[13],n.elements[14]=i[2]*t.x+i[6]*t.y+i[10]*t.z+i[14])}var KQ=new ke;function QQ(n){return n.invert?n.invert():n.getInverse(KQ.copy(n)),n}var JQ=class{constructor(n){this._inverseCache=new ke,this._shouldUpdateInverse=!0,this.matrix=n;const e={set:(t,i,a)=>(this._shouldUpdateInverse=!0,t[i]=a,!0)};this._originalElements=n.elements,n.elements=new Proxy(n.elements,e)}get inverse(){return this._shouldUpdateInverse&&(QQ(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},I2=new ke,gf=new L,qp=new L,jp=new L,Zp=new L,$Q=new ke,eJ=class{constructor(n,e,t={},i=[]){this._currentTail=new L,this._prevTail=new L,this._boneAxis=new L,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new ke,this._initialLocalRotation=new Tt,this._initialLocalChildPosition=new L;var a,r,s,o,c,h;this.bone=n,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(a=t.hitRadius)!=null?a:0,stiffness:(r=t.stiffness)!=null?r:1,gravityPower:(s=t.gravityPower)!=null?s:0,gravityDir:(c=(o=t.gravityDir)==null?void 0:o.clone())!=null?c:new L(0,-1,0),dragForce:(h=t.dragForce)!=null?h:.4},this.colliderGroups=i}get dependencies(){const n=new Set,e=this.bone.parent;e&&n.add(e);for(let t=0;t<this.colliderGroups.length;t++)for(let i=0;i<this.colliderGroups[t].colliders.length;i++)n.add(this.colliderGroups[t].colliders[i]);return n}get center(){return this._center}set center(n){var e;(e=this._center)!=null&&e.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=n,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new JQ(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:I2}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);const n=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(n),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);const n=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(n),this._prevTail.copy(this._currentTail)}update(n){if(n<=0)return;this._calcWorldSpaceBoneLength();const e=qp.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);Zp.copy(this._currentTail).add(gf.subVectors(this._currentTail,this._prevTail).multiplyScalar(1-this.settings.dragForce)).applyMatrix4(this._getMatrixCenterToWorld()).addScaledVector(e,this.settings.stiffness*n).addScaledVector(this.settings.gravityDir,this.settings.gravityPower*n),jp.setFromMatrixPosition(this.bone.matrixWorld),Zp.sub(jp).normalize().multiplyScalar(this._worldSpaceBoneLength).add(jp),this._collision(Zp),this._prevTail.copy(this._currentTail),this._currentTail.copy(Zp).applyMatrix4(this._getMatrixWorldToCenter());const t=$Q.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,gf.copy(Zp).applyMatrix4(t).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(n){for(let e=0;e<this.colliderGroups.length;e++)for(let t=0;t<this.colliderGroups[e].colliders.length;t++){const i=this.colliderGroups[e].colliders[t],a=i.shape.calculateCollision(i.colliderMatrix,n,this.settings.hitRadius,gf);if(a<0){n.addScaledVector(gf,-a),n.sub(jp);const r=n.length();n.multiplyScalar(this._worldSpaceBoneLength/r).add(jp)}}}_calcWorldSpaceBoneLength(){gf.setFromMatrixPosition(this.bone.matrixWorld),this.child?qp.setFromMatrixPosition(this.child.matrixWorld):(qp.copy(this._initialLocalChildPosition),qp.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=gf.sub(qp).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:I2}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:I2}};function tJ(n,e){const t=[];let i=n;for(;i!==null;)t.unshift(i),i=i.parent;t.forEach(a=>{e(a)})}function CE(n,e){n.children.forEach(t=>{e(t)||CE(t,e)})}function nJ(n){var e;const t=new Map;for(const i of n){let a=i;do{const r=((e=t.get(a))!=null?e:0)+1;if(r===n.size)return a;t.set(a,r),a=a.parent}while(a!==null)}return null}var ND=class{constructor(){this._joints=new Set,this._sortedJoints=[],this._hasWarnedCircularDependency=!1,this._ancestors=[],this._objectSpringBonesMap=new Map,this._isSortedJointsDirty=!1,this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){const n=new Set;return this._joints.forEach(e=>{e.colliderGroups.forEach(t=>{n.add(t)})}),Array.from(n)}get colliders(){const n=new Set;return this.colliderGroups.forEach(e=>{e.colliders.forEach(t=>{n.add(t)})}),Array.from(n)}addJoint(n){this._joints.add(n);let e=this._objectSpringBonesMap.get(n.bone);e==null&&(e=new Set,this._objectSpringBonesMap.set(n.bone,e)),e.add(n),this._isSortedJointsDirty=!0}addSpringBone(n){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(n)}deleteJoint(n){this._joints.delete(n),this._objectSpringBonesMap.get(n.bone).delete(n),this._isSortedJointsDirty=!0}deleteSpringBone(n){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(n)}setInitState(){this._sortJoints();for(let n=0;n<this._sortedJoints.length;n++){const e=this._sortedJoints[n];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.setInitState()}}reset(){this._sortJoints();for(let n=0;n<this._sortedJoints.length;n++){const e=this._sortedJoints[n];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.reset()}}update(n){this._sortJoints();for(let e=0;e<this._ancestors.length;e++)this._ancestors[e].updateWorldMatrix(e===0,!1);for(let e=0;e<this._sortedJoints.length;e++){const t=this._sortedJoints[e];t.bone.updateMatrix(),t.bone.updateWorldMatrix(!1,!1),t.update(n),CE(t.bone,this._relevantChildrenUpdated)}}_sortJoints(){if(!this._isSortedJointsDirty)return;const n=[],e=new Set,t=new Set,i=new Set;for(const r of this._joints)this._insertJointSort(r,e,t,n,i);this._sortedJoints=n;const a=nJ(i);this._ancestors=[],a&&(this._ancestors.push(a),CE(a,r=>{var s,o;return((o=(s=this._objectSpringBonesMap.get(r))==null?void 0:s.size)!=null?o:0)>0?!0:(this._ancestors.push(r),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(n,e,t,i,a){if(t.has(n))return;if(e.has(n)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}e.add(n);const r=n.dependencies;for(const s of r){let o=!1,c=null;tJ(s,h=>{const f=this._objectSpringBonesMap.get(h);if(f)for(const d of f)o=!0,this._insertJointSort(d,e,t,i,a);else o||(c=h)}),c&&a.add(c)}i.push(n),t.add(n)}_relevantChildrenUpdated(n){var e,t;return((t=(e=this._objectSpringBonesMap.get(n))==null?void 0:e.size)!=null?t:0)>0?!0:(n.updateWorldMatrix(!1,!1),!1)}},DD="VRMC_springBone_extended_collider",iJ=new Set(["1.0","1.0-beta"]),aJ=new Set(["1.0"]),B8=class wf{get name(){return wf.EXTENSION_NAME}constructor(e,t){var i;this.parser=e,this.jointHelperRoot=t==null?void 0:t.jointHelperRoot,this.colliderHelperRoot=t==null?void 0:t.colliderHelperRoot,this.useExtendedColliders=(i=t==null?void 0:t.useExtendedColliders)!=null?i:!0}afterRoot(e){return Hv(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return Hv(this,null,function*(){const t=yield this._v1Import(e);if(t!=null)return t;const i=yield this._v0Import(e);return i??null})}_v1Import(e){return Hv(this,null,function*(){var t,i,a,r,s;const o=e.parser.json;if(!(((t=o.extensionsUsed)==null?void 0:t.indexOf(wf.EXTENSION_NAME))!==-1))return null;const h=new ND,f=yield e.parser.getDependencies("node"),d=(i=o.extensions)==null?void 0:i[wf.EXTENSION_NAME];if(!d)return null;const m=d.specVersion;if(!iJ.has(m))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${wf.EXTENSION_NAME} specVersion "${m}"`),null;const g=(a=d.colliders)==null?void 0:a.map((T,S)=>{var v,y,E,b,D,C,I,P,O,R,B,j,ee,se,re;const W=f[T.node];if(W==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${S} attempted to use the node #${T.node} but not found`),null;const te=T.shape,K=(v=T.extensions)==null?void 0:v[DD];if(this.useExtendedColliders&&K!=null){const oe=K.specVersion;if(!aJ.has(oe))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${DD} specVersion "${oe}". Fallbacking to the ${wf.EXTENSION_NAME} definition`);else{const ie=K.shape;if(ie.sphere)return this._importSphereCollider(W,{offset:new L().fromArray((y=ie.sphere.offset)!=null?y:[0,0,0]),radius:(E=ie.sphere.radius)!=null?E:0,inside:(b=ie.sphere.inside)!=null?b:!1});if(ie.capsule)return this._importCapsuleCollider(W,{offset:new L().fromArray((D=ie.capsule.offset)!=null?D:[0,0,0]),radius:(C=ie.capsule.radius)!=null?C:0,tail:new L().fromArray((I=ie.capsule.tail)!=null?I:[0,0,0]),inside:(P=ie.capsule.inside)!=null?P:!1});if(ie.plane)return this._importPlaneCollider(W,{offset:new L().fromArray((O=ie.plane.offset)!=null?O:[0,0,0]),normal:new L().fromArray((R=ie.plane.normal)!=null?R:[0,0,1])})}}if(te.sphere)return this._importSphereCollider(W,{offset:new L().fromArray((B=te.sphere.offset)!=null?B:[0,0,0]),radius:(j=te.sphere.radius)!=null?j:0,inside:!1});if(te.capsule)return this._importCapsuleCollider(W,{offset:new L().fromArray((ee=te.capsule.offset)!=null?ee:[0,0,0]),radius:(se=te.capsule.radius)!=null?se:0,tail:new L().fromArray((re=te.capsule.tail)!=null?re:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${S} has no valid shape`)}),x=(r=d.colliderGroups)==null?void 0:r.map((T,S)=>{var v;return{colliders:((v=T.colliders)!=null?v:[]).flatMap(E=>{const b=g==null?void 0:g[E];return b??(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${S} attempted to use a collider #${E} but not found`),[])}),name:T.name}});return(s=d.springs)==null||s.forEach((T,S)=>{var v;const y=T.joints,E=(v=T.colliderGroups)==null?void 0:v.map(C=>{const I=x==null?void 0:x[C];if(I==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${S} attempted to use a colliderGroup ${C} but not found`);return I}),b=T.center!=null?f[T.center]:void 0;let D;y.forEach(C=>{if(D){const I=D.node,P=f[I],O=C.node,R=f[O],B={hitRadius:D.hitRadius,dragForce:D.dragForce,gravityPower:D.gravityPower,stiffness:D.stiffness,gravityDir:D.gravityDir!=null?new L().fromArray(D.gravityDir):void 0},j=this._importJoint(P,R,B,E);b&&(j.center=b),h.addJoint(j)}D=C})}),h.setInitState(),h})}_v0Import(e){return Hv(this,null,function*(){var t,i,a;const r=e.parser.json;if(!(((t=r.extensionsUsed)==null?void 0:t.indexOf("VRM"))!==-1))return null;const o=(i=r.extensions)==null?void 0:i.VRM,c=o==null?void 0:o.secondaryAnimation;if(!c)return null;const h=c==null?void 0:c.boneGroups;if(!h)return null;const f=new ND,d=yield e.parser.getDependencies("node"),m=(a=c.colliderGroups)==null?void 0:a.map(g=>{var x;const T=d[g.node];return{colliders:((x=g.colliders)!=null?x:[]).map((v,y)=>{var E,b,D;const C=new L(0,0,0);return v.offset&&C.set((E=v.offset.x)!=null?E:0,(b=v.offset.y)!=null?b:0,v.offset.z?-v.offset.z:0),this._importSphereCollider(T,{offset:C,radius:(D=v.radius)!=null?D:0,inside:!1})})}});return h==null||h.forEach((g,x)=>{const T=g.bones;T&&T.forEach(S=>{var v,y,E,b;const D=d[S],C=new L;g.gravityDir?C.set((v=g.gravityDir.x)!=null?v:0,(y=g.gravityDir.y)!=null?y:0,(E=g.gravityDir.z)!=null?E:0):C.set(0,-1,0);const I=g.center!=null?d[g.center]:void 0,P={hitRadius:g.hitRadius,dragForce:g.dragForce,gravityPower:g.gravityPower,stiffness:g.stiffiness,gravityDir:C},O=(b=g.colliderGroups)==null?void 0:b.map(R=>{const B=m==null?void 0:m[R];if(B==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${x} attempted to use a colliderGroup ${R} but not found`);return B});D.traverse(R=>{var B;const j=(B=R.children[0])!=null?B:null,ee=this._importJoint(R,j,P,O);I&&(ee.center=I),f.addJoint(ee)})})}),e.scene.updateMatrixWorld(),f.setInitState(),f})}_importJoint(e,t,i,a){const r=new eJ(e,t,i,a);if(this.jointHelperRoot){const s=new jQ(r);this.jointHelperRoot.add(s),s.renderOrder=this.jointHelperRoot.renderOrder}return r}_importSphereCollider(e,t){const i=new z8(t),a=new L2(i);if(e.add(a),this.colliderHelperRoot){const r=new O2(a);this.colliderHelperRoot.add(r),r.renderOrder=this.colliderHelperRoot.renderOrder}return a}_importCapsuleCollider(e,t){const i=new U8(t),a=new L2(i);if(e.add(a),this.colliderHelperRoot){const r=new O2(a);this.colliderHelperRoot.add(r),r.renderOrder=this.colliderHelperRoot.renderOrder}return a}_importPlaneCollider(e,t){const i=new P8(t),a=new L2(i);if(e.add(a),this.colliderHelperRoot){const r=new O2(a);this.colliderHelperRoot.add(r),r.renderOrder=this.colliderHelperRoot.renderOrder}return a}};B8.EXTENSION_NAME="VRMC_springBone";var rJ=B8,sJ=class{get name(){return"VRMLoaderPlugin"}constructor(n,e){var t,i,a,r,s,o,c,h,f,d;this.parser=n;const m=e==null?void 0:e.helperRoot,g=e==null?void 0:e.autoUpdateHumanBones;this.expressionPlugin=(t=e==null?void 0:e.expressionPlugin)!=null?t:new TK(n),this.firstPersonPlugin=(i=e==null?void 0:e.firstPersonPlugin)!=null?i:new MK(n),this.humanoidPlugin=(a=e==null?void 0:e.humanoidPlugin)!=null?a:new DK(n,{helperRoot:m,autoUpdateHumanBones:g}),this.lookAtPlugin=(r=e==null?void 0:e.lookAtPlugin)!=null?r:new YK(n,{helperRoot:m}),this.metaPlugin=(s=e==null?void 0:e.metaPlugin)!=null?s:new ZK(n),this.mtoonMaterialPlugin=(o=e==null?void 0:e.mtoonMaterialPlugin)!=null?o:new uQ(n),this.materialsHDREmissiveMultiplierPlugin=(c=e==null?void 0:e.materialsHDREmissiveMultiplierPlugin)!=null?c:new fQ(n),this.materialsV0CompatPlugin=(h=e==null?void 0:e.materialsV0CompatPlugin)!=null?h:new xQ(n),this.springBonePlugin=(f=e==null?void 0:e.springBonePlugin)!=null?f:new rJ(n,{colliderHelperRoot:m,jointHelperRoot:m}),this.nodeConstraintPlugin=(d=e==null?void 0:e.nodeConstraintPlugin)!=null?d:new FQ(n,{helperRoot:m})}beforeRoot(){return Pv(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(n){return Pv(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(n)})}getMaterialType(n){const e=this.mtoonMaterialPlugin.getMaterialType(n);return e??null}extendMaterialParams(n,e){return Pv(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(n,e),yield this.mtoonMaterialPlugin.extendMaterialParams(n,e)})}afterRoot(n){return Pv(this,null,function*(){yield this.metaPlugin.afterRoot(n),yield this.humanoidPlugin.afterRoot(n),yield this.expressionPlugin.afterRoot(n),yield this.lookAtPlugin.afterRoot(n),yield this.firstPersonPlugin.afterRoot(n),yield this.springBonePlugin.afterRoot(n),yield this.nodeConstraintPlugin.afterRoot(n),yield this.mtoonMaterialPlugin.afterRoot(n);const e=n.userData.vrmMeta,t=n.userData.vrmHumanoid;if(e&&t){const i=new QK({scene:n.scene,expressionManager:n.userData.vrmExpressionManager,firstPerson:n.userData.vrmFirstPerson,humanoid:t,lookAt:n.userData.vrmLookAt,meta:e,materials:n.userData.vrmMToonMaterials,springBoneManager:n.userData.vrmSpringBoneManager,nodeConstraintManager:n.userData.vrmNodeConstraintManager});n.userData.vrm=i}})}};function oJ(n){const e=new Set;return n.traverse(t=>{if(!t.isMesh)return;const i=t;e.add(i)}),e}function OD(n,e,t){if(e.size===1){const s=e.values().next().value;if(s.weight===1)return n[s.index]}const i=new Float32Array(n[0].count*3);let a=0;if(t)a=1;else for(const s of e)a+=s.weight;for(const s of e){const o=n[s.index],c=s.weight/a;for(let h=0;h<o.count;h++)i[h*3+0]+=o.getX(h)*c,i[h*3+1]+=o.getY(h)*c,i[h*3+2]+=o.getZ(h)*c}return new Ot(i,3)}function lJ(n){var e;const t=oJ(n.scene),i=new Map,a=(e=n.expressionManager)==null?void 0:e.expressionMap;if(a!=null)for(const[r,s]of Object.entries(a)){const o=new Set;for(const c of s.binds)if(c instanceof kx){if(c.weight!==0)for(const h of c.primitives){let f=i.get(h);f==null&&(f=new Map,i.set(h,f));let d=f.get(r);d==null&&(d=new Set,f.set(r,d)),d.add(c)}o.add(c)}for(const c of o)s.deleteBind(c)}for(const r of t){const s=i.get(r);if(s==null)continue;const o=r.geometry.morphAttributes;r.geometry.morphAttributes={};const c=r.geometry.clone();r.geometry=c;const h=c.morphTargetsRelative,f=o.position!=null,d=o.normal!=null,m={},g={},x=[];if(f||d){f&&(m.position=[]),d&&(m.normal=[]);let T=0;for(const[S,v]of s)f&&(m.position[T]=OD(o.position,v,h)),d&&(m.normal[T]=OD(o.normal,v,h)),a==null||a[S].addBind(new kx({index:T,weight:1,primitives:[r]})),g[S]=T,x.push(0),T++}c.morphAttributes=m,r.morphTargetDictionary=g,r.morphTargetInfluences=x}}function Xx(n,e,t){if(n.getComponent)return n.getComponent(e,t);{let i=n.array[e*n.itemSize+t];return n.normalized&&(i=$t.denormalize(i,n.array)),i}}function H8(n,e,t,i){n.setComponent?n.setComponent(e,t,i):(n.normalized&&(i=$t.normalize(i,n.array)),n.array[e*n.itemSize+t]=i)}function cJ(n){var e;const t=uJ(n),i=new Set;for(const d of t)i.has(d.geometry)&&(d.geometry=gJ(d.geometry)),i.add(d.geometry);const a=new Map;for(const d of i){const m=d.getAttribute("skinIndex"),g=(e=a.get(m))!=null?e:new Map;a.set(m,g);const x=d.getAttribute("skinWeight"),T=hJ(m,x);g.set(x,T)}const r=new Map;for(const d of t){const m=fJ(d,a);r.set(d,m)}const s=[];for(const[d,m]of r){let g=!1;for(const x of s)if(dJ(m,x.boneInverseMap)){g=!0,x.meshes.add(d);for(const[S,v]of m)x.boneInverseMap.set(S,v);break}g||s.push({boneInverseMap:m,meshes:new Set([d])})}const o=new Map,c=new U2,h=new U2,f=new U2;for(const d of s){const{boneInverseMap:m,meshes:g}=d,x=Array.from(m.keys()),T=Array.from(m.values()),S=new Ec(x,T),v=h.getOrCreate(S);for(const y of g){const E=y.geometry.getAttribute("skinIndex"),b=c.getOrCreate(E),D=y.skeleton.bones,C=D.map(O=>f.getOrCreate(O)).join(","),I=`${b};${v};${C}`;let P=o.get(I);P==null&&(P=E.clone(),pJ(P,D,x),o.set(I,P)),y.geometry.setAttribute("skinIndex",P)}for(const y of g)y.bind(S,new ke)}}function uJ(n){const e=new Set;return n.traverse(t=>{if(!t.isSkinnedMesh)return;const i=t;e.add(i)}),e}function hJ(n,e){const t=new Set;for(let i=0;i<n.count;i++)for(let a=0;a<n.itemSize;a++){const r=Xx(n,i,a);Xx(e,i,a)!==0&&t.add(r)}return t}function fJ(n,e){const t=new Map,i=n.skeleton,a=n.geometry,r=a.getAttribute("skinIndex"),s=a.getAttribute("skinWeight"),o=e.get(r),c=o==null?void 0:o.get(s);if(!c)throw new Error("Unreachable. attributeUsedIndexSetMap does not know the skin index attribute or the skin weight attribute.");for(const h of c)t.set(i.bones[h],i.boneInverses[h]);return t}function dJ(n,e){for(const[t,i]of n.entries()){const a=e.get(t);if(a!=null&&!mJ(i,a))return!1}return!0}function pJ(n,e,t){const i=new Map;for(const r of e)i.set(r,i.size);const a=new Map;for(const[r,s]of t.entries()){const o=i.get(s);a.set(o,r)}for(let r=0;r<n.count;r++)for(let s=0;s<n.itemSize;s++){const o=Xx(n,r,s),c=a.get(o);H8(n,r,s,c)}n.needsUpdate=!0}function mJ(n,e,t){if(t=t||1e-4,n.elements.length!=e.elements.length)return!1;for(let i=0,a=n.elements.length;i<a;i++)if(Math.abs(n.elements[i]-e.elements[i])>t)return!1;return!0}var U2=class{constructor(){this._objectIndexMap=new Map,this._index=0}get(n){return this._objectIndexMap.get(n)}getOrCreate(n){let e=this._objectIndexMap.get(n);return e==null&&(e=this._index,this._objectIndexMap.set(n,e),this._index++),e}};function gJ(n){var e,t,i,a;const r=new wt;r.name=n.name,r.setIndex(n.index);for(const[s,o]of Object.entries(n.attributes))r.setAttribute(s,o);for(const[s,o]of Object.entries(n.morphAttributes)){const c=s;r.morphAttributes[c]=o.concat()}r.morphTargetsRelative=n.morphTargetsRelative,r.groups=[];for(const s of n.groups)r.addGroup(s.start,s.count,s.materialIndex);return r.boundingSphere=(t=(e=n.boundingSphere)==null?void 0:e.clone())!=null?t:null,r.boundingBox=(a=(i=n.boundingBox)==null?void 0:i.clone())!=null?a:null,r.drawRange.start=n.drawRange.start,r.drawRange.count=n.drawRange.count,r.userData=n.userData,r}function LD(n){if(Object.values(n).forEach(e=>{e!=null&&e.isTexture&&e.dispose()}),n.isShaderMaterial){const e=n.uniforms;e&&Object.values(e).forEach(t=>{const i=t.value;i!=null&&i.isTexture&&i.dispose()})}n.dispose()}function vJ(n){const e=n.geometry;e&&e.dispose();const t=n.skeleton;t&&t.dispose();const i=n.material;i&&(Array.isArray(i)?i.forEach(a=>LD(a)):i&&LD(i))}function _J(n){n.traverse(vJ)}function xJ(n,e){var t,i;console.warn("VRMUtils.removeUnnecessaryJoints: removeUnnecessaryJoints is deprecated. Use combineSkeletons instead. combineSkeletons contributes more to the performance improvement. This function will be removed in the next major version.");const a=(t=e==null?void 0:e.experimentalSameBoneCounts)!=null?t:!1,r=[];n.traverse(c=>{c.type==="SkinnedMesh"&&r.push(c)});const s=new Map;let o=0;for(const c of r){const f=c.geometry.getAttribute("skinIndex");if(s.has(f))continue;const d=new Map,m=new Map;for(let g=0;g<f.count;g++)for(let x=0;x<f.itemSize;x++){const T=Xx(f,g,x);let S=d.get(T);S==null&&(S=d.size,d.set(T,S),m.set(S,T)),H8(f,g,x,S)}f.needsUpdate=!0,s.set(f,m),o=Math.max(o,d.size)}for(const c of r){const f=c.geometry.getAttribute("skinIndex"),d=s.get(f),m=[],g=[],x=a?o:d.size;for(let S=0;S<x;S++){const v=(i=d.get(S))!=null?i:0;m.push(c.skeleton.bones[v]),g.push(c.skeleton.boneInverses[v])}const T=new Ec(m,g);c.bind(T,new ke)}}function yJ(n){const e=new Map;n.traverse(t=>{var i,a,r,s;if(!t.isMesh)return;const o=t,c=o.geometry,h=c.index;if(h==null)return;const f=e.get(c);if(f!=null){o.geometry=f;return}const d=Object.values(c.attributes)[0].count,m=new Array(d);let g=0;const x=h.array;for(let b=0;b<x.length;b++){const D=x[b];m[D]||(m[D]=!0,g++)}if(g===d)return;const T=[],S=[];let v=0;for(let b=0;b<m.length;b++)if(m[b]){const D=v++;T[b]=D,S[D]=b}const y=new wt;y.name=c.name,y.morphTargetsRelative=c.morphTargetsRelative,c.groups.forEach(b=>{y.addGroup(b.start,b.count,b.materialIndex)}),y.boundingBox=(a=(i=c.boundingBox)==null?void 0:i.clone())!=null?a:null,y.boundingSphere=(s=(r=c.boundingSphere)==null?void 0:r.clone())!=null?s:null,y.setDrawRange(c.drawRange.start,c.drawRange.count),y.userData=c.userData,e.set(c,y);{const b=h.array,D=new b.constructor(b.length);for(let C=0;C<b.length;C++){const I=b[C],P=T[I];D[C]=P}y.setIndex(new Ot(D,1,!1))}Object.keys(c.attributes).forEach(b=>{const D=c.attributes[b];if(D.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const C=D.array,{itemSize:I,normalized:P}=D,O=new C.constructor(S.length*I);S.forEach((R,B)=>{for(let j=0;j<I;j++)O[B*I+j]=C[R*I+j]}),y.setAttribute(b,new Ot(O,I,P))});let E=!0;for(const[b,D]of Object.entries(c.morphAttributes)){const C=b;y.morphAttributes[C]=[];for(let I=0;I<D.length;I++){const P=D[I];if(P.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const O=P.array,{itemSize:R,normalized:B}=P,j=new O.constructor(S.length*R);S.forEach((ee,se)=>{for(let re=0;re<R;re++)j[se*R+re]=O[ee*R+re]}),E=E&&j.every(ee=>ee===0),y.morphAttributes[C][I]=new Ot(j,R,B)}}E&&(y.morphAttributes={}),o.geometry=y}),Array.from(e.keys()).forEach(t=>{t.dispose()})}function SJ(n){var e;((e=n.meta)==null?void 0:e.metaVersion)==="0"&&(n.scene.rotation.y=Math.PI)}var fh=class{constructor(){}};fh.combineMorphs=lJ;fh.combineSkeletons=cJ;fh.deepDispose=_J;fh.removeUnnecessaryJoints=xJ;fh.removeUnnecessaryVertices=yJ;fh.rotateVRM0=SJ;/*!
* @pixiv/three-vrm-core v3.4.4
* The implementation of core features of VRM, for @pixiv/three-vrm
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-core is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*//*!
* @pixiv/three-vrm-materials-mtoon v3.4.4
* MToon (toon material) module for @pixiv/three-vrm
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-materials-mtoon is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*//*!
* @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.4
* Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-materials-hdr-emissive-multiplier is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*//*!
* @pixiv/three-vrm-materials-v0compat v3.4.4
* VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-materials-v0compat is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*//*!
* @pixiv/three-vrm-node-constraint v3.4.4
* Node constraint module for @pixiv/three-vrm
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-node-constraint is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*//*!
* @pixiv/three-vrm-springbone v3.4.4
* Spring bone module for @pixiv/three-vrm
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-springbone is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*//*!
* @pixiv/three-vrm-animation v3.4.4
* The implementation of VRM Animation
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-animation is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*/var ID=(n,e,t)=>new Promise((i,a)=>{var r=c=>{try{o(t.next(c))}catch(h){a(h)}},s=c=>{try{o(t.throw(c))}catch(h){a(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,s);o((t=t.apply(n,e)).next())}),TJ={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};new je;new de;new L;new L;var UD={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function EJ(n){return n.invert?n.invert():n.inverse(),n}new L;new L;new L;new L;new L;new L(0,1,0);var MJ=new L,bJ=new L;function AJ(n,e){return n.matrixWorld.decompose(MJ,e,bJ),e}function P2(n){return[Math.atan2(-n.z,n.x),Math.atan2(n.y,Math.sqrt(n.x*n.x+n.z*n.z))]}function PD(n){const e=Math.round(n/2/Math.PI);return n-2*Math.PI*e}var zD=new L(0,0,1),RJ=new L,wJ=new L,CJ=new L,NJ=new Tt,z2=new Tt,BD=new Tt,DJ=new Tt,B2=new Ui,F8=class G8{constructor(e,t){this.offsetFromHeadBone=new L,this.autoUpdate=!0,this.faceFront=new L(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new Tt)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Ui)}getEuler(e){return e.set($t.DEG2RAD*this._pitch,$t.DEG2RAD*this._yaw,0,"YXZ")}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new G8(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){const t=this.humanoid.getRawBoneNode("head");return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){const t=this.humanoid.getRawBoneNode("head");return AJ(t,e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(zD)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,i]=P2(this.faceFront);return B2.set(0,.5*Math.PI+t,i,"YZX"),e.setFromEuler(B2).premultiply(DJ.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(z2),this.getFaceFrontQuaternion(BD),e.copy(zD).applyQuaternion(z2).applyQuaternion(BD).applyEuler(this.getEuler(B2))}lookAt(e){const t=NJ.copy(this._restHeadWorldQuaternion).multiply(EJ(this.getLookAtWorldQuaternion(z2))),i=this.getLookAtWorldPosition(wJ),a=CJ.copy(e).sub(i).applyQuaternion(t).normalize(),[r,s]=P2(this.faceFront),[o,c]=P2(a),h=PD(o-r),f=PD(s-c);this._yaw=$t.RAD2DEG*h,this._pitch=$t.RAD2DEG*f,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(RJ)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};F8.EULER_ORDER="YXZ";var OJ=F8;new L(0,0,1);new Ui(0,0,0,"YXZ");var HD=180/Math.PI,H2=new Ui,FD=class extends Zt{constructor(n){super(),this.vrmLookAt=n,this.type="VRMLookAtQuaternionProxy";const e=this.rotation._onChangeCallback;this.rotation._onChange(()=>{e(),this._applyToLookAt()});const t=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{t(),this._applyToLookAt()})}_applyToLookAt(){H2.setFromQuaternion(this.quaternion,OJ.EULER_ORDER),this.vrmLookAt.yaw=HD*H2.y,this.vrmLookAt.pitch=HD*H2.x}};function LJ(n,e,t){var i,a;const r=new Map,s=new Map;for(const[o,c]of n.humanoidTracks.rotation.entries()){const h=(i=e.getNormalizedBoneNode(o))==null?void 0:i.name;if(h!=null){const f=new vc(`${h}.quaternion`,c.times,c.values.map((d,m)=>t==="0"&&m%2===0?-d:d));s.set(o,f)}}for(const[o,c]of n.humanoidTracks.translation.entries()){const h=(a=e.getNormalizedBoneNode(o))==null?void 0:a.name;if(h!=null){const f=n.restHipsPosition.y,m=e.normalizedRestPose.hips.position[1]/f,g=c.clone();g.values=g.values.map((x,T)=>(t==="0"&&T%3!==1?-x:x)*m),g.name=`${h}.position`,r.set(o,g)}}return{translation:r,rotation:s}}function IJ(n,e){const t=new Map,i=new Map;for(const[a,r]of n.expressionTracks.preset.entries()){const s=e.getExpressionTrackName(a);if(s!=null){const o=r.clone();o.name=s,t.set(a,o)}}for(const[a,r]of n.expressionTracks.custom.entries()){const s=e.getExpressionTrackName(a);if(s!=null){const o=r.clone();o.name=s,i.set(a,o)}}return{preset:t,custom:i}}function UJ(n,e){if(n.lookAtTrack==null)return null;const t=n.lookAtTrack.clone();return t.name=e,t}function PJ(n,e){const t=[],i=LJ(n,e.humanoid,e.meta.metaVersion);if(t.push(...i.translation.values()),t.push(...i.rotation.values()),e.expressionManager!=null){const a=IJ(n,e.expressionManager);t.push(...a.preset.values()),t.push(...a.custom.values())}if(e.lookAt!=null){let a=e.scene.children.find(s=>s instanceof FD);a==null?(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually"),a=new FD(e.lookAt),a.name="VRMLookAtQuaternionProxy",e.scene.add(a)):a.name===""&&(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually"),a.name="VRMLookAtQuaternionProxy");const r=UJ(n,`${a.name}.quaternion`);r!=null&&t.push(r)}return new Ku("Clip",n.duration,t)}var zJ=class{constructor(){this.duration=0,this.restHipsPosition=new L,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function GD(n,e){const t=n.length,i=[];let a=[],r=0;for(let s=0;s<t;s++){const o=n[s];r<=0&&(r=e,a=[],i.push(a)),a.push(o),r--}return i}var BJ=new ke,Kp=new L,F2=new Tt,VD=new Tt,HJ=new Tt,FJ=new Set(["1.0","1.0-draft"]),GJ=new Set(Object.values(TJ)),VJ=class{constructor(n){this.parser=n}get name(){return"VRMC_vrm_animation"}afterRoot(n){return ID(this,null,function*(){var e,t,i;const a=n.parser.json,r=a.extensionsUsed;if(r==null||r.indexOf(this.name)==-1)return;const s=(e=a.extensions)==null?void 0:e[this.name];if(s==null)return;const o=s.specVersion;if(o==null)console.warn("VRMAnimationLoaderPlugin: specVersion of the VRMA is not defined. Consider updating the animation file. Assuming the spec version is 1.0.");else{if(!FJ.has(o)){console.warn(`VRMAnimationLoaderPlugin: Unknown VRMC_vrm_animation spec version: ${o}`);return}o==="1.0-draft"&&console.warn("VRMAnimationLoaderPlugin: Using a draft spec version: 1.0-draft. Some behaviors may be different. Consider updating the animation file.")}const c=this._createNodeMap(s),h=yield this._createBoneWorldMatrixMap(n,s),f=(i=(t=s.humanoid)==null?void 0:t.humanBones.hips)==null?void 0:i.node,d=f!=null?yield n.parser.getDependency("node",f):null,m=new L;d==null||d.getWorldPosition(m),m.y<.001&&console.warn("VRMAnimationLoaderPlugin: The loaded VRM Animation might violate the VRM T-pose (The y component of the rest hips position is approximately zero or below.)");const x=n.animations.map((T,S)=>{const v=a.animations[S],y=this._parseAnimation(T,v,c,h);return y.restHipsPosition=m,y});n.userData.vrmAnimations=x})}_createNodeMap(n){var e,t,i,a,r;const s=new Map,o=new Map,c=(e=n.humanoid)==null?void 0:e.humanBones;c&&Object.entries(c).forEach(([m,g])=>{const x=g==null?void 0:g.node;x!=null&&s.set(x,m)});const h=(t=n.expressions)==null?void 0:t.preset;h&&Object.entries(h).forEach(([m,g])=>{const x=g==null?void 0:g.node;x!=null&&o.set(x,m)});const f=(i=n.expressions)==null?void 0:i.custom;f&&Object.entries(f).forEach(([m,g])=>{const{node:x}=g;o.set(x,m)});const d=(r=(a=n.lookAt)==null?void 0:a.node)!=null?r:null;return{humanoidIndexToName:s,expressionsIndexToName:o,lookAtIndex:d}}_createBoneWorldMatrixMap(n,e){return ID(this,null,function*(){var t,i;n.scene.updateWorldMatrix(!1,!0);const a=yield n.parser.getDependencies("node"),r=new Map;if(e.humanoid==null)return r;for(const[s,o]of Object.entries(e.humanoid.humanBones)){const c=o==null?void 0:o.node;if(c!=null){const h=a[c];r.set(s,h.matrixWorld),s==="hips"&&r.set("hipsParent",(i=(t=h.parent)==null?void 0:t.matrixWorld)!=null?i:BJ)}}return r})}_parseAnimation(n,e,t,i){const a=n.tracks,r=e.channels,s=new zJ;return s.duration=n.duration,r.forEach((o,c)=>{const{node:h,path:f}=o.target,d=a[c];if(h==null)return;const m=t.humanoidIndexToName.get(h);if(m!=null){let x=UD[m];for(;x!=null&&i.get(x)==null;)x=UD[x];if(x==null&&(x="hipsParent"),f==="translation")if(m!=="hips")console.warn(`The loading animation contains a translation track for ${m}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{const T=i.get("hipsParent"),S=GD(d.values,3).flatMap(y=>Kp.fromArray(y).applyMatrix4(T).toArray()),v=d.clone();v.values=new Float32Array(S),s.humanoidTracks.translation.set(m,v)}else if(f==="rotation"){const T=i.get(m),S=i.get(x);T.decompose(Kp,F2,Kp),F2.invert(),S.decompose(Kp,VD,Kp);const v=GD(d.values,4).flatMap(E=>HJ.fromArray(E).premultiply(VD).multiply(F2).toArray()),y=d.clone();y.values=new Float32Array(v),s.humanoidTracks.rotation.set(m,y)}else throw new Error(`Invalid path "${f}"`);return}const g=t.expressionsIndexToName.get(h);if(g!=null){if(f==="translation"){const x=d.times,T=new Float32Array(d.values.length/3);for(let v=0;v<T.length;v++)T[v]=d.values[3*v];const S=new gc(`${g}.weight`,x,T);GJ.has(g)?s.expressionTracks.preset.set(g,S):s.expressionTracks.custom.set(g,S)}else throw new Error(`Invalid path "${f}"`);return}if(h===t.lookAtIndex)if(f==="rotation")s.lookAtTrack=d;else throw new Error(`Invalid path "${f}"`)}),s}};/*!
* @pixiv/three-vrm-core v3.4.4
* The implementation of core features of VRM, for @pixiv/three-vrm
*
* Copyright (c) 2019-2025 pixiv Inc.
* @pixiv/three-vrm-core is distributed under MIT License
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
*/function Yx(){return Yx=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},Yx.apply(null,arguments)}var kJ=Object.defineProperty,WJ=(n,e,t)=>e in n?kJ(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,XJ=(n,e,t)=>(WJ(n,e+"",t),t);class YJ{constructor(){XJ(this,"_listeners")}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const a=this._listeners[e];if(a!==void 0){const r=a.indexOf(t);r!==-1&&a.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const a=i.slice(0);for(let r=0,s=a.length;r<s;r++)a[r].call(this,e);e.target=null}}}var qJ=Object.defineProperty,jJ=(n,e,t)=>e in n?qJ(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Dt=(n,e,t)=>(jJ(n,typeof e!="symbol"?e+"":e,t),t);const Fv=new sh,kD=new Fo,ZJ=Math.cos(70*(Math.PI/180)),WD=(n,e)=>(n%e+e)%e;let KJ=class extends YJ{constructor(e,t){super(),Dt(this,"object"),Dt(this,"domElement"),Dt(this,"enabled",!0),Dt(this,"target",new L),Dt(this,"minDistance",0),Dt(this,"maxDistance",1/0),Dt(this,"minZoom",0),Dt(this,"maxZoom",1/0),Dt(this,"minPolarAngle",0),Dt(this,"maxPolarAngle",Math.PI),Dt(this,"minAzimuthAngle",-1/0),Dt(this,"maxAzimuthAngle",1/0),Dt(this,"enableDamping",!1),Dt(this,"dampingFactor",.05),Dt(this,"enableZoom",!0),Dt(this,"zoomSpeed",1),Dt(this,"enableRotate",!0),Dt(this,"rotateSpeed",1),Dt(this,"enablePan",!0),Dt(this,"panSpeed",1),Dt(this,"screenSpacePanning",!0),Dt(this,"keyPanSpeed",7),Dt(this,"zoomToCursor",!1),Dt(this,"autoRotate",!1),Dt(this,"autoRotateSpeed",2),Dt(this,"reverseOrbit",!1),Dt(this,"reverseHorizontalOrbit",!1),Dt(this,"reverseVerticalOrbit",!1),Dt(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Dt(this,"mouseButtons",{LEFT:mu.ROTATE,MIDDLE:mu.DOLLY,RIGHT:mu.PAN}),Dt(this,"touches",{ONE:gu.ROTATE,TWO:gu.DOLLY_PAN}),Dt(this,"target0"),Dt(this,"position0"),Dt(this,"zoom0"),Dt(this,"_domElementKeyEvents",null),Dt(this,"getPolarAngle"),Dt(this,"getAzimuthalAngle"),Dt(this,"setPolarAngle"),Dt(this,"setAzimuthalAngle"),Dt(this,"getDistance"),Dt(this,"getZoomScale"),Dt(this,"listenToKeyEvents"),Dt(this,"stopListenToKeyEvents"),Dt(this,"saveState"),Dt(this,"reset"),Dt(this,"update"),Dt(this,"connect"),Dt(this,"dispose"),Dt(this,"dollyIn"),Dt(this,"dollyOut"),Dt(this,"getScale"),Dt(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>f.phi,this.getAzimuthalAngle=()=>f.theta,this.setPolarAngle=Q=>{let pe=WD(Q,2*Math.PI),Oe=f.phi;Oe<0&&(Oe+=2*Math.PI),pe<0&&(pe+=2*Math.PI);let q=Math.abs(pe-Oe);2*Math.PI-q<q&&(pe<Oe?pe+=2*Math.PI:Oe+=2*Math.PI),d.phi=pe-Oe,i.update()},this.setAzimuthalAngle=Q=>{let pe=WD(Q,2*Math.PI),Oe=f.theta;Oe<0&&(Oe+=2*Math.PI),pe<0&&(pe+=2*Math.PI);let q=Math.abs(pe-Oe);2*Math.PI-q<q&&(pe<Oe?pe+=2*Math.PI:Oe+=2*Math.PI),d.theta=pe-Oe,i.update()},this.getDistance=()=>i.object.position.distanceTo(i.target),this.listenToKeyEvents=Q=>{Q.addEventListener("keydown",ye),this._domElementKeyEvents=Q},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",ye),this._domElementKeyEvents=null},this.saveState=()=>{i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=()=>{i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(a),i.update(),c=o.NONE},this.update=(()=>{const Q=new L,pe=new L(0,1,0),Oe=new Tt().setFromUnitVectors(e.up,pe),q=Oe.clone().invert(),Ve=new L,me=new Tt,We=2*Math.PI;return function(){const Re=i.object.position;Oe.setFromUnitVectors(e.up,pe),q.copy(Oe).invert(),Q.copy(Re).sub(i.target),Q.applyQuaternion(Oe),f.setFromVector3(Q),i.autoRotate&&c===o.NONE&&se(j()),i.enableDamping?(f.theta+=d.theta*i.dampingFactor,f.phi+=d.phi*i.dampingFactor):(f.theta+=d.theta,f.phi+=d.phi);let rt=i.minAzimuthAngle,yt=i.maxAzimuthAngle;isFinite(rt)&&isFinite(yt)&&(rt<-Math.PI?rt+=We:rt>Math.PI&&(rt-=We),yt<-Math.PI?yt+=We:yt>Math.PI&&(yt-=We),rt<=yt?f.theta=Math.max(rt,Math.min(yt,f.theta)):f.theta=f.theta>(rt+yt)/2?Math.max(rt,f.theta):Math.min(yt,f.theta)),f.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,f.phi)),f.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(g,i.dampingFactor):i.target.add(g),i.zoomToCursor&&O||i.object.isOrthographicCamera?f.radius=nt(f.radius):f.radius=nt(f.radius*m),Q.setFromSpherical(f),Q.applyQuaternion(q),Re.copy(i.target).add(Q),i.object.matrixAutoUpdate||i.object.updateMatrix(),i.object.lookAt(i.target),i.enableDamping===!0?(d.theta*=1-i.dampingFactor,d.phi*=1-i.dampingFactor,g.multiplyScalar(1-i.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let Gt=!1;if(i.zoomToCursor&&O){let Vt=null;if(i.object instanceof ui&&i.object.isPerspectiveCamera){const oi=Q.length();Vt=nt(oi*m);const li=oi-Vt;i.object.position.addScaledVector(I,li),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const oi=new L(P.x,P.y,0);oi.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/m)),i.object.updateProjectionMatrix(),Gt=!0;const li=new L(P.x,P.y,0);li.unproject(i.object),i.object.position.sub(li).add(oi),i.object.updateMatrixWorld(),Vt=Q.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;Vt!==null&&(i.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(Vt).add(i.object.position):(Fv.origin.copy(i.object.position),Fv.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(Fv.direction))<ZJ?e.lookAt(i.target):(kD.setFromNormalAndCoplanarPoint(i.object.up,i.target),Fv.intersectPlane(kD,i.target))))}else i.object instanceof io&&i.object.isOrthographicCamera&&(Gt=m!==1,Gt&&(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/m)),i.object.updateProjectionMatrix()));return m=1,O=!1,Gt||Ve.distanceToSquared(i.object.position)>h||8*(1-me.dot(i.object.quaternion))>h?(i.dispatchEvent(a),Ve.copy(i.object.position),me.copy(i.object.quaternion),Gt=!1,!0):!1}})(),this.connect=Q=>{i.domElement=Q,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",_t),i.domElement.addEventListener("pointerdown",ct),i.domElement.addEventListener("pointercancel",U),i.domElement.addEventListener("wheel",Le)},this.dispose=()=>{var Q,pe,Oe,q,Ve,me;i.domElement&&(i.domElement.style.touchAction="auto"),(Q=i.domElement)==null||Q.removeEventListener("contextmenu",_t),(pe=i.domElement)==null||pe.removeEventListener("pointerdown",ct),(Oe=i.domElement)==null||Oe.removeEventListener("pointercancel",U),(q=i.domElement)==null||q.removeEventListener("wheel",Le),(Ve=i.domElement)==null||Ve.ownerDocument.removeEventListener("pointermove",k),(me=i.domElement)==null||me.ownerDocument.removeEventListener("pointerup",U),i._domElementKeyEvents!==null&&i._domElementKeyEvents.removeEventListener("keydown",ye)};const i=this,a={type:"change"},r={type:"start"},s={type:"end"},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let c=o.NONE;const h=1e-6,f=new hE,d=new hE;let m=1;const g=new L,x=new de,T=new de,S=new de,v=new de,y=new de,E=new de,b=new de,D=new de,C=new de,I=new L,P=new de;let O=!1;const R=[],B={};function j(){return 2*Math.PI/60/60*i.autoRotateSpeed}function ee(){return Math.pow(.95,i.zoomSpeed)}function se(Q){i.reverseOrbit||i.reverseHorizontalOrbit?d.theta+=Q:d.theta-=Q}function re(Q){i.reverseOrbit||i.reverseVerticalOrbit?d.phi+=Q:d.phi-=Q}const W=(()=>{const Q=new L;return function(Oe,q){Q.setFromMatrixColumn(q,0),Q.multiplyScalar(-Oe),g.add(Q)}})(),te=(()=>{const Q=new L;return function(Oe,q){i.screenSpacePanning===!0?Q.setFromMatrixColumn(q,1):(Q.setFromMatrixColumn(q,0),Q.crossVectors(i.object.up,Q)),Q.multiplyScalar(Oe),g.add(Q)}})(),K=(()=>{const Q=new L;return function(Oe,q){const Ve=i.domElement;if(Ve&&i.object instanceof ui&&i.object.isPerspectiveCamera){const me=i.object.position;Q.copy(me).sub(i.target);let We=Q.length();We*=Math.tan(i.object.fov/2*Math.PI/180),W(2*Oe*We/Ve.clientHeight,i.object.matrix),te(2*q*We/Ve.clientHeight,i.object.matrix)}else Ve&&i.object instanceof io&&i.object.isOrthographicCamera?(W(Oe*(i.object.right-i.object.left)/i.object.zoom/Ve.clientWidth,i.object.matrix),te(q*(i.object.top-i.object.bottom)/i.object.zoom/Ve.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function oe(Q){i.object instanceof ui&&i.object.isPerspectiveCamera||i.object instanceof io&&i.object.isOrthographicCamera?m=Q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function ie(Q){oe(m/Q)}function Ce(Q){oe(m*Q)}function Xe(Q){if(!i.zoomToCursor||!i.domElement)return;O=!0;const pe=i.domElement.getBoundingClientRect(),Oe=Q.clientX-pe.left,q=Q.clientY-pe.top,Ve=pe.width,me=pe.height;P.x=Oe/Ve*2-1,P.y=-(q/me)*2+1,I.set(P.x,P.y,1).unproject(i.object).sub(i.object.position).normalize()}function nt(Q){return Math.max(i.minDistance,Math.min(i.maxDistance,Q))}function tt(Q){x.set(Q.clientX,Q.clientY)}function gt(Q){Xe(Q),b.set(Q.clientX,Q.clientY)}function ge(Q){v.set(Q.clientX,Q.clientY)}function Ae(Q){T.set(Q.clientX,Q.clientY),S.subVectors(T,x).multiplyScalar(i.rotateSpeed);const pe=i.domElement;pe&&(se(2*Math.PI*S.x/pe.clientHeight),re(2*Math.PI*S.y/pe.clientHeight)),x.copy(T),i.update()}function Ze(Q){D.set(Q.clientX,Q.clientY),C.subVectors(D,b),C.y>0?ie(ee()):C.y<0&&Ce(ee()),b.copy(D),i.update()}function ue(Q){y.set(Q.clientX,Q.clientY),E.subVectors(y,v).multiplyScalar(i.panSpeed),K(E.x,E.y),v.copy(y),i.update()}function it(Q){Xe(Q),Q.deltaY<0?Ce(ee()):Q.deltaY>0&&ie(ee()),i.update()}function Mt(Q){let pe=!1;switch(Q.code){case i.keys.UP:K(0,i.keyPanSpeed),pe=!0;break;case i.keys.BOTTOM:K(0,-i.keyPanSpeed),pe=!0;break;case i.keys.LEFT:K(i.keyPanSpeed,0),pe=!0;break;case i.keys.RIGHT:K(-i.keyPanSpeed,0),pe=!0;break}pe&&(Q.preventDefault(),i.update())}function ot(){if(R.length==1)x.set(R[0].pageX,R[0].pageY);else{const Q=.5*(R[0].pageX+R[1].pageX),pe=.5*(R[0].pageY+R[1].pageY);x.set(Q,pe)}}function Ke(){if(R.length==1)v.set(R[0].pageX,R[0].pageY);else{const Q=.5*(R[0].pageX+R[1].pageX),pe=.5*(R[0].pageY+R[1].pageY);v.set(Q,pe)}}function Te(){const Q=R[0].pageX-R[1].pageX,pe=R[0].pageY-R[1].pageY,Oe=Math.sqrt(Q*Q+pe*pe);b.set(0,Oe)}function G(){i.enableZoom&&Te(),i.enablePan&&Ke()}function Me(){i.enableZoom&&Te(),i.enableRotate&&ot()}function De(Q){if(R.length==1)T.set(Q.pageX,Q.pageY);else{const Oe=ht(Q),q=.5*(Q.pageX+Oe.x),Ve=.5*(Q.pageY+Oe.y);T.set(q,Ve)}S.subVectors(T,x).multiplyScalar(i.rotateSpeed);const pe=i.domElement;pe&&(se(2*Math.PI*S.x/pe.clientHeight),re(2*Math.PI*S.y/pe.clientHeight)),x.copy(T)}function Fe(Q){if(R.length==1)y.set(Q.pageX,Q.pageY);else{const pe=ht(Q),Oe=.5*(Q.pageX+pe.x),q=.5*(Q.pageY+pe.y);y.set(Oe,q)}E.subVectors(y,v).multiplyScalar(i.panSpeed),K(E.x,E.y),v.copy(y)}function Be(Q){const pe=ht(Q),Oe=Q.pageX-pe.x,q=Q.pageY-pe.y,Ve=Math.sqrt(Oe*Oe+q*q);D.set(0,Ve),C.set(0,Math.pow(D.y/b.y,i.zoomSpeed)),ie(C.y),b.copy(D)}function $e(Q){i.enableZoom&&Be(Q),i.enablePan&&Fe(Q)}function Je(Q){i.enableZoom&&Be(Q),i.enableRotate&&De(Q)}function ct(Q){var pe,Oe;i.enabled!==!1&&(R.length===0&&((pe=i.domElement)==null||pe.ownerDocument.addEventListener("pointermove",k),(Oe=i.domElement)==null||Oe.ownerDocument.addEventListener("pointerup",U)),pt(Q),Q.pointerType==="touch"?vt(Q):ce(Q))}function k(Q){i.enabled!==!1&&(Q.pointerType==="touch"?qe(Q):Ee(Q))}function U(Q){var pe,Oe,q;Ie(Q),R.length===0&&((pe=i.domElement)==null||pe.releasePointerCapture(Q.pointerId),(Oe=i.domElement)==null||Oe.ownerDocument.removeEventListener("pointermove",k),(q=i.domElement)==null||q.ownerDocument.removeEventListener("pointerup",U)),i.dispatchEvent(s),c=o.NONE}function ce(Q){let pe;switch(Q.button){case 0:pe=i.mouseButtons.LEFT;break;case 1:pe=i.mouseButtons.MIDDLE;break;case 2:pe=i.mouseButtons.RIGHT;break;default:pe=-1}switch(pe){case mu.DOLLY:if(i.enableZoom===!1)return;gt(Q),c=o.DOLLY;break;case mu.ROTATE:if(Q.ctrlKey||Q.metaKey||Q.shiftKey){if(i.enablePan===!1)return;ge(Q),c=o.PAN}else{if(i.enableRotate===!1)return;tt(Q),c=o.ROTATE}break;case mu.PAN:if(Q.ctrlKey||Q.metaKey||Q.shiftKey){if(i.enableRotate===!1)return;tt(Q),c=o.ROTATE}else{if(i.enablePan===!1)return;ge(Q),c=o.PAN}break;default:c=o.NONE}c!==o.NONE&&i.dispatchEvent(r)}function Ee(Q){if(i.enabled!==!1)switch(c){case o.ROTATE:if(i.enableRotate===!1)return;Ae(Q);break;case o.DOLLY:if(i.enableZoom===!1)return;Ze(Q);break;case o.PAN:if(i.enablePan===!1)return;ue(Q);break}}function Le(Q){i.enabled===!1||i.enableZoom===!1||c!==o.NONE&&c!==o.ROTATE||(Q.preventDefault(),i.dispatchEvent(r),it(Q),i.dispatchEvent(s))}function ye(Q){i.enabled===!1||i.enablePan===!1||Mt(Q)}function vt(Q){switch(He(Q),R.length){case 1:switch(i.touches.ONE){case gu.ROTATE:if(i.enableRotate===!1)return;ot(),c=o.TOUCH_ROTATE;break;case gu.PAN:if(i.enablePan===!1)return;Ke(),c=o.TOUCH_PAN;break;default:c=o.NONE}break;case 2:switch(i.touches.TWO){case gu.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;G(),c=o.TOUCH_DOLLY_PAN;break;case gu.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Me(),c=o.TOUCH_DOLLY_ROTATE;break;default:c=o.NONE}break;default:c=o.NONE}c!==o.NONE&&i.dispatchEvent(r)}function qe(Q){switch(He(Q),c){case o.TOUCH_ROTATE:if(i.enableRotate===!1)return;De(Q),i.update();break;case o.TOUCH_PAN:if(i.enablePan===!1)return;Fe(Q),i.update();break;case o.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;$e(Q),i.update();break;case o.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Je(Q),i.update();break;default:c=o.NONE}}function _t(Q){i.enabled!==!1&&Q.preventDefault()}function pt(Q){R.push(Q)}function Ie(Q){delete B[Q.pointerId];for(let pe=0;pe<R.length;pe++)if(R[pe].pointerId==Q.pointerId){R.splice(pe,1);return}}function He(Q){let pe=B[Q.pointerId];pe===void 0&&(pe=new de,B[Q.pointerId]=pe),pe.set(Q.pageX,Q.pageY)}function ht(Q){const pe=Q.pointerId===R[0].pointerId?R[1]:R[0];return B[pe.pointerId]}this.dollyIn=(Q=ee())=>{Ce(Q),i.update()},this.dollyOut=(Q=ee())=>{ie(Q),i.update()},this.getScale=()=>m,this.setScale=Q=>{oe(Q),i.update()},this.getZoomScale=()=>ee(),t!==void 0&&this.connect(t),this.update()}};function QJ(n,e,t){const i=Qi(g=>g.size),a=Qi(g=>g.viewport),r=typeof n=="number"?n:i.width*a.dpr,s=i.height*a.dpr,o=(typeof n=="number"?t:n)||{},{samples:c=0,depth:h,...f}=o,d=h??o.depthBuffer,m=be.useMemo(()=>{const g=new _i(r,s,{minFilter:Ht,magFilter:Ht,type:Xn,...f});return d&&(g.depthTexture=new U0(r,s,ri)),g.samples=c,g},[]);return be.useLayoutEffect(()=>{m.setSize(r,s),c&&(m.samples=c)},[c,m,r,s]),be.useEffect(()=>()=>m.dispose(),[]),m}const JJ=n=>typeof n=="function",V8=be.forwardRef(({envMap:n,resolution:e=256,frames:t=1/0,makeDefault:i,children:a,...r},s)=>{const o=Qi(({set:S})=>S),c=Qi(({camera:S})=>S),h=Qi(({size:S})=>S),f=be.useRef(null);be.useImperativeHandle(s,()=>f.current,[]);const d=be.useRef(null),m=QJ(e);be.useLayoutEffect(()=>{r.manual||(f.current.aspect=h.width/h.height)},[h,r]),be.useLayoutEffect(()=>{f.current.updateProjectionMatrix()});let g=0,x=null;const T=JJ(a);return Ac(S=>{T&&(t===1/0||g<t)&&(d.current.visible=!1,S.gl.setRenderTarget(m),x=S.scene.background,n&&(S.scene.background=n),S.gl.render(S.scene,f.current),S.scene.background=x,S.gl.setRenderTarget(null),d.current.visible=!0,g++)}),be.useLayoutEffect(()=>{if(i){const S=c;return o(()=>({camera:f.current})),()=>o(()=>({camera:S}))}},[f,i,o]),be.createElement(be.Fragment,null,be.createElement("perspectiveCamera",Yx({ref:f},r),!T&&a),be.createElement("group",{ref:d},T&&a(m.texture)))}),$J=be.forwardRef(({makeDefault:n,camera:e,regress:t,domElement:i,enableDamping:a=!0,keyEvents:r=!1,onChange:s,onStart:o,onEnd:c,...h},f)=>{const d=Qi(C=>C.invalidate),m=Qi(C=>C.camera),g=Qi(C=>C.gl),x=Qi(C=>C.events),T=Qi(C=>C.setEvents),S=Qi(C=>C.set),v=Qi(C=>C.get),y=Qi(C=>C.performance),E=e||m,b=i||x.connected||g.domElement,D=be.useMemo(()=>new KJ(E),[E]);return Ac(()=>{D.enabled&&D.update()},-1),be.useEffect(()=>(r&&D.connect(r===!0?b:r),D.connect(b),()=>void D.dispose()),[r,b,t,D,d]),be.useEffect(()=>{const C=O=>{d(),t&&y.regress(),s&&s(O)},I=O=>{o&&o(O)},P=O=>{c&&c(O)};return D.addEventListener("change",C),D.addEventListener("start",I),D.addEventListener("end",P),()=>{D.removeEventListener("start",I),D.removeEventListener("end",P),D.removeEventListener("change",C)}},[s,o,c,D,d,T]),be.useEffect(()=>{if(n){const C=v().controls;return S({controls:D}),()=>S({controls:C})}},[n,D]),be.createElement("primitive",Yx({ref:f,object:D,enableDamping:a},h))});/**
* postprocessing v6.38.0 build Sat Nov 08 2025
* https://github.com/pmndrs/postprocessing
* Copyright 2015-2025 Raoul van Rüschen
* @license Zlib
*/var G2=1/1e3,e$=1e3,t$=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(n){typeof document<"u"&&document.hidden!==void 0&&(n?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=n)}get delta(){return this._delta*G2}get fixedDelta(){return this._fixedDelta*G2}set fixedDelta(n){this._fixedDelta=n*e$}get elapsed(){return this._elapsed*G2}update(n){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(n!==void 0?n:performance.now())-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(n){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},n$=(()=>{const n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]),t=new wt;return t.setAttribute("position",new Ot(n,3)),t.setAttribute("uv",new Ot(e,2)),t})(),Pa=class NE{static get fullscreenGeometry(){return n$}constructor(e="Pass",t=new Ad,i=new io){this.name=e,this.renderer=null,this.scene=t,this.camera=i,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){const t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;t!==null?t.material=e:(t=new si(NE.fullscreenGeometry,e),t.frustumCulled=!1,this.scene===null&&(this.scene=new Ad),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=Sc){}render(e,t,i,a,r){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,i){}dispose(){for(const e of Object.keys(this)){const t=this[e];(t instanceof _i||t instanceof qn||t instanceof Nn||t instanceof NE)&&this[e].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},i$=class extends Pa{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(n,e,t,i,a){const r=n.state.buffers.stencil;r.setLocked(!1),r.setTest(!1)}},a$=`#ifdef COLOR_WRITE
#include <common>
#include <dithering_pars_fragment>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#endif
#ifdef DEPTH_WRITE
#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}
#endif
#ifdef USE_WEIGHTS
uniform vec4 channelWeights;
#endif
uniform float opacity;varying vec2 vUv;void main(){
#ifdef COLOR_WRITE
vec4 texel=texture2D(inputBuffer,vUv);
#ifdef USE_WEIGHTS
texel*=channelWeights;
#endif
gl_FragColor=opacity*texel;
#ifdef COLOR_SPACE_CONVERSION
#include <colorspace_fragment>
#endif
#include <dithering_fragment>
#else
gl_FragColor=vec4(0.0);
#endif
#ifdef DEPTH_WRITE
gl_FragDepth=readDepth(vUv);
#endif
}`,iA="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",r$=class extends Fi{constructor(){super({name:"CopyMaterial",defines:{DEPTH_PACKING:"0",COLOR_WRITE:"1"},uniforms:{inputBuffer:new J(null),depthBuffer:new J(null),channelWeights:new J(null),opacity:new J(1)},blending:Sa,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:a$,vertexShader:iA}),this.depthFunc=i0}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(n){const e=n!==null;this.colorWrite!==e&&(e?this.defines.COLOR_WRITE=!0:delete this.defines.COLOR_WRITE,this.colorWrite=e,this.needsUpdate=!0),this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){const e=n!==null;this.depthWrite!==e&&(e?this.defines.DEPTH_WRITE=!0:delete this.defines.DEPTH_WRITE,this.depthTest=e,this.depthWrite=e,this.needsUpdate=!0),this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}get channelWeights(){return this.uniforms.channelWeights.value}set channelWeights(n){n!==null?(this.defines.USE_WEIGHTS="1",this.uniforms.channelWeights.value=n):delete this.defines.USE_WEIGHTS,this.needsUpdate=!0}setInputBuffer(n){this.uniforms.inputBuffer.value=n}getOpacity(n){return this.uniforms.opacity.value}setOpacity(n){this.uniforms.opacity.value=n}},k8=class extends Pa{constructor(n,e=!0){super("CopyPass"),this.fullscreenMaterial=new r$,this.needsSwap=!1,this.renderTarget=n,n===void 0&&(this.renderTarget=new _i(1,1,{minFilter:Ht,magFilter:Ht,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=e}get resize(){return this.autoResize}set resize(n){this.autoResize=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(n){this.autoResize=n}render(n,e,t,i,a){this.fullscreenMaterial.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){this.autoResize&&this.renderTarget.setSize(n,e)}initialize(n,e,t){t!==void 0&&(this.renderTarget.texture.type=t,t!==Ii?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":n!==null&&n.outputColorSpace===En&&(this.renderTarget.texture.colorSpace=En))}},XD=new je,W8=class extends Pa{constructor(n=!0,e=!0,t=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=n,this.depth=e,this.stencil=t,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(n,e,t){this.color=n,this.depth=e,this.stencil=t}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(n){this.overrideClearColor=n}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(n){this.overrideClearAlpha=n}render(n,e,t,i,a){const r=this.overrideClearColor,s=this.overrideClearAlpha,o=n.getClearAlpha(),c=r!==null,h=s>=0;c?(n.getClearColor(XD),n.setClearColor(r,h?s:o)):h&&n.setClearAlpha(s),n.setRenderTarget(this.renderToScreen?null:e),n.clear(this.color,this.depth,this.stencil),c?n.setClearColor(XD,o):h&&n.setClearAlpha(o)}},s$=class extends Pa{constructor(n,e){super("MaskPass",n,e),this.needsSwap=!1,this.clearPass=new W8(!1,!1,!0),this.inverse=!1}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get inverted(){return this.inverse}set inverted(n){this.inverse=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(n){this.inverted=n}render(n,e,t,i,a){const r=n.getContext(),s=n.state.buffers,o=this.scene,c=this.camera,h=this.clearPass,f=this.inverted?0:1,d=1-f;s.color.setMask(!1),s.depth.setMask(!1),s.color.setLocked(!0),s.depth.setLocked(!0),s.stencil.setTest(!0),s.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.stencil.setFunc(r.ALWAYS,f,4294967295),s.stencil.setClear(d),s.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?h.render(n,null):(h.render(n,e),h.render(n,t))),this.renderToScreen?(n.setRenderTarget(null),n.render(o,c)):(n.setRenderTarget(e),n.render(o,c),n.setRenderTarget(t),n.render(o,c)),s.color.setLocked(!1),s.depth.setLocked(!1),s.stencil.setLocked(!1),s.stencil.setFunc(r.EQUAL,1,4294967295),s.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.stencil.setLocked(!0)}},o$=class{constructor(n=null,{depthBuffer:e=!0,stencilBuffer:t=!1,multisampling:i=0,frameBufferType:a}={}){this.renderer=null,this.inputBuffer=this.createBuffer(e,t,a,i),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new k8,this.depthTexture=null,this.passes=[],this.timer=new t$,this.autoRenderToScreen=!0,this.setRenderer(n)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(n){const e=this.inputBuffer,t=this.multisampling;t>0&&n>0?(this.inputBuffer.samples=n,this.outputBuffer.samples=n,this.inputBuffer.dispose(),this.outputBuffer.dispose()):t!==n&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,n),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(n){if(this.renderer=n,n!==null){const e=n.getSize(new de),t=n.getContext().getContextAttributes().alpha,i=this.inputBuffer.texture.type;i===Ii&&n.outputColorSpace===En&&(this.inputBuffer.texture.colorSpace=En,this.outputBuffer.texture.colorSpace=En,this.inputBuffer.dispose(),this.outputBuffer.dispose()),n.autoClear=!1,this.setSize(e.width,e.height);for(const a of this.passes)a.initialize(n,t,i)}}replaceRenderer(n,e=!0){const t=this.renderer,i=t.domElement.parentNode;return this.setRenderer(n),e&&i!==null&&(i.removeChild(t.domElement),i.appendChild(n.domElement)),t}createDepthTexture(){const n=this.depthTexture=new U0;return this.inputBuffer.depthTexture=n,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(n.format=Yu,n.type=Xu):n.type=Ns,n}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(const n of this.passes)n.setDepthTexture(null)}}createBuffer(n,e,t,i){const a=this.renderer,r=a===null?new de:a.getDrawingBufferSize(new de),s={minFilter:Ht,magFilter:Ht,stencilBuffer:e,depthBuffer:n,type:t},o=new _i(r.width,r.height,s);return i>0&&(o.samples=i),t===Ii&&a!==null&&a.outputColorSpace===En&&(o.texture.colorSpace=En),o.texture.name="EffectComposer.Buffer",o.texture.generateMipmaps=!1,o}setMainScene(n){for(const e of this.passes)e.mainScene=n}setMainCamera(n){for(const e of this.passes)e.mainCamera=n}addPass(n,e){const t=this.passes,i=this.renderer,a=i.getDrawingBufferSize(new de),r=i.getContext().getContextAttributes().alpha,s=this.inputBuffer.texture.type;if(n.setRenderer(i),n.setSize(a.width,a.height),n.initialize(i,r,s),this.autoRenderToScreen&&(t.length>0&&(t[t.length-1].renderToScreen=!1),n.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?t.splice(e,0,n):t.push(n),this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!0),n.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){const o=this.createDepthTexture();for(n of t)n.setDepthTexture(o)}else n.setDepthTexture(this.depthTexture)}removePass(n){const e=this.passes,t=e.indexOf(n);if(t!==-1&&e.splice(t,1).length>0){if(this.depthTexture!==null){const r=(o,c)=>o||c.needsDepthTexture;e.reduce(r,!1)||(n.getDepthTexture()===this.depthTexture&&n.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&t===e.length&&(n.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){const n=this.passes;this.deleteDepthTexture(),n.length>0&&(this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!1),this.passes=[])}render(n){const e=this.renderer,t=this.copyPass;let i=this.inputBuffer,a=this.outputBuffer,r=!1,s,o,c;n===void 0&&(this.timer.update(),n=this.timer.getDelta());for(const h of this.passes)h.enabled&&(h.render(e,i,a,n,r),h.needsSwap&&(r&&(t.renderToScreen=h.renderToScreen,s=e.getContext(),o=e.state.buffers.stencil,o.setFunc(s.NOTEQUAL,1,4294967295),t.render(e,i,a,n,r),o.setFunc(s.EQUAL,1,4294967295)),c=i,i=a,a=c),h instanceof s$?r=!0:h instanceof i$&&(r=!1))}setSize(n,e,t){const i=this.renderer,a=i.getSize(new de);(n===void 0||e===void 0)&&(n=a.width,e=a.height),(a.width!==n||a.height!==e)&&i.setSize(n,e,t);const r=i.getDrawingBufferSize(new de);this.inputBuffer.setSize(r.width,r.height),this.outputBuffer.setSize(r.width,r.height);for(const s of this.passes)s.setSize(r.width,r.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(const n of this.passes)n.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),Pa.fullscreenGeometry.dispose()}},Jo={NONE:0,DEPTH:1,CONVOLUTION:2},_n={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},l$=class{constructor(){this.shaderParts=new Map([[_n.FRAGMENT_HEAD,null],[_n.FRAGMENT_MAIN_UV,null],[_n.FRAGMENT_MAIN_IMAGE,null],[_n.VERTEX_HEAD,null],[_n.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=Jo.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=Wn}},V2=!1,YD=class{constructor(n=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(n),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case la:t=this.materialsFlatShadedDoubleSide;break;case Oi:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case la:t=this.materialsDoubleSide;break;case Oi:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(n){if(!(n instanceof Fi))return n.clone();const e=n.uniforms,t=new Map;for(const a in e){const r=e[a].value;r.isRenderTargetTexture&&(e[a].value=null,t.set(a,r))}const i=n.clone();for(const a of t)e[a[0]].value=a[1],i.uniforms[a[0]].value=a[1];return i}setMaterial(n){if(this.disposeMaterials(),this.material=n,n!==null){const e=this.materials=[this.cloneMaterial(n),this.cloneMaterial(n),this.cloneMaterial(n)];for(const t of e)t.uniforms=Object.assign({},n.uniforms),t.side=Cs;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=Oi,i}),this.materialsDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=la,i}),this.materialsFlatShaded=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i}),this.materialsFlatShadedBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=Oi,i}),this.materialsFlatShadedDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=la,i})}}render(n,e,t){const i=n.shadowMap.enabled;if(n.shadowMap.enabled=!1,V2){const a=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),n.render(e,t);for(const r of a)r[0].material=r[1];this.meshCount!==a.size&&a.clear()}else{const a=e.overrideMaterial;e.overrideMaterial=this.material,n.render(e,t),e.overrideMaterial=a}n.shadowMap.enabled=i}disposeMaterials(){if(this.material!==null){const n=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(const e of n)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return V2}static set workaroundEnabled(n){V2=n}},Il=-1,as=class extends tr{constructor(n,e=Il,t=Il,i=1){super(),this.resizable=n,this.baseSize=new de(1,1),this.preferredSize=new de(e,t),this.target=this.preferredSize,this.s=i,this.effectiveSize=new de,this.addEventListener("change",()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){const n=this.baseSize,e=this.preferredSize,t=this.effectiveSize,i=this.scale;e.width!==Il?t.width=e.width:e.height!==Il?t.width=Math.round(e.height*(n.width/Math.max(n.height,1))):t.width=Math.round(n.width*i),e.height!==Il?t.height=e.height:e.width!==Il?t.height=Math.round(e.width/Math.max(n.width/Math.max(n.height,1),1)):t.height=Math.round(n.height*i)}get width(){return this.effectiveSize.width}set width(n){this.preferredWidth=n}get height(){return this.effectiveSize.height}set height(n){this.preferredHeight=n}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(n){this.s!==n&&(this.s=n,this.preferredSize.setScalar(Il),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(n){this.scale=n}get baseWidth(){return this.baseSize.width}set baseWidth(n){this.baseSize.width!==n&&(this.baseSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(n){this.baseWidth=n}get baseHeight(){return this.baseSize.height}set baseHeight(n){this.baseSize.height!==n&&(this.baseSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(n){this.baseHeight=n}setBaseSize(n,e){(this.baseSize.width!==n||this.baseSize.height!==e)&&(this.baseSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(n){this.preferredSize.width!==n&&(this.preferredSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(n){this.preferredWidth=n}get preferredHeight(){return this.preferredSize.height}set preferredHeight(n){this.preferredSize.height!==n&&(this.preferredSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(n){this.preferredHeight=n}setPreferredSize(n,e){(this.preferredSize.width!==n||this.preferredSize.height!==e)&&(this.preferredSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(n){this.s=n.scale,this.baseSize.set(n.baseWidth,n.baseHeight),this.preferredSize.set(n.preferredWidth,n.preferredHeight),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return Il}},ln={ADD:0,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},c$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb,y.a),y.a*opacity);}",u$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb)*0.5,y.a),y.a*opacity);}",h$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.xy,xHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}",f$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/b)),vec3(1.0),step(1.0,a));return mix(x,vec4(z,y.a),y.a*opacity);}",d$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(x,vec4(z,y.a),y.a*opacity);}",p$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb,y.rgb),y.a),y.a*opacity);}",m$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(abs(x.rgb-y.rgb),y.a),y.a*opacity);}",g$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb/max(y.rgb,1e-12),y.a),y.a*opacity);}",v$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb-2.0*x.rgb*y.rgb),y.a),y.a*opacity);}",_$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=min(x.rgb,1.0);vec3 b=min(y.rgb,1.0);vec3 z=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(x,vec4(z,y.a),y.a*opacity);}",x$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(step(1.0,x.rgb+y.rgb),y.a),y.a*opacity);}",y$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.x,xHSL.yz));return mix(x,vec4(z,y.a),y.a*opacity);}",S$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-y.rgb,y.a),y.a*opacity);}",T$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(y.rgb*(1.0-x.rgb),y.a),y.a*opacity);}",E$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb,y.rgb),y.a),y.a*opacity);}",M$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(y.rgb+x.rgb-1.0,0.0,1.0),y.a),y.a*opacity);}",b$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb+y.rgb,1.0),y.a),y.a*opacity);}",A$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(2.0*y.rgb+x.rgb-1.0,0.0,1.0),y.a),y.a*opacity);}",R$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.xy,yHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}",w$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb*y.rgb,y.a),y.a*opacity);}",C$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-abs(1.0-x.rgb-y.rgb),y.a),y.a*opacity);}",N$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,y.a*opacity);}",D$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(2.0*y.rgb*x.rgb,1.0-2.0*(1.0-y.rgb)*(1.0-x.rgb),step(0.5,x.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}",O$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 y2=2.0*y.rgb;vec3 z=mix(mix(y2,x.rgb,step(0.5*x.rgb,y.rgb)),max(y2-1.0,vec3(0.0)),step(x.rgb,y2-1.0));return mix(x,vec4(z,y.a),y.a*opacity);}",L$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(min(x.rgb*x.rgb/max(1.0-y.rgb,1e-12),1.0),y.rgb,step(1.0,y.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}",I$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.x,yHSL.y,xHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}",U$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb-min(x.rgb*y.rgb,1.0),y.a),y.a*opacity);}",P$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb;vec3 b=y.rgb;vec3 y2=2.0*b;vec3 w=step(0.5,b);vec3 c=a-(1.0-y2)*a*(1.0-a);vec3 d=mix(a+(y2-1.0)*(sqrt(a)-a),a+(y2-1.0)*a*((16.0*a-12.0)*a+3.0),w*(1.0-step(0.25,a)));vec3 z=mix(c,d,w);return mix(x,vec4(z,y.a),y.a*opacity);}",z$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}",B$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb+y.rgb-1.0,0.0),y.a),y.a*opacity);}",H$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(max(1.0-min((1.0-x.rgb)/(2.0*y.rgb),1.0),0.0),min(x.rgb/(2.0*(1.0-y.rgb)),1.0),step(0.5,y.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}",F$=new Map([[ln.ADD,c$],[ln.AVERAGE,u$],[ln.COLOR,h$],[ln.COLOR_BURN,f$],[ln.COLOR_DODGE,d$],[ln.DARKEN,p$],[ln.DIFFERENCE,m$],[ln.DIVIDE,g$],[ln.DST,null],[ln.EXCLUSION,v$],[ln.HARD_LIGHT,_$],[ln.HARD_MIX,x$],[ln.HUE,y$],[ln.INVERT,S$],[ln.INVERT_RGB,T$],[ln.LIGHTEN,E$],[ln.LINEAR_BURN,M$],[ln.LINEAR_DODGE,b$],[ln.LINEAR_LIGHT,A$],[ln.LUMINOSITY,R$],[ln.MULTIPLY,w$],[ln.NEGATION,C$],[ln.NORMAL,N$],[ln.OVERLAY,D$],[ln.PIN_LIGHT,O$],[ln.REFLECT,L$],[ln.SATURATION,I$],[ln.SCREEN,U$],[ln.SOFT_LIGHT,P$],[ln.SRC,z$],[ln.SUBTRACT,B$],[ln.VIVID_LIGHT,H$]]),G$=class extends tr{constructor(n,e=1){super(),this._blendFunction=n,this.opacity=new J(e)}getOpacity(){return this.opacity.value}setOpacity(n){this.opacity.value=n}get blendFunction(){return this._blendFunction}set blendFunction(n){this._blendFunction=n,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(n){this.blendFunction=n}getShaderCode(){return F$.get(this.blendFunction)}},m0=class extends tr{constructor(n,e,{attributes:t=Jo.NONE,blendFunction:i=ln.NORMAL,defines:a=new Map,uniforms:r=new Map,extensions:s=null,vertexShader:o=null}={}){super(),this.name=n,this.renderer=null,this.attributes=t,this.fragmentShader=e,this.vertexShader=o,this.defines=a,this.uniforms=r,this.extensions=s,this.blendMode=new G$(i),this.blendMode.addEventListener("change",c=>this.setChanged()),this._inputColorSpace=Wn,this._outputColorSpace=Na}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(n){this._inputColorSpace=n,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n,this.setChanged()}set mainScene(n){}set mainCamera(n){}getName(){return this.name}setRenderer(n){this.renderer=n}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(n){this.attributes=n,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(n){this.fragmentShader=n,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(n){this.vertexShader=n,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(n,e=Sc){}update(n,e,t){}setSize(n,e){}initialize(n,e,t){}dispose(){for(const n of Object.keys(this)){const e=this[n];(e instanceof _i||e instanceof qn||e instanceof Nn||e instanceof Pa)&&this[n].dispose()}}},V$=`#include <common>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef RANGE
uniform vec2 range;
#elif defined(THRESHOLD)
uniform float threshold;uniform float smoothing;
#endif
varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);float mask=1.0;
#ifdef RANGE
float low=step(range.x,l);float high=step(l,range.y);mask=low*high;
#elif defined(THRESHOLD)
mask=smoothstep(threshold,threshold+smoothing,l);
#endif
#ifdef COLOR
gl_FragColor=texel*mask;
#else
gl_FragColor=vec4(l*mask);
#endif
}`,k$=class extends Fi{constructor(n=!1,e=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:ws.replace(/\D+/g,"")},uniforms:{inputBuffer:new J(null),threshold:new J(0),smoothing:new J(1),range:new J(null)},blending:Sa,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:V$,vertexShader:iA}),this.colorOutput=n,this.luminanceRange=e}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get threshold(){return this.uniforms.threshold.value}set threshold(n){this.smoothing>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=n}getThreshold(){return this.threshold}setThreshold(n){this.threshold=n}get smoothing(){return this.uniforms.smoothing.value}set smoothing(n){this.threshold>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=n}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(n){this.smoothing=n}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(n){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(n){n?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(n){return this.colorOutput}setColorOutputEnabled(n){this.colorOutput=n}get useRange(){return this.luminanceRange!==null}set useRange(n){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(n){n!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=n,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(n){this.luminanceRange=n}},W$=class extends Pa{constructor({renderTarget:n,luminanceRange:e,colorOutput:t,resolutionScale:i=1,width:a=as.AUTO_SIZE,height:r=as.AUTO_SIZE,resolutionX:s=a,resolutionY:o=r}={}){super("LuminancePass"),this.fullscreenMaterial=new k$(t,e),this.needsSwap=!1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new _i(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");const c=this.resolution=new as(this,s,o,i);c.addEventListener("change",h=>this.setSize(c.baseWidth,c.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(n,e,t,i,a){const r=this.fullscreenMaterial;r.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}initialize(n,e,t){t!==void 0&&t!==Ii&&(this.renderTarget.texture.type=t,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},DE=class extends Pa{constructor(n,e="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=n,this.input=e}setInput(n){this.input=n}render(n,e,t,i,a){const r=this.fullscreenMaterial.uniforms;e!==null&&r!==void 0&&r[this.input]!==void 0&&(r[this.input].value=e.texture),n.setRenderTarget(this.renderToScreen?null:t),n.render(this.scene,this.camera)}initialize(n,e,t){t!==void 0&&t!==Ii&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},aA=class extends Pa{constructor(n,e,t=null){super("RenderPass",n,e),this.needsSwap=!1,this.clearPass=new W8,this.overrideMaterialManager=t===null?null:new YD(t),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get renderToScreen(){return super.renderToScreen}set renderToScreen(n){super.renderToScreen=n,this.clearPass.renderToScreen=n}get overrideMaterial(){const n=this.overrideMaterialManager;return n!==null?n.material:null}set overrideMaterial(n){const e=this.overrideMaterialManager;n!==null?e!==null?e.setMaterial(n):this.overrideMaterialManager=new YD(n):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(n){this.overrideMaterial=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getSelection(){return this.selection}setSelection(n){this.selection=n}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(n){this.ignoreBackground=n}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(n){this.skipShadowMapUpdate=n}getClearPass(){return this.clearPass}render(n,e,t,i,a){const r=this.scene,s=this.camera,o=this.selection,c=s.layers.mask,h=r.background,f=n.shadowMap.autoUpdate,d=this.renderToScreen?null:e;o!==null&&s.layers.set(o.getLayer()),this.skipShadowMapUpdate&&(n.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(r.background=null),this.clearPass.enabled&&this.clearPass.render(n,e),n.setRenderTarget(d),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(n,r,s):n.render(r,s),s.layers.mask=c,r.background=h,n.shadowMap.autoUpdate=f}},Ya={LINEAR:0,REINHARD:1,REINHARD2:2,REINHARD2_ADAPTIVE:3,OPTIMIZED_CINEON:5,CINEON:5,ACES_FILMIC:6,AGX:7,NEUTRAL:8},X$=`#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
#ifdef DOWNSAMPLE_NORMALS
uniform lowp sampler2D normalBuffer;
#endif
varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]<maxDistance){remaining[j++]=i;}else{rejected[k++]=i;}}for(;j<3;++j){remaining[j]=rejected[--k];}vec3 s=vec3(samples[remaining[0]],samples[remaining[1]],samples[remaining[2]]);c=(s.x+s.y+s.z)/3.0;distances[0]=abs(c-s.x);distances[1]=abs(c-s.y);distances[2]=abs(c-s.z);float minDistance=min(distances[0],min(distances[1],distances[2]));for(i=0;i<3;++i){if(distances[i]==minDistance){break;}}return remaining[i];}void main(){float d[4];d[0]=readDepth(vUv0);d[1]=readDepth(vUv1);d[2]=readDepth(vUv2);d[3]=readDepth(vUv3);int index=findBestDepth(d);
#ifdef DOWNSAMPLE_NORMALS
vec3 n[4];n[0]=texture2D(normalBuffer,vUv0).rgb;n[1]=texture2D(normalBuffer,vUv1).rgb;n[2]=texture2D(normalBuffer,vUv2).rgb;n[3]=texture2D(normalBuffer,vUv3).rgb;
#else
vec3 n[4];n[0]=vec3(0.0);n[1]=vec3(0.0);n[2]=vec3(0.0);n[3]=vec3(0.0);
#endif
gl_FragColor=vec4(n[index],d[index]);}`,Y$="uniform vec2 texelSize;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vUv0=uv;vUv1=vec2(uv.x,uv.y+texelSize.y);vUv2=vec2(uv.x+texelSize.x,uv.y);vUv3=uv+texelSize;gl_Position=vec4(position.xy,1.0,1.0);}",q$=class extends Fi{constructor(){super({name:"DepthDownsamplingMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new J(null),normalBuffer:new J(null),texelSize:new J(new de)},blending:Sa,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:X$,vertexShader:Y$})}set depthBuffer(n){this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=Sc){this.depthBuffer=n,this.depthPacking=e}set normalBuffer(n){this.uniforms.normalBuffer.value=n,n!==null?this.defines.DOWNSAMPLE_NORMALS="1":delete this.defines.DOWNSAMPLE_NORMALS,this.needsUpdate=!0}setNormalBuffer(n){this.normalBuffer=n}setTexelSize(n,e){this.uniforms.texelSize.value.set(n,e)}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},j$=class extends Pa{constructor({normalBuffer:n=null,resolutionScale:e=.5,width:t=as.AUTO_SIZE,height:i=as.AUTO_SIZE,resolutionX:a=t,resolutionY:r=i}={}){super("DepthDownsamplingPass");const s=new q$;s.normalBuffer=n,this.fullscreenMaterial=s,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new _i(1,1,{minFilter:Fn,magFilter:Fn,depthBuffer:!1,type:ri}),this.renderTarget.texture.name="DepthDownsamplingPass.Target",this.renderTarget.texture.generateMipmaps=!1;const o=this.resolution=new as(this,a,r,e);o.addEventListener("change",c=>this.setSize(o.baseWidth,o.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(n,e=Sc){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e}render(n,e,t,i,a){n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.fullscreenMaterial.setSize(n,e)}initialize(n,e,t){const i=n.getContext();if(!(i.getExtension("EXT_color_buffer_float")||i.getExtension("EXT_color_buffer_half_float")))throw new Error("Rendering to float texture is not supported.")}},Z$=`#include <packing>
#define packFloatToRGBA(v) packDepthToRGBA(v)
#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
uniform lowp sampler2D luminanceBuffer0;uniform lowp sampler2D luminanceBuffer1;uniform float minLuminance;uniform float deltaTime;uniform float tau;varying vec2 vUv;void main(){float l0=unpackRGBAToFloat(texture2D(luminanceBuffer0,vUv));
#if __VERSION__ < 300
float l1=texture2DLodEXT(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r;
#else
float l1=textureLod(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r;
#endif
l0=max(minLuminance,l0);l1=max(minLuminance,l1);float adaptedLum=l0+(l1-l0)*(1.0-exp(-deltaTime*tau));gl_FragColor=(adaptedLum==1.0)?vec4(1.0):packFloatToRGBA(adaptedLum);}`,K$=class extends Fi{constructor(){super({name:"AdaptiveLuminanceMaterial",defines:{MIP_LEVEL_1X1:"0.0"},uniforms:{luminanceBuffer0:new J(null),luminanceBuffer1:new J(null),minLuminance:new J(.01),deltaTime:new J(0),tau:new J(1)},extensions:{shaderTextureLOD:!0},blending:Sa,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Z$,vertexShader:iA})}set luminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}setLuminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}set luminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}setLuminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}set mipLevel1x1(n){this.defines.MIP_LEVEL_1X1=n.toFixed(1),this.needsUpdate=!0}setMipLevel1x1(n){this.mipLevel1x1=n}set deltaTime(n){this.uniforms.deltaTime.value=n}setDeltaTime(n){this.uniforms.deltaTime.value=n}get minLuminance(){return this.uniforms.minLuminance.value}set minLuminance(n){this.uniforms.minLuminance.value=n}getMinLuminance(){return this.uniforms.minLuminance.value}setMinLuminance(n){this.uniforms.minLuminance.value=n}get adaptationRate(){return this.uniforms.tau.value}set adaptationRate(n){this.uniforms.tau.value=n}getAdaptationRate(){return this.uniforms.tau.value}setAdaptationRate(n){this.uniforms.tau.value=n}},Q$=class extends Pa{constructor(n,{minLuminance:e=.01,adaptationRate:t=1}={}){super("AdaptiveLuminancePass"),this.fullscreenMaterial=new K$,this.needsSwap=!1,this.renderTargetPrevious=new _i(1,1,{minFilter:Fn,magFilter:Fn,depthBuffer:!1}),this.renderTargetPrevious.texture.name="Luminance.Previous";const i=this.fullscreenMaterial;i.luminanceBuffer0=this.renderTargetPrevious.texture,i.luminanceBuffer1=n,i.minLuminance=e,i.adaptationRate=t,this.renderTargetAdapted=this.renderTargetPrevious.clone(),this.renderTargetAdapted.texture.name="Luminance.Adapted",this.copyPass=new k8(this.renderTargetPrevious,!1)}get texture(){return this.renderTargetAdapted.texture}getTexture(){return this.renderTargetAdapted.texture}set mipLevel1x1(n){this.fullscreenMaterial.mipLevel1x1=n}get adaptationRate(){return this.fullscreenMaterial.adaptationRate}set adaptationRate(n){this.fullscreenMaterial.adaptationRate=n}render(n,e,t,i,a){this.fullscreenMaterial.deltaTime=i,n.setRenderTarget(this.renderToScreen?null:this.renderTargetAdapted),n.render(this.scene,this.camera),this.copyPass.render(n,this.renderTargetAdapted)}},J$=`#include <tonemapping_pars_fragment>
uniform float whitePoint;
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
uniform float middleGrey;
#if TONE_MAPPING_MODE == 3
uniform lowp sampler2D luminanceBuffer;
#else
uniform float averageLuminance;
#endif
vec3 Reinhard2ToneMapping(vec3 color){color*=toneMappingExposure;float l=luminance(color);
#if TONE_MAPPING_MODE == 3
float lumAvg=unpackRGBAToFloat(texture2D(luminanceBuffer,vec2(0.5)));
#else
float lumAvg=averageLuminance;
#endif
float lumScaled=(l*middleGrey)/max(lumAvg,1e-6);float lumCompressed=lumScaled*(1.0+lumScaled/(whitePoint*whitePoint));lumCompressed/=(1.0+lumScaled);return clamp(lumCompressed*color,0.0,1.0);}
#elif TONE_MAPPING_MODE == 4
#define A 0.15
#define B 0.50
#define C 0.10
#define D 0.20
#define E 0.02
#define F 0.30
vec3 Uncharted2Helper(const in vec3 x){return((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}vec3 Uncharted2ToneMapping(vec3 color){color*=toneMappingExposure;return clamp(Uncharted2Helper(color)/Uncharted2Helper(vec3(whitePoint)),0.0,1.0);}
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
outputColor=vec4(Reinhard2ToneMapping(inputColor.rgb),inputColor.a);
#elif TONE_MAPPING_MODE == 4
outputColor=vec4(Uncharted2ToneMapping(inputColor.rgb),inputColor.a);
#else
outputColor=vec4(toneMapping(inputColor.rgb),inputColor.a);
#endif
}`,$$=class extends m0{constructor({blendFunction:n=ln.SRC,adaptive:e=!1,mode:t=e?Ya.REINHARD2_ADAPTIVE:Ya.AGX,resolution:i=256,maxLuminance:a=4,whitePoint:r=a,middleGrey:s=.6,minLuminance:o=.01,averageLuminance:c=1,adaptationRate:h=1}={}){super("ToneMappingEffect",J$,{blendFunction:n,uniforms:new Map([["luminanceBuffer",new J(null)],["maxLuminance",new J(a)],["whitePoint",new J(r)],["middleGrey",new J(s)],["averageLuminance",new J(c)]])}),this.renderTargetLuminance=new _i(1,1,{minFilter:Er,depthBuffer:!1}),this.renderTargetLuminance.texture.generateMipmaps=!0,this.renderTargetLuminance.texture.name="Luminance",this.luminancePass=new W$({renderTarget:this.renderTargetLuminance}),this.adaptiveLuminancePass=new Q$(this.luminancePass.texture,{minLuminance:o,adaptationRate:h}),this.uniforms.get("luminanceBuffer").value=this.adaptiveLuminancePass.texture,this.resolution=i,this.mode=t}get mode(){return Number(this.defines.get("TONE_MAPPING_MODE"))}set mode(n){if(this.mode===n)return;const t=ws.replace(/\D+/g,"")>=168?"CineonToneMapping(texel)":"OptimizedCineonToneMapping(texel)";switch(this.defines.clear(),this.defines.set("TONE_MAPPING_MODE",n.toFixed(0)),n){case Ya.LINEAR:this.defines.set("toneMapping(texel)","LinearToneMapping(texel)");break;case Ya.REINHARD:this.defines.set("toneMapping(texel)","ReinhardToneMapping(texel)");break;case Ya.CINEON:case Ya.OPTIMIZED_CINEON:this.defines.set("toneMapping(texel)",t);break;case Ya.ACES_FILMIC:this.defines.set("toneMapping(texel)","ACESFilmicToneMapping(texel)");break;case Ya.AGX:this.defines.set("toneMapping(texel)","AgXToneMapping(texel)");break;case Ya.NEUTRAL:this.defines.set("toneMapping(texel)","NeutralToneMapping(texel)");break;default:this.defines.set("toneMapping(texel)","texel");break}this.adaptiveLuminancePass.enabled=n===Ya.REINHARD2_ADAPTIVE,this.setChanged()}getMode(){return this.mode}setMode(n){this.mode=n}get whitePoint(){return this.uniforms.get("whitePoint").value}set whitePoint(n){this.uniforms.get("whitePoint").value=n}get middleGrey(){return this.uniforms.get("middleGrey").value}set middleGrey(n){this.uniforms.get("middleGrey").value=n}get averageLuminance(){return this.uniforms.get("averageLuminance").value}set averageLuminance(n){this.uniforms.get("averageLuminance").value=n}get adaptiveLuminanceMaterial(){return this.adaptiveLuminancePass.fullscreenMaterial}getAdaptiveLuminanceMaterial(){return this.adaptiveLuminanceMaterial}get resolution(){return this.luminancePass.resolution.width}set resolution(n){const e=Math.max(0,Math.ceil(Math.log2(n))),t=Math.pow(2,e);this.luminancePass.resolution.setPreferredSize(t,t),this.adaptiveLuminanceMaterial.mipLevel1x1=e}getResolution(){return this.resolution}setResolution(n){this.resolution=n}get adaptive(){return this.mode===Ya.REINHARD2_ADAPTIVE}set adaptive(n){this.mode=n?Ya.REINHARD2_ADAPTIVE:Ya.REINHARD2}get adaptationRate(){return this.adaptiveLuminanceMaterial.adaptationRate}set adaptationRate(n){this.adaptiveLuminanceMaterial.adaptationRate=n}get distinction(){return console.warn(this.name,"distinction was removed."),1}set distinction(n){console.warn(this.name,"distinction was removed.")}update(n,e,t){this.adaptiveLuminancePass.enabled&&(this.luminancePass.render(n,e),this.adaptiveLuminancePass.render(n,null,null,t))}initialize(n,e,t){this.adaptiveLuminancePass.initialize(n,e,t)}},eee=`#include <common>
#include <packing>
#include <dithering_pars_fragment>
#define packFloatToRGBA(v) packDepthToRGBA(v)
#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#if DEPTH_PACKING == 3201
uniform lowp sampler2D depthBuffer;
#elif defined(GL_FRAGMENT_PRECISION_HIGH)
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
float depth=texture2D(depthBuffer,uv).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth=1.0-depth;
#endif
return depth;}float getViewZ(const in float depth){
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
#else
return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
#endif
}vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0;
#ifdef ENCODE_OUTPUT
#include <colorspace_fragment>
#endif
#include <dithering_fragment>
}`,tee="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}",nee=class extends Fi{constructor(n,e,t,i,a=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:ws.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new J(null),depthBuffer:new J(null),resolution:new J(new de),texelSize:new J(new de),cameraNear:new J(.3),cameraFar:new J(1e3),aspect:new J(1),time:new J(0)},blending:Sa,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:a}),n&&this.setShaderParts(n),e&&this.setDefines(e),t&&this.setUniforms(t),this.copyCameraSettings(i)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){this.uniforms.depthBuffer.value=n}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=Sc){this.depthBuffer=n,this.depthPacking=e}setShaderData(n){this.setShaderParts(n.shaderParts),this.setDefines(n.defines),this.setUniforms(n.uniforms),this.setExtensions(n.extensions)}setShaderParts(n){return this.fragmentShader=eee.replace(_n.FRAGMENT_HEAD,n.get(_n.FRAGMENT_HEAD)||"").replace(_n.FRAGMENT_MAIN_UV,n.get(_n.FRAGMENT_MAIN_UV)||"").replace(_n.FRAGMENT_MAIN_IMAGE,n.get(_n.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=tee.replace(_n.VERTEX_HEAD,n.get(_n.VERTEX_HEAD)||"").replace(_n.VERTEX_MAIN_SUPPORT,n.get(_n.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(n){for(const e of n.entries())this.defines[e[0]]=e[1];return this.needsUpdate=!0,this}setUniforms(n){for(const e of n.entries())this.uniforms[e[0]]=e[1];return this}setExtensions(n){this.extensions={};for(const e of n)this.extensions[e]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(n){this.encodeOutput!==n&&(n?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(n){return this.encodeOutput}setOutputEncodingEnabled(n){this.encodeOutput=n}get time(){return this.uniforms.time.value}set time(n){this.uniforms.time.value=n}setDeltaTime(n){this.uniforms.time.value+=n}adoptCameraSettings(n){this.copyCameraSettings(n)}copyCameraSettings(n){n&&(this.uniforms.cameraNear.value=n.near,this.uniforms.cameraFar.value=n.far,n instanceof ui?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(n,e){const t=this.uniforms;t.resolution.value.set(n,e),t.texelSize.value.set(1/n,1/e),t.aspect.value=n/e}static get Section(){return _n}};function qD(n,e,t){for(const i of e){const a="$1"+n+i.charAt(0).toUpperCase()+i.slice(1),r=new RegExp("([^\\.])(\\b"+i+"\\b)","g");for(const s of t.entries())s[1]!==null&&t.set(s[0],s[1].replace(r,a))}}function iee(n,e,t){let i=e.getFragmentShader(),a=e.getVertexShader();const r=i!==void 0&&/mainImage/.test(i),s=i!==void 0&&/mainUv/.test(i);if(t.attributes|=e.getAttributes(),i===void 0)throw new Error(`Missing fragment shader (${e.name})`);if(s&&t.attributes&Jo.CONVOLUTION)throw new Error(`Effects that transform UVs are incompatible with convolution effects (${e.name})`);if(!r&&!s)throw new Error(`Could not find mainImage or mainUv function (${e.name})`);{const o=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,c=t.shaderParts;let h=c.get(_n.FRAGMENT_HEAD)||"",f=c.get(_n.FRAGMENT_MAIN_UV)||"",d=c.get(_n.FRAGMENT_MAIN_IMAGE)||"",m=c.get(_n.VERTEX_HEAD)||"",g=c.get(_n.VERTEX_MAIN_SUPPORT)||"";const x=new Set,T=new Set;if(s&&(f+=` ${n}MainUv(UV);
`,t.uvTransformation=!0),a!==null&&/mainSupport/.test(a)){const y=/mainSupport *\([\w\s]*?uv\s*?\)/.test(a);g+=` ${n}MainSupport(`,g+=y?`vUv);
`:`);
`;for(const E of a.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(const b of E[1].split(/\s*,\s*/))t.varyings.add(b),x.add(b),T.add(b);for(const E of a.matchAll(o))T.add(E[1])}for(const y of i.matchAll(o))T.add(y[1]);for(const y of e.defines.keys())T.add(y.replace(/\([\w\s,]*\)/g,""));for(const y of e.uniforms.keys())T.add(y);T.delete("while"),T.delete("for"),T.delete("if"),e.uniforms.forEach((y,E)=>t.uniforms.set(n+E.charAt(0).toUpperCase()+E.slice(1),y)),e.defines.forEach((y,E)=>t.defines.set(n+E.charAt(0).toUpperCase()+E.slice(1),y));const S=new Map([["fragment",i],["vertex",a]]);qD(n,T,t.defines),qD(n,T,S),i=S.get("fragment"),a=S.get("vertex");const v=e.blendMode;if(t.blendModes.set(v.blendFunction,v),r){e.inputColorSpace!==null&&e.inputColorSpace!==t.colorSpace&&(d+=e.inputColorSpace===En?`color0 = sRGBTransferOETF(color0);
`:`color0 = sRGBToLinear(color0);
`),e.outputColorSpace!==Na?t.colorSpace=e.outputColorSpace:e.inputColorSpace!==null&&(t.colorSpace=e.inputColorSpace);const y=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;d+=`${n}MainImage(color0, UV, `,t.attributes&Jo.DEPTH&&y.test(i)&&(d+="depth, ",t.readDepth=!0),d+=`color1);
`;const E=n+"BlendOpacity";t.uniforms.set(E,v.opacity),d+=`color0 = blend${v.blendFunction}(color0, color1, ${E});
`,h+=`uniform float ${E};
`}if(h+=i+`
`,a!==null&&(m+=a+`
`),c.set(_n.FRAGMENT_HEAD,h),c.set(_n.FRAGMENT_MAIN_UV,f),c.set(_n.FRAGMENT_MAIN_IMAGE,d),c.set(_n.VERTEX_HEAD,m),c.set(_n.VERTEX_MAIN_SUPPORT,g),e.extensions!==null)for(const y of e.extensions)t.extensions.add(y)}}var aee=class extends Pa{constructor(n,...e){super("EffectPass"),this.fullscreenMaterial=new nee(null,null,null,n),this.listener=t=>this.handleEvent(t),this.effects=[],this.setEffects(e),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(n){for(const e of this.effects)e.mainScene=n}set mainCamera(n){this.fullscreenMaterial.copyCameraSettings(n);for(const e of this.effects)e.mainCamera=n}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(n){this.fullscreenMaterial.encodeOutput=n}get dithering(){return this.fullscreenMaterial.dithering}set dithering(n){const e=this.fullscreenMaterial;e.dithering=n,e.needsUpdate=!0}setEffects(n){for(const e of this.effects)e.removeEventListener("change",this.listener);this.effects=n.sort((e,t)=>t.attributes-e.attributes);for(const e of this.effects)e.addEventListener("change",this.listener)}updateMaterial(){const n=new l$;let e=0;for(const s of this.effects)if(s.blendMode.blendFunction===ln.DST)n.attributes|=s.getAttributes()&Jo.DEPTH;else{if(n.attributes&s.getAttributes()&Jo.CONVOLUTION)throw new Error(`Convolution effects cannot be merged (${s.name})`);iee("e"+e++,s,n)}let t=n.shaderParts.get(_n.FRAGMENT_HEAD),i=n.shaderParts.get(_n.FRAGMENT_MAIN_IMAGE),a=n.shaderParts.get(_n.FRAGMENT_MAIN_UV);const r=/\bblend\b/g;for(const s of n.blendModes.values())t+=s.getShaderCode().replace(r,`blend${s.blendFunction}`)+`
`;n.attributes&Jo.DEPTH?(n.readDepth&&(i=`float depth = readDepth(UV);
`+i),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,n.colorSpace===En&&(i+=`color0 = sRGBToLinear(color0);
`),n.uvTransformation?(a=`vec2 transformedUv = vUv;
`+a,n.defines.set("UV","transformedUv")):n.defines.set("UV","vUv"),n.shaderParts.set(_n.FRAGMENT_HEAD,t),n.shaderParts.set(_n.FRAGMENT_MAIN_IMAGE,i),n.shaderParts.set(_n.FRAGMENT_MAIN_UV,a);for(const[s,o]of n.shaderParts)o!==null&&n.shaderParts.set(s,o.trim().replace(/^#/,`
#`));this.skipRendering=e===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(n)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(n,e=Sc){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(n,e)}render(n,e,t,i,a){for(const r of this.effects)r.update(n,e,i);if(!this.skipRendering||this.renderToScreen){const r=this.fullscreenMaterial;r.inputBuffer=e.texture,r.time+=i*this.timeScale,n.setRenderTarget(this.renderToScreen?null:t),n.render(this.scene,this.camera)}}setSize(n,e){this.fullscreenMaterial.setSize(n,e);for(const t of this.effects)t.setSize(n,e)}initialize(n,e,t){this.renderer=n;for(const i of this.effects)i.initialize(n,e,t);this.updateMaterial(),t!==void 0&&t!==Ii&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const n of this.effects)n.removeEventListener("change",this.listener),n.dispose()}handleEvent(n){switch(n.type){case"change":this.recompile();break}}},ree=class extends Pa{constructor(n,e,{renderTarget:t,resolutionScale:i=1,width:a=as.AUTO_SIZE,height:r=as.AUTO_SIZE,resolutionX:s=a,resolutionY:o=r}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new aA(n,e,new Lb);const c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;const h=c.getClearPass();h.overrideClearColor=new je(7829503),h.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new _i(1,1,{minFilter:Fn,magFilter:Fn}),this.renderTarget.texture.name="NormalPass.Target");const f=this.resolution=new as(this,s,o,i);f.addEventListener("change",d=>this.setSize(f.baseWidth,f.baseHeight))}set mainScene(n){this.renderPass.mainScene=n}set mainCamera(n){this.renderPass.mainCamera=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,a){const r=this.renderToScreen?null:this.renderTarget;this.renderPass.render(n,r,r)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}};function Bm(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}new de;new de;function X8(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}var Wr=function n(e,t,i){var a=this;X8(this,n),Bm(this,"dot2",function(r,s){return a.x*r+a.y*s}),Bm(this,"dot3",function(r,s,o){return a.x*r+a.y*s+a.z*o}),this.x=e,this.y=t,this.z=i},see=[new Wr(1,1,0),new Wr(-1,1,0),new Wr(1,-1,0),new Wr(-1,-1,0),new Wr(1,0,1),new Wr(-1,0,1),new Wr(1,0,-1),new Wr(-1,0,-1),new Wr(0,1,1),new Wr(0,-1,1),new Wr(0,1,-1),new Wr(0,-1,-1)],jD=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],ZD=new Array(512),KD=new Array(512),oee=function(e){e>0&&e<1&&(e*=65536),e=Math.floor(e),e<256&&(e|=e<<8);for(var t=0;t<256;t++){var i;t&1?i=jD[t]^e&255:i=jD[t]^e>>8&255,ZD[t]=ZD[t+256]=i,KD[t]=KD[t+256]=see[i%12]}};oee(0);function lee(n){if(typeof n=="number")n=Math.abs(n);else if(typeof n=="string"){var e=n;n=0;for(var t=0;t<e.length;t++)n=(n+(t+1)*(e.charCodeAt(t)%96))%2147483647}return n===0&&(n=311),n}function QD(n){var e=lee(n);return function(){var t=e*48271%2147483647;return e=t,t/2147483647}}var cee=function n(e){var t=this;X8(this,n),Bm(this,"seed",0),Bm(this,"init",function(i){t.seed=i,t.value=QD(i)}),Bm(this,"value",QD(this.seed)),this.init(e)};new cee(Math.random());const rA=be.createContext(null),JD=n=>(n.getAttributes()&2)===2,uee=be.memo(be.forwardRef(({children:n,camera:e,scene:t,resolutionScale:i,enabled:a=!0,renderPriority:r=1,autoClear:s=!0,depthBuffer:o,enableNormalPass:c,stencilBuffer:h,multisampling:f=8,frameBufferType:d=Xn},m)=>{const{gl:g,scene:x,camera:T,size:S}=Qi(),v=t||x,y=e||T,[E,b,D]=be.useMemo(()=>{const P=new o$(g,{depthBuffer:o,stencilBuffer:h,multisampling:f,frameBufferType:d});P.addPass(new aA(v,y));let O=null,R=null;return c&&(R=new ree(v,y),R.enabled=!1,P.addPass(R),i!==void 0&&(O=new j$({normalBuffer:R.texture,resolutionScale:i}),O.enabled=!1,P.addPass(O))),[P,R,O]},[y,g,o,h,f,d,v,c,i]);be.useEffect(()=>E==null?void 0:E.setSize(S.width,S.height),[E,S]),Ac((P,O)=>{if(a){const R=g.autoClear;g.autoClear=s,h&&!s&&g.clearStencil(),E.render(O),g.autoClear=R}},a?r:0);const C=be.useRef(null);be.useLayoutEffect(()=>{var R;const P=[],O=C.current.__r3f;if(O&&E){const B=O.children;for(let j=0;j<B.length;j++){const ee=B[j].object;if(ee instanceof m0){const se=[ee];if(!JD(ee)){let W=null;for(;(W=(R=B[j+1])==null?void 0:R.object)instanceof m0&&!JD(W);)se.push(W),j++}const re=new aee(y,...se);P.push(re)}else ee instanceof Pa&&P.push(ee)}for(const j of P)E==null||E.addPass(j);b&&(b.enabled=!0),D&&(D.enabled=!0)}return()=>{for(const B of P)E==null||E.removePass(B);b&&(b.enabled=!1),D&&(D.enabled=!1)}},[E,n,y,b,D]),be.useEffect(()=>{const P=g.toneMapping;return g.toneMapping=ns,()=>{g.toneMapping=P}},[g]);const I=be.useMemo(()=>({composer:E,normalPass:b,downSamplingPass:D,resolutionScale:i,camera:y,scene:v}),[E,b,D,i,y,v]);return be.useImperativeHandle(m,()=>E,[E]),Nt.jsx(rA.Provider,{value:I,children:Nt.jsx("group",{ref:C,children:n})})}));let hee=0;const $D=new WeakMap,fee=(n,e)=>function({blendFunction:t=e==null?void 0:e.blendFunction,opacity:i=e==null?void 0:e.opacity,...a}){let r=$D.get(n);if(!r){const c=`@react-three/postprocessing/${n.name}-${hee++}`;l8({[c]:n}),$D.set(n,r=c)}const s=Qi(c=>c.camera),o=hM.useMemo(()=>[...(e==null?void 0:e.args)??[],...a.args??[{...e,...a}]],[JSON.stringify(a)]);return Nt.jsx(r,{camera:s,"blendMode-blendFunction":t,"blendMode-opacity-value":i,...a,args:o})},dee=fee($$);var pee="Invariant failed";function qx(n,e){if(!n)throw new Error(pee)}const mee=new L;function Y8(n,e,t=new L,i){const{x:a,y:r,z:s}=n,o=e.x,c=e.y,h=e.z,f=a*a*o,d=r*r*c,m=s*s*h,g=f+d+m,x=Math.sqrt(1/g);if(!Number.isFinite(x))return;const T=mee.copy(n).multiplyScalar(x);if(g<((i==null?void 0:i.centerTolerance)??.1))return t.copy(T);const S=T.multiply(e).multiplyScalar(2);let v=(1-x)*n.length()/(S.length()/2),y=0,E,b,D,C;do{v-=y,E=1/(1+v*o),b=1/(1+v*c),D=1/(1+v*h);const I=E*E,P=b*b,O=D*D,R=I*E,B=P*b,j=O*D;C=f*I+d*P+m*O-1,y=C/((f*R*o+d*B*c+m*j*h)*-2)}while(Math.abs(C)>1e-12);return t.set(a*E,r*b,s*D)}const vf=new L,k2=new L,W2=new L,OE=class{constructor(e,t,i){this.radii=new L(e,t,i)}get minimumRadius(){return Math.min(this.radii.x,this.radii.y,this.radii.z)}get maximumRadius(){return Math.max(this.radii.x,this.radii.y,this.radii.z)}get flattening(){return 1-this.minimumRadius/this.maximumRadius}get eccentricity(){return Math.sqrt(this.eccentricitySquared)}get eccentricitySquared(){const e=this.maximumRadius**2,t=this.minimumRadius**2;return(e-t)/e}reciprocalRadii(e=new L){const{x:t,y:i,z:a}=this.radii;return e.set(1/t,1/i,1/a)}reciprocalRadiiSquared(e=new L){const{x:t,y:i,z:a}=this.radii;return e.set(1/t**2,1/i**2,1/a**2)}projectOnSurface(e,t=new L,i){return Y8(e,this.reciprocalRadiiSquared(),t,i)}getSurfaceNormal(e,t=new L){return t.multiplyVectors(this.reciprocalRadiiSquared(vf),e).normalize()}getEastNorthUpVectors(e,t=new L,i=new L,a=new L){this.getSurfaceNormal(e,a),t.set(-e.y,e.x,0).normalize(),i.crossVectors(a,t).normalize()}getEastNorthUpFrame(e,t=new ke){const i=vf,a=k2,r=W2;return this.getEastNorthUpVectors(e,i,a,r),t.makeBasis(i,a,r).setPosition(e)}getNorthUpEastFrame(e,t=new ke){const i=vf,a=k2,r=W2;return this.getEastNorthUpVectors(e,i,a,r),t.makeBasis(a,r,i).setPosition(e)}getIntersection(e,t=new L){const i=this.reciprocalRadii(vf),a=k2.copy(i).multiply(e.origin),r=W2.copy(i).multiply(e.direction),s=a.lengthSq(),o=r.lengthSq(),c=a.dot(r),h=c**2-o*(s-1);if(s===1)return t.copy(e.origin);if(s>1){if(c>=0||h<0)return;const f=Math.sqrt(h),d=(-c-f)/o,m=(-c+f)/o;return e.at(Math.min(d,m),t)}if(s<1){const f=c**2-o*(s-1),d=Math.sqrt(f),m=(-c+d)/o;return e.at(m,t)}if(c<0)return e.at(-c/o,t)}getOsculatingSphereCenter(e,t,i=new L){qx(this.radii.x===this.radii.y);const a=this.radii.x**2,r=this.radii.z**2,s=vf.set(e.x/a,e.y/a,e.z/r).normalize();return i.copy(s.multiplyScalar(-t).add(e))}getNormalAtHorizon(e,t,i=new L){qx(this.radii.x===this.radii.y);const a=this.radii.x**2,r=this.radii.z**2,s=e,o=t;let c=(s.x*o.x+s.y*o.y)/a+s.z*o.z/r;c/=(s.x**2+s.y**2)/a+s.z**2/r;const h=vf.copy(o).multiplyScalar(-c).add(e);return i.set(h.x/a,h.y/a,h.z/r).normalize()}};OE.WGS84=new OE(6378137,6378137,6356752314245179e-9);let g0=OE;const Gv=new L,eO=new L,hm=class LE{constructor(e=0,t=0,i=0){this.longitude=e,this.latitude=t,this.height=i}set(e,t,i){return this.longitude=e,this.latitude=t,i!=null&&(this.height=i),this}clone(){return new LE(this.longitude,this.latitude,this.height)}copy(e){return this.longitude=e.longitude,this.latitude=e.latitude,this.height=e.height,this}equals(e){return e.longitude===this.longitude&&e.latitude===this.latitude&&e.height===this.height}setLongitude(e){return this.longitude=e,this}setLatitude(e){return this.latitude=e,this}setHeight(e){return this.height=e,this}normalize(){return this.longitude<LE.MIN_LONGITUDE&&(this.longitude+=Math.PI*2),this}setFromECEF(e,t){const i=((t==null?void 0:t.ellipsoid)??g0.WGS84).reciprocalRadiiSquared(Gv),a=Y8(e,i,eO,t);if(a==null)throw new Error(`Could not project position to ellipsoid surface: ${e.toArray()}`);const r=Gv.multiplyVectors(a,i).normalize();this.longitude=Math.atan2(r.y,r.x),this.latitude=Math.asin(r.z);const s=Gv.subVectors(e,a);return this.height=Math.sign(s.dot(e))*s.length(),this}toECEF(e=new L,t){const i=(t==null?void 0:t.ellipsoid)??g0.WGS84,a=Gv.multiplyVectors(i.radii,i.radii),r=Math.cos(this.latitude),s=eO.set(r*Math.cos(this.longitude),r*Math.sin(this.longitude),Math.sin(this.latitude)).normalize();return e.multiplyVectors(a,s),e.divideScalar(Math.sqrt(s.dot(e))).add(s.multiplyScalar(this.height))}fromArray(e,t=0){return this.longitude=e[t],this.latitude=e[t+1],this.height=e[t+2],this}toArray(e=[],t=0){return e[t]=this.longitude,e[t+1]=this.latitude,e[t+2]=this.height,e}*[Symbol.iterator](){yield this.longitude,yield this.latitude,yield this.height}};hm.MIN_LONGITUDE=-Math.PI,hm.MAX_LONGITUDE=Math.PI,hm.MIN_LATITUDE=-Math.PI/2,hm.MAX_LATITUDE=Math.PI/2;let q8=hm;/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
*/var $r=Uint8Array,kf=Uint16Array,gee=Int32Array,j8=new $r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Z8=new $r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),vee=new $r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K8=function(n,e){for(var t=new kf(31),i=0;i<31;++i)t[i]=e+=1<<n[i-1];for(var a=new gee(t[30]),i=1;i<30;++i)for(var r=t[i];r<t[i+1];++r)a[r]=r-t[i]<<5|i;return{b:t,r:a}},Q8=K8(j8,2),J8=Q8.b,_ee=Q8.r;J8[28]=258,_ee[258]=28;var xee=K8(Z8,0),yee=xee.b,IE=new kf(32768);for(var $n=0;$n<32768;++$n){var Ul=($n&43690)>>1|($n&21845)<<1;Ul=(Ul&52428)>>2|(Ul&13107)<<2,Ul=(Ul&61680)>>4|(Ul&3855)<<4,IE[$n]=((Ul&65280)>>8|(Ul&255)<<8)>>1}var Hm=function(n,e,t){for(var i=n.length,a=0,r=new kf(e);a<i;++a)n[a]&&++r[n[a]-1];var s=new kf(e);for(a=1;a<e;++a)s[a]=s[a-1]+r[a-1]<<1;var o;if(t){o=new kf(1<<e);var c=15-e;for(a=0;a<i;++a)if(n[a])for(var h=a<<4|n[a],f=e-n[a],d=s[n[a]-1]++<<f,m=d|(1<<f)-1;d<=m;++d)o[IE[d]>>c]=h}else for(o=new kf(i),a=0;a<i;++a)n[a]&&(o[a]=IE[s[n[a]-1]++]>>15-n[a]);return o},V0=new $r(288);for(var $n=0;$n<144;++$n)V0[$n]=8;for(var $n=144;$n<256;++$n)V0[$n]=9;for(var $n=256;$n<280;++$n)V0[$n]=7;for(var $n=280;$n<288;++$n)V0[$n]=8;var $8=new $r(32);for(var $n=0;$n<32;++$n)$8[$n]=5;var See=Hm(V0,9,1),Tee=Hm($8,5,1),X2=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},vs=function(n,e,t){var i=e/8|0;return(n[i]|n[i+1]<<8)>>(e&7)&t},Y2=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},Eee=function(n){return(n+7)/8|0},Mee=function(n,e,t){return(t==null||t>n.length)&&(t=n.length),new $r(n.subarray(e,t))},bee=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ss=function(n,e,t){var i=new Error(e||bee[n]);if(i.code=n,Error.captureStackTrace&&Error.captureStackTrace(i,Ss),!t)throw i;return i},Aee=function(n,e,t,i){var a=n.length,r=0;if(!a||e.f&&!e.l)return t||new $r(0);var s=!t,o=s||e.i!=2,c=e.i;s&&(t=new $r(a*3));var h=function(Mt){var ot=t.length;if(Mt>ot){var Ke=new $r(Math.max(ot*2,Mt));Ke.set(t),t=Ke}},f=e.f||0,d=e.p||0,m=e.b||0,g=e.l,x=e.d,T=e.m,S=e.n,v=a*8;do{if(!g){f=vs(n,d,1);var y=vs(n,d+1,3);if(d+=3,y)if(y==1)g=See,x=Tee,T=9,S=5;else if(y==2){var C=vs(n,d,31)+257,I=vs(n,d+10,15)+4,P=C+vs(n,d+5,31)+1;d+=14;for(var O=new $r(P),R=new $r(19),B=0;B<I;++B)R[vee[B]]=vs(n,d+B*3,7);d+=I*3;for(var j=X2(R),ee=(1<<j)-1,se=Hm(R,j,1),B=0;B<P;){var re=se[vs(n,d,ee)];d+=re&15;var E=re>>4;if(E<16)O[B++]=E;else{var W=0,te=0;for(E==16?(te=3+vs(n,d,3),d+=2,W=O[B-1]):E==17?(te=3+vs(n,d,7),d+=3):E==18&&(te=11+vs(n,d,127),d+=7);te--;)O[B++]=W}}var K=O.subarray(0,C),oe=O.subarray(C);T=X2(K),S=X2(oe),g=Hm(K,T,1),x=Hm(oe,S,1)}else Ss(1);else{var E=Eee(d)+4,b=n[E-4]|n[E-3]<<8,D=E+b;if(D>a){c&&Ss(0);break}o&&h(m+b),t.set(n.subarray(E,D),m),e.b=m+=b,e.p=d=D*8,e.f=f;continue}if(d>v){c&&Ss(0);break}}o&&h(m+131072);for(var ie=(1<<T)-1,Ce=(1<<S)-1,Xe=d;;Xe=d){var W=g[Y2(n,d)&ie],nt=W>>4;if(d+=W&15,d>v){c&&Ss(0);break}if(W||Ss(2),nt<256)t[m++]=nt;else if(nt==256){Xe=d,g=null;break}else{var tt=nt-254;if(nt>264){var B=nt-257,gt=j8[B];tt=vs(n,d,(1<<gt)-1)+J8[B],d+=gt}var ge=x[Y2(n,d)&Ce],Ae=ge>>4;ge||Ss(3),d+=ge&15;var oe=yee[Ae];if(Ae>3){var gt=Z8[Ae];oe+=Y2(n,d)&(1<<gt)-1,d+=gt}if(d>v){c&&Ss(0);break}o&&h(m+131072);var Ze=m+tt;if(m<oe){var ue=r-oe,it=Math.min(oe,Ze);for(ue+m<0&&Ss(3);m<it;++m)t[m]=i[ue+m]}for(;m<Ze;++m)t[m]=t[m-oe]}}e.l=g,e.p=Xe,e.b=m,e.f=f,g&&(f=1,e.m=T,e.d=x,e.n=S)}while(!f);return m!=t.length&&s?Mee(t,0,m):t.subarray(0,m)},Ree=new $r(0),wee=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&Ss(6,"invalid zlib data"),(n[1]>>5&1)==1&&Ss(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Vv(n,e){return Aee(n.subarray(wee(n),-4),{i:2},e,e)}var Cee=typeof TextDecoder<"u"&&new TextDecoder,Nee=0;try{Cee.decode(Ree,{stream:!0}),Nee=1}catch{}class eP extends g6{constructor(e){super(e),this.type=Xn,this.outputFormat=Jn}parse(e){const O=Math.pow(2.7182818,2.2);function R(w,z){let Y=0;for(let V=0;V<65536;++V)(V==0||w[V>>3]&1<<(V&7))&&(z[Y++]=V);const N=Y-1;for(;Y<65536;)z[Y++]=0;return N}function B(w){for(let z=0;z<16384;z++)w[z]={},w[z].len=0,w[z].lit=0,w[z].p=null}const j={l:0,c:0,lc:0};function ee(w,z,Y,N,V){for(;Y<w;)z=z<<8|Q(N,V),Y+=8;Y-=w,j.l=z>>Y&(1<<w)-1,j.c=z,j.lc=Y}const se=new Array(59);function re(w){for(let Y=0;Y<=58;++Y)se[Y]=0;for(let Y=0;Y<65537;++Y)se[w[Y]]+=1;let z=0;for(let Y=58;Y>0;--Y){const N=z+se[Y]>>1;se[Y]=z,z=N}for(let Y=0;Y<65537;++Y){const N=w[Y];N>0&&(w[Y]=N|se[N]++<<6)}}function W(w,z,Y,N,V,Z){const H=z;let X=0,ne=0;for(;N<=V;N++){if(H.value-z.value>Y)return!1;ee(6,X,ne,w,H);const ae=j.l;if(X=j.c,ne=j.lc,Z[N]=ae,ae==63){if(H.value-z.value>Y)throw new Error("Something wrong with hufUnpackEncTable");ee(8,X,ne,w,H);let fe=j.l+6;if(X=j.c,ne=j.lc,N+fe>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;fe--;)Z[N++]=0;N--}else if(ae>=59){let fe=ae-59+2;if(N+fe>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;fe--;)Z[N++]=0;N--}}re(Z)}function te(w){return w&63}function K(w){return w>>6}function oe(w,z,Y,N){for(;z<=Y;z++){const V=K(w[z]),Z=te(w[z]);if(V>>Z)throw new Error("Invalid table entry");if(Z>14){const H=N[V>>Z-14];if(H.len)throw new Error("Invalid table entry");if(H.lit++,H.p){const X=H.p;H.p=new Array(H.lit);for(let ne=0;ne<H.lit-1;++ne)H.p[ne]=X[ne]}else H.p=new Array(1);H.p[H.lit-1]=z}else if(Z){let H=0;for(let X=1<<14-Z;X>0;X--){const ne=N[(V<<14-Z)+H];if(ne.len||ne.p)throw new Error("Invalid table entry");ne.len=Z,ne.lit=z,H++}}}return!0}const ie={c:0,lc:0};function Ce(w,z,Y,N){w=w<<8|Q(Y,N),z+=8,ie.c=w,ie.lc=z}const Xe={c:0,lc:0};function nt(w,z,Y,N,V,Z,H,X,ne){if(w==z){N<8&&(Ce(Y,N,V,Z),Y=ie.c,N=ie.lc),N-=8;let ae=Y>>N;if(ae=new Uint8Array([ae])[0],X.value+ae>ne)return!1;const fe=H[X.value-1];for(;ae-- >0;)H[X.value++]=fe}else if(X.value<ne)H[X.value++]=w;else return!1;Xe.c=Y,Xe.lc=N}function tt(w){return w&65535}function gt(w){const z=tt(w);return z>32767?z-65536:z}const ge={a:0,b:0};function Ae(w,z){const Y=gt(w),V=gt(z),Z=Y+(V&1)+(V>>1),H=Z,X=Z-V;ge.a=H,ge.b=X}function Ze(w,z){const Y=tt(w),N=tt(z),V=Y-(N>>1)&65535,Z=N+V-32768&65535;ge.a=Z,ge.b=V}function ue(w,z,Y,N,V,Z,H){const X=H<16384,ne=Y>V?V:Y;let ae=1,fe,_e;for(;ae<=ne;)ae<<=1;for(ae>>=1,fe=ae,ae>>=1;ae>=1;){_e=0;const Se=_e+Z*(V-fe),we=Z*ae,Pe=Z*fe,ze=N*ae,Ye=N*fe;let lt,St,bt,ft;for(;_e<=Se;_e+=Pe){let At=_e;const st=_e+N*(Y-fe);for(;At<=st;At+=Ye){const Kt=At+ze,On=At+we,Xt=On+ze;X?(Ae(w[At+z],w[On+z]),lt=ge.a,bt=ge.b,Ae(w[Kt+z],w[Xt+z]),St=ge.a,ft=ge.b,Ae(lt,St),w[At+z]=ge.a,w[Kt+z]=ge.b,Ae(bt,ft),w[On+z]=ge.a,w[Xt+z]=ge.b):(Ze(w[At+z],w[On+z]),lt=ge.a,bt=ge.b,Ze(w[Kt+z],w[Xt+z]),St=ge.a,ft=ge.b,Ze(lt,St),w[At+z]=ge.a,w[Kt+z]=ge.b,Ze(bt,ft),w[On+z]=ge.a,w[Xt+z]=ge.b)}if(Y&ae){const Kt=At+we;X?Ae(w[At+z],w[Kt+z]):Ze(w[At+z],w[Kt+z]),lt=ge.a,w[Kt+z]=ge.b,w[At+z]=lt}}if(V&ae){let At=_e;const st=_e+N*(Y-fe);for(;At<=st;At+=Ye){const Kt=At+ze;X?Ae(w[At+z],w[Kt+z]):Ze(w[At+z],w[Kt+z]),lt=ge.a,w[Kt+z]=ge.b,w[At+z]=lt}}fe=ae,ae>>=1}return _e}function it(w,z,Y,N,V,Z,H,X,ne){let ae=0,fe=0;const _e=H,Se=Math.trunc(N.value+(V+7)/8);for(;N.value<Se;)for(Ce(ae,fe,Y,N),ae=ie.c,fe=ie.lc;fe>=14;){const Pe=ae>>fe-14&16383,ze=z[Pe];if(ze.len)fe-=ze.len,nt(ze.lit,Z,ae,fe,Y,N,X,ne,_e),ae=Xe.c,fe=Xe.lc;else{if(!ze.p)throw new Error("hufDecode issues");let Ye;for(Ye=0;Ye<ze.lit;Ye++){const lt=te(w[ze.p[Ye]]);for(;fe<lt&&N.value<Se;)Ce(ae,fe,Y,N),ae=ie.c,fe=ie.lc;if(fe>=lt&&K(w[ze.p[Ye]])==(ae>>fe-lt&(1<<lt)-1)){fe-=lt,nt(ze.p[Ye],Z,ae,fe,Y,N,X,ne,_e),ae=Xe.c,fe=Xe.lc;break}}if(Ye==ze.lit)throw new Error("hufDecode issues")}}const we=8-V&7;for(ae>>=we,fe-=we;fe>0;){const Pe=z[ae<<14-fe&16383];if(Pe.len)fe-=Pe.len,nt(Pe.lit,Z,ae,fe,Y,N,X,ne,_e),ae=Xe.c,fe=Xe.lc;else throw new Error("hufDecode issues")}return!0}function Mt(w,z,Y,N,V,Z){const H={value:0},X=Y.value,ne=ht(z,Y),ae=ht(z,Y);Y.value+=4;const fe=ht(z,Y);if(Y.value+=4,ne<0||ne>=65537||ae<0||ae>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const _e=new Array(65537),Se=new Array(16384);B(Se);const we=N-(Y.value-X);if(W(w,Y,we,ne,ae,_e),fe>8*(N-(Y.value-X)))throw new Error("Something wrong with hufUncompress");oe(_e,ne,ae,Se),it(_e,Se,w,Y,fe,ae,Z,V,H)}function ot(w,z,Y){for(let N=0;N<Y;++N)z[N]=w[z[N]]}function Ke(w){for(let z=1;z<w.length;z++){const Y=w[z-1]+w[z]-128;w[z]=Y}}function Te(w,z){let Y=0,N=Math.floor((w.length+1)/2),V=0;const Z=w.length-1;for(;!(V>Z||(z[V++]=w[Y++],V>Z));)z[V++]=w[N++]}function G(w){let z=w.byteLength;const Y=new Array;let N=0;const V=new DataView(w);for(;z>0;){const Z=V.getInt8(N++);if(Z<0){const H=-Z;z-=H+1;for(let X=0;X<H;X++)Y.push(V.getUint8(N++))}else{const H=Z;z-=2;const X=V.getUint8(N++);for(let ne=0;ne<H+1;ne++)Y.push(X)}}return Y}function Me(w,z,Y,N,V,Z){let H=new DataView(Z.buffer);const X=Y[w.idx[0]].width,ne=Y[w.idx[0]].height,ae=3,fe=Math.floor(X/8),_e=Math.ceil(X/8),Se=Math.ceil(ne/8),we=X-(_e-1)*8,Pe=ne-(Se-1)*8,ze={value:0},Ye=new Array(ae),lt=new Array(ae),St=new Array(ae),bt=new Array(ae),ft=new Array(ae);for(let st=0;st<ae;++st)ft[st]=z[w.idx[st]],Ye[st]=st<1?0:Ye[st-1]+_e*Se,lt[st]=new Float32Array(64),St[st]=new Uint16Array(64),bt[st]=new Uint16Array(_e*64);for(let st=0;st<Se;++st){let Kt=8;st==Se-1&&(Kt=Pe);let On=8;for(let kt=0;kt<_e;++kt){kt==_e-1&&(On=we);for(let Ct=0;Ct<ae;++Ct)St[Ct].fill(0),St[Ct][0]=V[Ye[Ct]++],Fe(ze,N,St[Ct]),Be(St[Ct],lt[Ct]),$e(lt[Ct]);Je(lt);for(let Ct=0;Ct<ae;++Ct)ct(lt[Ct],bt[Ct],kt*64)}let Xt=0;for(let kt=0;kt<ae;++kt){const Ct=Y[w.idx[kt]].type;for(let Bn=8*st;Bn<8*st+Kt;++Bn){Xt=ft[kt][Bn];for(let Mi=0;Mi<fe;++Mi){const Mn=Mi*64+(Bn&7)*8;H.setUint16(Xt+0*2*Ct,bt[kt][Mn+0],!0),H.setUint16(Xt+1*2*Ct,bt[kt][Mn+1],!0),H.setUint16(Xt+2*2*Ct,bt[kt][Mn+2],!0),H.setUint16(Xt+3*2*Ct,bt[kt][Mn+3],!0),H.setUint16(Xt+4*2*Ct,bt[kt][Mn+4],!0),H.setUint16(Xt+5*2*Ct,bt[kt][Mn+5],!0),H.setUint16(Xt+6*2*Ct,bt[kt][Mn+6],!0),H.setUint16(Xt+7*2*Ct,bt[kt][Mn+7],!0),Xt+=8*2*Ct}}if(fe!=_e)for(let Bn=8*st;Bn<8*st+Kt;++Bn){const Mi=ft[kt][Bn]+8*fe*2*Ct,Mn=fe*64+(Bn&7)*8;for(let Gn=0;Gn<On;++Gn)H.setUint16(Mi+Gn*2*Ct,bt[kt][Mn+Gn],!0)}}}const At=new Uint16Array(X);H=new DataView(Z.buffer);for(let st=0;st<ae;++st){Y[w.idx[st]].decoded=!0;const Kt=Y[w.idx[st]].type;if(Y[st].type==2)for(let On=0;On<ne;++On){const Xt=ft[st][On];for(let kt=0;kt<X;++kt)At[kt]=H.getUint16(Xt+kt*2*Kt,!0);for(let kt=0;kt<X;++kt)H.setFloat32(Xt+kt*2*Kt,me(At[kt]),!0)}}}function De(w,z,Y,N,V,Z){const H=new DataView(Z.buffer),X=Y[w],ne=X.width,ae=X.height,fe=Math.ceil(ne/8),_e=Math.ceil(ae/8),Se=Math.floor(ne/8),we=ne-(fe-1)*8,Pe=ae-(_e-1)*8,ze={value:0};let Ye=0;const lt=new Float32Array(64),St=new Uint16Array(64),bt=new Uint16Array(fe*64);for(let ft=0;ft<_e;++ft){let At=8;ft==_e-1&&(At=Pe);for(let st=0;st<fe;++st)St.fill(0),St[0]=V[Ye++],Fe(ze,N,St),Be(St,lt),$e(lt),ct(lt,bt,st*64);for(let st=8*ft;st<8*ft+At;++st){let Kt=z[w][st];for(let On=0;On<Se;++On){const Xt=On*64+(st&7)*8;for(let kt=0;kt<8;++kt)H.setUint16(Kt+kt*2*X.type,bt[Xt+kt],!0);Kt+=8*2*X.type}if(fe!=Se){const On=Se*64+(st&7)*8;for(let Xt=0;Xt<we;++Xt)H.setUint16(Kt+Xt*2*X.type,bt[On+Xt],!0)}}}X.decoded=!0}function Fe(w,z,Y){let N,V=1;for(;V<64;)N=z[w.value],N==65280?V=64:N>>8==255?V+=N&255:(Y[V]=N,V++),w.value++}function Be(w,z){z[0]=me(w[0]),z[1]=me(w[1]),z[2]=me(w[5]),z[3]=me(w[6]),z[4]=me(w[14]),z[5]=me(w[15]),z[6]=me(w[27]),z[7]=me(w[28]),z[8]=me(w[2]),z[9]=me(w[4]),z[10]=me(w[7]),z[11]=me(w[13]),z[12]=me(w[16]),z[13]=me(w[26]),z[14]=me(w[29]),z[15]=me(w[42]),z[16]=me(w[3]),z[17]=me(w[8]),z[18]=me(w[12]),z[19]=me(w[17]),z[20]=me(w[25]),z[21]=me(w[30]),z[22]=me(w[41]),z[23]=me(w[43]),z[24]=me(w[9]),z[25]=me(w[11]),z[26]=me(w[18]),z[27]=me(w[24]),z[28]=me(w[31]),z[29]=me(w[40]),z[30]=me(w[44]),z[31]=me(w[53]),z[32]=me(w[10]),z[33]=me(w[19]),z[34]=me(w[23]),z[35]=me(w[32]),z[36]=me(w[39]),z[37]=me(w[45]),z[38]=me(w[52]),z[39]=me(w[54]),z[40]=me(w[20]),z[41]=me(w[22]),z[42]=me(w[33]),z[43]=me(w[38]),z[44]=me(w[46]),z[45]=me(w[51]),z[46]=me(w[55]),z[47]=me(w[60]),z[48]=me(w[21]),z[49]=me(w[34]),z[50]=me(w[37]),z[51]=me(w[47]),z[52]=me(w[50]),z[53]=me(w[56]),z[54]=me(w[59]),z[55]=me(w[61]),z[56]=me(w[35]),z[57]=me(w[36]),z[58]=me(w[48]),z[59]=me(w[49]),z[60]=me(w[57]),z[61]=me(w[58]),z[62]=me(w[62]),z[63]=me(w[63])}function $e(w){const z=.5*Math.cos(.7853975),Y=.5*Math.cos(3.14159/16),N=.5*Math.cos(3.14159/8),V=.5*Math.cos(3*3.14159/16),Z=.5*Math.cos(5*3.14159/16),H=.5*Math.cos(3*3.14159/8),X=.5*Math.cos(7*3.14159/16),ne=new Array(4),ae=new Array(4),fe=new Array(4),_e=new Array(4);for(let Se=0;Se<8;++Se){const we=Se*8;ne[0]=N*w[we+2],ne[1]=H*w[we+2],ne[2]=N*w[we+6],ne[3]=H*w[we+6],ae[0]=Y*w[we+1]+V*w[we+3]+Z*w[we+5]+X*w[we+7],ae[1]=V*w[we+1]-X*w[we+3]-Y*w[we+5]-Z*w[we+7],ae[2]=Z*w[we+1]-Y*w[we+3]+X*w[we+5]+V*w[we+7],ae[3]=X*w[we+1]-Z*w[we+3]+V*w[we+5]-Y*w[we+7],fe[0]=z*(w[we+0]+w[we+4]),fe[3]=z*(w[we+0]-w[we+4]),fe[1]=ne[0]+ne[3],fe[2]=ne[1]-ne[2],_e[0]=fe[0]+fe[1],_e[1]=fe[3]+fe[2],_e[2]=fe[3]-fe[2],_e[3]=fe[0]-fe[1],w[we+0]=_e[0]+ae[0],w[we+1]=_e[1]+ae[1],w[we+2]=_e[2]+ae[2],w[we+3]=_e[3]+ae[3],w[we+4]=_e[3]-ae[3],w[we+5]=_e[2]-ae[2],w[we+6]=_e[1]-ae[1],w[we+7]=_e[0]-ae[0]}for(let Se=0;Se<8;++Se)ne[0]=N*w[16+Se],ne[1]=H*w[16+Se],ne[2]=N*w[48+Se],ne[3]=H*w[48+Se],ae[0]=Y*w[8+Se]+V*w[24+Se]+Z*w[40+Se]+X*w[56+Se],ae[1]=V*w[8+Se]-X*w[24+Se]-Y*w[40+Se]-Z*w[56+Se],ae[2]=Z*w[8+Se]-Y*w[24+Se]+X*w[40+Se]+V*w[56+Se],ae[3]=X*w[8+Se]-Z*w[24+Se]+V*w[40+Se]-Y*w[56+Se],fe[0]=z*(w[Se]+w[32+Se]),fe[3]=z*(w[Se]-w[32+Se]),fe[1]=ne[0]+ne[3],fe[2]=ne[1]-ne[2],_e[0]=fe[0]+fe[1],_e[1]=fe[3]+fe[2],_e[2]=fe[3]-fe[2],_e[3]=fe[0]-fe[1],w[0+Se]=_e[0]+ae[0],w[8+Se]=_e[1]+ae[1],w[16+Se]=_e[2]+ae[2],w[24+Se]=_e[3]+ae[3],w[32+Se]=_e[3]-ae[3],w[40+Se]=_e[2]-ae[2],w[48+Se]=_e[1]-ae[1],w[56+Se]=_e[0]-ae[0]}function Je(w){for(let z=0;z<64;++z){const Y=w[0][z],N=w[1][z],V=w[2][z];w[0][z]=Y+1.5747*V,w[1][z]=Y-.1873*N-.4682*V,w[2][z]=Y+1.8556*N}}function ct(w,z,Y){for(let N=0;N<64;++N)z[Y+N]=aE.toHalfFloat(k(w[N]))}function k(w){return w<=1?Math.sign(w)*Math.pow(Math.abs(w),2.2):Math.sign(w)*Math.pow(O,Math.abs(w)-1)}function U(w){return new DataView(w.array.buffer,w.offset.value,w.size)}function ce(w){const z=w.viewer.buffer.slice(w.offset.value,w.offset.value+w.size),Y=new Uint8Array(G(z)),N=new Uint8Array(Y.length);return Ke(Y),Te(Y,N),new DataView(N.buffer)}function Ee(w){const z=w.array.slice(w.offset.value,w.offset.value+w.size),Y=Vv(z),N=new Uint8Array(Y.length);return Ke(Y),Te(Y,N),new DataView(N.buffer)}function Le(w){const z=w.viewer,Y={value:w.offset.value},N=new Uint16Array(w.columns*w.lines*(w.inputChannels.length*w.type)),V=new Uint8Array(8192);let Z=0;const H=new Array(w.inputChannels.length);for(let Pe=0,ze=w.inputChannels.length;Pe<ze;Pe++)H[Pe]={},H[Pe].start=Z,H[Pe].end=H[Pe].start,H[Pe].nx=w.columns,H[Pe].ny=w.lines,H[Pe].size=w.type,Z+=H[Pe].nx*H[Pe].ny*H[Pe].size;const X=We(z,Y),ne=We(z,Y);if(ne>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(X<=ne)for(let Pe=0;Pe<ne-X+1;Pe++)V[Pe+X]=pe(z,Y);const ae=new Uint16Array(65536),fe=R(V,ae),_e=ht(z,Y);Mt(w.array,z,Y,_e,N,Z);for(let Pe=0;Pe<w.inputChannels.length;++Pe){const ze=H[Pe];for(let Ye=0;Ye<H[Pe].size;++Ye)ue(N,ze.start+Ye,ze.nx,ze.size,ze.ny,ze.nx*ze.size,fe)}ot(ae,N,Z);let Se=0;const we=new Uint8Array(N.buffer.byteLength);for(let Pe=0;Pe<w.lines;Pe++)for(let ze=0;ze<w.inputChannels.length;ze++){const Ye=H[ze],lt=Ye.nx*Ye.size,St=new Uint8Array(N.buffer,Ye.end*2,lt*2);we.set(St,Se),Se+=lt*2,Ye.end+=lt}return new DataView(we.buffer)}function ye(w){const z=w.array.slice(w.offset.value,w.offset.value+w.size),Y=Vv(z),N=w.inputChannels.length*w.lines*w.columns*w.totalBytes,V=new ArrayBuffer(N),Z=new DataView(V);let H=0,X=0;const ne=new Array(4);for(let ae=0;ae<w.lines;ae++)for(let fe=0;fe<w.inputChannels.length;fe++){let _e=0;switch(w.inputChannels[fe].pixelType){case 1:ne[0]=H,ne[1]=ne[0]+w.columns,H=ne[1]+w.columns;for(let we=0;we<w.columns;++we){const Pe=Y[ne[0]++]<<8|Y[ne[1]++];_e+=Pe,Z.setUint16(X,_e,!0),X+=2}break;case 2:ne[0]=H,ne[1]=ne[0]+w.columns,ne[2]=ne[1]+w.columns,H=ne[2]+w.columns;for(let we=0;we<w.columns;++we){const Pe=Y[ne[0]++]<<24|Y[ne[1]++]<<16|Y[ne[2]++]<<8;_e+=Pe,Z.setUint32(X,_e,!0),X+=4}break}}return Z}function vt(w){const z=w.viewer,Y={value:w.offset.value},N=new Uint8Array(w.columns*w.lines*(w.inputChannels.length*w.type*2)),V={version:Oe(z,Y),unknownUncompressedSize:Oe(z,Y),unknownCompressedSize:Oe(z,Y),acCompressedSize:Oe(z,Y),dcCompressedSize:Oe(z,Y),rleCompressedSize:Oe(z,Y),rleUncompressedSize:Oe(z,Y),rleRawSize:Oe(z,Y),totalAcUncompressedCount:Oe(z,Y),totalDcUncompressedCount:Oe(z,Y),acCompression:Oe(z,Y)};if(V.version<2)throw new Error("EXRLoader.parse: "+rr.compression+" version "+V.version+" is unsupported");const Z=new Array;let H=We(z,Y)-2;for(;H>0;){const ze=qe(z.buffer,Y),Ye=pe(z,Y),lt=Ye>>2&3,St=(Ye>>4)-1,bt=new Int8Array([St])[0],ft=pe(z,Y);Z.push({name:ze,index:bt,type:ft,compression:lt}),H-=ze.length+3}const X=rr.channels,ne=new Array(w.inputChannels.length);for(let ze=0;ze<w.inputChannels.length;++ze){const Ye=ne[ze]={},lt=X[ze];Ye.name=lt.name,Ye.compression=0,Ye.decoded=!1,Ye.type=lt.pixelType,Ye.pLinear=lt.pLinear,Ye.width=w.columns,Ye.height=w.lines}const ae={idx:new Array(3)};for(let ze=0;ze<w.inputChannels.length;++ze){const Ye=ne[ze];for(let lt=0;lt<Z.length;++lt){const St=Z[lt];Ye.name==St.name&&(Ye.compression=St.compression,St.index>=0&&(ae.idx[St.index]=ze),Ye.offset=ze)}}let fe,_e,Se;if(V.acCompressedSize>0)switch(V.acCompression){case 0:fe=new Uint16Array(V.totalAcUncompressedCount),Mt(w.array,z,Y,V.acCompressedSize,fe,V.totalAcUncompressedCount);break;case 1:const ze=w.array.slice(Y.value,Y.value+V.totalAcUncompressedCount),Ye=Vv(ze);fe=new Uint16Array(Ye.buffer),Y.value+=V.totalAcUncompressedCount;break}if(V.dcCompressedSize>0){const ze={array:w.array,offset:Y,size:V.dcCompressedSize};_e=new Uint16Array(Ee(ze).buffer),Y.value+=V.dcCompressedSize}if(V.rleRawSize>0){const ze=w.array.slice(Y.value,Y.value+V.rleCompressedSize),Ye=Vv(ze);Se=G(Ye.buffer),Y.value+=V.rleCompressedSize}let we=0;const Pe=new Array(ne.length);for(let ze=0;ze<Pe.length;++ze)Pe[ze]=new Array;for(let ze=0;ze<w.lines;++ze)for(let Ye=0;Ye<ne.length;++Ye)Pe[Ye].push(we),we+=ne[Ye].width*w.type*2;ae.idx[0]!==void 0&&ne[ae.idx[0]]&&Me(ae,Pe,ne,fe,_e,N);for(let ze=0;ze<ne.length;++ze){const Ye=ne[ze];if(!Ye.decoded)switch(Ye.compression){case 2:let lt=0,St=0;for(let bt=0;bt<w.lines;++bt){let ft=Pe[ze][lt];for(let At=0;At<Ye.width;++At){for(let st=0;st<2*Ye.type;++st)N[ft++]=Se[St+st*Ye.width*Ye.height];St++}lt++}break;case 1:De(ze,Pe,ne,fe,_e,N);break;default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(N.buffer)}function qe(w,z){const Y=new Uint8Array(w);let N=0;for(;Y[z.value+N]!=0;)N+=1;const V=new TextDecoder().decode(Y.slice(z.value,z.value+N));return z.value=z.value+N+1,V}function _t(w,z,Y){const N=new TextDecoder().decode(new Uint8Array(w).slice(z.value,z.value+Y));return z.value=z.value+Y,N}function pt(w,z){const Y=He(w,z),N=ht(w,z);return[Y,N]}function Ie(w,z){const Y=ht(w,z),N=ht(w,z);return[Y,N]}function He(w,z){const Y=w.getInt32(z.value,!0);return z.value=z.value+4,Y}function ht(w,z){const Y=w.getUint32(z.value,!0);return z.value=z.value+4,Y}function Q(w,z){const Y=w[z.value];return z.value=z.value+1,Y}function pe(w,z){const Y=w.getUint8(z.value);return z.value=z.value+1,Y}const Oe=function(w,z){let Y;return"getBigInt64"in DataView.prototype?Y=Number(w.getBigInt64(z.value,!0)):Y=w.getUint32(z.value+4,!0)+Number(w.getUint32(z.value,!0)<<32),z.value+=8,Y};function q(w,z){const Y=w.getFloat32(z.value,!0);return z.value+=4,Y}function Ve(w,z){return aE.toHalfFloat(q(w,z))}function me(w){const z=(w&31744)>>10,Y=w&1023;return(w>>15?-1:1)*(z?z===31?Y?NaN:1/0:Math.pow(2,z-15)*(1+Y/1024):6103515625e-14*(Y/1024))}function We(w,z){const Y=w.getUint16(z.value,!0);return z.value+=2,Y}function Ge(w,z){return me(We(w,z))}function Re(w,z,Y,N){const V=Y.value,Z=[];for(;Y.value<V+N-1;){const H=qe(z,Y),X=He(w,Y),ne=pe(w,Y);Y.value+=3;const ae=He(w,Y),fe=He(w,Y);Z.push({name:H,pixelType:X,pLinear:ne,xSampling:ae,ySampling:fe})}return Y.value+=1,Z}function rt(w,z){const Y=q(w,z),N=q(w,z),V=q(w,z),Z=q(w,z),H=q(w,z),X=q(w,z),ne=q(w,z),ae=q(w,z);return{redX:Y,redY:N,greenX:V,greenY:Z,blueX:H,blueY:X,whiteX:ne,whiteY:ae}}function yt(w,z){const Y=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],N=pe(w,z);return Y[N]}function Gt(w,z){const Y=He(w,z),N=He(w,z),V=He(w,z),Z=He(w,z);return{xMin:Y,yMin:N,xMax:V,yMax:Z}}function Vt(w,z){const Y=["INCREASING_Y","DECREASING_Y","RANDOM_Y"],N=pe(w,z);return Y[N]}function oi(w,z){const Y=["ENVMAP_LATLONG","ENVMAP_CUBE"],N=pe(w,z);return Y[N]}function li(w,z){const Y=["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"],N=["ROUND_DOWN","ROUND_UP"],V=ht(w,z),Z=ht(w,z),H=pe(w,z);return{xSize:V,ySize:Z,levelMode:Y[H&15],roundingMode:N[H>>4]}}function co(w,z){const Y=q(w,z),N=q(w,z);return[Y,N]}function Ls(w,z){const Y=q(w,z),N=q(w,z),V=q(w,z);return[Y,N,V]}function Is(w,z,Y,N,V){if(N==="string"||N==="stringvector"||N==="iccProfile")return _t(z,Y,V);if(N==="chlist")return Re(w,z,Y,V);if(N==="chromaticities")return rt(w,Y);if(N==="compression")return yt(w,Y);if(N==="box2i")return Gt(w,Y);if(N==="envmap")return oi(w,Y);if(N==="tiledesc")return li(w,Y);if(N==="lineOrder")return Vt(w,Y);if(N==="float")return q(w,Y);if(N==="v2f")return co(w,Y);if(N==="v3f")return Ls(w,Y);if(N==="int")return He(w,Y);if(N==="rational")return pt(w,Y);if(N==="timecode")return Ie(w,Y);if(N==="preview")return Y.value+=V,"skipped";Y.value+=V}function Ei(w,z){const Y=Math.log2(w);return z=="ROUND_DOWN"?Math.floor(Y):Math.ceil(Y)}function Us(w,z,Y){let N=0;switch(w.levelMode){case"ONE_LEVEL":N=1;break;case"MIPMAP_LEVELS":N=Ei(Math.max(z,Y),w.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return N}function ha(w,z,Y,N){const V=new Array(w);for(let Z=0;Z<w;Z++){const H=1<<Z;let X=z/H|0;N=="ROUND_UP"&&X*H<z&&(X+=1);const ne=Math.max(X,1);V[Z]=(ne+Y-1)/Y|0}return V}function ki(){const w=this,z=w.offset,Y={value:0};for(let N=0;N<w.tileCount;N++){const V=He(w.viewer,z),Z=He(w.viewer,z);z.value+=8,w.size=ht(w.viewer,z);const H=V*w.blockWidth,X=Z*w.blockHeight;w.columns=H+w.blockWidth>w.width?w.width-H:w.blockWidth,w.lines=X+w.blockHeight>w.height?w.height-X:w.blockHeight;const ne=w.columns*w.totalBytes,fe=w.size<w.lines*ne?w.uncompress(w):U(w);z.value+=w.size;for(let _e=0;_e<w.lines;_e++){const Se=_e*w.columns*w.totalBytes;for(let we=0;we<w.inputChannels.length;we++){const Pe=rr.channels[we].name,ze=w.channelByteOffsets[Pe]*w.columns,Ye=w.decodeChannels[Pe];if(Ye===void 0)continue;Y.value=Se+ze;const lt=(w.height-(1+X+_e))*w.outLineWidth;for(let St=0;St<w.columns;St++){const bt=lt+(St+H)*w.outputChannels+Ye;w.byteArray[bt]=w.getter(fe,Y)}}}}}function Ha(){const w=this,z=w.offset,Y={value:0};for(let N=0;N<w.height/w.blockHeight;N++){const V=He(w.viewer,z)-rr.dataWindow.yMin;w.size=ht(w.viewer,z),w.lines=V+w.blockHeight>w.height?w.height-V:w.blockHeight;const Z=w.columns*w.totalBytes,X=w.size<w.lines*Z?w.uncompress(w):U(w);z.value+=w.size;for(let ne=0;ne<w.blockHeight;ne++){const ae=N*w.blockHeight,fe=ne+w.scanOrder(ae);if(fe>=w.height)continue;const _e=ne*Z,Se=(w.height-1-fe)*w.outLineWidth;for(let we=0;we<w.inputChannels.length;we++){const Pe=rr.channels[we].name,ze=w.channelByteOffsets[Pe]*w.columns,Ye=w.decodeChannels[Pe];if(Ye!==void 0){Y.value=_e+ze;for(let lt=0;lt<w.columns;lt++){const St=Se+lt*w.outputChannels+Ye;w.byteArray[St]=w.getter(X,Y)}}}}}}function Dn(w,z,Y){const N={};if(w.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");N.version=w.getUint8(4);const V=w.getUint8(5);N.spec={singleTile:!!(V&2),longName:!!(V&4),deepFormat:!!(V&8),multiPart:!!(V&16)},Y.value=8;let Z=!0;for(;Z;){const H=qe(z,Y);if(H==="")Z=!1;else{const X=qe(z,Y),ne=ht(w,Y),ae=Is(w,z,Y,X,ne);ae===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${X}'.`):N[H]=ae}}if(V&-7)throw console.error("THREE.EXRHeader:",N),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return N}function Or(w,z,Y,N,V,Z){const H={size:0,viewer:z,array:Y,offset:N,width:w.dataWindow.xMax-w.dataWindow.xMin+1,height:w.dataWindow.yMax-w.dataWindow.yMin+1,inputChannels:w.channels,channelByteOffsets:{},shouldExpand:!1,scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:Wn};switch(w.compression){case"NO_COMPRESSION":H.blockHeight=1,H.uncompress=U;break;case"RLE_COMPRESSION":H.blockHeight=1,H.uncompress=ce;break;case"ZIPS_COMPRESSION":H.blockHeight=1,H.uncompress=Ee;break;case"ZIP_COMPRESSION":H.blockHeight=16,H.uncompress=Ee;break;case"PIZ_COMPRESSION":H.blockHeight=32,H.uncompress=Le;break;case"PXR24_COMPRESSION":H.blockHeight=16,H.uncompress=ye;break;case"DWAA_COMPRESSION":H.blockHeight=32,H.uncompress=vt;break;case"DWAB_COMPRESSION":H.blockHeight=256,H.uncompress=vt;break;default:throw new Error("EXRLoader.parse: "+w.compression+" is unsupported")}const X={};for(const Se of w.channels)switch(Se.name){case"Y":case"R":case"G":case"B":case"A":X[Se.name]=!0,H.type=Se.pixelType}let ne=!1,ae=!1;if(X.R&&X.G&&X.B)H.outputChannels=4;else if(X.Y)H.outputChannels=1;else throw new Error("EXRLoader.parse: file contains unsupported data channels.");switch(H.outputChannels){case 4:Z==Jn?(ne=!X.A,H.format=Jn,H.colorSpace=Wn,H.outputChannels=4,H.decodeChannels={R:0,G:1,B:2,A:3}):Z==Vo?(H.format=Vo,H.colorSpace=Wn,H.outputChannels=2,H.decodeChannels={R:0,G:1}):Z==bs?(H.format=bs,H.colorSpace=Wn,H.outputChannels=1,H.decodeChannels={R:0}):ae=!0;break;case 1:Z==Jn?(ne=!0,H.format=Jn,H.colorSpace=Wn,H.outputChannels=4,H.shouldExpand=!0,H.decodeChannels={Y:0}):Z==Vo?(H.format=Vo,H.colorSpace=Wn,H.outputChannels=2,H.shouldExpand=!0,H.decodeChannels={Y:0}):Z==bs?(H.format=bs,H.colorSpace=Wn,H.outputChannels=1,H.decodeChannels={Y:0}):ae=!0;break;default:ae=!0}if(ae)throw new Error("EXRLoader.parse: invalid output format for specified file.");if(H.type==1)switch(V){case ri:H.getter=Ge;break;case Xn:H.getter=We;break}else if(H.type==2)switch(V){case ri:H.getter=q;break;case Xn:H.getter=Ve}else throw new Error("EXRLoader.parse: unsupported pixelType "+H.type+" for "+w.compression+".");H.columns=H.width;const fe=H.width*H.height*H.outputChannels;switch(V){case ri:H.byteArray=new Float32Array(fe),ne&&H.byteArray.fill(1,0,fe);break;case Xn:H.byteArray=new Uint16Array(fe),ne&&H.byteArray.fill(15360,0,fe);break;default:console.error("THREE.EXRLoader: unsupported type: ",V);break}let _e=0;for(const Se of w.channels)H.decodeChannels[Se.name]!==void 0&&(H.channelByteOffsets[Se.name]=_e),_e+=Se.pixelType*2;if(H.totalBytes=_e,H.outLineWidth=H.width*H.outputChannels,w.lineOrder==="INCREASING_Y"?H.scanOrder=Se=>Se:H.scanOrder=Se=>H.height-1-Se,w.spec.singleTile){H.blockHeight=w.tiles.ySize,H.blockWidth=w.tiles.xSize;const Se=Us(w.tiles,H.width,H.height),we=ha(Se,H.width,w.tiles.xSize,w.tiles.roundingMode),Pe=ha(Se,H.height,w.tiles.ySize,w.tiles.roundingMode);H.tileCount=we[0]*Pe[0];for(let ze=0;ze<Se;ze++)for(let Ye=0;Ye<Pe[ze];Ye++)for(let lt=0;lt<we[ze];lt++)Oe(z,N);H.decode=ki.bind(H)}else{H.blockWidth=H.width;const Se=Math.ceil(H.height/H.blockHeight);for(let we=0;we<Se;we++)Oe(z,N);H.decode=Ha.bind(H)}return H}const Ps={value:0},zs=new DataView(e),uo=new Uint8Array(e),rr=Dn(zs,e,Ps),fa=Or(rr,zs,uo,Ps,this.type,this.outputFormat);if(fa.decode(),fa.shouldExpand){const w=fa.byteArray;if(this.outputFormat==Jn)for(let z=0;z<w.length;z+=4)w[z+2]=w[z+1]=w[z];else if(this.outputFormat==Vo)for(let z=0;z<w.length;z+=2)w[z+1]=w[z]}return{header:rr,width:fa.width,height:fa.height,data:fa.byteArray,format:fa.format,colorSpace:fa.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}setOutputFormat(e){return this.outputFormat=e,this}load(e,t,i,a){function r(s,o){s.colorSpace=o.colorSpace,s.minFilter=Ht,s.magFilter=Ht,s.generateMipmaps=!1,s.flipY=!1,t&&t(s,o)}return super.load(e,r,i,a)}}let Dee=class extends Ti{load(e,t,i,a){const r=new ss(this.manager);r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),r.load(e,s=>{qx(s instanceof ArrayBuffer);try{t(s)}catch(o){a!=null?a(o):console.error(o),this.manager.itemError(e)}},i,a)}};function tP(n){var e,t;return n instanceof Kb?n.getContext().getExtension("OES_texture_float_linear")!=null:((t=(e=n.backend).hasFeature)==null?void 0:t.call(e,"float32-filterable"))??!1}const Oee=128,Lee=128,Iee=64,Uee="9627216cc50057994c98a2118f3c4a23765d43b9",nP=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${Uee}/packages/core/assets/stbn.bin`,Pee="This is not an object",zee="This is not a Float16Array object",tO="This constructor is not a subclass of Float16Array",iP="The constructor property value is not an object",Bee="Species constructor didn't return TypedArray object",Hee="Derived constructor created TypedArray object which was too small length",Fm="Attempting to access detached ArrayBuffer",UE="Cannot convert undefined or null to object",PE="Cannot mix BigInt and other types, use explicit conversions",nO="@@iterator property is not callable",iO="Reduce of empty array with no initial value",Fee="The comparison function must be either a function or undefined",q2="Offset is out of bounds";function jn(n){return(e,...t)=>qa(n,e,t)}function jd(n,e){return jn(Dd(n,e).get)}const{apply:qa,construct:fm,defineProperty:Gee,get:j2,getOwnPropertyDescriptor:Dd,getPrototypeOf:k0,has:zE,ownKeys:aP,set:aO,setPrototypeOf:rP}=Reflect,Vee=Proxy,{EPSILON:kee,MAX_SAFE_INTEGER:rO,isFinite:sP,isNaN:Od}=Number,{iterator:so,species:Wee,toStringTag:sA,for:Xee}=Symbol,Ld=Object,{create:oy,defineProperty:W0,freeze:Yee,is:sO}=Ld,BE=Ld.prototype,qee=BE.__lookupGetter__?jn(BE.__lookupGetter__):(n,e)=>{if(n==null)throw ii(UE);let t=Ld(n);do{const i=Dd(t,e);if(i!==void 0)return Wo(i,"get")?i.get:void 0}while((t=k0(t))!==null)},Wo=Ld.hasOwn||jn(BE.hasOwnProperty),oP=Array,lP=oP.isArray,ly=oP.prototype,jee=jn(ly.join),Zee=jn(ly.push),Kee=jn(ly.toLocaleString),oA=ly[so],Qee=jn(oA),{abs:Jee,trunc:cP}=Math,cy=ArrayBuffer,$ee=cy.isView,uP=cy.prototype,ete=jn(uP.slice),tte=jd(uP,"byteLength"),HE=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null,nte=HE&&jd(HE.prototype,"byteLength"),lA=k0(Uint8Array),ite=lA.from,na=lA.prototype,ate=na[so],rte=jn(na.keys),ste=jn(na.values),ote=jn(na.entries),lte=jn(na.set),oO=jn(na.reverse),cte=jn(na.fill),ute=jn(na.copyWithin),lO=jn(na.sort),Qp=jn(na.slice),hte=jn(na.subarray),ji=jd(na,"buffer"),uu=jd(na,"byteOffset"),Tn=jd(na,"length"),hP=jd(na,sA),fte=Uint8Array,_r=Uint16Array,cO=(...n)=>qa(ite,_r,n),cA=Uint32Array,dte=Float32Array,Ju=k0([][so]()),uy=jn(Ju.next),pte=jn(function*(){}().next),mte=k0(Ju),gte=DataView.prototype,vte=jn(gte.getUint16),ii=TypeError,Z2=RangeError,fP=WeakSet,dP=fP.prototype,_te=jn(dP.add),xte=jn(dP.has),hy=WeakMap,uA=hy.prototype,jx=jn(uA.get),yte=jn(uA.has),hA=jn(uA.set),pP=new hy,Ste=oy(null,{next:{value:function(){const n=jx(pP,this);return uy(n)}},[so]:{value:function(){return this}}});function dm(n){if(n[so]===oA&&Ju.next===uy)return n;const e=oy(Ste);return hA(pP,e,Qee(n)),e}const mP=new hy,gP=oy(mte,{next:{value:function(){const n=jx(mP,this);return pte(n)},writable:!0,configurable:!0}});for(const n of aP(Ju))n!=="next"&&W0(gP,n,Dd(Ju,n));function uO(n){const e=oy(gP);return hA(mP,e,n),e}function Zx(n){return n!==null&&typeof n=="object"||typeof n=="function"}function hO(n){return n!==null&&typeof n=="object"}function Kx(n){return hP(n)!==void 0}function FE(n){const e=hP(n);return e==="BigInt64Array"||e==="BigUint64Array"}function Tte(n){try{return lP(n)?!1:(tte(n),!0)}catch{return!1}}function vP(n){if(HE===null)return!1;try{return nte(n),!0}catch{return!1}}function Ete(n){return Tte(n)||vP(n)}function fO(n){return lP(n)?n[so]===oA&&Ju.next===uy:!1}function Mte(n){return Kx(n)?n[so]===ate&&Ju.next===uy:!1}function kv(n){if(typeof n!="string")return!1;const e=+n;return n!==e+""||!sP(e)?!1:e===cP(e)}const Qx=Xee("__Float16Array__");function bte(n){if(!hO(n))return!1;const e=k0(n);if(!hO(e))return!1;const t=e.constructor;if(t===void 0)return!1;if(!Zx(t))throw ii(iP);return zE(t,Qx)}const GE=1/kee;function Ate(n){return n+GE-GE}const _P=6103515625e-14,Rte=65504,xP=.0009765625,dO=xP*_P,wte=xP*GE;function Cte(n){const e=+n;if(!sP(e)||e===0)return e;const t=e>0?1:-1,i=Jee(e);if(i<_P)return t*Ate(i/dO)*dO;const a=(1+wte)*i,r=a-(a-i);return r>Rte||Od(r)?t*(1/0):t*r}const yP=new cy(4),SP=new dte(yP),TP=new cA(yP),_s=new _r(512),xs=new fte(512);for(let n=0;n<256;++n){const e=n-127;e<-24?(_s[n]=0,_s[n|256]=32768,xs[n]=24,xs[n|256]=24):e<-14?(_s[n]=1024>>-e-14,_s[n|256]=1024>>-e-14|32768,xs[n]=-e-1,xs[n|256]=-e-1):e<=15?(_s[n]=e+15<<10,_s[n|256]=e+15<<10|32768,xs[n]=13,xs[n|256]=13):e<128?(_s[n]=31744,_s[n|256]=64512,xs[n]=24,xs[n|256]=24):(_s[n]=31744,_s[n|256]=64512,xs[n]=13,xs[n|256]=13)}function js(n){SP[0]=Cte(n);const e=TP[0],t=e>>23&511;return _s[t]+((e&8388607)>>xs[t])}const fA=new cA(2048);for(let n=1;n<1024;++n){let e=n<<13,t=0;for(;!(e&8388608);)e<<=1,t-=8388608;e&=-8388609,t+=947912704,fA[n]=e|t}for(let n=1024;n<2048;++n)fA[n]=939524096+(n-1024<<13);const Zd=new cA(64);for(let n=1;n<31;++n)Zd[n]=n<<23;Zd[31]=1199570944;Zd[32]=2147483648;for(let n=33;n<63;++n)Zd[n]=2147483648+(n-32<<23);Zd[63]=3347054592;const EP=new _r(64);for(let n=1;n<64;++n)n!==32&&(EP[n]=1024);function An(n){const e=n>>10;return TP[0]=fA[EP[e]+(n&1023)]+Zd[e],SP[0]}function Po(n){const e=+n;return Od(e)||e===0?0:cP(e)}function K2(n){const e=Po(n);return e<0?0:e<rO?e:rO}function Wv(n,e){if(!Zx(n))throw ii(Pee);const t=n.constructor;if(t===void 0)return e;if(!Zx(t))throw ii(iP);return t[Wee]??e}function Gm(n){if(vP(n))return!1;try{return ete(n,0,0),!1}catch{}return!0}function pO(n,e){const t=Od(n),i=Od(e);if(t&&i)return 0;if(t)return 1;if(i||n<e)return-1;if(n>e)return 1;if(n===0&&e===0){const a=sO(n,0),r=sO(e,0);if(!a&&r)return-1;if(a&&!r)return 1}return 0}const dA=2,Jx=new hy;function Wf(n){return yte(Jx,n)||!$ee(n)&&bte(n)}function Sn(n){if(!Wf(n))throw ii(zee)}function Xv(n,e){const t=Wf(n),i=Kx(n);if(!t&&!i)throw ii(Bee);if(typeof e=="number"){let a;if(t){const r=Jt(n);a=Tn(r)}else a=Tn(n);if(a<e)throw ii(Hee)}if(FE(n))throw ii(PE)}function Jt(n){const e=jx(Jx,n);if(e!==void 0){const a=ji(e);if(Gm(a))throw ii(Fm);return e}const t=n.buffer;if(Gm(t))throw ii(Fm);const i=fm(ll,[t,n.byteOffset,n.length],n.constructor);return jx(Jx,i)}function mO(n){const e=Tn(n),t=[];for(let i=0;i<e;++i)t[i]=An(n[i]);return t}const MP=new fP;for(const n of aP(na)){if(n===sA)continue;const e=Dd(na,n);Wo(e,"get")&&typeof e.get=="function"&&_te(MP,e.get)}const Nte=Yee({get(n,e,t){return kv(e)&&Wo(n,e)?An(j2(n,e)):xte(MP,qee(n,e))?j2(n,e):j2(n,e,t)},set(n,e,t,i){return kv(e)&&Wo(n,e)?aO(n,e,js(t)):aO(n,e,t,i)},getOwnPropertyDescriptor(n,e){if(kv(e)&&Wo(n,e)){const t=Dd(n,e);return t.value=An(t.value),t}return Dd(n,e)},defineProperty(n,e,t){return kv(e)&&Wo(n,e)&&Wo(t,"value")&&(t.value=js(t.value)),Gee(n,e,t)}});let ll=class Zi{constructor(e,t,i){let a;if(Wf(e))a=fm(_r,[Jt(e)],new.target);else if(Zx(e)&&!Ete(e)){let s,o;if(Kx(e)){s=e,o=Tn(e);const c=ji(e);if(Gm(c))throw ii(Fm);if(FE(e))throw ii(PE);const h=new cy(o*dA);a=fm(_r,[h],new.target)}else{const c=e[so];if(c!=null&&typeof c!="function")throw ii(nO);c!=null?fO(e)?(s=e,o=e.length):(s=[...e],o=s.length):(s=e,o=K2(s.length)),a=fm(_r,[o],new.target)}for(let c=0;c<o;++c)a[c]=js(s[c])}else a=fm(_r,arguments,new.target);const r=new Vee(a,Nte);return hA(Jx,r,a),r}static from(e,...t){const i=this;if(!zE(i,Qx))throw ii(tO);if(i===Zi){if(Wf(e)&&t.length===0){const f=Jt(e),d=new _r(ji(f),uu(f),Tn(f));return new Zi(ji(Qp(d)))}if(t.length===0)return new Zi(ji(cO(e,js)));const c=t[0],h=t[1];return new Zi(ji(cO(e,function(f,...d){return js(qa(c,this,[f,...dm(d)]))},h)))}let a,r;const s=e[so];if(s!=null&&typeof s!="function")throw ii(nO);if(s!=null)fO(e)?(a=e,r=e.length):Mte(e)?(a=e,r=Tn(e)):(a=[...e],r=a.length);else{if(e==null)throw ii(UE);a=Ld(e),r=K2(a.length)}const o=new i(r);if(t.length===0)for(let c=0;c<r;++c)o[c]=a[c];else{const c=t[0],h=t[1];for(let f=0;f<r;++f)o[f]=qa(c,h,[a[f],f])}return o}static of(...e){const t=this;if(!zE(t,Qx))throw ii(tO);const i=e.length;if(t===Zi){const r=new Zi(i),s=Jt(r);for(let o=0;o<i;++o)s[o]=js(e[o]);return r}const a=new t(i);for(let r=0;r<i;++r)a[r]=e[r];return a}keys(){Sn(this);const e=Jt(this);return rte(e)}values(){Sn(this);const e=Jt(this);return uO(function*(){for(const t of ste(e))yield An(t)}())}entries(){Sn(this);const e=Jt(this);return uO(function*(){for(const[t,i]of ote(e))yield[t,An(i)]}())}at(e){Sn(this);const t=Jt(this),i=Tn(t),a=Po(e),r=a>=0?a:i+a;if(!(r<0||r>=i))return An(t[r])}with(e,t){Sn(this);const i=Jt(this),a=Tn(i),r=Po(e),s=r>=0?r:a+r,o=+t;if(s<0||s>=a)throw Z2(q2);const c=new _r(ji(i),uu(i),Tn(i)),h=new Zi(ji(Qp(c))),f=Jt(h);return f[s]=js(o),h}map(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0],s=Wv(i,Zi);if(s===Zi){const c=new Zi(a),h=Jt(c);for(let f=0;f<a;++f){const d=An(i[f]);h[f]=js(qa(e,r,[d,f,this]))}return c}const o=new s(a);Xv(o,a);for(let c=0;c<a;++c){const h=An(i[c]);o[c]=qa(e,r,[h,c,this])}return o}filter(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0],s=[];for(let h=0;h<a;++h){const f=An(i[h]);qa(e,r,[f,h,this])&&Zee(s,f)}const o=Wv(i,Zi),c=new o(s);return Xv(c),c}reduce(e,...t){Sn(this);const i=Jt(this),a=Tn(i);if(a===0&&t.length===0)throw ii(iO);let r,s;t.length===0?(r=An(i[0]),s=1):(r=t[0],s=0);for(let o=s;o<a;++o)r=e(r,An(i[o]),o,this);return r}reduceRight(e,...t){Sn(this);const i=Jt(this),a=Tn(i);if(a===0&&t.length===0)throw ii(iO);let r,s;t.length===0?(r=An(i[a-1]),s=a-2):(r=t[0],s=a-1);for(let o=s;o>=0;--o)r=e(r,An(i[o]),o,this);return r}forEach(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0];for(let s=0;s<a;++s)qa(e,r,[An(i[s]),s,this])}find(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0];for(let s=0;s<a;++s){const o=An(i[s]);if(qa(e,r,[o,s,this]))return o}}findIndex(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0];for(let s=0;s<a;++s){const o=An(i[s]);if(qa(e,r,[o,s,this]))return s}return-1}findLast(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0];for(let s=a-1;s>=0;--s){const o=An(i[s]);if(qa(e,r,[o,s,this]))return o}}findLastIndex(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0];for(let s=a-1;s>=0;--s){const o=An(i[s]);if(qa(e,r,[o,s,this]))return s}return-1}every(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0];for(let s=0;s<a;++s)if(!qa(e,r,[An(i[s]),s,this]))return!1;return!0}some(e,...t){Sn(this);const i=Jt(this),a=Tn(i),r=t[0];for(let s=0;s<a;++s)if(qa(e,r,[An(i[s]),s,this]))return!0;return!1}set(e,...t){Sn(this);const i=Jt(this),a=Po(t[0]);if(a<0)throw Z2(q2);if(e==null)throw ii(UE);if(FE(e))throw ii(PE);if(Wf(e))return lte(Jt(this),Jt(e),a);if(Kx(e)){const c=ji(e);if(Gm(c))throw ii(Fm)}const r=Tn(i),s=Ld(e),o=K2(s.length);if(a===1/0||o+a>r)throw Z2(q2);for(let c=0;c<o;++c)i[c+a]=js(s[c])}reverse(){Sn(this);const e=Jt(this);return oO(e),this}toReversed(){Sn(this);const e=Jt(this),t=new _r(ji(e),uu(e),Tn(e)),i=new Zi(ji(Qp(t))),a=Jt(i);return oO(a),i}fill(e,...t){Sn(this);const i=Jt(this);return cte(i,js(e),...dm(t)),this}copyWithin(e,t,...i){Sn(this);const a=Jt(this);return ute(a,e,t,...dm(i)),this}sort(e){Sn(this);const t=Jt(this),i=e!==void 0?e:pO;return lO(t,(a,r)=>i(An(a),An(r))),this}toSorted(e){Sn(this);const t=Jt(this);if(e!==void 0&&typeof e!="function")throw new ii(Fee);const i=e!==void 0?e:pO,a=new _r(ji(t),uu(t),Tn(t)),r=new Zi(ji(Qp(a))),s=Jt(r);return lO(s,(o,c)=>i(An(o),An(c))),r}slice(e,t){Sn(this);const i=Jt(this),a=Wv(i,Zi);if(a===Zi){const x=new _r(ji(i),uu(i),Tn(i));return new Zi(ji(Qp(x,e,t)))}const r=Tn(i),s=Po(e),o=t===void 0?r:Po(t);let c;s===-1/0?c=0:s<0?c=r+s>0?r+s:0:c=r<s?r:s;let h;o===-1/0?h=0:o<0?h=r+o>0?r+o:0:h=r<o?r:o;const f=h-c>0?h-c:0,d=new a(f);if(Xv(d,f),f===0)return d;const m=ji(i);if(Gm(m))throw ii(Fm);let g=0;for(;c<h;)d[g]=An(i[c]),++c,++g;return d}subarray(e,t){Sn(this);const i=Jt(this),a=Wv(i,Zi),r=new _r(ji(i),uu(i),Tn(i)),s=hte(r,e,t),o=new a(ji(s),uu(s),Tn(s));return Xv(o),o}indexOf(e,...t){Sn(this);const i=Jt(this),a=Tn(i);let r=Po(t[0]);if(r===1/0)return-1;r<0&&(r+=a,r<0&&(r=0));for(let s=r;s<a;++s)if(Wo(i,s)&&An(i[s])===e)return s;return-1}lastIndexOf(e,...t){Sn(this);const i=Jt(this),a=Tn(i);let r=t.length>=1?Po(t[0]):a-1;if(r===-1/0)return-1;r>=0?r=r<a-1?r:a-1:r+=a;for(let s=r;s>=0;--s)if(Wo(i,s)&&An(i[s])===e)return s;return-1}includes(e,...t){Sn(this);const i=Jt(this),a=Tn(i);let r=Po(t[0]);if(r===1/0)return!1;r<0&&(r+=a,r<0&&(r=0));const s=Od(e);for(let o=r;o<a;++o){const c=An(i[o]);if(s&&Od(c)||c===e)return!0}return!1}join(e){Sn(this);const t=Jt(this),i=mO(t);return jee(i,e)}toLocaleString(...e){Sn(this);const t=Jt(this),i=mO(t);return Kee(i,...dm(e))}get[sA](){if(Wf(this))return"Float16Array"}};W0(ll,"BYTES_PER_ELEMENT",{value:dA});W0(ll,Qx,{});rP(ll,lA);const $x=ll.prototype;W0($x,"BYTES_PER_ELEMENT",{value:dA});W0($x,so,{value:$x.values,writable:!0,configurable:!0});rP($x,na);function Dte(n,e,...t){return An(vte(n,e,...dm(t)))}let Ote=class extends Ti{constructor(e,t){super(t),this.parser=e}load(e,t,i,a){const r=new Dee(this.manager);r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),r.load(e,s=>{try{t(this.parser(s))}catch(o){a!=null?a(o):console.error(o),this.manager.itemError(e)}},i,a)}};function Lte(n){const e=n instanceof Int8Array?w1:n instanceof Uint8Array||n instanceof Uint8ClampedArray?Ii:n instanceof Int16Array?C1:n instanceof Uint16Array?Wu:n instanceof Int32Array?D0:n instanceof Uint32Array?Ns:n instanceof ll?Xn:n instanceof Float32Array||n instanceof Float64Array?ri:null;return qx(e!=null),e}let xu=class extends Ti{constructor(e,t,i={},a){super(a),this.textureClass=e,this.parser=t,this.options={format:Jn,minFilter:Ht,magFilter:Ht,...i}}load(e,t,i,a){const r=new this.textureClass,s=new Ote(this.parser,this.manager);return s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(this.withCredentials),s.load(e,o=>{r.image.data=o instanceof ll?new Uint16Array(o.buffer):o;const{width:c,height:h,depth:f,...d}=this.options;c!=null&&(r.image.width=c),h!=null&&(r.image.height=h),"depth"in r.image&&f!=null&&(r.image.depth=f),r.type=Lte(o),Object.assign(r,d),r.needsUpdate=!0,t==null||t(r)},i,a),r}};const e1=$t.clamp;$t.euclideanModulo;$t.inverseLerp;const bP=$t.lerp,Ite=$t.degToRad;$t.radToDeg;$t.isPowerOfTwo;$t.ceilPowerOfTwo;$t.floorPowerOfTwo;$t.normalize;function Ute(n,e,t,i=0,a=1){return $t.mapLinear(n,e,t,i,a)}function Pte(n){return Math.min(Math.max(n,0),1)}function dn(n){return(e,t)=>{e instanceof qn?Object.defineProperty(e,t,{enumerable:!0,get(){var i;return((i=this.defines)==null?void 0:i[n])!=null},set(i){var a;i!==this[t]&&(i?(this.defines??(this.defines={}),this.defines[n]="1"):(a=this.defines)==null||delete a[n],this.needsUpdate=!0)}}):Object.defineProperty(e,t,{enumerable:!0,get(){return this.defines.has(n)},set(i){i!==this[t]&&(i?this.defines.set(n,"1"):this.defines.delete(n),this.setChanged())}})}}function dh(n,{min:e=Number.MIN_SAFE_INTEGER,max:t=Number.MAX_SAFE_INTEGER}={}){return(i,a)=>{i instanceof qn?Object.defineProperty(i,a,{enumerable:!0,get(){var s;const r=(s=this.defines)==null?void 0:s[n];return r!=null?parseInt(r,10):0},set(r){const s=this[a];r!==s&&(this.defines??(this.defines={}),this.defines[n]=e1(r,e,t).toFixed(0),this.needsUpdate=!0)}}):Object.defineProperty(i,a,{enumerable:!0,get(){const r=this.defines.get(n);return r!=null?parseInt(r,10):0},set(r){const s=this[a];r!==s&&(this.defines.set(n,e1(r,e,t).toFixed(0)),this.setChanged())}})}}function pA(n,{min:e=-1/0,max:t=1/0,precision:i=7}={}){return(a,r)=>{a instanceof qn?Object.defineProperty(a,r,{enumerable:!0,get(){var o;const s=(o=this.defines)==null?void 0:o[n];return s!=null?parseFloat(s):0},set(s){const o=this[r];s!==o&&(this.defines??(this.defines={}),this.defines[n]=e1(s,e,t).toFixed(i),this.needsUpdate=!0)}}):Object.defineProperty(a,r,{enumerable:!0,get(){const s=this.defines.get(n);return s!=null?parseFloat(s):0},set(s){const o=this[r];s!==o&&(this.defines.set(n,e1(s,e,t).toFixed(i)),this.setChanged())}})}}function AP(n,{validate:e}={}){return(t,i)=>{t instanceof qn?Object.defineProperty(t,i,{enumerable:!0,get(){var a;return((a=this.defines)==null?void 0:a[n])??""},set(a){if(a!==this[i]){if((e==null?void 0:e(a))===!1){console.error(`Expression validation failed: ${a}`);return}this.defines??(this.defines={}),this.defines[n]=a,this.needsUpdate=!0}}}):Object.defineProperty(t,i,{enumerable:!0,get(){return this.defines.get(n)??""},set(a){if(a!==this[i]){if((e==null?void 0:e(a))===!1){console.error(`Expression validation failed: ${a}`);return}this.defines.set(n,a),this.setChanged()}}})}}function gO(n,...e){const t={};for(let i=0;i<e.length;i+=2){const a=e[i],r=e[i+1];for(const s of r)t[s]={enumerable:!0,get:()=>a[s],set:o=>{a[s]=o}}}return Object.defineProperties(n,t),n}function vO(n,e,t){const i={};for(const a of t)i[a]={enumerable:!0,get:()=>e.uniforms[a].value,set:r=>{e.uniforms[a].value=r}};return Object.defineProperties(n,i),n}class Q2 extends Ti{constructor(e={},t){super(t),this.options=e}load(e,t,i,a){const{width:r,height:s,depth:o}=this.options,c=new is(null,r,s,o),h=new eP(this.manager);return h.setRequestHeader(this.requestHeader),h.setPath(this.path),h.setWithCredentials(this.withCredentials),h.load(e,f=>{const{image:d}=f;c.image={data:d.data,width:r??d.width,height:s??d.height,depth:o??Math.sqrt(d.height)},c.type=f.type,c.format=f.format,c.colorSpace=f.colorSpace,c.needsUpdate=!0;try{t==null||t(c)}catch(m){a!=null?a(m):console.error(m),this.manager.itemError(e)}},i,a),c}}class _O extends Ti{constructor(e={},t){super(t),this.options=e}load(e,t,i,a){const{width:r,height:s}=this.options,o=new Ja(null,r,s),c=new eP(this.manager);return c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(this.withCredentials),c.load(e,h=>{const{image:f}=h;o.image={data:f.data,width:r??f.width,height:s??f.height},o.type=h.type,o.format=h.format,o.colorSpace=h.colorSpace,o.needsUpdate=!0;try{t==null||t(o)}catch(d){a!=null?a(d):console.error(d),this.manager.itemError(e)}},i,a),o}}const zte=/^[ \t]*#include +"([\w\d./]+)"/gm;function Ca(n,e){return n.replace(zte,(t,i)=>{const a=i.split("/").reduce((r,s)=>typeof r!="string"&&r!=null?r[s]:void 0,e);if(typeof a!="string")throw new Error(`Could not find include for ${i}.`);return Ca(a,e)})}let Yv;function Bte(){if(Yv!=null)return Yv;const n=new Uint32Array([268435456]);return Yv=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)[0]===0,Yv}function Hte(n,e,t,i=!0){if(i===Bte())return new e(n);const a=Object.assign(new DataView(n),{getFloat16(s,o){return Dte(this,s,o)}}),r=new e(a.byteLength/e.BYTES_PER_ELEMENT);for(let s=0,o=0;s<r.length;++s,o+=e.BYTES_PER_ELEMENT)r[s]=a[t](o,i);return r}const RP=n=>new Uint8Array(n),Jp=(n,e)=>Hte(n,ll,"getFloat16",e);class wP extends xu{constructor(e){super(is,RP,{format:bs,minFilter:Fn,magFilter:Fn,wrapS:Ta,wrapT:Ta,wrapR:Ta,width:Oee,height:Lee,depth:Iee},e)}}const Fte=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*(?:i\s*\+\+|\+\+\s*i)\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Gte(n,e,t,i){let a="";for(let r=parseInt(e,10);r<parseInt(t,10);++r)a+=i.replace(/\[\s*i\s*\]/g,"["+r+"]").replace(/UNROLLED_LOOP_INDEX/g,`${r}`);return a}function X0(n){return n.replace(Fte,Gte)}const Vte=`// Reference: https://github.com/mrdoob/three.js/blob/r171/examples/jsm/csm/CSMShader.js
#ifndef SHADOW_CASCADE_COUNT
#error "SHADOW_CASCADE_COUNT macro must be defined."
#endif // SHADOW_CASCADE_COUNT
int getCascadeIndex(
const mat4 viewMatrix,
const vec3 worldPosition,
const vec2 intervals[SHADOW_CASCADE_COUNT],
const float near,
const float far
) {
vec4 viewPosition = viewMatrix * vec4(worldPosition, 1.0);
float depth = viewZToOrthographicDepth(viewPosition.z, near, far);
vec2 interval;
#pragma unroll_loop_start
for (int i = 0; i < 4; ++i) {
#if UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
interval = intervals[i];
if (depth >= interval.x && depth < interval.y) {
return UNROLLED_LOOP_INDEX;
}
#endif // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
}
#pragma unroll_loop_end
return SHADOW_CASCADE_COUNT - 1;
}
int getFadedCascadeIndex(
const mat4 viewMatrix,
const vec3 worldPosition,
const vec2 intervals[SHADOW_CASCADE_COUNT],
const float near,
const float far,
const float jitter
) {
vec4 viewPosition = viewMatrix * vec4(worldPosition, 1.0);
float depth = viewZToOrthographicDepth(viewPosition.z, near, far);
vec2 interval;
float intervalCenter;
float closestEdge;
float margin;
int nextIndex = -1;
int prevIndex = -1;
float alpha;
#pragma unroll_loop_start
for (int i = 0; i < 4; ++i) {
#if UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
interval = intervals[i];
intervalCenter = (interval.x + interval.y) * 0.5;
closestEdge = depth < intervalCenter ? interval.x : interval.y;
margin = closestEdge * closestEdge * 0.5;
interval += margin * vec2(-0.5, 0.5);
#if UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT - 1
if (depth >= interval.x && depth < interval.y) {
prevIndex = nextIndex;
nextIndex = UNROLLED_LOOP_INDEX;
alpha = saturate(min(depth - interval.x, interval.y - depth) / margin);
}
#else // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT - 1
// Don't fade out the last cascade.
if (depth >= interval.x) {
prevIndex = nextIndex;
nextIndex = UNROLLED_LOOP_INDEX;
alpha = saturate((depth - interval.x) / margin);
}
#endif // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT - 1
#endif // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
}
#pragma unroll_loop_end
return jitter <= alpha
? nextIndex
: prevIndex;
}
`,kte=`// cSpell:words logdepthbuf
float reverseLogDepth(const float depth, const float near, const float far) {
#if defined(USE_LOGDEPTHBUF) || defined(USE_LOGARITHMIC_DEPTH_BUFFER)
float d = pow(2.0, depth * log2(far + 1.0)) - 1.0;
float a = far / (far - near);
float b = far * near / (near - far);
return a + b / d;
#else // defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(USE_LOGARITHMIC_DEPTH_BUFFER)
return depth;
#endif // defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(USE_LOGARITHMIC_DEPTH_BUFFER)
}
float linearizeDepth(const float depth, const float near, const float far) {
float ndc = depth * 2.0 - 1.0;
return 2.0 * near * far / (far + near - ndc * (far - near));
}
`,Wte=`float checker(const vec2 uv, const vec2 repeats) {
vec2 c = floor(repeats * uv);
float result = mod(c.x + c.y, 2.0);
return sign(result);
}
float checker(const vec2 uv, const float repeats) {
return checker(uv, vec2(repeats));
}
`,Xte=`// Reference: https://advances.realtimerendering.com/s2014/index.html#_NEXT_GENERATION_POST
float interleavedGradientNoise(const vec2 coord) {
const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
return fract(magic.z * fract(dot(coord, magic.xy)));
}
`,Yte=`#if !defined(saturate)
#define saturate(a) clamp(a, 0.0, 1.0)
#endif // !defined(saturate)
float remap(const float x, const float min1, const float max1, const float min2, const float max2) {
return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}
vec2 remap(const vec2 x, const vec2 min1, const vec2 max1, const vec2 min2, const vec2 max2) {
return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}
vec3 remap(const vec3 x, const vec3 min1, const vec3 max1, const vec3 min2, const vec3 max2) {
return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}
vec4 remap(const vec4 x, const vec4 min1, const vec4 max1, const vec4 min2, const vec4 max2) {
return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}
float remapClamped(
const float x,
const float min1,
const float max1,
const float min2,
const float max2
) {
return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}
vec2 remapClamped(
const vec2 x,
const vec2 min1,
const vec2 max1,
const vec2 min2,
const vec2 max2
) {
return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}
vec3 remapClamped(
const vec3 x,
const vec3 min1,
const vec3 max1,
const vec3 min2,
const vec3 max2
) {
return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}
vec4 remapClamped(
const vec4 x,
const vec4 min1,
const vec4 max1,
const vec4 min2,
const vec4 max2
) {
return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}
// Implicitly remap to 0 and 1
float remap(const float x, const float min1, const float max1) {
return (x - min1) / (max1 - min1);
}
vec2 remap(const vec2 x, const vec2 min1, const vec2 max1) {
return (x - min1) / (max1 - min1);
}
vec3 remap(const vec3 x, const vec3 min1, const vec3 max1) {
return (x - min1) / (max1 - min1);
}
vec4 remap(const vec4 x, const vec4 min1, const vec4 max1) {
return (x - min1) / (max1 - min1);
}
float remapClamped(const float x, const float min1, const float max1) {
return saturate((x - min1) / (max1 - min1));
}
vec2 remapClamped(const vec2 x, const vec2 min1, const vec2 max1) {
return saturate((x - min1) / (max1 - min1));
}
vec3 remapClamped(const vec3 x, const vec3 min1, const vec3 max1) {
return saturate((x - min1) / (max1 - min1));
}
vec4 remapClamped(const vec4 x, const vec4 min1, const vec4 max1) {
return saturate((x - min1) / (max1 - min1));
}
`,qte=`// Reference: https://jcgt.org/published/0003/02/01/paper.pdf
vec2 signNotZero(vec2 v) {
return vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);
}
vec2 packNormalToVec2(vec3 v) {
vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));
return v.z <= 0.0
? (1.0 - abs(p.yx)) * signNotZero(p)
: p;
}
vec3 unpackVec2ToNormal(vec2 e) {
vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));
if (v.z < 0.0) {
v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);
}
return normalize(v);
}
`,jte=`float raySphereFirstIntersection(
const vec3 origin,
const vec3 direction,
const vec3 center,
const float radius
) {
vec3 a = origin - center;
float b = 2.0 * dot(direction, a);
float c = dot(a, a) - radius * radius;
float discriminant = b * b - 4.0 * c;
return discriminant < 0.0
? -1.0
: (-b - sqrt(discriminant)) * 0.5;
}
float raySphereFirstIntersection(const vec3 origin, const vec3 direction, const float radius) {
return raySphereFirstIntersection(origin, direction, vec3(0.0), radius);
}
vec4 raySphereFirstIntersection(
const vec3 origin,
const vec3 direction,
const vec3 center,
const vec4 radius
) {
vec3 a = origin - center;
float b = 2.0 * dot(direction, a);
vec4 c = dot(a, a) - radius * radius;
vec4 discriminant = b * b - 4.0 * c;
vec4 mask = step(discriminant, vec4(0.0));
return mix((-b - sqrt(max(vec4(0.0), discriminant))) * 0.5, vec4(-1.0), mask);
}
vec4 raySphereFirstIntersection(const vec3 origin, const vec3 direction, const vec4 radius) {
return raySphereFirstIntersection(origin, direction, vec3(0.0), radius);
}
float raySphereSecondIntersection(
const vec3 origin,
const vec3 direction,
const vec3 center,
const float radius
) {
vec3 a = origin - center;
float b = 2.0 * dot(direction, a);
float c = dot(a, a) - radius * radius;
float discriminant = b * b - 4.0 * c;
return discriminant < 0.0
? -1.0
: (-b + sqrt(discriminant)) * 0.5;
}
float raySphereSecondIntersection(const vec3 origin, const vec3 direction, const float radius) {
return raySphereSecondIntersection(origin, direction, vec3(0.0), radius);
}
vec4 raySphereSecondIntersection(
const vec3 origin,
const vec3 direction,
const vec3 center,
const vec4 radius
) {
vec3 a = origin - center;
float b = 2.0 * dot(direction, a);
vec4 c = dot(a, a) - radius * radius;
vec4 discriminant = b * b - 4.0 * c;
vec4 mask = step(discriminant, vec4(0.0));
return mix((-b + sqrt(max(vec4(0.0), discriminant))) * 0.5, vec4(-1.0), mask);
}
vec4 raySphereSecondIntersection(const vec3 origin, const vec3 direction, const vec4 radius) {
return raySphereSecondIntersection(origin, direction, vec3(0.0), radius);
}
void raySphereIntersections(
const vec3 origin,
const vec3 direction,
const vec3 center,
const float radius,
out float intersection1,
out float intersection2
) {
vec3 a = origin - center;
float b = 2.0 * dot(direction, a);
float c = dot(a, a) - radius * radius;
float discriminant = b * b - 4.0 * c;
if (discriminant < 0.0) {
intersection1 = -1.0;
intersection2 = -1.0;
return;
} else {
float Q = sqrt(discriminant);
intersection1 = (-b - Q) * 0.5;
intersection2 = (-b + Q) * 0.5;
}
}
void raySphereIntersections(
const vec3 origin,
const vec3 direction,
const float radius,
out float intersection1,
out float intersection2
) {
raySphereIntersections(origin, direction, vec3(0.0), radius, intersection1, intersection2);
}
void raySphereIntersections(
const vec3 origin,
const vec3 direction,
const vec3 center,
const vec4 radius,
out vec4 intersection1,
out vec4 intersection2
) {
vec3 a = origin - center;
float b = 2.0 * dot(direction, a);
vec4 c = dot(a, a) - radius * radius;
vec4 discriminant = b * b - 4.0 * c;
vec4 mask = step(discriminant, vec4(0.0));
vec4 Q = sqrt(max(vec4(0.0), discriminant));
intersection1 = mix((-b - Q) * 0.5, vec4(-1.0), mask);
intersection2 = mix((-b + Q) * 0.5, vec4(-1.0), mask);
}
void raySphereIntersections(
const vec3 origin,
const vec3 direction,
const vec4 radius,
out vec4 intersection1,
out vec4 intersection2
) {
raySphereIntersections(origin, direction, vec3(0.0), radius, intersection1, intersection2);
}
`,Zte=`vec3 screenToView(
const vec2 uv,
const float depth,
const float viewZ,
const mat4 projectionMatrix,
const mat4 inverseProjectionMatrix
) {
vec4 clip = vec4(vec3(uv, depth) * 2.0 - 1.0, 1.0);
float clipW = projectionMatrix[2][3] * viewZ + projectionMatrix[3][3];
clip *= clipW;
return (inverseProjectionMatrix * clip).xyz;
}
`,Kte=`// A fifth-order polynomial approximation of Turbo color map.
// See: https://observablehq.com/@mbostock/turbo
// prettier-ignore
vec3 turbo(const float x) {
float r = 0.1357 + x * (4.5974 - x * (42.3277 - x * (130.5887 - x * (150.5666 - x * 58.1375))));
float g = 0.0914 + x * (2.1856 + x * (4.8052 - x * (14.0195 - x * (4.2109 + x * 2.7747))));
float b = 0.1067 + x * (12.5925 - x * (60.1097 - x * (109.0745 - x * (88.5066 - x * 26.8183))));
return vec3(r, g, b);
}
`,Qte=`// Reference: https://www.gamedev.net/tutorials/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
vec2 vogelDisk(const int index, const int sampleCount, const float phi) {
const float goldenAngle = 2.39996322972865332;
float r = sqrt(float(index) + 0.5) / sqrt(float(sampleCount));
float theta = float(index) * goldenAngle + phi;
return r * vec2(cos(theta), sin(theta));
}
`,CP=Vte,NP=kte,Jte=Wte,DP=Xte,mA=Yte,$te=qte,fy=jte,ene=Zte,OP=Kte,LP=Qte,Kd=64,Qd=16,dy=32,py=128,my=32,gy=8,Uu=gy*my,Pu=py,zu=dy,Jd=256,$d=64,t1=1/1e3,tne=new L;function gA(n,e,t,i){const a=t.projectOnSurface(n,tne);return a!=null?t.getOsculatingSphereCenter(a,e,i).negate():i.setScalar(0)}var nne="Invariant failed";function ine(n,e){if(!n)throw new Error(nne)}const xO=typeof window<"u"&&window.requestIdleCallback!=null?window.requestIdleCallback:function(n,e={}){const t=e.timeout??1,i=performance.now();return setTimeout(function(){n({get didTimeout(){return e.timeout!=null?!1:performance.now()-i-1>t},timeRemaining:function(){return Math.max(0,1+(performance.now()-i))}})},1)},Zs=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/functions.glsl
/**
* Copyright (c) 2017 Eric Bruneton
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* Precomputed Atmospheric Scattering
* Copyright (c) 2008 INRIA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
Number ClampCosine(const Number mu) {
return clamp(mu, Number(-1.0), Number(1.0));
}
Length ClampDistance(const Length d) {
return max(d, 0.0 * m);
}
Length ClampRadius(const AtmosphereParameters atmosphere, const Length r) {
return clamp(r, atmosphere.bottom_radius, atmosphere.top_radius);
}
Length SafeSqrt(const Area a) {
return sqrt(max(a, 0.0 * m2));
}
Length DistanceToTopAtmosphereBoundary(const AtmosphereParameters atmosphere,
const Length r, const Number mu) {
assert(r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
Area discriminant = r * r * (mu * mu - 1.0) +
atmosphere.top_radius * atmosphere.top_radius;
return ClampDistance(-r * mu + SafeSqrt(discriminant));
}
Length DistanceToBottomAtmosphereBoundary(const AtmosphereParameters atmosphere,
const Length r, const Number mu) {
assert(r >= atmosphere.bottom_radius);
assert(mu >= -1.0 && mu <= 1.0);
Area discriminant = r * r * (mu * mu - 1.0) +
atmosphere.bottom_radius * atmosphere.bottom_radius;
return ClampDistance(-r * mu - SafeSqrt(discriminant));
}
bool RayIntersectsGround(const AtmosphereParameters atmosphere,
const Length r, const Number mu) {
assert(r >= atmosphere.bottom_radius);
assert(mu >= -1.0 && mu <= 1.0);
return mu < 0.0 && r * r * (mu * mu - 1.0) +
atmosphere.bottom_radius * atmosphere.bottom_radius >= 0.0 * m2;
}
Number GetTextureCoordFromUnitRange(const Number x, const int texture_size) {
return 0.5 / Number(texture_size) + x * (1.0 - 1.0 / Number(texture_size));
}
vec2 GetTransmittanceTextureUvFromRMu(const AtmosphereParameters atmosphere,
const Length r, const Number mu) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
// Distance to top atmosphere boundary for a horizontal ray at ground level.
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
atmosphere.bottom_radius * atmosphere.bottom_radius);
// Distance to the horizon.
Length rho =
SafeSqrt(r * r - atmosphere.bottom_radius * atmosphere.bottom_radius);
// Distance to the top atmosphere boundary for the ray (r,mu), and its minimum
// and maximum values over all mu - obtained for (r,1) and (r,mu_horizon).
Length d = DistanceToTopAtmosphereBoundary(atmosphere, r, mu);
Length d_min = atmosphere.top_radius - r;
Length d_max = rho + H;
Number x_mu = (d - d_min) / (d_max - d_min);
Number x_r = rho / H;
return vec2(GetTextureCoordFromUnitRange(x_mu, TRANSMITTANCE_TEXTURE_WIDTH),
GetTextureCoordFromUnitRange(x_r, TRANSMITTANCE_TEXTURE_HEIGHT));
}
DimensionlessSpectrum GetTransmittanceToTopAtmosphereBoundary(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const Length r, const Number mu) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
vec2 uv = GetTransmittanceTextureUvFromRMu(atmosphere, r, mu);
// @shotamatsuda: Added for the precomputation stage in half-float precision.
#ifdef TRANSMITTANCE_PRECISION_LOG
// Manually interpolate the transmittance instead of the optical depth.
const vec2 size = vec2(TRANSMITTANCE_TEXTURE_WIDTH, TRANSMITTANCE_TEXTURE_HEIGHT);
const vec3 texel_size = vec3(1.0 / size, 0.0);
vec2 coord = (uv * size) - 0.5;
vec2 i = (floor(coord) + 0.5) * texel_size.xy;
vec2 f = fract(coord);
vec4 t1 = exp(-texture(transmittance_texture, i));
vec4 t2 = exp(-texture(transmittance_texture, i + texel_size.xz));
vec4 t3 = exp(-texture(transmittance_texture, i + texel_size.zy));
vec4 t4 = exp(-texture(transmittance_texture, i + texel_size.xy));
return DimensionlessSpectrum(mix(mix(t1, t2, f.x), mix(t3, t4, f.x), f.y));
#else // TRANSMITTANCE_PRECISION_LOG
return DimensionlessSpectrum(texture(transmittance_texture, uv));
#endif // TRANSMITTANCE_PRECISION_LOG
}
DimensionlessSpectrum GetTransmittance(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const Length r, const Number mu, const Length d,
const bool ray_r_mu_intersects_ground) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
assert(d >= 0.0 * m);
Length r_d = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
Number mu_d = ClampCosine((r * mu + d) / r_d);
if (ray_r_mu_intersects_ground) {
return min(
GetTransmittanceToTopAtmosphereBoundary(
atmosphere, transmittance_texture, r_d, -mu_d) /
GetTransmittanceToTopAtmosphereBoundary(
atmosphere, transmittance_texture, r, -mu),
DimensionlessSpectrum(1.0));
} else {
return min(
GetTransmittanceToTopAtmosphereBoundary(
atmosphere, transmittance_texture, r, mu) /
GetTransmittanceToTopAtmosphereBoundary(
atmosphere, transmittance_texture, r_d, mu_d),
DimensionlessSpectrum(1.0));
}
}
DimensionlessSpectrum GetTransmittanceToSun(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const Length r, const Number mu_s) {
Number sin_theta_h = atmosphere.bottom_radius / r;
Number cos_theta_h = -sqrt(max(1.0 - sin_theta_h * sin_theta_h, 0.0));
return GetTransmittanceToTopAtmosphereBoundary(
atmosphere, transmittance_texture, r, mu_s) *
smoothstep(-sin_theta_h * atmosphere.sun_angular_radius / rad,
sin_theta_h * atmosphere.sun_angular_radius / rad,
mu_s - cos_theta_h);
}
InverseSolidAngle RayleighPhaseFunction(const Number nu) {
InverseSolidAngle k = 3.0 / (16.0 * PI * sr);
return k * (1.0 + nu * nu);
}
InverseSolidAngle MiePhaseFunction(const Number g, const Number nu) {
InverseSolidAngle k = 3.0 / (8.0 * PI * sr) * (1.0 - g * g) / (2.0 + g * g);
return k * (1.0 + nu * nu) / pow(1.0 + g * g - 2.0 * g * nu, 1.5);
}
vec4 GetScatteringTextureUvwzFromRMuMuSNu(const AtmosphereParameters atmosphere,
const Length r, const Number mu, const Number mu_s, const Number nu,
const bool ray_r_mu_intersects_ground) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
assert(mu_s >= -1.0 && mu_s <= 1.0);
assert(nu >= -1.0 && nu <= 1.0);
// Distance to top atmosphere boundary for a horizontal ray at ground level.
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
atmosphere.bottom_radius * atmosphere.bottom_radius);
// Distance to the horizon.
Length rho =
SafeSqrt(r * r - atmosphere.bottom_radius * atmosphere.bottom_radius);
Number u_r = GetTextureCoordFromUnitRange(rho / H, SCATTERING_TEXTURE_R_SIZE);
// Discriminant of the quadratic equation for the intersections of the ray
// (r,mu) with the ground (see RayIntersectsGround).
Length r_mu = r * mu;
Area discriminant =
r_mu * r_mu - r * r + atmosphere.bottom_radius * atmosphere.bottom_radius;
Number u_mu;
if (ray_r_mu_intersects_ground) {
// Distance to the ground for the ray (r,mu), and its minimum and maximum
// values over all mu - obtained for (r,-1) and (r,mu_horizon).
Length d = -r_mu - SafeSqrt(discriminant);
Length d_min = r - atmosphere.bottom_radius;
Length d_max = rho;
u_mu = 0.5 - 0.5 * GetTextureCoordFromUnitRange(d_max == d_min ? 0.0 :
(d - d_min) / (d_max - d_min), SCATTERING_TEXTURE_MU_SIZE / 2);
} else {
// Distance to the top atmosphere boundary for the ray (r,mu), and its
// minimum and maximum values over all mu - obtained for (r,1) and
// (r,mu_horizon).
Length d = -r_mu + SafeSqrt(discriminant + H * H);
Length d_min = atmosphere.top_radius - r;
Length d_max = rho + H;
u_mu = 0.5 + 0.5 * GetTextureCoordFromUnitRange(
(d - d_min) / (d_max - d_min), SCATTERING_TEXTURE_MU_SIZE / 2);
}
Length d = DistanceToTopAtmosphereBoundary(
atmosphere, atmosphere.bottom_radius, mu_s);
Length d_min = atmosphere.top_radius - atmosphere.bottom_radius;
Length d_max = H;
Number a = (d - d_min) / (d_max - d_min);
Length D = DistanceToTopAtmosphereBoundary(
atmosphere, atmosphere.bottom_radius, atmosphere.mu_s_min);
Number A = (D - d_min) / (d_max - d_min);
// An ad-hoc function equal to 0 for mu_s = mu_s_min (because then d = D and
// thus a = A), equal to 1 for mu_s = 1 (because then d = d_min and thus
// a = 0), and with a large slope around mu_s = 0, to get more texture
// samples near the horizon.
Number u_mu_s = GetTextureCoordFromUnitRange(
max(1.0 - a / A, 0.0) / (1.0 + a), SCATTERING_TEXTURE_MU_S_SIZE);
Number u_nu = (nu + 1.0) / 2.0;
return vec4(u_nu, u_mu_s, u_mu, u_r);
}
vec2 GetIrradianceTextureUvFromRMuS(const AtmosphereParameters atmosphere,
const Length r, const Number mu_s) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu_s >= -1.0 && mu_s <= 1.0);
Number x_r = (r - atmosphere.bottom_radius) /
(atmosphere.top_radius - atmosphere.bottom_radius);
Number x_mu_s = mu_s * 0.5 + 0.5;
return vec2(GetTextureCoordFromUnitRange(x_mu_s, IRRADIANCE_TEXTURE_WIDTH),
GetTextureCoordFromUnitRange(x_r, IRRADIANCE_TEXTURE_HEIGHT));
}
IrradianceSpectrum GetIrradiance(
const AtmosphereParameters atmosphere,
const IrradianceTexture irradiance_texture,
const Length r, const Number mu_s) {
vec2 uv = GetIrradianceTextureUvFromRMuS(atmosphere, r, mu_s);
return IrradianceSpectrum(texture(irradiance_texture, uv));
}
`,Ks=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/definitions.glsl
/**
* Copyright (c) 2017 Eric Bruneton
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#define assert(x)
#define Length float
#define Wavelength float
#define Angle float
#define SolidAngle float
#define Power float
#define LuminousPower float
#define Number float
#define InverseLength float
#define Area float
#define Volume float
#define NumberDensity float
#define Irradiance float
#define Radiance float
#define SpectralPower float
#define SpectralIrradiance float
#define SpectralRadiance float
#define SpectralRadianceDensity float
#define ScatteringCoefficient float
#define InverseSolidAngle float
#define LuminousIntensity float
#define Luminance float
#define Illuminance float
// A generic function from Wavelength to some other type.
#define AbstractSpectrum vec3
// A function from Wavelength to Number.
#define DimensionlessSpectrum vec3
// A function from Wavelength to SpectralPower.
#define PowerSpectrum vec3
// A function from Wavelength to SpectralIrradiance.
#define IrradianceSpectrum vec3
// A function from Wavelength to SpectralRadiance.
#define RadianceSpectrum vec3
// A function from Wavelength to SpectralRadianceDensity.
#define RadianceDensitySpectrum vec3
// A function from Wavelength to ScatteringCoefficient.
#define ScatteringSpectrum vec3
// A position in 3D (3 length values).
#define Position vec3
// A unit direction vector in 3D (3 unit-less values).
#define Direction vec3
// A vector of 3 luminance values.
#define Luminance3 vec3
// A vector of 3 illuminance values.
#define Illuminance3 vec3
#define TransmittanceTexture sampler2D
#define AbstractScatteringTexture sampler3D
#define ReducedScatteringTexture sampler3D
#define ScatteringTexture sampler3D
#define ScatteringDensityTexture sampler3D
#define IrradianceTexture sampler2D
const Length m = 1.0;
const Wavelength nm = 1.0;
const Angle rad = 1.0;
const SolidAngle sr = 1.0;
const Power watt = 1.0;
const LuminousPower lm = 1.0;
#if !defined(PI)
const float PI = 3.14159265358979323846;
#endif // !defined(PI)
const Length km = 1000.0 * m;
const Area m2 = m * m;
const Volume m3 = m * m * m;
const Angle pi = PI * rad;
const Angle deg = pi / 180.0;
const Irradiance watt_per_square_meter = watt / m2;
const Radiance watt_per_square_meter_per_sr = watt / (m2 * sr);
const SpectralIrradiance watt_per_square_meter_per_nm = watt / (m2 * nm);
const SpectralRadiance watt_per_square_meter_per_sr_per_nm = watt / (m2 * sr * nm);
const SpectralRadianceDensity watt_per_cubic_meter_per_sr_per_nm = watt / (m3 * sr * nm);
const LuminousIntensity cd = lm / sr;
const LuminousIntensity kcd = 1000.0 * cd;
const Luminance cd_per_square_meter = cd / m2;
const Luminance kcd_per_square_meter = kcd / m2;
struct DensityProfileLayer {
Length width;
Number exp_term;
InverseLength exp_scale;
InverseLength linear_term;
Number constant_term;
};
struct DensityProfile {
DensityProfileLayer layers[2];
};
// See AtmosphereParameter.ts for further details.
struct AtmosphereParameters {
IrradianceSpectrum solar_irradiance;
Angle sun_angular_radius;
Length bottom_radius;
Length top_radius;
DensityProfile rayleigh_density;
ScatteringSpectrum rayleigh_scattering;
DensityProfile mie_density;
ScatteringSpectrum mie_scattering;
ScatteringSpectrum mie_extinction;
Number mie_phase_function_g;
DensityProfile absorption_density;
ScatteringSpectrum absorption_extinction;
DimensionlessSpectrum ground_albedo;
Number mu_s_min;
};
`,vy=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/functions.glsl
/**
* Copyright (c) 2017 Eric Bruneton
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* Precomputed Atmospheric Scattering
* Copyright (c) 2008 INRIA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef COMBINED_SCATTERING_TEXTURES
vec3 GetExtrapolatedSingleMieScattering(
const AtmosphereParameters atmosphere, const vec4 scattering) {
// Algebraically this can never be negative, but rounding errors can produce
// that effect for sufficiently short view rays.
// @shotamatsuda: Avoid division by infinitesimal values.
// See https://github.com/takram-design-engineering/three-geospatial/issues/47
if (scattering.r < 1e-5) {
return vec3(0.0);
}
return scattering.rgb * scattering.a / scattering.r *
(atmosphere.rayleigh_scattering.r / atmosphere.mie_scattering.r) *
(atmosphere.mie_scattering / atmosphere.rayleigh_scattering);
}
#endif // COMBINED_SCATTERING_TEXTURES
IrradianceSpectrum GetCombinedScattering(
const AtmosphereParameters atmosphere,
const ReducedScatteringTexture scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const bool ray_r_mu_intersects_ground,
out IrradianceSpectrum single_mie_scattering) {
vec4 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
atmosphere, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
Number tex_coord_x = uvwz.x * Number(SCATTERING_TEXTURE_NU_SIZE - 1);
Number tex_x = floor(tex_coord_x);
Number lerp = tex_coord_x - tex_x;
vec3 uvw0 = vec3((tex_x + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
uvwz.z, uvwz.w);
vec3 uvw1 = vec3((tex_x + 1.0 + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
uvwz.z, uvwz.w);
#ifdef COMBINED_SCATTERING_TEXTURES
vec4 combined_scattering =
texture(scattering_texture, uvw0) * (1.0 - lerp) +
texture(scattering_texture, uvw1) * lerp;
IrradianceSpectrum scattering = IrradianceSpectrum(combined_scattering);
single_mie_scattering =
GetExtrapolatedSingleMieScattering(atmosphere, combined_scattering);
#else // COMBINED_SCATTERING_TEXTURES
IrradianceSpectrum scattering = IrradianceSpectrum(
texture(scattering_texture, uvw0) * (1.0 - lerp) +
texture(scattering_texture, uvw1) * lerp);
single_mie_scattering = IrradianceSpectrum(
texture(single_mie_scattering_texture, uvw0) * (1.0 - lerp) +
texture(single_mie_scattering_texture, uvw1) * lerp);
#endif // COMBINED_SCATTERING_TEXTURES
return scattering;
}
// @shotamatsuda: Added for reading higher-order scattering texture.
#ifdef HAS_HIGHER_ORDER_SCATTERING_TEXTURE
IrradianceSpectrum GetScattering(
const AtmosphereParameters atmosphere,
const ReducedScatteringTexture scattering_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const bool ray_r_mu_intersects_ground) {
vec4 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
atmosphere, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
Number tex_coord_x = uvwz.x * Number(SCATTERING_TEXTURE_NU_SIZE - 1);
Number tex_x = floor(tex_coord_x);
Number lerp = tex_coord_x - tex_x;
vec3 uvw0 = vec3((tex_x + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
uvwz.z, uvwz.w);
vec3 uvw1 = vec3((tex_x + 1.0 + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
uvwz.z, uvwz.w);
IrradianceSpectrum scattering = IrradianceSpectrum(
texture(scattering_texture, uvw0) * (1.0 - lerp) +
texture(scattering_texture, uvw1) * lerp);
return scattering;
}
#endif // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
RadianceSpectrum GetSkyRadiance(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const ReducedScatteringTexture scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
Position camera, const Direction view_ray, const Length shadow_length,
const Direction sun_direction,
out DimensionlessSpectrum transmittance) {
// Compute the distance to the top atmosphere boundary along the view ray,
// assuming the viewer is in space (or NaN if the view ray does not intersect
// the atmosphere).
Length r = length(camera);
Length rmu = dot(camera, view_ray);
// @shotamatsuda: Use SafeSqrt instead.
// See: https://github.com/takram-design-engineering/three-geospatial/pull/26
Length distance_to_top_atmosphere_boundary = -rmu -
SafeSqrt(rmu * rmu - r * r +
atmosphere.top_radius * atmosphere.top_radius);
// If the viewer is in space and the view ray intersects the atmosphere, move
// the viewer to the top atmosphere boundary (along the view ray):
if (distance_to_top_atmosphere_boundary > 0.0 * m) {
camera = camera + view_ray * distance_to_top_atmosphere_boundary;
r = atmosphere.top_radius;
rmu += distance_to_top_atmosphere_boundary;
} else if (r > atmosphere.top_radius) {
// If the view ray does not intersect the atmosphere, simply return 0.
transmittance = DimensionlessSpectrum(1.0);
return RadianceSpectrum(0.0 * watt_per_square_meter_per_sr_per_nm);
}
// Compute the r, mu, mu_s and nu parameters needed for the texture lookups.
Number mu = rmu / r;
Number mu_s = dot(camera, sun_direction) / r;
Number nu = dot(view_ray, sun_direction);
// @shotamatsuda: For rendering points below the bottom atmosphere.
#ifdef GROUND
bool ray_r_mu_intersects_ground = RayIntersectsGround(atmosphere, r, mu);
#else // GROUND
bool ray_r_mu_intersects_ground = false;
#endif // GROUND
transmittance = ray_r_mu_intersects_ground ? DimensionlessSpectrum(0.0) :
GetTransmittanceToTopAtmosphereBoundary(
atmosphere, transmittance_texture, r, mu);
IrradianceSpectrum single_mie_scattering;
IrradianceSpectrum scattering;
if (shadow_length == 0.0 * m) {
scattering = GetCombinedScattering(
atmosphere, scattering_texture, single_mie_scattering_texture,
r, mu, mu_s, nu, ray_r_mu_intersects_ground,
single_mie_scattering);
} else {
// Case of light shafts (shadow_length is the total length noted l in our
// paper): we omit the scattering between the camera and the point at
// distance l, by implementing Eq. (18) of the paper (shadow_transmittance
// is the T(x,x_s) term, scattering is the S|x_s=x+lv term).
Length d = shadow_length;
Length r_p =
ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
Number mu_p = (r * mu + d) / r_p;
Number mu_s_p = (r * mu_s + d * nu) / r_p;
scattering = GetCombinedScattering(
atmosphere, scattering_texture, single_mie_scattering_texture,
r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground,
single_mie_scattering);
DimensionlessSpectrum shadow_transmittance =
GetTransmittance(atmosphere, transmittance_texture,
r, mu, shadow_length, ray_r_mu_intersects_ground);
// @shotamatsuda: Occlude only single Rayleigh scattering by the shadow.
#ifdef HAS_HIGHER_ORDER_SCATTERING_TEXTURE
IrradianceSpectrum higher_order_scattering = GetScattering(
atmosphere, higher_order_scattering_texture,
r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground);
IrradianceSpectrum single_scattering = scattering - higher_order_scattering;
scattering = single_scattering * shadow_transmittance + higher_order_scattering;
#else // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
scattering = scattering * shadow_transmittance;
#endif // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
single_mie_scattering = single_mie_scattering * shadow_transmittance;
}
return scattering * RayleighPhaseFunction(nu) + single_mie_scattering *
MiePhaseFunction(atmosphere.mie_phase_function_g, nu);
}
// @shotamatsuda: Returns the point on the ray closest to the origin.
vec3 ClosestPointOnRay(const Position camera, const Position point) {
Position ray = point - camera;
Number t = clamp(-dot(camera, ray) / dot(ray, ray), 0.0, 1.0);
return camera + t * ray;
}
vec2 RaySphereIntersections(
const Position camera, const Direction direction, const Length radius) {
float b = 2.0 * dot(direction, camera);
float c = dot(camera, camera) - radius * radius;
float discriminant = b * b - 4.0 * c;
float Q = sqrt(discriminant);
return vec2(-b - Q, -b + Q) * 0.5;
}
// @shotamatsuda: Clip the view ray at the bottom atmosphere boundary.
bool ClipAtBottomAtmosphere(
const AtmosphereParameters atmosphere,
const Direction view_ray, inout Position camera, inout Position point) {
const Length eps = 0.0;
Length bottom_radius = atmosphere.bottom_radius + eps;
Length r_camera = length(camera);
Length r_point = length(point);
bool camera_below = r_camera < bottom_radius;
bool point_below = r_point < bottom_radius;
vec2 t = RaySphereIntersections(camera, view_ray, bottom_radius);
Position intersection = camera + view_ray * (camera_below ? t.y : t.x);
camera = camera_below ? intersection : camera;
point = point_below ? intersection : point;
return camera_below && point_below;
}
RadianceSpectrum GetSkyRadianceToPoint(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const ReducedScatteringTexture scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
Position camera, Position point, const Length shadow_length,
const Direction sun_direction, out DimensionlessSpectrum transmittance) {
// @shotamatsuda: Avoid artifacts when the ray does not intersect the top
// atmosphere boundary.
if (length(ClosestPointOnRay(camera, point)) > atmosphere.top_radius) {
transmittance = vec3(1.0);
return vec3(0.0);
}
Direction view_ray = normalize(point - camera);
if (ClipAtBottomAtmosphere(atmosphere, view_ray, camera, point)) {
transmittance = vec3(1.0);
return vec3(0.0);
}
// Compute the distance to the top atmosphere boundary along the view ray,
// assuming the viewer is in space (or NaN if the view ray does not intersect
// the atmosphere).
Length r = length(camera);
Length rmu = dot(camera, view_ray);
// @shotamatsuda: Use SafeSqrt instead.
// See: https://github.com/takram-design-engineering/three-geospatial/pull/26
Length distance_to_top_atmosphere_boundary = -rmu -
SafeSqrt(rmu * rmu - r * r +
atmosphere.top_radius * atmosphere.top_radius);
// If the viewer is in space and the view ray intersects the atmosphere, move
// the viewer to the top atmosphere boundary (along the view ray):
if (distance_to_top_atmosphere_boundary > 0.0 * m) {
camera = camera + view_ray * distance_to_top_atmosphere_boundary;
r = atmosphere.top_radius;
rmu += distance_to_top_atmosphere_boundary;
}
// Compute the r, mu, mu_s and nu parameters for the first texture lookup.
Number mu = rmu / r;
Number mu_s = dot(camera, sun_direction) / r;
Number nu = dot(view_ray, sun_direction);
Length d = length(point - camera);
bool ray_r_mu_intersects_ground = RayIntersectsGround(atmosphere, r, mu);
// @shotamatsuda: Hack to avoid rendering artifacts near the horizon, due to
// finite atmosphere texture resolution and finite floating point precision.
// See: https://github.com/ebruneton/precomputed_atmospheric_scattering/pull/32
if (!ray_r_mu_intersects_ground) {
Number mu_horizon = -SafeSqrt(1.0 -
(atmosphere.bottom_radius * atmosphere.bottom_radius) / (r * r));
const Number eps = 0.004;
mu = max(mu, mu_horizon + eps);
}
transmittance = GetTransmittance(atmosphere, transmittance_texture,
r, mu, d, ray_r_mu_intersects_ground);
IrradianceSpectrum single_mie_scattering;
IrradianceSpectrum scattering = GetCombinedScattering(
atmosphere, scattering_texture, single_mie_scattering_texture,
r, mu, mu_s, nu, ray_r_mu_intersects_ground,
single_mie_scattering);
// Compute the r, mu, mu_s and nu parameters for the second texture lookup.
// If shadow_length is not 0 (case of light shafts), we want to ignore the
// scattering along the last shadow_length meters of the view ray, which we
// do by subtracting shadow_length from d (this way scattering_p is equal to
// the S|x_s=x_0-lv term in Eq. (17) of our paper).
d = max(d - shadow_length, 0.0 * m);
Length r_p = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
Number mu_p = (r * mu + d) / r_p;
Number mu_s_p = (r * mu_s + d * nu) / r_p;
IrradianceSpectrum single_mie_scattering_p;
IrradianceSpectrum scattering_p = GetCombinedScattering(
atmosphere, scattering_texture, single_mie_scattering_texture,
r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground,
single_mie_scattering_p);
// Combine the lookup results to get the scattering between camera and point.
DimensionlessSpectrum shadow_transmittance = transmittance;
if (shadow_length > 0.0 * m) {
// This is the T(x,x_s) term in Eq. (17) of our paper, for light shafts.
shadow_transmittance = GetTransmittance(atmosphere, transmittance_texture,
r, mu, d, ray_r_mu_intersects_ground);
}
// @shotamatsuda: Occlude only single Rayleigh scattering by the shadow.
#ifdef HAS_HIGHER_ORDER_SCATTERING_TEXTURE
IrradianceSpectrum higher_order_scattering = GetScattering(
atmosphere, higher_order_scattering_texture,
r, mu, mu_s, nu, ray_r_mu_intersects_ground);
IrradianceSpectrum single_scattering = scattering - higher_order_scattering;
IrradianceSpectrum higher_order_scattering_p = GetScattering(
atmosphere, higher_order_scattering_texture,
r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground);
IrradianceSpectrum single_scattering_p =
scattering_p - higher_order_scattering_p;
scattering =
single_scattering - shadow_transmittance * single_scattering_p +
higher_order_scattering - transmittance * higher_order_scattering_p;
#else // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
scattering = scattering - shadow_transmittance * scattering_p;
#endif // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
single_mie_scattering =
single_mie_scattering - shadow_transmittance * single_mie_scattering_p;
#ifdef COMBINED_SCATTERING_TEXTURES
single_mie_scattering = GetExtrapolatedSingleMieScattering(
atmosphere, vec4(scattering, single_mie_scattering.r));
#endif // COMBINED_SCATTERING_TEXTURES
// Hack to avoid rendering artifacts when the sun is below the horizon.
single_mie_scattering = single_mie_scattering *
smoothstep(Number(0.0), Number(0.01), mu_s);
return scattering * RayleighPhaseFunction(nu) + single_mie_scattering *
MiePhaseFunction(atmosphere.mie_phase_function_g, nu);
}
IrradianceSpectrum GetSunAndSkyIrradiance(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const IrradianceTexture irradiance_texture,
const Position point, const Direction normal, const Direction sun_direction,
out IrradianceSpectrum sky_irradiance) {
Length r = length(point);
Number mu_s = dot(point, sun_direction) / r;
// Indirect irradiance (approximated if the surface is not horizontal).
sky_irradiance = GetIrradiance(atmosphere, irradiance_texture, r, mu_s) *
(1.0 + dot(normal, point) / r) * 0.5;
// Direct irradiance.
return atmosphere.solar_irradiance *
GetTransmittanceToSun(
atmosphere, transmittance_texture, r, mu_s) *
max(dot(normal, sun_direction), 0.0);
}
// @shotamatsuda: Added for the clouds.
IrradianceSpectrum GetSunAndSkyScalarIrradiance(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const IrradianceTexture irradiance_texture,
const Position point, const Direction sun_direction,
out IrradianceSpectrum sky_irradiance) {
Length r = length(point);
Number mu_s = dot(point, sun_direction) / r;
// Indirect irradiance. Integral over sphere yields 2π.
sky_irradiance = GetIrradiance(atmosphere, irradiance_texture, r, mu_s) *
2.0 * PI;
// Direct irradiance. Omit the cosine term.
return atmosphere.solar_irradiance *
GetTransmittanceToSun(atmosphere, transmittance_texture, r, mu_s);
}
Luminance3 GetSolarLuminance() {
return ATMOSPHERE.solar_irradiance /
(PI * ATMOSPHERE.sun_angular_radius * ATMOSPHERE.sun_angular_radius) *
SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
}
Luminance3 GetSkyLuminance(
const Position camera, Direction view_ray, const Length shadow_length,
const Direction sun_direction, out DimensionlessSpectrum transmittance) {
return GetSkyRadiance(ATMOSPHERE, transmittance_texture,
scattering_texture, single_mie_scattering_texture,
camera, view_ray, shadow_length, sun_direction,
transmittance) * SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
}
Luminance3 GetSkyLuminanceToPoint(
const Position camera, const Position point, const Length shadow_length,
const Direction sun_direction, out DimensionlessSpectrum transmittance) {
return GetSkyRadianceToPoint(ATMOSPHERE, transmittance_texture,
scattering_texture, single_mie_scattering_texture,
camera, point, shadow_length, sun_direction, transmittance) *
SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
}
Illuminance3 GetSunAndSkyIlluminance(
const Position p, const Direction normal, const Direction sun_direction,
out IrradianceSpectrum sky_irradiance) {
IrradianceSpectrum sun_irradiance = GetSunAndSkyIrradiance(
ATMOSPHERE, transmittance_texture, irradiance_texture, p, normal,
sun_direction, sky_irradiance);
sky_irradiance *= SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
return sun_irradiance * SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
}
// @shotamatsuda: Added for the clouds.
Illuminance3 GetSunAndSkyScalarIlluminance(
const Position p, const Direction sun_direction,
out IrradianceSpectrum sky_irradiance) {
IrradianceSpectrum sun_irradiance = GetSunAndSkyScalarIrradiance(
ATMOSPHERE, transmittance_texture, irradiance_texture, p,
sun_direction, sky_irradiance);
sky_irradiance *= SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
return sun_irradiance * SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
}
#define GetSolarRadiance GetSolarLuminance
#define GetSkyRadiance GetSkyLuminance
#define GetSkyRadianceToPoint GetSkyLuminanceToPoint
#define GetSunAndSkyIrradiance GetSunAndSkyIlluminance
#define GetSunAndSkyScalarIrradiance GetSunAndSkyScalarIlluminance
`,_f=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/functions.glsl
/**
* Copyright (c) 2017 Eric Bruneton
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* Precomputed Atmospheric Scattering
* Copyright (c) 2008 INRIA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
Number GetLayerDensity(const DensityProfileLayer layer, const Length altitude) {
Number density = layer.exp_term * exp(layer.exp_scale * altitude) +
layer.linear_term * altitude + layer.constant_term;
return clamp(density, Number(0.0), Number(1.0));
}
Number GetProfileDensity(const DensityProfile profile, const Length altitude) {
DensityProfileLayer layers[2] = profile.layers;
return altitude < layers[0].width
? GetLayerDensity(layers[0], altitude)
: GetLayerDensity(layers[1], altitude);
}
Length ComputeOpticalLengthToTopAtmosphereBoundary(
const AtmosphereParameters atmosphere, const DensityProfile profile,
const Length r, const Number mu) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
// Number of intervals for the numerical integration.
const int SAMPLE_COUNT = 500;
// The integration step, i.e. the length of each integration interval.
Length dx =
DistanceToTopAtmosphereBoundary(atmosphere, r, mu) / Number(SAMPLE_COUNT);
// Integration loop.
Length result = 0.0 * m;
for (int i = 0; i <= SAMPLE_COUNT; ++i) {
Length d_i = Number(i) * dx;
// Distance between the current sample point and the planet center.
Length r_i = sqrt(d_i * d_i + 2.0 * r * mu * d_i + r * r);
// Number density at the current sample point (divided by the number density
// at the bottom of the atmosphere, yielding a dimensionless number).
Number y_i = GetProfileDensity(profile, r_i - atmosphere.bottom_radius);
// Sample weight (from the trapezoidal rule).
Number weight_i = i == 0 || i == SAMPLE_COUNT ? 0.5 : 1.0;
result += y_i * weight_i * dx;
}
return result;
}
DimensionlessSpectrum ComputeTransmittanceToTopAtmosphereBoundary(
const AtmosphereParameters atmosphere, const Length r, const Number mu) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
vec3 optical_depth = (
atmosphere.rayleigh_scattering *
ComputeOpticalLengthToTopAtmosphereBoundary(
atmosphere, atmosphere.rayleigh_density, r, mu) +
atmosphere.mie_extinction *
ComputeOpticalLengthToTopAtmosphereBoundary(
atmosphere, atmosphere.mie_density, r, mu) +
atmosphere.absorption_extinction *
ComputeOpticalLengthToTopAtmosphereBoundary(
atmosphere, atmosphere.absorption_density, r, mu));
// @shotamatsuda: Added for the precomputation stage in half-float precision.
#ifdef TRANSMITTANCE_PRECISION_LOG
return optical_depth;
#else // TRANSMITTANCE_PRECISION_LOG
return exp(-optical_depth);
#endif // TRANSMITTANCE_PRECISION_LOG
}
Number GetUnitRangeFromTextureCoord(const Number u, const int texture_size) {
return (u - 0.5 / Number(texture_size)) / (1.0 - 1.0 / Number(texture_size));
}
void GetRMuFromTransmittanceTextureUv(const AtmosphereParameters atmosphere,
const vec2 uv, out Length r, out Number mu) {
assert(uv.x >= 0.0 && uv.x <= 1.0);
assert(uv.y >= 0.0 && uv.y <= 1.0);
Number x_mu = GetUnitRangeFromTextureCoord(uv.x, TRANSMITTANCE_TEXTURE_WIDTH);
Number x_r = GetUnitRangeFromTextureCoord(uv.y, TRANSMITTANCE_TEXTURE_HEIGHT);
// Distance to top atmosphere boundary for a horizontal ray at ground level.
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
atmosphere.bottom_radius * atmosphere.bottom_radius);
// Distance to the horizon, from which we can compute r:
Length rho = H * x_r;
r = sqrt(rho * rho + atmosphere.bottom_radius * atmosphere.bottom_radius);
// Distance to the top atmosphere boundary for the ray (r,mu), and its minimum
// and maximum values over all mu - obtained for (r,1) and (r,mu_horizon) -
// from which we can recover mu:
Length d_min = atmosphere.top_radius - r;
Length d_max = rho + H;
Length d = d_min + x_mu * (d_max - d_min);
mu = d == 0.0 * m ? Number(1.0) : (H * H - rho * rho - d * d) / (2.0 * r * d);
mu = ClampCosine(mu);
}
DimensionlessSpectrum ComputeTransmittanceToTopAtmosphereBoundaryTexture(
const AtmosphereParameters atmosphere, const vec2 frag_coord) {
const vec2 TRANSMITTANCE_TEXTURE_SIZE =
vec2(TRANSMITTANCE_TEXTURE_WIDTH, TRANSMITTANCE_TEXTURE_HEIGHT);
Length r;
Number mu;
GetRMuFromTransmittanceTextureUv(
atmosphere, frag_coord / TRANSMITTANCE_TEXTURE_SIZE, r, mu);
return ComputeTransmittanceToTopAtmosphereBoundary(atmosphere, r, mu);
}
void ComputeSingleScatteringIntegrand(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const Length d, const bool ray_r_mu_intersects_ground,
out DimensionlessSpectrum rayleigh, out DimensionlessSpectrum mie) {
Length r_d = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
Number mu_s_d = ClampCosine((r * mu_s + d * nu) / r_d);
DimensionlessSpectrum transmittance =
GetTransmittance(
atmosphere, transmittance_texture, r, mu, d,
ray_r_mu_intersects_ground) *
GetTransmittanceToSun(
atmosphere, transmittance_texture, r_d, mu_s_d);
rayleigh = transmittance * GetProfileDensity(
atmosphere.rayleigh_density, r_d - atmosphere.bottom_radius);
mie = transmittance * GetProfileDensity(
atmosphere.mie_density, r_d - atmosphere.bottom_radius);
}
Length DistanceToNearestAtmosphereBoundary(const AtmosphereParameters atmosphere,
Length r, Number mu, bool ray_r_mu_intersects_ground) {
if (ray_r_mu_intersects_ground) {
return DistanceToBottomAtmosphereBoundary(atmosphere, r, mu);
} else {
return DistanceToTopAtmosphereBoundary(atmosphere, r, mu);
}
}
void ComputeSingleScattering(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const bool ray_r_mu_intersects_ground,
out IrradianceSpectrum rayleigh, out IrradianceSpectrum mie) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
assert(mu_s >= -1.0 && mu_s <= 1.0);
assert(nu >= -1.0 && nu <= 1.0);
// Number of intervals for the numerical integration.
const int SAMPLE_COUNT = 50;
// The integration step, i.e. the length of each integration interval.
Length dx =
DistanceToNearestAtmosphereBoundary(atmosphere, r, mu,
ray_r_mu_intersects_ground) / Number(SAMPLE_COUNT);
// Integration loop.
DimensionlessSpectrum rayleigh_sum = DimensionlessSpectrum(0.0);
DimensionlessSpectrum mie_sum = DimensionlessSpectrum(0.0);
for (int i = 0; i <= SAMPLE_COUNT; ++i) {
Length d_i = Number(i) * dx;
// The Rayleigh and Mie single scattering at the current sample point.
DimensionlessSpectrum rayleigh_i;
DimensionlessSpectrum mie_i;
ComputeSingleScatteringIntegrand(atmosphere, transmittance_texture,
r, mu, mu_s, nu, d_i, ray_r_mu_intersects_ground, rayleigh_i, mie_i);
// Sample weight (from the trapezoidal rule).
Number weight_i = (i == 0 || i == SAMPLE_COUNT) ? 0.5 : 1.0;
rayleigh_sum += rayleigh_i * weight_i;
mie_sum += mie_i * weight_i;
}
rayleigh = rayleigh_sum * dx * atmosphere.solar_irradiance *
atmosphere.rayleigh_scattering;
mie = mie_sum * dx * atmosphere.solar_irradiance * atmosphere.mie_scattering;
}
void GetRMuMuSNuFromScatteringTextureUvwz(const AtmosphereParameters atmosphere,
const vec4 uvwz, out Length r, out Number mu, out Number mu_s,
out Number nu, out bool ray_r_mu_intersects_ground) {
assert(uvwz.x >= 0.0 && uvwz.x <= 1.0);
assert(uvwz.y >= 0.0 && uvwz.y <= 1.0);
assert(uvwz.z >= 0.0 && uvwz.z <= 1.0);
assert(uvwz.w >= 0.0 && uvwz.w <= 1.0);
// Distance to top atmosphere boundary for a horizontal ray at ground level.
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
atmosphere.bottom_radius * atmosphere.bottom_radius);
// Distance to the horizon.
Length rho =
H * GetUnitRangeFromTextureCoord(uvwz.w, SCATTERING_TEXTURE_R_SIZE);
r = sqrt(rho * rho + atmosphere.bottom_radius * atmosphere.bottom_radius);
if (uvwz.z < 0.5) {
// Distance to the ground for the ray (r,mu), and its minimum and maximum
// values over all mu - obtained for (r,-1) and (r,mu_horizon) - from which
// we can recover mu:
Length d_min = r - atmosphere.bottom_radius;
Length d_max = rho;
Length d = d_min + (d_max - d_min) * GetUnitRangeFromTextureCoord(
1.0 - 2.0 * uvwz.z, SCATTERING_TEXTURE_MU_SIZE / 2);
mu = d == 0.0 * m ? Number(-1.0) :
ClampCosine(-(rho * rho + d * d) / (2.0 * r * d));
ray_r_mu_intersects_ground = true;
} else {
// Distance to the top atmosphere boundary for the ray (r,mu), and its
// minimum and maximum values over all mu - obtained for (r,1) and
// (r,mu_horizon) - from which we can recover mu:
Length d_min = atmosphere.top_radius - r;
Length d_max = rho + H;
Length d = d_min + (d_max - d_min) * GetUnitRangeFromTextureCoord(
2.0 * uvwz.z - 1.0, SCATTERING_TEXTURE_MU_SIZE / 2);
mu = d == 0.0 * m ? Number(1.0) :
ClampCosine((H * H - rho * rho - d * d) / (2.0 * r * d));
ray_r_mu_intersects_ground = false;
}
Number x_mu_s =
GetUnitRangeFromTextureCoord(uvwz.y, SCATTERING_TEXTURE_MU_S_SIZE);
Length d_min = atmosphere.top_radius - atmosphere.bottom_radius;
Length d_max = H;
Length D = DistanceToTopAtmosphereBoundary(
atmosphere, atmosphere.bottom_radius, atmosphere.mu_s_min);
Number A = (D - d_min) / (d_max - d_min);
Number a = (A - x_mu_s * A) / (1.0 + x_mu_s * A);
Length d = d_min + min(a, A) * (d_max - d_min);
mu_s = d == 0.0 * m ? Number(1.0) :
ClampCosine((H * H - d * d) / (2.0 * atmosphere.bottom_radius * d));
nu = ClampCosine(uvwz.x * 2.0 - 1.0);
}
void GetRMuMuSNuFromScatteringTextureFragCoord(
const AtmosphereParameters atmosphere, const vec3 frag_coord,
out Length r, out Number mu, out Number mu_s, out Number nu,
out bool ray_r_mu_intersects_ground) {
const vec4 SCATTERING_TEXTURE_SIZE = vec4(
SCATTERING_TEXTURE_NU_SIZE - 1,
SCATTERING_TEXTURE_MU_S_SIZE,
SCATTERING_TEXTURE_MU_SIZE,
SCATTERING_TEXTURE_R_SIZE);
Number frag_coord_nu =
floor(frag_coord.x / Number(SCATTERING_TEXTURE_MU_S_SIZE));
Number frag_coord_mu_s =
mod(frag_coord.x, Number(SCATTERING_TEXTURE_MU_S_SIZE));
vec4 uvwz =
vec4(frag_coord_nu, frag_coord_mu_s, frag_coord.y, frag_coord.z) /
SCATTERING_TEXTURE_SIZE;
GetRMuMuSNuFromScatteringTextureUvwz(
atmosphere, uvwz, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
// Clamp nu to its valid range of values, given mu and mu_s.
nu = clamp(nu, mu * mu_s - sqrt((1.0 - mu * mu) * (1.0 - mu_s * mu_s)),
mu * mu_s + sqrt((1.0 - mu * mu) * (1.0 - mu_s * mu_s)));
}
void ComputeSingleScatteringTexture(const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture, const vec3 frag_coord,
out IrradianceSpectrum rayleigh, out IrradianceSpectrum mie) {
Length r;
Number mu;
Number mu_s;
Number nu;
bool ray_r_mu_intersects_ground;
GetRMuMuSNuFromScatteringTextureFragCoord(atmosphere, frag_coord,
r, mu, mu_s, nu, ray_r_mu_intersects_ground);
ComputeSingleScattering(atmosphere, transmittance_texture,
r, mu, mu_s, nu, ray_r_mu_intersects_ground, rayleigh, mie);
}
AbstractSpectrum GetScattering(
const AtmosphereParameters atmosphere,
const AbstractScatteringTexture scattering_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const bool ray_r_mu_intersects_ground) {
vec4 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
atmosphere, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
Number tex_coord_x = uvwz.x * Number(SCATTERING_TEXTURE_NU_SIZE - 1);
Number tex_x = floor(tex_coord_x);
Number lerp = tex_coord_x - tex_x;
vec3 uvw0 = vec3((tex_x + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
uvwz.z, uvwz.w);
vec3 uvw1 = vec3((tex_x + 1.0 + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
uvwz.z, uvwz.w);
return AbstractSpectrum(texture(scattering_texture, uvw0) * (1.0 - lerp) +
texture(scattering_texture, uvw1) * lerp);
}
RadianceSpectrum GetScattering(
const AtmosphereParameters atmosphere,
const ReducedScatteringTexture single_rayleigh_scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
const ScatteringTexture multiple_scattering_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const bool ray_r_mu_intersects_ground,
const int scattering_order) {
if (scattering_order == 1) {
IrradianceSpectrum rayleigh = GetScattering(
atmosphere, single_rayleigh_scattering_texture, r, mu, mu_s, nu,
ray_r_mu_intersects_ground);
IrradianceSpectrum mie = GetScattering(
atmosphere, single_mie_scattering_texture, r, mu, mu_s, nu,
ray_r_mu_intersects_ground);
return rayleigh * RayleighPhaseFunction(nu) +
mie * MiePhaseFunction(atmosphere.mie_phase_function_g, nu);
} else {
return GetScattering(
atmosphere, multiple_scattering_texture, r, mu, mu_s, nu,
ray_r_mu_intersects_ground);
}
}
IrradianceSpectrum GetIrradiance(
const AtmosphereParameters atmosphere,
const IrradianceTexture irradiance_texture,
const Length r, const Number mu_s);
RadianceDensitySpectrum ComputeScatteringDensity(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const ReducedScatteringTexture single_rayleigh_scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
const ScatteringTexture multiple_scattering_texture,
const IrradianceTexture irradiance_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const int scattering_order) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
assert(mu_s >= -1.0 && mu_s <= 1.0);
assert(nu >= -1.0 && nu <= 1.0);
assert(scattering_order >= 2);
// Compute unit direction vectors for the zenith, the view direction omega and
// and the sun direction omega_s, such that the cosine of the view-zenith
// angle is mu, the cosine of the sun-zenith angle is mu_s, and the cosine of
// the view-sun angle is nu. The goal is to simplify computations below.
vec3 zenith_direction = vec3(0.0, 0.0, 1.0);
vec3 omega = vec3(sqrt(1.0 - mu * mu), 0.0, mu);
Number sun_dir_x = omega.x == 0.0 ? 0.0 : (nu - mu * mu_s) / omega.x;
Number sun_dir_y = sqrt(max(1.0 - sun_dir_x * sun_dir_x - mu_s * mu_s, 0.0));
vec3 omega_s = vec3(sun_dir_x, sun_dir_y, mu_s);
const int SAMPLE_COUNT = 16;
const Angle dphi = pi / Number(SAMPLE_COUNT);
const Angle dtheta = pi / Number(SAMPLE_COUNT);
RadianceDensitySpectrum rayleigh_mie =
RadianceDensitySpectrum(0.0 * watt_per_cubic_meter_per_sr_per_nm);
// Nested loops for the integral over all the incident directions omega_i.
for (int l = 0; l < SAMPLE_COUNT; ++l) {
Angle theta = (Number(l) + 0.5) * dtheta;
Number cos_theta = cos(theta);
Number sin_theta = sin(theta);
bool ray_r_theta_intersects_ground =
RayIntersectsGround(atmosphere, r, cos_theta);
// The distance and transmittance to the ground only depend on theta, so we
// can compute them in the outer loop for efficiency.
Length distance_to_ground = 0.0 * m;
DimensionlessSpectrum transmittance_to_ground = DimensionlessSpectrum(0.0);
DimensionlessSpectrum ground_albedo = DimensionlessSpectrum(0.0);
if (ray_r_theta_intersects_ground) {
distance_to_ground =
DistanceToBottomAtmosphereBoundary(atmosphere, r, cos_theta);
transmittance_to_ground =
GetTransmittance(atmosphere, transmittance_texture, r, cos_theta,
distance_to_ground, true /* ray_intersects_ground */);
ground_albedo = atmosphere.ground_albedo;
}
for (int m = 0; m < 2 * SAMPLE_COUNT; ++m) {
Angle phi = (Number(m) + 0.5) * dphi;
vec3 omega_i =
vec3(cos(phi) * sin_theta, sin(phi) * sin_theta, cos_theta);
SolidAngle domega_i = (dtheta / rad) * (dphi / rad) * sin(theta) * sr;
// The radiance L_i arriving from direction omega_i after n-1 bounces is
// the sum of a term given by the precomputed scattering texture for the
// (n-1)-th order:
Number nu1 = dot(omega_s, omega_i);
RadianceSpectrum incident_radiance = GetScattering(atmosphere,
single_rayleigh_scattering_texture, single_mie_scattering_texture,
multiple_scattering_texture, r, omega_i.z, mu_s, nu1,
ray_r_theta_intersects_ground, scattering_order - 1);
// and of the contribution from the light paths with n-1 bounces and whose
// last bounce is on the ground. This contribution is the product of the
// transmittance to the ground, the ground albedo, the ground BRDF, and
// the irradiance received on the ground after n-2 bounces.
vec3 ground_normal =
normalize(zenith_direction * r + omega_i * distance_to_ground);
IrradianceSpectrum ground_irradiance = GetIrradiance(
atmosphere, irradiance_texture, atmosphere.bottom_radius,
dot(ground_normal, omega_s));
incident_radiance += transmittance_to_ground *
ground_albedo * (1.0 / (PI * sr)) * ground_irradiance;
// The radiance finally scattered from direction omega_i towards direction
// -omega is the product of the incident radiance, the scattering
// coefficient, and the phase function for directions omega and omega_i
// (all this summed over all particle types, i.e. Rayleigh and Mie).
Number nu2 = dot(omega, omega_i);
Number rayleigh_density = GetProfileDensity(
atmosphere.rayleigh_density, r - atmosphere.bottom_radius);
Number mie_density = GetProfileDensity(
atmosphere.mie_density, r - atmosphere.bottom_radius);
rayleigh_mie += incident_radiance * (
atmosphere.rayleigh_scattering * rayleigh_density *
RayleighPhaseFunction(nu2) +
atmosphere.mie_scattering * mie_density *
MiePhaseFunction(atmosphere.mie_phase_function_g, nu2)) *
domega_i;
}
}
return rayleigh_mie;
}
RadianceSpectrum ComputeMultipleScattering(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const ScatteringDensityTexture scattering_density_texture,
const Length r, const Number mu, const Number mu_s, const Number nu,
const bool ray_r_mu_intersects_ground) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu >= -1.0 && mu <= 1.0);
assert(mu_s >= -1.0 && mu_s <= 1.0);
assert(nu >= -1.0 && nu <= 1.0);
// Number of intervals for the numerical integration.
const int SAMPLE_COUNT = 50;
// The integration step, i.e. the length of each integration interval.
Length dx =
DistanceToNearestAtmosphereBoundary(
atmosphere, r, mu, ray_r_mu_intersects_ground) /
Number(SAMPLE_COUNT);
// Integration loop.
RadianceSpectrum rayleigh_mie_sum =
RadianceSpectrum(0.0 * watt_per_square_meter_per_sr_per_nm);
for (int i = 0; i <= SAMPLE_COUNT; ++i) {
Length d_i = Number(i) * dx;
// The r, mu and mu_s parameters at the current integration point (see the
// single scattering section for a detailed explanation).
Length r_i =
ClampRadius(atmosphere, sqrt(d_i * d_i + 2.0 * r * mu * d_i + r * r));
Number mu_i = ClampCosine((r * mu + d_i) / r_i);
Number mu_s_i = ClampCosine((r * mu_s + d_i * nu) / r_i);
// The Rayleigh and Mie multiple scattering at the current sample point.
RadianceSpectrum rayleigh_mie_i =
GetScattering(
atmosphere, scattering_density_texture, r_i, mu_i, mu_s_i, nu,
ray_r_mu_intersects_ground) *
GetTransmittance(
atmosphere, transmittance_texture, r, mu, d_i,
ray_r_mu_intersects_ground) *
dx;
// Sample weight (from the trapezoidal rule).
Number weight_i = (i == 0 || i == SAMPLE_COUNT) ? 0.5 : 1.0;
rayleigh_mie_sum += rayleigh_mie_i * weight_i;
}
return rayleigh_mie_sum;
}
RadianceDensitySpectrum ComputeScatteringDensityTexture(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const ReducedScatteringTexture single_rayleigh_scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
const ScatteringTexture multiple_scattering_texture,
const IrradianceTexture irradiance_texture,
const vec3 frag_coord, const int scattering_order) {
Length r;
Number mu;
Number mu_s;
Number nu;
bool ray_r_mu_intersects_ground;
GetRMuMuSNuFromScatteringTextureFragCoord(atmosphere, frag_coord,
r, mu, mu_s, nu, ray_r_mu_intersects_ground);
return ComputeScatteringDensity(atmosphere, transmittance_texture,
single_rayleigh_scattering_texture, single_mie_scattering_texture,
multiple_scattering_texture, irradiance_texture, r, mu, mu_s, nu,
scattering_order);
}
RadianceSpectrum ComputeMultipleScatteringTexture(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const ScatteringDensityTexture scattering_density_texture,
const vec3 frag_coord, out Number nu) {
Length r;
Number mu;
Number mu_s;
bool ray_r_mu_intersects_ground;
GetRMuMuSNuFromScatteringTextureFragCoord(atmosphere, frag_coord,
r, mu, mu_s, nu, ray_r_mu_intersects_ground);
return ComputeMultipleScattering(atmosphere, transmittance_texture,
scattering_density_texture, r, mu, mu_s, nu,
ray_r_mu_intersects_ground);
}
IrradianceSpectrum ComputeDirectIrradiance(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const Length r, const Number mu_s) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu_s >= -1.0 && mu_s <= 1.0);
Number alpha_s = atmosphere.sun_angular_radius / rad;
// Approximate average of the cosine factor mu_s over the visible fraction of
// the Sun disc.
Number average_cosine_factor =
mu_s < -alpha_s ? 0.0 : (mu_s > alpha_s ? mu_s :
(mu_s + alpha_s) * (mu_s + alpha_s) / (4.0 * alpha_s));
return atmosphere.solar_irradiance *
GetTransmittanceToTopAtmosphereBoundary(
atmosphere, transmittance_texture, r, mu_s) * average_cosine_factor;
}
IrradianceSpectrum ComputeIndirectIrradiance(
const AtmosphereParameters atmosphere,
const ReducedScatteringTexture single_rayleigh_scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
const ScatteringTexture multiple_scattering_texture,
const Length r, const Number mu_s, const int scattering_order) {
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
assert(mu_s >= -1.0 && mu_s <= 1.0);
assert(scattering_order >= 1);
const int SAMPLE_COUNT = 32;
const Angle dphi = pi / Number(SAMPLE_COUNT);
const Angle dtheta = pi / Number(SAMPLE_COUNT);
IrradianceSpectrum result =
IrradianceSpectrum(0.0 * watt_per_square_meter_per_nm);
vec3 omega_s = vec3(sqrt(1.0 - mu_s * mu_s), 0.0, mu_s);
for (int j = 0; j < SAMPLE_COUNT / 2; ++j) {
Angle theta = (Number(j) + 0.5) * dtheta;
for (int i = 0; i < 2 * SAMPLE_COUNT; ++i) {
Angle phi = (Number(i) + 0.5) * dphi;
vec3 omega =
vec3(cos(phi) * sin(theta), sin(phi) * sin(theta), cos(theta));
SolidAngle domega = (dtheta / rad) * (dphi / rad) * sin(theta) * sr;
Number nu = dot(omega, omega_s);
result += GetScattering(atmosphere, single_rayleigh_scattering_texture,
single_mie_scattering_texture, multiple_scattering_texture,
r, omega.z, mu_s, nu, false /* ray_r_theta_intersects_ground */,
scattering_order) *
omega.z * domega;
}
}
return result;
}
void GetRMuSFromIrradianceTextureUv(const AtmosphereParameters atmosphere,
const vec2 uv, out Length r, out Number mu_s) {
assert(uv.x >= 0.0 && uv.x <= 1.0);
assert(uv.y >= 0.0 && uv.y <= 1.0);
Number x_mu_s = GetUnitRangeFromTextureCoord(uv.x, IRRADIANCE_TEXTURE_WIDTH);
Number x_r = GetUnitRangeFromTextureCoord(uv.y, IRRADIANCE_TEXTURE_HEIGHT);
r = atmosphere.bottom_radius +
x_r * (atmosphere.top_radius - atmosphere.bottom_radius);
mu_s = ClampCosine(2.0 * x_mu_s - 1.0);
}
const vec2 IRRADIANCE_TEXTURE_SIZE =
vec2(IRRADIANCE_TEXTURE_WIDTH, IRRADIANCE_TEXTURE_HEIGHT);
IrradianceSpectrum ComputeDirectIrradianceTexture(
const AtmosphereParameters atmosphere,
const TransmittanceTexture transmittance_texture,
const vec2 frag_coord) {
Length r;
Number mu_s;
GetRMuSFromIrradianceTextureUv(
atmosphere, frag_coord / IRRADIANCE_TEXTURE_SIZE, r, mu_s);
return ComputeDirectIrradiance(atmosphere, transmittance_texture, r, mu_s);
}
IrradianceSpectrum ComputeIndirectIrradianceTexture(
const AtmosphereParameters atmosphere,
const ReducedScatteringTexture single_rayleigh_scattering_texture,
const ReducedScatteringTexture single_mie_scattering_texture,
const ScatteringTexture multiple_scattering_texture,
const vec2 frag_coord, const int scattering_order) {
Length r;
Number mu_s;
GetRMuSFromIrradianceTextureUv(
atmosphere, frag_coord / IRRADIANCE_TEXTURE_SIZE, r, mu_s);
return ComputeIndirectIrradiance(atmosphere,
single_rayleigh_scattering_texture, single_mie_scattering_texture,
multiple_scattering_texture, r, mu_s, scattering_order);
}
`,ane=new L(.2126,.7152,.0722),rne=["solarIrradiance","sunAngularRadius","bottomRadius","topRadius","rayleighDensity","rayleighScattering","mieDensity","mieScattering","mieExtinction","miePhaseFunctionG","absorptionDensity","absorptionExtinction","groundAlbedo","muSMin","skyRadianceToLuminance","sunRadianceToLuminance"];function sne(n,e){if(e!=null)for(const t of rne){const i=e[t];i!=null&&(n[t]instanceof L?n[t].copy(i):n[t]=i)}}class xf{constructor(e,t,i,a,r){this.width=e,this.expTerm=t,this.expScale=i,this.linearTerm=a,this.constantTerm=r}toUniform(){return new J({width:this.width,exp_term:this.expTerm,exp_scale:this.expScale,linear_term:this.linearTerm,constant_term:this.constantTerm})}}const VE=class{constructor(e){this.solarIrradiance=new L(1.474,1.8504,1.91198),this.sunAngularRadius=.004675,this.bottomRadius=636e4,this.topRadius=642e4,this.rayleighDensity=[new xf(0,0,0,0,0),new xf(0,1,-.125,0,0)],this.rayleighScattering=new L(.005802,.013558,.0331),this.mieDensity=[new xf(0,0,0,0,0),new xf(0,1,-.833333,0,0)],this.mieScattering=new L(.003996,.003996,.003996),this.mieExtinction=new L(.00444,.00444,.00444),this.miePhaseFunctionG=.8,this.absorptionDensity=[new xf(25,0,0,1/15,-2/3),new xf(0,0,0,-1/15,8/3)],this.absorptionExtinction=new L(65e-5,.001881,85e-6),this.groundAlbedo=new je().setScalar(.1),this.muSMin=Math.cos(Ite(120)),this.sunRadianceToLuminance=new L(98242.786222,69954.398112,66475.012354),this.skyRadianceToLuminance=new L(114974.916437,71305.954816,65310.548555),this.sunRadianceToRelativeLuminance=new L,this.skyRadianceToRelativeLuminance=new L,sne(this,e);const t=ane.dot(this.sunRadianceToLuminance);this.sunRadianceToRelativeLuminance.copy(this.sunRadianceToLuminance).divideScalar(t),this.skyRadianceToRelativeLuminance.copy(this.skyRadianceToLuminance).divideScalar(t)}toUniform(){return new J({solar_irradiance:this.solarIrradiance,sun_angular_radius:this.sunAngularRadius,bottom_radius:this.bottomRadius*t1,top_radius:this.topRadius*t1,rayleigh_density:{layers:this.rayleighDensity.map(e=>e.toUniform().value)},rayleigh_scattering:this.rayleighScattering,mie_density:{layers:this.mieDensity.map(e=>e.toUniform().value)},mie_scattering:this.mieScattering,mie_extinction:this.mieExtinction,mie_phase_function_g:this.miePhaseFunctionG,absorption_density:{layers:this.absorptionDensity.map(e=>e.toUniform().value)},absorption_extinction:this.absorptionExtinction,ground_albedo:this.groundAlbedo,mu_s_min:this.muSMin})}};VE.DEFAULT=new VE;let Y0=VE;const one=`precision highp sampler2DArray;
#include "core/depth"
#include "core/math"
#include "core/packing"
#include "core/transform"
#ifdef HAS_SHADOW
#include "core/raySphereIntersection"
#include "core/cascadedShadowMaps"
#include "core/interleavedGradientNoise"
#include "core/vogelDisk"
#endif // HAS_SHADOW
#include "bruneton/definitions"
uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;
#include "bruneton/common"
#include "bruneton/runtime"
#include "sky"
uniform sampler2D normalBuffer;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 inverseProjectionMatrix;
uniform mat4 inverseViewMatrix;
uniform float bottomRadius;
uniform mat4 worldToECEFMatrix;
uniform float geometricErrorCorrectionAmount;
uniform vec3 sunDirection;
uniform vec3 moonDirection;
uniform float moonAngularRadius;
uniform float lunarRadianceScale;
uniform float albedoScale;
#ifdef HAS_LIGHTING_MASK
uniform sampler2D lightingMaskBuffer;
#endif // HAS_LIGHTING_MASK
// prettier-ignore
#define LIGHTING_MASK_CHANNEL_ LIGHTING_MASK_CHANNEL
#ifdef HAS_OVERLAY
uniform sampler2D overlayBuffer;
#endif // HAS_OVERLAY
#ifdef HAS_SHADOW
uniform sampler2DArray shadowBuffer;
uniform vec2 shadowIntervals[SHADOW_CASCADE_COUNT];
uniform mat4 shadowMatrices[SHADOW_CASCADE_COUNT];
uniform mat4 inverseShadowMatrices[SHADOW_CASCADE_COUNT];
uniform float shadowFar;
uniform float shadowTopHeight;
uniform float shadowRadius;
uniform sampler3D stbnTexture;
uniform int frame;
#endif // HAS_SHADOW
#ifdef HAS_SHADOW_LENGTH
uniform sampler2D shadowLengthBuffer;
#endif // HAS_SHADOW_LENGTH
varying vec3 vCameraPosition;
varying vec3 vRayDirection;
varying vec3 vGeometryAltitudeCorrection;
varying vec3 vEllipsoidRadiiSquared;
vec3 readNormal(const vec2 uv) {
#ifdef OCT_ENCODED_NORMAL
return unpackVec2ToNormal(texture(normalBuffer, uv).xy);
#else // OCT_ENCODED_NORMAL
return 2.0 * texture(normalBuffer, uv).xyz - 1.0;
#endif // OCT_ENCODED_NORMAL
}
void correctGeometricError(inout vec3 positionECEF, inout vec3 normalECEF) {
// TODO: The error is pronounced at the edge of the ellipsoid due to the
// large difference between the sphere position and the unprojected position
// at the current fragment. Calculating the sphere position from the fragment
// UV may resolve this.
// Correct way is slerp, but this will be small-angle interpolation anyways.
vec3 sphereNormal = normalize(positionECEF / vEllipsoidRadiiSquared);
vec3 spherePosition = ATMOSPHERE.bottom_radius * sphereNormal;
normalECEF = mix(normalECEF, sphereNormal, geometricErrorCorrectionAmount);
positionECEF = mix(positionECEF, spherePosition, geometricErrorCorrectionAmount);
}
#if defined(SUN_LIGHT) || defined(SKY_LIGHT)
vec3 getSunSkyIrradiance(
const vec3 positionECEF,
const vec3 normal,
const vec3 inputColor,
const float sunTransmittance
) {
// Assume lambertian BRDF. If both SUN_LIGHT and SKY_LIGHT are not defined,
// regard the inputColor as radiance at the texel.
vec3 diffuse = inputColor * albedoScale * RECIPROCAL_PI;
vec3 skyIrradiance;
vec3 sunIrradiance = GetSunAndSkyIrradiance(positionECEF, normal, sunDirection, skyIrradiance);
#ifdef HAS_SHADOW
sunIrradiance *= sunTransmittance;
#endif // HAS_SHADOW
#if defined(SUN_LIGHT) && defined(SKY_LIGHT)
return diffuse * (sunIrradiance + skyIrradiance);
#elif defined(SUN_LIGHT)
return diffuse * sunIrradiance;
#elif defined(SKY_LIGHT)
return diffuse * skyIrradiance;
#endif // defined(SUN_LIGHT) && defined(SKY_LIGHT)
}
#endif // defined(SUN_LIGHT) || defined(SKY_LIGHT)
#if defined(TRANSMITTANCE) || defined(INSCATTER)
void applyTransmittanceInscatter(const vec3 positionECEF, float shadowLength, inout vec3 radiance) {
vec3 transmittance;
vec3 inscatter = GetSkyRadianceToPoint(
vCameraPosition,
positionECEF,
shadowLength,
sunDirection,
transmittance
);
#ifdef TRANSMITTANCE
radiance = radiance * transmittance;
#endif // TRANSMITTANCE
#ifdef INSCATTER
radiance = radiance + inscatter;
#endif // INSCATTER
}
#endif // defined(TRANSMITTANCE) || defined(INSCATTER)
#ifdef HAS_SHADOW
float getSTBN() {
ivec3 size = textureSize(stbnTexture, 0);
vec3 scale = 1.0 / vec3(size);
return texture(stbnTexture, vec3(gl_FragCoord.xy, float(frame % size.z)) * scale).r;
}
vec2 getShadowUv(const vec3 worldPosition, const int cascadeIndex) {
vec4 clip = shadowMatrices[cascadeIndex] * vec4(worldPosition, 1.0);
clip /= clip.w;
return clip.xy * 0.5 + 0.5;
}
float getDistanceToShadowTop(const vec3 positionECEF) {
// Distance to the top of the shadows along the sun direction, which matches
// the ray origin of BSM.
return raySphereSecondIntersection(
positionECEF / METER_TO_LENGTH_UNIT, // TODO: Make units consistent
sunDirection,
vec3(0.0),
bottomRadius + shadowTopHeight
);
}
float readShadowOpticalDepth(const vec2 uv, const float distanceToTop, const int cascadeIndex) {
// r: frontDepth, g: meanExtinction, b: maxOpticalDepth, a: maxOpticalDepthTail
vec4 shadow = texture(shadowBuffer, vec3(uv, float(cascadeIndex)));
// Omit adding maxOpticalDepthTail to avoid pronounced aliasing. Ground
// shadow will be attenuated by inscatter anyways.
return min(shadow.b, shadow.g * max(0.0, distanceToTop - shadow.r));
}
float sampleShadowOpticalDepthPCF(
const vec3 worldPosition,
const float distanceToTop,
const float radius,
const int cascadeIndex
) {
vec2 uv = getShadowUv(worldPosition, cascadeIndex);
if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
return 0.0;
}
vec2 texelSize = vec2(1.0) / vec2(textureSize(shadowBuffer, 0).xy);
float sum = 0.0;
vec2 offset;
#pragma unroll_loop_start
for (int i = 0; i < 16; ++i) {
#if UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
offset = vogelDisk(
UNROLLED_LOOP_INDEX,
SHADOW_SAMPLE_COUNT,
interleavedGradientNoise(gl_FragCoord.xy) * PI2
);
sum += readShadowOpticalDepth(uv + offset * radius * texelSize, distanceToTop, cascadeIndex);
#endif // UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
}
#pragma unroll_loop_end
return sum / float(SHADOW_SAMPLE_COUNT);
}
float sampleShadowOpticalDepth(
const vec3 worldPosition,
const vec3 positionECEF,
const float radius,
const float jitter
) {
float distanceToTop = getDistanceToShadowTop(positionECEF);
if (distanceToTop <= 0.0) {
return 0.0;
}
int cascadeIndex = getFadedCascadeIndex(
viewMatrix,
worldPosition,
shadowIntervals,
cameraNear,
shadowFar,
jitter
);
return cascadeIndex >= 0
? sampleShadowOpticalDepthPCF(worldPosition, distanceToTop, radius, cascadeIndex)
: 0.0;
}
float getShadowRadius(const vec3 worldPosition) {
vec4 clip = shadowMatrices[0] * vec4(worldPosition, 1.0);
clip /= clip.w;
// Offset by 1px in each direction in shadow's clip coordinates.
vec2 shadowSize = vec2(textureSize(shadowBuffer, 0));
vec3 offset = vec3(2.0 / shadowSize, 0.0);
vec4 clipX = clip + offset.xzzz;
vec4 clipY = clip + offset.zyzz;
// Convert back to world space.
vec4 worldX = inverseShadowMatrices[0] * clipX;
vec4 worldY = inverseShadowMatrices[0] * clipY;
// Project into the main camera's clip space.
mat4 viewProjectionMatrix = projectionMatrix * viewMatrix;
vec4 projected = viewProjectionMatrix * vec4(worldPosition, 1.0);
vec4 projectedX = viewProjectionMatrix * worldX;
vec4 projectedY = viewProjectionMatrix * worldY;
projected /= projected.w;
projectedX /= projectedX.w;
projectedY /= projectedY.w;
// Take the mean of pixel sizes.
vec2 center = (projected.xy * 0.5 + 0.5) * resolution;
vec2 offsetX = (projectedX.xy * 0.5 + 0.5) * resolution;
vec2 offsetY = (projectedY.xy * 0.5 + 0.5) * resolution;
float size = max(length(offsetX - center), length(offsetY - center));
return remapClamped(size, 10.0, 50.0, 0.0, shadowRadius);
}
#endif // HAS_SHADOW
void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
#if defined(HAS_LIGHTING_MASK) && defined(DEBUG_SHOW_LIGHTING_MASK)
outputColor.rgb = vec3(texture(lightingMaskBuffer, uv).LIGHTING_MASK_CHANNEL_);
outputColor.a = 1.0;
return;
#endif // defined(HAS_LIGHTING_MASK) && defined(DEBUG_SHOW_LIGHTING_MASK)
float shadowLength = 0.0;
#ifdef HAS_SHADOW_LENGTH
shadowLength = texture(shadowLengthBuffer, uv).r;
#endif // HAS_SHADOW_LENGTH
#ifdef HAS_OVERLAY
vec4 overlay = texture(overlayBuffer, uv);
if (overlay.a == 1.0) {
outputColor = overlay;
return;
}
#endif // HAS_OVERLAY
float depth = readDepth(uv);
if (depth >= 1.0 - 1e-8) {
#ifdef SKY
vec3 rayDirection = normalize(vRayDirection);
outputColor.rgb = getSkyRadiance(
vCameraPosition,
rayDirection,
shadowLength,
sunDirection,
moonDirection,
moonAngularRadius,
lunarRadianceScale
);
outputColor.a = 1.0;
#else // SKY
outputColor = inputColor;
#endif // SKY
#ifdef HAS_OVERLAY
outputColor.rgb = outputColor.rgb * (1.0 - overlay.a) + overlay.rgb;
#endif // HAS_OVERLAY
return;
}
depth = reverseLogDepth(depth, cameraNear, cameraFar);
// Reconstruct position and normal in world space.
vec3 viewPosition = screenToView(
uv,
depth,
getViewZ(depth),
projectionMatrix,
inverseProjectionMatrix
);
vec3 viewNormal;
#ifdef RECONSTRUCT_NORMAL
vec3 dx = dFdx(viewPosition);
vec3 dy = dFdy(viewPosition);
viewNormal = normalize(cross(dx, dy));
#else // RECONSTRUCT_NORMAL
viewNormal = readNormal(uv);
#endif // RECONSTRUCT_NORMAL
vec3 worldPosition = (inverseViewMatrix * vec4(viewPosition, 1.0)).xyz;
vec3 worldNormal = (inverseViewMatrix * vec4(viewNormal, 0.0)).xyz;
vec3 positionECEF = (worldToECEFMatrix * vec4(worldPosition, 1.0)).xyz;
positionECEF = positionECEF * METER_TO_LENGTH_UNIT + vGeometryAltitudeCorrection;
vec3 normalECEF = (worldToECEFMatrix * vec4(worldNormal, 0.0)).xyz;
#ifdef CORRECT_GEOMETRIC_ERROR
correctGeometricError(positionECEF, normalECEF);
#endif // CORRECT_GEOMETRIC_ERROR
#ifdef HAS_SHADOW
float stbn = getSTBN();
float radius = getShadowRadius(worldPosition);
float opticalDepth = sampleShadowOpticalDepth(worldPosition, positionECEF, radius, stbn);
float sunTransmittance = exp(-opticalDepth);
#else // HAS_SHADOW
float sunTransmittance = 1.0;
#endif // HAS_SHADOW
vec3 radiance;
#if defined(SUN_LIGHT) || defined(SKY_LIGHT)
radiance = getSunSkyIrradiance(positionECEF, normalECEF, inputColor.rgb, sunTransmittance);
#ifdef HAS_LIGHTING_MASK
float lightingMask = texture(lightingMaskBuffer, uv).LIGHTING_MASK_CHANNEL_;
radiance = mix(inputColor.rgb, radiance, lightingMask);
#endif // HAS_LIGHTING_MASK
#else // defined(SUN_LIGHT) || defined(SKY_LIGHT)
radiance = inputColor.rgb;
#endif // defined(SUN_LIGHT) || defined(SKY_LIGHT)
#if defined(TRANSMITTANCE) || defined(INSCATTER)
applyTransmittanceInscatter(positionECEF, shadowLength, radiance);
#endif // defined(TRANSMITTANCE) || defined(INSCATTER)
outputColor = vec4(radiance, inputColor.a);
#ifdef HAS_OVERLAY
outputColor.rgb = outputColor.rgb * (1.0 - overlay.a) + overlay.rgb;
#endif // HAS_OVERLAY
}
`,lne=`uniform mat4 inverseViewMatrix;
uniform mat4 inverseProjectionMatrix;
uniform vec3 cameraPosition;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;
uniform float geometricErrorCorrectionAmount;
uniform vec3 ellipsoidRadii;
varying vec3 vCameraPosition;
varying vec3 vRayDirection;
varying vec3 vGeometryAltitudeCorrection;
varying vec3 vEllipsoidRadiiSquared;
void getCameraRay(out vec3 origin, out vec3 direction) {
bool isPerspective = inverseProjectionMatrix[2][3] != 0.0; // 4th entry in the 3rd column
if (isPerspective) {
// Calculate the camera ray for a perspective camera.
vec4 viewPosition = inverseProjectionMatrix * vec4(position, 1.0);
vec4 worldDirection = inverseViewMatrix * vec4(viewPosition.xyz, 0.0);
origin = cameraPosition;
direction = worldDirection.xyz;
} else {
// Unprojected points to calculate direction.
vec4 nearPoint = inverseProjectionMatrix * vec4(position.xy, -1.0, 1.0);
vec4 farPoint = inverseProjectionMatrix * vec4(position.xy, -0.9, 1.0);
nearPoint /= nearPoint.w;
farPoint /= farPoint.w;
// Calculate world values.
vec4 worldDirection = inverseViewMatrix * vec4(farPoint.xyz - nearPoint.xyz, 0.0);
vec4 worldOrigin = inverseViewMatrix * nearPoint;
// Outputs
direction = worldDirection.xyz;
origin = worldOrigin.xyz;
}
}
void mainSupport() {
vec3 direction, origin;
getCameraRay(origin, direction);
vec3 cameraPositionECEF = (worldToECEFMatrix * vec4(origin, 1.0)).xyz;
vCameraPosition = (cameraPositionECEF + altitudeCorrection) * METER_TO_LENGTH_UNIT;
vRayDirection = (worldToECEFMatrix * vec4(direction, 0.0)).xyz;
vGeometryAltitudeCorrection = altitudeCorrection * METER_TO_LENGTH_UNIT;
// Gradually turn off the altitude correction on geometries as the geometric
// error correction takes effect, because that on the ideal sphere will be
// over corrected.
// See: https://github.com/takram-design-engineering/three-geospatial/pull/23#issuecomment-2542914656
#ifdef CORRECT_GEOMETRIC_ERROR
vGeometryAltitudeCorrection *= 1.0 - geometricErrorCorrectionAmount;
#endif // CORRECT_GEOMETRIC_ERROR
vec3 radii = ellipsoidRadii * METER_TO_LENGTH_UNIT;
vEllipsoidRadiiSquared = radii * radii;
}
`,IP=`vec3 getLunarRadiance(const float moonAngularRadius) {
// Not a physical number but the order of 10^-6 relative to the sun may fit.
vec3 radiance =
ATMOSPHERE.solar_irradiance *
0.000002 /
(PI * moonAngularRadius * moonAngularRadius) *
SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
return radiance;
}
float intersectSphere(const vec3 ray, const vec3 point, const float radius) {
vec3 P = -point;
float PoR = dot(P, ray);
float D = dot(P, P) - radius * radius;
return -PoR - sqrt(PoR * PoR - D);
}
float orenNayarDiffuse(const vec3 L, const vec3 V, const vec3 N) {
float NoL = dot(N, L);
float NoV = dot(N, V);
float s = dot(L, V) - NoL * NoV;
float t = mix(1.0, max(NoL, NoV), step(0.0, s));
return max(0.0, NoL) * (0.62406015 + 0.41284404 * s / t);
}
vec3 getSkyRadiance(
const vec3 cameraPosition,
const vec3 rayDirection,
const float shadowLength,
const vec3 sunDirection,
const vec3 moonDirection,
const float moonAngularRadius,
const float lunarRadianceScale
) {
vec3 transmittance;
vec3 radiance = GetSkyRadiance(
cameraPosition,
rayDirection,
shadowLength,
sunDirection,
transmittance
);
// Rendering celestial objects without perspective doesn't make sense.
#ifdef PERSPECTIVE_CAMERA
#if defined(SUN) || defined(MOON)
vec3 ddx = dFdx(rayDirection);
vec3 ddy = dFdy(rayDirection);
float fragmentAngle = length(ddx + ddy) / length(rayDirection);
#endif // defined(SUN) || defined(MOON)
#ifdef SUN
float viewDotSun = dot(rayDirection, sunDirection);
if (viewDotSun > cos(ATMOSPHERE.sun_angular_radius)) {
float angle = acos(clamp(viewDotSun, -1.0, 1.0));
float antialias = smoothstep(
ATMOSPHERE.sun_angular_radius,
ATMOSPHERE.sun_angular_radius - fragmentAngle,
angle
);
radiance += transmittance * GetSolarRadiance() * antialias;
}
#endif // SUN
#ifdef MOON
float intersection = intersectSphere(rayDirection, moonDirection, moonAngularRadius);
if (intersection > 0.0) {
vec3 normal = normalize(moonDirection - rayDirection * intersection);
float diffuse = orenNayarDiffuse(-sunDirection, rayDirection, normal);
float viewDotMoon = dot(rayDirection, moonDirection);
float angle = acos(clamp(viewDotMoon, -1.0, 1.0));
float antialias = smoothstep(moonAngularRadius, moonAngularRadius - fragmentAngle, angle);
radiance +=
transmittance *
getLunarRadiance(moonAngularRadius) *
lunarRadianceScale *
diffuse *
antialias;
}
#endif // MOON
#endif // PERSPECTIVE_CAMERA
return radiance;
}
`;var cne=Object.defineProperty,ir=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&cne(e,t,a),a};const une=new L,hne=new L,fne=new q8,UP={blendFunction:ln.NORMAL,octEncodedNormal:!1,reconstructNormal:!1,ellipsoid:g0.WGS84,correctAltitude:!0,correctGeometricError:!0,sunLight:!1,skyLight:!1,transmittance:!0,inscatter:!0,albedoScale:1,sky:!1,sun:!0,moon:!0,moonAngularRadius:.0045,lunarRadianceScale:1,ground:!0};let za=class extends m0{constructor(e=new Tc,t,i=Y0.DEFAULT){const{blendFunction:a,normalBuffer:r=null,octEncodedNormal:s,reconstructNormal:o,irradianceTexture:c=null,scatteringTexture:h=null,transmittanceTexture:f=null,singleMieScatteringTexture:d=null,higherOrderScatteringTexture:m=null,ellipsoid:g,correctAltitude:x,correctGeometricError:T,sunDirection:S,sunIrradiance:v,sunLight:y,skyIrradiance:E,skyLight:b,transmittance:D,inscatter:C,irradianceScale:I,albedoScale:P,sky:O,sun:R,moon:B,moonDirection:j,moonAngularRadius:ee,lunarRadianceScale:se,ground:re}={...UP,...t};super("AerialPerspectiveEffect",X0(Ca(one,{core:{depth:NP,packing:$te,math:mA,transform:ene,raySphereIntersection:fy,cascadedShadowMaps:CP,interleavedGradientNoise:DP,vogelDisk:LP},bruneton:{common:Zs,definitions:Ks,runtime:vy},sky:IP})),{blendFunction:a,vertexShader:lne,attributes:Jo.DEPTH,uniforms:new Map(Object.entries({normalBuffer:new J(r),projectionMatrix:new J(new ke),viewMatrix:new J(new ke),inverseProjectionMatrix:new J(new ke),inverseViewMatrix:new J(new ke),cameraPosition:new J(new L),bottomRadius:new J(i.bottomRadius),ellipsoidRadii:new J(new L),worldToECEFMatrix:new J(new ke),altitudeCorrection:new J(new L),geometricErrorCorrectionAmount:new J(0),sunDirection:new J((S==null?void 0:S.clone())??new L),albedoScale:new J(I??P),moonDirection:new J((j==null?void 0:j.clone())??new L),moonAngularRadius:new J(ee),lunarRadianceScale:new J(se),overlayBuffer:new J(null),shadowBuffer:new J(null),shadowMapSize:new J(new de),shadowIntervals:new J([]),shadowMatrices:new J([]),inverseShadowMatrices:new J([]),shadowFar:new J(0),shadowTopHeight:new J(0),shadowRadius:new J(3),stbnTexture:new J(null),frame:new J(0),shadowLengthBuffer:new J(null),lightingMaskBuffer:new J(null),ATMOSPHERE:i.toUniform(),SUN_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(i.sunRadianceToRelativeLuminance),SKY_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(i.skyRadianceToRelativeLuminance),irradiance_texture:new J(c),scattering_texture:new J(h),transmittance_texture:new J(f),single_mie_scattering_texture:new J(null),higher_order_scattering_texture:new J(null)})),defines:new Map([["TRANSMITTANCE_TEXTURE_WIDTH",Jd.toFixed(0)],["TRANSMITTANCE_TEXTURE_HEIGHT",$d.toFixed(0)],["SCATTERING_TEXTURE_R_SIZE",dy.toFixed(0)],["SCATTERING_TEXTURE_MU_SIZE",py.toFixed(0)],["SCATTERING_TEXTURE_MU_S_SIZE",my.toFixed(0)],["SCATTERING_TEXTURE_NU_SIZE",gy.toFixed(0)],["IRRADIANCE_TEXTURE_WIDTH",Kd.toFixed(0)],["IRRADIANCE_TEXTURE_HEIGHT",Qd.toFixed(0)],["METER_TO_LENGTH_UNIT",t1.toFixed(7)]])}),this.camera=e,this.atmosphere=i,this.overlay=null,this.shadow=null,this.shadowLength=null,this.lightingMask=null,this.combinedScatteringTextures=!1,this.hasHigherOrderScatteringTexture=!1,this.shadowSampleCount=8,this.octEncodedNormal=s,this.reconstructNormal=o,this.singleMieScatteringTexture=d,this.higherOrderScatteringTexture=m,this.ellipsoid=g,this.correctAltitude=x,this.correctGeometricError=T,this.sunLight=v??y,this.skyLight=E??b,this.transmittance=D,this.inscatter=C,this.sky=O,this.sun=R,this.moon=B,this.ground=re}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e}copyCameraSettings(e){const{projectionMatrix:t,matrixWorldInverse:i,projectionMatrixInverse:a,matrixWorld:r}=e,s=this.uniforms;s.get("projectionMatrix").value.copy(t),s.get("viewMatrix").value.copy(i),s.get("inverseProjectionMatrix").value.copy(a),s.get("inverseViewMatrix").value.copy(r);const o=e.getWorldPosition(s.get("cameraPosition").value),c=s.get("worldToECEFMatrix").value,h=une.copy(o).applyMatrix4(c);try{const d=fne.setFromECEF(h).height,m=hne.set(0,this.ellipsoid.maximumRadius,-Math.max(0,d)).applyMatrix4(t);s.get("geometricErrorCorrectionAmount").value=Pte(Ute(m.y,41.5,13.8,0,1))}catch{return}const f=s.get("altitudeCorrection");this.correctAltitude?gA(h,this.atmosphere.bottomRadius,this.ellipsoid,f.value):f.value.setScalar(0)}updateOverlay(){let e=!1;const{uniforms:t,defines:i,overlay:a}=this,r=i.has("HAS_OVERLAY"),s=a!=null;return s!==r&&(s?i.set("HAS_OVERLAY","1"):(i.delete("HAS_OVERLAY"),t.get("overlayBuffer").value=null),e=!0),s&&(t.get("overlayBuffer").value=a.map),e}updateShadow(){let e=!1;const{uniforms:t,defines:i,shadow:a}=this,r=i.has("HAS_SHADOW"),s=a!=null;if(s!==r&&(s?i.set("HAS_SHADOW","1"):(i.delete("HAS_SHADOW"),t.get("shadowBuffer").value=null),e=!0),s){const o=i.get("SHADOW_CASCADE_COUNT"),c=`${a.cascadeCount}`;o!==c&&(i.set("SHADOW_CASCADE_COUNT",a.cascadeCount.toFixed(0)),e=!0),t.get("shadowBuffer").value=a.map,t.get("shadowMapSize").value=a.mapSize,t.get("shadowIntervals").value=a.intervals,t.get("shadowMatrices").value=a.matrices,t.get("inverseShadowMatrices").value=a.inverseMatrices,t.get("shadowFar").value=a.far,t.get("shadowTopHeight").value=a.topHeight}return e}updateShadowLength(){let e=!1;const{uniforms:t,defines:i,shadowLength:a}=this,r=i.has("HAS_SHADOW_LENGTH"),s=a!=null;return s!==r&&(s?i.set("HAS_SHADOW_LENGTH","1"):(i.delete("HAS_SHADOW_LENGTH"),t.get("shadowLengthBuffer").value=null),e=!0),s&&(t.get("shadowLengthBuffer").value=a.map),e}updateLightingMask(){let e=!1;const{uniforms:t,defines:i,lightingMask:a}=this,r=i.has("HAS_LIGHTING_MASK"),s=a!=null;if(s!==r&&(s?i.set("HAS_LIGHTING_MASK","1"):(i.delete("HAS_LIGHTING_MASK"),t.get("lightingMaskBuffer").value=null),e=!0),s){t.get("lightingMaskBuffer").value=a.map;const o=i.get("LIGHTING_MASK_CHANNEL"),c=a.channel;c!==o&&(/^[rgba]$/.test(c)?(i.set("LIGHTING_MASK_CHANNEL",c),e=!0):console.error(`Expression validation failed: ${c}`))}return e}update(e,t,i){this.copyCameraSettings(this.camera);let a=!1;a||(a=this.updateOverlay()),a||(a=this.updateShadow()),a||(a=this.updateShadowLength()),a||(a=this.updateLightingMask()),a&&this.setChanged(),++this.uniforms.get("frame").value}get normalBuffer(){return this.uniforms.get("normalBuffer").value}set normalBuffer(e){this.uniforms.get("normalBuffer").value=e}get irradianceTexture(){return this.uniforms.get("irradiance_texture").value}set irradianceTexture(e){this.uniforms.get("irradiance_texture").value=e}get scatteringTexture(){return this.uniforms.get("scattering_texture").value}set scatteringTexture(e){this.uniforms.get("scattering_texture").value=e}get transmittanceTexture(){return this.uniforms.get("transmittance_texture").value}set transmittanceTexture(e){this.uniforms.get("transmittance_texture").value=e}get singleMieScatteringTexture(){return this.uniforms.get("single_mie_scattering_texture").value}set singleMieScatteringTexture(e){this.uniforms.get("single_mie_scattering_texture").value=e,this.combinedScatteringTextures=e==null}get higherOrderScatteringTexture(){return this.uniforms.get("higher_order_scattering_texture").value}set higherOrderScatteringTexture(e){this.uniforms.get("higher_order_scattering_texture").value=e,this.hasHigherOrderScatteringTexture=e!=null}get ellipsoid(){return this._ellipsoid}set ellipsoid(e){this._ellipsoid=e,this.uniforms.get("ellipsoidRadii").value.copy(e.radii)}get worldToECEFMatrix(){return this.uniforms.get("worldToECEFMatrix").value}get sunDirection(){return this.uniforms.get("sunDirection").value}get sunIrradiance(){return this.sunLight}set sunIrradiance(e){this.sunLight=e}get skyIrradiance(){return this.skyLight}set skyIrradiance(e){this.skyLight=e}get irradianceScale(){return this.albedoScale}set irradianceScale(e){this.albedoScale=e}get albedoScale(){return this.uniforms.get("albedoScale").value}set albedoScale(e){this.uniforms.get("albedoScale").value=e}get moonDirection(){return this.uniforms.get("moonDirection").value}get moonAngularRadius(){return this.uniforms.get("moonAngularRadius").value}set moonAngularRadius(e){this.uniforms.get("moonAngularRadius").value=e}get lunarRadianceScale(){return this.uniforms.get("lunarRadianceScale").value}set lunarRadianceScale(e){this.uniforms.get("lunarRadianceScale").value=e}get stbnTexture(){return this.uniforms.get("stbnTexture").value}set stbnTexture(e){this.uniforms.get("stbnTexture").value=e}get shadowRadius(){return this.uniforms.get("shadowRadius").value}set shadowRadius(e){this.uniforms.get("shadowRadius").value=e}};ir([dn("OCT_ENCODED_NORMAL")],za.prototype,"octEncodedNormal");ir([dn("RECONSTRUCT_NORMAL")],za.prototype,"reconstructNormal");ir([dn("COMBINED_SCATTERING_TEXTURES")],za.prototype,"combinedScatteringTextures");ir([dn("HAS_HIGHER_ORDER_SCATTERING_TEXTURE")],za.prototype,"hasHigherOrderScatteringTexture");ir([dn("CORRECT_GEOMETRIC_ERROR")],za.prototype,"correctGeometricError");ir([dn("SUN_LIGHT")],za.prototype,"sunLight");ir([dn("SKY_LIGHT")],za.prototype,"skyLight");ir([dn("TRANSMITTANCE")],za.prototype,"transmittance");ir([dn("INSCATTER")],za.prototype,"inscatter");ir([dn("SKY")],za.prototype,"sky");ir([dn("SUN")],za.prototype,"sun");ir([dn("MOON")],za.prototype,"moon");ir([dn("GROUND")],za.prototype,"ground");ir([dh("SHADOW_SAMPLE_COUNT",{min:1,max:16})],za.prototype,"shadowSampleCount");var dne=Object.defineProperty,PP=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&dne(e,t,a),a};const pne=new L;function mne(n,e){let t="",i="";for(let a=1;a<e;++a)t+=`layout(location = ${a}) out float renderTarget${a};
`,i+=`renderTarget${a} = 0.0;
`;return n.replace("#include <mrt_layout>",t).replace("#include <mrt_output>",i)}const vA={ellipsoid:g0.WGS84,correctAltitude:!0,renderTargetCount:1};class q0 extends ch{constructor(e,t=Y0.DEFAULT){const{irradianceTexture:i=null,scatteringTexture:a=null,transmittanceTexture:r=null,singleMieScatteringTexture:s=null,higherOrderScatteringTexture:o=null,ellipsoid:c,correctAltitude:h,sunDirection:f,sunAngularRadius:d,renderTargetCount:m,...g}={...vA,...e};super({toneMapped:!1,depthWrite:!1,depthTest:!1,...g,uniforms:{cameraPosition:new J(new L),worldToECEFMatrix:new J(new ke),altitudeCorrection:new J(new L),sunDirection:new J((f==null?void 0:f.clone())??new L),ATMOSPHERE:t.toUniform(),SUN_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(t.sunRadianceToRelativeLuminance),SKY_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(t.skyRadianceToRelativeLuminance),irradiance_texture:new J(i),scattering_texture:new J(a),transmittance_texture:new J(r),single_mie_scattering_texture:new J(null),higher_order_scattering_texture:new J(null),...g.uniforms},defines:{PI:`${Math.PI}`,TRANSMITTANCE_TEXTURE_WIDTH:Jd.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:$d.toFixed(0),SCATTERING_TEXTURE_R_SIZE:dy.toFixed(0),SCATTERING_TEXTURE_MU_SIZE:py.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:my.toFixed(0),SCATTERING_TEXTURE_NU_SIZE:gy.toFixed(0),IRRADIANCE_TEXTURE_WIDTH:Kd.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:Qd.toFixed(0),METER_TO_LENGTH_UNIT:t1.toFixed(7),...g.defines}}),this.atmosphere=t,this.combinedScatteringTextures=!1,this.hasHigherOrderScatteringTexture=!1,this.singleMieScatteringTexture=s,this.higherOrderScatteringTexture=o,this.ellipsoid=c,this.correctAltitude=h,d!=null&&(this.sunAngularRadius=d),this.renderTargetCount=m}copyCameraSettings(e){const t=this.uniforms,i=e.getWorldPosition(t.cameraPosition.value),a=pne.copy(i).applyMatrix4(t.worldToECEFMatrix.value),r=t.altitudeCorrection.value;this.correctAltitude?gA(a,this.atmosphere.bottomRadius,this.ellipsoid,r):r.setScalar(0)}onBeforeCompile(e,t){e.fragmentShader=mne(e.fragmentShader,this.renderTargetCount)}onBeforeRender(e,t,i,a,r,s){this.copyCameraSettings(i)}get irradianceTexture(){return this.uniforms.irradiance_texture.value}set irradianceTexture(e){this.uniforms.irradiance_texture.value=e}get scatteringTexture(){return this.uniforms.scattering_texture.value}set scatteringTexture(e){this.uniforms.scattering_texture.value=e}get transmittanceTexture(){return this.uniforms.transmittance_texture.value}set transmittanceTexture(e){this.uniforms.transmittance_texture.value=e}get singleMieScatteringTexture(){return this.uniforms.single_mie_scattering_texture.value}set singleMieScatteringTexture(e){this.uniforms.single_mie_scattering_texture.value=e,this.combinedScatteringTextures=e==null}get higherOrderScatteringTexture(){return this.uniforms.higher_order_scattering_texture.value}set higherOrderScatteringTexture(e){this.uniforms.higher_order_scattering_texture.value=e,this.hasHigherOrderScatteringTexture=e!=null}get worldToECEFMatrix(){return this.uniforms.worldToECEFMatrix.value}get sunDirection(){return this.uniforms.sunDirection.value}get sunAngularRadius(){return this.uniforms.ATMOSPHERE.value.sun_angular_radius}set sunAngularRadius(e){this.uniforms.ATMOSPHERE.value.sun_angular_radius=e}get renderTargetCount(){return this._renderTargetCount}set renderTargetCount(e){e!==this.renderTargetCount&&(this._renderTargetCount=e,this.needsUpdate=!0)}}PP([dn("COMBINED_SCATTERING_TEXTURES")],q0.prototype,"combinedScatteringTextures");PP([dn("HAS_HIGHER_ORDER_SCATTERING_TEXTURE")],q0.prototype,"hasHigherOrderScatteringTexture");/**
@preserve
Astronomy library for JavaScript (browser and Node.js).
https://github.com/cosinekitty/astronomy
MIT License
Copyright (c) 2019-2023 Don Cross <cosinekitty@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*//**
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
* @author Don Cross <cosinekitty@gmail.com>
* @license MIT
*/const gne=173.1446326846693,vne=14959787069098932e-8,$u=.017453292519943295,_ne=365.24217,yO=new Date("2000-01-01T12:00:00Z"),zo=2*Math.PI,Pl=3600*(180/Math.PI),Xf=484813681109536e-20,xne=10800*60,yne=2*xne,Sne=6378.1366,Tne=Sne/vne,Ene=81.30056,_A=.0002959122082855911,kE=2825345909524226e-22,WE=8459715185680659e-23,XE=1292024916781969e-23,YE=1524358900784276e-23;function y_(n){if(!Number.isFinite(n))throw console.trace(),`Value is not a finite number: ${n}`;return n}function yf(n){return n-Math.floor(n)}var zn;(function(n){n.Sun="Sun",n.Moon="Moon",n.Mercury="Mercury",n.Venus="Venus",n.Earth="Earth",n.Mars="Mars",n.Jupiter="Jupiter",n.Saturn="Saturn",n.Uranus="Uranus",n.Neptune="Neptune",n.Pluto="Pluto",n.SSB="SSB",n.EMB="EMB",n.Star1="Star1",n.Star2="Star2",n.Star3="Star3",n.Star4="Star4",n.Star5="Star5",n.Star6="Star6",n.Star7="Star7",n.Star8="Star8"})(zn||(zn={}));const Mne=[zn.Star1,zn.Star2,zn.Star3,zn.Star4,zn.Star5,zn.Star6,zn.Star7,zn.Star8],bne=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function Ane(n){const e=Mne.indexOf(n);return e>=0?bne[e]:null}function zP(n){const e=Ane(n);return e&&e.dist>0?e:null}var rl;(function(n){n[n.From2000=0]="From2000",n[n.Into2000=1]="Into2000"})(rl||(rl={}));const Yf={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function Rne(n){var e,t,i,a,r,s,o;const c=2e3+(n-14)/_ne;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,i=e*t,a=t*t,r=t*i,s=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*a+.022174192*r+.0090316521*s):c<1600?(e=(c-1e3)/100,t=e*e,i=e*t,a=t*t,r=t*i,s=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*a-.005050998*r+.0083572073*s):c<1700?(e=c-1600,t=e*e,i=e*t,120-.9808*e-.01532*t+i/7129):c<1800?(e=c-1700,t=e*e,i=e*t,a=t*t,8.83+.1603*e-.0059285*t+13336e-8*i-a/1174e3):c<1860?(e=c-1800,t=e*e,i=e*t,a=t*t,r=t*i,s=i*i,o=i*a,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*a+121272e-10*r-1699e-10*s+875e-12*o):c<1900?(e=c-1860,t=e*e,i=e*t,a=t*t,r=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*a+r/233174):c<1920?(e=c-1900,t=e*e,i=e*t,a=t*t,-2.79+1.494119*e-.0598939*t+.0061966*i-197e-6*a):c<1941?(e=c-1920,t=e*e,i=e*t,21.2+.84493*e-.0761*t+.0020936*i):c<1961?(e=c-1950,t=e*e,i=e*t,29.07+.407*e-t/233+i/2547):c<1986?(e=c-1975,t=e*e,i=e*t,45.45+1.067*e-t/260-i/718):c<2005?(e=c-2e3,t=e*e,i=e*t,a=t*t,r=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*a+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let wne=Rne;function SO(n){return n+wne(n)/86400}class lc{constructor(e){if(e instanceof lc){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-yO.getTime())/t,this.tt=SO(this.ut);return}if(Number.isFinite(e)){this.date=new Date(yO.getTime()+e*t),this.ut=e,this.tt=SO(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new lc(e);for(;;){const i=e-t.tt;if(Math.abs(i)<1e-12)return t;t=t.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(e){return new lc(this.ut+e)}}function ph(n){return n instanceof lc?n:new lc(n)}function Cne(n){function e(m){return m%yne*Xf}const t=n.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),a=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),s=e(450160.398036-t*69628905431e-4);let o=Math.sin(s),c=Math.cos(s),h=(-172064161-174666*t)*o+33386*c,f=(92052331+9086*t)*c+15377*o,d=2*(a-r+s);return o=Math.sin(d),c=Math.cos(d),h+=(-13170906-1675*t)*o-13696*c,f+=(5730336-3015*t)*c-4587*o,d=2*(a+s),o=Math.sin(d),c=Math.cos(d),h+=(-2276413-234*t)*o+2796*c,f+=(978459-485*t)*c+1374*o,d=2*s,o=Math.sin(d),c=Math.cos(d),h+=(2074554+207*t)*o-698*c,f+=(-897492+470*t)*c-291*o,o=Math.sin(i),c=Math.cos(i),h+=(1475877-3633*t)*o+11817*c,f+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+h*1e-7,deps:388e-6+f*1e-7}}function BP(n){var e=n.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var qv;function HP(n){if(!qv||Math.abs(qv.tt-n.tt)>1e-6){const e=Cne(n),t=BP(n),i=t+e.deps/3600;qv={tt:n.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*$u)/15,mobl:t,tobl:i}}return qv}function Nne(n,e){const t=n*$u,i=Math.cos(t),a=Math.sin(t);return[e[0],e[1]*i-e[2]*a,e[1]*a+e[2]*i]}function Dne(n,e){return Nne(BP(n),e)}function One(n){const e=n.tt/36525;function t(ot,Ke){const Te=[];let G;for(G=0;G<=Ke-ot;++G)Te.push(0);return{min:ot,array:Te}}function i(ot,Ke,Te,G){const Me=[];for(let De=0;De<=Ke-ot;++De)Me.push(t(Te,G));return{min:ot,array:Me}}function a(ot,Ke,Te){const G=ot.array[Ke-ot.min];return G.array[Te-G.min]}function r(ot,Ke,Te,G){const Me=ot.array[Ke-ot.min];Me.array[Te-Me.min]=G}let s,o,c,h,f,d,m,g,x,T,S,v,y,E,b,D,C,I,P,O,R,B,j,ee=i(-6,6,1,4),se=i(-6,6,1,4);function re(ot,Ke){return a(ee,ot,Ke)}function W(ot,Ke){return a(se,ot,Ke)}function te(ot,Ke,Te){return r(ee,ot,Ke,Te)}function K(ot,Ke,Te){return r(se,ot,Ke,Te)}function oe(ot,Ke,Te,G,Me){Me(ot*Te-Ke*G,Ke*Te+ot*G)}function ie(ot){return Math.sin(zo*ot)}m=e*e,x=0,j=0,S=0,v=3422.7;var Ce=ie(.19833+.05611*e),Xe=ie(.27869+.04508*e),nt=ie(.16827-.36903*e),tt=ie(.34734-5.37261*e),gt=ie(.10498-5.37899*e),ge=ie(.42681-.41855*e),Ae=ie(.14943-5.37511*e);for(I=.84*Ce+.31*Xe+14.27*nt+7.26*tt+.28*gt+.24*ge,P=2.94*Ce+.31*Xe+14.27*nt+9.34*tt+1.12*gt+.83*ge,O=-6.4*Ce-1.89*ge,R=.21*Ce+.31*Xe+14.27*nt-88.7*tt-15.3*gt+.24*ge-1.86*Ae,B=I-O,g=-3332e-9*ie(.59734-5.37261*e)-539e-9*ie(.35498-5.37899*e)-64e-9*ie(.39943-5.37511*e),y=zo*yf(.60643382+1336.85522467*e-313e-8*m)+I/Pl,E=zo*yf(.37489701+1325.55240982*e+2565e-8*m)+P/Pl,b=zo*yf(.99312619+99.99735956*e-44e-8*m)+O/Pl,D=zo*yf(.25909118+1342.2278298*e-892e-8*m)+R/Pl,C=zo*yf(.82736186+1236.85308708*e-397e-8*m)+B/Pl,f=1;f<=4;++f){switch(f){case 1:c=E,o=4,h=1.000002208;break;case 2:c=b,o=3,h=.997504612-.002495388*e;break;case 3:c=D,o=4,h=1.000002708+139.978*g;break;case 4:c=C,o=6,h=1;break;default:throw`Internal error: I = ${f}`}for(te(0,f,1),te(1,f,Math.cos(c)*h),K(0,f,0),K(1,f,Math.sin(c)*h),d=2;d<=o;++d)oe(re(d-1,f),W(d-1,f),re(1,f),W(1,f),(ot,Ke)=>(te(d,f,ot),K(d,f,Ke)));for(d=1;d<=o;++d)te(-d,f,re(d,f)),K(-d,f,-W(d,f))}function Ze(ot,Ke,Te,G){for(var Me={x:1,y:0},De=[0,ot,Ke,Te,G],Fe=1;Fe<=4;++Fe)De[Fe]!==0&&oe(Me.x,Me.y,re(De[Fe],Fe),W(De[Fe],Fe),(Be,$e)=>(Me.x=Be,Me.y=$e));return Me}function ue(ot,Ke,Te,G,Me,De,Fe,Be){var $e=Ze(Me,De,Fe,Be);x+=ot*$e.y,j+=Ke*$e.y,S+=Te*$e.x,v+=G*$e.x}ue(13.902,14.06,-.001,.2607,0,0,0,4),ue(.403,-4.01,.394,.0023,0,0,0,3),ue(2369.912,2373.36,.601,28.2333,0,0,0,2),ue(-125.154,-112.79,-.725,-.9781,0,0,0,1),ue(1.979,6.98,-.445,.0433,1,0,0,4),ue(191.953,192.72,.029,3.0861,1,0,0,2),ue(-8.466,-13.51,.455,-.1093,1,0,0,1),ue(22639.5,22609.07,.079,186.5398,1,0,0,0),ue(18.609,3.59,-.094,.0118,1,0,0,-1),ue(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),ue(3.215,5.44,.192,-.0386,1,0,0,-3),ue(-38.428,-38.64,.001,.6008,1,0,0,-4),ue(-.393,-1.43,-.092,.0086,1,0,0,-6),ue(-.289,-1.59,.123,-.0053,0,1,0,4),ue(-24.42,-25.1,.04,-.3,0,1,0,2),ue(18.023,17.93,.007,.1494,0,1,0,1),ue(-668.146,-126.98,-1.302,-.3997,0,1,0,0),ue(.56,.32,-.001,-.0037,0,1,0,-1),ue(-165.145,-165.06,.054,1.9178,0,1,0,-2),ue(-1.877,-6.46,-.416,.0339,0,1,0,-4),ue(.213,1.02,-.074,.0054,2,0,0,4),ue(14.387,14.78,-.017,.2833,2,0,0,2),ue(-.586,-1.2,.054,-.01,2,0,0,1),ue(769.016,767.96,.107,10.1657,2,0,0,0),ue(1.75,2.01,-.018,.0155,2,0,0,-1),ue(-211.656,-152.53,5.679,-.3039,2,0,0,-2),ue(1.225,.91,-.03,-.0088,2,0,0,-3),ue(-30.773,-34.07,-.308,.3722,2,0,0,-4),ue(-.57,-1.4,-.074,.0109,2,0,0,-6),ue(-2.921,-11.75,.787,-.0484,1,1,0,2),ue(1.267,1.52,-.022,.0164,1,1,0,1),ue(-109.673,-115.18,.461,-.949,1,1,0,0),ue(-205.962,-182.36,2.056,1.4437,1,1,0,-2),ue(.233,.36,.012,-.0025,1,1,0,-3),ue(-4.391,-9.66,-.471,.0673,1,1,0,-4),ue(.283,1.53,-.111,.006,1,-1,0,4),ue(14.577,31.7,-1.54,.2302,1,-1,0,2),ue(147.687,138.76,.679,1.1528,1,-1,0,0),ue(-1.089,.55,.021,0,1,-1,0,-1),ue(28.475,23.59,-.443,-.2257,1,-1,0,-2),ue(-.276,-.38,-.006,-.0036,1,-1,0,-3),ue(.636,2.27,.146,-.0102,1,-1,0,-4),ue(-.189,-1.68,.131,-.0028,0,2,0,2),ue(-7.486,-.66,-.037,-.0086,0,2,0,0),ue(-8.096,-16.35,-.74,.0918,0,2,0,-2),ue(-5.741,-.04,0,-9e-4,0,0,2,2),ue(.255,0,0,0,0,0,2,1),ue(-411.608,-.2,0,-.0124,0,0,2,0),ue(.584,.84,0,.0071,0,0,2,-1),ue(-55.173,-52.14,0,-.1052,0,0,2,-2),ue(.254,.25,0,-.0017,0,0,2,-3),ue(.025,-1.67,0,.0031,0,0,2,-4),ue(1.06,2.96,-.166,.0243,3,0,0,2),ue(36.124,50.64,-1.3,.6215,3,0,0,0),ue(-13.193,-16.4,.258,-.1187,3,0,0,-2),ue(-1.187,-.74,.042,.0074,3,0,0,-4),ue(-.293,-.31,-.002,.0046,3,0,0,-6),ue(-.29,-1.45,.116,-.0051,2,1,0,2),ue(-7.649,-10.56,.259,-.1038,2,1,0,0),ue(-8.627,-7.59,.078,-.0192,2,1,0,-2),ue(-2.74,-2.54,.022,.0324,2,1,0,-4),ue(1.181,3.32,-.212,.0213,2,-1,0,2),ue(9.703,11.67,-.151,.1268,2,-1,0,0),ue(-.352,-.37,.001,-.0028,2,-1,0,-1),ue(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),ue(.36,.2,-.012,-.0043,2,-1,0,-4),ue(-1.167,-1.25,.008,-.0106,1,2,0,0),ue(-7.412,-6.12,.117,.0484,1,2,0,-2),ue(-.311,-.65,-.032,.0044,1,2,0,-4),ue(.757,1.82,-.105,.0112,1,-2,0,2),ue(2.58,2.32,.027,.0196,1,-2,0,0),ue(2.533,2.4,-.014,-.0212,1,-2,0,-2),ue(-.344,-.57,-.025,.0036,0,3,0,-2),ue(-.992,-.02,0,0,1,0,2,2),ue(-45.099,-.02,0,-.001,1,0,2,0),ue(-.179,-9.52,0,-.0833,1,0,2,-2),ue(-.301,-.33,0,.0014,1,0,2,-4),ue(-6.382,-3.37,0,-.0481,1,0,-2,2),ue(39.528,85.13,0,-.7136,1,0,-2,0),ue(9.366,.71,0,-.0112,1,0,-2,-2),ue(.202,.02,0,0,1,0,-2,-4),ue(.415,.1,0,.0013,0,1,2,0),ue(-2.152,-2.26,0,-.0066,0,1,2,-2),ue(-1.44,-1.3,0,.0014,0,1,-2,2),ue(.384,-.04,0,0,0,1,-2,-2),ue(1.938,3.6,-.145,.0401,4,0,0,0),ue(-.952,-1.58,.052,-.013,4,0,0,-2),ue(-.551,-.94,.032,-.0097,3,1,0,0),ue(-.482,-.57,.005,-.0045,3,1,0,-2),ue(.681,.96,-.026,.0115,3,-1,0,0),ue(-.297,-.27,.002,-9e-4,2,2,0,-2),ue(.254,.21,-.003,0,2,-2,0,-2),ue(-.25,-.22,.004,.0014,1,3,0,-2),ue(-3.996,0,0,4e-4,2,0,2,0),ue(.557,-.75,0,-.009,2,0,2,-2),ue(-.459,-.38,0,-.0053,2,0,-2,2),ue(-1.298,.74,0,4e-4,2,0,-2,0),ue(.538,1.14,0,-.0141,2,0,-2,-2),ue(.263,.02,0,0,1,1,2,0),ue(.426,.07,0,-6e-4,1,1,-2,-2),ue(-.304,.03,0,3e-4,1,-1,2,0),ue(-.372,-.19,0,-.0027,1,-1,-2,2),ue(.418,0,0,0,0,0,4,0),ue(-.33,-.04,0,0,3,0,2,0);function it(ot,Ke,Te,G,Me){return ot*Ze(Ke,Te,G,Me).y}T=0,T+=it(-526.069,0,0,1,-2),T+=it(-3.352,0,0,1,-4),T+=it(44.297,1,0,1,-2),T+=it(-6,1,0,1,-4),T+=it(20.599,-1,0,1,0),T+=it(-30.598,-1,0,1,-2),T+=it(-24.649,-2,0,1,0),T+=it(-2,-2,0,1,-2),T+=it(-22.571,0,1,1,-2),T+=it(10.985,0,-1,1,-2),x+=.82*ie(.7736-62.5512*e)+.31*ie(.0466-125.1025*e)+.35*ie(.5785-25.1042*e)+.66*ie(.4591+1335.8075*e)+.64*ie(.313-91.568*e)+1.14*ie(.148+1331.2898*e)+.21*ie(.5918+1056.5859*e)+.44*ie(.5784+1322.8595*e)+.24*ie(.2275-5.7374*e)+.28*ie(.2965+2.6929*e)+.33*ie(.3132+6.3368*e),s=D+j/Pl;let Mt=(1.000002708+139.978*g)*(18518.511+1.189+S)*Math.sin(s)-6.24*Math.sin(3*s)+T;return{geo_eclip_lon:zo*yf((y+x/Pl)/zo),geo_eclip_lat:Math.PI/(180*3600)*Mt,distance_au:Pl*Tne/(.999953253*v)}}function Lne(n,e){return[n.rot[0][0]*e[0]+n.rot[1][0]*e[1]+n.rot[2][0]*e[2],n.rot[0][1]*e[0]+n.rot[1][1]*e[1]+n.rot[2][1]*e[2],n.rot[0][2]*e[0]+n.rot[1][2]*e[1]+n.rot[2][2]*e[2]]}function Ine(n,e,t){const i=FP(e,t);return Lne(i,n)}function FP(n,e){const t=n.tt/36525;let i=84381.406,a=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,s=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=Xf,a*=Xf,r*=Xf,s*=Xf;const o=Math.sin(i),c=Math.cos(i),h=Math.sin(-a),f=Math.cos(-a),d=Math.sin(-r),m=Math.cos(-r),g=Math.sin(s),x=Math.cos(s),T=x*f-h*g*m,S=x*h*c+g*m*f*c-o*g*d,v=x*h*o+g*m*f*o+c*g*d,y=-g*f-h*x*m,E=-g*h*c+x*m*f*c-o*x*d,b=-g*h*o+x*m*f*o+c*x*d,D=h*d,C=-d*f*c-o*m,I=-d*f*o+m*c;if(e===rl.Into2000)return new Id([[T,S,v],[y,E,b],[D,C,I]]);if(e===rl.From2000)return new Id([[T,y,D],[S,E,C],[v,b,I]]);throw"Invalid precess direction"}function Une(n){const e=.779057273264+.00273781191135448*n.ut,t=n.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let jv;function Pne(n){if(!jv||jv.tt!==n.tt){const e=n.tt/36525;let t=15*HP(n).ee;const i=Une(n);let a=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;a<0&&(a+=24),jv={tt:n.tt,st:a}}return jv.st}function zne(n){const e=ph(n);return Pne(e)}function Bne(n,e){const t=HP(n),i=t.mobl*$u,a=t.tobl*$u,r=t.dpsi*Xf,s=Math.cos(i),o=Math.sin(i),c=Math.cos(a),h=Math.sin(a),f=Math.cos(r),d=Math.sin(r),m=f,g=-d*s,x=-d*o,T=d*c,S=f*s*c+o*h,v=f*o*c-s*h,y=d*h,E=f*s*h-o*c,b=f*o*h+s*c;if(e===rl.From2000)return new Id([[m,T,y],[g,S,E],[x,v,b]]);if(e===rl.Into2000)return new Id([[m,g,x],[T,S,v],[y,E,b]]);throw"Invalid precess direction"}class Rs{constructor(e,t,i,a){this.x=e,this.y=t,this.z=i,this.t=a}Length(){return Math.hypot(this.x,this.y,this.z)}}class Hne{constructor(e,t,i,a,r,s,o){this.x=e,this.y=t,this.z=i,this.vx=a,this.vy=r,this.vz=s,this.t=o}}let Fne=class{constructor(e,t,i){this.lat=y_(e),this.lon=y_(t),this.dist=y_(i)}};class Id{constructor(e){this.rot=e}}function qE(n){const e=ph(n),t=One(e),i=t.distance_au*Math.cos(t.geo_eclip_lat),a=[i*Math.cos(t.geo_eclip_lon),i*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],r=Dne(e,a),s=Ine(r,e,rl.Into2000);return new Rs(s[0],s[1],s[2],e)}function ad(n,e,t){let i=1,a=0;for(let r of n){let s=0;for(let[c,h,f]of r)s+=c*Math.cos(h+e*f);let o=i*s;t&&(o%=zo),a+=o,i*=e}return a}function J2(n,e){let t=1,i=0,a=0,r=0;for(let s of n){let o=0,c=0;for(let[h,f,d]of s){let m=f+e*d;o+=h*d*Math.sin(m),r>0&&(c+=h*Math.cos(m))}a+=r*i*c-t*o,i=t,t*=e,++r}return a}const pm=365250,jE=0,ZE=1,KE=2;function QE(n){return new ya(n[0]+44036e-11*n[1]-190919e-12*n[2],-479966e-12*n[0]+.917482137087*n[1]-.397776982902*n[2],.397776982902*n[1]+.917482137087*n[2])}function GP(n,e,t){const i=t*Math.cos(e),a=Math.cos(n),r=Math.sin(n);return[i*a,i*r,t*Math.sin(e)]}function S_(n,e){const t=e.tt/pm,i=ad(n[jE],t,!0),a=ad(n[ZE],t,!1),r=ad(n[KE],t,!1),s=GP(i,a,r);return QE(s).ToAstroVector(e)}function Gne(n,e){const t=e/pm,i=ad(n[jE],t,!0),a=ad(n[ZE],t,!1),r=ad(n[KE],t,!1),s=J2(n[jE],t),o=J2(n[ZE],t),c=J2(n[KE],t),h=Math.cos(i),f=Math.sin(i),d=Math.cos(a),m=Math.sin(a),g=+(c*d*h)-r*m*h*o-r*d*f*s,x=+(c*d*f)-r*m*f*o+r*d*h*s,T=+(c*m)+r*d*o,S=GP(i,a,r),v=[g/pm,x/pm,T/pm],y=QE(S),E=QE(v);return new eh(e,y,E)}function Zv(n,e,t,i){const a=i/(i+_A),r=S_(Yf[t],e);n.x+=a*r.x,n.y+=a*r.y,n.z+=a*r.z}function Vne(n){const e=new Rs(0,0,0,n);return Zv(e,n,zn.Jupiter,kE),Zv(e,n,zn.Saturn,WE),Zv(e,n,zn.Uranus,XE),Zv(e,n,zn.Neptune,YE),e}const JE=51,kne=29200,qf=146,Bo=201,Au=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class ya{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new ya(this.x,this.y,this.z)}ToAstroVector(e){return new Rs(this.x,this.y,this.z,e)}static zero(){return new ya(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new ya(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new ya(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new ya(e*this.x,e*this.y,e*this.z)}div(e){return new ya(this.x/e,this.y/e,this.z/e)}mean(e){return new ya((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new ya(-this.x,-this.y,-this.z)}}class eh{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new eh(this.tt,this.r,this.v)}sub(e){return new eh(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function Wne(n){let[e,[t,i,a],[r,s,o]]=n;return new eh(e,new ya(t,i,a),new ya(r,s,o))}function Kv(n,e,t,i){const a=i/(i+_A),r=Gne(Yf[t],e);return n.r.incr(r.r.mul(a)),n.v.incr(r.v.mul(a)),r}function $p(n,e,t){const i=t.sub(n),a=i.quadrature();return i.mul(e/(a*Math.sqrt(a)))}class xA{constructor(e){let t=new eh(e,new ya(0,0,0),new ya(0,0,0));this.Jupiter=Kv(t,e,zn.Jupiter,kE),this.Saturn=Kv(t,e,zn.Saturn,WE),this.Uranus=Kv(t,e,zn.Uranus,XE),this.Neptune=Kv(t,e,zn.Neptune,YE),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new eh(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=$p(e,_A,this.Sun.r);return t.incr($p(e,kE,this.Jupiter.r)),t.incr($p(e,WE,this.Saturn.r)),t.incr($p(e,XE,this.Uranus.r)),t.incr($p(e,YE,this.Neptune.r)),t}}let VP=class kP{constructor(e,t,i,a){this.tt=e,this.r=t,this.v=i,this.a=a}clone(){return new kP(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}},WP=class{constructor(e,t){this.bary=e,this.grav=t}};function n1(n,e,t,i){return new ya(e.x+n*(t.x+n*i.x/2),e.y+n*(t.y+n*i.y/2),e.z+n*(t.z+n*i.z/2))}function TO(n,e,t){return new ya(e.x+n*t.x,e.y+n*t.y,e.z+n*t.z)}function $E(n,e){const t=n-e.tt,i=new xA(n),a=n1(t,e.r,e.v,e.a),r=i.Acceleration(a).mean(e.a),s=n1(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=i.Acceleration(s),h=new VP(n,s,o,c);return new WP(i,h)}const Xne=[];function XP(n,e){const t=Math.floor(n);return t<0?0:t>=e?e-1:t}function eM(n){const e=Wne(n),t=new xA(e.tt),i=e.r.add(t.Sun.r),a=e.v.add(t.Sun.v),r=t.Acceleration(i),s=new VP(e.tt,i,a,r);return new WP(t,s)}function Yne(n,e){const t=Au[0][0];if(e<t||e>Au[JE-1][0])return null;const i=XP((e-t)/kne,JE-1);if(!n[i]){const r=n[i]=[];r[0]=eM(Au[i]).grav,r[Bo-1]=eM(Au[i+1]).grav;let s,o=r[0].tt;for(s=1;s<Bo-1;++s)r[s]=$E(o+=qf,r[s-1]).grav;o=r[Bo-1].tt;var a=[];for(a[Bo-1]=r[Bo-1],s=Bo-2;s>0;--s)a[s]=$E(o-=qf,a[s+1]).grav;for(s=Bo-2;s>0;--s){const c=s/(Bo-1);r[s].r=r[s].r.mul(1-c).add(a[s].r.mul(c)),r[s].v=r[s].v.mul(1-c).add(a[s].v.mul(c)),r[s].a=r[s].a.mul(1-c).add(a[s].a.mul(c))}}return n[i]}function EO(n,e,t){let i=eM(n);const a=Math.ceil((e-i.grav.tt)/t);for(let r=0;r<a;++r)i=$E(r+1===a?e:i.grav.tt+t,i.grav);return i}function qne(n,e){let t,i,a;const r=Yne(Xne,n.tt);if(r){const s=XP((n.tt-r[0].tt)/qf,Bo-1),o=r[s],c=r[s+1],h=o.a.mean(c.a),f=n1(n.tt-o.tt,o.r,o.v,h),d=TO(n.tt-o.tt,o.v,h),m=n1(n.tt-c.tt,c.r,c.v,h),g=TO(n.tt-c.tt,c.v,h),x=(n.tt-o.tt)/qf;t=f.mul(1-x).add(m.mul(x)),i=d.mul(1-x).add(g.mul(x))}else{let s;n.tt<Au[0][0]?s=EO(Au[0],n.tt,-qf):s=EO(Au[JE-1],n.tt,+qf),t=s.grav.r,i=s.grav.v,a=s.bary}return a||(a=new xA(n.tt)),t=t.sub(a.Sun.r),i=i.sub(a.Sun.v),new Hne(t.x,t.y,t.z,i.x,i.y,i.z,n)}function Vm(n,e){var t=ph(e);if(n in Yf)return S_(Yf[n],t);if(n===zn.Pluto){const s=qne(t);return new Rs(s.x,s.y,s.z,t)}if(n===zn.Sun)return new Rs(0,0,0,t);if(n===zn.Moon){var i=S_(Yf.Earth,t),a=qE(t);return new Rs(i.x+a.x,i.y+a.y,i.z+a.z,t)}if(n===zn.EMB){const s=S_(Yf.Earth,t),o=qE(t),c=1+Ene;return new Rs(s.x+o.x/c,s.y+o.y/c,s.z+o.z/c,t)}if(n===zn.SSB)return Vne(t);const r=zP(n);if(r){const s=new Fne(r.dec,15*r.ra,r.dist);return eie(s,t)}throw`HelioVector: Unknown body "${n}"`}function jne(n,e){let t=e,i=0;for(let a=0;a<10;++a){const r=n(t),s=r.Length()/gne;if(s>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-s);if(i=Math.abs(o.tt-t.tt),i<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class Zne{constructor(e,t,i,a){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=a}Position(e){this.aberration&&(this.observerPos=Vm(this.observerBody,e));const t=Vm(this.targetBody,e);return new Rs(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function Kne(n,e,t,i){const a=ph(n);if(zP(t)){const o=Vm(t,a),c=Vm(e,a);return new Rs(o.x-c.x,o.y-c.y,o.z-c.z,a)}let r;r=Vm(e,a);const s=new Zne(e,t,i,r);return jne(o=>s.Position(o),a)}function Qne(n,e,t){const i=ph(e);switch(n){case zn.Earth:return new Rs(0,0,0,i);case zn.Moon:return qE(i);default:const a=Kne(i,zn.Earth,n,t);return a.t=i,a}}var MO;(function(n){n[n.Pericenter=0]="Pericenter",n[n.Apocenter=1]="Apocenter"})(MO||(MO={}));function Jne(n,e){return new Id([[e.rot[0][0]*n.rot[0][0]+e.rot[1][0]*n.rot[0][1]+e.rot[2][0]*n.rot[0][2],e.rot[0][1]*n.rot[0][0]+e.rot[1][1]*n.rot[0][1]+e.rot[2][1]*n.rot[0][2],e.rot[0][2]*n.rot[0][0]+e.rot[1][2]*n.rot[0][1]+e.rot[2][2]*n.rot[0][2]],[e.rot[0][0]*n.rot[1][0]+e.rot[1][0]*n.rot[1][1]+e.rot[2][0]*n.rot[1][2],e.rot[0][1]*n.rot[1][0]+e.rot[1][1]*n.rot[1][1]+e.rot[2][1]*n.rot[1][2],e.rot[0][2]*n.rot[1][0]+e.rot[1][2]*n.rot[1][1]+e.rot[2][2]*n.rot[1][2]],[e.rot[0][0]*n.rot[2][0]+e.rot[1][0]*n.rot[2][1]+e.rot[2][0]*n.rot[2][2],e.rot[0][1]*n.rot[2][0]+e.rot[1][1]*n.rot[2][1]+e.rot[2][1]*n.rot[2][2],e.rot[0][2]*n.rot[2][0]+e.rot[1][2]*n.rot[2][1]+e.rot[2][2]*n.rot[2][2]]])}function $ne(n,e,t){const i=y_(t)*$u,a=Math.cos(i),r=Math.sin(i),s=(e+1)%3,o=(e+2)%3,c=e;let h=[[0,0,0],[0,0,0],[0,0,0]];return h[s][s]=a*n.rot[s][s]-r*n.rot[s][o],h[s][o]=r*n.rot[s][s]+a*n.rot[s][o],h[s][c]=n.rot[s][c],h[o][s]=a*n.rot[o][s]-r*n.rot[o][o],h[o][o]=r*n.rot[o][s]+a*n.rot[o][o],h[o][c]=n.rot[o][c],h[c][s]=a*n.rot[c][s]-r*n.rot[c][o],h[c][o]=r*n.rot[c][s]+a*n.rot[c][o],h[c][c]=n.rot[c][c],new Id(h)}function eie(n,e){e=ph(e);const t=n.lat*$u,i=n.lon*$u,a=n.dist*Math.cos(t);return new Rs(a*Math.cos(i),a*Math.sin(i),n.dist*Math.sin(t),e)}function tie(n){n=ph(n);const e=FP(n,rl.From2000),t=Bne(n,rl.From2000);return Jne(e,t)}var bO;(function(n){n.Penumbral="penumbral",n.Partial="partial",n.Annular="annular",n.Total="total"})(bO||(bO={}));var AO;(function(n){n[n.Invalid=0]="Invalid",n[n.Ascending=1]="Ascending",n[n.Descending=-1]="Descending"})(AO||(AO={}));function yA(n){return n instanceof lc?n:new lc(n instanceof Date?n:new Date(n))}function nie(n,e=new L){const{x:t,y:i,z:a}=n;return e.set(t,i,a)}function iie(n,e=new ke){const[t,i,a]=n.rot;return e.set(t[0],i[0],a[0],0,t[1],i[1],a[1],0,t[2],i[2],a[2],0,0,0,0,1)}function aie(n,e=new ke){const t=yA(n),i=$ne(tie(t),2,-15*zne(t));return iie(i,e)}function YP(n,e,t,i,a){const r=Qne(n,e,!1);return nie(r,t),i!=null,t.normalize()}function rie(n,e=new L,t){return YP(zn.Sun,yA(n),e,t)}function sie(n,e=new L,t){return YP(zn.Moon,yA(n),e,t)}const oie=`precision highp float;
precision highp sampler3D;
#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"
uniform AtmosphereParameters ATMOSPHERE;
uniform sampler2D transmittanceTexture;
layout(location = 0) out vec4 outputColor;
void main() {
vec3 deltaIrradiance;
vec3 irradiance;
deltaIrradiance = ComputeDirectIrradianceTexture(
ATMOSPHERE,
transmittanceTexture,
gl_FragCoord.xy
);
irradiance = vec3(0.0);
outputColor = vec4(OUTPUT, 1.0);
}
`,lie=`precision highp float;
precision highp sampler3D;
#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"
uniform AtmosphereParameters ATMOSPHERE;
uniform mat3 luminanceFromRadiance;
uniform sampler3D singleRayleighScatteringTexture;
uniform sampler3D singleMieScatteringTexture;
uniform sampler3D multipleScatteringTexture;
uniform int scatteringOrder;
layout(location = 0) out vec4 outputColor;
void main() {
vec3 deltaIrradiance;
vec3 irradiance;
deltaIrradiance = ComputeIndirectIrradianceTexture(
ATMOSPHERE,
singleRayleighScatteringTexture,
singleMieScatteringTexture,
multipleScatteringTexture,
gl_FragCoord.xy,
scatteringOrder
);
irradiance = luminanceFromRadiance * deltaIrradiance;
outputColor = vec4(OUTPUT, 1.0);
}
`,cie=`precision highp float;
precision highp sampler3D;
#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"
uniform AtmosphereParameters ATMOSPHERE;
uniform mat3 luminanceFromRadiance;
uniform sampler2D transmittanceTexture;
uniform sampler3D scatteringDensityTexture;
uniform int layer;
layout(location = 0) out vec4 outputColor;
void main() {
vec4 deltaMultipleScattering;
vec4 scattering;
float nu;
deltaMultipleScattering.rgb = ComputeMultipleScatteringTexture(
ATMOSPHERE,
transmittanceTexture,
scatteringDensityTexture,
vec3(gl_FragCoord.xy, float(layer) + 0.5),
nu
);
deltaMultipleScattering.a = 1.0;
scattering = vec4(
luminanceFromRadiance * deltaMultipleScattering.rgb / RayleighPhaseFunction(nu),
0.0
);
outputColor = OUTPUT;
}
`,uie=`precision highp float;
precision highp sampler3D;
#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"
uniform AtmosphereParameters ATMOSPHERE;
uniform sampler2D transmittanceTexture;
uniform sampler3D singleRayleighScatteringTexture;
uniform sampler3D singleMieScatteringTexture;
uniform sampler3D multipleScatteringTexture;
uniform sampler2D irradianceTexture;
uniform int scatteringOrder;
uniform int layer;
layout(location = 0) out vec4 scatteringDensity;
void main() {
scatteringDensity.rgb = ComputeScatteringDensityTexture(
ATMOSPHERE,
transmittanceTexture,
singleRayleighScatteringTexture,
singleMieScatteringTexture,
multipleScatteringTexture,
irradianceTexture,
vec3(gl_FragCoord.xy, float(layer) + 0.5),
scatteringOrder
);
scatteringDensity.a = 1.0;
}
`,hie=`precision highp float;
precision highp sampler3D;
#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"
uniform AtmosphereParameters ATMOSPHERE;
uniform mat3 luminanceFromRadiance;
uniform sampler2D transmittanceTexture;
uniform int layer;
layout(location = 0) out vec4 outputColor;
void main() {
vec4 deltaRayleigh;
vec4 deltaMie;
vec4 scattering;
vec4 singleMieScattering;
ComputeSingleScatteringTexture(
ATMOSPHERE,
transmittanceTexture,
vec3(gl_FragCoord.xy, float(layer) + 0.5),
deltaRayleigh.rgb,
deltaMie.rgb
);
deltaRayleigh.a = 1.0;
deltaMie.a = 1.0;
scattering = vec4(
luminanceFromRadiance * deltaRayleigh.rgb,
(luminanceFromRadiance * deltaMie.rgb).r
);
singleMieScattering.rgb = luminanceFromRadiance * deltaMie.rgb;
singleMieScattering.a = 1.0;
outputColor = OUTPUT;
}
`,fie=`precision highp float;
precision highp sampler3D;
#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"
uniform AtmosphereParameters ATMOSPHERE;
layout(location = 0) out vec4 transmittance;
void main() {
transmittance.rgb = ComputeTransmittanceToTopAtmosphereBoundaryTexture(
ATMOSPHERE,
gl_FragCoord.xy
);
transmittance.a = 1.0;
}
`,die=`
precision highp float;
in vec2 position;
void main() {
gl_Position = vec4(position, 1.0, 1.0);
}
`;function i1(n,e,t){const i=new _i(e,t,{depthBuffer:!1,type:n,format:Jn}),a=i.texture;return a.minFilter=Ht,a.magFilter=Ht,a.wrapS=Li,a.wrapT=Li,a.colorSpace=Na,i}function rd(n,e,t,i){const a=new zU(e,t,i,{depthBuffer:!1,type:n,format:Jn}),r=a.texture;return r.minFilter=Ht,r.magFilter=Ht,r.wrapS=Li,r.wrapT=Li,r.wrapR=Li,r.colorSpace=Na,a}function pie(n){const e=n[Symbol.iterator]();return new Promise((t,i)=>{const a=()=>{try{const{value:r,done:s}=e.next();s===!0?t(r):xO(a)}catch(r){i(r instanceof Error?r:new Error)}};xO(a)})}async function RO(n,e,t){const{width:i,height:a}=e,r=t.type===Xn?new Uint16Array(i*a*4):new Float32Array(i*a*4);await n.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,r),t.userData.imageData=r}class mie{constructor(e){this.lambdas=new L,this.luminanceFromRadiance=new Et,e===Xn&&(this.opticalDepth=i1(e,Jd,$d)),this.deltaIrradiance=i1(e,Kd,Qd),this.deltaRayleighScattering=rd(e,Uu,Pu,zu),this.deltaMieScattering=rd(e,Uu,Pu,zu),this.deltaScatteringDensity=rd(e,Uu,Pu,zu),this.deltaMultipleScattering=this.deltaRayleighScattering}dispose(){var e;(e=this.opticalDepth)==null||e.dispose(),this.deltaIrradiance.dispose(),this.deltaRayleighScattering.dispose(),this.deltaMieScattering.dispose(),this.deltaScatteringDensity.dispose()}}class Sf extends ch{constructor(e){super({glslVersion:ao,vertexShader:die,...e,defines:{TRANSMITTANCE_TEXTURE_WIDTH:Jd.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:$d.toFixed(0),SCATTERING_TEXTURE_R_SIZE:dy.toFixed(0),SCATTERING_TEXTURE_MU_SIZE:py.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:my.toFixed(0),SCATTERING_TEXTURE_NU_SIZE:gy.toFixed(0),IRRADIANCE_TEXTURE_WIDTH:Kd.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:Qd.toFixed(0),...e.defines}})}set additive(e){this.transparent=e,this.blending=e?lb:Sa,this.blendEquation=Qs,this.blendEquationAlpha=Qs,this.blendSrc=Gf,this.blendDst=Gf,this.blendSrcAlpha=Gf,this.blendDstAlpha=Gf}setUniforms(e){const t=this.uniforms;t.luminanceFromRadiance!=null&&t.luminanceFromRadiance.value.copy(e.luminanceFromRadiance),t.singleRayleighScatteringTexture!=null&&(t.singleRayleighScatteringTexture.value=e.deltaRayleighScattering.texture),t.singleMieScatteringTexture!=null&&(t.singleMieScatteringTexture.value=e.deltaMieScattering.texture),t.multipleScatteringTexture!=null&&(t.multipleScatteringTexture.value=e.deltaMultipleScattering.texture),t.scatteringDensityTexture!=null&&(t.scatteringDensityTexture.value=e.deltaScatteringDensity.texture),t.irradianceTexture!=null&&(t.irradianceTexture.value=e.deltaIrradiance.texture)}}class gie{constructor(e,{type:t=tP(e)?ri:Xn,combinedScattering:i=!0,higherOrderScattering:a=!0}={}){var r,s;this.transmittanceMaterial=new Sf({fragmentShader:Ca(fie,{bruneton:{common:Zs,definitions:Ks,precompute:_f}})}),this.directIrradianceMaterial=new Sf({fragmentShader:Ca(oie,{bruneton:{common:Zs,definitions:Ks,precompute:_f}}),uniforms:{transmittanceTexture:new J(null)}}),this.singleScatteringMaterial=new Sf({fragmentShader:Ca(hie,{bruneton:{common:Zs,definitions:Ks,precompute:_f}}),uniforms:{luminanceFromRadiance:new J(new Et),transmittanceTexture:new J(null),layer:new J(0)}}),this.scatteringDensityMaterial=new Sf({fragmentShader:Ca(uie,{bruneton:{common:Zs,definitions:Ks,precompute:_f}}),uniforms:{transmittanceTexture:new J(null),singleRayleighScatteringTexture:new J(null),singleMieScatteringTexture:new J(null),multipleScatteringTexture:new J(null),irradianceTexture:new J(null),scatteringOrder:new J(0),layer:new J(0)}}),this.indirectIrradianceMaterial=new Sf({fragmentShader:Ca(lie,{bruneton:{common:Zs,definitions:Ks,precompute:_f}}),uniforms:{luminanceFromRadiance:new J(new Et),singleRayleighScatteringTexture:new J(null),singleMieScatteringTexture:new J(null),multipleScatteringTexture:new J(null),scatteringOrder:new J(0)}}),this.multipleScatteringMaterial=new Sf({fragmentShader:Ca(cie,{bruneton:{common:Zs,definitions:Ks,precompute:_f}}),uniforms:{luminanceFromRadiance:new J(new Et),transmittanceTexture:new J(null),scatteringDensityTexture:new J(null),layer:new J(0)}}),this.mesh=new si(new lh(2,2)),this.scene=new Ad().add(this.mesh),this.camera=new Tc,this.updating=!1,this.renderer=e,this.type=t,this.transmittanceRenderTarget=i1(t,Jd,$d),this.scatteringRenderTarget=rd(t,Uu,Pu,zu),this.irradianceRenderTarget=i1(t,Kd,Qd),i||(this.singleMieScatteringRenderTarget=rd(t,Uu,Pu,zu)),a&&(this.higherOrderScatteringRenderTarget=rd(t,Uu,Pu,zu)),this.textures={transmittanceTexture:this.transmittanceRenderTarget.texture,scatteringTexture:this.scatteringRenderTarget.texture,irradianceTexture:this.irradianceRenderTarget.texture,singleMieScatteringTexture:(r=this.singleMieScatteringRenderTarget)==null?void 0:r.texture,higherOrderScatteringTexture:(s=this.higherOrderScatteringRenderTarget)==null?void 0:s.texture}}render3DRenderTarget(e,t){for(let i=0;i<e.depth;++i)t.uniforms.layer.value=i,this.renderer.setRenderTarget(e,i),this.renderer.render(this.scene,this.camera)}computeTransmittance(e){const t=this.transmittanceMaterial;delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeOpticalDepth(e){const t=this.transmittanceMaterial;t.defines.TRANSMITTANCE_PRECISION_LOG="1",t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeDirectIrradiance(e){var a;const t=this.directIrradianceMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===Xn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.texture)??this.transmittanceRenderTarget.texture,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeSingleScattering(e){var a;const t=this.singleScatteringMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===Xn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.texture)??this.transmittanceRenderTarget.texture,t.setUniforms(e.context),this.mesh.material=t,this.render3DRenderTarget(e.renderTarget,t)}computeScatteringDensity(e){var a;const t=this.scatteringDensityMaterial;this.type===Xn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.texture)??this.transmittanceRenderTarget.texture,i.scatteringOrder.value=e.scatteringOrder,t.setUniforms(e.context),this.mesh.material=t,this.render3DRenderTarget(e.renderTarget,t)}computeIndirectIrradiance(e){const t=this.indirectIrradianceMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,t.needsUpdate=!0;const i=t.uniforms;i.scatteringOrder.value=e.scatteringOrder-1,t.setUniforms(e.context),this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeMultipleScattering(e){var a;const t=this.multipleScatteringMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===Xn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.texture)??this.transmittanceRenderTarget.texture,t.setUniforms(e.context),this.mesh.material=t,this.render3DRenderTarget(e.renderTarget,t)}*precompute(e,t){this.computeTransmittance({renderTarget:this.transmittanceRenderTarget}),this.type===Xn&&(ine(e.opticalDepth!=null),this.computeOpticalDepth({renderTarget:e.opticalDepth})),this.computeDirectIrradiance({renderTarget:e.deltaIrradiance,context:e,output:"deltaIrradiance",additive:!1}),this.computeDirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,output:"irradiance",additive:t}),this.renderer.setRenderTarget(null),yield,this.computeSingleScattering({renderTarget:e.deltaRayleighScattering,context:e,output:"deltaRayleigh",additive:!1}),this.computeSingleScattering({renderTarget:e.deltaMieScattering,context:e,output:"deltaMie",additive:!1}),this.computeSingleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:t}),this.singleMieScatteringRenderTarget!=null&&this.computeSingleScattering({renderTarget:this.singleMieScatteringRenderTarget,context:e,output:"singleMieScattering",additive:t}),this.renderer.setRenderTarget(null),yield;for(let i=2;i<=4;++i)this.computeScatteringDensity({renderTarget:e.deltaScatteringDensity,context:e,scatteringOrder:i}),this.computeIndirectIrradiance({renderTarget:e.deltaIrradiance,context:e,scatteringOrder:i,output:"deltaIrradiance",additive:!1}),this.computeIndirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,scatteringOrder:i,output:"irradiance",additive:!0}),this.computeMultipleScattering({renderTarget:e.deltaMultipleScattering,context:e,output:"deltaMultipleScattering",additive:!1}),this.computeMultipleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:!0}),this.higherOrderScatteringRenderTarget!=null&&this.computeMultipleScattering({renderTarget:this.higherOrderScatteringRenderTarget,context:e,output:"scattering",additive:!0}),this.renderer.setRenderTarget(null),yield}async update(e=Y0.DEFAULT){var s;this.updating=!0;const t=e.toUniform();this.transmittanceMaterial.uniforms.ATMOSPHERE=t,this.directIrradianceMaterial.uniforms.ATMOSPHERE=t,this.singleScatteringMaterial.uniforms.ATMOSPHERE=t,this.scatteringDensityMaterial.uniforms.ATMOSPHERE=t,this.indirectIrradianceMaterial.uniforms.ATMOSPHERE=t,this.multipleScatteringMaterial.uniforms.ATMOSPHERE=t;const i=this.renderer,a=new mie(this.type);a.lambdas.set(680,550,440),a.luminanceFromRadiance.identity();const r=i.autoClear;return i.autoClear=!1,await pie(this.precompute(a,!1)),i.autoClear=r,a.dispose(),await RO(this.renderer,this.transmittanceRenderTarget,this.transmittanceRenderTarget.texture),await RO(this.renderer,this.irradianceRenderTarget,this.irradianceRenderTarget.texture),this.updating=!1,(s=this.disposeQueue)==null||s.call(this),this.textures}dispose(e={}){var i,a,r,s;if(this.updating){this.disposeQueue=()=>{this.dispose(e),this.disposeQueue=void 0};return}const{textures:t=!0}=e;t||(this.transmittanceRenderTarget.textures.splice(0,1),this.scatteringRenderTarget.textures.splice(0,1),this.irradianceRenderTarget.textures.splice(0,1),(i=this.singleMieScatteringRenderTarget)==null||i.textures.splice(0,1),(a=this.higherOrderScatteringRenderTarget)==null||a.textures.splice(0,1)),this.transmittanceRenderTarget.dispose(),this.scatteringRenderTarget.dispose(),this.irradianceRenderTarget.dispose(),(r=this.singleMieScatteringRenderTarget)==null||r.dispose(),(s=this.higherOrderScatteringRenderTarget)==null||s.dispose(),this.transmittanceMaterial.dispose(),this.directIrradianceMaterial.dispose(),this.singleScatteringMaterial.dispose(),this.scatteringDensityMaterial.dispose(),this.indirectIrradianceMaterial.dispose(),this.multipleScatteringMaterial.dispose(),this.mesh.geometry.dispose()}}function vie(n){var e=[];if(n.length===0)return"";if(typeof n[0]!="string")throw new TypeError("Url must be a string. Received "+n[0]);if(n[0].match(/^[^/:]+:\/*$/)&&n.length>1){var t=n.shift();n[0]=t+n[0]}n[0].match(/^file:\/\/\//)?n[0]=n[0].replace(/^([^/:]+):\/*/,"$1:///"):n[0]=n[0].replace(/^([^/:]+):\/*/,"$1://");for(var i=0;i<n.length;i++){var a=n[i];if(typeof a!="string")throw new TypeError("Url must be a string. Received "+a);a!==""&&(i>0&&(a=a.replace(/^[\/]+/,"")),i<n.length-1?a=a.replace(/[\/]+$/,""):a=a.replace(/[\/]+$/,"/"),e.push(a))}var r=e.join("/");r=r.replace(/\/(\?|&|#[^!])/g,"$1");var s=r.split("?");return r=s.shift()+(s.length>0?"?":"")+s.join("&"),r}function _ie(){var n;return typeof arguments[0]=="object"?n=arguments[0]:n=[].slice.call(arguments),vie(n)}const wO={width:Jd,height:$d},Tf={width:Uu,height:Pu,depth:zu},CO={width:Kd,height:Qd};class qP extends Ti{constructor({format:e="exr",type:t=Xn,combinedScattering:i=!0,higherOrderScattering:a=!0}={},r){super(r),this.format=e,this.type=t,this.combinedScattering=i,this.higherOrderScattering=a}setType(e){return this.type=tP(e)?ri:Xn,this}setTypeFromRenderer(e){return this.setType(e)}load(e,t,i,a){const r={},s=({key:o,loader:c,path:h})=>(c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(this.withCredentials),c.load(_ie(e,h),f=>{f.type=this.type,this.type===ri&&(f.image.data=new Float32Array(new ll(f.image.data.buffer))),f.minFilter=Ht,f.magFilter=Ht,r[`${o}Texture`]=f,r.irradianceTexture!=null&&r.scatteringTexture!=null&&r.transmittanceTexture!=null&&(this.combinedScattering||r.singleMieScatteringTexture!=null)&&(!this.higherOrderScattering||r.higherOrderScatteringTexture!=null)&&(t==null||t(r))},i,a));return this.format==="exr"?{transmittanceTexture:s({key:"transmittance",loader:new _O(wO,this.manager),path:"transmittance.exr"}),scatteringTexture:s({key:"scattering",loader:new Q2(Tf,this.manager),path:"scattering.exr"}),irradianceTexture:s({key:"irradiance",loader:new _O(CO,this.manager),path:"irradiance.exr"}),singleMieScatteringTexture:this.combinedScattering?void 0:s({key:"singleMieScattering",loader:new Q2(Tf,this.manager),path:"single_mie_scattering.exr"}),higherOrderScatteringTexture:this.higherOrderScattering?s({key:"higherOrderScattering",loader:new Q2(Tf,this.manager),path:"higher_order_scattering.exr"}):void 0}:{transmittanceTexture:s({key:"transmittance",loader:new xu(Ja,Jp,wO,this.manager),path:"transmittance.bin"}),scatteringTexture:s({key:"scattering",loader:new xu(is,Jp,Tf,this.manager),path:"scattering.bin"}),irradianceTexture:s({key:"irradiance",loader:new xu(Ja,Jp,CO,this.manager),path:"irradiance.bin"}),singleMieScatteringTexture:this.combinedScattering?void 0:s({key:"singleMieScattering",loader:new xu(is,Jp,Tf,this.manager),path:"single_mie_scattering.bin"}),higherOrderScatteringTexture:this.higherOrderScattering?s({key:"higherOrderScattering",loader:new xu(is,Jp,Tf,this.manager),path:"higher_order_scattering.bin"}):void 0}}}const xie=`precision highp float;
precision highp sampler3D;
#define RECIPROCAL_PI 0.3183098861837907
#include "core/raySphereIntersection"
#include "bruneton/definitions"
uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;
#include "bruneton/common"
#include "bruneton/runtime"
#include "sky"
uniform vec3 sunDirection;
uniform vec3 moonDirection;
uniform float moonAngularRadius;
uniform float lunarRadianceScale;
uniform vec3 groundAlbedo;
#ifdef HAS_SHADOW_LENGTH
uniform sampler2D shadowLengthBuffer;
#endif // HAS_SHADOW_LENGTH
in vec2 vUv;
in vec3 vCameraPosition;
in vec3 vRayDirection;
layout(location = 0) out vec4 outputColor;
#include <mrt_layout>
void main() {
float shadowLength = 0.0;
#ifdef HAS_SHADOW_LENGTH
shadowLength = texture(shadowLengthBuffer, vUv).r;
#endif // HAS_SHADOW_LENGTH
vec3 cameraPosition = vCameraPosition;
vec3 rayDirection = normalize(vRayDirection);
#ifdef GROUND_ALBEDO
float r = length(cameraPosition);
float mu = dot(cameraPosition, rayDirection) / r;
bool intersectsGround = RayIntersectsGround(ATMOSPHERE, r, mu);
if (intersectsGround) {
float distanceToGround = raySphereFirstIntersection(
cameraPosition,
rayDirection,
ATMOSPHERE.bottom_radius
);
vec3 groundPosition = rayDirection * distanceToGround + cameraPosition;
vec3 surfaceNormal = normalize(groundPosition);
vec3 skyIrradiance;
vec3 sunIrradiance = GetSunAndSkyIrradiance(
cameraPosition,
surfaceNormal,
sunDirection,
skyIrradiance
);
vec3 transmittance;
vec3 inscatter = GetSkyRadianceToPoint(
cameraPosition,
ATMOSPHERE.bottom_radius * surfaceNormal,
shadowLength,
sunDirection,
transmittance
);
vec3 radiance = groundAlbedo * RECIPROCAL_PI * (sunIrradiance + skyIrradiance);
outputColor.rgb = radiance * transmittance + inscatter;
} else {
outputColor.rgb = getSkyRadiance(
cameraPosition,
rayDirection,
shadowLength,
sunDirection,
moonDirection,
moonAngularRadius,
lunarRadianceScale
);
}
#else // GROUND_ALBEDO
outputColor.rgb = getSkyRadiance(
cameraPosition,
rayDirection,
shadowLength,
sunDirection,
moonDirection,
moonAngularRadius,
lunarRadianceScale
);
#endif // GROUND_ALBEDO
outputColor.a = 1.0;
#include <mrt_output>
}
`,yie=`precision highp float;
precision highp sampler3D;
uniform mat4 inverseProjectionMatrix;
uniform mat4 inverseViewMatrix;
uniform vec3 cameraPosition;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;
layout(location = 0) in vec3 position;
out vec2 vUv;
out vec3 vCameraPosition;
out vec3 vRayDirection;
void getCameraRay(out vec3 origin, out vec3 direction) {
bool isPerspective = inverseProjectionMatrix[2][3] != 0.0; // 4th entry in the 3rd column
if (isPerspective) {
// Calculate the camera ray for a perspective camera.
vec4 viewPosition = inverseProjectionMatrix * vec4(position, 1.0);
vec4 worldDirection = inverseViewMatrix * vec4(viewPosition.xyz, 0.0);
origin = cameraPosition;
direction = worldDirection.xyz;
} else {
// Unprojected points to calculate direction.
vec4 nearPoint = inverseProjectionMatrix * vec4(position.xy, -1.0, 1.0);
vec4 farPoint = inverseProjectionMatrix * vec4(position.xy, -0.9, 1.0);
nearPoint /= nearPoint.w;
farPoint /= farPoint.w;
// Calculate world values
vec4 worldDirection = inverseViewMatrix * vec4(farPoint.xyz - nearPoint.xyz, 0.0);
vec4 worldOrigin = inverseViewMatrix * nearPoint;
// Outputs
direction = worldDirection.xyz;
origin = worldOrigin.xyz;
}
}
void main() {
vUv = position.xy * 0.5 + 0.5;
vec3 direction, origin;
getCameraRay(origin, direction);
vec3 cameraPositionECEF = (worldToECEFMatrix * vec4(origin, 1.0)).xyz;
vCameraPosition = (cameraPositionECEF + altitudeCorrection) * METER_TO_LENGTH_UNIT;
vRayDirection = (worldToECEFMatrix * vec4(direction, 0.0)).xyz;
gl_Position = vec4(position.xy, 1.0, 1.0);
}
`;var Sie=Object.defineProperty,SA=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&Sie(e,t,a),a};const Tie={...vA,sun:!0,moon:!0,moonAngularRadius:.0045,lunarRadianceScale:1,ground:!0,groundAlbedo:new je(0)};class TA extends q0{constructor(e){const{sun:t,moon:i,moonDirection:a,moonAngularRadius:r,lunarRadianceScale:s,ground:o,groundAlbedo:c,...h}={...Tie,...e};super({name:"SkyMaterial",glslVersion:ao,vertexShader:yie,fragmentShader:Ca(xie,{core:{raySphereIntersection:fy},bruneton:{common:Zs,definitions:Ks,runtime:vy},sky:IP}),...h,uniforms:{inverseProjectionMatrix:new J(new ke),inverseViewMatrix:new J(new ke),moonDirection:new J((a==null?void 0:a.clone())??new L),moonAngularRadius:new J(r),lunarRadianceScale:new J(s),groundAlbedo:new J(c.clone()),shadowLengthBuffer:new J(null),...h.uniforms},defines:{PERSPECTIVE_CAMERA:"1"},depthTest:!0}),this.shadowLength=null,this.sun=t,this.moon=i,this.ground=o}onBeforeRender(e,t,i,a,r,s){super.onBeforeRender(e,t,i,a,r,s);const{uniforms:o,defines:c}=this;o.inverseProjectionMatrix.value.copy(i.projectionMatrixInverse),o.inverseViewMatrix.value.copy(i.matrixWorld);const h=c.PERSPECTIVE_CAMERA!=null,f=i.isPerspectiveCamera===!0;f!==h&&(f?c.PERSPECTIVE_CAMERA="1":delete c.PERSPECTIVE_CAMERA,this.needsUpdate=!0);const d=this.groundAlbedo,m=c.GROUND_ALBEDO!=null,g=d.r!==0||d.g!==0||d.b!==0;g!==m&&(g?this.defines.GROUND_ALBEDO="1":delete this.defines.GROUND_ALBEDO,this.needsUpdate=!0);const x=this.shadowLength,T=c.HAS_SHADOW_LENGTH!=null,S=x!=null;S!==T&&(S?c.HAS_SHADOW_LENGTH="1":(delete c.HAS_SHADOW_LENGTH,o.shadowLengthBuffer.value=null),this.needsUpdate=!0),S&&(o.shadowLengthBuffer.value=x.map)}get moonDirection(){return this.uniforms.moonDirection.value}get moonAngularRadius(){return this.uniforms.moonAngularRadius.value}set moonAngularRadius(e){this.uniforms.moonAngularRadius.value=e}get lunarRadianceScale(){return this.uniforms.lunarRadianceScale.value}set lunarRadianceScale(e){this.uniforms.lunarRadianceScale.value=e}get groundAlbedo(){return this.uniforms.groundAlbedo.value}}SA([dn("SUN")],TA.prototype,"sun");SA([dn("MOON")],TA.prototype,"moon");SA([dn("GROUND")],TA.prototype,"ground");const Eie=`precision highp float;
precision highp sampler3D;
#include "bruneton/definitions"
uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;
#include "bruneton/common"
#include "bruneton/runtime"
uniform vec3 sunDirection;
in vec3 vCameraPosition;
in vec3 vRayDirection;
layout(location = 0) out vec4 outputColor;
#include <mrt_layout>
in vec3 vColor;
void main() {
#if !defined(PERSPECTIVE_CAMERA)
outputColor = vec4(0.0);
discard; // Rendering celestial objects without perspective doesn't make sense.
#endif // !defined(PERSPECTIVE_CAMERA)
#ifdef BACKGROUND
vec3 rayDirection = normalize(vRayDirection);
float r = length(vCameraPosition);
float mu = dot(vCameraPosition, rayDirection) / r;
if (RayIntersectsGround(ATMOSPHERE, r, mu)) {
discard;
}
vec3 transmittance;
vec3 radiance = GetSkyRadiance(
vCameraPosition,
normalize(vRayDirection),
0.0, // Shadow length
sunDirection,
transmittance
);
radiance += transmittance * vColor;
outputColor = vec4(radiance, 1.0);
#else // BACKGROUND
outputColor = vec4(vColor, 1.0);
#endif // BACKGROUND
#include <mrt_output>
}
`,Mie=`precision highp float;
precision highp sampler3D;
#define saturate(x) clamp(x, 0.0, 1.0)
uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 viewMatrix;
uniform mat4 matrixWorld;
uniform vec3 cameraPosition;
uniform float cameraFar;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;
uniform float pointSize;
uniform vec2 magnitudeRange;
uniform float intensity;
layout(location = 0) in vec3 position;
layout(location = 1) in float magnitude;
layout(location = 2) in vec3 color;
out vec3 vCameraPosition;
out vec3 vRayDirection;
out vec3 vEllipsoidCenter;
out vec3 vColor;
void main() {
// Magnitude is stored between 0 to 1 within the given range.
float m = mix(magnitudeRange.x, magnitudeRange.y, magnitude);
vec3 v = pow(vec3(10.0), -vec3(magnitudeRange, m) / 2.5);
vColor = vec3(intensity * color);
vColor *= saturate((v.z - v.y) / (v.x - v.y));
#ifdef BACKGROUND
vec3 worldDirection = normalize(matrixWorld * vec4(position, 1.0)).xyz;
vec3 cameraPositionECEF = (worldToECEFMatrix * vec4(cameraPosition, 1.0)).xyz;
vCameraPosition = (cameraPositionECEF + altitudeCorrection) * METER_TO_LENGTH_UNIT;
vRayDirection = (worldToECEFMatrix * vec4(worldDirection, 0.0)).xyz;
gl_Position =
projectionMatrix * viewMatrix * vec4(cameraPosition + worldDirection * cameraFar, 1.0);
#else // BACKGROUND
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
#endif // BACKGROUND
gl_PointSize = pointSize;
}
`;var bie=Object.defineProperty,jP=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&bie(e,t,a),a};const Aie={...vA,pointSize:1,intensity:1,background:!0,ground:!0};let ZP=class extends q0{constructor(e){const{pointSize:t,radianceScale:i,intensity:a,background:r,ground:s,...o}={...Aie,...e};super({name:"StarsMaterial",glslVersion:ao,vertexShader:Mie,fragmentShader:Ca(Eie,{bruneton:{common:Zs,definitions:Ks,runtime:vy}}),...o,uniforms:{projectionMatrix:new J(new ke),modelViewMatrix:new J(new ke),viewMatrix:new J(new ke),matrixWorld:new J(new ke),cameraFar:new J(0),pointSize:new J(0),magnitudeRange:new J(new de(-2,8)),intensity:new J(i??a),...o.uniforms},defines:{PERSPECTIVE_CAMERA:"1"}}),this.pointSize=t,this.background=r,this.ground=s}onBeforeRender(e,t,i,a,r,s){super.onBeforeRender(e,t,i,a,r,s);const o=this.uniforms;o.projectionMatrix.value.copy(i.projectionMatrix),o.modelViewMatrix.value.copy(i.modelViewMatrix),o.viewMatrix.value.copy(i.matrixWorldInverse),o.matrixWorld.value.copy(r.matrixWorld),o.cameraFar.value=i.far,o.pointSize.value=this.pointSize*e.getPixelRatio();const c=i.isPerspectiveCamera===!0;this.defines.PERSPECTIVE_CAMERA!=null!==c&&(c?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}get magnitudeRange(){return this.uniforms.magnitudeRange.value}get radianceScale(){return this.intensity}set radianceScale(e){this.intensity=e}get intensity(){return this.uniforms.intensity.value}set intensity(e){this.uniforms.intensity.value=e}};jP([dn("BACKGROUND")],ZP.prototype,"background");jP([dn("GROUND")],ZP.prototype,"ground");const EA=be.createContext({}),Rie=({ref:n,textures:e,ellipsoid:t=g0.WGS84,correctAltitude:i=!0,ground:a=!0,date:r,children:s})=>{const o=be.useRef({sunDirection:new L,moonDirection:new L,worldToECEFMatrix:new ke,inertialToECEFMatrix:new ke,overlay:null,shadow:null,shadowLength:null,lightingMask:null}),c=Qi(({gl:T})=>T),h=be.useMemo(()=>typeof e=="string"?new qP().setType(c).load(e):void 0,[e,c]);be.useEffect(()=>{if(h!=null)return()=>{for(const T of Object.values(h))T==null||T.dispose()}},[h]);const f=be.useMemo(()=>e==null?new gie(c):void 0,[e,c]);be.useEffect(()=>{if(f!=null)return f.update().catch(T=>{console.error(T)}),()=>{f.dispose()}},[f]);const d=(f==null?void 0:f.textures)??(typeof e=="string"?h:e),m=be.useMemo(()=>({textures:d,ellipsoid:t,correctAltitude:i,ground:a,transientStates:o.current}),[d,t,i,a]),g=be.useMemo(()=>{const{sunDirection:T,moonDirection:S,inertialToECEFMatrix:v}=o.current;return y=>{aie(y,v),rie(y,T).applyMatrix4(v),sie(y,S).applyMatrix4(v)}},[]),x=r!=null&&!isNaN(+r)?+r:void 0;return be.useEffect(()=>{x!=null&&g(x)},[x,g]),be.useImperativeHandle(n,()=>({...o.current,textures:d,updateByDate:g}),[d,g]),Nt.jsx(EA.Provider,{value:m,children:s})};function KP(n){const{irradianceTexture:e,scatteringTexture:t,transmittanceTexture:i,singleMieScatteringTexture:a,higherOrderScatteringTexture:r,ellipsoid:s,correctAltitude:o,sunDirection:c,sunAngularRadius:h,ground:f,renderTargetCount:d,...m}=n;return[{irradianceTexture:e,scatteringTexture:t,transmittanceTexture:i,singleMieScatteringTexture:a,higherOrderScatteringTexture:r,ellipsoid:s,correctAltitude:o,sunDirection:c,sunAngularRadius:h,ground:f,renderTargetCount:d},m]}function wie(n){const e=be.useMemo(()=>typeof n=="string"?new wP().load(n):void 0,[n]);return be.useEffect(()=>{if(e!=null)return()=>{e.dispose()}},[e]),(typeof n=="string"?e:n)??null}const Cie=({ref:n,stbnTexture:e=nP,...t})=>{const{textures:i,transientStates:a,...r}=be.useContext(EA),[s,{blendFunction:o,...c}]=KP({...UP,...r,...i,...t}),h=be.useContext(rA),{normalPass:f,camera:d}=h,m="geometryPass"in h&&h.geometryPass instanceof aA&&"geometryTexture"in h.geometryPass&&h.geometryPass.geometryTexture instanceof Nn?h.geometryPass.geometryTexture:void 0,g=be.useMemo(()=>new za(void 0,{blendFunction:o}),[o]);be.useEffect(()=>()=>{g.dispose()},[g]);const[x,T]=be.useState(!1);Ac(()=>{a!=null&&(g.sunDirection.copy(a.sunDirection),g.moonDirection.copy(a.moonDirection),g.worldToECEFMatrix.copy(a.worldToECEFMatrix),g.overlay=a.overlay,g.shadow=a.shadow,g.shadowLength=a.shadowLength,g.lightingMask=a.lightingMask,!x&&g.shadow!=null&&T(!0))});const S=wie(x?e:void 0);return Nt.jsx("primitive",{ref:n,object:g,mainCamera:d,normalBuffer:m??(f==null?void 0:f.texture)??null,...s,...c,stbnTexture:S,octEncodedNormal:m!=null})};function Nie(n){return e=>{for(const t of n)tM(t,e)}}function Die(n){return e=>{const t=[];for(const i of n){const a=tM(i,e),r=typeof a=="function";t.push(r?a:()=>tM(i,null))}return()=>{for(const i of t)i()}}}function tM(n,e){if(typeof n=="function")return n(e);n&&(n.current=e)}parseInt(be.version.split(".")[0],10)>=19;new qP;const NO=vy,DO=Zs,OO=Ks;class _y{constructor(e=0,t=0,i=0,a=0){this.expTerm=e,this.exponent=t,this.linearTerm=i,this.constantTerm=a}set(e=0,t=0,i=0,a=0){return this.expTerm=e,this.exponent=t,this.linearTerm=i,this.constantTerm=a,this}clone(){return new _y(this.expTerm,this.exponent,this.linearTerm,this.constantTerm)}copy(e){return this.expTerm=e.expTerm,this.exponent=e.exponent,this.linearTerm=e.linearTerm,this.constantTerm=e.constantTerm,this}}const Oie=["channel","altitude","height","densityScale","shapeAmount","shapeDetailAmount","weatherExponent","shapeAlteringBias","coverageFilterWidth","shadow","densityProfile"];function Lie(n,e){if(e!=null)for(const t of Oie){const i=e[t];i!=null&&(n[t]instanceof _y?n[t].copy(i):n[t]=i)}}const nM=class QP{constructor(e){this.channel="r",this.altitude=0,this.height=0,this.densityScale=.2,this.shapeAmount=1,this.shapeDetailAmount=1,this.weatherExponent=1,this.shapeAlteringBias=.35,this.coverageFilterWidth=.6,this.densityProfile=new _y(0,0,.75,.25),this.shadow=!1,this.set(e)}set(e){return Lie(this,e),this}clone(){return new QP(this)}copy(e){return this.channel=e.channel,this.altitude=e.altitude,this.height=e.height,this.densityScale=e.densityScale,this.shapeAmount=e.shapeAmount,this.shapeDetailAmount=e.shapeDetailAmount,this.weatherExponent=e.weatherExponent,this.shapeAlteringBias=e.shapeAlteringBias,this.coverageFilterWidth=e.coverageFilterWidth,this.densityProfile.copy(e.densityProfile),this.shadow=e.shadow,this}};nM.DEFAULT=new nM;let Ts=nM;const Ef=Array.from({length:8},()=>({value:0,flag:0})),em=Array.from({length:3},()=>({min:0,max:0}));function Iie(n,e){return n.value!==e.value?n.value-e.value:n.flag-e.flag}const iM=class JP extends Array{constructor(e){super(new Ts(e==null?void 0:e[0]),new Ts(e==null?void 0:e[1]),new Ts(e==null?void 0:e[2]),new Ts(e==null?void 0:e[3]))}set(e){return this[0].set(e==null?void 0:e[0]),this[1].set(e==null?void 0:e[1]),this[2].set(e==null?void 0:e[2]),this[3].set(e==null?void 0:e[3]),this}reset(){return this[0].copy(Ts.DEFAULT),this[1].copy(Ts.DEFAULT),this[2].copy(Ts.DEFAULT),this[3].copy(Ts.DEFAULT),this}clone(){return new JP(this)}copy(e){return this[0].copy(e[0]),this[1].copy(e[1]),this[2].copy(e[2]),this[3].copy(e[3]),this}get localWeatherChannels(){return this[0].channel+this[1].channel+this[2].channel+this[3].channel}packValues(e,t){return t.set(this[0][e],this[1][e],this[2][e],this[3][e])}packSums(e,t,i){return i.set(this[0][e]+this[0][t],this[1][e]+this[1][t],this[2][e]+this[2][t],this[3][e]+this[3][t])}packDensityProfiles(e,t){return t.set(this[0].densityProfile[e],this[1].densityProfile[e],this[2].densityProfile[e],this[3].densityProfile[e])}packIntervalHeights(e,t){for(let s=0;s<4;++s){const o=this[s];let c=Ef[s];c.value=o.altitude,c.flag=0,c=Ef[s+4],c.value=o.altitude+o.height,c.flag=1}Ef.sort(Iie);let i=0,a=0;for(let s=0;s<Ef.length;++s){const{value:o,flag:c}=Ef[s];if(a===0&&s>0){const h=em[i++];h.min=Ef[s-1].value,h.max=o}a+=c===0?1:-1}for(;i<3;++i){const s=em[i];s.min=0,s.max=0}let r=em[0];e.x=r.min,t.x=r.max,r=em[1],e.y=r.min,t.y=r.max,r=em[2],e.z=r.min,t.z=r.max}};iM.DEFAULT=new iM([{channel:"r",altitude:750,height:650,densityScale:.2,shapeAmount:1,shapeDetailAmount:1,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.6,shadow:!0},{channel:"g",altitude:1e3,height:1200,densityScale:.2,shapeAmount:1,shapeDetailAmount:1,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.6,shadow:!0},{channel:"b",altitude:7500,height:500,densityScale:.003,shapeAmount:.4,shapeDetailAmount:0,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.5},{channel:"a"}]);let a1=iM;var Uie="Invariant failed";function Ql(n,e){if(!n)throw new Error(Uie)}class v0{constructor(e,t){this.near=[new L,new L,new L,new L],this.far=[new L,new L,new L,new L],e!=null&&t!=null&&this.setFromCamera(e,t)}clone(){return new v0().copy(this)}copy(e){for(let t=0;t<4;++t)this.near[t].copy(e.near[t]),this.far[t].copy(e.far[t]);return this}setFromCamera(e,t){const i=e.isOrthographicCamera===!0,a=e.projectionMatrixInverse;this.near[0].set(1,1,-1),this.near[1].set(1,-1,-1),this.near[2].set(-1,-1,-1),this.near[3].set(-1,1,-1);for(let r=0;r<4;++r)this.near[r].applyMatrix4(a);this.far[0].set(1,1,1),this.far[1].set(1,-1,1),this.far[2].set(-1,-1,1),this.far[3].set(-1,1,1);for(let r=0;r<4;++r){const s=this.far[r];s.applyMatrix4(a);const o=Math.abs(s.z);i?s.z*=Math.min(t/o,1):s.multiplyScalar(Math.min(t/o,1))}return this}split(e,t=[]){for(let i=0;i<e.length;++i){const a=t[i]??(t[i]=new v0);if(i===0)for(let r=0;r<4;++r)a.near[r].copy(this.near[r]);else for(let r=0;r<4;++r)a.near[r].lerpVectors(this.near[r],this.far[r],e[i-1]);if(i===e.length-1)for(let r=0;r<4;++r)a.far[r].copy(this.far[r]);else for(let r=0;r<4;++r)a.far[r].lerpVectors(this.near[r],this.far[r],e[i])}return t.length=e.length,t}applyMatrix4(e){for(let t=0;t<4;++t)this.near[t].applyMatrix4(e),this.far[t].applyMatrix4(e);return this}}const Pie={uniform:(n,e,t,i,a=[])=>{for(let r=0;r<n;++r)a[r]=(e+(t-e)*(r+1)/n)/t;return a.length=n,a},logarithmic:(n,e,t,i,a=[])=>{for(let r=0;r<n;++r)a[r]=e*(t/e)**((r+1)/n)/t;return a.length=n,a},practical:(n,e,t,i=.5,a=[])=>{for(let r=0;r<n;++r){const s=(e+(t-e)*(r+1)/n)/t,o=e*(t/e)**((r+1)/n)/t;a[r]=bP(s,o,i)}return a.length=n,a}};function zie(n,e,t,i,a,r=[]){return Pie[n](e,t,i,a,r)}const LO=new L,IO=new L,Bie=new ke,UO=new ke,Hie=new v0,Fie=new ea,Gie={maxFar:null,farScale:1,splitMode:"practical",splitLambda:.5,margin:0,fade:!0};class Vie{constructor(e){this.cascades=[],this.mapSize=new de,this.cameraFrustum=new v0,this.frusta=[],this.splits=[],this._far=0;const{cascadeCount:t,mapSize:i,maxFar:a,farScale:r,splitMode:s,splitLambda:o,margin:c,fade:h}={...Gie,...e};this.cascadeCount=t,this.mapSize.copy(i),this.maxFar=a,this.farScale=r,this.splitMode=s,this.splitLambda=o,this.margin=c,this.fade=h}get cascadeCount(){return this.cascades.length}set cascadeCount(e){var t;if(e!==this.cascadeCount){for(let i=0;i<e;++i)(t=this.cascades)[i]??(t[i]={interval:new de,matrix:new ke,inverseMatrix:new ke,projectionMatrix:new ke,inverseProjectionMatrix:new ke,viewMatrix:new ke,inverseViewMatrix:new ke});this.cascades.length=e}}get far(){return this._far}updateIntervals(e){const t=this.cascadeCount,i=this.splits,a=this.far;zie(this.splitMode,t,e.near,a,this.splitLambda,i),this.cameraFrustum.setFromCamera(e,a),this.cameraFrustum.split(i,this.frusta);const r=this.cascades;for(let s=0;s<t;++s)r[s].interval.set(i[s-1]??0,i[s]??0)}getFrustumRadius(e,t){const i=t.near,a=t.far;let r=Math.max(a[0].distanceTo(a[2]),a[0].distanceTo(i[2]));if(this.fade){const s=e.near,o=this.far,c=a[0].z/(o-s);r+=.25*c**2*(o-s)}return r*.5}updateMatrices(e,t,i=1){const a=Bie.lookAt(LO.setScalar(0),IO.copy(t).multiplyScalar(-1),Zt.DEFAULT_UP),r=UO.multiplyMatrices(UO.copy(a).invert(),e.matrixWorld),s=this.frusta,o=this.cascades;Ql(s.length===o.length);const c=this.margin,h=this.mapSize;for(let f=0;f<s.length;++f){const d=s[f],m=o[f],g=this.getFrustumRadius(e,s[f]),x=-g,T=g,S=g,v=-g;m.projectionMatrix.makeOrthographic(x,T,S,v,-this.margin,g*2+this.margin);const{near:y,far:E}=Hie.copy(d).applyMatrix4(r),b=Fie.makeEmpty();for(let O=0;O<4;O++)b.expandByPoint(y[O]),b.expandByPoint(E[O]);const D=b.getCenter(LO);D.z=b.max.z+c;const C=(T-x)/h.width,I=(S-v)/h.height;D.x=Math.round(D.x/C)*C,D.y=Math.round(D.y/I)*I,D.applyMatrix4(a);const P=IO.copy(t).multiplyScalar(i).add(D);m.inverseViewMatrix.lookAt(D,P,Zt.DEFAULT_UP).setPosition(P)}}update(e,t,i){this._far=this.maxFar!=null?Math.min(this.maxFar,e.far*this.farScale):e.far*this.farScale,this.updateIntervals(e),this.updateMatrices(e,t,i);const a=this.cascades,r=this.cascadeCount;for(let s=0;s<r;++s){const{matrix:o,inverseMatrix:c,projectionMatrix:h,inverseProjectionMatrix:f,viewMatrix:d,inverseViewMatrix:m}=a[s];f.copy(h).invert(),d.copy(m).invert(),o.copy(h).multiply(d),c.copy(m).multiply(f)}}}const PO=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5],$P=PO.reduce((n,e,t)=>{const i=new de;for(let a=0;a<16;++a)if(PO[a]===t){i.set((a%4+.5)/4,(Math.floor(a/4)+.5)/4);break}return[...n,i]},[]),kie={resolutionScale:1,lightShafts:!0,shapeDetail:!0,turbulence:!0,haze:!0,clouds:{multiScatteringOctaves:8,accurateSunSkyLight:!0,accuratePhaseFunction:!1,maxIterationCount:500,minStepSize:50,maxStepSize:1e3,maxRayDistance:2e5,perspectiveStepScale:1.01,minDensity:1e-5,minExtinction:1e-5,minTransmittance:.01,maxIterationCountToGround:3,maxIterationCountToSun:2,minSecondaryStepSize:100,secondaryStepScale:2,maxShadowLengthIterationCount:500,minShadowLengthStepSize:50,maxShadowLengthRayDistance:2e5},shadow:{cascadeCount:3,mapSize:new de(512,512),maxIterationCount:50,minStepSize:100,maxStepSize:1e3,minDensity:1e-5,minExtinction:1e-5,minTransmittance:1e-4}},It=kie,Wie={low:{...It,lightShafts:!1,shapeDetail:!1,turbulence:!1,clouds:{...It.clouds,accurateSunSkyLight:!1,maxIterationCount:200,minStepSize:100,maxRayDistance:1e5,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.1,maxIterationCountToGround:0,maxIterationCountToSun:1},shadow:{...It.shadow,maxIterationCount:25,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.01,cascadeCount:2,mapSize:new de(256,256)}},medium:{...It,lightShafts:!1,turbulence:!1,clouds:{...It.clouds,minDensity:1e-4,minExtinction:1e-4,accurateSunSkyLight:!1,maxIterationCountToSun:2,maxIterationCountToGround:1},shadow:{...It.shadow,minDensity:1e-4,minExtinction:1e-4,mapSize:new de(256,256)}},high:It,ultra:{...It,clouds:{...It.clouds,minStepSize:10},shadow:{...It.shadow,mapSize:new de(1024,1024)}}},Xie=`precision highp float;
precision highp sampler3D;
precision highp sampler2DArray;
#include <common>
#include <packing>
#include "core/depth"
#include "core/math"
#include "core/turbo"
#include "core/generators"
#include "core/raySphereIntersection"
#include "core/cascadedShadowMaps"
#include "core/interleavedGradientNoise"
#include "core/vogelDisk"
#include "atmosphere/bruneton/definitions"
uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;
#include "atmosphere/bruneton/common"
#include "atmosphere/bruneton/runtime"
#include "types"
#include "parameters"
#include "clouds"
#if !defined(RECIPROCAL_PI4)
#define RECIPROCAL_PI4 0.07957747154594767
#endif // !defined(RECIPROCAL_PI4)
uniform sampler2D depthBuffer;
uniform mat4 viewMatrix;
uniform mat4 reprojectionMatrix;
uniform mat4 viewReprojectionMatrix;
uniform float cameraNear;
uniform float cameraFar;
uniform float cameraHeight;
uniform vec2 temporalJitter;
uniform vec2 targetUvScale;
uniform float mipLevelScale;
// Scattering
const vec2 scatterAnisotropy = vec2(SCATTER_ANISOTROPY_1, SCATTER_ANISOTROPY_2);
const float scatterAnisotropyMix = SCATTER_ANISOTROPY_MIX;
uniform float skyLightScale;
uniform float groundBounceScale;
uniform float powderScale;
uniform float powderExponent;
// Primary raymarch
uniform int maxIterationCount;
uniform float minStepSize;
uniform float maxStepSize;
uniform float maxRayDistance;
uniform float perspectiveStepScale;
// Secondary raymarch
uniform int maxIterationCountToSun;
uniform int maxIterationCountToGround;
uniform float minSecondaryStepSize;
uniform float secondaryStepScale;
// Beer shadow map
uniform sampler2DArray shadowBuffer;
uniform vec2 shadowTexelSize;
uniform vec2 shadowIntervals[SHADOW_CASCADE_COUNT];
uniform mat4 shadowMatrices[SHADOW_CASCADE_COUNT];
uniform float shadowFar;
uniform float maxShadowFilterRadius;
// Shadow length
#ifdef SHADOW_LENGTH
uniform int maxShadowLengthIterationCount;
uniform float minShadowLengthStepSize;
uniform float maxShadowLengthRayDistance;
#endif // SHADOW_LENGTH
in vec2 vUv;
in vec3 vCameraPosition;
in vec3 vCameraDirection; // Direction to the center of screen
in vec3 vRayDirection; // Direction to the texel
in vec3 vViewPosition;
in GroundIrradiance vGroundIrradiance;
in CloudsIrradiance vCloudsIrradiance;
layout(location = 0) out vec4 outputColor;
layout(location = 1) out vec3 outputDepthVelocity;
#ifdef SHADOW_LENGTH
layout(location = 2) out float outputShadowLength;
#endif // SHADOW_LENGTH
float readDepth(const vec2 uv) {
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture(depthBuffer, uv));
#else // DEPTH_PACKING == 3201
return texture(depthBuffer, uv).r;
#endif // DEPTH_PACKING == 3201
}
float getViewZ(const float depth) {
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
#else // PERSPECTIVE_CAMERA
return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
#endif // PERSPECTIVE_CAMERA
}
vec3 ecefToWorld(const vec3 positionECEF) {
return (ecefToWorldMatrix * vec4(positionECEF - altitudeCorrection, 1.0)).xyz;
}
vec2 getShadowUv(const vec3 worldPosition, const int cascadeIndex) {
vec4 clip = shadowMatrices[cascadeIndex] * vec4(worldPosition, 1.0);
clip /= clip.w;
return clip.xy * 0.5 + 0.5;
}
float getDistanceToShadowTop(const vec3 rayPosition) {
// Distance to the top of the shadows along the sun direction, which matches
// the ray origin of BSM.
return raySphereSecondIntersection(
rayPosition,
sunDirection,
vec3(0.0),
bottomRadius + shadowTopHeight
);
}
#ifdef DEBUG_SHOW_CASCADES
const vec3 cascadeColors[4] = vec3[4](
vec3(1.0, 0.0, 0.0),
vec3(0.0, 1.0, 0.0),
vec3(0.0, 0.0, 1.0),
vec3(1.0, 1.0, 0.0)
);
vec3 getCascadeColor(const vec3 rayPosition) {
vec3 worldPosition = ecefToWorld(rayPosition);
int cascadeIndex = getCascadeIndex(
viewMatrix,
worldPosition,
shadowIntervals,
cameraNear,
shadowFar
);
vec2 uv = getShadowUv(worldPosition, cascadeIndex);
if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
return vec3(1.0);
}
return cascadeColors[cascadeIndex];
}
vec3 getFadedCascadeColor(const vec3 rayPosition, const float jitter) {
vec3 worldPosition = ecefToWorld(rayPosition);
int cascadeIndex = getFadedCascadeIndex(
viewMatrix,
worldPosition,
shadowIntervals,
cameraNear,
shadowFar,
jitter
);
return cascadeIndex >= 0
? cascadeColors[cascadeIndex]
: vec3(1.0);
}
#endif // DEBUG_SHOW_CASCADES
float readShadowOpticalDepth(
const vec2 uv,
const float distanceToTop,
const float distanceOffset,
const int cascadeIndex
) {
// r: frontDepth, g: meanExtinction, b: maxOpticalDepth, a: maxOpticalDepthTail
// Also see the discussion here: https://x.com/shotamatsuda/status/1885322308908442106
vec4 shadow = texture(shadowBuffer, vec3(uv, float(cascadeIndex)));
float distanceToFront = max(0.0, distanceToTop - distanceOffset - shadow.r);
return min(shadow.b + shadow.a, shadow.g * distanceToFront);
}
float sampleShadowOpticalDepthPCF(
const vec3 worldPosition,
const float distanceToTop,
const float distanceOffset,
const float radius,
const int cascadeIndex
) {
vec2 uv = getShadowUv(worldPosition, cascadeIndex);
if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
return 0.0;
}
if (radius < 0.1) {
return readShadowOpticalDepth(uv, distanceToTop, distanceOffset, cascadeIndex);
}
float sum = 0.0;
vec2 offset;
#pragma unroll_loop_start
for (int i = 0; i < 16; ++i) {
#if UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
offset = vogelDisk(
UNROLLED_LOOP_INDEX,
SHADOW_SAMPLE_COUNT,
interleavedGradientNoise(gl_FragCoord.xy + temporalJitter * resolution) * PI2
);
sum += readShadowOpticalDepth(
uv + offset * radius * shadowTexelSize,
distanceToTop,
distanceOffset,
cascadeIndex
);
#endif // UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
}
#pragma unroll_loop_end
return sum / float(SHADOW_SAMPLE_COUNT);
}
float sampleShadowOpticalDepth(
const vec3 rayPosition,
const float distanceOffset,
const float radius,
const float jitter
) {
float distanceToTop = getDistanceToShadowTop(rayPosition);
if (distanceToTop <= 0.0) {
return 0.0;
}
vec3 worldPosition = ecefToWorld(rayPosition);
int cascadeIndex = getFadedCascadeIndex(
viewMatrix,
worldPosition,
shadowIntervals,
cameraNear,
shadowFar,
jitter
);
return cascadeIndex >= 0
? sampleShadowOpticalDepthPCF(
worldPosition,
distanceToTop,
distanceOffset,
radius,
cascadeIndex
)
: 0.0;
}
#ifdef DEBUG_SHOW_SHADOW_MAP
vec4 getCascadedShadowMaps(vec2 uv) {
vec4 coord = vec4(vUv, vUv - 0.5) * 2.0;
vec4 shadow = vec4(0.0);
if (uv.y > 0.5) {
if (uv.x < 0.5) {
shadow = texture(shadowBuffer, vec3(coord.xw, 0.0));
} else {
#if SHADOW_CASCADE_COUNT > 1
shadow = texture(shadowBuffer, vec3(coord.zw, 1.0));
#endif // SHADOW_CASCADE_COUNT > 1
}
} else {
if (uv.x < 0.5) {
#if SHADOW_CASCADE_COUNT > 2
shadow = texture(shadowBuffer, vec3(coord.xy, 2.0));
#endif // SHADOW_CASCADE_COUNT > 2
} else {
#if SHADOW_CASCADE_COUNT > 3
shadow = texture(shadowBuffer, vec3(coord.zy, 3.0));
#endif // SHADOW_CASCADE_COUNT > 3
}
}
#if !defined(DEBUG_SHOW_SHADOW_MAP_TYPE)
#define DEBUG_SHOW_SHADOW_MAP_TYPE 0
#endif // !defined(DEBUG_SHOW_SHADOW_MAP_TYPE
const float frontDepthScale = 1e-5;
const float meanExtinctionScale = 10.0;
const float maxOpticalDepthScale = 0.01;
vec3 color;
#if DEBUG_SHOW_SHADOW_MAP_TYPE == 1
color = vec3(shadow.r * frontDepthScale);
#elif DEBUG_SHOW_SHADOW_MAP_TYPE == 2
color = vec3(shadow.g * meanExtinctionScale);
#elif DEBUG_SHOW_SHADOW_MAP_TYPE == 3
color = vec3((shadow.b + shadow.a) * maxOpticalDepthScale);
#else // DEBUG_SHOW_SHADOW_MAP_TYPE
color =
(shadow.rgb + vec3(0.0, 0.0, shadow.a)) *
vec3(frontDepthScale, meanExtinctionScale, maxOpticalDepthScale);
#endif // DEBUG_SHOW_SHADOW_MAP_TYPE
return vec4(color, 1.0);
}
#endif // DEBUG_SHOW_SHADOW_MAP
vec2 henyeyGreenstein(const vec2 g, const float cosTheta) {
vec2 g2 = g * g;
// prettier-ignore
return RECIPROCAL_PI4 *
((1.0 - g2) / max(vec2(1e-7), pow(1.0 + g2 - 2.0 * g * cosTheta, vec2(1.5))));
}
#ifdef ACCURATE_PHASE_FUNCTION
float draine(float u, float g, float a) {
float g2 = g * g;
// prettier-ignore
return (1.0 - g2) *
(1.0 + a * u * u) /
(4.0 * (1.0 + a * (1.0 + 2.0 * g2) / 3.0) * PI * pow(1.0 + g2 - 2.0 * g * u, 1.5));
}
// Numerically-fitted large particles (d=10) phase function It won't be
// plausible without a more precise multiple scattering.
// Reference: https://research.nvidia.com/labs/rtr/approximate-mie/
float phaseFunction(const float cosTheta, const float attenuation) {
const float gHG = 0.988176691700256; // exp(-0.0990567/(d-1.67154))
const float gD = 0.5556712547839497; // exp(-2.20679/(d+3.91029) - 0.428934)
const float alpha = 21.995520856274638; // exp(3.62489 - 8.29288/(d+5.52825))
const float weight = 0.4819554318404214; // exp(-0.599085/(d-0.641583)-0.665888)
return mix(
henyeyGreenstein(vec2(gHG) * attenuation, cosTheta).x,
draine(cosTheta, gD * attenuation, alpha),
weight
);
}
#else // ACCURATE_PHASE_FUNCTION
float phaseFunction(const float cosTheta, const float attenuation) {
const vec2 g = scatterAnisotropy;
const vec2 weights = vec2(1.0 - scatterAnisotropyMix, scatterAnisotropyMix);
// A similar approximation is described in the Frostbite's paper, where phase
// angle is attenuated instead of anisotropy.
return dot(henyeyGreenstein(g * attenuation, cosTheta), weights);
}
#endif // ACCURATE_PHASE_FUNCTION
float phaseFunction(const float cosTheta) {
return phaseFunction(cosTheta, 1.0);
}
float marchOpticalDepth(
const vec3 rayOrigin,
const vec3 rayDirection,
const int maxIterationCount,
const float mipLevel,
const float jitter,
out float rayDistance
) {
int iterationCount = int(
max(0.0, remap(mipLevel, 0.0, 1.0, float(maxIterationCount + 1), 1.0) - jitter)
);
if (iterationCount == 0) {
// Fudge factor to approximate the mean optical depth.
// TODO: Remove it.
return 0.5;
}
float stepSize = minSecondaryStepSize / float(iterationCount);
float nextDistance = stepSize * jitter;
float opticalDepth = 0.0;
for (int i = 0; i < iterationCount; ++i) {
rayDistance = nextDistance;
vec3 position = rayDistance * rayDirection + rayOrigin;
vec2 uv = getGlobeUv(position);
float height = length(position) - bottomRadius;
WeatherSample weather = sampleWeather(uv, height, mipLevel);
MediaSample media = sampleMedia(weather, position, uv, mipLevel, jitter);
opticalDepth += media.extinction * stepSize;
nextDistance += stepSize;
stepSize *= secondaryStepScale;
}
return opticalDepth;
}
float marchOpticalDepth(
const vec3 rayOrigin,
const vec3 rayDirection,
const int maxIterationCount,
const float mipLevel,
const float jitter
) {
float rayDistance;
return marchOpticalDepth(
rayOrigin,
rayDirection,
maxIterationCount,
mipLevel,
jitter,
rayDistance
);
}
float approximateMultipleScattering(const float opticalDepth, const float cosTheta) {
// Multiple scattering approximation
// See: https://fpsunflower.github.io/ckulla/data/oz_volumes.pdf
// a: attenuation, b: contribution, c: phase attenuation
vec3 coeffs = vec3(1.0); // [a, b, c]
const vec3 attenuation = vec3(0.5, 0.5, 0.5); // Should satisfy a <= b
float scattering = 0.0;
float beerLambert;
#pragma unroll_loop_start
for (int i = 0; i < 12; ++i) {
#if UNROLLED_LOOP_INDEX < MULTI_SCATTERING_OCTAVES
beerLambert = exp(-opticalDepth * coeffs.y);
scattering += coeffs.x * beerLambert * phaseFunction(cosTheta, coeffs.z);
coeffs *= attenuation;
#endif // UNROLLED_LOOP_INDEX < MULTI_SCATTERING_OCTAVES
}
#pragma unroll_loop_end
return scattering;
}
// TODO: Construct spherical harmonics of degree 2 using 2 sample points
// positioned near the horizon occlusion points on the sun direction plane.
vec3 getGroundSunSkyIrradiance(
const vec3 position,
const vec3 surfaceNormal,
const float height,
out vec3 skyIrradiance
) {
#ifdef ACCURATE_SUN_SKY_LIGHT
return GetSunAndSkyIrradiance(
(position - surfaceNormal * height) * METER_TO_LENGTH_UNIT,
surfaceNormal,
sunDirection,
skyIrradiance
);
#else // ACCURATE_SUN_SKY_LIGHT
skyIrradiance = vGroundIrradiance.sky;
return vGroundIrradiance.sun;
#endif // ACCURATE_SUN_SKY_LIGHT
}
vec3 getCloudsSunSkyIrradiance(const vec3 position, const float height, out vec3 skyIrradiance) {
#ifdef ACCURATE_SUN_SKY_LIGHT
return GetSunAndSkyScalarIrradiance(position * METER_TO_LENGTH_UNIT, sunDirection, skyIrradiance);
#else // ACCURATE_SUN_SKY_LIGHT
float alpha = remapClamped(height, minHeight, maxHeight);
skyIrradiance = mix(vCloudsIrradiance.minSky, vCloudsIrradiance.maxSky, alpha);
return mix(vCloudsIrradiance.minSun, vCloudsIrradiance.maxSun, alpha);
#endif // ACCURATE_SUN_SKY_LIGHT
}
#ifdef GROUND_BOUNCE
vec3 approximateRadianceFromGround(
const vec3 position,
const vec3 surfaceNormal,
const float height,
const float mipLevel,
const float jitter
) {
float opticalDepthToGround = marchOpticalDepth(
position,
-surfaceNormal,
maxIterationCountToGround,
mipLevel,
jitter
);
vec3 skyIrradiance;
vec3 sunIrradiance = getGroundSunSkyIrradiance(position, surfaceNormal, height, skyIrradiance);
const float groundAlbedo = 0.3;
vec3 groundIrradiance = skyIrradiance + (1.0 - coverage) * sunIrradiance;
vec3 bouncedRadiance = groundAlbedo * RECIPROCAL_PI * groundIrradiance;
return bouncedRadiance * exp(-opticalDepthToGround);
}
#endif // GROUND_BOUNCE
vec4 marchClouds(
const vec3 rayOrigin,
const vec3 rayDirection,
const vec2 rayNearFar,
const float cosTheta,
const float jitter,
const float rayStartTexelsPerPixel,
out float frontDepth,
out ivec3 sampleCount
) {
vec3 radianceIntegral = vec3(0.0);
float transmittanceIntegral = 1.0;
float weightedDistanceSum = 0.0;
float transmittanceSum = 0.0;
float maxRayDistance = rayNearFar.y - rayNearFar.x;
float stepSize = minStepSize + (perspectiveStepScale - 1.0) * rayNearFar.x;
// I don't understand why spatial aliasing remains unless doubling the jitter.
float rayDistance = stepSize * jitter * 2.0;
for (int i = 0; i < maxIterationCount; ++i) {
if (rayDistance > maxRayDistance) {
break; // Termination
}
vec3 position = rayDistance * rayDirection + rayOrigin;
float height = length(position) - bottomRadius;
float mipLevel = log2(max(1.0, rayStartTexelsPerPixel + rayDistance * 1e-5));
#if !defined(DEBUG_MARCH_INTERVALS)
if (insideLayerIntervals(height)) {
stepSize *= perspectiveStepScale;
rayDistance += mix(stepSize, maxStepSize, min(1.0, mipLevel));
continue;
}
#endif // !defined(DEBUG_MARCH_INTERVALS)
// Sample rough weather.
vec2 uv = getGlobeUv(position);
WeatherSample weather = sampleWeather(uv, height, mipLevel);
#ifdef DEBUG_SHOW_SAMPLE_COUNT
++sampleCount.x;
#endif // DEBUG_SHOW_SAMPLE_COUNT
if (!any(greaterThan(weather.density, vec4(minDensity)))) {
// Step longer in empty space.
// TODO: This produces banding artifacts.
// Possible improvement: Binary search refinement
stepSize *= perspectiveStepScale;
rayDistance += mix(stepSize, maxStepSize, min(1.0, mipLevel));
continue;
}
// Sample detailed participating media.
MediaSample media = sampleMedia(weather, position, uv, mipLevel, jitter, sampleCount);
if (media.extinction > minExtinction) {
vec3 skyIrradiance;
vec3 sunIrradiance = getCloudsSunSkyIrradiance(position, height, skyIrradiance);
vec3 surfaceNormal = normalize(position);
// March optical depth to the sun for finer details, which BSM lacks.
float sunRayDistance = 0.0;
float opticalDepth = marchOpticalDepth(
position,
sunDirection,
maxIterationCountToSun,
mipLevel,
jitter,
sunRayDistance
);
if (height < shadowTopHeight) {
// Obtain the optical depth from BSM at the ray position.
opticalDepth += sampleShadowOpticalDepth(
position,
// Take account of only positions further than the marched ray
// distance.
sunRayDistance,
// Apply PCF only when the sun is close to the horizon.
maxShadowFilterRadius * remapClamped(dot(sunDirection, surfaceNormal), 0.1, 0.0),
jitter
);
}
vec3 radiance = sunIrradiance * approximateMultipleScattering(opticalDepth, cosTheta);
#ifdef GROUND_BOUNCE
// Fudge factor for the irradiance from ground.
if (height < shadowTopHeight && mipLevel < 0.5) {
vec3 groundRadiance = approximateRadianceFromGround(
position,
surfaceNormal,
height,
mipLevel,
jitter
);
radiance += groundRadiance * RECIPROCAL_PI4 * groundBounceScale;
}
#endif // GROUND_BOUNCE
// Crude approximation of sky gradient. Better than none in the shadows.
float skyGradient = dot(weather.heightFraction * 0.5 + 0.5, media.weight);
radiance += skyIrradiance * RECIPROCAL_PI4 * skyGradient * skyLightScale;
// Finally multiply by scattering.
radiance *= media.scattering;
#ifdef POWDER
radiance *= 1.0 - powderScale * exp(-media.extinction * powderExponent);
#endif // POWDER
#ifdef DEBUG_SHOW_CASCADES
if (height < shadowTopHeight) {
radiance = 1e-3 * getFadedCascadeColor(position, jitter);
}
#endif // DEBUG_SHOW_CASCADES
// Energy-conserving analytical integration of scattered light
// See 5.6.3 in https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/s2016-pbs-frostbite-sky-clouds-new.pdf
float transmittance = exp(-media.extinction * stepSize);
float clampedExtinction = max(media.extinction, 1e-7);
vec3 scatteringIntegral = (radiance - radiance * transmittance) / clampedExtinction;
radianceIntegral += transmittanceIntegral * scatteringIntegral;
transmittanceIntegral *= transmittance;
// Aerial perspective affecting clouds
// See 5.9.1 in https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/s2016-pbs-frostbite-sky-clouds-new.pdf
weightedDistanceSum += rayDistance * transmittanceIntegral;
transmittanceSum += transmittanceIntegral;
}
if (transmittanceIntegral <= minTransmittance) {
break; // Early termination
}
// Take a shorter step because we've already hit the clouds.
stepSize *= perspectiveStepScale;
rayDistance += stepSize;
}
// The final product of 5.9.1 and we'll evaluate this in aerial perspective.
frontDepth = transmittanceSum > 0.0 ? weightedDistanceSum / transmittanceSum : -1.0;
return vec4(radianceIntegral, remapClamped(transmittanceIntegral, 1.0, minTransmittance));
}
#ifdef SHADOW_LENGTH
float marchShadowLength(
const vec3 rayOrigin,
const vec3 rayDirection,
const vec2 rayNearFar,
const float jitter
) {
float shadowLength = 0.0;
float maxRayDistance = rayNearFar.y - rayNearFar.x;
float stepSize = minShadowLengthStepSize;
float rayDistance = stepSize * jitter;
const float attenuationFactor = 1.0 - 5e-4;
float attenuation = 1.0;
// TODO: This march is closed, and sample resolution can be much lower.
// Refining the termination by binary search will make it much more efficient.
for (int i = 0; i < maxShadowLengthIterationCount; ++i) {
if (rayDistance > maxRayDistance) {
break; // Termination
}
vec3 position = rayDistance * rayDirection + rayOrigin;
float opticalDepth = sampleShadowOpticalDepth(position, 0.0, 0.0, jitter);
shadowLength += (1.0 - exp(-opticalDepth)) * stepSize * attenuation;
stepSize *= perspectiveStepScale;
rayDistance += stepSize;
}
return shadowLength;
}
#endif // SHADOW_LENGTH
#ifdef HAZE
vec4 approximateHaze(
const vec3 rayOrigin,
const vec3 rayDirection,
const float maxRayDistance,
const float cosTheta,
const float shadowLength
) {
float modulation = remapClamped(coverage, 0.2, 0.4);
if (cameraHeight * modulation < 0.0) {
return vec4(0.0);
}
float density = modulation * hazeDensityScale * exp(-cameraHeight * hazeExponent);
if (density < 1e-7) {
return vec4(0.0); // Prevent artifact in views from space
}
// Blend two normals by the difference in angle so that normal near the
// ground becomes that of the origin, and in the sky that of the horizon.
vec3 normalAtOrigin = normalize(rayOrigin);
vec3 normalAtHorizon = (rayOrigin - dot(rayOrigin, rayDirection) * rayDirection) / bottomRadius;
float alpha = remapClamped(dot(normalAtOrigin, normalAtHorizon), 0.9, 1.0);
vec3 normal = mix(normalAtOrigin, normalAtHorizon, alpha);
// Analytical optical depth where density exponentially decreases with height.
// Based on: https://iquilezles.org/articles/fog/
float angle = max(dot(normal, rayDirection), 1e-5);
float exponent = angle * hazeExponent;
float linearTerm = density / hazeExponent / angle;
// Derive the optical depths separately for with and without shadow length.
float expTerm = 1.0 - exp(-maxRayDistance * exponent);
float shadowExpTerm = 1.0 - exp(-min(maxRayDistance, shadowLength) * exponent);
float opticalDepth = expTerm * linearTerm;
float shadowOpticalDepth = max((expTerm - shadowExpTerm) * linearTerm, 0.0);
float transmittance = saturate(1.0 - exp(-opticalDepth));
float shadowTransmittance = saturate(1.0 - exp(-shadowOpticalDepth));
vec3 skyIrradiance = vGroundIrradiance.sky;
vec3 sunIrradiance = vGroundIrradiance.sun;
vec3 inscatter = sunIrradiance * phaseFunction(cosTheta) * shadowTransmittance;
inscatter += skyIrradiance * RECIPROCAL_PI4 * skyLightScale * transmittance;
inscatter *= hazeScatteringCoefficient / (hazeAbsorptionCoefficient + hazeScatteringCoefficient);
return vec4(inscatter, transmittance);
}
#endif // HAZE
void applyAerialPerspective(
const vec3 cameraPosition,
const vec3 frontPosition,
const float shadowLength,
inout vec4 color
) {
vec3 transmittance;
vec3 inscatter = GetSkyRadianceToPoint(
cameraPosition * METER_TO_LENGTH_UNIT,
frontPosition * METER_TO_LENGTH_UNIT,
shadowLength * METER_TO_LENGTH_UNIT,
sunDirection,
transmittance
);
color.rgb = color.rgb * transmittance + inscatter * color.a;
}
bool rayIntersectsGround(const vec3 cameraPosition, const vec3 rayDirection) {
float r = length(cameraPosition);
float mu = dot(cameraPosition, rayDirection) / r;
return mu < 0.0 && r * r * (mu * mu - 1.0) + bottomRadius * bottomRadius >= 0.0;
}
struct IntersectionResult {
bool ground;
vec4 first;
vec4 second;
};
IntersectionResult getIntersections(const vec3 cameraPosition, const vec3 rayDirection) {
IntersectionResult intersections;
intersections.ground = rayIntersectsGround(cameraPosition, rayDirection);
raySphereIntersections(
cameraPosition,
rayDirection,
bottomRadius + vec4(0.0, minHeight, maxHeight, shadowTopHeight),
intersections.first,
intersections.second
);
return intersections;
}
vec2 getRayNearFar(const IntersectionResult intersections) {
vec2 nearFar;
if (cameraHeight < minHeight) {
// View below the clouds
if (intersections.ground) {
nearFar = vec2(-1.0); // No clouds to the ground
} else {
nearFar = vec2(intersections.second.y, intersections.second.z);
nearFar.y = min(nearFar.y, maxRayDistance);
}
} else if (cameraHeight < maxHeight) {
// View inside the total cloud layer
if (intersections.ground) {
nearFar = vec2(cameraNear, intersections.first.y);
} else {
nearFar = vec2(cameraNear, intersections.second.z);
}
} else {
// View above the clouds
nearFar = vec2(intersections.first.z, intersections.second.z);
if (intersections.ground) {
// Clamp the ray at the min height.
nearFar.y = intersections.first.y;
}
}
return nearFar;
}
#ifdef SHADOW_LENGTH
vec2 getShadowRayNearFar(const IntersectionResult intersections) {
vec2 nearFar;
if (cameraHeight < shadowTopHeight) {
if (intersections.ground) {
nearFar = vec2(cameraNear, intersections.first.x);
} else {
nearFar = vec2(cameraNear, intersections.second.w);
}
} else {
nearFar = vec2(intersections.first.w, intersections.second.w);
if (intersections.ground) {
// Clamp the ray at the ground.
nearFar.y = intersections.first.x;
}
}
nearFar.y = min(nearFar.y, maxShadowLengthRayDistance);
return nearFar;
}
#endif // SHADOW_LENGTH
#ifdef HAZE
vec2 getHazeRayNearFar(const IntersectionResult intersections) {
vec2 nearFar;
if (cameraHeight < maxHeight) {
if (intersections.ground) {
nearFar = vec2(cameraNear, intersections.first.x);
} else {
nearFar = vec2(cameraNear, intersections.second.z);
}
} else {
nearFar = vec2(cameraNear, intersections.second.z);
if (intersections.ground) {
// Clamp the ray at the ground.
nearFar.y = intersections.first.x;
}
}
return nearFar;
}
#endif // HAZE
float getRayDistanceToScene(const vec3 rayDirection, out float viewZ) {
float depth = readDepth(vUv * targetUvScale + temporalJitter);
if (depth < 1.0 - 1e-7) {
depth = reverseLogDepth(depth, cameraNear, cameraFar);
viewZ = getViewZ(depth);
return -viewZ / dot(rayDirection, vCameraDirection);
}
viewZ = 0.0;
return 0.0;
}
void main() {
#ifdef DEBUG_SHOW_SHADOW_MAP
outputColor = getCascadedShadowMaps(vUv);
outputDepthVelocity = vec3(0.0);
#ifdef SHADOW_LENGTH
outputShadowLength = 0.0;
#endif // SHADOW_LENGTH
return;
#endif // DEBUG_SHOW_SHADOW_MAP
vec3 cameraPosition = vCameraPosition + altitudeCorrection;
vec3 rayDirection = normalize(vRayDirection);
float cosTheta = dot(sunDirection, rayDirection);
IntersectionResult intersections = getIntersections(cameraPosition, rayDirection);
vec2 rayNearFar = getRayNearFar(intersections);
#ifdef SHADOW_LENGTH
vec2 shadowRayNearFar = getShadowRayNearFar(intersections);
#endif // SHADOW_LENGTH
#ifdef HAZE
vec2 hazeRayNearFar = getHazeRayNearFar(intersections);
#endif // HAZE
float sceneViewZ;
float rayDistanceToScene = getRayDistanceToScene(rayDirection, sceneViewZ);
if (rayDistanceToScene > 0.0) {
rayNearFar.y = min(rayNearFar.y, rayDistanceToScene);
#ifdef SHADOW_LENGTH
shadowRayNearFar.y = min(shadowRayNearFar.y, rayDistanceToScene);
#endif // SHADOW_LENGTH
#ifdef HAZE
hazeRayNearFar.y = min(hazeRayNearFar.y, rayDistanceToScene);
#endif // HAZE
}
bool intersectsGround = any(lessThan(rayNearFar, vec2(0.0)));
bool intersectsScene = rayNearFar.y < rayNearFar.x;
float stbn = getSTBN();
vec4 color = vec4(0.0);
float frontDepth = rayNearFar.y;
vec3 depthVelocity = vec3(0.0);
float shadowLength = 0.0;
bool hitClouds = false;
if (!intersectsGround && !intersectsScene) {
vec3 rayOrigin = rayNearFar.x * rayDirection + cameraPosition;
vec2 globeUv = getGlobeUv(rayOrigin);
#ifdef DEBUG_SHOW_UV
outputColor = vec4(vec3(checker(globeUv, localWeatherRepeat + localWeatherOffset)), 1.0);
outputDepthVelocity = vec3(0.0);
#ifdef SHADOW_LENGTH
outputShadowLength = 0.0;
#endif // SHADOW_LENGTH
return;
#endif // DEBUG_SHOW_UV
float mipLevel = getMipLevel(globeUv * localWeatherRepeat) * mipLevelScale;
mipLevel = mix(0.0, mipLevel, min(1.0, 0.2 * cameraHeight / maxHeight));
float marchedFrontDepth;
ivec3 sampleCount = ivec3(0);
color = marchClouds(
rayOrigin,
rayDirection,
rayNearFar,
cosTheta,
stbn,
pow(2.0, mipLevel),
marchedFrontDepth,
sampleCount
);
#ifdef DEBUG_SHOW_SAMPLE_COUNT
outputColor = vec4(vec3(sampleCount) / vec3(500.0, 5.0, 5.0), 1.0);
outputDepthVelocity = vec3(0.0);
#ifdef SHADOW_LENGTH
outputShadowLength = 0.0;
#endif // SHADOW_LENGTH
return;
#endif // DEBUG_SHOW_SAMPLE_COUNT
// Front depth will be -1.0 when no samples are accumulated.
hitClouds = marchedFrontDepth >= 0.0;
if (hitClouds) {
frontDepth = rayNearFar.x + marchedFrontDepth;
#ifdef SHADOW_LENGTH
// Clamp the shadow length ray at the clouds.
shadowRayNearFar.y = mix(
shadowRayNearFar.y,
min(frontDepth, shadowRayNearFar.y),
color.a // Interpolate by the alpha for smoother edges.
);
// Shadow length must be computed before applying aerial perspective.
if (all(greaterThanEqual(shadowRayNearFar, vec2(0.0)))) {
shadowLength = marchShadowLength(
shadowRayNearFar.x * rayDirection + cameraPosition,
rayDirection,
shadowRayNearFar,
stbn
);
}
#endif // SHADOW_LENGTH
#ifdef HAZE
// Clamp the haze ray at the clouds.
hazeRayNearFar.y = mix(
hazeRayNearFar.y,
min(frontDepth, hazeRayNearFar.y),
color.a // Interpolate by the alpha for smoother edges.
);
#endif // HAZE
// Apply aerial perspective.
vec3 frontPosition = cameraPosition + frontDepth * rayDirection;
applyAerialPerspective(cameraPosition, frontPosition, shadowLength, color);
// Velocity for temporal resolution.
vec3 frontPositionWorld = ecefToWorld(frontPosition);
vec4 prevClip = reprojectionMatrix * vec4(frontPositionWorld, 1.0);
prevClip /= prevClip.w;
vec2 prevUv = prevClip.xy * 0.5 + 0.5;
vec2 velocity = vUv - prevUv;
depthVelocity = vec3(frontDepth, velocity);
}
}
if (!hitClouds) {
#ifdef SHADOW_LENGTH
if (all(greaterThanEqual(shadowRayNearFar, vec2(0.0)))) {
shadowLength = marchShadowLength(
shadowRayNearFar.x * rayDirection + cameraPosition,
rayDirection,
shadowRayNearFar,
stbn
);
}
#endif // SHADOW_LENGTH
// Velocity for temporal resolution. Here reproject in the view space for
// greatly reducing the precision errors.
frontDepth = sceneViewZ < 0.0 ? -sceneViewZ : cameraFar;
vec3 frontView = vViewPosition * frontDepth;
vec4 prevClip = viewReprojectionMatrix * vec4(frontView, 1.0);
prevClip /= prevClip.w;
vec2 prevUv = prevClip.xy * 0.5 + 0.5;
vec2 velocity = vUv - prevUv;
depthVelocity = vec3(frontDepth, velocity);
}
#ifdef DEBUG_SHOW_FRONT_DEPTH
outputColor = vec4(turbo(frontDepth / maxRayDistance), 1.0);
outputDepthVelocity = vec3(0.0);
#ifdef SHADOW_LENGTH
outputShadowLength = 0.0;
#endif // SHADOW_LENGTH
return;
#endif // DEBUG_SHOW_FRONT_DEPTH
#ifdef HAZE
vec4 haze = approximateHaze(
cameraNear * rayDirection + cameraPosition,
rayDirection,
hazeRayNearFar.y - hazeRayNearFar.x,
cosTheta,
shadowLength
);
color.rgb = mix(color.rgb, haze.rgb, haze.a);
color.a = color.a * (1.0 - haze.a) + haze.a;
#endif // HAZE
outputColor = color;
outputDepthVelocity = depthVelocity;
#ifdef SHADOW_LENGTH
outputShadowLength = shadowLength * METER_TO_LENGTH_UNIT;
#endif // SHADOW_LENGTH
}
`,e9=`float getSTBN() {
ivec3 size = textureSize(stbnTexture, 0);
vec3 scale = 1.0 / vec3(size);
return texture(stbnTexture, vec3(gl_FragCoord.xy, float(frame % size.z)) * scale).r;
}
// Straightforward spherical mapping
vec2 getSphericalUv(const vec3 position) {
vec2 st = normalize(position.yx);
float phi = atan(st.x, st.y);
float theta = asin(normalize(position).z);
return vec2(phi * RECIPROCAL_PI2 + 0.5, theta * RECIPROCAL_PI + 0.5);
}
vec2 getCubeSphereUv(const vec3 position) {
// Cube-sphere relaxation by: http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html
// TODO: Tile and fix seams.
// Possible improvements:
// https://iquilezles.org/articles/texturerepetition/
// https://gamedev.stackexchange.com/questions/184388/fragment-shader-map-dot-texture-repeatedly-over-the-sphere
// https://github.com/mmikk/hextile-demo
vec3 n = normalize(position);
vec3 f = abs(n);
vec3 c = n / max(f.x, max(f.y, f.z));
vec2 m;
if (all(greaterThan(f.yy, f.xz))) {
m = c.y > 0.0 ? vec2(-n.x, n.z) : n.xz;
} else if (all(greaterThan(f.xx, f.yz))) {
m = c.x > 0.0 ? n.yz : vec2(-n.y, n.z);
} else {
m = c.z > 0.0 ? n.xy : vec2(n.x, -n.y);
}
vec2 m2 = m * m;
float q = dot(m2.xy, vec2(-2.0, 2.0)) - 3.0;
float q2 = q * q;
vec2 uv;
uv.x = sqrt(1.5 + m2.x - m2.y - 0.5 * sqrt(-24.0 * m2.x + q2)) * (m.x > 0.0 ? 1.0 : -1.0);
uv.y = sqrt(6.0 / (3.0 - uv.x * uv.x)) * m.y;
return uv * 0.5 + 0.5;
}
vec2 getGlobeUv(const vec3 position) {
return getCubeSphereUv(position);
}
float getMipLevel(const vec2 uv) {
const float mipLevelScale = 0.1;
vec2 coord = uv * resolution;
vec2 ddx = dFdx(coord);
vec2 ddy = dFdy(coord);
float deltaMaxSqr = max(dot(ddx, ddx), dot(ddy, ddy)) * mipLevelScale;
return max(0.0, 0.5 * log2(max(1.0, deltaMaxSqr)));
}
bool insideLayerIntervals(const float height) {
bvec3 gt = greaterThan(vec3(height), minIntervalHeights);
bvec3 lt = lessThan(vec3(height), maxIntervalHeights);
return any(bvec3(gt.x && lt.x, gt.y && lt.y, gt.z && lt.z));
}
struct WeatherSample {
vec4 heightFraction; // Normalized height of each layer
vec4 density;
};
vec4 shapeAlteringFunction(const vec4 heightFraction, const vec4 bias) {
// Apply a semi-circle transform to round the clouds towards the top.
vec4 biased = pow(heightFraction, bias);
vec4 x = clamp(biased * 2.0 - 1.0, -1.0, 1.0);
return 1.0 - x * x;
}
WeatherSample sampleWeather(const vec2 uv, const float height, const float mipLevel) {
WeatherSample weather;
weather.heightFraction = remapClamped(vec4(height), minLayerHeights, maxLayerHeights);
vec4 localWeather = pow(
textureLod(
localWeatherTexture,
uv * localWeatherRepeat + localWeatherOffset,
mipLevel
).LOCAL_WEATHER_CHANNELS,
weatherExponents
);
#ifdef SHADOW
localWeather *= shadowLayerMask;
#endif // SHADOW
vec4 heightScale = shapeAlteringFunction(weather.heightFraction, shapeAlteringBiases);
// Modulation to control weather by coverage parameter.
// Reference: https://github.com/Prograda/Skybolt/blob/master/Assets/Core/Shaders/Clouds.h#L63
vec4 factor = 1.0 - coverage * heightScale;
weather.density = remapClamped(
mix(localWeather, vec4(1.0), coverageFilterWidths),
factor,
factor + coverageFilterWidths
);
return weather;
}
vec4 getLayerDensity(const vec4 heightFraction) {
// prettier-ignore
return densityProfile.expTerms * exp(densityProfile.exponents * heightFraction) +
densityProfile.linearTerms * heightFraction +
densityProfile.constantTerms;
}
struct MediaSample {
float density;
vec4 weight;
float scattering;
float extinction;
};
MediaSample sampleMedia(
const WeatherSample weather,
const vec3 position,
const vec2 uv,
const float mipLevel,
const float jitter,
out ivec3 sampleCount
) {
vec4 density = weather.density;
// TODO: Define in physical length.
vec3 surfaceNormal = normalize(position);
float localWeatherSpeed = length(localWeatherOffset);
vec3 evolution = -surfaceNormal * localWeatherSpeed * 2e4;
vec3 turbulence = vec3(0.0);
#ifdef TURBULENCE
vec2 turbulenceUv = uv * localWeatherRepeat * turbulenceRepeat;
turbulence =
turbulenceDisplacement *
(texture(turbulenceTexture, turbulenceUv).rgb * 2.0 - 1.0) *
dot(density, remapClamped(weather.heightFraction, vec4(0.3), vec4(0.0)));
#endif // TURBULENCE
vec3 shapePosition = (position + evolution + turbulence) * shapeRepeat + shapeOffset;
float shape = texture(shapeTexture, shapePosition).r;
density = remapClamped(density, vec4(1.0 - shape) * shapeAmounts, vec4(1.0));
#ifdef DEBUG_SHOW_SAMPLE_COUNT
++sampleCount.y;
#endif // DEBUG_SHOW_SAMPLE_COUNT
#ifdef SHAPE_DETAIL
if (mipLevel * 0.5 + (jitter - 0.5) * 0.5 < 0.5) {
vec3 detailPosition = (position + turbulence) * shapeDetailRepeat + shapeDetailOffset;
float detail = texture(shapeDetailTexture, detailPosition).r;
// Fluffy at the top and whippy at the bottom.
vec4 modifier = mix(
vec4(pow(detail, 6.0)),
vec4(1.0 - detail),
remapClamped(weather.heightFraction, vec4(0.2), vec4(0.4))
);
modifier = mix(vec4(0.0), modifier, shapeDetailAmounts);
density = remapClamped(density * 2.0, vec4(modifier * 0.5), vec4(1.0));
#ifdef DEBUG_SHOW_SAMPLE_COUNT
++sampleCount.z;
#endif // DEBUG_SHOW_SAMPLE_COUNT
}
#endif // SHAPE_DETAIL
// Apply the density profiles.
density = saturate(density * densityScales * getLayerDensity(weather.heightFraction));
MediaSample media;
float densitySum = density.x + density.y + density.z + density.w;
media.weight = density / densitySum;
media.scattering = densitySum * scatteringCoefficient;
media.extinction = densitySum * absorptionCoefficient + media.scattering;
return media;
}
MediaSample sampleMedia(
const WeatherSample weather,
const vec3 position,
const vec2 uv,
const float mipLevel,
const float jitter
) {
ivec3 sampleCount;
return sampleMedia(weather, position, uv, mipLevel, jitter, sampleCount);
}
`,Yie=`precision highp float;
precision highp sampler3D;
#include "atmosphere/bruneton/definitions"
uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;
#include "atmosphere/bruneton/common"
#include "atmosphere/bruneton/runtime"
#include "types"
uniform mat4 inverseProjectionMatrix;
uniform mat4 inverseViewMatrix;
uniform vec3 cameraPosition;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;
// Atmosphere
uniform float bottomRadius;
uniform vec3 sunDirection;
// Cloud layers
uniform float minHeight;
uniform float maxHeight;
layout(location = 0) in vec3 position;
out vec2 vUv;
out vec3 vCameraPosition;
out vec3 vCameraDirection; // Direction to the center of screen
out vec3 vRayDirection; // Direction to the texel
out vec3 vViewPosition;
out GroundIrradiance vGroundIrradiance;
out CloudsIrradiance vCloudsIrradiance;
void sampleSunSkyIrradiance(const vec3 positionECEF) {
vGroundIrradiance.sun = GetSunAndSkyScalarIrradiance(
positionECEF * METER_TO_LENGTH_UNIT,
sunDirection,
vGroundIrradiance.sky
);
vec3 surfaceNormal = normalize(positionECEF);
vec2 radii = (bottomRadius + vec2(minHeight, maxHeight)) * METER_TO_LENGTH_UNIT;
vCloudsIrradiance.minSun = GetSunAndSkyScalarIrradiance(
surfaceNormal * radii.x,
sunDirection,
vCloudsIrradiance.minSky
);
vCloudsIrradiance.maxSun = GetSunAndSkyScalarIrradiance(
surfaceNormal * radii.y,
sunDirection,
vCloudsIrradiance.maxSky
);
}
void main() {
vUv = position.xy * 0.5 + 0.5;
vec3 viewPosition = (inverseProjectionMatrix * vec4(position, 1.0)).xyz;
vec3 worldDirection = (inverseViewMatrix * vec4(viewPosition.xyz, 0.0)).xyz;
vec3 cameraDirection = normalize((inverseViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz);
vCameraPosition = (worldToECEFMatrix * vec4(cameraPosition, 1.0)).xyz;
vCameraDirection = (worldToECEFMatrix * vec4(cameraDirection, 0.0)).xyz;
vRayDirection = (worldToECEFMatrix * vec4(worldDirection, 0.0)).xyz;
vViewPosition = viewPosition;
sampleSunSkyIrradiance(vCameraPosition + altitudeCorrection);
gl_Position = vec4(position.xy, 1.0, 1.0);
}
`,t9=`uniform vec2 resolution;
uniform int frame;
uniform sampler3D stbnTexture;
// Atmosphere
uniform float bottomRadius;
uniform mat4 worldToECEFMatrix;
uniform mat4 ecefToWorldMatrix;
uniform vec3 altitudeCorrection;
uniform vec3 sunDirection;
// Participating medium
uniform float scatteringCoefficient;
uniform float absorptionCoefficient;
// Primary raymarch
uniform float minDensity;
uniform float minExtinction;
uniform float minTransmittance;
// Shape and weather
uniform sampler2D localWeatherTexture;
uniform vec2 localWeatherRepeat;
uniform vec2 localWeatherOffset;
uniform float coverage;
uniform sampler3D shapeTexture;
uniform vec3 shapeRepeat;
uniform vec3 shapeOffset;
#ifdef SHAPE_DETAIL
uniform sampler3D shapeDetailTexture;
uniform vec3 shapeDetailRepeat;
uniform vec3 shapeDetailOffset;
#endif // SHAPE_DETAIL
#ifdef TURBULENCE
uniform sampler2D turbulenceTexture;
uniform vec2 turbulenceRepeat;
uniform float turbulenceDisplacement;
#endif // TURBULENCE
// Haze
#ifdef HAZE
uniform float hazeDensityScale;
uniform float hazeExponent;
uniform float hazeScatteringCoefficient;
uniform float hazeAbsorptionCoefficient;
#endif // HAZE
// Cloud layers
uniform vec4 minLayerHeights;
uniform vec4 maxLayerHeights;
uniform vec3 minIntervalHeights;
uniform vec3 maxIntervalHeights;
uniform vec4 densityScales;
uniform vec4 shapeAmounts;
uniform vec4 shapeDetailAmounts;
uniform vec4 weatherExponents;
uniform vec4 shapeAlteringBiases;
uniform vec4 coverageFilterWidths;
uniform float minHeight;
uniform float maxHeight;
uniform float shadowTopHeight;
uniform float shadowBottomHeight;
uniform vec4 shadowLayerMask;
uniform CloudDensityProfile densityProfile;
`,aM=`struct GroundIrradiance {
vec3 sun;
vec3 sky;
};
struct CloudsIrradiance {
vec3 minSun;
vec3 minSky;
vec3 maxSun;
vec3 maxSky;
};
struct CloudDensityProfile {
vec4 expTerms;
vec4 exponents;
vec4 linearTerms;
vec4 constantTerms;
};
`;var qie=Object.defineProperty,ar=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&qie(e,t,a),a};const jie=new L,Zie=new q8;let Ba=class extends q0{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i},a=Y0.DEFAULT){super({name:"CloudsMaterial",glslVersion:ao,vertexShader:Ca(Yie,{atmosphere:{bruneton:{common:DO,definitions:OO,runtime:NO}},types:aM}),fragmentShader:X0(Ca(Xie,{core:{depth:NP,math:mA,turbo:OP,generators:Jte,raySphereIntersection:fy,cascadedShadowMaps:CP,interleavedGradientNoise:DP,vogelDisk:LP},atmosphere:{bruneton:{common:DO,definitions:OO,runtime:NO}},types:aM,parameters:t9,clouds:e9})),uniforms:{...e,...t,...i,depthBuffer:new J(null),viewMatrix:new J(new ke),inverseProjectionMatrix:new J(new ke),inverseViewMatrix:new J(new ke),reprojectionMatrix:new J(new ke),viewReprojectionMatrix:new J(new ke),resolution:new J(new de),cameraNear:new J(0),cameraFar:new J(0),cameraHeight:new J(0),frame:new J(0),temporalJitter:new J(new de),targetUvScale:new J(new de),mipLevelScale:new J(1),stbnTexture:new J(null),skyLightScale:new J(1),groundBounceScale:new J(1),powderScale:new J(.8),powderExponent:new J(150),maxIterationCount:new J(It.clouds.maxIterationCount),minStepSize:new J(It.clouds.minStepSize),maxStepSize:new J(It.clouds.maxStepSize),maxRayDistance:new J(It.clouds.maxRayDistance),perspectiveStepScale:new J(It.clouds.perspectiveStepScale),minDensity:new J(It.clouds.minDensity),minExtinction:new J(It.clouds.minExtinction),minTransmittance:new J(It.clouds.minTransmittance),maxIterationCountToSun:new J(It.clouds.maxIterationCountToSun),maxIterationCountToGround:new J(It.clouds.maxIterationCountToGround),minSecondaryStepSize:new J(It.clouds.minSecondaryStepSize),secondaryStepScale:new J(It.clouds.secondaryStepScale),shadowBuffer:new J(null),shadowTexelSize:new J(new de),shadowIntervals:new J(Array.from({length:4},()=>new de)),shadowMatrices:new J(Array.from({length:4},()=>new ke)),shadowFar:new J(0),maxShadowFilterRadius:new J(6),shadowLayerMask:new J(new zt().setScalar(1)),maxShadowLengthIterationCount:new J(It.clouds.maxShadowLengthIterationCount),minShadowLengthStepSize:new J(It.clouds.minShadowLengthStepSize),maxShadowLengthRayDistance:new J(It.clouds.maxShadowLengthRayDistance),hazeDensityScale:new J(3e-5),hazeExponent:new J(.001),hazeScatteringCoefficient:new J(.9),hazeAbsorptionCoefficient:new J(.5)}},a),this.temporalUpscale=!0,this.depthPacking=0,this.localWeatherChannels="rgba",this.shapeDetail=It.shapeDetail,this.turbulence=It.turbulence,this.shadowLength=It.lightShafts,this.haze=It.haze,this.multiScatteringOctaves=It.clouds.multiScatteringOctaves,this.accurateSunSkyLight=It.clouds.accurateSunSkyLight,this.accuratePhaseFunction=It.clouds.accuratePhaseFunction,this.shadowCascadeCount=It.shadow.cascadeCount,this.shadowSampleCount=8,this.scatterAnisotropy1=.7,this.scatterAnisotropy2=-.2,this.scatterAnisotropyMix=.5}onBeforeRender(e,t,i,a,r,s){const o=this.defines.USE_LOGARITHMIC_DEPTH_BUFFER!=null,c=e.capabilities.logarithmicDepthBuffer;c!==o&&(c?this.defines.USE_LOGARITHMIC_DEPTH_BUFFER="1":delete this.defines.USE_LOGARITHMIC_DEPTH_BUFFER);const h=this.defines.POWDER!=null,f=this.uniforms.powderScale.value>0;f!==h&&(f?this.defines.POWDER="1":delete this.defines.POWDER,this.needsUpdate=!0);const d=this.defines.GROUND_BOUNCE!=null;(this.uniforms.groundBounceScale.value>0&&this.uniforms.maxIterationCountToGround.value>0)!==d&&(f?this.defines.GROUND_BOUNCE="1":delete this.defines.GROUND_BOUNCE,this.needsUpdate=!0)}copyCameraSettings(e){e.isPerspectiveCamera===!0?this.defines.PERSPECTIVE_CAMERA!=="1"&&(this.defines.PERSPECTIVE_CAMERA="1",this.needsUpdate=!0):this.defines.PERSPECTIVE_CAMERA!=null&&(delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0);const t=this.uniforms;t.viewMatrix.value.copy(e.matrixWorldInverse),t.inverseViewMatrix.value.copy(e.matrixWorld);const i=this.previousProjectionMatrix??e.projectionMatrix,a=this.previousViewMatrix??e.matrixWorldInverse,r=t.inverseProjectionMatrix.value,s=t.inverseViewMatrix.value,o=t.reprojectionMatrix.value,c=t.viewReprojectionMatrix.value;if(this.temporalUpscale){const d=t.frame.value%16,m=t.resolution.value,g=$P[d],x=(g.x-.5)/m.x*4,T=(g.y-.5)/m.y*4;t.temporalJitter.value.set(x,T),t.mipLevelScale.value=.25,r.copy(e.projectionMatrix),r.elements[8]+=x*2,r.elements[9]+=T*2,r.invert(),o.copy(i),o.elements[8]+=x*2,o.elements[9]+=T*2,o.multiply(a),c.copy(o).multiply(s)}else t.temporalJitter.value.setScalar(0),t.mipLevelScale.value=1,r.copy(e.projectionMatrixInverse),o.copy(i).multiply(a),c.copy(o).multiply(s);t.cameraNear.value=e.near,t.cameraFar.value=e.far;const h=e.getWorldPosition(t.cameraPosition.value),f=jie.copy(h).applyMatrix4(t.worldToECEFMatrix.value);try{t.cameraHeight.value=Zie.setFromECEF(f).height}catch{}}copyReprojectionMatrix(e){this.previousProjectionMatrix??(this.previousProjectionMatrix=new ke),this.previousViewMatrix??(this.previousViewMatrix=new ke),this.previousProjectionMatrix.copy(e.projectionMatrix),this.previousViewMatrix.copy(e.matrixWorldInverse)}setSize(e,t,i,a){this.uniforms.resolution.value.set(e,t),i!=null&&a!=null?this.uniforms.targetUvScale.value.set(e/i,t/a):this.uniforms.targetUvScale.value.setScalar(1),this.previousProjectionMatrix=void 0,this.previousViewMatrix=void 0}setShadowSize(e,t){this.uniforms.shadowTexelSize.value.set(1/e,1/t)}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get accurateSunSkyIrradiance(){return this.accurateSunSkyLight}set accurateSunSkyIrradiance(e){this.accurateSunSkyLight=e}};ar([dh("DEPTH_PACKING")],Ba.prototype,"depthPacking");ar([AP("LOCAL_WEATHER_CHANNELS",{validate:n=>/^[rgba]{4}$/.test(n)})],Ba.prototype,"localWeatherChannels");ar([dn("SHAPE_DETAIL")],Ba.prototype,"shapeDetail");ar([dn("TURBULENCE")],Ba.prototype,"turbulence");ar([dn("SHADOW_LENGTH")],Ba.prototype,"shadowLength");ar([dn("HAZE")],Ba.prototype,"haze");ar([dh("MULTI_SCATTERING_OCTAVES",{min:1,max:12})],Ba.prototype,"multiScatteringOctaves");ar([dn("ACCURATE_SUN_SKY_LIGHT")],Ba.prototype,"accurateSunSkyLight");ar([dn("ACCURATE_PHASE_FUNCTION")],Ba.prototype,"accuratePhaseFunction");ar([dh("SHADOW_CASCADE_COUNT",{min:1,max:4})],Ba.prototype,"shadowCascadeCount");ar([dh("SHADOW_SAMPLE_COUNT",{min:1,max:16})],Ba.prototype,"shadowSampleCount");ar([pA("SCATTER_ANISOTROPY_1")],Ba.prototype,"scatterAnisotropy1");ar([pA("SCATTER_ANISOTROPY_2")],Ba.prototype,"scatterAnisotropy2");ar([pA("SCATTER_ANISOTROPY_MIX")],Ba.prototype,"scatterAnisotropyMix");const Kie=`// Taken from https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
// TODO: Use 5-taps version: https://www.shadertoy.com/view/MtVGWz
// Or even 4 taps (requires preprocessing in the input buffer):
// https://www.shadertoy.com/view/4tyGDD
/**
* MIT License
*
* Copyright (c) 2019 MJP
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
vec4 textureCatmullRom(sampler2D tex, vec2 uv) {
vec2 texSize = vec2(textureSize(tex, 0));
// We're going to sample a a 4x4 grid of texels surrounding the target UV
// coordinate. We'll do this by rounding down the sample location to get the
// exact center of our "starting" texel. The starting texel will be at
// location [1, 1] in the grid, where [0, 0] is the top left corner.
vec2 samplePos = uv * texSize;
vec2 texPos1 = floor(samplePos - 0.5) + 0.5;
// Compute the fractional offset from our starting texel to our original
// sample location, which we'll feed into the Catmull-Rom spline function to
// get our filter weights.
vec2 f = samplePos - texPos1;
// Compute the Catmull-Rom weights using the fractional offset that we
// calculated earlier. These equations are pre-expanded based on our knowledge
// of where the texels will be located, which lets us avoid having to evaluate
// a piece-wise function.
vec2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f));
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5 * f);
vec2 w2 = f * (0.5 + f * (2.0 - 1.5 * f));
vec2 w3 = f * f * (-0.5 + 0.5 * f);
// Work out weighting factors and sampling offsets that will let us use
// bilinear filtering to simultaneously evaluate the middle 2 samples from the
// 4x4 grid.
vec2 w12 = w1 + w2;
vec2 offset12 = w2 / (w1 + w2);
// Compute the final UV coordinates we'll use for sampling the texture
vec2 texPos0 = texPos1 - 1.0;
vec2 texPos3 = texPos1 + 2.0;
vec2 texPos12 = texPos1 + offset12;
texPos0 /= texSize;
texPos3 /= texSize;
texPos12 /= texSize;
vec4 result = vec4(0.0);
result += texture(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
result += texture(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
result += texture(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;
result += texture(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
result += texture(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
result += texture(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;
result += texture(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
result += texture(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
result += texture(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;
return result;
}
vec4 textureCatmullRom(sampler2DArray tex, vec3 uv) {
vec2 texSize = vec2(textureSize(tex, 0));
vec2 samplePos = uv.xy * texSize;
vec2 texPos1 = floor(samplePos - 0.5) + 0.5;
vec2 f = samplePos - texPos1;
vec2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f));
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5 * f);
vec2 w2 = f * (0.5 + f * (2.0 - 1.5 * f));
vec2 w3 = f * f * (-0.5 + 0.5 * f);
vec2 w12 = w1 + w2;
vec2 offset12 = w2 / (w1 + w2);
vec2 texPos0 = texPos1 - 1.0;
vec2 texPos3 = texPos1 + 2.0;
vec2 texPos12 = texPos1 + offset12;
texPos0 /= texSize;
texPos3 /= texSize;
texPos12 /= texSize;
vec4 result = vec4(0.0);
result += texture(tex, vec3(texPos0.x, texPos0.y, uv.z)) * w0.x * w0.y;
result += texture(tex, vec3(texPos12.x, texPos0.y, uv.z)) * w12.x * w0.y;
result += texture(tex, vec3(texPos3.x, texPos0.y, uv.z)) * w3.x * w0.y;
result += texture(tex, vec3(texPos0.x, texPos12.y, uv.z)) * w0.x * w12.y;
result += texture(tex, vec3(texPos12.x, texPos12.y, uv.z)) * w12.x * w12.y;
result += texture(tex, vec3(texPos3.x, texPos12.y, uv.z)) * w3.x * w12.y;
result += texture(tex, vec3(texPos0.x, texPos3.y, uv.z)) * w0.x * w3.y;
result += texture(tex, vec3(texPos12.x, texPos3.y, uv.z)) * w12.x * w3.y;
result += texture(tex, vec3(texPos3.x, texPos3.y, uv.z)) * w3.x * w3.y;
return result;
}
`,Qie=`precision highp float;
precision highp sampler2DArray;
#include "core/turbo"
#include "catmullRomSampling"
#include "varianceClipping"
uniform sampler2D colorBuffer;
uniform sampler2D depthVelocityBuffer;
uniform sampler2D colorHistoryBuffer;
#ifdef SHADOW_LENGTH
uniform sampler2D shadowLengthBuffer;
uniform sampler2D shadowLengthHistoryBuffer;
#endif // SHADOW_LENGTH
uniform vec2 texelSize;
uniform int frame;
uniform float varianceGamma;
uniform float temporalAlpha;
uniform vec2 jitterOffset;
in vec2 vUv;
layout(location = 0) out vec4 outputColor;
#ifdef SHADOW_LENGTH
layout(location = 1) out float outputShadowLength;
#endif // SHADOW_LENGTH
const ivec2 neighborOffsets[9] = ivec2[9](
ivec2(-1, -1),
ivec2(-1, 0),
ivec2(-1, 1),
ivec2(0, -1),
ivec2(0, 0),
ivec2(0, 1),
ivec2(1, -1),
ivec2(1, 0),
ivec2(1, 1)
);
const ivec4[4] bayerIndices = ivec4[4](
ivec4(0, 12, 3, 15),
ivec4(8, 4, 11, 7),
ivec4(2, 14, 1, 13),
ivec4(10, 6, 9, 5)
);
vec4 getClosestFragment(const ivec2 coord) {
vec4 result = vec4(1e7, 0.0, 0.0, 0.0);
vec4 neighbor;
#pragma unroll_loop_start
for (int i = 0; i < 9; ++i) {
neighbor = texelFetchOffset(depthVelocityBuffer, coord, 0, neighborOffsets[i]);
if (neighbor.r < result.r) {
result = neighbor;
}
}
#pragma unroll_loop_end
return result;
}
void temporalUpscale(
const ivec2 coord,
const ivec2 lowResCoord,
const bool currentFrame,
out vec4 outputColor,
out float outputShadowLength
) {
vec4 currentColor = texelFetch(colorBuffer, lowResCoord, 0);
#ifdef SHADOW_LENGTH
vec4 currentShadowLength = vec4(texelFetch(shadowLengthBuffer, lowResCoord, 0).rgb, 1.0);
#endif // SHADOW_LENGTH
if (currentFrame) {
// Use the texel just rendered without any accumulation.
outputColor = currentColor;
#ifdef SHADOW_LENGTH
outputShadowLength = currentShadowLength.r;
#endif // SHADOW_LENGTH
return;
}
vec4 depthVelocity = getClosestFragment(lowResCoord);
vec2 velocity = depthVelocity.gb;
vec2 prevUv = vUv - velocity;
if (prevUv.x < 0.0 || prevUv.x > 1.0 || prevUv.y < 0.0 || prevUv.y > 1.0) {
outputColor = currentColor;
#ifdef SHADOW_LENGTH
outputShadowLength = currentShadowLength.r;
#endif // SHADOW_LENGTH
return; // Rejection
}
// Variance clipping with a large variance gamma seems to work fine for
// upsampling. This increases ghosting, of course, but it's hard to notice on
// clouds.
// vec4 historyColor = textureCatmullRom(colorHistoryBuffer, prevUv);
vec4 historyColor = texture(colorHistoryBuffer, prevUv);
vec4 clippedColor = varianceClipping(colorBuffer, vUv, currentColor, historyColor, varianceGamma);
outputColor = clippedColor;
#ifdef SHADOW_LENGTH
// Sampling the shadow length history using scene depth doesn't make much
// sense, but it's too hard to derive it properly. At least this approach
// resolves the edges of scene objects.
// vec4 historyShadowLength = vec4(textureCatmullRom(shadowLengthHistoryBuffer, prevUv).rgb, 1.0);
vec4 historyShadowLength = vec4(texture(shadowLengthHistoryBuffer, prevUv).rgb, 1.0);
vec4 clippedShadowLength = varianceClipping(
shadowLengthBuffer,
vUv,
currentShadowLength,
historyShadowLength,
varianceGamma
);
outputShadowLength = clippedShadowLength.r;
#endif // SHADOW_LENGTH
}
void temporalAntialiasing(const ivec2 coord, out vec4 outputColor, out float outputShadowLength) {
vec4 currentColor = texelFetch(colorBuffer, coord, 0);
#ifdef SHADOW_LENGTH
vec4 currentShadowLength = vec4(texelFetch(shadowLengthBuffer, coord, 0).rgb, 1.0);
#endif // SHADOW_LENGTH
vec4 depthVelocity = getClosestFragment(coord);
vec2 velocity = depthVelocity.gb;
vec2 prevUv = vUv - velocity;
if (prevUv.x < 0.0 || prevUv.x > 1.0 || prevUv.y < 0.0 || prevUv.y > 1.0) {
outputColor = currentColor;
#ifdef SHADOW_LENGTH
outputShadowLength = currentShadowLength.r;
#endif // SHADOW_LENGTH
return; // Rejection
}
vec4 historyColor = texture(colorHistoryBuffer, prevUv);
vec4 clippedColor = varianceClipping(colorBuffer, coord, currentColor, historyColor);
outputColor = mix(clippedColor, currentColor, temporalAlpha);
#ifdef SHADOW_LENGTH
vec4 historyShadowLength = vec4(texture(shadowLengthHistoryBuffer, prevUv).rgb, 1.0);
vec4 clippedShadowLength = varianceClipping(
shadowLengthBuffer,
coord,
currentShadowLength,
historyShadowLength
);
outputShadowLength = mix(clippedShadowLength.r, currentShadowLength.r, temporalAlpha);
#endif // SHADOW_LENGTH
}
void main() {
ivec2 coord = ivec2(gl_FragCoord.xy);
#if !defined(SHADOW_LENGTH)
float outputShadowLength;
#endif // !defined(SHADOW_LENGTH)
#ifdef TEMPORAL_UPSCALE
ivec2 lowResCoord = coord / 4;
int bayerValue = bayerIndices[coord.x % 4][coord.y % 4];
bool currentFrame = bayerValue == frame % 16;
temporalUpscale(coord, lowResCoord, currentFrame, outputColor, outputShadowLength);
#else // TEMPORAL_UPSCALE
temporalAntialiasing(coord, outputColor, outputShadowLength);
#endif // TEMPORAL_UPSCALE
#if defined(SHADOW_LENGTH) && defined(DEBUG_SHOW_SHADOW_LENGTH)
outputColor = vec4(turbo(outputShadowLength * 0.05), 1.0);
#endif // defined(SHADOW_LENGTH) && defined(DEBUG_SHOW_SHADOW_LENGTH)
#ifdef DEBUG_SHOW_VELOCITY
outputColor.rgb = outputColor.rgb + vec3(abs(texture(depthVelocityBuffer, vUv).gb) * 10.0, 0.0);
#endif // DEBUG_SHOW_VELOCITY
}
`,Jie=`precision highp float;
layout(location = 0) in vec3 position;
out vec2 vUv;
void main() {
vUv = position.xy * 0.5 + 0.5;
gl_Position = vec4(position.xy, 1.0, 1.0);
}
`,n9=`#ifdef VARIANCE_9_SAMPLES
#define VARIANCE_OFFSET_COUNT 8
const ivec2 varianceOffsets[8] = ivec2[8](
ivec2(-1, -1),
ivec2(-1, 1),
ivec2(1, -1),
ivec2(1, 1),
ivec2(1, 0),
ivec2(0, -1),
ivec2(0, 1),
ivec2(-1, 0)
);
#else // VARIANCE_9_SAMPLES
#define VARIANCE_OFFSET_COUNT 4
const ivec2 varianceOffsets[4] = ivec2[4](ivec2(1, 0), ivec2(0, -1), ivec2(0, 1), ivec2(-1, 0));
#endif // VARIANCE_9_SAMPLES
// Reference: https://github.com/playdeadgames/temporal
vec4 clipAABB(const vec4 current, const vec4 history, const vec4 minColor, const vec4 maxColor) {
vec3 pClip = 0.5 * (maxColor.rgb + minColor.rgb);
vec3 eClip = 0.5 * (maxColor.rgb - minColor.rgb) + 1e-7;
vec4 vClip = history - vec4(pClip, current.a);
vec3 vUnit = vClip.xyz / eClip;
vec3 aUnit = abs(vUnit);
float maUnit = max(aUnit.x, max(aUnit.y, aUnit.z));
if (maUnit > 1.0) {
return vec4(pClip, current.a) + vClip / maUnit;
}
return history;
}
#ifdef VARIANCE_SAMPLER_ARRAY
#define VARIANCE_SAMPLER sampler2DArray
#define VARIANCE_SAMPLER_COORD ivec3
#else // VARIANCE_SAMPLER_ARRAY
#define VARIANCE_SAMPLER sampler2D
#define VARIANCE_SAMPLER_COORD ivec2
#endif // VARIANCE_SAMPLER_ARRAY
// Variance clipping
// Reference: https://developer.download.nvidia.com/gameworks/events/GDC2016/msalvi_temporal_supersampling.pdf
vec4 varianceClipping(
const VARIANCE_SAMPLER inputBuffer,
const VARIANCE_SAMPLER_COORD coord,
const vec4 current,
const vec4 history,
const float gamma
) {
vec4 moment1 = current;
vec4 moment2 = current * current;
vec4 neighbor;
#pragma unroll_loop_start
for (int i = 0; i < 8; ++i) {
#if UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
neighbor = texelFetchOffset(inputBuffer, coord, 0, varianceOffsets[i]);
moment1 += neighbor;
moment2 += neighbor * neighbor;
#endif // UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
}
#pragma unroll_loop_end
const float N = float(VARIANCE_OFFSET_COUNT + 1);
vec4 mean = moment1 / N;
vec4 varianceGamma = sqrt(max(moment2 / N - mean * mean, 0.0)) * gamma;
vec4 minColor = mean - varianceGamma;
vec4 maxColor = mean + varianceGamma;
return clipAABB(clamp(mean, minColor, maxColor), history, minColor, maxColor);
}
vec4 varianceClipping(
const VARIANCE_SAMPLER inputBuffer,
const VARIANCE_SAMPLER_COORD coord,
const vec4 current,
const vec4 history
) {
return varianceClipping(inputBuffer, coord, current, history, 1.0);
}
vec4 varianceClipping(
const sampler2D inputBuffer,
const vec2 coord,
const vec4 current,
const vec4 history,
const float gamma
) {
vec4 moment1 = current;
vec4 moment2 = current * current;
vec4 neighbor;
#pragma unroll_loop_start
for (int i = 0; i < 8; ++i) {
#if UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
neighbor = textureOffset(inputBuffer, coord, varianceOffsets[i]);
moment1 += neighbor;
moment2 += neighbor * neighbor;
#endif // UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
}
#pragma unroll_loop_end
const float N = float(VARIANCE_OFFSET_COUNT + 1);
vec4 mean = moment1 / N;
vec4 varianceGamma = sqrt(max(moment2 / N - mean * mean, 0.0)) * gamma;
vec4 minColor = mean - varianceGamma;
vec4 maxColor = mean + varianceGamma;
return clipAABB(clamp(mean, minColor, maxColor), history, minColor, maxColor);
}
vec4 varianceClipping(
const sampler2D inputBuffer,
const vec2 coord,
const vec4 current,
const vec4 history
) {
return varianceClipping(inputBuffer, coord, current, history, 1.0);
}
`;var $ie=Object.defineProperty,i9=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&$ie(e,t,a),a};class MA extends ch{constructor({colorBuffer:e=null,depthVelocityBuffer:t=null,shadowLengthBuffer:i=null,colorHistoryBuffer:a=null,shadowLengthHistoryBuffer:r=null}={}){super({name:"CloudsResolveMaterial",glslVersion:ao,vertexShader:Jie,fragmentShader:X0(Ca(Qie,{core:{turbo:OP},catmullRomSampling:Kie,varianceClipping:n9})),uniforms:{colorBuffer:new J(e),depthVelocityBuffer:new J(t),shadowLengthBuffer:new J(i),colorHistoryBuffer:new J(a),shadowLengthHistoryBuffer:new J(r),texelSize:new J(new de),frame:new J(0),jitterOffset:new J(new de),varianceGamma:new J(2),temporalAlpha:new J(.1)}}),this.temporalUpscale=!0,this.shadowLength=!0}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}onBeforeRender(e,t,i,a,r,s){const o=this.uniforms.frame.value%16,c=$P[o],h=(c.x-.5)*4,f=(c.y-.5)*4;this.uniforms.jitterOffset.value.set(h,f)}}i9([dn("TEMPORAL_UPSCALE")],MA.prototype,"temporalUpscale");i9([dn("SHADOW_LENGTH")],MA.prototype,"shadowLength");class a9 extends Pa{constructor(e,t){super(e),this._mainCamera=new Tc;const{shadow:i}=t;this.shadow=i}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e}}function $2(n,{depthVelocity:e,shadowLength:t}){const i=new _i(1,1,{depthBuffer:!1,type:Xn});i.texture.minFilter=Ht,i.texture.magFilter=Ht,i.texture.name=n;let a;e&&(a=i.texture.clone(),a.isRenderTargetTexture=!0,i.depthVelocity=a,i.textures.push(a));let r;return t&&(r=i.texture.clone(),r.isRenderTargetTexture=!0,r.format=bs,i.shadowLength=r,i.textures.push(r)),Object.assign(i,{depthVelocity:a??null,shadowLength:r??null})}class eae extends a9{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i,...a},r){super("CloudsPass",a),this.atmosphere=r,this.width=0,this.height=0,this.currentMaterial=new Ba({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i},r),this.currentPass=new DE(this.currentMaterial),this.resolveMaterial=new MA,this.resolvePass=new DE(this.resolveMaterial),this.initRenderTargets({depthVelocity:!0,shadowLength:It.lightShafts})}copyCameraSettings(e){this.currentMaterial.copyCameraSettings(e)}initialize(e,t,i){this.currentPass.initialize(e,t,i),this.resolvePass.initialize(e,t,i)}initRenderTargets(e){var s,o,c;(s=this.currentRenderTarget)==null||s.dispose(),(o=this.resolveRenderTarget)==null||o.dispose(),(c=this.historyRenderTarget)==null||c.dispose();const t=$2("Clouds",e),i=$2("Clouds.A",{...e,depthVelocity:!1}),a=$2("Clouds.B",{...e,depthVelocity:!1});this.currentRenderTarget=t,this.resolveRenderTarget=i,this.historyRenderTarget=a;const r=this.resolveMaterial.uniforms;r.colorBuffer.value=t.texture,r.depthVelocityBuffer.value=t.depthVelocity,r.shadowLengthBuffer.value=t.shadowLength,r.colorHistoryBuffer.value=a.texture,r.shadowLengthHistoryBuffer.value=a.shadowLength}copyShadow(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const a=e.cascades[i];t.shadowIntervals.value[i].copy(a.interval),t.shadowMatrices.value[i].copy(a.matrix)}t.shadowFar.value=e.far}copyReprojection(){this.currentMaterial.copyReprojectionMatrix(this.mainCamera)}swapBuffers(){const e=this.historyRenderTarget,t=this.resolveRenderTarget;this.resolveRenderTarget=e,this.historyRenderTarget=t;const i=this.resolveMaterial.uniforms;i.colorHistoryBuffer.value=t.texture,i.shadowLengthHistoryBuffer.value=t.shadowLength}update(e,t,i){this.currentMaterial.uniforms.frame.value=t,this.resolveMaterial.uniforms.frame.value=t,this.copyCameraSettings(this.mainCamera),this.copyShadow(),this.currentPass.render(e,null,this.currentRenderTarget),this.resolvePass.render(e,null,this.resolveRenderTarget),this.copyReprojection(),this.swapBuffers()}setSize(e,t){if(this.width=e,this.height=t,this.temporalUpscale){const i=Math.ceil(e/4),a=Math.ceil(t/4);this.currentRenderTarget.setSize(i,a),this.currentMaterial.setSize(i*4,a*4,e,t)}else this.currentRenderTarget.setSize(e,t),this.currentMaterial.setSize(e,t);this.resolveRenderTarget.setSize(e,t),this.resolveMaterial.setSize(e,t),this.historyRenderTarget.setSize(e,t)}setShadowSize(e,t,i){this.currentMaterial.shadowCascadeCount=i,this.currentMaterial.setShadowSize(e,t)}setDepthTexture(e,t){this.currentMaterial.depthBuffer=e,this.currentMaterial.depthPacking=t??0}get outputBuffer(){return this.historyRenderTarget.texture}get shadowBuffer(){return this.currentMaterial.uniforms.shadowBuffer.value}set shadowBuffer(e){this.currentMaterial.uniforms.shadowBuffer.value=e}get shadowLengthBuffer(){return this.historyRenderTarget.shadowLength}get temporalUpscale(){return this.currentMaterial.temporalUpscale}set temporalUpscale(e){e!==this.temporalUpscale&&(this.currentMaterial.temporalUpscale=e,this.resolveMaterial.temporalUpscale=e,this.setSize(this.width,this.height))}get lightShafts(){return this.currentMaterial.shadowLength}set lightShafts(e){e!==this.lightShafts&&(this.currentMaterial.shadowLength=e,this.resolveMaterial.shadowLength=e,this.initRenderTargets({depthVelocity:!0,shadowLength:e}),this.setSize(this.width,this.height))}}function tae(n,e){const t=n.properties.get(e.texture).__webglTexture,i=n.getContext();Ql(i instanceof WebGL2RenderingContext),n.setRenderTarget(e);const a=[];if(t!=null)for(let r=0;r<e.depth;++r)i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+r,t,0,r),a.push(i.COLOR_ATTACHMENT0+r);i.drawBuffers(a)}let zO=class extends DE{render(e,t,i,a,r){const s=this.fullscreenMaterial.uniforms;t!==null&&(s==null?void 0:s[this.input])!=null&&(s[this.input].value=t.texture),tae(e,i),e.render(this.scene,this.camera)}};const nae=`precision highp float;
precision highp sampler3D;
#include <common>
#include "core/math"
#include "core/raySphereIntersection"
#include "types"
#include "parameters"
#include "structuredSampling"
#include "clouds"
uniform mat4 inverseShadowMatrices[CASCADE_COUNT];
uniform mat4 reprojectionMatrices[CASCADE_COUNT];
// Primary raymarch
uniform int maxIterationCount;
uniform float minStepSize;
uniform float maxStepSize;
uniform float opticalDepthTailScale;
in vec2 vUv;
layout(location = 0) out vec4 outputColor[CASCADE_COUNT];
// Redundant notation for prettier.
#if CASCADE_COUNT == 1
layout(location = 1) out vec3 outputDepthVelocity[CASCADE_COUNT];
#elif CASCADE_COUNT == 2
layout(location = 2) out vec3 outputDepthVelocity[CASCADE_COUNT];
#elif CASCADE_COUNT == 3
layout(location = 3) out vec3 outputDepthVelocity[CASCADE_COUNT];
#elif CASCADE_COUNT == 4
layout(location = 4) out vec3 outputDepthVelocity[CASCADE_COUNT];
#endif // CASCADE_COUNT
vec4 marchClouds(
const vec3 rayOrigin,
const vec3 rayDirection,
const float maxRayDistance,
const float jitter,
const float mipLevel
) {
// Setup structured volume sampling (SVS).
// While SVS introduces spatial aliasing, it is indeed temporally stable,
// which is important for lower-resolution shadow maps where a flickering
// single pixel can be highly noticeable.
vec3 normal = getStructureNormal(rayDirection, jitter);
float rayDistance;
float stepSize;
intersectStructuredPlanes(
normal,
rayOrigin,
rayDirection,
clamp(maxRayDistance / float(maxIterationCount), minStepSize, maxStepSize),
rayDistance,
stepSize
);
#ifdef TEMPORAL_JITTER
rayDistance -= stepSize * jitter;
#endif // TEMPORAL_JITTER
float extinctionSum = 0.0;
float maxOpticalDepth = 0.0;
float maxOpticalDepthTail = 0.0;
float transmittanceIntegral = 1.0;
float weightedDistanceSum = 0.0;
float transmittanceSum = 0.0;
int sampleCount = 0;
for (int i = 0; i < maxIterationCount; ++i) {
if (rayDistance > maxRayDistance) {
break; // Termination
}
vec3 position = rayDistance * rayDirection + rayOrigin;
float height = length(position) - bottomRadius;
#if !defined(DEBUG_MARCH_INTERVALS)
if (insideLayerIntervals(height)) {
rayDistance += stepSize;
continue;
}
#endif // !defined(DEBUG_MARCH_INTERVALS)
// Sample rough weather.
vec2 uv = getGlobeUv(position);
WeatherSample weather = sampleWeather(uv, height, mipLevel);
if (any(greaterThan(weather.density, vec4(minDensity)))) {
// Sample detailed participating media.
// Note this assumes an homogeneous medium.
MediaSample media = sampleMedia(weather, position, uv, mipLevel, jitter);
if (media.extinction > minExtinction) {
extinctionSum += media.extinction;
maxOpticalDepth += media.extinction * stepSize;
transmittanceIntegral *= exp(-media.extinction * stepSize);
weightedDistanceSum += rayDistance * transmittanceIntegral;
transmittanceSum += transmittanceIntegral;
++sampleCount;
}
}
if (transmittanceIntegral <= minTransmittance) {
// A large amount of optical depth accumulates in the tail, beyond the
// point of minimum transmittance. The expected optical depth seems to
// decrease exponentially with the number of samples taken before reaching
// the minimum transmittance.
// See the discussion here: https://x.com/shotamatsuda/status/1886259549931520437
maxOpticalDepthTail = min(
opticalDepthTailScale * stepSize * exp(float(1 - sampleCount)),
stepSize * 0.5 // Excessive optical depth only introduces aliasing.
);
break; // Early termination
}
rayDistance += stepSize;
}
if (sampleCount == 0) {
return vec4(maxRayDistance, 0.0, 0.0, 0.0);
}
float frontDepth = min(weightedDistanceSum / transmittanceSum, maxRayDistance);
float meanExtinction = extinctionSum / float(sampleCount);
return vec4(frontDepth, meanExtinction, maxOpticalDepth, maxOpticalDepthTail);
}
void getRayNearFar(
const vec3 sunPosition,
const vec3 rayDirection,
out float rayNear,
out float rayFar
) {
vec4 firstIntersections = raySphereFirstIntersection(
sunPosition,
rayDirection,
vec3(0.0),
bottomRadius + vec4(shadowTopHeight, shadowBottomHeight, 0.0, 0.0)
);
rayNear = max(0.0, firstIntersections.x);
rayFar = firstIntersections.y;
if (rayFar < 0.0) {
rayFar = 1e6;
}
}
void cascade(
const int cascadeIndex,
const float mipLevel,
out vec4 outputColor,
out vec3 outputDepthVelocity
) {
vec2 clip = vUv * 2.0 - 1.0;
vec4 point = inverseShadowMatrices[cascadeIndex] * vec4(clip.xy, -1.0, 1.0);
point /= point.w;
vec3 sunPosition = (worldToECEFMatrix * vec4(point.xyz, 1.0)).xyz + altitudeCorrection;
vec3 rayDirection = normalize(-sunDirection);
float rayNear;
float rayFar;
getRayNearFar(sunPosition, rayDirection, rayNear, rayFar);
vec3 rayOrigin = rayNear * rayDirection + sunPosition;
float stbn = getSTBN();
vec4 color = marchClouds(rayOrigin, rayDirection, rayFar - rayNear, stbn, mipLevel);
outputColor = color;
// Velocity for temporal resolution.
#ifdef TEMPORAL_PASS
vec3 frontPosition = color.x * rayDirection + rayOrigin;
vec3 frontPositionWorld = (ecefToWorldMatrix * vec4(frontPosition - altitudeCorrection, 1.0)).xyz;
vec4 prevClip = reprojectionMatrices[cascadeIndex] * vec4(frontPositionWorld, 1.0);
prevClip /= prevClip.w;
vec2 prevUv = prevClip.xy * 0.5 + 0.5;
vec2 velocity = (vUv - prevUv) * resolution;
outputDepthVelocity = vec3(color.x, velocity);
#else // TEMPORAL_PASS
outputDepthVelocity = vec3(0.0);
#endif // TEMPORAL_PASS
}
// TODO: Calculate from the main camera frustum perhaps?
const float mipLevels[4] = float[4](0.0, 0.5, 1.0, 2.0);
void main() {
#pragma unroll_loop_start
for (int i = 0; i < 4; ++i) {
#if UNROLLED_LOOP_INDEX < CASCADE_COUNT
cascade(UNROLLED_LOOP_INDEX, mipLevels[i], outputColor[i], outputDepthVelocity[i]);
#endif // UNROLLED_LOOP_INDEX < CASCADE_COUNT
}
#pragma unroll_loop_end
}
`,iae=`precision highp float;
layout(location = 0) in vec3 position;
out vec2 vUv;
void main() {
vUv = position.xy * 0.5 + 0.5;
gl_Position = vec4(position.xy, 1.0, 1.0);
}
`,aae=`// Implements Structured Volume Sampling in fragment shader:
// https://github.com/huwb/volsample
// Implementation reference:
// https://www.shadertoy.com/view/ttVfDc
void getIcosahedralVertices(const vec3 direction, out vec3 v1, out vec3 v2, out vec3 v3) {
// Normalization scalers to fit dodecahedron to unit sphere.
const float a = 0.85065080835204; // phi / sqrt(2 + phi)
const float b = 0.5257311121191336; // 1 / sqrt(2 + phi)
// Derive the vertices of icosahedron where triangle intersects the direction.
// See: https://www.ppsloan.org/publications/AmbientDice.pdf
const float kT = 0.6180339887498948; // 1 / phi
const float kT2 = 0.38196601125010515; // 1 / phi^2
vec3 absD = abs(direction);
float selector1 = dot(absD, vec3(1.0, kT2, -kT));
float selector2 = dot(absD, vec3(-kT, 1.0, kT2));
float selector3 = dot(absD, vec3(kT2, -kT, 1.0));
v1 = selector1 > 0.0 ? vec3(a, b, 0.0) : vec3(-b, 0.0, a);
v2 = selector2 > 0.0 ? vec3(0.0, a, b) : vec3(a, -b, 0.0);
v3 = selector3 > 0.0 ? vec3(b, 0.0, a) : vec3(0.0, a, -b);
vec3 octantSign = sign(direction);
v1 *= octantSign;
v2 *= octantSign;
v3 *= octantSign;
}
void swapIfBigger(inout vec4 a, inout vec4 b) {
if (a.w > b.w) {
vec4 t = a;
a = b;
b = t;
}
}
void sortVertices(inout vec3 a, inout vec3 b, inout vec3 c) {
const vec3 base = vec3(0.5, 0.5, 1.0);
vec4 aw = vec4(a, dot(a, base));
vec4 bw = vec4(b, dot(b, base));
vec4 cw = vec4(c, dot(c, base));
swapIfBigger(aw, bw);
swapIfBigger(bw, cw);
swapIfBigger(aw, bw);
a = aw.xyz;
b = bw.xyz;
c = cw.xyz;
}
vec3 getPentagonalWeights(const vec3 direction, const vec3 v1, const vec3 v2, const vec3 v3) {
float d1 = dot(v1, direction);
float d2 = dot(v2, direction);
float d3 = dot(v3, direction);
vec3 w = exp(vec3(d1, d2, d3) * 40.0);
return w / (w.x + w.y + w.z);
}
vec3 getStructureNormal(
const vec3 direction,
const float jitter,
out vec3 a,
out vec3 b,
out vec3 c,
out vec3 weights
) {
getIcosahedralVertices(direction, a, b, c);
sortVertices(a, b, c);
weights = getPentagonalWeights(direction, a, b, c);
return jitter < weights.x
? a
: jitter < weights.x + weights.y
? b
: c;
}
vec3 getStructureNormal(const vec3 direction, const float jitter) {
vec3 a, b, c, weights;
return getStructureNormal(direction, jitter, a, b, c, weights);
}
// Reference: https://github.com/huwb/volsample/blob/master/src/unity/Assets/Shaders/RayMarchCore.cginc
void intersectStructuredPlanes(
const vec3 normal,
const vec3 rayOrigin,
const vec3 rayDirection,
const float samplePeriod,
out float stepOffset,
out float stepSize
) {
float NoD = dot(rayDirection, normal);
stepSize = samplePeriod / abs(NoD);
// Skips leftover bit to get from rayOrigin to first strata plane.
stepOffset = -mod(dot(rayOrigin, normal), samplePeriod) / NoD;
// mod() gives different results depending on if the arg is negative or
// positive. This line makes it consistent, and ensures the first sample is in
// front of the viewer.
if (stepOffset < 0.0) {
stepOffset += stepSize;
}
}
`;var rae=Object.defineProperty,ep=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&rae(e,t,a),a};class mh extends ch{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i}){super({name:"ShadowMaterial",glslVersion:ao,vertexShader:iae,fragmentShader:X0(Ca(nae,{core:{math:mA,raySphereIntersection:fy},types:aM,parameters:t9,structuredSampling:aae,clouds:e9})),uniforms:{...e,...t,...i,inverseShadowMatrices:new J(Array.from({length:4},()=>new ke)),reprojectionMatrices:new J(Array.from({length:4},()=>new ke)),resolution:new J(new de),frame:new J(0),stbnTexture:new J(null),maxIterationCount:new J(It.shadow.maxIterationCount),minStepSize:new J(It.shadow.minStepSize),maxStepSize:new J(It.shadow.maxStepSize),minDensity:new J(It.shadow.minDensity),minExtinction:new J(It.shadow.minExtinction),minTransmittance:new J(It.shadow.minTransmittance),opticalDepthTailScale:new J(2)},defines:{SHADOW:"1",TEMPORAL_PASS:"1",TEMPORAL_JITTER:"1"}}),this.localWeatherChannels="rgba",this.cascadeCount=It.shadow.cascadeCount,this.temporalPass=!0,this.temporalJitter=!0,this.shapeDetail=It.shapeDetail,this.turbulence=It.turbulence,this.cascadeCount=It.shadow.cascadeCount}setSize(e,t){this.uniforms.resolution.value.set(e,t)}}ep([AP("LOCAL_WEATHER_CHANNELS",{validate:n=>/^[rgba]{4}$/.test(n)})],mh.prototype,"localWeatherChannels");ep([dh("CASCADE_COUNT",{min:1,max:4})],mh.prototype,"cascadeCount");ep([dn("TEMPORAL_PASS")],mh.prototype,"temporalPass");ep([dn("TEMPORAL_JITTER")],mh.prototype,"temporalJitter");ep([dn("SHAPE_DETAIL")],mh.prototype,"shapeDetail");ep([dn("TURBULENCE")],mh.prototype,"turbulence");const sae=`precision highp float;
precision highp sampler2DArray;
#define VARIANCE_9_SAMPLES 1
#define VARIANCE_SAMPLER_ARRAY 1
#include "varianceClipping"
uniform sampler2DArray inputBuffer;
uniform sampler2DArray historyBuffer;
uniform vec2 texelSize;
uniform float varianceGamma;
uniform float temporalAlpha;
in vec2 vUv;
layout(location = 0) out vec4 outputColor[CASCADE_COUNT];
const ivec2 neighborOffsets[9] = ivec2[9](
ivec2(-1, -1),
ivec2(-1, 0),
ivec2(-1, 1),
ivec2(0, -1),
ivec2(0, 0),
ivec2(0, 1),
ivec2(1, -1),
ivec2(1, 0),
ivec2(1, 1)
);
vec4 getClosestFragment(const ivec3 coord) {
vec4 result = vec4(1e7, 0.0, 0.0, 0.0);
vec4 neighbor;
#pragma unroll_loop_start
for (int i = 0; i < 9; ++i) {
neighbor = texelFetchOffset(
inputBuffer,
coord + ivec3(0, 0, CASCADE_COUNT),
0,
neighborOffsets[i]
);
if (neighbor.r < result.r) {
result = neighbor;
}
}
#pragma unroll_loop_end
return result;
}
void cascade(const int cascadeIndex, out vec4 outputColor) {
ivec3 coord = ivec3(gl_FragCoord.xy, cascadeIndex);
vec4 current = texelFetch(inputBuffer, coord, 0);
vec4 depthVelocity = getClosestFragment(coord);
vec2 velocity = depthVelocity.gb * texelSize;
vec2 prevUv = vUv - velocity;
if (prevUv.x < 0.0 || prevUv.x > 1.0 || prevUv.y < 0.0 || prevUv.y > 1.0) {
outputColor = current;
return; // Rejection
}
vec4 history = texture(historyBuffer, vec3(prevUv, float(cascadeIndex)));
vec4 clippedHistory = varianceClipping(inputBuffer, coord, current, history, varianceGamma);
outputColor = mix(clippedHistory, current, temporalAlpha);
}
void main() {
#pragma unroll_loop_start
for (int i = 0; i < 4; ++i) {
#if UNROLLED_LOOP_INDEX < CASCADE_COUNT
cascade(UNROLLED_LOOP_INDEX, outputColor[i]);
#endif // UNROLLED_LOOP_INDEX < CASCADE_COUNT
}
#pragma unroll_loop_end
}
`,oae=`precision highp float;
layout(location = 0) in vec3 position;
out vec2 vUv;
void main() {
vUv = position.xy * 0.5 + 0.5;
gl_Position = vec4(position.xy, 1.0, 1.0);
}
`;var lae=Object.defineProperty,cae=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&lae(e,t,a),a};class r9 extends ch{constructor({inputBuffer:e=null,historyBuffer:t=null}={}){super({name:"ShadowResolveMaterial",glslVersion:ao,vertexShader:oae,fragmentShader:X0(Ca(sae,{varianceClipping:n9})),uniforms:{inputBuffer:new J(e),historyBuffer:new J(t),texelSize:new J(new de),varianceGamma:new J(1),temporalAlpha:new J(.01)},defines:{}}),this.cascadeCount=It.shadow.cascadeCount}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}}cae([dh("CASCADE_COUNT",{min:1,max:4})],r9.prototype,"cascadeCount");function e3(n){const e=new PU(1,1,1,{depthBuffer:!1});return e.texture.type=Xn,e.texture.minFilter=Ht,e.texture.magFilter=Ht,e.texture.name=n,e}class uae extends a9{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i,...a}){super("ShadowPass",a),this.width=0,this.height=0,this.currentMaterial=new mh({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i}),this.currentPass=new zO(this.currentMaterial),this.resolveMaterial=new r9,this.resolvePass=new zO(this.resolveMaterial),this.initRenderTargets()}initialize(e,t,i){this.currentPass.initialize(e,t,i),this.resolvePass.initialize(e,t,i)}initRenderTargets(){var r,s,o;(r=this.currentRenderTarget)==null||r.dispose(),(s=this.resolveRenderTarget)==null||s.dispose(),(o=this.historyRenderTarget)==null||o.dispose();const e=e3("Shadow"),t=this.temporalPass?e3("Shadow.A"):null,i=this.temporalPass?e3("Shadow.B"):null;this.currentRenderTarget=e,this.resolveRenderTarget=t,this.historyRenderTarget=i;const a=this.resolveMaterial.uniforms;a.inputBuffer.value=e.texture,a.historyBuffer.value=(i==null?void 0:i.texture)??null}copyShadow(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const a=e.cascades[i];t.inverseShadowMatrices.value[i].copy(a.inverseMatrix)}}copyReprojection(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const a=e.cascades[i];t.reprojectionMatrices.value[i].copy(a.matrix)}}swapBuffers(){Ql(this.historyRenderTarget!=null),Ql(this.resolveRenderTarget!=null);const e=this.historyRenderTarget,t=this.resolveRenderTarget;this.resolveRenderTarget=e,this.historyRenderTarget=t,this.resolveMaterial.uniforms.historyBuffer.value=t.texture}update(e,t,i){this.currentMaterial.uniforms.frame.value=t,this.copyShadow(),this.currentPass.render(e,null,this.currentRenderTarget),this.temporalPass&&(Ql(this.resolveRenderTarget!=null),this.resolvePass.render(e,null,this.resolveRenderTarget),this.copyReprojection(),this.swapBuffers())}setSize(e,t,i=this.shadow.cascadeCount){var a,r;this.width=e,this.height=t,this.currentMaterial.cascadeCount=i,this.resolveMaterial.cascadeCount=i,this.currentMaterial.setSize(e,t),this.resolveMaterial.setSize(e,t),this.currentRenderTarget.setSize(e,t,this.temporalPass?i*2:i),(a=this.resolveRenderTarget)==null||a.setSize(e,t,i),(r=this.historyRenderTarget)==null||r.setSize(e,t,i)}get outputBuffer(){return this.temporalPass?(Ql(this.historyRenderTarget!=null),this.historyRenderTarget.texture):this.currentRenderTarget.texture}get temporalPass(){return this.currentMaterial.temporalPass}set temporalPass(e){e!==this.temporalPass&&(this.currentMaterial.temporalPass=e,this.initRenderTargets(),this.setSize(this.width,this.height))}}function hae(n){return{scatteringCoefficient:new J(1),absorptionCoefficient:new J(0),coverage:new J(.3),localWeatherTexture:new J(n.localWeatherTexture),localWeatherRepeat:new J(n.localWeatherRepeat),localWeatherOffset:new J(n.localWeatherOffset),shapeTexture:new J(n.shapeTexture),shapeRepeat:new J(n.shapeRepeat),shapeOffset:new J(n.shapeOffset),shapeDetailTexture:new J(n.shapeDetailTexture),shapeDetailRepeat:new J(n.shapeDetailRepeat),shapeDetailOffset:new J(n.shapeDetailOffset),turbulenceTexture:new J(n.turbulenceTexture),turbulenceRepeat:new J(n.turbulenceRepeat),turbulenceDisplacement:new J(350)}}function fae(){return{minLayerHeights:new J(new zt),maxLayerHeights:new J(new zt),minIntervalHeights:new J(new L),maxIntervalHeights:new J(new L),densityScales:new J(new zt),shapeAmounts:new J(new zt),shapeDetailAmounts:new J(new zt),weatherExponents:new J(new zt),shapeAlteringBiases:new J(new zt),coverageFilterWidths:new J(new zt),minHeight:new J(0),maxHeight:new J(0),shadowTopHeight:new J(0),shadowBottomHeight:new J(0),shadowLayerMask:new J(new zt),densityProfile:new J({expTerms:new zt,exponents:new zt,linearTerms:new zt,constantTerms:new zt})}}const t3=[0,0,0,0];function dae(n,e){e.packValues("altitude",n.minLayerHeights.value),e.packSums("altitude","height",n.maxLayerHeights.value),e.packIntervalHeights(n.minIntervalHeights.value,n.maxIntervalHeights.value),e.packValues("densityScale",n.densityScales.value),e.packValues("shapeAmount",n.shapeAmounts.value),e.packValues("shapeDetailAmount",n.shapeDetailAmounts.value),e.packValues("weatherExponent",n.weatherExponents.value),e.packValues("shapeAlteringBias",n.shapeAlteringBiases.value),e.packValues("coverageFilterWidth",n.coverageFilterWidths.value);const t=n.densityProfile.value;e.packDensityProfiles("expTerm",t.expTerms),e.packDensityProfiles("exponent",t.exponents),e.packDensityProfiles("linearTerm",t.linearTerms),e.packDensityProfiles("constantTerm",t.constantTerms);let i=1/0,a=0,r=1/0,s=0;t3.fill(0);for(let o=0;o<e.length;++o){const{altitude:c,height:h,shadow:f}=e[o],d=c+h;h>0&&(c<i&&(i=c),f&&c<r&&(r=c),d>a&&(a=d),f&&d>s&&(s=d)),t3[o]=f?1:0}i!==1/0?(n.minHeight.value=i,n.maxHeight.value=a):(Ql(a===0),n.minHeight.value=0),r!==1/0?(n.shadowBottomHeight.value=r,n.shadowTopHeight.value=s):(Ql(s===0),n.shadowBottomHeight.value=0),n.shadowLayerMask.value.fromArray(t3)}function pae(n,e){return{bottomRadius:new J(n.bottomRadius),topRadius:new J(n.topRadius),worldToECEFMatrix:new J(e.worldToECEFMatrix),ecefToWorldMatrix:new J(e.ecefToWorldMatrix),altitudeCorrection:new J(e.altitudeCorrection),sunDirection:new J(e.sunDirection)}}const mae=`uniform sampler2D cloudsBuffer;
void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
#ifdef SKIP_RENDERING
outputColor = inputColor;
#else // SKIP_RENDERING
vec4 clouds = texture(cloudsBuffer, uv);
outputColor.rgb = inputColor.rgb * (1.0 - clouds.a) + clouds.rgb;
outputColor.a = inputColor.a * (1.0 - clouds.a) + clouds.a;
#endif // SKIP_RENDERING
}
`;var gae=Object.defineProperty,vae=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&gae(e,t,a),a};const tm=new L,_ae=new de,xae=new Et,yae=["maxIterationCount","minStepSize","maxStepSize","maxRayDistance","perspectiveStepScale","minDensity","minExtinction","minTransmittance","maxIterationCountToSun","maxIterationCountToGround","minSecondaryStepSize","secondaryStepScale","maxShadowFilterRadius","maxShadowLengthIterationCount","minShadowLengthStepSize","maxShadowLengthRayDistance","hazeDensityScale","hazeExponent","hazeScatteringCoefficient","hazeAbsorptionCoefficient"],Sae=["multiScatteringOctaves","accurateSunSkyLight","accuratePhaseFunction"],Tae=["maxIterationCount","minStepSize","maxStepSize","minDensity","minExtinction","minTransmittance","opticalDepthTailScale"],Eae=["temporalJitter"],Mae=["temporalPass"],bae=["cascadeCount","mapSize","maxFar","farScale","splitMode","splitLambda"],Io={type:"change"},s9={resolutionScale:It.resolutionScale,width:as.AUTO_SIZE,height:as.AUTO_SIZE};class o9 extends m0{constructor(e=new Tc,t,i=Y0.DEFAULT){var f,d,m,g;super("CloudsEffect",mae,{attributes:Jo.DEPTH,uniforms:new Map([["cloudsBuffer",new J(null)]])}),this.camera=e,this.atmosphere=i,this.cloudLayers=a1.DEFAULT.clone(),this.correctAltitude=!0,this.localWeatherRepeat=new de().setScalar(100),this.localWeatherOffset=new de,this.shapeRepeat=new L().setScalar(3e-4),this.shapeOffset=new L,this.shapeDetailRepeat=new L().setScalar(.006),this.shapeDetailOffset=new L,this.turbulenceRepeat=new de().setScalar(20),this.worldToECEFMatrix=new ke,this.ecefToWorldMatrix=new ke,this.altitudeCorrection=new L,this.sunDirection=new L,this.localWeatherVelocity=new de,this.shapeVelocity=new L,this.shapeDetailVelocity=new L,this._atmosphereOverlay=null,this._atmosphereShadow=null,this._atmosphereShadowLength=null,this.events=new tr,this.frame=0,this.shadowCascadeCount=0,this.shadowMapSize=new de,this.onResolutionChange=()=>{this.setSize(this.resolution.baseWidth,this.resolution.baseHeight)},this.skipRendering=!0;const{resolutionScale:a,width:r,height:s,resolutionX:o=r,resolutionY:c=s}={...s9,...t};this.shadowMaps=new Vie({cascadeCount:It.shadow.cascadeCount,mapSize:It.shadow.mapSize,splitLambda:.6}),this.parameterUniforms=hae({localWeatherTexture:((f=this.proceduralLocalWeather)==null?void 0:f.texture)??null,localWeatherRepeat:this.localWeatherRepeat,localWeatherOffset:this.localWeatherOffset,shapeTexture:((d=this.proceduralShape)==null?void 0:d.texture)??null,shapeRepeat:this.shapeRepeat,shapeOffset:this.shapeOffset,shapeDetailTexture:((m=this.proceduralShapeDetail)==null?void 0:m.texture)??null,shapeDetailRepeat:this.shapeDetailRepeat,shapeDetailOffset:this.shapeDetailOffset,turbulenceTexture:((g=this.proceduralTurbulence)==null?void 0:g.texture)??null,turbulenceRepeat:this.turbulenceRepeat}),this.layerUniforms=fae(),this.atmosphereUniforms=pae(i,{worldToECEFMatrix:this.worldToECEFMatrix,ecefToWorldMatrix:this.ecefToWorldMatrix,altitudeCorrection:this.altitudeCorrection,sunDirection:this.sunDirection});const h={shadow:this.shadowMaps,parameterUniforms:this.parameterUniforms,layerUniforms:this.layerUniforms,atmosphereUniforms:this.atmosphereUniforms};this.shadowPass=new uae(h),this.shadowPass.mainCamera=e,this.cloudsPass=new eae(h,i),this.cloudsPass.mainCamera=e,this.clouds=gO(vO({},this.cloudsPass.currentMaterial,yae),this.cloudsPass.currentMaterial,Sae),this.shadow=gO(vO({},this.shadowPass.currentMaterial,Tae),this.shadowPass.currentMaterial,Eae,this.shadowPass,Mae,this.shadowMaps,bae),this.resolution=new as(this,o,c,a),this.resolution.addEventListener("change",this.onResolutionChange)}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e,this.shadowPass.mainCamera=e,this.cloudsPass.mainCamera=e}initialize(e,t,i){this.shadowPass.initialize(e,t,i),this.cloudsPass.initialize(e,t,i)}updateSharedUniforms(e){dae(this.layerUniforms,this.cloudLayers);const{parameterUniforms:t}=this;t.localWeatherOffset.value.add(_ae.copy(this.localWeatherVelocity).multiplyScalar(e)),t.shapeOffset.value.add(tm.copy(this.shapeVelocity).multiplyScalar(e)),t.shapeDetailOffset.value.add(tm.copy(this.shapeDetailVelocity).multiplyScalar(e));const i=this.worldToECEFMatrix;this.ecefToWorldMatrix.copy(i).invert();const a=this.camera.getWorldPosition(tm).applyMatrix4(this.worldToECEFMatrix),r=this.altitudeCorrection;this.correctAltitude?gA(a,this.atmosphere.bottomRadius,this.ellipsoid,r):r.setScalar(0);const s=this.ellipsoid.getSurfaceNormal(a,tm),o=this.sunDirection.dot(s),c=bP(1e6,1e3,o),h=xae.setFromMatrix4(i).transpose();this.shadowMaps.update(this.camera,tm.copy(this.sunDirection).applyMatrix3(h),c)}updateWeatherTextureChannels(){const e=this.cloudLayers.localWeatherChannels;this.cloudsPass.currentMaterial.localWeatherChannels=e,this.shadowPass.currentMaterial.localWeatherChannels=e}updateAtmosphereComposition(){const{shadowMaps:e,shadowPass:t,cloudsPass:i}=this,a=t.currentMaterial.uniforms,r=i.currentMaterial.uniforms,s=this._atmosphereOverlay,o=Object.assign(this._atmosphereOverlay??{},{map:i.outputBuffer});s!==o&&(this._atmosphereOverlay=o,Io.target=this,Io.property="atmosphereOverlay",this.events.dispatchEvent(Io));const c=this._atmosphereShadow,h=Object.assign(this._atmosphereShadow??{},{map:t.outputBuffer,mapSize:e.mapSize,cascadeCount:e.cascadeCount,intervals:r.shadowIntervals.value,matrices:r.shadowMatrices.value,inverseMatrices:a.inverseShadowMatrices.value,far:e.far,topHeight:r.shadowTopHeight.value});c!==h&&(this._atmosphereShadow=h,Io.target=this,Io.property="atmosphereShadow",this.events.dispatchEvent(Io));const f=this._atmosphereShadowLength,d=i.shadowLengthBuffer!=null?Object.assign(this._atmosphereShadowLength??{},{map:i.shadowLengthBuffer}):null;f!==d&&(this._atmosphereShadowLength=d,Io.target=this,Io.property="atmosphereShadowLength",this.events.dispatchEvent(Io))}update(e,t,i=0){var o,c,h,f;const{shadowMaps:a,shadowPass:r,cloudsPass:s}=this;if(a.cascadeCount!==this.shadowCascadeCount||!a.mapSize.equals(this.shadowMapSize)){const{width:d,height:m}=a.mapSize,g=a.cascadeCount;this.shadowMapSize.set(d,m),this.shadowCascadeCount=g,r.setSize(d,m,g),s.setShadowSize(d,m,g)}(o=this.proceduralLocalWeather)==null||o.render(e,i),(c=this.proceduralShape)==null||c.render(e,i),(h=this.proceduralShapeDetail)==null||h.render(e,i),(f=this.proceduralTurbulence)==null||f.render(e,i),++this.frame,this.updateSharedUniforms(i),this.updateWeatherTextureChannels(),r.update(e,this.frame,i),s.shadowBuffer=r.outputBuffer,s.update(e,this.frame,i),this.updateAtmosphereComposition(),this.uniforms.get("cloudsBuffer").value=this.cloudsPass.outputBuffer}setSize(e,t){const{resolution:i}=this;i.setBaseSize(e,t);const{width:a,height:r}=i;this.cloudsPass.setSize(a,r)}setDepthTexture(e,t){this.shadowPass.setDepthTexture(e,t),this.cloudsPass.setDepthTexture(e,t)}set qualityPreset(e){const{clouds:t,shadow:i,...a}=Wie[e];Object.assign(this,a),Object.assign(this.clouds,t),Object.assign(this.shadow,i)}get localWeatherTexture(){return this.proceduralLocalWeather??this.parameterUniforms.localWeatherTexture.value}set localWeatherTexture(e){e instanceof Nn||e==null?(this.proceduralLocalWeather=void 0,this.parameterUniforms.localWeatherTexture.value=e):(this.proceduralLocalWeather=e,this.parameterUniforms.localWeatherTexture.value=e.texture)}get shapeTexture(){return this.proceduralShape??this.parameterUniforms.shapeTexture.value}set shapeTexture(e){e instanceof is||e==null?(this.proceduralShape=void 0,this.parameterUniforms.shapeTexture.value=e):(this.proceduralShape=e,this.parameterUniforms.shapeTexture.value=e.texture)}get shapeDetailTexture(){return this.proceduralShapeDetail??this.parameterUniforms.shapeDetailTexture.value}set shapeDetailTexture(e){e instanceof is||e==null?(this.proceduralShapeDetail=void 0,this.parameterUniforms.shapeDetailTexture.value=e):(this.proceduralShapeDetail=e,this.parameterUniforms.shapeDetailTexture.value=e.texture)}get turbulenceTexture(){return this.proceduralTurbulence??this.parameterUniforms.turbulenceTexture.value}set turbulenceTexture(e){e instanceof Nn||e==null?(this.proceduralTurbulence=void 0,this.parameterUniforms.turbulenceTexture.value=e):(this.proceduralTurbulence=e,this.parameterUniforms.turbulenceTexture.value=e.texture)}get stbnTexture(){return this.cloudsPass.currentMaterial.uniforms.stbnTexture.value}set stbnTexture(e){this.cloudsPass.currentMaterial.uniforms.stbnTexture.value=e,this.shadowPass.currentMaterial.uniforms.stbnTexture.value=e}get resolutionScale(){return this.resolution.scale}set resolutionScale(e){this.resolution.scale=e}get temporalUpscale(){return this.cloudsPass.temporalUpscale}set temporalUpscale(e){this.cloudsPass.temporalUpscale=e}get lightShafts(){return this.cloudsPass.lightShafts}set lightShafts(e){this.cloudsPass.lightShafts=e}get shapeDetail(){return this.cloudsPass.currentMaterial.shapeDetail}set shapeDetail(e){this.cloudsPass.currentMaterial.shapeDetail=e,this.shadowPass.currentMaterial.shapeDetail=e}get turbulence(){return this.cloudsPass.currentMaterial.turbulence}set turbulence(e){this.cloudsPass.currentMaterial.turbulence=e,this.shadowPass.currentMaterial.turbulence=e}get haze(){return this.cloudsPass.currentMaterial.haze}set haze(e){this.cloudsPass.currentMaterial.haze=e}get scatteringCoefficient(){return this.parameterUniforms.scatteringCoefficient.value}set scatteringCoefficient(e){this.parameterUniforms.scatteringCoefficient.value=e}get absorptionCoefficient(){return this.parameterUniforms.absorptionCoefficient.value}set absorptionCoefficient(e){this.parameterUniforms.absorptionCoefficient.value=e}get coverage(){return this.parameterUniforms.coverage.value}set coverage(e){this.parameterUniforms.coverage.value=e}get turbulenceDisplacement(){return this.parameterUniforms.turbulenceDisplacement.value}set turbulenceDisplacement(e){this.parameterUniforms.turbulenceDisplacement.value=e}get scatterAnisotropy1(){return this.cloudsPass.currentMaterial.scatterAnisotropy1}set scatterAnisotropy1(e){this.cloudsPass.currentMaterial.scatterAnisotropy1=e}get scatterAnisotropy2(){return this.cloudsPass.currentMaterial.scatterAnisotropy2}set scatterAnisotropy2(e){this.cloudsPass.currentMaterial.scatterAnisotropy2=e}get scatterAnisotropyMix(){return this.cloudsPass.currentMaterial.scatterAnisotropyMix}set scatterAnisotropyMix(e){this.cloudsPass.currentMaterial.scatterAnisotropyMix=e}get skyIrradianceScale(){return this.skyLightScale}set skyIrradianceScale(e){this.skyLightScale=e}get skyLightScale(){return this.cloudsPass.currentMaterial.uniforms.skyLightScale.value}set skyLightScale(e){this.cloudsPass.currentMaterial.uniforms.skyLightScale.value=e}get groundIrradianceScale(){return this.groundBounceScale}set groundIrradianceScale(e){this.groundBounceScale=e}get groundBounceScale(){return this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value}set groundBounceScale(e){this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value=e}get powderScale(){return this.cloudsPass.currentMaterial.uniforms.powderScale.value}set powderScale(e){this.cloudsPass.currentMaterial.uniforms.powderScale.value=e}get powderExponent(){return this.cloudsPass.currentMaterial.uniforms.powderExponent.value}set powderExponent(e){this.cloudsPass.currentMaterial.uniforms.powderExponent.value=e}get atmosphereOverlay(){return this._atmosphereOverlay}get atmosphereShadow(){return this._atmosphereShadow}get atmosphereShadowLength(){return this._atmosphereShadowLength}get irradianceTexture(){return this.cloudsPass.currentMaterial.irradianceTexture}set irradianceTexture(e){this.cloudsPass.currentMaterial.irradianceTexture=e}get scatteringTexture(){return this.cloudsPass.currentMaterial.scatteringTexture}set scatteringTexture(e){this.cloudsPass.currentMaterial.scatteringTexture=e}get transmittanceTexture(){return this.cloudsPass.currentMaterial.transmittanceTexture}set transmittanceTexture(e){this.cloudsPass.currentMaterial.transmittanceTexture=e}get singleMieScatteringTexture(){return this.cloudsPass.currentMaterial.singleMieScatteringTexture}set singleMieScatteringTexture(e){this.cloudsPass.currentMaterial.singleMieScatteringTexture=e}get higherOrderScatteringTexture(){return this.cloudsPass.currentMaterial.higherOrderScatteringTexture}set higherOrderScatteringTexture(e){this.cloudsPass.currentMaterial.higherOrderScatteringTexture=e}get ellipsoid(){return this.cloudsPass.currentMaterial.ellipsoid}set ellipsoid(e){this.cloudsPass.currentMaterial.ellipsoid=e}get sunAngularRadius(){return this.cloudsPass.currentMaterial.sunAngularRadius}set sunAngularRadius(e){this.cloudsPass.currentMaterial.sunAngularRadius=e}}vae([dn("SKIP_RENDERING")],o9.prototype,"skipRendering");const Aae=128,Rae=32,xy="45a1c6c1bb9fd38b3680fd120795ff4c32df68ff",wae=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${xy}/packages/clouds/assets/local_weather.png`,Cae=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${xy}/packages/clouds/assets/shape.bin`,Nae=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${xy}/packages/clouds/assets/shape_detail.bin`,Dae=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${xy}/packages/clouds/assets/turbulence.png`,l9=be.createContext(null),Oae=({layers:n,disableDefault:e=!1,children:t})=>{const[i,a]=be.useState();return be.useLayoutEffect(()=>{n.set(e?Array(4).fill(Ts.DEFAULT):a1.DEFAULT),a({layers:n,indexPool:[0,1,2,3],disableDefault:e})},[n,e]),i!=null&&Nt.jsx(l9.Provider,{value:i,children:t})};function BO(n,e){const t=be.useMemo(()=>typeof n=="string"?new Fb().load(n,i=>{i.minFilter=_U,i.magFilter=Ht,i.wrapS=Ta,i.wrapT=Ta,i.colorSpace=Na,i.needsUpdate=!0}):void 0,[n]);return be.useEffect(()=>{if(t!=null)return()=>{t.dispose()}},[t]),(typeof n=="string"?t:n)??null}function HO(n,e){const t=be.useMemo(()=>typeof n=="string"?new xu(is,RP,{width:e,height:e,depth:e,format:bs,minFilter:Ht,magFilter:Ht,wrapS:Ta,wrapT:Ta,wrapR:Ta,colorSpace:Na}).load(n):void 0,[n,e]);return be.useEffect(()=>{if(t!=null)return()=>{t.dispose()}},[t]),(typeof n=="string"?t:n)??null}function Lae(n){const e=be.useMemo(()=>typeof n=="string"?new wP().load(n):void 0,[n]);return be.useEffect(()=>{if(e!=null)return()=>{e.dispose()}},[e]),(typeof n=="string"?e:n)??null}const Iae=({ref:n,disableDefaultLayers:e=!1,localWeatherTexture:t=wae,shapeTexture:i=Cae,shapeDetailTexture:a=Nae,turbulenceTexture:r=Dae,stbnTexture:s=nP,children:o,...c})=>{const{textures:h,transientStates:f,...d}=be.useContext(EA),[m,g]=KP({...s9,...d,...h,...c}),x=be.useMemo(()=>new o9,[]);be.useEffect(()=>()=>{x.dispose()},[x]),Ac(()=>{f!=null&&(x.sunDirection.copy(f.sunDirection),x.worldToECEFMatrix.copy(f.worldToECEFMatrix))}),be.useEffect(()=>{if(f!=null)return f.overlay=x.atmosphereOverlay,f.shadow=x.atmosphereShadow,f.shadowLength=x.atmosphereShadowLength,()=>{f.overlay=null,f.shadow=null,f.shadowLength=null}},[x,f]);const T=be.useCallback(C=>{if(f!=null)switch(C.property){case"atmosphereOverlay":f.overlay=x.atmosphereOverlay;break;case"atmosphereShadow":f.shadow=x.atmosphereShadow;break;case"atmosphereShadowLength":f.shadowLength=x.atmosphereShadowLength;break}},[x,f]);be.useEffect(()=>(x.events.addEventListener("change",T),()=>{x.events.removeEventListener("change",T)}),[x,T]),Qi(({gl:C})=>C);const S=BO(t),v=HO(i,Aae),y=HO(a,Rae),E=BO(r),b=Lae(s),{camera:D}=be.useContext(rA);return Nt.jsxs(Nt.Fragment,{children:[Nt.jsx("primitive",{ref:n,object:x,mainCamera:D,...m,localWeatherTexture:S,shapeTexture:v,shapeDetailTexture:y,turbulenceTexture:E,stbnTexture:b,...g}),Nt.jsx(Oae,{layers:x.cloudLayers,disableDefault:e,children:o})]})},Uae=({ref:n,index:e,...t})=>{const i=be.useContext(l9);if(i==null)throw new Error("CloudLayer can only be used within the Clouds component!");const{layers:a,indexPool:r,disableDefault:s}=i,[o,c]=be.useState();if(be.useLayoutEffect(()=>{if(e!=null){const h=r.indexOf(e);if(h!==-1)return r.splice(h,1),c(e),()=>{r.push(e),c(void 0)}}else{const h=r.sort((f,d)=>f-d).shift();if(h!=null)return c(h),()=>{r.push(h),c(void 0)}}},[e,a,r]),be.useLayoutEffect(()=>{if(o==null)return;const h=a[o];return()=>{h.copy(s?Ts.DEFAULT:a1.DEFAULT[o])}},[a,o,s]),be.useEffect(()=>{o!=null&&(typeof n=="function"?n(a[o]):n!=null&&(n.current=a[o]))},[n,a,o]),o!=null){const h=a[o];h.copy(s?Ts.DEFAULT:a1.DEFAULT[o]),h.set(t)}return null},c9="/pkg/atmosphere/",Pae=`${c9}ai.vrm`,zae=`${c9}fly.vrma`,rM=6378137,Bae=5*60*1e3,Hae=100,Fae=new Date("2024-06-21T12:00:00"),FO=[{name:"Clear (快晴)",coverage:.1,layers:[{channel:"r",altitude:1500,height:500,densityScale:0},{channel:"g",altitude:2500,height:800,densityScale:0},{channel:"b",altitude:7500,height:500,densityScale:.1}]},{name:"Sunny (晴れ)",coverage:.4,layers:[{channel:"r",altitude:1500,height:500,densityScale:.4},{channel:"g",altitude:2500,height:800,densityScale:0},{channel:"b",altitude:7500,height:500,densityScale:.2}]},{name:"Cloudy (曇り)",coverage:.75,layers:[{channel:"r",altitude:1500,height:500,densityScale:.6},{channel:"g",altitude:2e3,height:1e3,densityScale:.5},{channel:"b",altitude:7500,height:500,densityScale:0}]}];function Gae(){const{gl:n}=Qi(),e=be.useRef(),t=be.useRef(),i=be.useRef(new Date(Fae)),[a,r]=be.useState(FO[1]);return be.useEffect(()=>{n.toneMapping=ns,n.toneMappingExposure=10},[n]),be.useEffect(()=>{const s=setInterval(()=>{r(o=>{const c=FO.filter(f=>f.name!==o.name),h=c[Math.floor(Math.random()*c.length)];return console.log(`[Weather] Changing to: ${h.name}`),h})},Bae);return()=>clearInterval(s)},[]),Ac((s,o)=>{const c=i.current,h=o*Hae*1e3;if(c.setTime(c.getTime()+h),t.current&&t.current.updateByDate(c),e.current){const f=c.getHours()+c.getMinutes()/60+c.getSeconds()/3600,d=$t.mapLinear(f,6,18,0,Math.PI),m=-Math.cos(d),g=Math.sin(d);f<6||f>18?(e.current.position.set(0,-1,0),e.current.intensity=0):(e.current.position.set(m,g,.2),e.current.intensity=$t.lerp(.5,3,g))}}),Nt.jsxs(Nt.Fragment,{children:[Nt.jsx(V8,{makeDefault:!0,position:[0,rM+2e3,0],near:1,far:1e7,fov:45}),Nt.jsx("directionalLight",{ref:e,position:[0,1,0],intensity:3,castShadow:!0}),Nt.jsx(Rie,{ref:t,children:Nt.jsxs(uee,{multisampling:0,disableNormalPass:!1,children:[Nt.jsx(Iae,{disableDefaultLayers:!0,coverage:a.coverage,children:a.layers.map((s,o)=>Nt.jsx(Uae,{channel:s.channel,altitude:s.altitude,height:s.height,densityScale:s.densityScale,shapeAmount:.5},o))}),Nt.jsx(Cie,{sky:!0,sunLight:!0,skyLight:!0}),Nt.jsx(dee,{mode:Ya.AGX})]})}),Nt.jsx(Vae,{})]})}function Vae(){return Ac(n=>{const e=n.clock.getElapsedTime()*.05,t=2e3,i=5e3;n.camera.position.x=Math.sin(e)*i,n.camera.position.z=Math.cos(e)*i,n.camera.position.y=rM+t;const a=new L(Math.sin(e+.1)*i,rM+t,Math.cos(e+.1)*i);n.camera.lookAt(a)}),null}function kae(){const n=be.useRef(null),e=be.useRef(null),t=Gx(qN,Pae,a=>{a.register(r=>new sJ(r))}),i=Gx(qN,zae,a=>{a.register(r=>new VJ(r))});return be.useEffect(()=>{var r;const a=t.userData.vrm;if(e.current=a,fh.removeUnnecessaryJoints(a.scene),a.humanoid.resetPose(),a.scene.rotation.y=Math.PI,(r=i.userData.vrmAnimations)!=null&&r[0]){const s=PJ(i.userData.vrmAnimations[0],a);n.current=new C6(a.scene),n.current.clipAction(s).play()}},[t,i]),Ac((a,r)=>{var s,o;(s=n.current)==null||s.update(r),(o=e.current)==null||o.update(r)}),Nt.jsx("primitive",{object:t.scene})}function Wae(){return Nt.jsxs(m8,{gl:{alpha:!0,antialias:!0},children:[Nt.jsx(V8,{makeDefault:!0,position:[0,1.5,3],fov:30}),Nt.jsx("directionalLight",{position:[-1,1,1],intensity:1.5}),Nt.jsx("ambientLight",{intensity:1}),Nt.jsx("spotLight",{position:[0,2,-2],intensity:3,color:"#ffdcb4"}),Nt.jsx(be.Suspense,{fallback:null,children:Nt.jsx(kae,{})}),Nt.jsx($J,{target:[0,1.2,0]})]})}function Xae(){return Nt.jsx(m8,{children:Nt.jsx(Gae,{})})}function Yae(){const n={position:"absolute",top:0,left:0,width:"100%",height:"100%"};return Nt.jsxs("div",{style:{position:"relative",width:"100vw",height:"100vh",background:"#000"},children:[Nt.jsx("div",{style:{...n,zIndex:0},children:Nt.jsx(Xae,{})}),Nt.jsx("div",{style:{...n,zIndex:1,pointerEvents:"none"},children:Nt.jsx("div",{style:{width:"100%",height:"100%",pointerEvents:"auto"},children:Nt.jsx(Wae,{})})})]})}oF.createRoot(document.getElementById("root")).render(Nt.jsx(hM.StrictMode,{children:Nt.jsx(Yae,{})}));