@iwsdk/vite-plugin-dev 1.0.1-rc.0 → 1.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/bundle-feature-gates.d.ts +9 -0
- package/dist/index.js +8704 -7942
- package/dist/index.js.map +1 -1
- package/dist/injection/chunks/_iwsdk-legacy-capture-B-A3EajS.js +1 -0
- package/dist/injection/chunks/bedroom-DETf9sEz.js +1 -0
- package/dist/injection/chunks/conference_room-CqY6mchI.js +1 -0
- package/dist/injection/chunks/home_office-BxWjiBZF.js +1 -0
- package/dist/injection/chunks/index-C3rlN7Lf.js +1 -0
- package/dist/injection/chunks/injection-template-9pnR-F15.js +984 -0
- package/dist/injection/chunks/kitchen-X_P3Lfoy.js +1 -0
- package/dist/injection/chunks/music_studio-glBmJOMe.js +1 -0
- package/dist/injection/chunks/open_office-BEqVZ5xR.js +1 -0
- package/dist/injection/chunks/open_studio-CVCR0jsb.js +1 -0
- package/dist/injection/chunks/sunlit_living_room-1m7CU_6o.js +1 -0
- package/dist/injection/runtime.js +1 -0
- package/dist/injection-bundler.d.ts +24 -1
- package/dist/injection-template.d.ts +3 -1
- package/dist/types.d.ts +18 -6
- package/package.json +8 -8
- package/dist/injection-bundle.js +0 -1045
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,i={exports:{}},r={};var s,a={exports:{}},o={};a.exports=function(){if(s)return o;s=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),f=Symbol.iterator,m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||m}function x(){}function b(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||m}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},x.prototype=y.prototype;var _=b.prototype=new x;_.constructor=b,g(_,y.prototype),_.isPureReactComponent=!0;var w=Array.isArray;function S(){}var M={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(t,n,i){var r=i.ref;return{$$typeof:e,type:t,key:n,ref:void 0!==r?r:null,props:i}}function A(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var R=/\/+/g;function C(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,i={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return i[e]})):t.toString(36);var n,i}function P(n,i,r,s,a){var o=typeof n;"undefined"!==o&&"boolean"!==o||(n=null);var l,c,u=!1;if(null===n)u=!0;else switch(o){case"bigint":case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0;break;case d:return P((u=n._init)(n._payload),i,r,s,a)}}if(u)return a=a(n),u=""===s?"."+C(n,0):s,w(a)?(r="",null!=u&&(r=u.replace(R,"$&/")+"/"),P(a,i,r,"",function(e){return e})):null!=a&&(A(a)&&(l=a,c=r+(null==a.key||n&&n.key===a.key?"":(""+a.key).replace(R,"$&/")+"/")+u,a=E(l.type,c,l.props)),i.push(a)),1;u=0;var h,p=""===s?".":s+":";if(w(n))for(var m=0;m<n.length;m++)u+=P(s=n[m],i,r,o=p+C(s,m),a);else if("function"==typeof(m=null===(h=n)||"object"!=typeof h?null:"function"==typeof(h=f&&h[f]||h["@@iterator"])?h:null))for(n=m.call(n),m=0;!(s=n.next()).done;)u+=P(s=s.value,i,r,o=p+C(s,m++),a);else if("object"===o){if("function"==typeof n.then)return P(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(S,S):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(n),i,r,s,a);throw i=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===i?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.")}return u}function I(e,t,n){if(null==e)return e;var i=[],r=0;return P(e,i,"","",function(e){return t.call(n,e,r++)}),i}function L(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var D="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},N={map:I,forEach:function(e,t,n){I(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return I(e,function(){t++}),t},toArray:function(e){return I(e,function(e){return e})||[]},only:function(e){if(!A(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};return o.Activity=p,o.Children=N,o.Component=y,o.Fragment=n,o.Profiler=r,o.PureComponent=b,o.StrictMode=i,o.Suspense=u,o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=M,o.__COMPILER_RUNTIME={__proto__:null,c:function(e){return M.H.useMemoCache(e)}},o.cache=function(e){return function(){return e.apply(null,arguments)}},o.cacheSignal=function(){return null},o.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var i=g({},e.props),r=e.key;if(null!=t)for(s in void 0!==t.key&&(r=""+t.key),t)!T.call(t,s)||"key"===s||"__self"===s||"__source"===s||"ref"===s&&void 0===t.ref||(i[s]=t[s]);var s=arguments.length-2;if(1===s)i.children=n;else if(1<s){for(var a=Array(s),o=0;o<s;o++)a[o]=arguments[o+2];i.children=a}return E(e.type,r,i)},o.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:a,_context:e},e},o.createElement=function(e,t,n){var i,r={},s=null;if(null!=t)for(i in void 0!==t.key&&(s=""+t.key),t)T.call(t,i)&&"key"!==i&&"__self"!==i&&"__source"!==i&&(r[i]=t[i]);var a=arguments.length-2;if(1===a)r.children=n;else if(1<a){for(var o=Array(a),l=0;l<a;l++)o[l]=arguments[l+2];r.children=o}if(e&&e.defaultProps)for(i in a=e.defaultProps)void 0===r[i]&&(r[i]=a[i]);return E(e,s,r)},o.createRef=function(){return{current:null}},o.forwardRef=function(e){return{$$typeof:c,render:e}},o.isValidElement=A,o.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:L}},o.memo=function(e,t){return{$$typeof:h,type:e,compare:void 0===t?null:t}},o.startTransition=function(e){var t=M.T,n={};M.T=n;try{var i=e(),r=M.S;null!==r&&r(n,i),"object"==typeof i&&null!==i&&"function"==typeof i.then&&i.then(S,D)}catch(e){D(e)}finally{null!==t&&null!==n.types&&(t.types=n.types),M.T=t}},o.unstable_useCacheRefresh=function(){return M.H.useCacheRefresh()},o.use=function(e){return M.H.use(e)},o.useActionState=function(e,t,n){return M.H.useActionState(e,t,n)},o.useCallback=function(e,t){return M.H.useCallback(e,t)},o.useContext=function(e){return M.H.useContext(e)},o.useDebugValue=function(){},o.useDeferredValue=function(e,t){return M.H.useDeferredValue(e,t)},o.useEffect=function(e,t){return M.H.useEffect(e,t)},o.useEffectEvent=function(e){return M.H.useEffectEvent(e)},o.useId=function(){return M.H.useId()},o.useImperativeHandle=function(e,t,n){return M.H.useImperativeHandle(e,t,n)},o.useInsertionEffect=function(e,t){return M.H.useInsertionEffect(e,t)},o.useLayoutEffect=function(e,t){return M.H.useLayoutEffect(e,t)},o.useMemo=function(e,t){return M.H.useMemo(e,t)},o.useOptimistic=function(e,t){return M.H.useOptimistic(e,t)},o.useReducer=function(e,t,n){return M.H.useReducer(e,t,n)},o.useRef=function(e){return M.H.useRef(e)},o.useState=function(e){return M.H.useState(e)},o.useSyncExternalStore=function(e,t,n){return M.H.useSyncExternalStore(e,t,n)},o.useTransition=function(){return M.H.useTransition()},o.version="19.2.8",o}();var l=a.exports,c=t(l);i.exports=function(){if(n)return r;n=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function i(t,n,i){var r=null;if(void 0!==i&&(r=""+i),void 0!==n.key&&(r=""+n.key),"key"in n)for(var s in i={},n)"key"!==s&&(i[s]=n[s]);else i=n;return n=i.ref,{$$typeof:e,type:t,key:r,ref:void 0!==n?n:null,props:i}}return r.Fragment=t,r.jsx=i,r.jsxs=i,r}();var u=i.exports,h="-ms-",d="-moz-",p="-webkit-",f="comm",m="rule",g="decl",v="@keyframes",y=Math.abs,x=String.fromCharCode,b=Object.assign;function _(e){return e.trim()}function w(e,t){return(e=t.exec(e))?e[0]:e}function S(e,t,n){return e.replace(t,n)}function M(e,t,n){return e.indexOf(t,n)}function T(e,t){return 0|e.charCodeAt(t)}function E(e,t,n){return e.slice(t,n)}function A(e){return e.length}function R(e){return e.length}function C(e,t){return t.push(e),e}function P(e,t){return e.filter(function(e){return!w(e,t)})}var I,L,D=1,N=1,O=0,F=0,k=0,U="";function z(e,t,n,i,r,s,a,o){return{value:e,root:t,parent:n,type:i,props:r,children:s,line:D,column:N,length:a,return:"",siblings:o}}function B(e,t){return b(z("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function V(e){for(;e.root;)e=B(e.root,{children:[e]});C(e,e.siblings)}function G(){return k=F>0?T(U,--F):0,N--,10===k&&(N=1,D--),k}function H(){return k=F<O?T(U,F++):0,N++,10===k&&(N=1,D++),k}function W(){return T(U,F)}function j(){return F}function X(e,t){return E(U,e,t)}function q(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function $(e){return _(X(F-1,Z(91===e?e+2:40===e?e+1:e)))}function Y(e){for(;(k=W())&&k<33;)H();return q(e)>2||q(k)>3?"":" "}function K(e,t){for(;--t&&H()&&!(k<48||k>102||k>57&&k<65||k>70&&k<97););return X(e,j()+(t<6&&32==W()&&32==H()))}function Z(e){for(;H();)switch(k){case e:return F;case 34:case 39:34!==e&&39!==e&&Z(k);break;case 40:41===e&&Z(e);break;case 92:H()}return F}function J(e,t){for(;H()&&e+k!==57&&(e+k!==84||47!==W()););return"/*"+X(t,F-1)+"*"+x(47===e?e:H())}function Q(e){for(;!q(W());)H();return X(e,F)}function ee(e){return function(e){return U="",e}(te("",null,null,null,[""],e=function(e){return D=N=1,O=A(U=e),F=0,[]}(e),0,[0],e))}function te(e,t,n,i,r,s,a,o,l){for(var c=0,u=0,h=a,d=0,p=0,f=0,m=1,g=1,v=1,b=0,_="",w=r,R=s,P=i,I=_;g;)switch(f=b,b=H()){case 40:if(108!=f&&58==T(I,h-1)){-1!=M(I+=S($(b),"&","&\f"),"&\f",y(c?o[c-1]:0))&&(v=-1);break}case 34:case 39:case 91:I+=$(b);break;case 9:case 10:case 13:case 32:I+=Y(f);break;case 92:I+=K(j()-1,7);continue;case 47:switch(W()){case 42:case 47:C(ie(J(H(),j()),t,n,l),l),5!=q(f||1)&&5!=q(W()||1)||!A(I)||" "===E(I,-1,void 0)||(I+=" ");break;default:I+="/"}break;case 123*m:o[c++]=A(I)*v;case 125*m:case 59:case 0:switch(b){case 0:case 125:g=0;case 59+u:-1==v&&(I=S(I,/\f/g,"")),p>0&&(A(I)-h||0===m&&47===f)&&C(p>32?re(I+";",i,n,h-1,l):re(S(I," ","")+";",i,n,h-2,l),l);break;case 59:I+=";";default:if(C(P=ne(I,t,n,c,u,r,o,_,w=[],R=[],h,s),s),123===b)if(0===u)te(I,t,P,P,w,s,h,o,R);else{switch(d){case 99:if(110===T(I,3))break;case 108:if(97===T(I,2))break;default:u=0;case 100:case 109:case 115:}u?te(e,P,P,i&&C(ne(e,P,P,0,0,r,o,_,r,w=[],h,R),R),r,R,h,o,i?w:R):te(I,P,P,P,[""],R,0,o,R)}}c=u=p=0,m=v=1,_=I="",h=a;break;case 58:h=1+A(I),p=f;default:if(m<1)if(123==b)--m;else if(125==b&&0==m++&&125==G())continue;switch(I+=x(b),b*m){case 38:v=u>0?1:(I+="\f",-1);break;case 44:o[c++]=(A(I)-1)*v,v=1;break;case 64:45===W()&&(I+=$(H())),d=W(),u=h=A(_=I+=Q(j())),b++;break;case 45:45===f&&2==A(I)&&(m=0)}}return s}function ne(e,t,n,i,r,s,a,o,l,c,u,h){for(var d=r-1,p=0===r?s:[""],f=R(p),g=0,v=0,x=0;g<i;++g)for(var b=0,w=E(e,d+1,d=y(v=a[g])),M=e;b<f;++b)(M=_(v>0?p[b]+" "+w:S(w,/&\f/g,p[b])))&&(l[x++]=M);return z(e,t,n,0===r?m:o,l,c,u,h)}function ie(e,t,n,i){return z(e,t,n,f,x(k),E(e,2,-2),0,i)}function re(e,t,n,i,r){return z(e,t,n,g,E(e,0,i),E(e,i+1,-1),i,r)}function se(e,t,n){switch(function(e,t){return 45^T(e,0)?(((t<<2^T(e,0))<<2^T(e,1))<<2^T(e,2))<<2^T(e,3):0}(e,t)){case 5103:return p+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return p+e+e;case 4855:return p+e.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+e;case 4789:return d+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return p+e+d+e+h+e+e;case 5936:switch(T(e,t+11)){case 114:return p+e+h+S(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return p+e+h+S(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return p+e+h+S(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return p+e+h+e+e;case 6165:return p+e+h+"flex-"+e+e;case 5187:return p+e+S(e,/(\w+).+(:[^]+)/,p+"box-$1$2"+h+"flex-$1$2")+e;case 5443:return p+e+h+"flex-item-"+S(e,/flex-|-self/g,"")+(w(e,/flex-|baseline/)?"":h+"grid-row-"+S(e,/flex-|-self/g,""))+e;case 4675:return p+e+h+"flex-line-pack"+S(e,/align-content|flex-|-self/g,"")+e;case 5548:return p+e+h+S(e,"shrink","negative")+e;case 5292:return p+e+h+S(e,"basis","preferred-size")+e;case 6060:return p+"box-"+S(e,"-grow","")+p+e+h+S(e,"grow","positive")+e;case 4554:return p+S(e,/([^-])(transform)/g,"$1"+p+"$2")+e;case 6187:return S(S(S(e,/(zoom-|grab)/,p+"$1"),/(image-set)/,p+"$1"),e,"")+e;case 5495:case 3959:return S(e,/(image-set\([^]*)/,p+"$1$`$1");case 4968:return S(S(e,/(.+:)(flex-)?(.*)/,p+"box-pack:$3"+h+"flex-pack:$3"),/space-between/,"justify")+p+e+e;case 4200:if(!w(e,/flex-|baseline/))return h+"grid-column-align"+E(e,t)+e;break;case 2592:case 3360:return h+S(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,w(e.props,/grid-\w+-end/)})?~M(e+(n=n[t].value),"span",0)?e:h+S(e,"-start","")+e+h+"grid-row-span:"+(~M(n,"span",0)?w(n,/\d+/):+w(n,/\d+/)-+w(e,/\d+/))+";":h+S(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return w(e.props,/grid-\w+-start/)})?e:h+S(S(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return S(e,/(.+)-inline(.+)/,p+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(A(e)-1-t>6)switch(T(e,t+1)){case 109:if(45!==T(e,t+4))break;case 102:return S(e,/(.+:)(.+)-([^]+)/,"$1"+p+"$2-$3$1"+d+(108==T(e,t+3)?"$3":"$2-$3"))+e;case 115:return~M(e,"stretch",0)?se(S(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return S(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,i,r,s,a,o){return h+n+":"+i+o+(r?h+n+"-span:"+(s?a:+a-+i)+o:"")+e});case 4949:if(121===T(e,t+6))return S(e,":",":"+p)+e;break;case 6444:switch(T(e,45===T(e,14)?18:11)){case 120:return S(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+p+(45===T(e,14)?"inline-":"")+"box$3$1"+p+"$2$3$1"+h+"$2box$3")+e;case 100:return S(e,":",":"+h)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return S(e,"scroll-","scroll-snap-")+e}return e}function ae(e,t){for(var n="",i=0;i<e.length;i++)n+=t(e[i],i,e,t)||"";return n}function oe(e,t,n,i){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case"@namespace":case g:return e.return=e.return||e.value;case f:return"";case v:return e.return=e.value+"{"+ae(e.children,i)+"}";case m:if(!A(e.value=e.props.join(",")))return""}return A(n=ae(e.children,i))?e.return=e.value+"{"+n+"}":""}function le(e,t,n,i){if(e.length>-1&&!e.return)switch(e.type){case g:return void(e.return=se(e.value,e.length,n));case v:return ae([B(e,{value:S(e.value,"@","@"+p)})],i);case m:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(w(t,i=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":V(B(e,{props:[S(t,/:(read-\w+)/,":-moz-$1")]})),V(B(e,{props:[t]})),b(e,{props:P(n,i)});break;case"::placeholder":V(B(e,{props:[S(t,/:(plac\w+)/,":"+p+"input-$1")]})),V(B(e,{props:[S(t,/:(plac\w+)/,":-moz-$1")]})),V(B(e,{props:[S(t,/:(plac\w+)/,h+"input-$1")]})),V(B(e,{props:[t]})),b(e,{props:P(n,i)})}return""})}}const ce="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",ue="active",he="data-styled-version",de="6.4.4",pe="/*!sc*/\n",fe="undefined"!=typeof window&&"undefined"!=typeof document;function me(e){if("undefined"!=typeof process&&void 0!==process.env){const t=process.env[e];if(void 0!==t&&""!==t)return"false"!==t}}const ge=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:null!==(L=null!==(I=me("REACT_APP_SC_DISABLE_SPEEDY"))&&void 0!==I?I:me("SC_DISABLE_SPEEDY"))&&void 0!==L?L:"undefined"!=typeof process&&void 0!==process.env&&!1);function ve(e,...t){return new Error(`An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#${e} for more information.${t.length>0?` Args: ${t.join(", ")}`:""}`)}let ye=new Map,xe=new Map,be=1;const _e=e=>{if(ye.has(e))return ye.get(e);for(;xe.has(be);)be++;const t=be++;return ye.set(e,t),xe.set(t,e),t},we=e=>xe.get(e),Se=(e,t)=>{be=t+1,ye.set(e,t),xe.set(t,e)},Me=Object.freeze([]),Te=Object.freeze({});const Ee=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Ae=/(^-|-$)/g;function Re(e){return e.replace(Ee,"-").replace(Ae,"")}const Ce=/(a)(d)/gi,Pe=e=>String.fromCharCode(e+(e>25?39:97));function Ie(e){let t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Pe(t%52)+n;return(Pe(t%52)+n).replace(Ce,"$1-$2")}const Le=5381,De=(e,t)=>{let n=t.length;for(;n;)e=33*e^t.charCodeAt(--n);return e},Ne=e=>De(Le,e);function Oe(e){return"string"==typeof e&&!0}function Fe(e){return Oe(e)?`styled.${e}`:`Styled(${function(e){return e.displayName||e.name||"Component"}(e)})`}const ke=Symbol.for("react.memo"),Ue=Symbol.for("react.forward_ref"),ze={contextType:!0,defaultProps:!0,displayName:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,propTypes:!0,type:!0},Be={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Ve={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Ge={[Ue]:{$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},[ke]:Ve};function He(e){return("type"in(t=e)&&t.type.$$typeof)===ke?Ve:"$$typeof"in e?Ge[e.$$typeof]:ze;var t}const We=Object.defineProperty,je=Object.getOwnPropertyNames,Xe=Object.getOwnPropertySymbols,qe=Object.getOwnPropertyDescriptor,$e=Object.getPrototypeOf,Ye=Object.prototype;function Ke(e,t,n){if("string"!=typeof t){const i=$e(t);i&&i!==Ye&&Ke(e,i,n);const r=je(t).concat(Xe(t)),s=He(e),a=He(t);for(let i=0;i<r.length;++i){const o=r[i];if(!(o in Be||n&&n[o]||a&&o in a||s&&o in s)){const n=qe(t,o);try{We(e,o,n)}catch(e){}}}}return e}function Ze(e){return"function"==typeof e}const Je=Symbol.for("react.forward_ref");function Qe(e){return null!=e&&("object"==typeof e||"function"==typeof e)&&e.$$typeof===Je&&"styledComponentId"in e}function et(e,t){return e&&t?e+" "+t:e||t||""}function tt(e,t){return e.join("")}function nt(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function it(e,t,n=!1){if(!n&&!nt(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(let n=0;n<t.length;n++)e[n]=it(e[n],t[n]);else if(nt(t))for(const n in t)e[n]=it(e[n],t[n]);return e}function rt(e,t){Object.defineProperty(e,"toString",{value:t})}const st=class{constructor(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e,this._cGroup=0,this._cIndex=0}indexOfGroup(e){if(e===this._cGroup)return this._cIndex;let t=this._cIndex;if(e>this._cGroup)for(let n=this._cGroup;n<e;n++)t+=this.groupSizes[n];else for(let n=this._cGroup-1;n>=e;n--)t-=this.groupSizes[n];return this._cGroup=e,this._cIndex=t,t}insertRules(e,t){if(e>=this.groupSizes.length){const t=this.groupSizes,n=t.length;let i=n;for(;e>=i;)if(i<<=1,i<0)throw ve(16,`${e}`);this.groupSizes=new Uint32Array(i),this.groupSizes.set(t),this.length=i;for(let e=n;e<i;e++)this.groupSizes[e]=0}let n=this.indexOfGroup(e+1),i=0;for(let r=0,s=t.length;r<s;r++)this.tag.insertRule(n,t[r])&&(this.groupSizes[e]++,n++,i++);i>0&&this._cGroup>e&&(this._cIndex+=i)}clearGroup(e){if(e<this.length){const t=this.groupSizes[e],n=this.indexOfGroup(e),i=n+t;this.groupSizes[e]=0;for(let e=n;e<i;e++)this.tag.deleteRule(n);t>0&&this._cGroup>e&&(this._cIndex-=t)}}getGroup(e){let t="";if(e>=this.length||0===this.groupSizes[e])return t;const n=this.groupSizes[e],i=this.indexOfGroup(e),r=i+n;for(let e=i;e<r;e++)t+=this.tag.getRule(e)+pe;return t}},at=`style[${ce}][${he}="${de}"]`,ot=new RegExp(`^${ce}\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)`),lt=e=>"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot||"host"in e&&11===e.nodeType,ct=e=>{if(!e)return document;if(lt(e))return e;if("getRootNode"in e){const t=e.getRootNode();if(lt(t))return t}return document},ut=(e,t,n)=>{const i=n.split(",");let r;for(let n=0,s=i.length;n<s;n++)(r=i[n])&&e.registerName(t,r)},ht=(e,t)=>{var n;const i=(null!==(n=t.textContent)&&void 0!==n?n:"").split(pe),r=[];for(let t=0,n=i.length;t<n;t++){const n=i[t].trim();if(!n)continue;const s=n.match(ot);if(s){const t=0|parseInt(s[1],10),n=s[2];0!==t&&(Se(n,t),ut(e,n,s[3]),e.getTag().insertRules(t,r)),r.length=0}else r.push(n)}},dt=e=>{const t=ct(e.options.target).querySelectorAll(at);for(let n=0,i=t.length;n<i;n++){const i=t[n];i&&i.getAttribute(ce)!==ue&&(ht(e,i),i.parentNode&&i.parentNode.removeChild(i))}};let pt=!1;const ft=(e,t)=>{const n=document.head,i=e||n,r=document.createElement("style"),s=(e=>{const t=Array.from(e.querySelectorAll(`style[${ce}]`));return t[t.length-1]})(i),a=void 0!==s?s.nextSibling:null;r.setAttribute(ce,ue),r.setAttribute(he,de);const o=t||function(){if(!1!==pt)return pt;if("undefined"!=typeof document){const e=document.head.querySelector('meta[property="csp-nonce"]');if(e)return pt=e.nonce||e.getAttribute("content")||void 0;const t=document.head.querySelector('meta[name="sc-nonce"]');if(t)return pt=t.getAttribute("content")||void 0}return pt="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0}();return o&&r.setAttribute("nonce",o),i.insertBefore(r,a),r},mt=class{constructor(e,t){this.element=ft(e,t),this.element.appendChild(document.createTextNode("")),this.sheet=(e=>{var t;if(e.sheet)return e.sheet;const n=null!==(t=e.getRootNode().styleSheets)&&void 0!==t?t:document.styleSheets;for(let t=0,i=n.length;t<i;t++){const i=n[t];if(i.ownerNode===e)return i}throw ve(17)})(this.element),this.length=0}insertRule(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}}deleteRule(e){this.sheet.deleteRule(e),this.length--}getRule(e){const t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""}},gt=class{constructor(e,t){this.element=ft(e,t),this.nodes=this.element.childNodes,this.length=0}insertRule(e,t){if(e<=this.length&&e>=0){const n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1}deleteRule(e){this.element.removeChild(this.nodes[e]),this.length--}getRule(e){return e<this.length?this.nodes[e].textContent:""}};let vt=fe;const yt={isServer:!fe,useCSSOMInjection:!ge};class xt{static registerId(e){return _e(e)}constructor(e=Te,t={},n){this.options=Object.assign(Object.assign({},yt),e),this.gs=t,this.keyframeIds=new Set,this.names=new Map(n),this.server=!!e.isServer,!this.server&&fe&&vt&&(vt=!1,dt(this)),rt(this,()=>(e=>{const t=e.getTag(),{length:n}=t;let i="";for(let r=0;r<n;r++){const n=we(r);if(void 0===n)continue;const s=e.names.get(n);if(void 0===s||!s.size)continue;const a=t.getGroup(r);if(0===a.length)continue;const o=ce+".g"+r+'[id="'+n+'"]';let l="";for(const e of s)e.length>0&&(l+=e+",");i+=a+o+'{content:"'+l+'"}'+pe}return i})(this))}rehydrate(){!this.server&&fe&&dt(this)}reconstructWithOptions(e,t=!0){const n=new xt(Object.assign(Object.assign({},this.options),e),this.gs,t&&this.names||void 0);return n.keyframeIds=new Set(this.keyframeIds),!this.server&&fe&&e.target!==this.options.target&&ct(this.options.target)!==ct(e.target)&&dt(n),n}allocateGSInstance(e){return this.gs[e]=(this.gs[e]||0)+1}getTag(){return this.tag||(this.tag=(e=(({useCSSOMInjection:e,target:t,nonce:n})=>e?new mt(t,n):new gt(t,n))(this.options),new st(e)));var e}hasNameForId(e,t){var n,i;return null!==(i=null===(n=this.names.get(e))||void 0===n?void 0:n.has(t))&&void 0!==i&&i}registerName(e,t){_e(e),e.startsWith("sc-keyframes-")&&this.keyframeIds.add(e);const n=this.names.get(e);n?n.add(t):this.names.set(e,new Set([t]))}insertRules(e,t,n){this.registerName(e,t),this.getTag().insertRules(_e(e),n)}clearNames(e){this.names.has(e)&&this.names.get(e).clear()}clearRules(e){this.getTag().clearGroup(_e(e)),this.clearNames(e)}clearTag(){this.tag=void 0}}const bt=new WeakSet,_t={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexShrink:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function wt(e,t){return null==t||"boolean"==typeof t||""===t?"":"number"!=typeof t||0===t||e in _t||e.startsWith("--")?String(t).trim():t+"px"}const St=47;function Mt(e){if(45===e.charCodeAt(0)&&45===e.charCodeAt(1))return e;let t="";for(let n=0;n<e.length;n++){const i=e.charCodeAt(n);t+=i>=65&&i<=90?"-"+String.fromCharCode(i+32):e[n]}return t.startsWith("ms-")?"-"+t:t}const Tt=Symbol.for("sc-keyframes");function Et(e){return Ze(e)&&!(e.prototype&&e.prototype.isReactComponent)}const At=e=>null==e||!1===e||""===e,Rt=Symbol.for("react.client.reference");function Ct(e){return e.$$typeof===Rt}function Pt(e,t){for(const n in e){const i=e[n];e.hasOwnProperty(n)&&!At(i)&&(Array.isArray(i)&&bt.has(i)||Ze(i)?t.push(Mt(n)+":",i,";"):nt(i)?(t.push(n+" {"),Pt(i,t),t.push("}")):t.push(Mt(n)+": "+wt(n,i)+";"))}}function It(e,t,n,i,r=[]){if(At(e))return r;const s=typeof e;if("string"===s)return r.push(e),r;if("function"===s){if(Ct(e))return r;if(Et(e)&&t){return It(e(t),t,n,i,r)}return r.push(e),r}if(Array.isArray(e)){for(let s=0;s<e.length;s++)It(e[s],t,n,i,r);return r}return Qe(e)?(r.push(`.${e.styledComponentId}`),r):function(e){return"object"==typeof e&&null!==e&&Tt in e}(e)?(n?(e.inject(n,i),r.push(e.getName(i))):r.push(e),r):Ct(e)?r:nt(e)?e.toString!==Object.prototype.toString?(r.push(e.toString()),r):(Pt(e,r),r):(r.push(e.toString()),r)}const Lt=Ne(de);class Dt{constructor(e,t,n){this.rules=e,this.componentId=t,this.baseHash=De(Lt,t),this.baseStyle=n,xt.registerId(t)}generateAndInjectStyles(e,t,n){let i=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";{let r="";for(let i=0;i<this.rules.length;i++){const s=this.rules[i];if("string"==typeof s)r+=s;else if(s)if(Et(s)){const i=s(e);"string"==typeof i?r+=i:null!=i&&!1!==i&&(r+=tt(It(i,e,t,n)))}else r+=tt(It(s,e,t,n))}if(r){this.dynamicNameCache||(this.dynamicNameCache=new Map);const e=n.hash?n.hash+r:r;let s=this.dynamicNameCache.get(e);if(!s){if(s=Ie(De(De(this.baseHash,n.hash),r)>>>0),this.dynamicNameCache.size>=200){const e=this.dynamicNameCache.keys().next().value;void 0!==e&&this.dynamicNameCache.delete(e)}this.dynamicNameCache.set(e,s)}if(!t.hasNameForId(this.componentId,s)){const e=n(r,"."+s,void 0,this.componentId);t.insertRules(this.componentId,s,e)}i=et(i,s)}}return i}}const Nt=/&/g;function Ot(e,t){let n=0;for(;--t>=0&&92===e.charCodeAt(t);)n++;return!(1&~n)}function Ft(e){const t=e.length;let n="",i=0,r=0,s=0,a=!1,o=!1;for(let l=0;l<t;l++){const c=e.charCodeAt(l);if(0!==s||a||c!==St||42!==e.charCodeAt(l+1))if(a)42===c&&e.charCodeAt(l+1)===St&&(a=!1,l++);else if(34!==c&&39!==c||Ot(e,l)){if(0===s)if(123===c)r++;else if(125===c){if(r--,r<0){o=!0;let n=l+1;for(;n<t;){const t=e.charCodeAt(n);if(59===t||10===t)break;n++}n<t&&59===e.charCodeAt(n)&&n++,r=0,l=n-1,i=n;continue}0===r&&(n+=e.substring(i,l+1),i=l+1)}else 59===c&&0===r&&(n+=e.substring(i,l+1),i=l+1)}else 0===s?s=c:s===c&&(s=0);else a=!0,l++}return o||0!==r||0!==s?(i<t&&0===r&&0===s&&(n+=e.substring(i)),n):e}function kt(e,t){const n=t+" ",i=","+n;for(let r=0;r<e.length;r++){const s=e[r];if("rule"===s.type){s.value=(n+s.value).replaceAll(",",i);const e=s.props,t=[];for(let i=0;i<e.length;i++)t[i]=n+e[i];s.props=t}Array.isArray(s.children)&&"@keyframes"!==s.type&&kt(s.children,t)}return e}function Ut({options:e=Te,plugins:t=Me}=Te){let n,i,r;const s=(e,t,r)=>r.startsWith(i)&&r.endsWith(i)&&r.replaceAll(i,"").length>0?`.${n}`:e,a=t.slice();a.push(e=>{e.type===m&&e.value.includes("&")&&(r||(r=new RegExp(`\\${i}\\b`,"g")),e.props[0]=e.props[0].replace(Nt,i).replace(r,s))}),e.prefix&&a.push(le),a.push(oe);let o=[];const l=function(e){var t=R(e);return function(n,i,r,s){for(var a="",o=0;o<t;o++)a+=e[o](n,i,r,s)||"";return a}}(a.concat((h=e=>o.push(e),function(e){e.root||(e=e.return)&&h(e)}))),c=(t,s="",a="",c="&")=>{n=c,i=s,r=void 0;const u=function(e){const t=-1!==e.indexOf("//"),n=-1!==e.indexOf("}");if(!t&&!n)return e;if(!t)return Ft(e);const i=e.length;let r="",s=0,a=0,o=0,l=0,c=0,u=!1;for(;a<i;){const t=e.charCodeAt(a);if(34!==t&&39!==t||Ot(e,a))if(0===o)if(t===St&&a+1<i&&42===e.charCodeAt(a+1)){for(a+=2;a+1<i&&(42!==e.charCodeAt(a)||e.charCodeAt(a+1)!==St);)a++;a+=2}else if(40!==t)if(41!==t)if(l>0)a++;else if(42===t&&a+1<i&&e.charCodeAt(a+1)===St)r+=e.substring(s,a),a+=2,s=a,u=!0;else if(t===St&&a+1<i&&e.charCodeAt(a+1)===St){for(r+=e.substring(s,a);a<i&&10!==e.charCodeAt(a);)a++;s=a,u=!0}else 123===t?c++:125===t&&c--,a++;else l>0&&l--,a++;else l++,a++;else a++;else 0===o?o=t:o===t&&(o=0),a++}return u?(s<i&&(r+=e.substring(s)),0===c?r:Ft(r)):0===c?e:Ft(e)}(t);let h=ee(a||s?a+" "+s+" { "+u+" }":u);return e.namespace&&(h=kt(h,e.namespace)),o=[],ae(h,l),o},u=e;var h;let d=Le;for(let e=0;e<t.length;e++)t[e].name||ve(15),d=De(d,t[e].name);return(null==u?void 0:u.namespace)&&(d=De(d,u.namespace)),(null==u?void 0:u.prefix)&&(d=De(d,"p")),c.hash=d!==Le?d.toString():"",c}const zt=new xt,Bt=Ut(),Vt=c.createContext({shouldForwardProp:void 0,styleSheet:zt,stylis:Bt,stylisPlugins:void 0});function Gt(){return c.useContext(Vt)}function Ht(e){var t;const n=Gt(),{styleSheet:i}=n,r=c.useMemo(()=>{let t=i;return e.sheet?t=e.sheet:e.target?t=t.reconstructWithOptions(void 0!==e.nonce?{target:e.target,nonce:e.nonce}:{target:e.target},!1):void 0!==e.nonce&&(t=t.reconstructWithOptions({nonce:e.nonce})),e.disableCSSOMInjection&&(t=t.reconstructWithOptions({useCSSOMInjection:!1})),t},[e.disableCSSOMInjection,e.nonce,e.sheet,e.target,i]),s=c.useMemo(()=>{var t;return void 0===e.stylisPlugins&&void 0===e.namespace&&void 0===e.enableVendorPrefixes?n.stylis:Ut({options:{namespace:e.namespace,prefix:e.enableVendorPrefixes},plugins:null!==(t=e.stylisPlugins)&&void 0!==t?t:n.stylisPlugins})},[e.enableVendorPrefixes,e.namespace,e.stylisPlugins,n.stylis,n.stylisPlugins]),a="shouldForwardProp"in e?e.shouldForwardProp:n.shouldForwardProp,o=null!==(t=e.stylisPlugins)&&void 0!==t?t:n.stylisPlugins,l=c.useMemo(()=>({shouldForwardProp:a,styleSheet:r,stylis:s,stylisPlugins:o}),[a,r,s,o]);return c.createElement(Vt.Provider,{value:l},e.children)}Vt.Consumer;const Wt=c.createContext(void 0);Wt.Consumer;const jt=Object.prototype.hasOwnProperty,Xt={};function qt(e,t){const n="string"!=typeof e?"sc":Re(e);Xt[n]=(Xt[n]||0)+1;const i=n+"-"+function(e){return Ie(Ne(e)>>>0)}(de+n+Xt[n]);return t?t+"-"+i:i}function $t(e,t,n){const i=Qe(e),r=e,s=!Oe(e),{attrs:a=Me,componentId:o=qt(t.displayName,t.parentComponentId),displayName:u=Fe(e)}=t,h=t.displayName&&t.componentId?Re(t.displayName)+"-"+t.componentId:t.componentId||o,d=i&&r.attrs?r.attrs.concat(a).filter(Boolean):a;let{shouldForwardProp:p}=t;if(i&&r.shouldForwardProp){const e=r.shouldForwardProp;if(t.shouldForwardProp){const n=t.shouldForwardProp;p=(t,i)=>e(t,i)&&n(t,i)}else p=e}const f=new Dt(n,h,i?r.componentStyle:void 0);function m(e,t){return function(e,t,n){const{attrs:i,componentStyle:r,defaultProps:s,foldedComponentIds:a,styledComponentId:o,target:u}=e,h=c.useContext(Wt),d=Gt(),p=e.shouldForwardProp||d.shouldForwardProp,f=function(e,t,n=Te){return e.theme!==n.theme&&e.theme||t||n.theme}(t,h,s)||Te;let m,g;{const e=c.useRef(null),n=e.current;if(null!==n&&n[1]===f&&n[2]===d.styleSheet&&n[3]===d.stylis&&n[7]===r&&function(e,t,n){const i=e,r=t;let s=0;for(const e in r)if(jt.call(r,e)&&(s++,i[e]!==r[e]))return!1;return s===n}(n[0],t,n[4]))m=n[5],g=n[6];else{m=function(e,t,n){const i=Object.assign(Object.assign({},t),{className:void 0,theme:n}),r=e.length>1;for(let n=0;n<e.length;n++){const s=e[n],a=Ze(s)?s(r?Object.assign({},i):i):s;for(const e in a)"className"===e?i.className=et(i.className,a[e]):"style"===e?i.style=Object.assign(Object.assign({},i.style),a[e]):e in t&&void 0===t[e]||(i[e]=a[e])}return"className"in t&&"string"==typeof t.className&&(i.className=et(i.className,t.className)),i}(i,t,f),g=function(e,t,n,i){return e.generateAndInjectStyles(t,n,i)}(r,m,d.styleSheet,d.stylis);let n=0;for(const e in t)jt.call(t,e)&&n++;e.current=[t,f,d.styleSheet,d.stylis,n,m,g,r]}}const v=m.as||u,y=function(e,t,n,i){const r={};for(const s in e)void 0===e[s]||"$"===s[0]||"as"===s||"theme"===s&&e.theme===n||("forwardedAs"===s?r.as=e.forwardedAs:i&&!i(s,t)||(r[s]=e[s]));return r}(m,v,f,p);let x=et(a,o);return g&&(x+=" "+g),m.className&&(x+=" "+m.className),y[Oe(v)&&v.includes("-")?"class":"className"]=x,n&&(y.ref=n),l.createElement(v,y)}(g,e,t)}m.displayName=u;let g=c.forwardRef(m);return g.attrs=d,g.componentStyle=f,g.displayName=u,g.shouldForwardProp=p,g.foldedComponentIds=i?et(r.foldedComponentIds,r.styledComponentId):"",g.styledComponentId=h,g.target=i?r.target:e,Object.defineProperty(g,"defaultProps",{get(){return this._foldedDefaultProps},set(e){this._foldedDefaultProps=i?function(e,...t){for(const n of t)it(e,n,!0);return e}({},r.defaultProps,e):e}}),rt(g,()=>`.${g.styledComponentId}`),s&&Ke(g,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),g}var Yt=new Set(["a","abbr","address","area","article","aside","audio","b","bdi","bdo","blockquote","body","button","br","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","slot","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","tspan","use"]);function Kt(e,t){const n=[e[0]];for(let i=0,r=t.length;i<r;i+=1)n.push(t[i],e[i+1]);return n}const Zt=e=>(bt.add(e),e);function Jt(e,t,n=Te){if(!t)throw ve(1,t);const i=(i,...r)=>e(t,n,function(e,...t){if(Ze(e)||nt(e))return Zt(It(Kt(Me,[e,...t])));const n=e;return 0===t.length&&1===n.length&&"string"==typeof n[0]?It(n):Zt(It(Kt(n,t)))}(i,...r));return i.attrs=i=>Jt(e,t,Object.assign(Object.assign({},n),{attrs:Array.prototype.concat(n.attrs,i).filter(Boolean)})),i.withConfig=i=>Jt(e,t,Object.assign(Object.assign({},n),i)),i}const Qt=e=>Jt($t,e),en=Qt;Yt.forEach(e=>{en[e]=Qt(e)});const tn="#EDEDED",nn="#9C9C9C",rn="#6B6B6E",sn="rgba(243, 151, 143, 1)",an="rgba(240, 97, 84,1)",on="#2D7FF9",ln="rgba(45, 127, 249, 0.35)",cn="rgba(38, 38, 38, 0.72)",un="rgba(61, 61, 63, 0.7)",hn="rgba(61, 61, 63, 0.6)",dn="rgba(61, 61, 63, 1)",pn="linear-gradient(to bottom, rgba(52, 52, 52, 0.75), rgba(57, 57, 57, 0.75))",fn="30px",mn="30px",gn="14px",vn="3px",yn="10px",xn="10px 3px 3px 10px",bn="3px 10px 10px 3px",_n="70px",wn="3px",Sn=en.button`
|
|
2
|
+
background: ${pn};
|
|
3
|
+
border: none;
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
color: ${tn};
|
|
9
|
+
border: 1px solid transparent;
|
|
10
|
+
border-radius: ${vn};
|
|
11
|
+
font-size: ${gn};
|
|
12
|
+
height: ${fn};
|
|
13
|
+
min-width: ${mn};
|
|
14
|
+
transition: all 0.2s ease-in-out;
|
|
15
|
+
text-transform: none;
|
|
16
|
+
box-shadow: none;
|
|
17
|
+
font-family:
|
|
18
|
+
system-ui,
|
|
19
|
+
-apple-system,
|
|
20
|
+
'Segoe UI',
|
|
21
|
+
Roboto,
|
|
22
|
+
sans-serif;
|
|
23
|
+
|
|
24
|
+
&:first-child {
|
|
25
|
+
border-radius: ${({$reverse:e})=>e?bn:xn};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:last-child {
|
|
29
|
+
border-radius: ${({$reverse:e})=>e?xn:bn};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:first-child:last-child {
|
|
33
|
+
border-radius: ${yn};
|
|
34
|
+
}
|
|
35
|
+
`,Mn=en.div`
|
|
36
|
+
padding: 4px;
|
|
37
|
+
display: flex;
|
|
38
|
+
gap: 2px;
|
|
39
|
+
background-color: ${cn};
|
|
40
|
+
border: 1px solid ${un};
|
|
41
|
+
backdrop-filter: blur(40px);
|
|
42
|
+
-webkit-backdrop-filter: blur(40px);
|
|
43
|
+
box-shadow:
|
|
44
|
+
0 5px 10px rgba(0, 0, 0, 0.3),
|
|
45
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
46
|
+
justify-content: center;
|
|
47
|
+
pointer-events: all;
|
|
48
|
+
border-radius: 14px;
|
|
49
|
+
align-items: center;
|
|
50
|
+
`,Tn=en.button`
|
|
51
|
+
background-color: ${({$active:e,$open:t})=>e?"rgba(45, 127, 249, 0.18)":t?"rgba(255, 255, 255, 0.1)":"transparent"};
|
|
52
|
+
border: none;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
color: ${({$active:e})=>e?on:tn};
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
height: 28px;
|
|
60
|
+
min-width: 28px;
|
|
61
|
+
padding: 0 6px;
|
|
62
|
+
transition: all 0.15s ease-in-out;
|
|
63
|
+
text-transform: none;
|
|
64
|
+
box-shadow: none;
|
|
65
|
+
font-family:
|
|
66
|
+
system-ui,
|
|
67
|
+
-apple-system,
|
|
68
|
+
'Segoe UI',
|
|
69
|
+
Roboto,
|
|
70
|
+
sans-serif;
|
|
71
|
+
|
|
72
|
+
&:hover:not(:disabled) {
|
|
73
|
+
background-color: ${({$active:e,$open:t})=>e?"rgba(45, 127, 249, 0.24)":t?"rgba(255, 255, 255, 0.14)":"rgba(255, 255, 255, 0.06)"};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:active:not(:disabled) {
|
|
77
|
+
background-color: ${({$active:e,$open:t})=>e?"rgba(45, 127, 249, 0.32)":t?"rgba(255, 255, 255, 0.18)":"rgba(255, 255, 255, 0.1)"};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&:focus {
|
|
81
|
+
outline: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:focus-visible {
|
|
85
|
+
outline: 2px solid ${on};
|
|
86
|
+
outline-offset: 1px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:disabled {
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
opacity: 0.45;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&:disabled:hover,
|
|
95
|
+
&:disabled:active {
|
|
96
|
+
background-color: transparent;
|
|
97
|
+
}
|
|
98
|
+
`,En=en.div`
|
|
99
|
+
background-color: ${({$pressed:e})=>e?dn:hn};
|
|
100
|
+
border: none;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
color: ${tn};
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
font-size: 14px;
|
|
107
|
+
font-family:
|
|
108
|
+
system-ui,
|
|
109
|
+
-apple-system,
|
|
110
|
+
'Segoe UI',
|
|
111
|
+
Roboto,
|
|
112
|
+
sans-serif;
|
|
113
|
+
height: 30px;
|
|
114
|
+
width: 30px;
|
|
115
|
+
transition: all 0.2s ease-in-out;
|
|
116
|
+
`,An=en.div`
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: row;
|
|
119
|
+
align-items: center;
|
|
120
|
+
gap: 3px;
|
|
121
|
+
margin-bottom: 3px;
|
|
122
|
+
|
|
123
|
+
&:last-child {
|
|
124
|
+
margin-bottom: 0;
|
|
125
|
+
}
|
|
126
|
+
`,Rn=en.div`
|
|
127
|
+
flex: none;
|
|
128
|
+
box-sizing: border-box;
|
|
129
|
+
width: 30px;
|
|
130
|
+
height: 30px;
|
|
131
|
+
border-radius: 50%;
|
|
132
|
+
border: 1px solid ${un};
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
justify-content: center;
|
|
136
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
137
|
+
font-size: 9px;
|
|
138
|
+
font-weight: 600;
|
|
139
|
+
color: ${nn};
|
|
140
|
+
`;en.div`
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
height: 30px;
|
|
144
|
+
margin-bottom: 3px;
|
|
145
|
+
justify-content: flex-start;
|
|
146
|
+
flex-direction: ${({$reverse:e})=>e?"row-reverse":"row"};
|
|
147
|
+
|
|
148
|
+
&:last-child {
|
|
149
|
+
margin-bottom: 0;
|
|
150
|
+
}
|
|
151
|
+
`,en.div`
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: ${({$reverse:e})=>e?"row-reverse":"row"};
|
|
154
|
+
height: 100%;
|
|
155
|
+
justify-content: space-between;
|
|
156
|
+
align-items: center;
|
|
157
|
+
margin: ${({$reverse:e})=>e?"0 5px 0 0":"0 0 0 5px"};
|
|
158
|
+
gap: 3px;
|
|
159
|
+
`,en.button`
|
|
160
|
+
background-color: rgba(255, 255, 255, 0.3);
|
|
161
|
+
border: none;
|
|
162
|
+
display: flex;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
align-items: center;
|
|
165
|
+
padding: 0;
|
|
166
|
+
pointer-events: none;
|
|
167
|
+
width: 50px;
|
|
168
|
+
height: 50px;
|
|
169
|
+
border-radius: 50%;
|
|
170
|
+
position: relative;
|
|
171
|
+
margin: 0 5px;
|
|
172
|
+
backdrop-filter: blur(10px);
|
|
173
|
+
-webkit-backdrop-filter: blur(10px);
|
|
174
|
+
`,en.div`
|
|
175
|
+
position: absolute;
|
|
176
|
+
background-color: ${on};
|
|
177
|
+
box-shadow: 0 0 8px ${ln};
|
|
178
|
+
border-radius: 50%;
|
|
179
|
+
width: 36px;
|
|
180
|
+
height: 36px;
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
pointer-events: auto;
|
|
183
|
+
`,en.input.attrs({type:"range"})`
|
|
184
|
+
-webkit-appearance: none;
|
|
185
|
+
appearance: none;
|
|
186
|
+
background: ${pn};
|
|
187
|
+
border: none;
|
|
188
|
+
height: 100%;
|
|
189
|
+
width: ${_n};
|
|
190
|
+
cursor: pointer;
|
|
191
|
+
margin: 0;
|
|
192
|
+
transition: all 0.2s ease-in-out;
|
|
193
|
+
border-radius: ${({$reverse:e})=>e?xn:bn};
|
|
194
|
+
|
|
195
|
+
&::-webkit-slider-thumb {
|
|
196
|
+
-webkit-appearance: none;
|
|
197
|
+
appearance: none;
|
|
198
|
+
width: 8px;
|
|
199
|
+
height: 30px;
|
|
200
|
+
background-color: ${on};
|
|
201
|
+
border-radius: ${vn};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&::-moz-range-thumb {
|
|
205
|
+
width: 10px;
|
|
206
|
+
height: 30px;
|
|
207
|
+
background-color: ${on};
|
|
208
|
+
border-radius: ${vn};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
&::-ms-thumb {
|
|
212
|
+
width: 8px;
|
|
213
|
+
height: 24px;
|
|
214
|
+
background-color: ${on};
|
|
215
|
+
border-radius: ${vn};
|
|
216
|
+
}
|
|
217
|
+
`,en.div`
|
|
218
|
+
display: flex;
|
|
219
|
+
flex-direction: column;
|
|
220
|
+
align-items: ${({$reverse:e})=>e?"flex-start":"flex-end"};
|
|
221
|
+
justify-content: center;
|
|
222
|
+
margin: ${({$reverse:e})=>e?"2px -26px 0 0":"2px 0 0 -26px"};
|
|
223
|
+
`,en.div`
|
|
224
|
+
display: flex;
|
|
225
|
+
flex-direction: ${({$reverse:e})=>e?"row-reverse":"row"};
|
|
226
|
+
align-items: center;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
`;const Cn="40px",Pn="52px",In="4px",Ln="26px",Dn="8px",Nn="rgba(0, 0, 0, 0.25)",On="rgba(45, 127, 249, 0.45)",Fn="rgba(45, 127, 249, 0.18)",kn=en.span`
|
|
229
|
+
flex: none;
|
|
230
|
+
width: ${Cn};
|
|
231
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
232
|
+
font-size: 10px;
|
|
233
|
+
color: ${nn};
|
|
234
|
+
`,Un=en.div`
|
|
235
|
+
position: fixed;
|
|
236
|
+
padding: 5px;
|
|
237
|
+
font-family:
|
|
238
|
+
system-ui,
|
|
239
|
+
-apple-system,
|
|
240
|
+
'Segoe UI',
|
|
241
|
+
Roboto,
|
|
242
|
+
sans-serif;
|
|
243
|
+
color: ${tn};
|
|
244
|
+
pointer-events: all;
|
|
245
|
+
background-color: ${cn};
|
|
246
|
+
border: 1px solid ${un};
|
|
247
|
+
backdrop-filter: blur(40px);
|
|
248
|
+
-webkit-backdrop-filter: blur(40px);
|
|
249
|
+
border-radius: 12px;
|
|
250
|
+
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
|
251
|
+
overflow: hidden;
|
|
252
|
+
display: flex;
|
|
253
|
+
flex-direction: column;
|
|
254
|
+
`,zn=en.hr`
|
|
255
|
+
width: ${({$horizontal:e=!0})=>e?"unset":"1px"};
|
|
256
|
+
height: ${({$horizontal:e=!0})=>e?"1px":"unset"};
|
|
257
|
+
background-color: ${un};
|
|
258
|
+
margin: 5px 3px;
|
|
259
|
+
border: none;
|
|
260
|
+
`,Bn=en.button`
|
|
261
|
+
background-color: transparent;
|
|
262
|
+
border: none;
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
cursor: pointer;
|
|
267
|
+
color: ${({$isRed:e})=>e?sn:tn};
|
|
268
|
+
font-size: 12px;
|
|
269
|
+
padding: 3px;
|
|
270
|
+
text-transform: none;
|
|
271
|
+
box-shadow: none;
|
|
272
|
+
|
|
273
|
+
&:hover {
|
|
274
|
+
color: ${({$isRed:e})=>e?an:"#ffffff"};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&:active {
|
|
278
|
+
color: ${({$isRed:e})=>e?an:"#ffffff"};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
&:focus {
|
|
282
|
+
outline: none;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
&:focus-visible {
|
|
286
|
+
outline: 2px solid ${on};
|
|
287
|
+
outline-offset: 1px;
|
|
288
|
+
}
|
|
289
|
+
`,Vn=en.div`
|
|
290
|
+
display: flex;
|
|
291
|
+
flex-direction: row;
|
|
292
|
+
gap: ${In};
|
|
293
|
+
height: ${Ln};
|
|
294
|
+
`,Gn=en.input.attrs({type:"text"})`
|
|
295
|
+
width: ${Pn};
|
|
296
|
+
outline: none;
|
|
297
|
+
background: ${Nn};
|
|
298
|
+
border: 1px solid ${un};
|
|
299
|
+
border-radius: ${Dn};
|
|
300
|
+
height: ${Ln};
|
|
301
|
+
color: ${tn};
|
|
302
|
+
padding: 0 10px 0 5px;
|
|
303
|
+
box-sizing: border-box;
|
|
304
|
+
font-size: 10px;
|
|
305
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
306
|
+
|
|
307
|
+
&:focus-visible {
|
|
308
|
+
outline: 2px solid ${on};
|
|
309
|
+
outline-offset: 1px;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
&:read-only {
|
|
313
|
+
background: ${Nn};
|
|
314
|
+
cursor: default;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
&:invalid {
|
|
318
|
+
background-color: ${sn};
|
|
319
|
+
}
|
|
320
|
+
`,Hn=en.span`
|
|
321
|
+
position: absolute;
|
|
322
|
+
right: 5px;
|
|
323
|
+
top: 50%;
|
|
324
|
+
transform: translateY(-50%);
|
|
325
|
+
pointer-events: none;
|
|
326
|
+
color: ${nn};
|
|
327
|
+
font-size: 10px;
|
|
328
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
329
|
+
`,Wn=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),jn=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Xn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const qn=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1},$n=l.createContext({}),Yn=l.forwardRef(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:i,className:r="",children:s,iconNode:a,...o},c)=>{const{size:u=24,strokeWidth:h=2,absoluteStrokeWidth:d=!1,color:p="currentColor",className:f=""}=l.useContext($n)??{},m=i??d?24*Number(n??h)/Number(t??u):n??h;return l.createElement("svg",{ref:c,...Xn,width:t??u??Xn.width,height:t??u??Xn.height,stroke:e??p,strokeWidth:m,className:Wn("lucide",f,r),...!s&&!qn(o)&&{"aria-hidden":"true"},...o},[...a.map(([e,t])=>l.createElement(e,t)),...Array.isArray(s)?s:[s]])}),Kn=(e,t)=>{const n=l.forwardRef(({className:n,...i},r)=>{return l.createElement(Yn,{ref:r,iconNode:t,className:Wn(`lucide-${s=jn(e),s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...i});var s});return n.displayName=jn(e),n},Zn=Kn("armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]),Jn=Kn("arrow-big-up",[["path",{d:"M9 19a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-6a1 1 0 0 1 1-1h3.293a.707.707 0 0 0 .5-1.207l-7.086-7.086a1 1 0 0 0-1.414 0l-7.086 7.086a.707.707 0 0 0 .5 1.207H8a1 1 0 0 1 1 1z",key:"106j91"}]]),Qn=Kn("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),ei=Kn("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),ti=Kn("arrow-right-to-line",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]),ni=Kn("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),ii=Kn("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),ri=Kn("atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]),si=Kn("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]),ai=Kn("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]),oi=Kn("bug",[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]),li=Kn("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),ci=Kn("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),ui=Kn("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),hi=Kn("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),di=Kn("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),pi=Kn("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),fi=Kn("delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]),mi=Kn("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),gi=Kn("gamepad-2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]),vi=Kn("glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]),yi=Kn("hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]),xi=Kn("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),bi=Kn("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),_i=Kn("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),wi=Kn("mouse-left",[["path",{d:"M12 7.318V10",key:"17s7lh"}],["path",{d:"M5 10v5a7 7 0 0 0 14 0V9c0-3.527-2.608-6.515-6-7",key:"imk5ea"}],["circle",{cx:"7",cy:"4",r:"2",key:"ra7k3"}]]),Si=Kn("mouse-right",[["path",{d:"M12 7.318V10",key:"17s7lh"}],["path",{d:"M19 10v5a7 7 0 0 1-14 0V9c0-3.527 2.608-6.515 6-7",key:"2es5nn"}],["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}]]),Mi=Kn("mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]),Ti=Kn("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),Ei=Kn("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]),Ai=Kn("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Ri=Kn("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Ci=Kn("scan-eye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),Pi=Kn("scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]),Ii=Kn("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Li=Kn("shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]),Di=Kn("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),Ni={"rotate-ccw":Ai,"circle-play":hi,"gamepad-2":gi,hand:yi,eye:mi,keyboard:xi,armchair:Zn,layers:bi,box:ai,shapes:Li,save:Ri,scan:Pi,"scan-eye":Ci,"log-out":_i,atom:ri,bug:oi,x:Kn("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),settings:Ii,"circle-x":di,plug:Ei,glasses:vi,video:Di,pin:Ti,"circle-dot":ui,"chevron-left":li,"chevron-right":ci,ban:si,mouse:Mi,"mouse-left":wi,"mouse-right":Si,"corner-down-left":pi,"arrow-big-up":Jn,"arrow-up":ii,"arrow-down":Qn,"arrow-left":ei,"arrow-right":ni,"arrow-right-to-line":ti,delete:fi},Oi=({size:e,color:t,style:n})=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 14 14",fill:"none",style:n,children:[u.jsx("path",{fill:t,d:"M10.5 8.367a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8Z"}),u.jsx("path",{fill:t,fillRule:"evenodd",d:"M0 5.8A2.8 2.8 0 0 1 2.8 3h8.4A2.8 2.8 0 0 1 14 5.8v2.8a2.8 2.8 0 0 1-2.8 2.8H9.526c-.619 0-1.184-.35-1.46-.903l-.108-.214a.933.933 0 0 0-.835-.516h-.246c-.354 0-.677.2-.835.516l-.107.214a1.633 1.633 0 0 1-1.461.903H2.8A2.8 2.8 0 0 1 0 8.6V5.8Zm4.9 1.167a1.4 1.4 0 1 1-2.8 0 1.4 1.4 0 0 1 2.8 0Zm8.367-.768a.268.268 0 0 0 .076-.292 2.942 2.942 0 0 0-.187-.407l-.055-.096a3.012 3.012 0 0 0-.262-.37.27.27 0 0 0-.29-.08l-.66.21a2.279 2.279 0 0 0-.522-.302l-.148-.676a.268.268 0 0 0-.215-.211 3.062 3.062 0 0 0-1.008.001.268.268 0 0 0-.215.21l-.148.677a2.28 2.28 0 0 0-.522.301l-.66-.21a.268.268 0 0 0-.29.081c-.096.116-.184.24-.262.37l-.056.096c-.072.13-.135.265-.187.406a.268.268 0 0 0 .076.292l.513.467a2.293 2.293 0 0 0 0 .603l-.513.467a.268.268 0 0 0-.076.291c.052.141.115.276.187.407l.056.096c.078.13.166.253.262.37a.27.27 0 0 0 .29.08l.66-.211c.158.122.333.224.52.3l.149.677a.268.268 0 0 0 .215.211 3.06 3.06 0 0 0 1.007 0 .268.268 0 0 0 .216-.21l.148-.677a2.28 2.28 0 0 0 .521-.301l.66.21c.105.033.22.004.29-.08.097-.117.184-.24.263-.37l.055-.097c.073-.13.135-.265.188-.406a.268.268 0 0 0-.076-.292l-.513-.466a2.299 2.299 0 0 0 0-.602l.513-.467Z"})]}),Fi=({name:e,size:t=16,color:n="currentColor",strokeWidth:i=2,style:r})=>{if("iwer"===e)return u.jsx(Oi,{size:t,color:n,style:r});const s=Ni[e];return s?u.jsx(s,{size:t,color:n,strokeWidth:i,style:r}):null},ki={KeyA:"A",KeyB:"B",KeyC:"C",KeyD:"D",KeyE:"E",KeyF:"F",KeyG:"G",KeyH:"H",KeyI:"I",KeyJ:"J",KeyK:"K",KeyL:"L",KeyM:"M",KeyN:"N",KeyO:"O",KeyP:"P",KeyQ:"Q",KeyR:"R",KeyS:"S",KeyT:"T",KeyU:"U",KeyV:"V",KeyW:"W",KeyX:"X",KeyY:"Y",KeyZ:"Z",Digit0:"0",Digit1:"1",Digit2:"2",Digit3:"3",Digit4:"4",Digit5:"5",Digit6:"6",Digit7:"7",Digit8:"8",Digit9:"9",Tab:u.jsx(Fi,{name:"arrow-right-to-line",size:15}),Backspace:u.jsx(Fi,{name:"delete",size:15}),Enter:u.jsx(Fi,{name:"corner-down-left",size:15}),ShiftLeft:u.jsx(Fi,{name:"arrow-big-up",size:15}),ShiftRight:u.jsx(Fi,{name:"arrow-big-up",size:15}),Space:" ",ArrowUp:u.jsx(Fi,{name:"arrow-up",size:15}),ArrowDown:u.jsx(Fi,{name:"arrow-down",size:15}),ArrowLeft:u.jsx(Fi,{name:"arrow-left",size:15}),ArrowRight:u.jsx(Fi,{name:"arrow-right",size:15}),Semicolon:";",Equal:"=",Comma:",",Minus:"-",Period:".",Slash:"/",Backquote:"`",BracketLeft:"[",Backslash:"\\",BracketRight:"]",Quote:"'",MouseLeft:u.jsx(Fi,{name:"mouse-left",size:15}),MouseRight:u.jsx(Fi,{name:"mouse-right",size:15})},Ui=e=>{let t;const n=new Set,i=(e,i)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=i?i:"object"!=typeof r||null===r)?r:Object.assign({},t,r),n.forEach(n=>n(t,e))}},r=()=>t,s={setState:i,getState:r,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(i,r,s);return s},zi=e=>e;const Bi=e=>{const t=(e=>e?Ui(e):Ui)(e),n=e=>function(e,t=zi){const n=c.useSyncExternalStore(e.subscribe,c.useCallback(()=>t(e.getState()),[e,t]),c.useCallback(()=>t(e.getInitialState()),[e,t]));return c.useDebugValue(n),n}(t,e);return Object.assign(n,t),n},Vi=e=>e?Bi(e):Bi;function Gi(e){if("undefined"==typeof window||!e)return;const t="null"===window.location.origin?"*":window.location.origin;window.postMessage({channel:"iwer-prefs",scope:"origin",patch:e},t)}const Hi={thumbstick:"Press",trigger:"Trig",squeeze:"Grip","x-button":"X","y-button":"Y","a-button":"A","b-button":"B",thumbrest:"Rest",pose:"Pose",pinch:"Pinch"},Wi=e=>{var t;return null!==(t=Hi[e])&&void 0!==t?t:e},ji={"thumbstick-up":"arrow-up","thumbstick-down":"arrow-down","thumbstick-left":"arrow-left","thumbstick-right":"arrow-right"},Xi=["thumbstick-up","thumbstick-down","thumbstick-left","thumbstick-right","thumbstick"],qi=["trigger","squeeze","a-button","b-button","x-button","y-button","thumbrest","pose","pinch"],$i={left:{"thumbstick-up":"KeyW","thumbstick-down":"KeyS","thumbstick-left":"KeyA","thumbstick-right":"KeyD",thumbstick:"KeyR","x-button":"KeyX","y-button":"KeyZ",trigger:"KeyQ",squeeze:"KeyE",pinch:"MouseLeft",pose:"KeyF"},right:{"thumbstick-up":"ArrowUp","thumbstick-down":"ArrowDown","thumbstick-left":"ArrowLeft","thumbstick-right":"ArrowRight",thumbstick:"Slash","a-button":"Enter","b-button":"ShiftRight",trigger:"MouseLeft",squeeze:"MouseRight",pinch:"MouseRight",pose:"Backslash"}},Yi=Vi(e=>({keyMap:$i,bindKey:(t,n,i="Unmapped")=>{Gi({keymap:{[t]:{[n]:i}}}),e(e=>({keyMap:{...e.keyMap,[t]:{...e.keyMap[t],[n]:i}}}))},resetKeyMap:t=>{const n={...$i[t]};Gi({keymap:{[t]:n}}),e(e=>({keyMap:{...e.keyMap,[t]:n}}))}})),Ki=en.div`
|
|
330
|
+
display: flex;
|
|
331
|
+
align-items: center;
|
|
332
|
+
gap: 6px;
|
|
333
|
+
padding: 6px 8px;
|
|
334
|
+
background-color: ${Nn};
|
|
335
|
+
border-radius: ${Dn};
|
|
336
|
+
margin-bottom: ${In};
|
|
337
|
+
color: ${rn};
|
|
338
|
+
font-size: 10px;
|
|
339
|
+
line-height: 1.3;
|
|
340
|
+
`,Zi=en.div`
|
|
341
|
+
font-size: 10px;
|
|
342
|
+
font-weight: 600;
|
|
343
|
+
letter-spacing: 0.5px;
|
|
344
|
+
text-transform: uppercase;
|
|
345
|
+
color: ${rn};
|
|
346
|
+
margin: 4px 0 1px;
|
|
347
|
+
`,Ji=en.div`
|
|
348
|
+
display: flex;
|
|
349
|
+
flex-direction: row;
|
|
350
|
+
align-items: center;
|
|
351
|
+
gap: ${In};
|
|
352
|
+
height: ${Ln};
|
|
353
|
+
margin-bottom: ${In};
|
|
354
|
+
`,Qi=en.div`
|
|
355
|
+
flex: none;
|
|
356
|
+
width: ${Cn};
|
|
357
|
+
height: ${Ln};
|
|
358
|
+
display: flex;
|
|
359
|
+
align-items: center;
|
|
360
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
361
|
+
font-size: 10px;
|
|
362
|
+
color: ${nn};
|
|
363
|
+
`,er=en.button`
|
|
364
|
+
flex: 1 1 auto;
|
|
365
|
+
height: ${Ln};
|
|
366
|
+
display: flex;
|
|
367
|
+
align-items: center;
|
|
368
|
+
justify-content: center;
|
|
369
|
+
gap: 4px;
|
|
370
|
+
border-radius: ${Dn};
|
|
371
|
+
border: 1px solid
|
|
372
|
+
${({$listening:e})=>e?on:un};
|
|
373
|
+
background-color: ${({$listening:e})=>e?Fn:hn};
|
|
374
|
+
color: ${({$listening:e})=>e?on:tn};
|
|
375
|
+
cursor: pointer;
|
|
376
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
377
|
+
font-size: 12px;
|
|
378
|
+
transition: all 0.12s ease;
|
|
379
|
+
|
|
380
|
+
&:hover {
|
|
381
|
+
background-color: ${({$listening:e})=>e?Fn:dn};
|
|
382
|
+
}
|
|
383
|
+
&:focus {
|
|
384
|
+
outline: none;
|
|
385
|
+
}
|
|
386
|
+
`,tr=en.button`
|
|
387
|
+
flex: none;
|
|
388
|
+
width: 24px;
|
|
389
|
+
height: 24px;
|
|
390
|
+
display: flex;
|
|
391
|
+
align-items: center;
|
|
392
|
+
justify-content: center;
|
|
393
|
+
border: none;
|
|
394
|
+
border-radius: 6px;
|
|
395
|
+
background-color: transparent;
|
|
396
|
+
color: ${nn};
|
|
397
|
+
cursor: pointer;
|
|
398
|
+
transition: all 0.12s ease;
|
|
399
|
+
|
|
400
|
+
&:hover {
|
|
401
|
+
background-color: rgba(255, 255, 255, 0.06);
|
|
402
|
+
color: ${tn};
|
|
403
|
+
}
|
|
404
|
+
&:focus {
|
|
405
|
+
outline: none;
|
|
406
|
+
}
|
|
407
|
+
`,nr=en.button`
|
|
408
|
+
display: flex;
|
|
409
|
+
align-items: center;
|
|
410
|
+
justify-content: center;
|
|
411
|
+
gap: 6px;
|
|
412
|
+
width: 100%;
|
|
413
|
+
height: ${Ln};
|
|
414
|
+
border: none;
|
|
415
|
+
border-radius: ${Dn};
|
|
416
|
+
background-color: transparent;
|
|
417
|
+
color: ${nn};
|
|
418
|
+
cursor: pointer;
|
|
419
|
+
font-family:
|
|
420
|
+
system-ui,
|
|
421
|
+
-apple-system,
|
|
422
|
+
'Segoe UI',
|
|
423
|
+
Roboto,
|
|
424
|
+
sans-serif;
|
|
425
|
+
font-size: 12px;
|
|
426
|
+
transition: all 0.12s ease;
|
|
427
|
+
|
|
428
|
+
&:hover {
|
|
429
|
+
background-color: rgba(255, 255, 255, 0.06);
|
|
430
|
+
color: ${tn};
|
|
431
|
+
}
|
|
432
|
+
&:focus {
|
|
433
|
+
outline: none;
|
|
434
|
+
}
|
|
435
|
+
`,ir=({handedness:e,actions:t})=>{var n;const{keyMap:i,bindKey:r,resetKeyMap:s}=Yi(),[a,o]=l.useState(null);l.useEffect(()=>{if(!a)return;const t=t=>{ki[t.code]&&(r(e,a,t.code),o(null))},n=t=>{const n=0===t.button?"MouseLeft":2===t.button?"MouseRight":null;n&&ki[n]&&(r(e,a,n),o(null))},i=e=>e.preventDefault();return window.addEventListener("keydown",t),window.addEventListener("mousedown",n),window.addEventListener("contextmenu",i),()=>{window.removeEventListener("keydown",t),window.removeEventListener("mousedown",n),window.removeEventListener("contextmenu",i)}},[a,e,r]);const c=null!==(n=i[e])&&void 0!==n?n:{},h=Object.keys(c).filter(e=>t.includes(e)),d=Xi.filter(e=>h.includes(e)),p=h.filter(e=>!e.startsWith("thumbstick")).sort((e,t)=>qi.indexOf(e)-qi.indexOf(t)),f=t=>{const n=ki[c[t]];return u.jsxs(Ji,{children:[u.jsx(Qi,{children:ji[t]?u.jsx(Fi,{name:ji[t],size:14}):Wi(t)}),u.jsx(er,{type:"button",$listening:a===t,onClick:()=>o(a===t?null:t),onContextMenu:e=>e.preventDefault(),title:"Click, then press a key or mouse button",children:a===t?"press a key…":null!=n?n:"—"}),u.jsx(tr,{type:"button",onClick:()=>r(e,t),onContextMenu:e=>e.preventDefault(),title:"Clear binding",children:u.jsx(Fi,{name:"ban",size:12})})]},t)};return u.jsxs(u.Fragment,{children:[u.jsx(zn,{}),u.jsxs(Ki,{children:[u.jsx(Fi,{name:"keyboard",size:12}),"Click a binding, then press a key or mouse button"]}),d.length>0&&u.jsx(Zi,{children:"Thumbstick"}),d.map(f),p.length>0&&d.length>0&&u.jsx(Zi,{children:"Buttons"}),p.map(f),u.jsx(zn,{}),u.jsxs(nr,{type:"button",onClick:()=>s(e),children:[u.jsx(Fi,{name:"rotate-ccw",size:12}),"Reset to defaults"]})]})},rr=en.div`
|
|
436
|
+
display: flex;
|
|
437
|
+
flex-direction: row;
|
|
438
|
+
align-items: flex-start;
|
|
439
|
+
gap: 0;
|
|
440
|
+
margin-bottom: ${In};
|
|
441
|
+
`,sr=en.div`
|
|
442
|
+
position: relative;
|
|
443
|
+
flex: none;
|
|
444
|
+
width: ${Pn};
|
|
445
|
+
height: ${Pn};
|
|
446
|
+
border-radius: 50%;
|
|
447
|
+
background-color: ${Nn};
|
|
448
|
+
box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
|
|
449
|
+
display: flex;
|
|
450
|
+
align-items: center;
|
|
451
|
+
justify-content: center;
|
|
452
|
+
`,ar=en.div`
|
|
453
|
+
position: absolute;
|
|
454
|
+
width: 18px;
|
|
455
|
+
height: 18px;
|
|
456
|
+
border-radius: 50%;
|
|
457
|
+
background-color: ${on};
|
|
458
|
+
box-shadow: 0 0 8px ${ln};
|
|
459
|
+
cursor: grab;
|
|
460
|
+
pointer-events: auto;
|
|
461
|
+
`,or=en.div`
|
|
462
|
+
display: flex;
|
|
463
|
+
flex-direction: column;
|
|
464
|
+
gap: ${In};
|
|
465
|
+
flex: 1 1 auto;
|
|
466
|
+
/* Joystick occupies column 1 (= label-width's first field). Offset the X/Y
|
|
467
|
+
stack by one grid gap so the fields land exactly in columns 2 and 3,
|
|
468
|
+
lining up with the Position/Rotation fields above. */
|
|
469
|
+
margin-left: ${In};
|
|
470
|
+
`,lr=en.div`
|
|
471
|
+
display: flex;
|
|
472
|
+
gap: ${In};
|
|
473
|
+
align-items: center;
|
|
474
|
+
`,cr=en.div`
|
|
475
|
+
position: relative;
|
|
476
|
+
display: inline-block;
|
|
477
|
+
height: ${Ln};
|
|
478
|
+
`,ur=en.div`
|
|
479
|
+
flex: 1 1 auto;
|
|
480
|
+
height: ${Ln};
|
|
481
|
+
border-radius: ${Dn};
|
|
482
|
+
display: flex;
|
|
483
|
+
align-items: center;
|
|
484
|
+
justify-content: center;
|
|
485
|
+
cursor: pointer;
|
|
486
|
+
user-select: none;
|
|
487
|
+
font-size: 11px;
|
|
488
|
+
color: ${tn};
|
|
489
|
+
background-color: ${({$active:e})=>e?Fn:Nn};
|
|
490
|
+
transition: background-color 0.12s ease;
|
|
491
|
+
`,hr=en.button`
|
|
492
|
+
flex: none;
|
|
493
|
+
width: 22px;
|
|
494
|
+
height: ${Ln};
|
|
495
|
+
display: flex;
|
|
496
|
+
align-items: center;
|
|
497
|
+
justify-content: center;
|
|
498
|
+
border: none;
|
|
499
|
+
border-radius: 6px;
|
|
500
|
+
cursor: pointer;
|
|
501
|
+
background-color: ${({$active:e})=>e?Fn:"transparent"};
|
|
502
|
+
color: ${({$active:e})=>e?on:nn};
|
|
503
|
+
|
|
504
|
+
&:hover {
|
|
505
|
+
background-color: rgba(255, 255, 255, 0.06);
|
|
506
|
+
}
|
|
507
|
+
&:focus {
|
|
508
|
+
outline: none;
|
|
509
|
+
}
|
|
510
|
+
`,dr=en.div`
|
|
511
|
+
flex: none;
|
|
512
|
+
display: flex;
|
|
513
|
+
align-items: center;
|
|
514
|
+
gap: ${In};
|
|
515
|
+
margin-left: ${In};
|
|
516
|
+
`,pr=({xrController:e,pointerLocked:t,buttonId:n,mappedKeyUp:i,mappedKeyDown:r,mappedKeyLeft:s,mappedKeyRight:a,mappedKeyPressed:o})=>{const c=l.useRef(null),h=l.useRef({x:0,y:0}),d=l.useRef(!1),[p,f]=l.useState({x:0,y:0}),[m,g]=l.useState(!1),[v,y]=l.useState(!1),x=l.useRef(!1);x.current=v;const[b,_]=l.useState(!1),[w,S]=l.useState({up:!1,down:!1,left:!1,right:!1,pressed:!1}),M=l.useRef(w);M.current=w;l.useEffect(()=>{const t=t=>{if(!d.current||!c.current)return;const i=t.clientX-h.current.x,r=t.clientY-h.current.y;let s=i,a=r;if(Math.sqrt(i*i+r*r)>16){const e=Math.atan2(r,i);s=16*Math.cos(e),a=16*Math.sin(e)}c.current.style.transform=`translate(${s}px, ${a}px)`;const o=s/16,l=a/16;e.updateAxes(n,o,l),f({x:o,y:l})},i=()=>{d.current&&(d.current=!1,c.current&&(c.current.style.transform="translate(0, 0)"),e.updateAxes(n,0,0),f({x:0,y:0}))};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",i),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i)}},[n,e]),l.useEffect(()=>{const t=()=>{m&&!x.current&&(g(!1),e.updateButtonValue(n,0))};return window.addEventListener("mouseup",t),()=>window.removeEventListener("mouseup",t)},[m,n,e]),l.useEffect(()=>{if(!t)return;const l=(t,l)=>{if(!t)return;const c={...M.current};let u=!1;t===i&&(c.up=l,u=!0),t===r&&(c.down=l,u=!0),t===s&&(c.left=l,u=!0),t===a&&(c.right=l,u=!0),t===o&&(c.pressed=l,u=!0,e.updateButtonValue(n,l?1:0)),u&&(S(c),(t=>{const i=(t.right?1:0)-(t.left?1:0),r=(t.down?1:0)-(t.up?1:0),s=Math.sqrt(i*i+r*r);0===s?e.updateAxes(n,0,0):e.updateAxes(n,i/s,r/s)})(c))},c=e=>0===e.button?"MouseLeft":2===e.button?"MouseRight":null,u=e=>l(e.code,!0),h=e=>l(e.code,!1),d=e=>l(c(e),!0),p=e=>l(c(e),!1);return window.addEventListener("keydown",u),window.addEventListener("keyup",h),window.addEventListener("mousedown",d),window.addEventListener("mouseup",p),()=>{window.removeEventListener("keydown",u),window.removeEventListener("keyup",h),window.removeEventListener("mousedown",d),window.removeEventListener("mouseup",p)}},[t,i,r,s,a,o,n,e]);return t?u.jsxs(u.Fragment,{children:[u.jsxs(An,{children:[u.jsx(Rn,{children:"Stick"}),u.jsx(En,{$pressed:w.up,children:ki[i]}),u.jsx(En,{$pressed:w.pressed,children:ki[o]})]}),u.jsxs(An,{children:[u.jsx(En,{$pressed:w.left,children:ki[s]}),u.jsx(En,{$pressed:w.down,children:ki[r]}),u.jsx(En,{$pressed:w.right,children:ki[a]})]})]}):u.jsxs(rr,{children:[u.jsx(kn,{children:"Stick"}),u.jsx(sr,{children:u.jsx(ar,{ref:c,onMouseDown:e=>{const t=c.current;if(!t)return;const n=t.getBoundingClientRect();h.current={x:n.left+n.width/2,y:n.top+n.height/2},d.current=!0,e.preventDefault()}})}),u.jsxs(or,{children:[u.jsxs(lr,{children:[u.jsxs(cr,{children:[u.jsx(Gn,{readOnly:!0,value:p.x.toFixed(2)}),u.jsx(Hn,{children:"X"})]}),u.jsxs(cr,{children:[u.jsx(Gn,{readOnly:!0,value:p.y.toFixed(2)}),u.jsx(Hn,{children:"Y"})]})]}),u.jsxs(lr,{style:{gap:0},children:[u.jsx(ur,{$active:m||v,onMouseDown:()=>{v||(g(!0),e.updateButtonValue(n,1))},children:"click"}),u.jsxs(dr,{children:[u.jsx(hr,{$active:v,onClick:()=>{const t=!v;y(t),g(t),e.updateButtonValue(n,t?1:0)},type:"button",title:"Hold (latch)",children:u.jsx(Fi,{name:"pin",size:12})}),u.jsx(hr,{$active:b,onClick:()=>{const t=!b;_(t),e.updateButtonTouch(n,t)},type:"button",title:"Toggle touch state",children:u.jsx(Fi,{name:"circle-dot",size:12})})]})]})]})]})},fr=en.div`
|
|
517
|
+
display: flex;
|
|
518
|
+
flex-direction: row;
|
|
519
|
+
align-items: center;
|
|
520
|
+
gap: 0;
|
|
521
|
+
height: ${Ln};
|
|
522
|
+
margin-bottom: ${In};
|
|
523
|
+
|
|
524
|
+
&:last-child {
|
|
525
|
+
margin-bottom: 0;
|
|
526
|
+
}
|
|
527
|
+
`,mr=en.div`
|
|
528
|
+
flex: none;
|
|
529
|
+
display: flex;
|
|
530
|
+
align-items: center;
|
|
531
|
+
gap: ${In};
|
|
532
|
+
margin-left: ${In};
|
|
533
|
+
`,gr=en.div`
|
|
534
|
+
position: relative;
|
|
535
|
+
flex: 1 1 auto;
|
|
536
|
+
height: ${Ln};
|
|
537
|
+
border-radius: ${Dn};
|
|
538
|
+
cursor: pointer;
|
|
539
|
+
overflow: hidden;
|
|
540
|
+
display: flex;
|
|
541
|
+
align-items: center;
|
|
542
|
+
justify-content: center;
|
|
543
|
+
padding: 0 8px;
|
|
544
|
+
user-select: none;
|
|
545
|
+
background-color: ${({$active:e})=>e?Fn:Nn};
|
|
546
|
+
transition: background-color 0.12s ease;
|
|
547
|
+
`,vr=en.div`
|
|
548
|
+
position: absolute;
|
|
549
|
+
left: 0;
|
|
550
|
+
top: 0;
|
|
551
|
+
bottom: 0;
|
|
552
|
+
background-color: ${On};
|
|
553
|
+
pointer-events: none;
|
|
554
|
+
`,yr=en.span`
|
|
555
|
+
position: relative;
|
|
556
|
+
z-index: 1;
|
|
557
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
558
|
+
font-size: 11px;
|
|
559
|
+
color: ${tn};
|
|
560
|
+
pointer-events: none;
|
|
561
|
+
`,xr=en.button`
|
|
562
|
+
flex: none;
|
|
563
|
+
width: 22px;
|
|
564
|
+
height: ${Ln};
|
|
565
|
+
display: flex;
|
|
566
|
+
align-items: center;
|
|
567
|
+
justify-content: center;
|
|
568
|
+
border: none;
|
|
569
|
+
border-radius: 6px;
|
|
570
|
+
cursor: pointer;
|
|
571
|
+
background-color: ${({$active:e})=>e?Fn:"transparent"};
|
|
572
|
+
color: ${({$active:e})=>e?on:nn};
|
|
573
|
+
transition: all 0.12s ease;
|
|
574
|
+
|
|
575
|
+
&:hover {
|
|
576
|
+
background-color: rgba(255, 255, 255, 0.06);
|
|
577
|
+
}
|
|
578
|
+
&:focus {
|
|
579
|
+
outline: none;
|
|
580
|
+
}
|
|
581
|
+
`,br=({label:e,analog:t,supportsTouch:n,mappedKey:i,pointerLocked:r,onValue:s,onTouch:a})=>{const[o,c]=l.useState(0),[h,d]=l.useState(!1),[p,f]=l.useState(!1),[m,g]=l.useState(!1),v=l.useRef(null),y=l.useRef(!1),x=l.useRef(!1);x.current=h;const b=e=>{const t=Math.min(1,Math.max(0,e));c(t),s(t)};l.useEffect(()=>{if(!r)return;const e=e=>{s(e?1:0),g(e)},t=e=>"MouseLeft"===i&&0===e.button||"MouseRight"===i&&2===e.button,n=t=>{t.code===i&&e(!0)},a=t=>{t.code===i&&e(!1)},o=n=>{t(n)&&e(!0)},l=n=>{t(n)&&e(!1)};return window.addEventListener("keydown",n),window.addEventListener("keyup",a),window.addEventListener("mousedown",o),window.addEventListener("mouseup",l),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",l)}},[i,r,s]),l.useEffect(()=>{const e=e=>{if(!y.current||!t||!v.current)return;const n=v.current.getBoundingClientRect();b((e.clientX-n.left)/n.width)},n=()=>{y.current&&(y.current=!1,x.current||b(0))};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",n),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",n)}},[t]);if(r)return u.jsxs(An,{children:[u.jsx(Rn,{children:e}),u.jsx(En,{$pressed:m,children:ki[i]})]});const _=t?o.toFixed(2):h?"hold":"press";return u.jsxs(fr,{children:[u.jsx(kn,{children:e}),u.jsxs(gr,{ref:v,$active:!t&&o>0,onMouseDown:()=>{h||(y.current=!0,b(1))},title:"Click to press; drag to set value",children:[t&&u.jsx(vr,{style:{width:100*o+"%"}}),u.jsx(yr,{children:_})]}),u.jsxs(mr,{children:[u.jsx(xr,{$active:h,onClick:()=>{const e=!h;d(e),b(e?o>0?o:1:0)},title:"Hold (latch)",type:"button",children:u.jsx(Fi,{name:"pin",size:12})}),n&&u.jsx(xr,{$active:p,onClick:()=>{const e=!p;f(e),null==a||a(e)},title:"Toggle touch state",type:"button",children:u.jsx(Fi,{name:"circle-dot",size:12})})]})]})};function _r(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}const wr=en.div`
|
|
582
|
+
width: 100%;
|
|
583
|
+
display: flex;
|
|
584
|
+
flex-direction: row;
|
|
585
|
+
align-items: center;
|
|
586
|
+
margin-bottom: ${({$mb:e})=>null!=e?e:"0"};
|
|
587
|
+
`,Sr=en.div`
|
|
588
|
+
position: relative;
|
|
589
|
+
display: inline-block;
|
|
590
|
+
height: 26px;
|
|
591
|
+
`,Mr=({vector:e,label:t="",multiplier:n=1,precision:i=2,onValidInput:r=()=>{},marginBottom:s="0"})=>{const[a,o]=l.useState({x:(e.x/n).toFixed(i),y:(e.y/n).toFixed(i),z:(e.z/n).toFixed(i)}),c=l.useRef({x:_r(e.x/n,i),y:_r(e.y/n,i),z:_r(e.z/n,i)}),h=l.useRef(null),d=l.useRef({x:0,y:0,z:0}),p=()=>{const t=d.current;t.x=_r(e.x/n,i),t.y=_r(e.y/n,i),t.z=_r(e.z/n,i);const{x:r,y:s,z:a}=c.current;t.x===r&&t.y===s&&t.z===a||(c.current={x:t.x,y:t.y,z:t.z},o({x:t.x.toFixed(i),y:t.y.toFixed(i),z:t.z.toFixed(i)})),h.current=requestAnimationFrame(p)};l.useEffect(()=>(h.current=requestAnimationFrame(p),()=>{h.current&&cancelAnimationFrame(h.current)}),[e,n,i]);const f=t=>i=>{const s=i.target.value,a=parseFloat(s);o(e=>({...e,[t]:s})),isNaN(a)||(c.current[t]=a,e[t]=a*n,r())};return u.jsxs(wr,{$mb:s,children:[u.jsx(kn,{children:t}),u.jsx(Vn,{children:["x","y","z"].map(e=>u.jsxs(Sr,{children:[u.jsx(Gn,{value:a[e],onChange:f(e),className:parseFloat(a[e])!==c.current[e]?"invalid":void 0}),u.jsx(Hn,{children:e.toUpperCase()})]},`${t}-${e}`))})]})},Tr={thumbstick:"Stick",trigger:"Trig",squeeze:"Grip","a-button":"A","b-button":"B","x-button":"X","y-button":"Y",thumbrest:"Rest",menu:"Menu"};const Er=({controller:e,handle:t,handedness:n,pointerLocked:i})=>{const{keyMap:r}=Yi(),[s,a]=c.useState(e.connected),[o,l]=c.useState(!1),h=function(e){const t=new Set;for(const n of e.axes)n&&n.id&&t.add(n.id);const n=e.buttons.filter(e=>null!==e).map(e=>({id:e.id,type:e.type,hasAxes:t.has(e.id)}));return n.sort((e,t)=>e.hasAxes&&!t.hasAxes?-1:!e.hasAxes&&t.hasAxes?1:0),n}(e.gamepadConfig),d=h.flatMap(e=>e.hasAxes?[`${e.id}-left`,`${e.id}-right`,`${e.id}-up`,`${e.id}-down`,e.id]:e.id);return c.useEffect(()=>{i&&l(!1)},[i]),u.jsxs(Un,{style:"left"===n?{left:"8px",bottom:"8px"}:{right:"8px",bottom:"8px"},children:[!i&&u.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[u.jsxs("div",{style:{fontSize:"14px",fontWeight:600,display:"flex",flexDirection:"row",alignItems:"center",gap:"6px"},children:[u.jsx(Fi,{name:"gamepad-2",size:15}),"Controller [","left"===n?"L":"R","]"]}),u.jsx("div",{style:{display:"flex",flexDirection:"row",gap:"1px"},children:s?u.jsxs(u.Fragment,{children:[u.jsx(Bn,{title:`Click to ${o?"close":"change"} key bindings`,onClick:()=>l(!o),children:u.jsx(Fi,{name:"settings",size:14})}),u.jsx(Bn,{title:`Click to disconnect ${n} controller`,$isRed:!0,onClick:()=>{e.connected=!1,a(!1)},children:u.jsx(Fi,{name:"circle-x",size:14})})]}):u.jsx(Bn,{title:`Click to reconnect ${n} controller`,onClick:()=>{e.connected=!0,a(!0)},style:{marginLeft:"5px"},children:u.jsx(Fi,{name:"plug",size:14})})})]}),s&&!i&&u.jsxs(u.Fragment,{children:[!o&&u.jsxs(u.Fragment,{children:[u.jsx(zn,{}),u.jsx(Mr,{vector:t.position,label:"Pos",marginBottom:In}),u.jsx(Mr,{vector:t.rotation,label:"Rot"})]}),u.jsx(zn,{})]}),s&&(o?u.jsx(ir,{handedness:n,actions:d}):h.map(t=>{const s=r[n];return t.hasAxes?u.jsx(pr,{xrController:e,pointerLocked:i,buttonId:t.id,mappedKeyUp:s[`${t.id}-up`],mappedKeyDown:s[`${t.id}-down`],mappedKeyLeft:s[`${t.id}-left`],mappedKeyRight:s[`${t.id}-right`],mappedKeyPressed:s[t.id]},t.id):u.jsx(br,{label:(a=t.id,Tr[a]?Tr[a]:a.charAt(0).toUpperCase()+a.slice(1).replace(/-button$/,"")),analog:"analog"===t.type,supportsTouch:!0,mappedKey:s[t.id],pointerLocked:i,onValue:n=>e.updateButtonValue(t.id,n),onTouch:n=>e.updateButtonTouch(t.id,n)},t.id);var a}))]},n)},Ar=["default","pinch","point"],Rr=en.div`
|
|
592
|
+
display: flex;
|
|
593
|
+
flex-direction: row;
|
|
594
|
+
align-items: center;
|
|
595
|
+
gap: 0;
|
|
596
|
+
height: ${Ln};
|
|
597
|
+
margin-bottom: ${In};
|
|
598
|
+
`,Cr=en.div`
|
|
599
|
+
flex: 1 1 auto;
|
|
600
|
+
display: flex;
|
|
601
|
+
flex-direction: row;
|
|
602
|
+
align-items: center;
|
|
603
|
+
gap: ${In};
|
|
604
|
+
height: ${Ln};
|
|
605
|
+
`,Pr=en.button`
|
|
606
|
+
flex: none;
|
|
607
|
+
width: 22px;
|
|
608
|
+
height: ${Ln};
|
|
609
|
+
display: flex;
|
|
610
|
+
align-items: center;
|
|
611
|
+
justify-content: center;
|
|
612
|
+
border: none;
|
|
613
|
+
border-radius: 6px;
|
|
614
|
+
cursor: pointer;
|
|
615
|
+
background-color: ${Nn};
|
|
616
|
+
color: ${nn};
|
|
617
|
+
|
|
618
|
+
&:hover {
|
|
619
|
+
color: ${tn};
|
|
620
|
+
}
|
|
621
|
+
&:focus {
|
|
622
|
+
outline: none;
|
|
623
|
+
}
|
|
624
|
+
`,Ir=en.div`
|
|
625
|
+
flex: 1 1 auto;
|
|
626
|
+
height: ${Ln};
|
|
627
|
+
border-radius: ${Dn};
|
|
628
|
+
background-color: ${Nn};
|
|
629
|
+
display: flex;
|
|
630
|
+
align-items: center;
|
|
631
|
+
justify-content: center;
|
|
632
|
+
font-size: 11px;
|
|
633
|
+
color: ${tn};
|
|
634
|
+
`,Lr=({hand:e,pointerLocked:t,mappedKey:n})=>{const[i,r]=l.useState(e.poseId),[s,a]=l.useState(!1),o=e.inputSource.handedness,c=t=>{const n=(Ar.indexOf(e.poseId)+Ar.length+t)%Ar.length;r(Ar[n]),e.poseId=Ar[n],Gi({handPoses:{[o]:Ar[n]}})};return l.useEffect(()=>{const e=e=>"MouseLeft"===n&&0===e.button||"MouseRight"===n&&2===e.button,i=e=>{e.repeat||e.code===n&&(c(1),a(!0))},r=e=>{e.code===n&&a(!1)},s=t=>{e(t)&&(c(1),a(!0))},o=t=>{e(t)&&a(!1)};return t&&(window.addEventListener("keydown",i),window.addEventListener("keyup",r),window.addEventListener("mousedown",s),window.addEventListener("mouseup",o)),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",r),window.removeEventListener("mousedown",s),window.removeEventListener("mouseup",o)}},[n,t,e]),t?u.jsxs(An,{children:[u.jsx(Rn,{children:"Pose"}),u.jsx(En,{$pressed:s,children:ki[n]})]}):u.jsxs(Rr,{children:[u.jsx(kn,{children:"Pose"}),u.jsxs(Cr,{children:[u.jsx(Pr,{type:"button",onClick:()=>c(-1),title:"Previous pose",children:u.jsx(Fi,{name:"chevron-left",size:14})}),u.jsx(Ir,{children:i}),u.jsx(Pr,{type:"button",onClick:()=>c(1),title:"Next pose",children:u.jsx(Fi,{name:"chevron-right",size:14})})]})]})},Dr=({hand:e,handle:t,handedness:n,pointerLocked:i})=>{const{keyMap:r}=Yi(),[s,a]=c.useState(e.connected),[o,l]=c.useState(!1);return c.useEffect(()=>{i&&l(!1)},[i]),u.jsxs(Un,{style:"left"===n?{left:"8px",bottom:"8px"}:{right:"8px",bottom:"8px"},children:[!i&&u.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[u.jsxs("div",{style:{fontSize:"14px",fontWeight:600,display:"flex",flexDirection:"row",alignItems:"center",gap:"6px"},children:[u.jsx(Fi,{name:"hand",size:15}),"Hand [","left"===n?"L":"R","]"]}),u.jsx("div",{style:{display:"flex",flexDirection:"row",gap:"1px"},children:s?u.jsxs(u.Fragment,{children:[u.jsx(Bn,{title:`Click to ${o?"close":"change"} key bindings`,onClick:()=>l(!o),children:u.jsx(Fi,{name:"settings",size:14})}),u.jsx(Bn,{title:`Click to disconnect ${n} hand`,$isRed:!0,onClick:()=>{e.connected=!1,a(!1)},children:u.jsx(Fi,{name:"circle-x",size:14})})]}):u.jsx(Bn,{title:`Click to reconnect ${n} hand`,onClick:()=>{e.connected=!0,a(!0)},style:{marginLeft:"5px"},children:u.jsx(Fi,{name:"plug",size:14})})})]}),s&&!i&&u.jsxs(u.Fragment,{children:[!o&&u.jsxs(u.Fragment,{children:[u.jsx(zn,{}),u.jsx(Mr,{vector:t.position,label:"Pos",marginBottom:In}),u.jsx(Mr,{vector:t.rotation,label:"Rot"})]}),u.jsx(zn,{})]}),s&&(o?u.jsx(ir,{handedness:n,actions:["pose","pinch"]}):u.jsxs(u.Fragment,{children:[u.jsx(Lr,{hand:e,pointerLocked:i,mappedKey:r[n].pose}),u.jsx(br,{label:"Pinch",analog:!0,supportsTouch:!1,mappedKey:r[n].pinch,pointerLocked:i,onValue:t=>e.updatePinchValue(t)})]}))]},n)},Nr=Vi(e=>({inputMode:"controller",setInputMode:t=>e(()=>({inputMode:t}))})),Or=({xrDevice:e,inputLayer:t,pointerLocked:n})=>{const i=Nr(e=>e.inputMode);return u.jsx(u.Fragment,{children:"controller"===i?Object.entries(e.controllers).map(([e,i])=>u.jsx(Er,{controller:i,handle:t.transformHandles.get(e),handedness:e,pointerLocked:n},`controller-${e}`)):Object.entries(e.hands).map(([e,i])=>u.jsx(Dr,{hand:i,handle:t.transformHandles.get(e),handedness:e,pointerLocked:n},`hand-${e}`))})};var Fr=1e-6,kr="undefined"!=typeof Float32Array?Float32Array:Array;function Ur(){var e=new kr(16);return kr!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function zr(e){var t=new kr(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Br(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Vr(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Gr(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],y=n*o-i*a,x=n*l-r*a,b=n*c-s*a,_=i*l-r*o,w=i*c-s*o,S=r*c-s*l,M=u*m-h*f,T=u*g-d*f,E=u*v-p*f,A=h*g-d*m,R=h*v-p*m,C=d*v-p*g,P=y*C-x*R+b*A+_*E-w*T+S*M;return P?(P=1/P,e[0]=(o*C-l*R+c*A)*P,e[1]=(r*R-i*C-s*A)*P,e[2]=(m*S-g*w+v*_)*P,e[3]=(d*w-h*S-p*_)*P,e[4]=(l*E-a*C-c*T)*P,e[5]=(n*C-r*E+s*T)*P,e[6]=(g*b-f*S-v*x)*P,e[7]=(u*S-d*b+p*x)*P,e[8]=(a*R-o*E+c*M)*P,e[9]=(i*E-n*R-s*M)*P,e[10]=(f*w-m*b+v*y)*P,e[11]=(h*b-u*w-p*y)*P,e[12]=(o*T-a*A-l*M)*P,e[13]=(n*A-i*T+r*M)*P,e[14]=(m*x-f*_-g*y)*P,e[15]=(u*_-h*x+d*y)*P,e):null}function Hr(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],y=t[15],x=n[0],b=n[1],_=n[2],w=n[3];return e[0]=x*i+b*o+_*h+w*m,e[1]=x*r+b*l+_*d+w*g,e[2]=x*s+b*c+_*p+w*v,e[3]=x*a+b*u+_*f+w*y,x=n[4],b=n[5],_=n[6],w=n[7],e[4]=x*i+b*o+_*h+w*m,e[5]=x*r+b*l+_*d+w*g,e[6]=x*s+b*c+_*p+w*v,e[7]=x*a+b*u+_*f+w*y,x=n[8],b=n[9],_=n[10],w=n[11],e[8]=x*i+b*o+_*h+w*m,e[9]=x*r+b*l+_*d+w*g,e[10]=x*s+b*c+_*p+w*v,e[11]=x*a+b*u+_*f+w*y,x=n[12],b=n[13],_=n[14],w=n[15],e[12]=x*i+b*o+_*h+w*m,e[13]=x*r+b*l+_*d+w*g,e[14]=x*s+b*c+_*p+w*v,e[15]=x*a+b*u+_*f+w*y,e}function Wr(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function jr(e,t,n){var i,r,s,a=n[0],o=n[1],l=n[2],c=Math.sqrt(a*a+o*o+l*l);return c<Fr?null:(a*=c=1/c,o*=c,l*=c,i=Math.sin(t),s=1-(r=Math.cos(t)),e[0]=a*a*s+r,e[1]=o*a*s+l*i,e[2]=l*a*s-o*i,e[3]=0,e[4]=a*o*s-l*i,e[5]=o*o*s+r,e[6]=l*o*s+a*i,e[7]=0,e[8]=a*l*s+o*i,e[9]=o*l*s-a*i,e[10]=l*l*s+r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Xr(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=i+i,l=r+r,c=s+s,u=i*o,h=i*l,d=i*c,p=r*l,f=r*c,m=s*c,g=a*o,v=a*l,y=a*c;return e[0]=1-(p+m),e[1]=h+y,e[2]=d-v,e[3]=0,e[4]=h-y,e[5]=1-(u+m),e[6]=f+g,e[7]=0,e[8]=d+v,e[9]=f-g,e[10]=1-(u+p),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function qr(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function $r(e,t){var n=t[0],i=t[1],r=t[2],s=t[4],a=t[5],o=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(s*s+a*a+o*o),e[2]=Math.sqrt(l*l+c*c+u*u),e}function Yr(e,t){var n=new kr(3);$r(n,t);var i=1/n[0],r=1/n[1],s=1/n[2],a=t[0]*i,o=t[1]*r,l=t[2]*s,c=t[4]*i,u=t[5]*r,h=t[6]*s,d=t[8]*i,p=t[9]*r,f=t[10]*s,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(h-p)/g,e[1]=(d-l)/g,e[2]=(o-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(h-p)/g,e[0]=.25*g,e[1]=(o+c)/g,e[2]=(d+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(d-l)/g,e[0]=(o+c)/g,e[1]=.25*g,e[2]=(h+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(o-c)/g,e[0]=(d+l)/g,e[1]=(h+p)/g,e[2]=.25*g),e}var Kr=function(e,t,n,i,r){var s=1/Math.tan(t/2);if(e[0]=s/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0){var a=1/(i-r);e[10]=(r+i)*a,e[14]=2*r*i*a}else e[10]=-1,e[14]=-2*i;return e};function Zr(){var e=new kr(3);return kr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Jr(e,t,n){var i=new kr(3);return i[0]=e,i[1]=t,i[2]=n,i}function Qr(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function es(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function ts(e,t){var n=t[0],i=t[1],r=t[2],s=n*n+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function ns(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function is(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[0],o=n[1],l=n[2];return e[0]=r*l-s*o,e[1]=s*a-i*l,e[2]=i*o-r*a,e}function rs(e,t,n,i){var r=t[0],s=t[1],a=t[2];return e[0]=r+i*(n[0]-r),e[1]=s+i*(n[1]-s),e[2]=a+i*(n[2]-a),e}function ss(){var e=new kr(4);return kr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function as(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e}function os(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3];return e[0]=n[0]*i+n[4]*r+n[8]*s+n[12]*a,e[1]=n[1]*i+n[5]*r+n[9]*s+n[13]*a,e[2]=n[2]*i+n[6]*r+n[10]*s+n[14]*a,e[3]=n[3]*i+n[7]*r+n[11]*s+n[15]*a,e}function ls(){var e=new kr(4);return kr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function cs(e,t,n){n*=.5;var i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function us(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=n[0],l=n[1],c=n[2],u=n[3];return e[0]=i*u+a*o+r*c-s*l,e[1]=r*u+a*l+s*o-i*c,e[2]=s*u+a*c+i*l-r*o,e[3]=a*u-i*o-r*l-s*c,e}function hs(e,t,n,i){var r,s,a,o,l,c=t[0],u=t[1],h=t[2],d=t[3],p=n[0],f=n[1],m=n[2],g=n[3];return(s=c*p+u*f+h*m+d*g)<0&&(s=-s,p=-p,f=-f,m=-m,g=-g),1-s>Fr?(r=Math.acos(s),a=Math.sin(r),o=Math.sin((1-i)*r)/a,l=Math.sin(i*r)/a):(o=1-i,l=i),e[0]=o*c+l*p,e[1]=o*u+l*f,e[2]=o*h+l*m,e[3]=o*d+l*g,e}Zr(),function(){var e=ss()}();var ds,ps=function(e,t,n,i){var r=new kr(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r},fs=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},ms=as,gs=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},vs=function(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=n*n+i*i+r*r+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=i*a,e[2]=r*a,e[3]=s*a,e};Zr(),Jr(1,0,0),Jr(0,1,0),ls(),ls(),ds=new kr(9),kr!=Float32Array&&(ds[1]=0,ds[2]=0,ds[3]=0,ds[5]=0,ds[6]=0,ds[7]=0),ds[0]=1,ds[4]=1,ds[8]=1;const ys=Symbol("@iwer/action-player"),xs=Symbol("@iwer/xr-anchor"),bs=Symbol("@iwer/xr-controller"),_s=Symbol("@iwer/xr-device"),ws=Symbol("@iwer/xr-hand-input"),Ss=Symbol("@iwer/xr-tracked-input"),Ms=Symbol("@iwer/xr-frame"),Ts=Symbol("@iwer/gamepad"),Es=Symbol("@iwer/xr-system"),As=Symbol("@iwer/xr-input-source"),Rs=Symbol("@iwer/xr-webgl-layer"),Cs=Symbol("@iwer/xr-mesh"),Ps=Symbol("@iwer/xr-plane"),Is=Symbol("@iwer/xr-joint-pose"),Ls=Symbol("@iwer/xr-pose"),Ds=Symbol("@iwer/xr-viewer-pose"),Ns=Symbol("@iwer/xr-rigid-transform"),Os=Symbol("@iwer/xr-render-state"),Fs=Symbol("@iwer/xr-session"),ks=Symbol("@iwer/xr-joint-space"),Us=Symbol("@iwer/xr-reference-space"),zs=Symbol("@iwer/xr-space"),Bs=Symbol("@iwer/xr-view"),Vs=Symbol("@iwer/xr-viewport"),Gs=Symbol("@iwer/xr-ray"),Hs=Symbol("@iwer/xr-depth-info"),Ws=Symbol("@iwer/xr-hit-test"),js=Zr();class Xs extends EventTarget{constructor(e,t){super(),this[zs]={parentSpace:e,offsetMatrix:t?zr(t):Ur(),emulated:!0}}}class qs extends Xs{constructor(){super(void 0,Ur())}}class $s{static updateOffsetPosition(e,t){Wr(e[zs].offsetMatrix,t)}static updateOffsetQuaternion(e,t){const n=e[zs].offsetMatrix;qr(js,n),Xr(n,t,js)}static updateOffsetMatrix(e,t){Br(e[zs].offsetMatrix,t)}static calculateGlobalOffsetMatrix(e,t=Ur()){const n=[];let i=e;for(;i;)n.push(i),i=i[zs].parentSpace;Vr(t);for(let e=n.length-1;e>=0;e--)Hr(t,t,n[e][zs].offsetMatrix);return t}}let Ys=class e{constructor(e=0,t=0,n=0){this.vec3=Jr(e,t,n),this.tempVec3=Zr()}get x(){return this.vec3[0]}set x(e){this.vec3[0]=e}get y(){return this.vec3[1]}set y(e){this.vec3[1]=e}get z(){return this.vec3[2]}set z(e){this.vec3[2]=e}set(e,t,n){return es(this.vec3,e,t,n),this}clone(){return new e(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}normalize(){return Qr(this.tempVec3,this.vec3),ts(this.vec3,this.tempVec3),this}add(e){return Qr(this.tempVec3,this.vec3),function(e,t,n){e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2]}(this.vec3,this.tempVec3,e.vec3),this}applyQuaternion(e){return Qr(this.tempVec3,this.vec3),function(e,t,n){var i=n[0],r=n[1],s=n[2],a=n[3],o=t[0],l=t[1],c=t[2],u=r*c-s*l,h=s*o-i*c,d=i*l-r*o;u+=u,h+=h,d+=d,e[0]=o+a*u+r*d-s*h,e[1]=l+a*h+s*u-i*d,e[2]=c+a*d+i*h-r*u}(this.vec3,this.tempVec3,e.quat),this}},Ks=class e{constructor(e=0,t=0,n=0,i=1){this.quat=ps(e,t,n,i),this.tempQuat=ls()}get x(){return this.quat[0]}set x(e){this.quat[0]=e}get y(){return this.quat[1]}set y(e){this.quat[1]=e}get z(){return this.quat[2]}set z(e){this.quat[2]=e}get w(){return this.quat[3]}set w(e){this.quat[3]=e}set(e,t,n,i){return ms(this.quat,e,t,n,i),this}clone(){return new e(this.x,this.y,this.z,this.w)}copy(e){return ms(this.quat,e.x,e.y,e.z,e.w),this}normalize(){return fs(this.tempQuat,this.quat),vs(this.quat,this.tempQuat),this}invert(){return fs(this.tempQuat,this.quat),function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this.quat,this.tempQuat),this}multiply(e){return fs(this.tempQuat,this.quat),us(this.quat,this.tempQuat,e.quat),this}setFromAxisAngle(e,t){return cs(this.quat,e.vec3,t),this}};function Zs(e){return{x:e.x,y:e.y,z:e.z}}function Js(e){return{x:e.x,y:e.y,z:e.z,w:e.w}}function Qs(e){const{x:t,y:n,z:i,w:r}=e,s=180/Math.PI,a=Math.max(-1,Math.min(1,2*(r*t-n*i)));let o;o=Math.abs(a)>=1?Math.sign(a)*Math.PI/2:Math.asin(a);const l=2*(r*n+t*i),c=1-2*(t*t+n*n),u=2*(r*i+t*n),h=1-2*(t*t+i*i);return{pitch:o*s,yaw:Math.atan2(l,c)*s,roll:Math.atan2(u,h)*s}}function ea(e){return function(e){return"pitch"in e||"yaw"in e||"roll"in e}(e)?function(e){var t,n,i;const r=Math.PI/180,s=(null!==(t=e.pitch)&&void 0!==t?t:0)*r,a=(null!==(n=e.yaw)&&void 0!==n?n:0)*r,o=(null!==(i=e.roll)&&void 0!==i?i:0)*r,l=Math.cos(.5*s),c=Math.sin(.5*s),u=Math.cos(.5*a),h=Math.sin(.5*a),d=Math.cos(.5*o),p=Math.sin(.5*o);return{w:l*u*d+c*h*p,x:c*u*d+l*h*p,y:l*h*d-c*u*p,z:l*u*p-c*h*d}}(e):e}function ta(e,t,n){return e+(t-e)*n}const na={right:"controller-right",left:"controller-left","right-controller":"controller-right","left-controller":"controller-left","controllers.right":"controller-right","controllers.left":"controller-left",rightController:"controller-right",leftController:"controller-left","right-hand":"hand-right","left-hand":"hand-left","hands.right":"hand-right","hands.left":"hand-left",rightHand:"hand-right",leftHand:"hand-left"};function ia(e){var t;return null!==(t=na[e])&&void 0!==t?t:e}const ra=.15;function sa(e){switch(e){case"controller-left":case"controller-right":case"hand-left":case"hand-right":return e;default:throw new Error(`Unsupported select device: ${String(e)}`)}}const aa=ls(),oa=ls(),la=ls();function ca(e){return"number"==typeof e&&Number.isFinite(e)}function ua(e,t,n){return Math.min(n,Math.max(t,e))}function ha(e){if(!ca(e.x)||!ca(e.y)||!ca(e.z))throw new Error(`Invalid position: x, y, z must be finite numbers (got ${JSON.stringify(e)}).`)}function da(e){if(!(ca(e.x)&&ca(e.y)&&ca(e.z)&&ca(e.w)))throw new Error(`Invalid orientation: x, y, z, w must be finite numbers (got ${JSON.stringify(e)}).`);const t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w);if(t<1e-6)throw new Error("Invalid orientation: quaternion has near-zero length.");return{x:e.x/t,y:e.y/t,z:e.z/t,w:e.w/t}}class pa{constructor(e){this.commandQueue=[],this._isCaptured=!1,this.releaseTimer=null,this.actionIdCounter=0,this.RELEASE_TIMEOUT_MS=3e4,this.ACTION_TIMEOUT_MS=1e4,this.actionTimers=new WeakMap,this.device=e}generateActionId(){return"action_"+ ++this.actionIdCounter}get isCaptured(){return this._isCaptured}get queueLength(){return this.commandQueue.length}enqueueDiscrete(e,t){return new Promise((n,i)=>{const r={type:"discrete",id:this.generateActionId(),method:e,params:t,resolve:n,reject:i};this.commandQueue.push(r),this.armActionTimeout(r,e)})}enqueueDuration(e,t,n,i,r){return new Promise((s,a)=>{const o={type:"duration",id:this.generateActionId(),method:e,params:t,durationMs:n,elapsedMs:0,startState:i,targetState:r,resolve:s,reject:a};this.commandQueue.push(o),this.armActionTimeout(o,e,n)})}armActionTimeout(e,t,n=0){const i=this.ACTION_TIMEOUT_MS+n,r=setTimeout(()=>{const n=this.commandQueue.indexOf(e);-1!==n&&(this.commandQueue.splice(n,1),this.actionTimers.delete(e),e.reject(new Error(`RemoteControlInterface: action '${t}' timed out after ${i}ms with no frame processing the queue (is the XR render loop running?).`)))},i);this.actionTimers.set(e,r)}clearActionTimeout(e){const t=this.actionTimers.get(e);void 0!==t&&(clearTimeout(t),this.actionTimers.delete(e))}update(e){if(0!==this.commandQueue.length){for(this.cancelReleaseTimer(),this._isCaptured||(this._isCaptured=!0,this.device.controlMode="programmatic");this.commandQueue.length>0;){const t=this.commandQueue[0];if("discrete"===t.type){try{const e=this.executeDiscreteAction(t);t.resolve(e)}catch(e){t.reject(e)}this.clearActionTimeout(t),this.commandQueue.shift()}else{if(t.elapsedMs+=e,!(t.elapsedMs>=t.durationMs)){try{const e=t.elapsedMs/t.durationMs;this.applyDurationLerpState(t,e)}catch(e){t.reject(e),this.clearActionTimeout(t),this.commandQueue.shift();continue}break}try{this.applyDurationFinalState(t),t.resolve(this.getDurationResult(t))}catch(e){t.reject(e)}this.clearActionTimeout(t),this.commandQueue.shift()}}this.device.notifyStateChange(),0===this.commandQueue.length&&this.startReleaseTimer()}}startReleaseTimer(){this.cancelReleaseTimer(),this.releaseTimer=setTimeout(()=>{this._isCaptured=!1,this.device.controlMode="manual",this.releaseTimer=null},this.RELEASE_TIMEOUT_MS)}cancelReleaseTimer(){null!==this.releaseTimer&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}getDeviceTransform(e){switch(e){case"headset":return{position:Zs(this.device.position),orientation:Js(this.device.quaternion)};case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");return{position:Zs(e.position),orientation:Js(e.quaternion)}}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");return{position:Zs(e.position),orientation:Js(e.quaternion)}}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");return{position:Zs(e.position),orientation:Js(e.quaternion)}}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");return{position:Zs(e.position),orientation:Js(e.quaternion)}}case"gaze":{const e=this.device.gaze;if(!e)throw new Error("Gaze input not available");return us(aa,this.device.quaternion.quat,e.quaternion.quat),{position:Zs(this.device.position),orientation:{x:aa[0],y:aa[1],z:aa[2],w:aa[3]}}}default:throw new Error(`Unknown device: ${e}`)}}setDeviceTransform(e,t,n){if("gaze"===e&&t)throw new Error("Gaze position is derived from the headset. Move the headset transform instead.");t&&ha(t);const i=n?da(n):void 0;switch(e){case"headset":t&&this.device.position.set(t.x,t.y,t.z),i&&this.device.quaternion.set(i.x,i.y,i.z,i.w);break;case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"gaze":{const e=this.device.gaze;if(!e)throw new Error("Gaze input not available");i&&(!function(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=n*n+i*i+r*r+s*s,o=a?1/a:0;e[0]=-n*o,e[1]=-i*o,e[2]=-r*o,e[3]=s*o}(oa,this.device.quaternion.quat),ms(aa,i.x,i.y,i.z,i.w),us(la,oa,aa),e.quaternion.set(la[0],la[1],la[2],la[3]));break}default:throw new Error(`Unknown device: ${e}`)}}transformXROriginToGlobal(e){const t=this.device[_s].runtime.getSession();if(!t)return e;const n=t.originOffsetMatrix;if(!n)return e;const i=Jr(e.x,e.y,e.z);return function(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a}(i,i,n),{x:i[0],y:i[1],z:i[2]}}getDeviceSelectValue(e){var t,n,i,r,s,a,o,l;switch(e){case"controller-left":return null!==(n=null===(t=this.device.controllers.left)||void 0===t?void 0:t.getButtonValue("trigger"))&&void 0!==n?n:0;case"controller-right":return null!==(r=null===(i=this.device.controllers.right)||void 0===i?void 0:i.getButtonValue("trigger"))&&void 0!==r?r:0;case"hand-left":return null!==(a=null===(s=this.device.hands.left)||void 0===s?void 0:s.pinchValue)&&void 0!==a?a:0;case"hand-right":return null!==(l=null===(o=this.device.hands.right)||void 0===o?void 0:o.pinchValue)&&void 0!==l?l:0;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceSelectValue(e,t){var n,i,r,s;switch(e){case"controller-left":null===(n=this.device.controllers.left)||void 0===n||n.updateButtonValue("trigger",t);break;case"controller-right":null===(i=this.device.controllers.right)||void 0===i||i.updateButtonValue("trigger",t);break;case"hand-left":null===(r=this.device.hands.left)||void 0===r||r.updatePinchValue(t);break;case"hand-right":null===(s=this.device.hands.right)||void 0===s||s.updatePinchValue(t);break;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceConnected(e,t){switch(e){case"controller-left":this.device.controllers.left&&(this.device.controllers.left.connected=t);break;case"controller-right":this.device.controllers.right&&(this.device.controllers.right.connected=t);break;case"hand-left":this.device.hands.left&&(this.device.hands.left.connected=t);break;case"hand-right":this.device.hands.right&&(this.device.hands.right.connected=t);break;case"gaze":if(!this.device.gaze)throw new Error("Gaze input not available");this.device.gaze.connected=t;break;default:throw new Error(`Unknown input device: ${e}`)}}executeDiscreteAction(e){const{method:t,params:n}=e;switch(t){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(n);case"set_transform":return this.executeSetTransform(n);case"look_at":return this.executeLookAt(n);case"set_input_mode":return this.executeSetInputMode(n);case"set_connected":return this.executeSetConnected(n);case"get_select_value":return this.executeGetSelectValue(n);case"set_select_value":return this.executeSetSelectValue(n);case"set_hand_pose":return this.executeSetHandPose(n);case"get_gamepad_state":return this.executeGetGamepadState(n);case"set_gamepad_state":return this.executeSetGamepadState(n);case"get_device_state":return this.executeGetDeviceState();case"set_device_state":return this.executeSetDeviceState(n);case"_select_press":{const e=sa(n.device);return void this.setDeviceSelectValue(e,1)}case"_select_release":{const e=sa(n.device);return void this.setDeviceSelectValue(e,0)}default:throw new Error(`Unknown method: ${t}`)}}executeGetSessionStatus(){var e,t;const n=this.device[_s].runtime,i=n.getSession();return{deviceName:this.device.name,isRuntimeInstalled:!0,sessionActive:!!i,sessionOffered:"emulated"===n.kind&&this.device.sessionOffered,sessionMode:null!==(e=null==i?void 0:i.mode)&&void 0!==e?e:null,enabledFeatures:i?Array.from(i.enabledFeatures):[],visibilityState:null!==(t=null==i?void 0:i.visibilityState)&&void 0!==t?t:this.device.visibilityState,runtimeKind:n.kind}}executeAcceptSession(){if("native"===this.device[_s].runtime.kind)throw new Error("Session start is app-driven in native override mode; immersive sessions require a user gesture.");if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),{success:!0}}executeEndSession(){const e=this.device[_s].runtime.getSession();if(!e)throw new Error("No active session");return e.end(),{success:!0}}executeGetTransform(e){const{device:t}=e,n=this.getDeviceTransform(t);return{device:t,position:n.position,orientation:n.orientation,euler:Qs(n.orientation)}}executeSetTransform(e){const{device:t,position:n,orientation:i}=e,r=i?ea(i):void 0;this.setDeviceTransform(t,n,r);const s=this.getDeviceTransform(t);return{device:t,position:s.position,orientation:s.orientation}}executeLookAt(e){const{device:t,target:n,moveToDistance:i}=e;if("gaze"===t&&void 0!==i)throw new Error("Gaze origin is derived from the headset; moveToDistance is not supported for gaze.");const r=this.getDeviceTransform(t),s=this.transformXROriginToGlobal(n),a=function(e,t){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,s=Math.sqrt(n*n+i*i+r*r);return 0===s?{x:0,y:0,z:-1}:{x:n/s,y:i/s,z:r/s}}(r.position,s),o="headset"===t?function(e){const t=Math.sqrt(e.x*e.x+e.z*e.z);let n=0;t>1e-4&&(n=Math.atan2(-e.x,-e.z));const i=Math.atan2(e.y,t),r=Math.cos(.5*i),s=Math.sin(.5*i),a=Math.cos(.5*n),o=Math.sin(.5*n);return{w:r*a,x:s*a,y:r*o,z:-s*o}}(a):function(e,t={x:0,y:1,z:0}){const n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);if(0===n)return{x:0,y:0,z:0,w:1};const i=e.x/n,r=e.y/n,s=e.z/n,a={x:r*t.z-s*t.y,y:s*t.x-i*t.z,z:i*t.y-r*t.x},o=Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z);if(0===o){const e={x:1,y:0,z:0};a.x=r*e.z-s*e.y,a.y=s*e.x-i*e.z,a.z=i*e.y-r*e.x;const t=Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z);a.x/=t,a.y/=t,a.z/=t}else a.x/=o,a.y/=o,a.z/=o;const l={x:a.y*s-a.z*r,y:a.z*i-a.x*s,z:a.x*r-a.y*i},c=a.x,u=l.x,h=-i,d=a.y,p=l.y,f=-r,m=a.z,g=l.z,v=-s,y=c+p+v;let x,b,_,w;if(y>0){const e=.5/Math.sqrt(y+1);x=.25/e,b=(g-f)*e,_=(h-m)*e,w=(d-u)*e}else if(c>p&&c>v){const e=2*Math.sqrt(1+c-p-v);x=(g-f)/e,b=.25*e,_=(u+d)/e,w=(h+m)/e}else if(p>v){const e=2*Math.sqrt(1+p-c-v);x=(h-m)/e,b=(u+d)/e,_=.25*e,w=(f+g)/e}else{const e=2*Math.sqrt(1+v-c-p);x=(d-u)/e,b=(h+m)/e,_=(f+g)/e,w=.25*e}const S=Math.sqrt(b*b+_*_+w*w+x*x);return S>0&&(b/=S,_/=S,w/=S,x/=S),{x:b,y:_,z:w,w:x}}(a);let l;void 0!==i&&(l={x:s.x-a.x*i,y:s.y-a.y*i,z:s.z-a.z*i}),this.setDeviceTransform(t,l,o);const c=this.getDeviceTransform(t);return{device:t,position:c.position,orientation:c.orientation}}executeSetInputMode(e){var t,n,i,r,s;const{mode:a}=e;this.device.primaryInputMode=a;const o=[];return"controller"===a?((null===(t=this.device.controllers.left)||void 0===t?void 0:t.connected)&&o.push("controller-left"),(null===(n=this.device.controllers.right)||void 0===n?void 0:n.connected)&&o.push("controller-right")):((null===(i=this.device.hands.left)||void 0===i?void 0:i.connected)&&o.push("hand-left"),(null===(r=this.device.hands.right)||void 0===r?void 0:r.connected)&&o.push("hand-right")),(null===(s=this.device.gaze)||void 0===s?void 0:s.connected)&&o.push("gaze"),{mode:a,activeDevices:o}}executeSetConnected(e){const{device:t,connected:n}=e;return this.setDeviceConnected(t,n),{device:t,connected:n}}executeGetSelectValue(e){const{device:t}=e;return{device:t,value:this.getDeviceSelectValue(t)}}executeSetSelectValue(e){const{device:t,value:n}=e;return this.setDeviceSelectValue(t,n),{device:t,value:n}}executeSetHandPose(e){const{device:t,poseId:n}=e,i="hand-left"===t?"left":"hand-right"===t?"right":null;if(!i)throw new Error(`set_hand_pose requires device 'hand-left' or 'hand-right', got '${t}'.`);const r=this.device.hands[i];if(!r)throw new Error(`Hand ${i} not available`);return r.poseId=n,{device:t,poseId:n}}requireSem(){const e=this.device.sem;if(!e)throw new Error("Scene understanding (SEM) is not installed on this device. Install @iwer/sem to query the emulated world.");return e}executeGetObjects(){const e=this.requireSem(),t=[];return e.trackedPlanes.forEach(e=>{var n;t.push({type:"plane",semanticLabel:null!==(n=e.semanticLabel)&&void 0!==n?n:null})}),e.trackedMeshes.forEach(e=>{var n;t.push({type:"mesh",semanticLabel:null!==(n=e.semanticLabel)&&void 0!==n?n:null})}),{objects:t}}executeGetWorldState(){const e=this.requireSem();return{planeCount:e.trackedPlanes.size,meshCount:e.trackedMeshes.size,objects:this.executeGetObjects().objects}}listMethods(){const e=[];return pa.IMMEDIATE_METHODS.forEach(t=>{e.push({method:t,immediate:!0,requiresSession:!1})}),pa.SESSION_REQUIRED_METHODS.forEach(t=>{e.push({method:t,immediate:!1,requiresSession:!0})}),e}describe(){return this.listMethods()}connectTransport(e){e.addEventListener("message",t=>{const n=t.data;if(!n||"string"!=typeof n.method)return;const{id:i,method:r,params:s}=n;this.dispatch(r,null!=s?s:{}).then(t=>e.postMessage({id:i,result:t})).catch(t=>e.postMessage({id:i,error:t instanceof Error?t.message:String(t)}))})}executeGetGamepadState(e){const{device:t}=e,n="controller-left"===t?"left":"right",i=this.device.controllers[n];if(!i)throw new Error(`Controller ${n} not available`);const r=["trigger","squeeze","thumbstick","left"===n?"x-button":"a-button","left"===n?"y-button":"b-button","thumbrest"].map((e,t)=>({index:t,name:e.replace("x-button","x").replace("y-button","y").replace("a-button","a").replace("b-button","b"),value:i.getButtonValue(e),touched:i.getButtonTouched(e),pressed:i.getButtonValue(e)>.5})),s=i.getAxes(),a=[{index:0,name:"thumbstick-x",value:s.x},{index:1,name:"thumbstick-y",value:s.y}];return{device:t,connected:i.connected,buttons:r,axes:a}}executeSetGamepadState(e){const{device:t,buttons:n,axes:i}=e,r="controller-left"===t?"left":"right",s=this.device.controllers[r];if(!s)throw new Error(`Controller ${r} not available`);let a=0,o=0;const l=["trigger","squeeze","thumbstick","left"===r?"x-button":"a-button","left"===r?"y-button":"b-button","thumbrest"];if(n)for(const e of n){const t=l[e.index];t&&ca(e.value)&&(s.updateButtonValue(t,ua(e.value,0,1)),void 0!==e.touched&&s.updateButtonTouch(t,e.touched),a++)}if(i){let e,t;for(const n of i)ca(n.value)&&(0===n.index?(e=ua(n.value,-1,1),o++):1===n.index&&(t=ua(n.value,-1,1),o++));if(void 0!==e||void 0!==t){const n=s.getAxes();s.updateAxes("thumbstick",null!=e?e:n.x,null!=t?t:n.y)}}return{device:t,buttonsSet:a,axesSet:o}}executeGetDeviceState(){var e,t,n,i,r,s,a,o,l,c,u,h,d,p,f,m,g,v,y,x,b,_,w,S;return{headset:{position:Zs(this.device.position),orientation:Js(this.device.quaternion)},inputMode:this.device.primaryInputMode,controllers:{left:{connected:null!==(t=null===(e=this.device.controllers.left)||void 0===e?void 0:e.connected)&&void 0!==t&&t,position:Zs(null!==(i=null===(n=this.device.controllers.left)||void 0===n?void 0:n.position)&&void 0!==i?i:{x:0,y:0,z:0}),orientation:Js(null!==(s=null===(r=this.device.controllers.left)||void 0===r?void 0:r.quaternion)&&void 0!==s?s:{x:0,y:0,z:0,w:1})},right:{connected:null!==(o=null===(a=this.device.controllers.right)||void 0===a?void 0:a.connected)&&void 0!==o&&o,position:Zs(null!==(c=null===(l=this.device.controllers.right)||void 0===l?void 0:l.position)&&void 0!==c?c:{x:0,y:0,z:0}),orientation:Js(null!==(h=null===(u=this.device.controllers.right)||void 0===u?void 0:u.quaternion)&&void 0!==h?h:{x:0,y:0,z:0,w:1})}},hands:{left:{connected:null!==(p=null===(d=this.device.hands.left)||void 0===d?void 0:d.connected)&&void 0!==p&&p,position:Zs(null!==(m=null===(f=this.device.hands.left)||void 0===f?void 0:f.position)&&void 0!==m?m:{x:0,y:0,z:0}),orientation:Js(null!==(v=null===(g=this.device.hands.left)||void 0===g?void 0:g.quaternion)&&void 0!==v?v:{x:0,y:0,z:0,w:1})},right:{connected:null!==(x=null===(y=this.device.hands.right)||void 0===y?void 0:y.connected)&&void 0!==x&&x,position:Zs(null!==(_=null===(b=this.device.hands.right)||void 0===b?void 0:b.position)&&void 0!==_?_:{x:0,y:0,z:0}),orientation:Js(null!==(S=null===(w=this.device.hands.right)||void 0===w?void 0:w.quaternion)&&void 0!==S?S:{x:0,y:0,z:0,w:1})}},...this.device.gaze?{gaze:{connected:this.device.gaze.connected,orientation:this.getDeviceTransform("gaze").orientation}}:{},stereoEnabled:this.device.stereoEnabled,fov:this.device.fovy*(180/Math.PI)}}executeSetDeviceState(e){const{state:t}=e;if(t){if(t.headset){t.headset.position&&ha(t.headset.position);const e=t.headset.orientation?da(t.headset.orientation):void 0;t.headset.position&&this.device.position.set(t.headset.position.x,t.headset.position.y,t.headset.position.z),e&&this.device.quaternion.set(e.x,e.y,e.z,e.w)}void 0!==t.inputMode&&(this.device.primaryInputMode=t.inputMode),void 0!==t.stereoEnabled&&(this.device.stereoEnabled=t.stereoEnabled),void 0!==t.fov&&(this.device.fovy=t.fov*(Math.PI/180)),t.controllers&&(this.applyInputState("controller-left",t.controllers.left),this.applyInputState("controller-right",t.controllers.right)),t.hands&&(this.applyInputState("hand-left",t.hands.left),this.applyInputState("hand-right",t.hands.right)),t.gaze&&this.applyInputState("gaze",t.gaze)}else this.device.position.set(0,1.6,0),this.device.quaternion.set(0,0,0,1),this.device.primaryInputMode="controller",this.device.stereoEnabled=!1,this.device.controllers.left&&(this.device.controllers.left.position.set(-.2,1.4,-.3),this.device.controllers.left.quaternion.set(0,0,0,1),this.device.controllers.left.connected=!0),this.device.controllers.right&&(this.device.controllers.right.position.set(.2,1.4,-.3),this.device.controllers.right.quaternion.set(0,0,0,1),this.device.controllers.right.connected=!0),this.device.hands.left&&(this.device.hands.left.position.set(-.15,1.3,-.4),this.device.hands.left.quaternion.set(0,0,0,1),this.device.hands.left.connected=!0),this.device.hands.right&&(this.device.hands.right.position.set(.15,1.3,-.4),this.device.hands.right.quaternion.set(0,0,0,1),this.device.hands.right.connected=!0),this.device.gaze&&(this.device.gaze.quaternion.set(0,0,0,1),this.device.gaze.connected=!0);return{state:this.executeGetDeviceState()}}applyInputState(e,t){t&&(void 0!==t.connected&&this.setDeviceConnected(e,t.connected),(t.position||t.orientation)&&this.setDeviceTransform(e,t.position,t.orientation))}applyDurationLerpState(e,t){const{startState:n,targetState:i,params:r}=e,s=r.device;let a,o;n.position&&i.position&&(a=function(e,t,n){return{x:ta(e.x,t.x,n),y:ta(e.y,t.y,n),z:ta(e.z,t.z,n)}}(n.position,i.position,t)),n.orientation&&i.orientation&&(o=function(e,t,n){let i=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,r=t.x,s=t.y,a=t.z,o=t.w;if(i<0&&(i=-i,r=-r,s=-s,a=-a,o=-o),i>.9995){const t={x:ta(e.x,r,n),y:ta(e.y,s,n),z:ta(e.z,a,n),w:ta(e.w,o,n)},i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w);return{x:t.x/i,y:t.y/i,z:t.z/i,w:t.w/i}}const l=Math.acos(i),c=l*n,u=Math.sin(c),h=Math.sin(l),d=Math.cos(c)-i*u/h,p=u/h;return{x:d*e.x+p*r,y:d*e.y+p*s,z:d*e.z+p*a,w:d*e.w+p*o}}(n.orientation,i.orientation,t)),this.setDeviceTransform(s,a,o)}applyDurationFinalState(e){const{targetState:t,params:n}=e,i=n.device;this.setDeviceTransform(i,t.position,t.orientation)}getDurationResult(e){const{params:t,elapsedMs:n}=e,i=t.device,r=this.getDeviceTransform(i);return{device:i,position:r.position,orientation:r.orientation,actualDuration:n/1e3}}activateCaptureMode(){this._isCaptured||(this._isCaptured=!0,this.cancelReleaseTimer(),this.device.controlMode="programmatic"),this.startReleaseTimer()}async dispatch(e,t={}){var n;const i="string"==typeof t.device?{...t,device:ia(t.device)}:t;if(pa.IMMEDIATE_METHODS.has(e))return pa.ACTIVE_IMMEDIATE_METHODS.has(e)&&this.activateCaptureMode(),this.executeImmediateMethod(e,i);if(pa.SESSION_REQUIRED_METHODS.has(e)&&!this.device[_s].runtime.getSession()){const t="native"===this.device[_s].runtime.kind?"The application must start its native immersive session first.":"Use 'get_session_status' to check session state, and 'accept_session' to start a session.";throw new Error(`Cannot execute '${e}': No active XR session. `+t)}if("animate_to"===e){const t=i;if("gaze"===t.device&&t.position)throw new Error("Gaze position is derived from the headset. Move the headset transform instead.");const r=this.getDeviceTransform(t.device),s=1e3*(null!==(n=t.duration)&&void 0!==n?n:.5),a=t.orientation?ea(t.orientation):void 0,o=t.position?this.transformXROriginToGlobal(t.position):void 0;return this.enqueueDuration(e,i,s,{position:t.position?r.position:void 0,orientation:a?r.orientation:void 0},{position:o,orientation:a})}if("select"===e){const e=i;return this.executeSelectSequence(e)}return this.enqueueDiscrete(e,i)}executeImmediateMethod(e,t){switch(e){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(t);case"get_select_value":return this.executeGetSelectValue(t);case"get_gamepad_state":return this.executeGetGamepadState(t);case"get_device_state":return this.executeGetDeviceState();case"get_world_state":return this.executeGetWorldState();case"get_objects":return this.executeGetObjects();default:throw new Error(`Unknown immediate method: ${e}`)}}executeSelectSequence(e){const{device:t,duration:n=ra}=e;return this.getDeviceSelectValue(t),new Promise((e,i)=>{let r=0;const s=()=>{r++,3===r&&e({device:t,duration:n})},a={type:"discrete",id:this.generateActionId(),method:"_select_press",params:{device:t},resolve:s,reject:i},o={type:"duration",id:this.generateActionId(),method:"_select_wait",params:{device:t},durationMs:1e3*n,elapsedMs:0,startState:{},targetState:{},resolve:s,reject:i},l={type:"discrete",id:this.generateActionId(),method:"_select_release",params:{device:t},resolve:s,reject:i};this.commandQueue.push(a,o,l)})}async acceptSession(){if("native"===this.device[_s].runtime.kind)throw new Error("Session start is app-driven in native override mode; immersive sessions require a user gesture.");if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),await function(e,t=5e3){return new Promise((n,i)=>{const r=Date.now(),s=()=>{e()?n():Date.now()-r>t?i(new Error("Timeout waiting for condition")):requestAnimationFrame(s)};s()})}(()=>!!this.device.activeSession,5e3),{success:!0}}forceRelease(){this.cancelReleaseTimer(),this._isCaptured=!1,this.device.controlMode="manual";for(const e of this.commandQueue)this.clearActionTimeout(e),e.reject(new Error("Capture released"));this.commandQueue=[];for(const e of["left","right"]){const t=this.device.controllers[e];if(t){const n=["trigger","squeeze","thumbstick","thumbrest","left"===e?"x-button":"a-button","left"===e?"y-button":"b-button"];for(const e of n)t.updateButtonValue(e,0);t.updateAxes("thumbstick",0,0)}const n=this.device.hands[e];n&&n.updatePinchValue(0)}}}var fa,ma,ga;pa.IMMEDIATE_METHODS=new Set(["get_session_status","accept_session","end_session","get_transform","get_select_value","get_gamepad_state","get_device_state","get_world_state","get_objects"]),pa.ACTIVE_IMMEDIATE_METHODS=new Set(["accept_session","end_session"]),pa.SESSION_REQUIRED_METHODS=new Set(["set_transform","look_at","animate_to","set_input_mode","set_connected","set_select_value","select","set_gamepad_state","set_device_state","set_hand_pose"]),function(e){e.None="",e.Standard="standard",e.XRStandard="xr-standard"}(fa||(fa={}));class va{constructor(e,t){this[Ts]={type:e,eventTrigger:t,pressed:!1,touched:!1,value:0,lastFrameValue:0,pendingValue:null,immediateTransitionFrom:null}}get pressed(){return"manual"===this[Ts].type?this[Ts].pressed:this[Ts].value>0}get touched(){return"manual"===this[Ts].type?this[Ts].touched:this[Ts].touched||this.pressed}get value(){return this[Ts].value}}class ya{constructor(){this.pressed=!1,this.touched=!1,this.value=0}}class xa{constructor(e="vibration"){this[Ts]={type:e,lastPulse:null}}get type(){return this[Ts].type}pulse(e,t){return this[Ts].lastPulse={value:e,duration:t,startTime:performance.now()},Promise.resolve(!0)}}class ba{constructor(e,t="",n=-1,i=0){this[Ts]={id:t,index:n,connected:!1,timestamp:performance.now(),mapping:e.mapping,buttonsMap:{},buttonsSequence:[],axesMap:{},axesSequence:[],hapticActuators:Array.from({length:Math.max(0,i)},()=>new xa("vibration")),buttonsView:[],axesView:[],axesResolvers:[]},e.buttons.forEach(e=>{var t;null===e?this[Ts].buttonsSequence.push(null):(this[Ts].buttonsSequence.push(e.id),this[Ts].buttonsMap[e.id]=new va(e.type,null!==(t=e.eventTrigger)&&void 0!==t?t:null))}),e.axes.forEach(e=>{null===e?this[Ts].axesSequence.push(null):(this[Ts].axesSequence.push(e.id+e.type),this[Ts].axesMap[e.id]||(this[Ts].axesMap[e.id]={x:0,y:0}))}),this[Ts].buttonsView=this[Ts].buttonsSequence.map(e=>null===e?new ya:this[Ts].buttonsMap[e]),this[Ts].axesResolvers=this[Ts].axesSequence.map(e=>null===e?null:{axisId:e.substring(0,e.length-6),isY:"y-axis"===e.substring(e.length-6)}),this[Ts].axesView=this[Ts].axesResolvers.map(()=>null)}get id(){return this[Ts].id}get index(){return this[Ts].index}get connected(){return this[Ts].connected}get timestamp(){return this[Ts].timestamp}get mapping(){return this[Ts].mapping}get axes(){const{axesView:e,axesResolvers:t,axesMap:n}=this[Ts];for(let i=0;i<t.length;i++){const r=t[i];if(null===r)e[i]=null;else{const t=n[r.axisId];e[i]=r.isY?t.y:t.x}}return e}get buttons(){return this[Ts].buttonsView}get hapticActuators(){return this[Ts].hapticActuators}get vibrationActuator(){var e;return null!==(e=this[Ts].hapticActuators[0])&&void 0!==e?e:null}}!function(e){e.None="none",e.Left="left",e.Right="right"}(ma||(ma={})),function(e){e.Gaze="gaze",e.TrackedPointer="tracked-pointer",e.Screen="screen",e.TransientPointer="transient-pointer"}(ga||(ga={}));class _a extends Array{}class wa{constructor(e,t,n,i,r,s,a){this[As]={handedness:e,targetRayMode:t,targetRaySpace:i,gripSpace:s,profiles:n,gamepad:r,hand:a}}get handedness(){return this[As].handedness}get targetRayMode(){return this[As].targetRayMode}get targetRaySpace(){return this[As].targetRaySpace}get gripSpace(){return this[As].gripSpace}get profiles(){return this[As].profiles}get gamepad(){return this[As].gamepad}get hand(){return this[As].hand}}class Sa extends Event{constructor(e,t){if(super(e,t),!t.frame)throw new Error("XRInputSourceEventInit.frame is required");if(!t.inputSource)throw new Error("XRInputSourceEventInit.inputSource is required");this.frame=t.frame,this.inputSource=t.inputSource}}const Ma={[ma.Left]:{position:new Ys(-.25,1.5,-.4),quaternion:new Ks},[ma.Right]:{position:new Ys(.25,1.5,-.4),quaternion:new Ks},[ma.None]:{position:new Ys(.25,1.5,-.4),quaternion:new Ks}};class Ta{constructor(e){this[Ss]={inputSource:e,position:Ma[e.handedness].position.clone(),quaternion:Ma[e.handedness].quaternion.clone(),connected:!0,lastFrameConnected:!1,inputSourceChanged:!0}}get position(){return this[Ss].position}get quaternion(){return this[Ss].quaternion}get inputSource(){return this[Ss].inputSource}get connected(){return this[Ss].connected}set connected(e){this[Ss].connected=e;const t=this[Ss].inputSource.gamepad;t&&(t[Ts].connected=e)}updateTargetRaySpace(){Xr(this[Ss].inputSource.targetRaySpace[zs].offsetMatrix,this[Ss].quaternion.quat,this[Ss].position.vec3)}onFrameStart(e){var t;this.updateTargetRaySpace();const n=e.session;null===(t=this[Ss].inputSource.gamepad)||void 0===t||t.buttons.forEach(t=>{var i;t instanceof va&&(t[Ts].lastFrameValue=null!==(i=t[Ts].immediateTransitionFrom)&&void 0!==i?i:t[Ts].value,t[Ts].immediateTransitionFrom=null,null!=t[Ts].pendingValue&&(t[Ts].value=t[Ts].pendingValue,t[Ts].pendingValue=null),null!=t[Ts].eventTrigger&&(0===t[Ts].lastFrameValue&&t[Ts].value>0?(n.dispatchEvent(new Sa(t[Ts].eventTrigger,{frame:e,inputSource:this[Ss].inputSource})),n.dispatchEvent(new Sa(t[Ts].eventTrigger+"start",{frame:e,inputSource:this[Ss].inputSource}))):t[Ts].lastFrameValue>0&&0===t[Ts].value&&n.dispatchEvent(new Sa(t[Ts].eventTrigger+"end",{frame:e,inputSource:this[Ss].inputSource}))))}),this[Ss].inputSourceChanged=this.connected!==this[Ss].lastFrameConnected,this[Ss].lastFrameConnected=this.connected}}class Ea extends Ta{constructor(e,t,n){if(!e.layout[t])throw new DOMException("Handedness not supported","InvalidStateError");const i=new Xs(n),r=e.layout[t].gripOffsetMatrix?new Xs(i,e.layout[t].gripOffsetMatrix):void 0,s=[e.profileId,...e.fallbackProfileIds];super(new wa(t,ga.TrackedPointer,s,i,new ba(e.layout[t].gamepad,"",-1,e.layout[t].numHapticActuators),r)),this[bs]={profileId:e.profileId,gamepadConfig:e.layout[t].gamepad}}get gamepadConfig(){return this[bs].gamepadConfig}get profileId(){return this[bs].profileId}updateButtonValue(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[Ss].inputSource.gamepad[Ts].buttonsMap[e];if(n){if("binary"===n[Ts].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);n[Ts].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}setButtonValueImmediate(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[Ss].inputSource.gamepad[Ts].buttonsMap[e];if(n){if("binary"===n[Ts].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);null===n[Ts].immediateTransitionFrom&&(n[Ts].immediateTransitionFrom=n[Ts].value),n[Ts].value=t,n[Ts].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}updateButtonTouch(e,t){const n=this[Ss].inputSource.gamepad[Ts].buttonsMap[e];n?n[Ts].touched=t:console.warn(`Current controller does not have button ${e}.`)}updateAxis(e,t,n){if(n>1||n<-1)return void console.warn(`Out-of-range value ${n} provided for ${e} axes.`);const i=this[Ss].inputSource.gamepad[Ts].axesMap[e];i?"x-axis"===t?i.x=n:"y-axis"===t&&(i.y=n):console.warn(`Current controller does not have ${e} axes.`)}updateAxes(e,t,n){if(t>1||t<-1||n>1||n<-1)return void console.warn(`Out-of-range value x:${t}, y:${n} provided for ${e} axes.`);const i=this[Ss].inputSource.gamepad[Ts].axesMap[e];i?(i.x=t,i.y=n):console.warn(`Current controller does not have ${e} axes.`)}getButtonValue(e){var t;const n=this[Ss].inputSource.gamepad[Ts].buttonsMap[e];return n?null!==(t=n[Ts].pendingValue)&&void 0!==t?t:n.value:0}getButtonTouched(e){const t=this[Ss].inputSource.gamepad[Ts].buttonsMap[e];return!!t&&t.touched}getAxes(e="thumbstick"){const t=this[Ss].inputSource.gamepad[Ts].axesMap[e];return t?{x:t.x,y:t.y}:{x:0,y:0}}}class Aa{constructor(e,t,n,i,r){this[Cs]={nativeMesh:e,frame:void 0,meshSpace:t,vertices:n,indices:i,lastChangedTime:performance.now(),semanticLabel:r}}get meshSpace(){return this[Cs].meshSpace}get vertices(){return this[Cs].vertices}get indices(){return this[Cs].indices}get lastChangedTime(){return this[Cs].lastChangedTime}get semanticLabel(){return this[Cs].semanticLabel}}class Ra extends Set{}class Ca{constructor(e,t,n,i){this.transform=e,this.vertices=t,this.indices=n,this.semanticLabel=i}}var Pa,Ia;!function(e){e.Desk="desk",e.Couch="couch",e.Floor="floor",e.Ceiling="ceiling",e.Wall="wall",e.Door="door",e.Window="window",e.Table="table",e.Shelf="shelf",e.Bed="bed",e.Screen="screen",e.Lamp="lamp",e.Plant="plant",e.WallArt="wall art",e.GlobalMesh="global mesh",e.Other="other"}(Pa||(Pa={})),function(e){e.Horizontal="horizontal",e.Vertical="vertical"}(Ia||(Ia={}));const La={[Pa.Desk]:Ia.Horizontal,[Pa.Couch]:Ia.Horizontal,[Pa.Floor]:Ia.Horizontal,[Pa.Ceiling]:Ia.Horizontal,[Pa.Wall]:Ia.Vertical,[Pa.Door]:Ia.Vertical,[Pa.Window]:Ia.Vertical,[Pa.Table]:Ia.Horizontal,[Pa.Shelf]:Ia.Horizontal,[Pa.Bed]:Ia.Horizontal,[Pa.Screen]:Ia.Vertical,[Pa.Lamp]:Ia.Horizontal,[Pa.Plant]:Ia.Horizontal,[Pa.WallArt]:Ia.Vertical};function Da(e,t){var n;const i=null===(n=e.transform)||void 0===n?void 0:n.orientation;if(i){const e=1-2*(i.x*i.x+i.z*i.z);return Math.abs(e)>=Math.SQRT1_2?Ia.Horizontal:Ia.Vertical}return t?La[t]:void 0}class Na{constructor(e,t,n,i){this[Ps]={nativePlane:e,frame:void 0,planeSpace:t,polygon:n,lastChangedTime:performance.now(),semanticLabel:i,orientation:Da(e,i)}}get planeSpace(){return this[Ps].planeSpace}get polygon(){return this[Ps].polygon}get orientation(){return this[Ps].orientation}get lastChangedTime(){return this[Ps].lastChangedTime}get semanticLabel(){return this[Ps].semanticLabel}}class Oa extends Set{}class Fa{constructor(e,t,n){this.transform=e,this.polygon=t,this.semanticLabel=n}}class ka{constructor(e,t,n,i,r,s){this[Hs]={data:e,width:t,height:n,normDepthBufferFromNormView:i,rawValueToMeters:r,dataFormat:s,view:"float32"===s?new Float32Array(e):new Uint8Array(e)}}get data(){return this[Hs].data}get width(){return this[Hs].width}get height(){return this[Hs].height}get normDepthBufferFromNormView(){return this[Hs].normDepthBufferFromNormView}get rawValueToMeters(){return this[Hs].rawValueToMeters}get dataFormat(){return this[Hs].dataFormat}getDepthInMeters(e,t){const{width:n,height:i,rawValueToMeters:r,dataFormat:s,view:a}=this[Hs];if(e<0||e>=1||t<0||t>=1)throw new RangeError("Normalized coordinates must be in [0, 1) range.");const o=Math.floor(e*n),l=Math.floor(t*i);if("float32"===s){return a[l*n+o]*r}{const e=a,t=2*(l*n+o);return(e[t]+256*e[t+1])*r}}}class Ua{constructor(e,t,n,i,r,s,a,o,l){this.texture=e,this.width=t,this.height=n,this.normDepthBufferFromNormView=i,this.rawValueToMeters=r,this.depthNear=s,this.depthFar=a,this.textureType=o,this.imageIndex=l,this.isValid=!0}}let za=class{constructor(e,t){this._session=e}getDepthInformation(e){var t;const n=this._session[Fs].activeFrame;if(!n||!n[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(!this._session[Fs].enabledFeatures.includes("depth-sensing"))throw new DOMException("depth-sensing feature is not enabled on this session.","InvalidStateError");if("gpu-optimized"!==this._session[Fs].depthSensingUsage)throw new DOMException("getDepthInformation on XRWebGLBinding requires gpu-optimized depth sensing usage.","InvalidStateError");const i=e[Bs].eye;return null!==(t=n[Ms].gpuDepthDataMap.get(i))&&void 0!==t?t:null}};class Ba{constructor(e,t){this[xs]={anchorSpace:e,session:t,deleted:!1},t[Fs].trackedAnchors.add(this)}get anchorSpace(){if(this[xs].deleted)throw new DOMException("XRAnchor has already been deleted.","InvalidStateError");return this[xs].anchorSpace}requestPersistentHandle(){return new Promise((e,t)=>{if(this[xs].deleted)t(new DOMException("XRAnchor has already been deleted.","InvalidStateError"));else{const t=this[xs].session[Fs].persistentAnchors;for(const[n,i]of t.entries())if(i===this)return void e(n);const n=crypto.randomUUID();Ha.createPersistentAnchor(this[xs].session,this,n),e(n)}})}delete(){this[xs].deleted||(this[xs].anchorSpace=null,this[xs].deleted=!0,this[xs].session[Fs].trackedAnchors.delete(this))}}class Va extends Set{}const Ga="@immersive-web-emulation-runtime/persistent-anchors";class Ha{static recoverPersistentAnchorsFromStorage(e){const t=JSON.parse(localStorage.getItem(Ga)||"{}"),n=e[Fs].device[_s].globalSpace;Object.entries(t).forEach(([t,i])=>{const r=new Xs(n,i),s=new Ba(r,e);e[Fs].persistentAnchors.set(t,s)})}static createPersistentAnchor(e,t,n){e[Fs].trackedAnchors.add(t),e[Fs].persistentAnchors.set(n,t);const i=JSON.parse(localStorage.getItem(Ga)||"{}");i[n]=Array.from(t[xs].anchorSpace[zs].offsetMatrix),localStorage.setItem(Ga,JSON.stringify(i))}}class Wa{constructor(e,t){const n=Jr(0,0,0),i=ls(),r=e?Jr(e.x,e.y,e.z):n,s=t?vs(ls(),ps(t.x,t.y,t.z,t.w)):i;this[Ns]={matrix:Ur(),position:r,orientation:s,positionPoint:new DOMPointReadOnly(r[0],r[1],r[2],1),orientationPoint:new DOMPointReadOnly(s[0],s[1],s[2],s[3]),inverse:null},this.updateMatrix()}updateMatrix(){Xr(this[Ns].matrix,this[Ns].orientation,this[Ns].position)}get matrix(){return this[Ns].matrix}get position(){return this[Ns].positionPoint}get orientation(){return this[Ns].orientationPoint}get inverse(){if(!this[Ns].inverse){const e=Ur();if(!Gr(e,this[Ns].matrix))throw new Error("Matrix is not invertible.");let t=Zr();qr(t,e);let n=ls();Yr(n,e),this[Ns].inverse=new Wa(new DOMPointReadOnly(t[0],t[1],t[2],1),new DOMPointReadOnly(n[0],n[1],n[2],n[3])),this[Ns].inverse[Ns].inverse=this}return this[Ns].inverse}}let ja=class{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}};class Xa{constructor(e,t){const n={x:0,y:0,z:0,w:1},i={x:0,y:0,z:-1,w:0};if(e instanceof Wa){const t=e.matrix,r=as(ss(),n.x,n.y,n.z,n.w),s=as(ss(),i.x,i.y,i.z,i.w);os(r,r,t),os(s,s,t),n.x=r[0],n.y=r[1],n.z=r[2],n.w=r[3],i.x=s[0],i.y=s[1],i.z=s[2],i.w=s[3]}else if(e&&(n.x=e.x,n.y=e.y,n.z=e.z,n.w=e.w),t){if(0===t.x&&0===t.y&&0===t.z||0!==t.w)throw new DOMException("Invalid direction value to construct XRRay","TypeError");i.x=t.x,i.y=t.y,i.z=t.z,i.w=t.w}const r=Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z)||1;i.x=i.x/r,i.y=i.y/r,i.z=i.z/r,this[Gs]={origin:new ja(n.x,n.y,n.z,n.w),direction:new ja(i.x,i.y,i.z,i.w),matrix:null}}get origin(){return this[Gs].origin}get direction(){return this[Gs].direction}get matrix(){if(this[Gs].matrix)return this[Gs].matrix;const e=es(Zr(),0,0,-1),t=es(Zr(),this[Gs].origin.x,this[Gs].origin.y,this[Gs].origin.z),n=es(Zr(),this[Gs].direction.x,this[Gs].direction.y,this[Gs].direction.z),i=is(Zr(),n,e),r=ns(n,e),s=Ur();r>-1&&r<1?jr(s,Math.acos(r),i):-1===r?jr(s,Math.acos(r),es(Zr(),1,0,0)):Vr(s);const a=Wr(Ur(),t),o=Hr(Ur(),a,s);return this[Gs].matrix=new Float32Array(o),this[Gs].matrix}}class qa{constructor(e,t){var n;this[Ws]={session:e,space:t.space,offsetRay:null!==(n=t.offsetRay)&&void 0!==n?n:new Xa,entityTypes:t.entityTypes}}cancel(){this[Ws].session[Fs].hitTestSources.delete(this)}}class $a{constructor(e,t){this[Ws]={frame:e,offsetSpace:t}}getPose(e){return this[Ws].frame.getPose(this[Ws].offsetSpace,e)}createAnchor(){return this[Ws].frame.createAnchor(new Wa,this[Ws].offsetSpace)}}class Ya extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRInputSourcesChangeEventInit.session is required");if(!t.added)throw new Error("XRInputSourcesChangeEventInit.added is required");if(!t.removed)throw new Error("XRInputSourcesChangeEventInit.removed is required");this.session=t.session,this.added=t.added,this.removed=t.removed}}var Ka,Za,Ja;!function(e){e.Viewer="viewer",e.Local="local",e.LocalFloor="local-floor",e.BoundedFloor="bounded-floor",e.Unbounded="unbounded"}(Za||(Za={}));class Qa extends Xs{constructor(e,t,n){super(t,n),this[Ka]={type:null,onreset:null},this[Us].type=e}get onreset(){return this[Us].onreset}set onreset(e){this[Us].onreset&&this.removeEventListener("reset",this[Us].onreset),this[Us].onreset=e,e&&this.addEventListener("reset",e)}getOffsetReferenceSpace(e){return new Qa(this[Us].type,this,e)}}Ka=Us;class eo{constructor(e={},t){var n,i,r,s,a,o,l,c;this[Os]={depthNear:null!==(i=null!==(n=e.depthNear)&&void 0!==n?n:null==t?void 0:t.depthNear)&&void 0!==i?i:.1,depthFar:null!==(s=null!==(r=e.depthFar)&&void 0!==r?r:null==t?void 0:t.depthFar)&&void 0!==s?s:1e3,inlineVerticalFieldOfView:null!==(o=null!==(a=e.inlineVerticalFieldOfView)&&void 0!==a?a:null==t?void 0:t.inlineVerticalFieldOfView)&&void 0!==o?o:null,baseLayer:null!==(c=null!==(l=e.baseLayer)&&void 0!==l?l:null==t?void 0:t.baseLayer)&&void 0!==c?c:null}}get depthNear(){return this[Os].depthNear}get depthFar(){return this[Os].depthFar}get inlineVerticalFieldOfView(){return this[Os].inlineVerticalFieldOfView}get baseLayer(){return this[Os].baseLayer}}class to extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRSessionEventInit.session is required");this.session=t.session}}!function(e){e.None="none",e.Left="left",e.Right="right"}(Ja||(Ja={}));class no{constructor(e,t,n,i){this[Bs]={eye:e,projectionMatrix:t,transform:n,recommendedViewportScale:null,requestedViewportScale:1,session:i}}get eye(){return this[Bs].eye}get projectionMatrix(){return this[Bs].projectionMatrix}get transform(){return this[Bs].transform}get recommendedViewportScale(){return this[Bs].recommendedViewportScale}requestViewportScale(e){null===e||e<=0||e>1?console.warn("Invalid scale value. Scale must be > 0 and <= 1."):this[Bs].requestedViewportScale=e}}class io{constructor(e,t=!1,n=void 0,i=void 0){this[Ls]={transform:e,emulatedPosition:t,linearVelocity:n,angularVelocity:i}}get transform(){return this[Ls].transform}get emulatedPosition(){return this[Ls].emulatedPosition}get linearVelocity(){return this[Ls].linearVelocity}get angularVelocity(){return this[Ls].angularVelocity}}class ro extends io{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[Is]={radius:t}}get radius(){return this[Is].radius}}class so extends io{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[Ds]={views:Object.freeze(t)}}get views(){return this[Ds].views}}const ao=Ur(),oo=Ur(),lo=Ur(),co=Zr(),uo=ls(),ho=[Ja.None],po=[Ja.Left,Ja.Right],fo=(e,t,n)=>{$s.calculateGlobalOffsetMatrix(t,ao),$s.calculateGlobalOffsetMatrix(n,oo),Gr(lo,oo),Hr(e,lo,ao)};class mo{constructor(e,t,n,i,r){this[Ms]={session:e,id:t,active:n,animationFrame:i,predictedDisplayTime:r,tempMat4:Ur(),detectedPlanes:new Oa,detectedMeshes:new Ra,trackedAnchors:e[Fs].frameTrackedAnchors,hitTestResultsMap:new Map,depthDataMap:new Map,gpuDepthDataMap:new Map}}get session(){return this[Ms].session}get predictedDisplayTime(){return this[Ms].predictedDisplayTime}getPose(e,t){if(!this[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return fo(this[Ms].tempMat4,e,t),qr(co,this[Ms].tempMat4),Yr(uo,this[Ms].tempMat4),new io(new Wa({x:co[0],y:co[1],z:co[2],w:1},{x:uo[0],y:uo[1],z:uo[2],w:uo[3]}),e[zs].emulated)}getViewerPose(e){if(!this[Ms].animationFrame)throw new DOMException("getViewerPose can only be called on XRFrame objects passed to XRSession.requestAnimationFrame callbacks.","InvalidStateError");const t=this[Ms].session,n=t[Fs].device,i=this.getPose(n.viewerSpace,e),r="inline"===t[Fs].mode?ho:po,s=[];return r.forEach(i=>{const r=n.viewSpaces[i],a=this.getPose(r,e),o=t[Fs].getProjectionMatrix(i),l=new no(i,new Float32Array(o),a.transform,t);s.push(l)}),new so(i.transform,s,!1)}getJointPose(e,t){const n=this.getPose(e,t),i=e[ks].radius;return new ro(n.transform,i,!1)}fillJointRadii(e,t){if(e=Array.from(e),!this[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(e.length>t.length)throw new DOMException("The length of jointSpaces is larger than the number of elements in radii","TypeError");let n=!0;for(let i=0;i<e.length;i++)e[i][ks].radius?t[i]=e[i][ks].radius:(t[i]=NaN,n=!1);return n}fillPoses(e,t,n){if(e=Array.from(e),!this[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(16*e.length>n.length)throw new DOMException("The length of spaces multiplied by 16 is larger than the number of elements in transforms","TypeError");return e.forEach((e,i)=>{fo(this[Ms].tempMat4,e,t),n.set(this[Ms].tempMat4,16*i)}),!0}get detectedPlanes(){if(!this[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[Ms].detectedPlanes}get detectedMeshes(){if(!this[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[Ms].detectedMeshes}get trackedAnchors(){if(!this[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[Ms].trackedAnchors}createAnchor(e,t){return new Promise((n,i)=>{if(this[Ms].active){const r=this[Ms].session[Fs].device[_s].globalSpace,s=new Xs(t,e.matrix),a=$s.calculateGlobalOffsetMatrix(s),o=new Xs(r,a),l=new Ba(o,this[Ms].session);this[Ms].session[Fs].trackedAnchors.add(l),this[Ms].session[Fs].newAnchors.set(l,{resolve:n,reject:i})}else i(new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError"))})}getHitTestResults(e){if(this[Ms].active){if(this[Ms].hitTestResultsMap.has(e))return[...this[Ms].hitTestResultsMap.get(e)];throw new DOMException("Requested hit test results are not available for current frame.","InvalidStateError")}throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError")}getDepthInformation(e){var t;if(!this[Ms].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(!this[Ms].session[Fs].enabledFeatures.includes("depth-sensing"))throw new DOMException("depth-sensing feature is not enabled on this session.","InvalidStateError");return null!==(t=this[Ms].depthDataMap.get(e[Bs].eye))&&void 0!==t?t:null}}var go,vo,yo;!function(e){e.Opaque="opaque",e.AlphaBlend="alpha-blend",e.Additive="additive"}(go||(go={})),function(e){e.ScreenSpace="screen-space",e.WorldSpace="world-space"}(vo||(vo={}));class xo extends EventTarget{constructor(e,t,n,i){var r,s;super(),this[Fs]={device:e,mode:t,renderState:new eo,pendingRenderState:null,enabledFeatures:n,hasAnchors:n.includes("anchors"),hasPlanes:n.includes("plane-detection"),hasMeshes:n.includes("mesh-detection"),hasDepth:n.includes("depth-sensing"),hasHitTest:n.includes("hit-test"),hasGazeTracking:n.includes("gaze-tracking")||n.includes("eye-tracking"),supportedFrameRates:new Float32Array(e.supportedFrameRates),isSystemKeyboardSupported:!1,ended:!1,projectionMatrices:{[Ja.Left]:Ur(),[Ja.Right]:Ur(),[Ja.None]:Ur()},getProjectionMatrix:e=>this[Fs].projectionMatrices[e],referenceSpaceIsSupported:e=>{if(!this[Fs].enabledFeatures.includes(e))return!1;switch(e){case Za.Viewer:return!0;case Za.Local:case Za.LocalFloor:case Za.BoundedFloor:case Za.Unbounded:return"inline"!=this[Fs].mode}},frameHandle:0,frameCallbacks:[],currentFrameCallbacks:null,onDeviceFrame:()=>{if(this[Fs].ended)return;this[Fs].deviceFrameHandle=globalThis.requestAnimationFrame(this[Fs].onDeviceFrame),null!=this[Fs].pendingRenderState&&(this[Fs].renderState=this[Fs].pendingRenderState,this[Fs].pendingRenderState=null,this[Fs].device[_s].onBaseLayerSet(this[Fs].renderState.baseLayer));const e=this[Fs].renderState.baseLayer;if(null===e)return;const t=e.context,n=t.canvas;if("inline"!=this[Fs].mode){const e=t.getParameter(t.COLOR_CLEAR_VALUE),n=t.getParameter(t.DEPTH_CLEAR_VALUE),i=t.getParameter(t.STENCIL_CLEAR_VALUE);t.clearColor(0,0,0,0),t.clearDepth(1),t.clearStencil(0),t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),t.clearColor(e[0],e[1],e[2],e[3]),t.clearDepth(n),t.clearStencil(i)}const{depthNear:i,depthFar:r}=this[Fs].renderState,{width:s,height:a}=n;if("inline"!==this[Fs].mode){const e=s*(this[Fs].device.stereoEnabled?.5:1)/a;Kr(this[Fs].projectionMatrices[Ja.Left],this[Fs].device.fovy,e,i,r),Br(this[Fs].projectionMatrices[Ja.Right],this[Fs].projectionMatrices[Ja.Left])}else{const e=s/a;Kr(this[Fs].projectionMatrices[Ja.None],this[Fs].renderState.inlineVerticalFieldOfView,e,i,r)}const o=performance.now(),l=new mo(this,this[Fs].frameHandle,!0,!0,o),c=this[Fs].device[_s].devui;if(c&&c.render(o),"immersive-ar"===this[Fs].mode){const e=this[Fs].device[_s].sem;e&&e.render(o)}this[Fs].hasAnchors&&this[Fs].updateTrackedAnchors(),this[Fs].hasPlanes&&this[Fs].updateTrackedPlanes(l),this[Fs].hasMeshes&&this[Fs].updateTrackedMeshes(l),this[Fs].hasDepth&&this[Fs].computeDepthSensing(l),this[Fs].hasHitTest&&this[Fs].computeHitTestResults(l),this[Fs].activeFrame=l,this[Fs].device[_s].onFrameStart(l),this[Fs].updateActiveInputSources();const u=this[Fs].currentFrameCallbacks=this[Fs].frameCallbacks;this[Fs].frameCallbacks=[];for(let e=0;e<u.length;e++)try{u[e].cancelled||u[e].callback(o,l)}catch(e){console.error(e)}this[Fs].currentFrameCallbacks=null,l[Ms].active=!1,this[Fs].activeFrame=null},nominalFrameRate:e.internalNominalFrameRate,referenceSpaces:[],inputSourceArray:[],activeInputSources:[],updateActiveInputSources:()=>{const e=this[Fs].enabledFeatures.includes("hand-tracking"),t=this[Fs].hasGazeTracking,n=this[Fs].activeInputSources,i=this[Fs].device.inputSources.filter(n=>(!n.hand||e)&&("gaze"!==n.targetRayMode||t)),r=i.filter(e=>!n.includes(e)),s=n.filter(e=>!i.includes(e));this[Fs].activeInputSources=i,(r.length>0||s.length>0)&&this.dispatchEvent(new Ya("inputsourceschange",{session:this,added:r,removed:s}))},trackedAnchors:new Va,persistentAnchors:new Map,newAnchors:new Map,frameTrackedAnchors:new Va,updateTrackedAnchors:()=>{this[Fs].enabledFeatures.includes("anchors")&&(this[Fs].frameTrackedAnchors.clear(),Array.from(this[Fs].trackedAnchors).forEach(e=>{if(e[xs].deleted){if(this[Fs].trackedAnchors.delete(e),this[Fs].newAnchors.has(e)){const{reject:t}=this[Fs].newAnchors.get(e);t(new DOMException("Anchor is no longer tracked","InvalidStateError"))}}else if(this[Fs].frameTrackedAnchors.add(e),this[Fs].newAnchors.has(e)){const{resolve:t}=this[Fs].newAnchors.get(e);t(e),this[Fs].newAnchors.delete(e)}}))},trackedPlanes:new Map,updateTrackedPlanes:e=>{const t=this[Fs].device[_s].sem;if(!t)return;Array.from(this[Fs].trackedPlanes.keys()).forEach(e=>{t.trackedPlanes.has(e)||this[Fs].trackedPlanes.delete(e)}),t.trackedPlanes.forEach(t=>{let n=this[Fs].trackedPlanes.get(t);if(n){$s.updateOffsetMatrix(n.planeSpace,t.transform.matrix);const i=Da(t,t.semanticLabel);i!==n[Ps].orientation&&(n[Ps].orientation=i,n[Ps].lastChangedTime=e.predictedDisplayTime)}else{const i=new Xs(this[Fs].device[_s].globalSpace,t.transform.matrix);n=new Na(t,i,t.polygon,t.semanticLabel),n[Ps].lastChangedTime=e.predictedDisplayTime,this[Fs].trackedPlanes.set(t,n)}n[Ps].frame=e,e[Ms].detectedPlanes.add(n)})},trackedMeshes:new Map,updateTrackedMeshes:e=>{const t=this[Fs].device[_s].sem;if(!t)return;Array.from(this[Fs].trackedMeshes.keys()).forEach(e=>{t.trackedMeshes.has(e)||this[Fs].trackedMeshes.delete(e)}),t.trackedMeshes.forEach(t=>{let n=this[Fs].trackedMeshes.get(t);if(n)$s.updateOffsetMatrix(n.meshSpace,t.transform.matrix);else{const i=new Xs(this[Fs].device[_s].globalSpace,t.transform.matrix);n=new Aa(t,i,t.vertices,t.indices,t.semanticLabel),n[Cs].lastChangedTime=e.predictedDisplayTime,this[Fs].trackedMeshes.set(t,n)}n[Cs].frame=e,e[Ms].detectedMeshes.add(n)})},depthSensingUsage:null!==(s=null===(r=null==i?void 0:i.usagePreference)||void 0===r?void 0:r[0])&&void 0!==s?s:"cpu-optimized",depthSensingDataFormat:"float32",depthTexture:null,depthTextureWidth:0,depthTextureHeight:0,depthFlipScratch:null,depthFlipScratchSize:0,activeFrame:null,computeDepthSensing:e=>{const t=this[Fs].device[_s].sem;if(!t)return;const{depthNear:n,depthFar:i}=this[Fs].renderState,r=this[Fs].renderState.baseLayer;if(!r)return;const s=r.context.canvas,a=Math.max(1,Math.floor(s.width/4)),o=Math.max(1,Math.floor(s.height/4)),l="inline"===this[Fs].mode?[Ja.None]:[Ja.Left,Ja.Right],c="gpu-optimized"===this[Fs].depthSensingUsage;for(const s of l){const l=this[Fs].getProjectionMatrix(s),u=this[Fs].device.viewSpaces[s],h=$s.calculateGlobalOffsetMatrix(u),d=Ur();Gr(d,h);const p=t.computeDepthBuffer(d,l,a,o,n,i);if(p)if(c){const t=r.context,{width:a,height:o}=p,l=2;this[Fs].depthTexture&&this[Fs].depthTextureWidth===a&&this[Fs].depthTextureHeight===o?t.bindTexture(t.TEXTURE_2D_ARRAY,this[Fs].depthTexture):(this[Fs].depthTexture&&t.deleteTexture(this[Fs].depthTexture),this[Fs].depthTexture=t.createTexture(),t.bindTexture(t.TEXTURE_2D_ARRAY,this[Fs].depthTexture),t.texStorage3D(t.TEXTURE_2D_ARRAY,1,t.R32F,a,o,l),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this[Fs].depthTextureWidth=a,this[Fs].depthTextureHeight=o);const c=new Float32Array(p.data),u=a*o;this[Fs].depthFlipScratch&&this[Fs].depthFlipScratchSize===u||(this[Fs].depthFlipScratch=new Float32Array(u),this[Fs].depthFlipScratchSize=u);const h=this[Fs].depthFlipScratch;for(let e=0;e<o;e++){const t=o-1-e;for(let i=0;i<a;i++){const r=c[t*a+i];h[e*a+i]=r>0?1-n/r:0}}const d=t.getParameter(t.UNPACK_FLIP_Y_WEBGL),f=t.getParameter(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL);t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);const m=s===Ja.Right?1:0;t.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,m,a,o,1,t.RED,t.FLOAT,h),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,d),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,f);const g=new Ua(this[Fs].depthTexture,a,o,new Wa,p.rawValueToMeters,n,i,"texture-array",m);e[Ms].gpuDepthDataMap.set(s,g)}else{const t=new ka(p.data,p.width,p.height,new Wa,p.rawValueToMeters,this[Fs].depthSensingDataFormat);e[Ms].depthDataMap.set(s,t)}}},hitTestSources:new Set,computeHitTestResults:e=>{const t=this[Fs].device[_s].sem;if(!t)return;const n=this[Fs].device[_s].globalSpace;this[Fs].hitTestSources.forEach(i=>{const r=i[Ws].space,s=$s.calculateGlobalOffsetMatrix(r),a=i[Ws].offsetRay.matrix,o=Ur();Hr(o,s,a);const l=[];t.computeHitTestResults(o).forEach(t=>{const i=new Xs(n,t),r=new $a(e,i);l.push(r)}),e[Ms].hitTestResultsMap.set(i,l)})},onend:null,oninputsourceschange:null,onselect:null,onselectstart:null,onselectend:null,onsqueeze:null,onsqueezestart:null,onsqueezeend:null,onvisibilitychange:null,onframeratechange:null},Ha.recoverPersistentAnchorsFromStorage(this),this[Fs].onDeviceFrame()}get visibilityState(){return this[Fs].device.visibilityState}get frameRate(){return this[Fs].nominalFrameRate}get supportedFrameRates(){return this[Fs].supportedFrameRates}get renderState(){return this[Fs].renderState}get inputSources(){return this[Fs].inputSourceArray.length=0,this[Fs].ended||"inline"===this[Fs].mode||this[Fs].inputSourceArray.push(...this[Fs].activeInputSources),this[Fs].inputSourceArray}get enabledFeatures(){return this[Fs].enabledFeatures}get isSystemKeyboardSupported(){return this[Fs].isSystemKeyboardSupported}get environmentBlendMode(){var e;return null!==(e=this[Fs].device[_s].environmentBlendModes[this[Fs].mode])&&void 0!==e?e:go.Opaque}get interactionMode(){return this[Fs].device[_s].interactionMode}get depthUsage(){return this[Fs].depthSensingUsage}get depthDataFormat(){return this[Fs].depthSensingDataFormat}updateRenderState(e={}){var t,n,i,r,s,a,o,l,c,u,h,d;if(this[Fs].ended)throw new DOMException("XRSession has already ended.","InvalidStateError");if(e.baseLayer&&e.baseLayer[Rs].session!==this)throw new DOMException("Base layer was created by a different XRSession","InvalidStateError");if(null!=e.inlineVerticalFieldOfView&&"inline"!==this[Fs].mode)throw new DOMException("InlineVerticalFieldOfView must not be set for an immersive session","InvalidStateError");const p={baseLayer:null!==(i=null!==(t=e.baseLayer)&&void 0!==t?t:null===(n=this[Fs].pendingRenderState)||void 0===n?void 0:n.baseLayer)&&void 0!==i?i:void 0,depthFar:null!==(a=null!==(r=e.depthFar)&&void 0!==r?r:null===(s=this[Fs].pendingRenderState)||void 0===s?void 0:s.depthFar)&&void 0!==a?a:void 0,depthNear:null!==(c=null!==(o=e.depthNear)&&void 0!==o?o:null===(l=this[Fs].pendingRenderState)||void 0===l?void 0:l.depthNear)&&void 0!==c?c:void 0,inlineVerticalFieldOfView:null!==(d=null!==(u=e.inlineVerticalFieldOfView)&&void 0!==u?u:null===(h=this[Fs].pendingRenderState)||void 0===h?void 0:h.inlineVerticalFieldOfView)&&void 0!==d?d:void 0};this[Fs].pendingRenderState=new eo(p,this[Fs].renderState)}async updateTargetFrameRate(e){return new Promise((t,n)=>{this[Fs].ended?n(new DOMException("XRSession has already ended.","InvalidStateError")):this[Fs].device.supportedFrameRates.includes(e)?(this[Fs].nominalFrameRate===e?console.log("Requested frame rate is the same as the current nominal frame rate, no update made"):(this[Fs].nominalFrameRate=e,this.dispatchEvent(new to("frameratechange",{session:this})),console.log(`Nominal frame rate updated to ${e}`)),t()):n(new DOMException("Requested frame rate not supported.","InvalidStateError"))})}async requestReferenceSpace(e){return new Promise((t,n)=>{if(this[Fs].ended||!this[Fs].referenceSpaceIsSupported(e))return void n(new DOMException("The requested reference space type is not supported.","NotSupportedError"));let i;switch(e){case Za.Viewer:i=this[Fs].device.viewerSpace;break;case Za.Local:i=new Qa(e,this[Fs].device[_s].globalSpace,this[Fs].device.viewerSpace[zs].offsetMatrix);break;case Za.LocalFloor:case Za.BoundedFloor:case Za.Unbounded:i=new Qa(e,this[Fs].device[_s].globalSpace)}this[Fs].referenceSpaces.push(i),t(i)})}requestAnimationFrame(e){if(this[Fs].ended)return 0;const t=++this[Fs].frameHandle;return this[Fs].frameCallbacks.push({handle:t,callback:e,cancelled:!1}),t}cancelAnimationFrame(e){let t=this[Fs].frameCallbacks,n=t.findIndex(t=>t&&t.handle===e);n>-1&&(t[n].cancelled=!0,t.splice(n,1)),t=this[Fs].currentFrameCallbacks,t&&(n=t.findIndex(t=>t&&t.handle===e),n>-1&&(t[n].cancelled=!0))}async end(){return new Promise((e,t)=>{var n;if(this[Fs].ended)t(new DOMException("XRSession has already ended.","InvalidStateError"));else{if(this[Fs].ended=!0,globalThis.cancelAnimationFrame(this[Fs].deviceFrameHandle),this[Fs].deviceFrameHandle=void 0,this[Fs].device[_s].onSessionEnd(),this[Fs].frameCallbacks.length=0,this[Fs].currentFrameCallbacks=null,this[Fs].referenceSpaces.length=0,this[Fs].hitTestSources.clear(),this[Fs].trackedPlanes.clear(),this[Fs].trackedMeshes.clear(),this[Fs].trackedAnchors.clear(),this[Fs].frameTrackedAnchors.clear(),this[Fs].newAnchors.forEach(({reject:e})=>{e(new DOMException("XRSession has ended before the anchor was resolved.","InvalidStateError"))}),this[Fs].newAnchors.clear(),this[Fs].depthTexture){const e=null===(n=this[Fs].renderState.baseLayer)||void 0===n?void 0:n.context;null==e||e.deleteTexture(this[Fs].depthTexture),this[Fs].depthTexture=null}this.dispatchEvent(new to("end",{session:this})),e()}})}get persistentAnchors(){return Array.from(this[Fs].persistentAnchors.keys())}restorePersistentAnchor(e){return new Promise((t,n)=>{if(this[Fs].persistentAnchors.has(e))if(this[Fs].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else{const i=this[Fs].persistentAnchors.get(e);this[Fs].newAnchors.has(i)?n(new DOMException(`Multiple concurrent attempts detected to restore the anchor with UUID: ${e}.`,"InvalidStateError")):(this[Fs].trackedAnchors.add(i),this[Fs].newAnchors.set(i,{resolve:t,reject:n}))}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}deletePersistentAnchor(e){return new Promise((t,n)=>{if(this[Fs].persistentAnchors.has(e)){const n=this[Fs].persistentAnchors.get(e);this[Fs].persistentAnchors.delete(e),n.delete(),t(void 0)}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}requestHitTestSource(e){return new Promise((t,n)=>{if(this[Fs].enabledFeatures.includes("hit-test"))if(this[Fs].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else if(this[Fs].device[_s].sem){const n=new qa(this,e);this[Fs].hitTestSources.add(n),t(n)}else n(new DOMException("Synthethic Environment Module required for emulating hit-test","OperationError"));else n(new DOMException('WebXR feature "hit-test" is not supported by current session',"NotSupportedError"))})}get onend(){return this[Fs].onend}set onend(e){this[Fs].onend&&this.removeEventListener("end",this[Fs].onend),this[Fs].onend=e,e&&this.addEventListener("end",e)}get oninputsourceschange(){return this[Fs].oninputsourceschange}set oninputsourceschange(e){this[Fs].oninputsourceschange&&this.removeEventListener("inputsourceschange",this[Fs].oninputsourceschange),this[Fs].oninputsourceschange=e,e&&this.addEventListener("inputsourceschange",e)}get onselect(){return this[Fs].onselect}set onselect(e){this[Fs].onselect&&this.removeEventListener("select",this[Fs].onselect),this[Fs].onselect=e,e&&this.addEventListener("select",e)}get onselectstart(){return this[Fs].onselectstart}set onselectstart(e){this[Fs].onselectstart&&this.removeEventListener("selectstart",this[Fs].onselectstart),this[Fs].onselectstart=e,e&&this.addEventListener("selectstart",e)}get onselectend(){return this[Fs].onselectend}set onselectend(e){this[Fs].onselectend&&this.removeEventListener("selectend",this[Fs].onselectend),this[Fs].onselectend=e,e&&this.addEventListener("selectend",e)}get onsqueeze(){return this[Fs].onsqueeze}set onsqueeze(e){this[Fs].onsqueeze&&this.removeEventListener("squeeze",this[Fs].onsqueeze),this[Fs].onsqueeze=e,e&&this.addEventListener("squeeze",e)}get onsqueezestart(){return this[Fs].onsqueezestart}set onsqueezestart(e){this[Fs].onsqueezestart&&this.removeEventListener("squeezestart",this[Fs].onsqueezestart),this[Fs].onsqueezestart=e,e&&this.addEventListener("squeezestart",e)}get onsqueezeend(){return this[Fs].onsqueezeend}set onsqueezeend(e){this[Fs].onsqueezeend&&this.removeEventListener("squeezeend",this[Fs].onsqueezeend),this[Fs].onsqueezeend=e,e&&this.addEventListener("squeezeend",e)}get onvisibilitychange(){return this[Fs].onvisibilitychange}set onvisibilitychange(e){this[Fs].onvisibilitychange&&this.removeEventListener("visibilitychange",this[Fs].onvisibilitychange),this[Fs].onvisibilitychange=e,e&&this.addEventListener("visibilitychange",e)}get onframeratechange(){return this[Fs].onframeratechange}set onframeratechange(e){this[Fs].onframeratechange&&this.removeEventListener("frameratechange",this[Fs].onframeratechange),this[Fs].onframeratechange=e,e&&this.addEventListener("frameratechange",e)}}!function(e){e.Wrist="wrist",e.ThumbMetacarpal="thumb-metacarpal",e.ThumbPhalanxProximal="thumb-phalanx-proximal",e.ThumbPhalanxDistal="thumb-phalanx-distal",e.ThumbTip="thumb-tip",e.IndexFingerMetacarpal="index-finger-metacarpal",e.IndexFingerPhalanxProximal="index-finger-phalanx-proximal",e.IndexFingerPhalanxIntermediate="index-finger-phalanx-intermediate",e.IndexFingerPhalanxDistal="index-finger-phalanx-distal",e.IndexFingerTip="index-finger-tip",e.MiddleFingerMetacarpal="middle-finger-metacarpal",e.MiddleFingerPhalanxProximal="middle-finger-phalanx-proximal",e.MiddleFingerPhalanxIntermediate="middle-finger-phalanx-intermediate",e.MiddleFingerPhalanxDistal="middle-finger-phalanx-distal",e.MiddleFingerTip="middle-finger-tip",e.RingFingerMetacarpal="ring-finger-metacarpal",e.RingFingerPhalanxProximal="ring-finger-phalanx-proximal",e.RingFingerPhalanxIntermediate="ring-finger-phalanx-intermediate",e.RingFingerPhalanxDistal="ring-finger-phalanx-distal",e.RingFingerTip="ring-finger-tip",e.PinkyFingerMetacarpal="pinky-finger-metacarpal",e.PinkyFingerPhalanxProximal="pinky-finger-phalanx-proximal",e.PinkyFingerPhalanxIntermediate="pinky-finger-phalanx-intermediate",e.PinkyFingerPhalanxDistal="pinky-finger-phalanx-distal",e.PinkyFingerTip="pinky-finger-tip"}(yo||(yo={}));class bo extends Map{}class _o extends Xs{constructor(e,t,n){super(t,n),this[ks]={jointName:e,radius:0}}get jointName(){return this[ks].jointName}}const wo={profileId:"oculus-hand",fallbackProfileIds:["generic-hand","generic-hand-select","generic-trigger"],poses:{default:{jointTransforms:{wrist:{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.04913589730858803,.0021463718730956316,.11701996624469757,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.07536252588033676,-.9959676265716553,-.04867160692811012,0,.5877083539962769,-.08379616588354111,.8047218918800354,0,-.8055551648139954,.032041035592556,.5916536450386047,0,-.010643752291798592,.0006936835707165301,.08736639469861984,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.1374533325433731,-.9904957413673401,.004982374142855406,0,.5534393787384033,.08097179979085922,.8289443850517273,0,-.8214688897132874,-.11118389666080475,.559309184551239,0,.015547193586826324,-.0003480653394944966,.0681300163269043,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.04330715537071228,.003409178927540779,.0492292083799839,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.062003348022699356,.004069602582603693,.03322213143110275,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.02009812369942665,.008770795539021492,.08660387247800827,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9001791477203369,-.2598813474178314,.3494834005832672,0,.06073702871799469,.8695210218429565,.490146666765213,0,-.4312632381916046,-.41999316215515137,.7985095381736755,0,-.00017739279428496957,.03890012577176094,.039073407649993896,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9082008600234985,-.20898112654685974,.36262574791908264,0,.11045389622449875,.9553793668746948,.27395179867744446,0,-.40369608998298645,-.20874978601932526,.8907597661018372,0,.01617925800383091,.05482936650514603,.008788082748651505,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.02599053829908371,.059902746230363846,-.012860597111284733,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.03362493962049484,.06421422213315964,-.033461250364780426,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.03627845644950867,.011579737067222595,.08550142496824265,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9876697659492493,-.06786545366048813,.1410750150680542,0,-.015095947310328484,.855663537979126,.5173118710517883,0,-.15582047402858734,-.5130629539489746,.8440889716148376,0,-.021259509027004242,.04587256908416748,.03659208118915558,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.988391637802124,-.04354291781783104,.14555205404758453,0,.008894841186702251,.9729899168014526,.23067504167556763,0,-.15166506171226501,-.22670257091522217,.9620829224586487,0,-.014570588245987892,.06789684295654297,.0003578895702958107,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.010392282158136368,.07414241135120392,-.026147106662392616,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.0069718430750072,.08024183660745621,-.05014154314994812,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.05402477830648422,.015797706320881844,.08152295649051666,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9940828680992126,.05735103040933609,.09224652498960495,0,-.10022822767496109,.8116500377655029,.5754809379577637,0,-.041867565363645554,-.5813214182853699,.8125960826873779,0,-.041623555123806,.04171867296099663,.03582974523305893,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9843675494194031,.12044742703437805,.12850022315979004,0,-.15629759430885315,.9337108135223389,.3221098482608795,0,-.08118485659360886,-.3371586799621582,.937940776348114,0,-.039990875869989395,.06438793987035751,.004141641780734062,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03783353418111801,.07334739714860916,-.020782606676220894,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03445569798350334,.0802423357963562,-.04392268508672714,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9181402921676636,.35625091195106506,.17350243031978607,0,-.39615097641944885,.8352503180503845,.38134080171585083,0,-.009065053425729275,-.41885748505592346,.9080066680908203,0,-.06191859766840935,.013620133511722088,.07850203663110733,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9714386463165283,.236698180437088,-.016745081171393394,0,-.18462024629116058,.7982627749443054,.5733163952827454,0,.14906984567642212,-.5538501739501953,.8191629648208618,0,-.061502378433942795,.032741155475378036,.03705105185508728,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9337416291236877,.35620439052581787,-.03527557849884033,0,-.33203884959220886,.8987522721290588,.28634607791900635,0,.13370157778263092,-.2556603252887726,.9574766755104065,0,-.06608185172080994,.049755651503801346,.011886020191013813,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.0687975287437439,.054948460310697556,-.007561664097011089,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.06947512179613113,.0613851435482502,-.028543535619974136,1],radius:.005425984505563974}},gripOffsetMatrix:[-.0005348679260350764,-.8648636937141418,-.5020061135292053,0,-.2741127908229828,-.48265108466148376,.8318111896514893,0,-.9616971015930176,.13805119693279266,-.2368120402097702,0,-.02878567762672901,.0017147823236882687,.04536811262369156,1]},pinch:{jointTransforms:{wrist:{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06867414712905884,-.009423808194696903,.10627774149179459,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.5012241005897522,-.8650535345077515,-.0213695727288723,0,.7415963411331177,-.4421543478965759,.5045139193534851,0,-.44587990641593933,.23702676594257355,.8631392121315002,0,-.032122574746608734,-.01196830440312624,.07194234430789948,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[-.3175753057003021,-.9460570216178894,-.06419729441404343,0,.8958902955055237,-.32153913378715515,.30658137798309326,0,-.3106854259967804,.03984907269477844,.9496771097183228,0,-.017625702545046806,-.01967475935816765,.04387917369604111,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,-.007126678712666035,-.021021386608481407,.011786630377173424,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,.0003423091256991029,-.024528030306100845,-.011410919018089771,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.038037415593862534,-.0020236473064869642,.07626739144325256,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.7986818552017212,-.35985732078552246,.48229536414146423,0,.538311243057251,.7854709625244141,-.30537736415863037,0,-.2689369022846222,.5035246014595032,.8210577368736267,0,-.006869405973702669,.033938243985176086,.04206443578004837,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.8285930156707764,-.32672837376594543,.4546217918395996,0,.5577570199966431,.4116027057170868,-.7207564115524292,0,.04836784675717354,.8507823944091797,.5232869386672974,0,.0033306588884443045,.014840902760624886,.010923954658210278,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,.0021551470272243023,-.0058362227864563465,-.0017938464879989624,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,-.00131594471167773,-.025222131982445717,-.012442642822861671,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.05395089089870453,.003063359996303916,.07402937114238739,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9187911748886108,-.1530158370733261,.36387869715690613,0,.038666240870952606,.9522662162780762,.302808940410614,0,-.3928440511226654,-.26414817571640015,.8808513283729553,0,-.02717282809317112,.04162866622209549,.03678669035434723,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9228746294975281,-.12856416404247284,.36300456523895264,0,.14524033665657043,.9892153143882751,-.01890045404434204,0,-.3566599190235138,.07016586512327194,.9315956234931946,0,-.01030921470373869,.05296773463487625,-.0010256498353555799,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,-.0004833847051486373,.05103470757603645,-.026690717786550522,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,.008158999495208263,.05004044249653816,-.050120558589696884,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06732909381389618,.007902119308710098,.07209732383489609,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9391821026802063,-.027994679287075996,.34227466583251953,0,-.18282271921634674,.8029410243034363,.5673282742500305,0,-.2907087206840515,-.5954000353813171,.7489906549453735,0,-.047129884362220764,.03806127607822418,.032147664576768875,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9249380826950073,.03699534013867378,.3783116042613983,0,-.12898847460746765,.9667453765869141,.2208271026611328,0,-.3575615882873535,-.25304901599884033,.8989526629447937,0,-.03579339757561684,.06127955764532089,.002939916681498289,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.026291755959391594,.06800390034914017,-.02094830758869648,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.016345610842108727,.07300511747598648,-.04263874143362045,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.8769711852073669,.31462907791137695,.36322021484375,0,-.4506046175956726,.801031768321991,.39408499002456665,0,-.16696058213710785,-.5092697143554688,.8442559838294983,0,-.07460174709558487,.0062340241856873035,.06756893545389175,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9498357176780701,.1553308218717575,.2714462876319885,0,-.3019258379936218,.6817675232887268,.6663586497306824,0,-.08155745267868042,-.7148879170417786,.694466233253479,0,-.06697750836610794,.029482364654541016,.02902858518064022,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9214097261428833,.27928245067596436,.2701927423477173,0,-.3670244514942169,.8538867831230164,.36901235580444336,0,-.12765564024448395,-.43917882442474365,.8892839550971985,0,-.06447203457355499,.05144399777054787,.0076942890882492065,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.06187915802001953,.060364335775375366,-.010368337854743004,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.056796226650476456,.07042007893323898,-.02921444922685623,1],radius:.005425984505563974}},gripOffsetMatrix:[.08027800917625427,-.8086723685264587,-.5827556252479553,0,-.4154181480407715,-.5585916638374329,.7179154753684998,0,-.9060805439949036,.1844543218612671,-.3807799518108368,0,-.038054611533880234,-.002910431008785963,.03720742464065552,1]},point:{jointTransforms:{wrist:{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05789132043719292,.01670890860259533,.11183350533246994,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[.02145560085773468,-.9978390336036682,.0621047280728817,0,.41311800479888916,.06541631370782852,.9083252549171448,0,-.9104245901107788,.006167683284729719,.4136286973953247,0,-.016488194465637207,.012708572670817375,.08862338215112686,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.21270370483398438,-.966137707233429,.14606566727161407,0,.49890995025634766,.2359165996313095,.8339261412620544,0,-.8401462435722351,-.10450579971075058,.5321959853172302,0,.013112368993461132,.012508046813309193,.07517509907484055,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.04150351136922836,.016039609909057617,.05719054117798805,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.06548332422971725,.01683700829744339,.0516640841960907,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.02592567168176174,.019982583820819855,.08479326963424683,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9063700437545776,-.21756279468536377,.3621589243412018,0,.0970839336514473,.9415287375450134,.3226419687271118,0,-.41117796301841736,-.2572731077671051,.8744958639144897,0,-.0015709538711234927,.043078210204839706,.034657616168260574,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9159826040267944,-.1651475727558136,.36565208435058594,0,.09755707532167435,.9756820797920227,.1962820291519165,0,-.3891757130622864,-.14411886036396027,.9098196625709534,0,.014023927971720695,.052835866808891296,.0014903299743309617,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.023482320830225945,.05633850023150444,-.020621655508875847,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.03096788562834263,.06281610578298569,-.040703095495700836,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.04184452444314957,.022474845871329308,.08177298307418823,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9720265865325928,-.08313076198101044,.21966552734375,0,.20477405190467834,.7580050826072693,-.6192700862884521,0,-.11502730846405029,.6469289064407349,.7538246512413025,0,-.022107340395450592,.05035499855875969,.02970452979207039,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9779140949249268,-.07129573822021484,.19646917283535004,0,.1287083923816681,-.5352076292037964,-.8348574042320251,0,.1646735966205597,.8417060971260071,-.5142109394073486,0,-.017169542610645294,.022584279999136925,-.00265491777099669,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02170622907578945,-.0006043742760084569,.011511396616697311,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02438267692923546,-.0026927536819130182,.03627248480916023,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05944233387708664,.0264605600386858,.07478221505880356,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9842101335525513,.024470895528793335,.1753024309873581,0,.12200043350458145,.6237703561782837,-.7720272541046143,0,-.12824076414108276,.7812241315841675,.610936164855957,0,-.04249368980526924,.0467497780919075,.027722163125872612,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9941774606704712,.05949164181947708,.08983955532312393,0,.10504482686519623,-.7208291888237,-.6851072907447815,0,.024001073092222214,.6905553936958313,-.7228817939758301,0,-.0374927744269371,.016285063698887825,.0038980208337306976,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.038130562752485275,-.0020653479732573032,.02310742810368538,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.0390593595802784,.004176302347332239,.0466572530567646,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9147363901138306,.3458845317363739,.20885537564754486,0,-.3923271894454956,.8839452862739563,.2544005811214447,0,-.09662359952926636,-.3146490156650543,.9442773461341858,0,-.06715242564678192,.024195827543735504,.07137546688318253,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9613109827041626,.22439135611057281,.15977802872657776,0,.01002211682498455,.5511574745178223,-.8343409299850464,0,-.27528178691864014,.8036624789237976,.5275853276252747,0,-.06273911893367767,.038559623062610626,.028268879279494286,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9820972084999084,.18811029195785522,-.00995189044624567,0,.14063723385334015,-.7673450708389282,-.6256227493286133,0,-.12532226741313934,.6130226850509644,-.7800630927085876,0,-.05428232625126839,.013870777562260628,.012061242014169693,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05173685774207115,.0014194445684552193,.02790539152920246,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05098633095622063,.008463085629045963,.048688892275094986,1],radius:.005425984505563974}},gripOffsetMatrix:[.005510995630174875,-.9149997234344482,-.40341615676879883,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.9340395331382751,.13936474919319153,-.32885703444480896,0,-.031803809106349945,.007837686687707901,.04313928261399269,1]}}},So={mapping:fa.None,buttons:[{id:"pinch",type:"analog",eventTrigger:"select"}],axes:[]},Mo=Zr(),To=ls(),Eo=Zr(),Ao=Zr(),Ro=ls(),Co=Zr(),Po=Zr(),Io=ls(),Lo=Zr(),Do=(e,t,n,i)=>(qr(Mo,t),Yr(To,t),$r(Eo,t),qr(Ao,n),Yr(Ro,n),$r(Co,n),rs(Po,Mo,Ao,i),hs(Io,To,Ro,i),rs(Lo,Eo,Co,i),function(e,t,n,i){var r=t[0],s=t[1],a=t[2],o=t[3],l=r+r,c=s+s,u=a+a,h=r*l,d=r*c,p=r*u,f=s*c,m=s*u,g=a*u,v=o*l,y=o*c,x=o*u,b=i[0],_=i[1],w=i[2];e[0]=(1-(f+g))*b,e[1]=(d+x)*b,e[2]=(p-y)*b,e[3]=0,e[4]=(d-x)*_,e[5]=(1-(h+g))*_,e[6]=(m+v)*_,e[7]=0,e[8]=(p+y)*w,e[9]=(m-v)*w,e[10]=(1-(h+f))*w,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1}(e,Io,Po,Lo),e),No=[1,-1,-1,0,-1,1,1,0,-1,1,1,0,-1,1,1,1];class Oo extends Ta{constructor(e,t,n){if(t!==ma.Left&&t!==ma.Right)throw new DOMException('handedness for XRHandInput must be either "left" or "right"',"InvalidStateError");if(!e.poses.default||!e.poses.pinch)throw new DOMException('"default" and "pinch" hand pose configs are required',"InvalidStateError");const i=new Xs(n),r=new Xs(i),s=[e.profileId,...e.fallbackProfileIds],a=new bo;Object.values(yo).forEach(e=>{a.set(e,new _o(e,i))});super(new wa(t,ga.TrackedPointer,s,i,new ba(So),r,a)),this[ws]={poseId:"default",poses:e.poses},this.updateHandPose()}get poseId(){return this[ws].poseId}set poseId(e){this[ws].poses[e]?this[ws].poseId=e:console.warn(`Pose config ${e} not found`)}updateHandPose(){const e=this[ws].poses[this[ws].poseId],t=this[ws].poses.pinch;Object.values(yo).forEach(n=>{const i=e.jointTransforms[n].offsetMatrix,r=t.jointTransforms[n].offsetMatrix,s=this.inputSource.hand.get(n);Do(s[zs].offsetMatrix,i,r,this.pinchValue),this.inputSource.handedness===ma.Right&&(e=>{for(let t=0;t<16;t++)e[t]*=No[t]})(s[zs].offsetMatrix),s[ks].radius=(1-this.pinchValue)*e.jointTransforms[n].radius+this.pinchValue*t.jointTransforms[n].radius}),e.gripOffsetMatrix&&t.gripOffsetMatrix&&Do(this.inputSource.gripSpace[zs].offsetMatrix,e.gripOffsetMatrix,t.gripOffsetMatrix,this.pinchValue)}get pinchValue(){return this[Ss].inputSource.gamepad[Ts].buttonsMap.pinch.value}updatePinchValue(e){if(e>1||e<0)return void console.warn(`Out-of-range value ${e} provided for pinch`);this[Ss].inputSource.gamepad[Ts].buttonsMap.pinch[Ts].pendingValue=e}setPinchValueImmediate(e){if(e>1||e<0)return void console.warn(`Out-of-range value ${e} provided for pinch`);const t=this[Ss].inputSource.gamepad[Ts].buttonsMap.pinch;null===t[Ts].immediateTransitionFrom&&(t[Ts].immediateTransitionFrom=t[Ts].value),t[Ts].value=e,t[Ts].pendingValue=e}onFrameStart(e){super.onFrameStart(e),this.updateHandPose()}}class Fo extends EventTarget{}const ko={antialias:!0,depth:!0,stencil:!1,alpha:!0,ignoreDepthValues:!1,framebufferScaleFactor:1};let Uo=class extends Fo{constructor(e,t,n={}){if(super(),e[Fs].ended)throw new DOMException("Session has ended","InvalidStateError");const i={...ko,...n};this[Rs]={session:e,context:t,antialias:i.antialias}}get context(){return this[Rs].context}get antialias(){return this[Rs].antialias}get ignoreDepthValues(){return!0}get framebuffer(){return null}get framebufferWidth(){return this[Rs].context.drawingBufferWidth}get framebufferHeight(){return this[Rs].context.drawingBufferHeight}getViewport(e){if(e[Bs].session!==this[Rs].session)throw new DOMException("View's session differs from Layer's session","InvalidStateError");return this[Rs].session[Fs].device[_s].getViewport(this,e)}static getNativeFramebufferScaleFactor(e){if(!(e instanceof xo))throw new TypeError("getNativeFramebufferScaleFactor must be passed a session.");return e[Fs].ended?0:1}};class zo{constructor(e,t,n,i={}){var r;const{schema:s,frames:a}=t;if(!a||!s||0===a.length)throw new DOMException("wrong recording format","NotSupportedError");const o=new Qa(Za.Viewer,e),l={[Ja.Left]:new Xs(o),[Ja.Right]:new Xs(o),[Ja.None]:new Xs(o)};this[ys]={refSpace:e,inputSources:new Map,inputSchemas:new Map,frames:a,recordedFramePointer:0,startingTimeStamp:a[0][0],endingTimeStamp:a[a.length-1][0],playbackTime:a[0][0],playing:!1,autoAdvance:!0,manualFrameActive:!1,viewerSpace:o,viewSpaces:l,vec3:Zr(),quat:ls(),f1p:Zr(),f1q:ls(),f2p:Zr(),f2q:ls(),lastFrameInputs:new Map,nextFrameInputs:new Map,loop:null!==(r=i.loop)&&void 0!==r&&r,playbackRate:null!=i.playbackRate&&i.playbackRate>0?i.playbackRate:1,eventContext:i.eventContext,lastEventFramePointer:-1},Wr(this[ys].viewSpaces[Ja.Left][zs].offsetMatrix,Jr(-n/2,0,0)),Wr(this[ys].viewSpaces[Ja.Right][zs].offsetMatrix,Jr(n/2,0,0)),s.forEach(t=>{const n=t[0],i=t[1];let r;if(i.hasGamepad){const e=[];for(let t=0;t<i.numButtons;t++)e.push({id:t.toString(),type:"manual"});const t=[];for(let e=0;e<i.numAxes;e++)t.push({id:e.toString(),type:"manual"});r=new ba({mapping:i.mapping,buttons:e,axes:t})}const s=new Xs(e);let a;i.hasHand&&(a=new bo,Object.values(yo).forEach(e=>{a.set(e,new _o(e,s))}));const o=new wa(i.handedness,i.targetRayMode,i.profiles,s,r,i.hasGrip?new Xs(e):void 0,i.hasHand?a:void 0);this[ys].inputSources.set(n,{active:!1,source:o}),this[ys].inputSchemas.set(n,i)}),a.forEach((e,t)=>{for(let n=8;n<e.length;n++){const i=e[n],r=i[0],s=this[ys].inputSchemas.get(r);if(!s)throw new DOMException(`recording frame ${t} references unknown input source ${r}`,"NotSupportedError");if(s.hasGamepad){let e=8;s.hasGrip&&e++,s.hasHand&&e++;const n=i[e],a=s.numButtons+s.numAxes;if(!Array.isArray(n)||n.length!==a){const e=Array.isArray(n)?n.length:"no";throw new DOMException(`recording frame ${t} input source ${r} has ${e} gamepad entries, expected ${a} (${s.numButtons} buttons + ${s.numAxes} axes)`,"NotSupportedError")}}}})}play(){var e,t;null===(t=null===(e=this[ys].eventContext)||void 0===e?void 0:e.onDiscontinuity)||void 0===t||t.call(e),this[ys].recordedFramePointer=0,this[ys].playbackTime=this[ys].startingTimeStamp,this[ys].playing=!0,this[ys].autoAdvance=!0,this[ys].manualFrameActive=!1,this[ys].actualTimeStamp=performance.now(),this[ys].lastEventFramePointer=-1}stop(){this[ys].playing=!1,this[ys].autoAdvance=!0,this[ys].manualFrameActive=!1}get playing(){return this[ys].playing}get viewerSpace(){return this[ys].viewerSpace}get viewSpaces(){return this[ys].viewSpaces}get inputSources(){return Array.from(this[ys].inputSources.values()).filter(e=>e.active).map(e=>e.source)}get loop(){return this[ys].loop}set loop(e){this[ys].loop=e}get playbackRate(){return this[ys].playbackRate}set playbackRate(e){e>0&&(this[ys].playbackRate=e)}setEventContext(e){this[ys].eventContext=e}get duration(){return this[ys].endingTimeStamp-this[ys].startingTimeStamp}get currentTime(){return this[ys].playbackTime-this[ys].startingTimeStamp}seek(e){var t,n;const i=this[ys],r=Math.max(0,Math.min(e,this.duration)),s=i.startingTimeStamp+r,a=this.findFramePointer(s);a!==i.recordedFramePointer&&(null===(n=null===(t=i.eventContext)||void 0===t?void 0:t.onDiscontinuity)||void 0===n||n.call(t),i.lastEventFramePointer=-1),i.playbackTime=s,i.recordedFramePointer=a,i.actualTimeStamp=performance.now()}findFramePointer(e){const t=this[ys].frames;let n=0,i=t.length-1,r=0;for(;n<=i;){const s=n+i>>1;t[s][0]<=e?(r=s,n=s+1):i=s-1}return r}stepFrames(e=1){var t,n;const i=this[ys],r=i.frames;i.playing=!0,i.autoAdvance=!1,i.manualFrameActive=!0;for(let s=0;s<e;s++){if(i.recordedFramePointer+1>=r.length){if(!i.loop)return i.playbackTime=i.endingTimeStamp,this.applyFrameAtPointer(0),void(i.playing=!1);null===(n=null===(t=i.eventContext)||void 0===t?void 0:t.onDiscontinuity)||void 0===n||n.call(t),i.recordedFramePointer=0,i.playbackTime=i.startingTimeStamp,i.lastEventFramePointer=-1}else i.recordedFramePointer++,i.playbackTime=r[i.recordedFramePointer][0];this.applyFrameAtPointer(0)}i.actualTimeStamp=performance.now()}playFrame(){var e,t;const n=performance.now(),i=(n-this[ys].actualTimeStamp)*this[ys].playbackRate;this[ys].actualTimeStamp=n,this[ys].playbackTime+=i;const r=this[ys].frames;if(this[ys].playbackTime>this[ys].endingTimeStamp)if(this[ys].loop){null===(t=null===(e=this[ys].eventContext)||void 0===e?void 0:e.onDiscontinuity)||void 0===t||t.call(e);const n=this[ys].playbackTime-this[ys].endingTimeStamp,i=this.duration>0?this[ys].startingTimeStamp+n%this.duration:this[ys].startingTimeStamp;this[ys].playbackTime=i,this[ys].recordedFramePointer=this.findFramePointer(i),this[ys].lastEventFramePointer=-1}else this[ys].playbackTime=this[ys].endingTimeStamp,this.stop();for(;this[ys].recordedFramePointer+1<r.length&&r[this[ys].recordedFramePointer+1][0]<this[ys].playbackTime;)this[ys].recordedFramePointer++;const s=this[ys].recordedFramePointer+1<r.length,a=r[this[ys].recordedFramePointer],o=s?r[this[ys].recordedFramePointer+1]:a,l=s?(this[ys].playbackTime-a[0])/(o[0]-a[0]):0;this.applyFrameAtPointer(l)}applyFrameAtPointer(e){const t=this[ys].frames,n=this[ys].recordedFramePointer+1<t.length,i=t[this[ys].recordedFramePointer],r=n?t[this[ys].recordedFramePointer+1]:i;this.updateXRSpaceFromMergedFrames(this[ys].viewerSpace,i.slice(1,8),r.slice(1,8),e);const s=this[ys].lastFrameInputs;s.clear();for(let e=8;e<i.length;e++){const{index:t,inputData:n}=this.processRawInputData(i[e]);s.set(t,n)}const a=this[ys].nextFrameInputs;a.clear();for(let e=8;e<r.length;e++){const{index:t,inputData:n}=this.processRawInputData(r[e]);a.set(t,n)}this[ys].inputSources.forEach(e=>{e.active=!1}),a.forEach((t,n)=>{this[ys].inputSources.get(n).active=!0;const i=this[ys].inputSources.get(n).source,r=this[ys].inputSchemas.get(n);this.updateInputSource(i,r,s.has(n)?s.get(n):t,t,e)}),this.dispatchSelectSqueezeEdges()}dispatchSelectSqueezeEdges(){const e=this[ys],t=e.eventContext,n=e.recordedFramePointer;if(!t)return void(e.lastEventFramePointer=n);const i=e.lastEventFramePointer;if(i<0||i===n)return void(e.lastEventFramePointer=n);const r=t.getFrame();if(!r)return void(e.lastEventFramePointer=n);const s=e.frames,a=n>i?1:-1;for(let e=i;e!==n;e+=a){const n=a>0?e:e-1,i=n+1;this.dispatchEdgesBetweenFrames(s[n],s[i],t,r)}e.lastEventFramePointer=n}dispatchEdgesBetweenFrames(e,t,n,i){var r;const s=new Map;for(let t=8;t<e.length;t++){const{index:n,inputData:i}=this.processRawInputData(e[t]);s.set(n,i)}for(let e=8;e<t.length;e++){const{index:a,inputData:o}=this.processRawInputData(t[e]),l=this[ys].inputSchemas.get(a);if(!l||!l.hasGamepad||!o.buttons)continue;const c=s.get(a);if(!c||!c.buttons)continue;const u=null===(r=this[ys].inputSources.get(a))||void 0===r?void 0:r.source;u&&o.buttons.forEach((e,t)=>{var r,s;const a=this.eventTriggerForButton(l,t);if(null==a)return;const o=null!==(s=null===(r=c.buttons[t])||void 0===r?void 0:r[2])&&void 0!==s?s:0,h=e[2];0===o&&h>0?(n.session.dispatchEvent(new Sa(a,{frame:i,inputSource:u})),n.session.dispatchEvent(new Sa(a+"start",{frame:i,inputSource:u}))):o>0&&0===h&&n.session.dispatchEvent(new Sa(a+"end",{frame:i,inputSource:u}))})}}eventTriggerForButton(e,t){return e.mapping!==fa.XRStandard?null:0===t?"select":1===t?"squeeze":null}updateInputSource(e,t,n,i,r){if(this.updateXRSpaceFromMergedFrames(e.targetRaySpace,n.targetRayTransform,i.targetRayTransform,r),t.hasGrip&&this.updateXRSpaceFromMergedFrames(e.gripSpace,n.gripTransform,i.gripTransform,r),t.hasHand)for(let s=0;s<25;s++){const a=n.handTransforms.slice(8*s,8*s+7),o=i.handTransforms.slice(8*s,8*s+7),l=n.handTransforms[8*s+7],c=i.handTransforms[8*s+7],u=e.hand.get(t.jointSequence[s]);this.updateXRSpaceFromMergedFrames(u,a,o,r),u[ks].radius=(c-l)*r+l}if(t.hasGamepad){const t=e.gamepad;i.buttons.forEach((e,i)=>{const s=t.buttons[i];s[Ts].pressed=1===e[0],s[Ts].touched=1===e[1];const a=n.buttons[i][2],o=e[2];s[Ts].value=(o-a)*r+a}),i.axes.forEach((e,i)=>{const s=n.axes[i];t[Ts].axesMap[i.toString()].x=(e-s)*r+s})}}updateXRSpaceFromMergedFrames(e,t,n,i){const r=es(this[ys].f1p,t[0],t[1],t[2]),s=ms(this[ys].f1q,t[3],t[4],t[5],t[6]),a=es(this[ys].f2p,n[0],n[1],n[2]),o=ms(this[ys].f2q,n[3],n[4],n[5],n[6]);rs(this[ys].vec3,r,a,i),hs(this[ys].quat,s,o,i),Xr(e[zs].offsetMatrix,this[ys].quat,this[ys].vec3)}processRawInputData(e){const t=e[0],n=this[ys].inputSchemas.get(t),i={targetRayTransform:e.slice(1,8)};let r=8;if(n.hasGrip&&(i.gripTransform=e[r++]),n.hasHand&&(i.handTransforms=e[r++]),n.hasGamepad){const t=e[r];i.buttons=t.slice(0,n.numButtons),i.axes=t.slice(n.numButtons)}return{index:t,inputData:i}}}const Bo="2.6.0";class Vo extends Event{constructor(e,t){if(super(e,t),!t.referenceSpace)throw new Error("XRReferenceSpaceEventInit.referenceSpace is required");this.referenceSpace=t.referenceSpace,this.transform=t.transform}}const Go=["gaze-tracking","eye-tracking"],Ho=e=>Go.includes(e),Wo=e=>e.some(Ho);class jo extends Ta{constructor(e){super(new wa(ma.None,ga.Gaze,["eye-gaze"],new Xs(e))),this.position.set(0,0,0)}updateTargetRaySpace(){this.position.set(0,0,0),super.updateTargetRaySpace()}}class Xo extends EventTarget{constructor(e){super(),this[Es]={device:e,grantSession:({resolve:e,reject:t,mode:n,options:i})=>{if(this[Es].activeSession)return void t(new DOMException("An active XRSession already exists.","InvalidStateError"));const{requiredFeatures:r=[],optionalFeatures:s=[]}=i,{supportedFeatures:a}=this[Es].device,o=e=>Ho(e)?Wo(a):a.includes(e);if(!r.every(o))return void t(new Error("One or more required features are not supported by the device."));const l=s.filter(o),c=Array.from(new Set([...r,...l,"viewer","local"])),u=new xo(this[Es].device,n,c,i.depthSensing);this[Es].activeSession=u,u.addEventListener("end",()=>{this[Es].activeSession=void 0},{once:!0}),e(u)}}}isSessionSupported(e){return new Promise((t,n)=>{t("inline"===e||this[Es].device.supportedSessionModes.includes(e))})}requestSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{if(!r)return void i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"));const s={resolve:n,reject:i,mode:e,options:t};this[Es].grantSession(s)}).catch(i)})}offerSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{var s;r?(null===(s=this[Es].offeredSessionConfig)||void 0===s||s.reject(new Error("Offer superseded by a new offerSession call.")),this[Es].offeredSessionConfig={resolve:n,reject:i,mode:e,options:t}):i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"))}).catch(i)})}}class qo{constructor(e,t,n,i){this[Vs]={x:e,y:t,width:n,height:i}}get x(){return this[Vs].x}get y(){return this[Vs].y}get width(){return this[Vs].width}get height(){return this[Vs].height}}const $o=(e,t,n)=>Math.min(n,Math.max(t,e));var Yo,Ko;!function(e){e.texture="texture",e["texture-array"]="texture-array"}(Yo||(Yo={})),function(e){e.default="default",e.mono="mono",e.stereo="stereo",e["stereo-left-right"]="stereo-left-right",e["stereo-top-bottom"]="stereo-top-bottom"}(Ko||(Ko={}));const Zo=e=>e&&"function"==typeof e.getOffsetReferenceSpace,Jo=()=>"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Qo=(e,t)=>{switch(t){case e.RGBA8:case e.RGB5_A1:case e.RGBA4:case e.SRGB8_ALPHA8:return{internalFormat:t,textureFormat:e.RGBA,type:e.UNSIGNED_BYTE};case e.RGBA8_SNORM:return{internalFormat:t,textureFormat:e.RGBA,type:e.BYTE};case e.RGB10_A2:return{internalFormat:t,textureFormat:e.RGBA,type:e.UNSIGNED_INT_2_10_10_10_REV};case e.RGBA16F:return{internalFormat:t,textureFormat:e.RGBA,type:e.HALF_FLOAT};case e.RGBA32F:return{internalFormat:t,textureFormat:e.RGBA,type:e.FLOAT};case e.RGBA8UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_BYTE};case e.RGBA8I:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.BYTE};case e.RGBA16UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_SHORT};case e.RGBA16I:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.SHORT};case e.RGBA32UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_INT};case e.RGBA32I:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.INT};case e.RGB10_A2UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_INT_2_10_10_10_REV};case e.RGB8:case e.RGB565:case e.SRGB8:return{internalFormat:t,textureFormat:e.RGB,type:e.UNSIGNED_BYTE};case e.RGB8_SNORM:return{internalFormat:t,textureFormat:e.RGB,type:e.BYTE};case e.RGB16F:case e.R11F_G11F_B10F:case e.RGB9_E5:return{internalFormat:t,textureFormat:e.RGB,type:e.HALF_FLOAT};case e.RGB32F:return{internalFormat:t,textureFormat:e.RGB,type:e.FLOAT};case e.RGB8UI:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.UNSIGNED_BYTE};case e.RGB8I:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.BYTE};case e.RGB16UI:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.UNSIGNED_SHORT};case e.RGB16I:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.SHORT};case e.RGB32UI:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.UNSIGNED_INT};case e.RGB32I:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.INT};case e.DEPTH_COMPONENT16:return{internalFormat:t,textureFormat:e.DEPTH_COMPONENT,type:e.UNSIGNED_SHORT};case e.DEPTH_COMPONENT24:return{internalFormat:t,textureFormat:e.DEPTH_COMPONENT,type:e.UNSIGNED_INT};case e.DEPTH_COMPONENT32F:return{internalFormat:t,textureFormat:e.DEPTH_COMPONENT,type:e.FLOAT};case e.DEPTH24_STENCIL8:return{internalFormat:t,textureFormat:e.DEPTH_STENCIL,type:e.UNSIGNED_INT_24_8};case e.DEPTH32F_STENCIL8:return{internalFormat:t,textureFormat:e.DEPTH_STENCIL,type:e.FLOAT_32_UNSIGNED_INT_24_8_REV};case e.DEPTH_COMPONENT:return Qo(e,e.DEPTH_COMPONENT24);case e.DEPTH_STENCIL:return Qo(e,e.DEPTH24_STENCIL8);case e.RGBA:case e.RGB:case e.LUMINANCE_ALPHA:case e.LUMINANCE:case e.ALPHA:return{internalFormat:t,textureFormat:t,type:e.UNSIGNED_BYTE};default:throw new Error("Attempted to create polyfill with unsupported format.")}};class el{constructor(){this._hasRunDeferredInitialize=!1,this._media=null}initialize(e,t){this.session=e,t&&(this.context=t),this.blendTextureSourceAlpha=!0}destroy(){this._colorTextures=[],this._depthStencilTextures=[]}addEventListener(e,t,n){}dispatchEvent(e){return!1}removeEventListener(e,t,n){}getContext(){return this.context}getTextureType(){throw new Error("Unimplemented")}get colorTextures(){return this._colorTextures}get depthStencilTextures(){return this._depthStencilTextures}get colorTexturesMeta(){return this._texturesMeta}get media(){return this.isMediaLayer()||console.warn("Attempted to retrieve media from a non-media layer"),this._media}determineLayoutAttribute(e,t,n){if(!(t instanceof WebGL2RenderingContext)&&e===Yo["texture-array"])throw new TypeError;if(n===Ko.mono)return n;if(n===Ko.default){if(this.session.internalViews&&1===this.session.internalViews.length)return Ko.mono;if(e===Yo["texture-array"])return n}return n===Ko.default||n===Ko.stereo?Ko["stereo-left-right"]:n}isMediaLayer(){return null!==this._media}_deferredInitialize(){}initializeIfNeeded(){this._hasRunDeferredInitialize||(this._hasRunDeferredInitialize=!0,this._deferredInitialize())}_allocateColorTexturesInternal(e,t){let n=this.session.internalViews;if(n&&0!==n.length){if(this.initializeIfNeeded(),this.layout===Ko.mono){if(e===Yo["texture-array"]){const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}{const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}}if(this.layout===Ko.stereo){if(e===Yo["texture-array"]){const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat,2);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}{const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat),i=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n,i],void(this._colorTextures=[n.texture,i.texture])}}if(this.layout===Ko["stereo-left-right"]){const n=this._createNewColorTexture(2*t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}if(this.layout===Ko["stereo-top-bottom"]){const n=this._createNewColorTexture(t.viewPixelWidth,2*t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}}else console.warn("We can't allocate color textures without views")}_allocateDepthStencilTexturesInternal(e,t){if(t.depthFormat){if(this._getSupportedDepthFormats().indexOf(t.depthFormat)<0)throw new Error("Depth format provided is not supported in non-projection layers.");if(t.mipLevels<1)throw new Error("Invalid miplevel. Miplevel needs to be >= 1");if(this.layout===Ko.mono){if(e===Yo["texture-array"]){const n=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}{const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}}if(this.layout===Ko.stereo){if(e===Yo["texture-array"]){const n=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat,2);return void(this._depthStencilTextures=[n.texture])}{const n=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat),i=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture,i.texture])}}if(this.layout===Ko["stereo-left-right"]){const n=this._createNewDepthStencilTexture(2*t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}if(this.layout===Ko["stereo-top-bottom"]){const n=this._createNewDepthStencilTexture(t.viewPixelWidth,2*t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}}else this._depthStencilTextures=[]}_createNewColorTexture(e,t,n,i,r=1){return this._createGenericPolyfillTexture(n,e,t,i,0,r)}_createNewDepthStencilTexture(e,t,n,i,r=1){return this._createGenericPolyfillTexture(n,e,t,i,0,r)}_createGenericPolyfillTexture(e,t,n,i,r=0,s=1){if(e===Yo["texture-array"]&&s<=1&&console.warn("creating a texture array with a single layer..."),e===Yo["texture-array"]&&this.context instanceof WebGLRenderingContext)throw new Error("WebGL 1 does not support texture array");let a=this.context.createTexture(),o={width:t,height:n,layers:s,type:e,textureFormat:i,texture:a},l=i,c=this.context.UNSIGNED_BYTE;if(this.context instanceof WebGL2RenderingContext){const e=Qo(this.context,i);l=e.internalFormat,i=e.textureFormat,c=e.type}else i===this.context.DEPTH_COMPONENT&&(c=this.context.UNSIGNED_INT),i===this.context.DEPTH_STENCIL&&(c=this.context.UNSIGNED_INT_24_8_WEBGL);if(e===Yo["texture-array"]&&this.context instanceof WebGL2RenderingContext){console.warn("texture-array layers are supported...questionably in the polyfill at the moment. Use at your own risk.");const e=this.context.getParameter(this.context.TEXTURE_BINDING_2D_ARRAY);this.context.bindTexture(this.context.TEXTURE_2D_ARRAY,a),this._getSupportedDepthFormats().indexOf(i)>=0?this.context.texStorage3D(this.context.TEXTURE_2D_ARRAY,1,l,t,n,s):this.context.texImage3D(this.context.TEXTURE_2D_ARRAY,0,l,t,n,s,0,i,c,null),this.context.bindTexture(this.context.TEXTURE_2D_ARRAY,e)}else{const e=this.context.getParameter(this.context.TEXTURE_BINDING_2D);this.context.bindTexture(this.context.TEXTURE_2D,a),this.context.texImage2D(this.context.TEXTURE_2D,0,l,t,n,0,i,c,null),this.context.bindTexture(this.context.TEXTURE_2D,e)}return o}_getSupportedDepthFormats(){const e=[];return this.context instanceof WebGLRenderingContext&&!this.context.getExtension("WEBGL_depth_texture")||(e.push(this.context.DEPTH_COMPONENT,this.context.DEPTH_STENCIL),this.context instanceof WebGL2RenderingContext&&e.push(this.context.DEPTH_COMPONENT24,this.context.DEPTH24_STENCIL8)),e}}const tl={colorFormat:6408,mipLevels:1,layout:Ko.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0,textureType:Yo.texture,radius:2,centralAngle:.78539,aspectRatio:2},nl={layout:Ko.mono,invertStereo:!1,space:null,radius:2,centralAngle:.78539};class il extends el{constructor(e,t){super(),this._media=null!=t?t:null,this.isMediaLayer()?this.init=Object.assign(Object.assign({},nl),e):this.init=Object.assign(Object.assign({},tl),e),this.radius=this.init.radius,this.centralAngle=this.init.centralAngle,this.aspectRatio=this.init.aspectRatio,this.space=this.init.space,this.layout=this.init.layout;const n=Jo();this.init.transform?this.transform=new n.XRRigidTransform(e.transform.position,e.transform.orientation):this.transform=new n.XRRigidTransform({x:0,y:0,z:0,w:1}),this.isMediaLayer()||(this.isStatic=e.isStatic)}getTextureType(){return this.isMediaLayer()?Yo.texture:this.init.textureType}_deferredInitialize(){let e=this.determineLayoutAttribute(this.init.textureType,this.context,this.init.layout);this.layout=e,this.needsRedraw=!0}get colorTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._colorTextures}get depthStencilTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._depthStencilTextures&&this._depthStencilTextures.length||this._allocateDepthStencilTexturesInternal(this.getTextureType(),this.init),this._depthStencilTextures}get colorTexturesMeta(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._texturesMeta}get width(){return 2*this.radius*Math.PI*(this.centralAngle/(2*Math.PI))}get height(){return this.width/this.aspectRatio}}const rl={colorFormat:6408,mipLevels:1,layout:Ko.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0,textureType:Yo.texture,radius:0,centralHorizontalAngle:6.28318,upperVerticalAngle:1.570795,lowerVerticalAngle:-1.570795},sl={space:null,layout:Ko.mono,invertStereo:!1,radius:0,centralHorizontalAngle:6.28318,upperVerticalAngle:1.570795,lowerVerticalAngle:-1.570795};class al extends el{constructor(e,t){if(super(),this._media=null!=t?t:null,this.isMediaLayer()?this.init=Object.assign(Object.assign({},sl),e):this.init=Object.assign(Object.assign({},rl),e),!Zo(this.init.space))throw new TypeError("Equirect layer's space needs to be an XRReferenceSpace");this.radius=this.init.radius,this.centralHorizontalAngle=this.init.centralHorizontalAngle,this.upperVerticalAngle=this.init.upperVerticalAngle,this.lowerVerticalAngle=this.init.lowerVerticalAngle,this.space=this.init.space,this.layout=this.init.layout;const n=Jo();e.transform?this.transform=new n.XRRigidTransform(e.transform.position,e.transform.orientation):this.transform=new n.XRRigidTransform({x:0,y:0,z:0,w:1}),this.isMediaLayer()||(this.isStatic=e.isStatic)}getTextureType(){return this.isMediaLayer()?Yo.texture:this.init.textureType}_deferredInitialize(){let e=this.determineLayoutAttribute(this.init.textureType,this.context,this.init.layout);this.layout=e,this.needsRedraw=!0}get colorTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._colorTextures}get depthStencilTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._depthStencilTextures&&this._depthStencilTextures.length||this._allocateDepthStencilTexturesInternal(this.getTextureType(),this.init),this._depthStencilTextures}get colorTexturesMeta(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._texturesMeta}}const ol={colorFormat:6408,mipLevels:1,layout:Ko.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0,textureType:Yo.texture,width:1,height:1},ll={space:null,layout:Ko.mono,invertStereo:!1};class cl extends el{constructor(e,t){super(),this._media=null!=t?t:null,this.isMediaLayer()?this.init=Object.assign(Object.assign({},ll),e):this.init=Object.assign(Object.assign({},ol),e),this.width=this.init.width,this.height=this.init.height,this.space=this.init.space,this.layout=this.init.layout;const n=Jo();this.init.transform?this.transform=new n.XRRigidTransform(e.transform.position,e.transform.orientation):this.transform=new n.XRRigidTransform({x:0,y:0,z:0,w:1}),this.isMediaLayer()||(this.isStatic=e.isStatic)}getTextureType(){return this.isMediaLayer()?Yo.texture:this.init.textureType}_deferredInitialize(){let e=this.determineLayoutAttribute(this.init.textureType,this.context,this.init.layout);this.layout=e,this.needsRedraw=!0}get colorTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._colorTextures}get depthStencilTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._depthStencilTextures&&this._depthStencilTextures.length||this._allocateDepthStencilTexturesInternal(this.getTextureType(),this.init),this._depthStencilTextures}get colorTexturesMeta(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._texturesMeta}}class ul{constructor(e){if(this.session=e,this.session.ended)throw new Error("Session has ended")}createQuadLayer(e,t){if(this.session.ended)throw new Error("Session has ended");if(t.layout===Ko.default)throw new TypeError("Media Quad layer cannot be created with layout of default");let n=this.calculateAspectRatio(e,t.layout);void 0===t.width&&void 0===t.height&&(t.width=1),void 0===t.height&&(t.height=t.width/n),void 0===t.width&&(t.width=t.height/n);let i=new cl(t,e);return i.needsRedraw=!1,i.initialize(this.session),i}createCylinderLayer(e,t){if(this.session.ended)throw new Error("Session has ended");if(t.layout===Ko.default)throw new TypeError("Media Cylinder layer cannot be created with layout of default");let n=this.calculateAspectRatio(e,t.layout);void 0===t.aspectRatio&&(t.aspectRatio=n);let i=new il(t,e);return i.needsRedraw=!1,i.initialize(this.session),i}createEquirectLayer(e,t){if(this.session.ended)throw new Error("Session has ended");if(t.layout===Ko.default)throw new TypeError("Media Equirect layer cannot be created with layout of default");if(!Zo(t.space))throw new Error("Media Equirect layer's space must be of type XRReferenceSpace");let n=new al(t,e);return n.needsRedraw=!1,n.initialize(this.session),n}calculateAspectRatio(e,t){let n=e.videoWidth,i=e.videoHeight;return t===Ko["stereo-left-right"]&&(n/=2),t===Ko["stereo-top-bottom"]&&(i/=2),n/i}}const hl={textureType:Yo.texture,colorFormat:6408,depthFormat:6402,scaleFactor:1};class dl extends el{constructor(e=hl){super(),this.init=Object.assign(Object.assign({},hl),e)}initialize(e,t){super.initialize(e,t),this.initializeIfNeeded();let n=e.getBaseLayer();this.textureWidth=n.framebufferWidth*this.init.scaleFactor,this.textureHeight=n.framebufferHeight*this.init.scaleFactor}_allocateProjectionColorTextures(){let e=[],t=[];const n=()=>{e=[];for(let n of t)e.push(n.texture)};let i=this.session,r=i.internalViews;if(!r||0===r.length)return void console.warn("We can't allocate color textures without views");let s=i.getBaseLayer(),a=r.length,o=s.framebufferWidth*this.init.scaleFactor/r.length,l=s.framebufferHeight*this.init.scaleFactor;if(this.layout===Ko.mono||this.layout===Ko.default){if(this.init.textureType===Yo["texture-array"]){let e=this._createNewColorTexture(o,l,Yo["texture-array"],this.init.colorFormat,a);t=[e]}else for(let e of r){let e=this._createNewColorTexture(o,l,Yo.texture,this.init.colorFormat);t.push(e)}return n(),this._colorTexturesMeta=t,void(this._colorTextures=e)}if(this.layout===Ko["stereo-left-right"]){let e=this._createNewColorTexture(o*a,l,this.init.textureType,this.init.colorFormat);t=[e]}else if(this.layout===Ko["stereo-top-bottom"]){let e=this._createNewColorTexture(o,l*a,this.init.textureType,this.init.colorFormat);t=[e]}n(),this._colorTexturesMeta=t,this._colorTextures=e}_allocateProjectionDepthStencilTextures(){let e=this.session,t=e.internalViews;if(!t||0===t.length)return;if(0===this.init.depthFormat)return void(this._depthStencilTextures=[]);if(this.context instanceof WebGLRenderingContext){if(!this.context.getExtension("WEBGL_depth_texture"))return void(this._depthStencilTextures=[])}let n=[],i=[];const r=()=>{n=[];for(let e of i)n.push(e.texture)};this.initializeIfNeeded();let s=e.getBaseLayer(),a=t.length,o=s.framebufferWidth*this.init.scaleFactor/t.length,l=s.framebufferHeight*this.init.scaleFactor;if(this.layout===Ko.mono||this.layout===Ko.default){if(this.init.textureType===Yo["texture-array"]){let e=this._createNewDepthStencilTexture(o,l,this.init.textureType,this.init.depthFormat,a);i=[e]}else for(let e of t){let e=this._createNewDepthStencilTexture(o,l,this.init.textureType,this.init.depthFormat);i.push(e)}return r(),void(this._depthStencilTextures=n)}if(this.layout===Ko["stereo-left-right"]){let e=this._createNewDepthStencilTexture(o*a,l,this.init.textureType,this.init.depthFormat);i=[e]}else if(this.layout===Ko["stereo-top-bottom"]){let e=this._createNewDepthStencilTexture(o,l*a,this.init.textureType,this.init.depthFormat);i=[e]}r(),this._depthStencilTextures=n}get colorTextures(){return this._colorTextures&&this._colorTextures.length||this._allocateProjectionColorTextures(),this._colorTextures}get depthStencilTextures(){return void 0===this._depthStencilTextures&&this._allocateProjectionDepthStencilTextures(),this._depthStencilTextures||[]}get colorTexturesMeta(){return this._colorTextures&&this._colorTextures.length||this._allocateProjectionColorTextures(),this._colorTexturesMeta}getTextureType(){return this.init.textureType}_deferredInitialize(){this.isStatic=!1,this.ignoreDepthValues=!1,this.fixedFoveation=0;let e=this.determineLayoutAttribute(this.init.textureType,this.context,Ko.default);this.layout=e,this.needsRedraw=!0;let t=this.determineMaximumScaleFactor(),n=Math.min(this.init.scaleFactor,t);this.init.scaleFactor=n}determineMaximumScaleFactor(){let e=this.session.getBaseLayer(this.context),t=e.framebufferWidth,n=e.framebufferHeight;this.layout===Ko["stereo-left-right"]&&(t*=2),this.layout===Ko["stereo-top-bottom"]&&(n*=2);let i=Math.max(t,n);return this.context.getParameter(this.context.MAX_TEXTURE_SIZE)/i}}const pl=(e,t,n,i,r)=>{let s=0,a=0,o=t.width,l=t.height;n===Ko["stereo-left-right"]?(s=t.width*i/r,o=t.width/r):n===Ko["stereo-top-bottom"]&&(a=t.height*i/r,l=t.height/r),e.x=s,e.y=a,e.width=o,e.height=l},fl=(e,t,n)=>{var i=e.createShader(n);if(e.shaderSource(i,t),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw"could not compile shader:"+e.getShaderInfoLog(i);return i},ml=(e,t,n)=>{const i=e.createProgram(),r=fl(e,t,e.VERTEX_SHADER),s=fl(e,n,e.FRAGMENT_SHADER);if(e.attachShader(i,r),e.attachShader(i,s),e.deleteShader(r),e.deleteShader(s),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw"program failed to link:"+e.getProgramInfoLog(i);return i},gl=e=>{if(e instanceof WebGL2RenderingContext)return e;const t=e.getExtension("OES_vertex_array_object");if(!t)throw new Error("Cannot use VAOs.");return{VERTEX_ARRAY_BINDING:t.VERTEX_ARRAY_BINDING_OES,bindVertexArray:t.bindVertexArrayOES.bind(t),createVertexArray:t.createVertexArrayOES.bind(t),deleteVertexArray:t.deleteVertexArrayOES.bind(t),isVertexArray:t.isVertexArrayOES.bind(t)}},vl=e=>e,yl=vl`
|
|
635
|
+
attribute vec2 a_position;
|
|
636
|
+
attribute vec2 a_texCoord;
|
|
637
|
+
|
|
638
|
+
varying vec2 v_texCoord;
|
|
639
|
+
|
|
640
|
+
void main() {
|
|
641
|
+
// convert the rectangle from pixels to 0.0 to 1.0
|
|
642
|
+
vec2 zeroToOne = a_position;
|
|
643
|
+
|
|
644
|
+
// convert from 0->1 to 0->2
|
|
645
|
+
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
646
|
+
|
|
647
|
+
// convert from 0->2 to -1->+1 (clipspace)
|
|
648
|
+
vec2 clipSpace = zeroToTwo - 1.0;
|
|
649
|
+
|
|
650
|
+
gl_Position = vec4(clipSpace * vec2(1, 1), 0, 1);
|
|
651
|
+
|
|
652
|
+
// pass the texCoord to the fragment shader
|
|
653
|
+
// The GPU will interpolate this value between points.
|
|
654
|
+
v_texCoord = a_texCoord;
|
|
655
|
+
}
|
|
656
|
+
`,xl=vl`
|
|
657
|
+
precision mediump float;
|
|
658
|
+
|
|
659
|
+
// our texture
|
|
660
|
+
uniform sampler2D u_image;
|
|
661
|
+
|
|
662
|
+
// the texCoords passed in from the vertex shader.
|
|
663
|
+
varying vec2 v_texCoord;
|
|
664
|
+
|
|
665
|
+
void main() {
|
|
666
|
+
vec4 tex = texture2D(u_image, v_texCoord);
|
|
667
|
+
gl_FragColor = vec4(tex.rgb, tex.a);
|
|
668
|
+
}
|
|
669
|
+
`;class bl{constructor(e,t){this.gl=t,this.layer=e,this.program=ml(this.gl,yl,xl),this.programInfo={attribLocations:{a_position:this.gl.getAttribLocation(this.program,"a_position"),a_texCoord:this.gl.getAttribLocation(this.program,"a_texCoord")}},this._createVAOs()}render(e){let t=this.gl,n=e.getBaseLayer();t.viewport(0,0,n.framebufferWidth,n.framebufferHeight);const i=this.layer.getTextureType(),r=t.getParameter(t.TEXTURE_BINDING_2D),s=t.getParameter(t.ACTIVE_TEXTURE);if(i!==Yo.texture)throw new Error("Created a texture projection renderer instead of a texture-array projection renderer for a texture-array layer.\nThis is probably an error with the polyfill itself; please file an issue on Github if you run into this.");t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.layer.colorTextures[0]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let i of e.internalViews){let e=n.getViewport(i);t.viewport(e.x,e.y,e.width,e.height),this._shouldUseStereoTexturePoints()?this._renderInternalStereo(i):this._renderInternal()}t.activeTexture(s),t.bindTexture(t.TEXTURE_2D,r)}_renderInternal(){let e=this.gl;const t=e.getParameter(e.CURRENT_PROGRAM);e.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao);var n=e.TRIANGLES;e.drawArrays(n,0,6),this.vaoGl.bindVertexArray(null),e.useProgram(t)}_renderInternalStereo(e){if("none"===e.eye)return this._renderInternal();let t=this.gl;this.vaoGl.bindVertexArray(this.vao);const n=t.getParameter(t.CURRENT_PROGRAM);t.useProgram(this.program),this._setStereoTextureBuffer("right"===e.eye?1:0);var i=t.TRIANGLES;t.drawArrays(i,0,6),this.vaoGl.bindVertexArray(null),t.useProgram(n)}_createVAOs(){this._createTextureUVs();let e=this.gl;this.vaoGl=gl(e);let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t),((e,t,n,i,r)=>{var s=t,a=t+i,o=n,l=n+r;e.bufferData(e.ARRAY_BUFFER,new Float32Array([s,o,a,o,s,l,s,l,a,o,a,l]),e.DYNAMIC_DRAW)})(e,0,0,1,1);let n=e.FLOAT,i=!1;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,2,n,i,0,0),this.texcoordBuffer=e.createBuffer(),e.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),e.bindBuffer(e.ARRAY_BUFFER,this.texcoordBuffer),e.bufferData(e.ARRAY_BUFFER,this.texturePoints,e.DYNAMIC_DRAW),e.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,2,n,i,0,0),this.vaoGl.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null)}_setStereoTextureBuffer(e){let t=this.gl;t.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),t.bufferData(t.ARRAY_BUFFER,this.stereoTexturePoints[e],t.STATIC_DRAW);var n=t.FLOAT;t.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,2,n,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,null)}_createTextureUVs(){this.texturePoints=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);const e={x:0,y:0,width:1,height:1};this._shouldUseStereoTexturePoints()&&(this.stereoTexturePoints=[],pl(e,this.layer.colorTexturesMeta[0],this.layer.layout,0,2),this.stereoTexturePoints[0]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e),pl(e,this.layer.colorTexturesMeta[0],this.layer.layout,1,2),this.stereoTexturePoints[1]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e))}_offsetTextureUVsByRect(e,t,n){const i=(n=null!=n?n:{x:0,y:0,width:e.width,height:e.height}).x/e.width,r=n.y/e.height,s=n.width/e.width,a=n.height/e.height,o=[];for(let e=0;e<t.length;e+=2){let n=t[e]*s+i,l=t[e+1]*a+r;o[e]=n,o[e+1]=l}return new Float32Array(o)}_shouldUseStereoTexturePoints(){return this.layer.layout===Ko["stereo-left-right"]||this.layer.layout===Ko["stereo-top-bottom"]}}const _l=vl`#version 300 es
|
|
670
|
+
|
|
671
|
+
in vec2 a_position;
|
|
672
|
+
in vec2 a_texCoord;
|
|
673
|
+
|
|
674
|
+
out vec2 v_texCoord;
|
|
675
|
+
|
|
676
|
+
void main() {
|
|
677
|
+
// convert the rectangle from pixels to 0.0 to 1.0
|
|
678
|
+
vec2 zeroToOne = a_position;
|
|
679
|
+
|
|
680
|
+
// convert from 0->1 to 0->2
|
|
681
|
+
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
682
|
+
|
|
683
|
+
// convert from 0->2 to -1->+1 (clipspace)
|
|
684
|
+
vec2 clipSpace = zeroToTwo - 1.0;
|
|
685
|
+
|
|
686
|
+
gl_Position = vec4(clipSpace * vec2(1, 1), 0, 1);
|
|
687
|
+
|
|
688
|
+
// pass the texCoord to the fragment shader
|
|
689
|
+
// The GPU will interpolate this value between points.
|
|
690
|
+
v_texCoord = a_texCoord;
|
|
691
|
+
}
|
|
692
|
+
`,wl=vl`#version 300 es
|
|
693
|
+
precision mediump float;
|
|
694
|
+
precision mediump int;
|
|
695
|
+
precision mediump sampler2DArray;
|
|
696
|
+
|
|
697
|
+
uniform sampler2DArray u_image;
|
|
698
|
+
uniform int u_layer;
|
|
699
|
+
|
|
700
|
+
in vec2 v_texCoord;
|
|
701
|
+
|
|
702
|
+
out vec4 fragColor;
|
|
703
|
+
|
|
704
|
+
void main() {
|
|
705
|
+
vec4 tex = texture(u_image, vec3(v_texCoord.x, v_texCoord.y, u_layer));
|
|
706
|
+
fragColor = vec4(tex.rgb, tex.a);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
`;class Sl extends bl{constructor(e,t){super(e,t),this.program=ml(this.gl,_l,wl),this._createVAOs(),this.u_layerInfo=this.gl.getUniformLocation(this.program,"u_layer")}render(e){let t=this.gl;if(this.layer.getTextureType()===Yo.texture)throw new Error("Using texture array projection renderer on a layer without texture array.");let n=e.getBaseLayer();const i=t.getParameter(t.TEXTURE_BINDING_2D_ARRAY);t.bindTexture(t.TEXTURE_2D_ARRAY,this.layer.colorTextures[0]),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let i of e.internalViews){let r=e.getViewIndex(i),s=n.getViewport(i);t.viewport(s.x,s.y,s.width,s.height),this._renderInternal(r)}t.bindTexture(t.TEXTURE_2D_ARRAY,i)}_renderInternal(e=0){let t=this.gl;const n=t.getParameter(t.CURRENT_PROGRAM);t.useProgram(this.program),t.bindVertexArray(this.vao),t.uniform1i(this.u_layerInfo,e);var i=t.TRIANGLES;t.drawArrays(i,0,6),t.bindVertexArray(null),t.useProgram(n)}}const Ml=(e,t)=>e.getTextureType()===Yo["texture-array"]&&t instanceof WebGL2RenderingContext?new Sl(e,t):new bl(e,t);var Tl="undefined"!=typeof Float32Array?Float32Array:Array;function El(){var e=new Tl(16);return Tl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Al(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],y=t[15],x=n[0],b=n[1],_=n[2],w=n[3];return e[0]=x*i+b*o+_*h+w*m,e[1]=x*r+b*l+_*d+w*g,e[2]=x*s+b*c+_*p+w*v,e[3]=x*a+b*u+_*f+w*y,x=n[4],b=n[5],_=n[6],w=n[7],e[4]=x*i+b*o+_*h+w*m,e[5]=x*r+b*l+_*d+w*g,e[6]=x*s+b*c+_*p+w*v,e[7]=x*a+b*u+_*f+w*y,x=n[8],b=n[9],_=n[10],w=n[11],e[8]=x*i+b*o+_*h+w*m,e[9]=x*r+b*l+_*d+w*g,e[10]=x*s+b*c+_*p+w*v,e[11]=x*a+b*u+_*f+w*y,x=n[12],b=n[13],_=n[14],w=n[15],e[12]=x*i+b*o+_*h+w*m,e[13]=x*r+b*l+_*d+w*g,e[14]=x*s+b*c+_*p+w*v,e[15]=x*a+b*u+_*f+w*y,e}function Rl(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=n+n,o=i+i,l=r+r,c=n*a,u=i*a,h=i*o,d=r*a,p=r*o,f=r*l,m=s*a,g=s*o,v=s*l;return e[0]=1-h-f,e[1]=u+v,e[2]=d-g,e[3]=0,e[4]=u-v,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Cl(){var e=new Tl(2);return Tl!=Float32Array&&(e[0]=0,e[1]=0),e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),function(){var e=Cl()}();const Pl=e=>e,Il=Pl`
|
|
710
|
+
attribute vec4 a_position;
|
|
711
|
+
attribute vec2 a_texCoord;
|
|
712
|
+
|
|
713
|
+
uniform mat4 u_matrix;
|
|
714
|
+
uniform mat4 u_projectionMatrix;
|
|
715
|
+
|
|
716
|
+
varying vec2 v_texCoord;
|
|
717
|
+
|
|
718
|
+
void main() {
|
|
719
|
+
// Multiply the position by the matrix.
|
|
720
|
+
gl_Position = u_projectionMatrix * u_matrix * a_position;
|
|
721
|
+
|
|
722
|
+
// pass the texCoord to the fragment shader
|
|
723
|
+
// The GPU will interpolate this value between points.
|
|
724
|
+
v_texCoord = a_texCoord;
|
|
725
|
+
}
|
|
726
|
+
`,Ll=Pl`
|
|
727
|
+
precision mediump float;
|
|
728
|
+
|
|
729
|
+
// our texture
|
|
730
|
+
uniform sampler2D u_image;
|
|
731
|
+
|
|
732
|
+
// the texCoords passed in from the vertex shader.
|
|
733
|
+
varying vec2 v_texCoord;
|
|
734
|
+
|
|
735
|
+
void main() {
|
|
736
|
+
vec4 tex = texture2D(u_image, v_texCoord);
|
|
737
|
+
gl_FragColor = vec4(tex.rgb, tex.a);
|
|
738
|
+
// gl_FragColor = vec4(1.0, 0, 0, 1.0);
|
|
739
|
+
}
|
|
740
|
+
`,Dl=Pl`#version 300 es
|
|
741
|
+
|
|
742
|
+
in vec4 a_position;
|
|
743
|
+
in vec2 a_texCoord;
|
|
744
|
+
|
|
745
|
+
uniform mat4 u_matrix;
|
|
746
|
+
uniform mat4 u_projectionMatrix;
|
|
747
|
+
|
|
748
|
+
out vec2 v_texCoord;
|
|
749
|
+
|
|
750
|
+
void main() {
|
|
751
|
+
// Multiply the position by the matrix.
|
|
752
|
+
gl_Position = u_projectionMatrix * u_matrix * a_position;
|
|
753
|
+
|
|
754
|
+
// pass the texCoord to the fragment shader
|
|
755
|
+
// The GPU will interpolate this value between points.
|
|
756
|
+
v_texCoord = a_texCoord;
|
|
757
|
+
}
|
|
758
|
+
`,Nl=Pl`#version 300 es
|
|
759
|
+
precision mediump float;
|
|
760
|
+
precision mediump int;
|
|
761
|
+
precision mediump sampler2DArray;
|
|
762
|
+
|
|
763
|
+
uniform sampler2DArray u_image;
|
|
764
|
+
uniform int u_layer;
|
|
765
|
+
|
|
766
|
+
in vec2 v_texCoord;
|
|
767
|
+
|
|
768
|
+
out vec4 fragColor;
|
|
769
|
+
|
|
770
|
+
void main() {
|
|
771
|
+
vec4 tex = texture(u_image, vec3(v_texCoord.x, v_texCoord.y, u_layer));
|
|
772
|
+
fragColor = vec4(tex.rgb, tex.a);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
`;class Ol{constructor(e,t){this.usesTextureArrayShaders=!1,this.savedVaoState={vao:null,arrayBuffer:null},this.hasMipmap=!1,this.gl=t,this.layer=e;let n=this.gl;this.transformMatrix=El(),t instanceof WebGL2RenderingContext&&this.layer.getTextureType()===Yo["texture-array"]&&(this.usesTextureArrayShaders=!0),this.usesTextureArrayShaders?this.program=ml(n,Dl,Nl):this.program=ml(n,Il,Ll),this.programInfo={attribLocations:{a_position:n.getAttribLocation(this.program,"a_position"),a_texCoord:n.getAttribLocation(this.program,"a_texCoord")},uniformLocations:{u_matrix:n.getUniformLocation(this.program,"u_matrix"),u_projectionMatrix:n.getUniformLocation(this.program,"u_projectionMatrix")}},this.usesTextureArrayShaders&&(this.programInfo.uniformLocations.u_layer=n.getUniformLocation(this.program,"u_layer"))}saveVaoState(){this.savedVaoState.vao=this.gl.getParameter(this.vaoGl.VERTEX_ARRAY_BINDING),this.savedVaoState.arrayBuffer=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING)}restoreVaoState(){this.vaoGl.bindVertexArray(this.savedVaoState.vao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.savedVaoState.arrayBuffer),this.savedVaoState.vao=this.savedVaoState.arrayBuffer=null}initialize(){let e=this.gl;if(this.layer.isMediaLayer()){this.mediaTexture=e.createTexture(),this.mediaTexturePolyfill={texture:this.mediaTexture,textureFormat:e.RGBA,width:this.layer.media.videoWidth,height:this.layer.media.videoHeight,type:Yo.texture};const t=e.getParameter(e.TEXTURE_BINDING_2D);e.bindTexture(e.TEXTURE_2D,this.mediaTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.layer.media.videoWidth,this.layer.media.videoHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindTexture(e.TEXTURE_2D,t)}this._createVAOs()}render(e,t){this.saveVaoState();let n=this.gl,i=e.getBaseLayer(),r=t.getViewerPose(e.getReferenceSpace());const s=n.getParameter(n.ACTIVE_TEXTURE);for(let a of r.views){let r=i.getViewport(a);if(n.viewport(r.x,r.y,r.width,r.height),n.activeTexture(n.TEXTURE0),this.usesTextureArrayShaders){if(n instanceof WebGLRenderingContext)throw new Error("This should never happen; texture-arrays only supported on WebGL2.");if(this.layer.isMediaLayer())throw new Error("This should never happen. Media layers should never be created with texture-array");const i=n.getParameter(n.TEXTURE_BINDING_2D_ARRAY);n.bindTexture(n.TEXTURE_2D_ARRAY,this.layer.colorTextures[0]),this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_2D_ARRAY),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_2D_ARRAY,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_2D_ARRAY,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR);let r=0;if(this.layer.layout===Ko.stereo&&"right"===a.eye)r=1;this._shouldUseStereoTexturePoints()?this._renderInternalStereo(e,t,a,r):this._renderInternal(e,t,a,r),n.activeTexture(s),n.bindTexture(n.TEXTURE_2D_ARRAY,i)}else{const i=n.getParameter(n.TEXTURE_BINDING_2D);if(this.layer.isMediaLayer())n.bindTexture(n.TEXTURE_2D,this.mediaTexture),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.layer.media.videoWidth,this.layer.media.videoHeight,n.RGBA,n.UNSIGNED_BYTE,this.layer.media);else if(this.layer.layout===Ko.stereo)if("right"===a.eye)n.bindTexture(n.TEXTURE_2D,this.layer.colorTextures[1]);else n.bindTexture(n.TEXTURE_2D,this.layer.colorTextures[0]);else n.bindTexture(n.TEXTURE_2D,this.layer.colorTextures[0]);this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_2D),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),this._shouldUseStereoTexturePoints()?this._renderInternalStereo(e,t,a):this._renderInternal(e,t,a),n.activeTexture(s),n.bindTexture(n.TEXTURE_2D,i)}}this.restoreVaoState()}createPositionPoints(){return new Float32Array([])}createTextureUVs(){return new Float32Array([])}_offsetTextureUVsByRect(e,t,n){const i=(n=null!=n?n:{x:0,y:0,width:e.width,height:e.height}).x/e.width,r=n.y/e.height,s=n.width/e.width,a=n.height/e.height,o=[];for(let e=0;e<t.length;e+=2){let n=t[e]*s+i,l=t[e+1]*a+r;o[e]=n,o[e+1]=l}return new Float32Array(o)}_shouldUseStereoTexturePoints(){return this.layer.layout===Ko["stereo-left-right"]||this.layer.layout===Ko["stereo-top-bottom"]}_setStereoTextureBuffer(e){let t=this.gl;t.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),t.bufferData(t.ARRAY_BUFFER,this.stereoTexturePoints[e],t.STATIC_DRAW);var n=t.FLOAT;t.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,2,n,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,null)}_recalculateVertices(){this.positionPoints=this.createPositionPoints(),this.texturePoints=this.createTextureUVs();const e={x:0,y:0,width:1,height:1};if(this._shouldUseStereoTexturePoints()){if(this.stereoTexturePoints=[],this.layer.isMediaLayer())return pl(e,this.mediaTexturePolyfill,this.layer.layout,0,2),this.stereoTexturePoints[0]=this._offsetTextureUVsByRect(this.mediaTexturePolyfill,this.texturePoints,e),pl(e,this.mediaTexturePolyfill,this.layer.layout,1,2),this.stereoTexturePoints[1]=this._offsetTextureUVsByRect(this.mediaTexturePolyfill,this.texturePoints,e),void(this.layer.layout===Ko["stereo-top-bottom"]&&([this.stereoTexturePoints[0],this.stereoTexturePoints[1]]=[this.stereoTexturePoints[1],this.stereoTexturePoints[0]]));pl(e,this.layer.colorTexturesMeta[0],this.layer.layout,0,2),this.stereoTexturePoints[0]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e),pl(e,this.layer.colorTexturesMeta[0],this.layer.layout,1,2),this.stereoTexturePoints[1]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e),this.layer.layout===Ko["stereo-top-bottom"]&&([this.stereoTexturePoints[0],this.stereoTexturePoints[1]]=[this.stereoTexturePoints[1],this.stereoTexturePoints[0]])}}_createVAOs(){this._recalculateVertices();let e=this.gl;this.vaoGl=gl(e),this.saveVaoState();let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t);const n=this.positionPoints;e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW);var i=3,r=e.FLOAT,s=!1,a=0,o=0;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,i,r,s,a,o),e.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),this.texcoordBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.texcoordBuffer),e.bufferData(e.ARRAY_BUFFER,this.texturePoints,e.STATIC_DRAW);i=2,r=e.FLOAT,s=!1,a=0,o=0;e.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,i,r,s,a,o),this.restoreVaoState()}_renderInternal(e,t,n,i){let r=this.gl;const s=r.getParameter(r.CURRENT_PROGRAM);r.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao),this.usesTextureArrayShaders&&r.uniform1i(this.programInfo.uniformLocations.u_layer,i),this._setTransformMatrix(e,t,n),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,n.projectionMatrix);var a=r.TRIANGLES,o=this.positionPoints.length/3;r.drawArrays(a,0,o),this.vaoGl.bindVertexArray(null),r.useProgram(s)}_renderInternalStereo(e,t,n,i){if("none"===n.eye)return this._renderInternal(e,t,n);let r=this.gl;this.vaoGl.bindVertexArray(this.vao);const s=r.getParameter(r.CURRENT_PROGRAM);r.useProgram(this.program),this._setStereoTextureBuffer("right"===n.eye?1:0),this.usesTextureArrayShaders&&r.uniform1i(this.programInfo.uniformLocations.u_layer,i),this._setTransformMatrix(e,t,n),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,n.projectionMatrix);var a=r.TRIANGLES,o=this.positionPoints.length/3;r.drawArrays(a,0,o),this.vaoGl.bindVertexArray(null),r.useProgram(s)}_setTransformMatrix(e,t,n){let i=t.getPose(this.layer.space,e.getReferenceSpace());Al(this.transformMatrix,i.transform.matrix,this.layer.transform.matrix),Al(this.transformMatrix,n.transform.inverse.matrix,this.transformMatrix)}}class Fl extends Ol{constructor(e,t){super(e,t),this.initialize()}createPositionPoints(){const e=this.layer.width,t=this.layer.height;return new Float32Array([-e,-t,0,e,-t,0,-e,t,0,-e,t,0,e,-t,0,e,t,0])}createTextureUVs(){return new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])}}class kl extends Ol{constructor(e,t){super(e,t),this.segments=16,this.initialize()}createPositionPoints(){const e=[],t=this.layer.centralAngle,n=this.layer.height,i=this.layer.radius,r=t/this.segments,s=Math.PI/2-t/2,a=[],o=Cl();o[0]=i*Math.cos(s),o[1]=-i*Math.sin(s),a.push(o);for(let e=0;e<this.segments;e++){const t=Cl();t[0]=i*Math.cos(s+r*(e+1)),t[1]=-i*Math.sin(s+r*(e+1)),a.push(t)}a.reverse();for(let t=0;t<this.segments;t++){const i=a[t],r=a[t+1];e.push(i[0],-n/2,i[1]),e.push(r[0],-n/2,r[1]),e.push(i[0],n/2,i[1]),e.push(i[0],n/2,i[1]),e.push(r[0],-n/2,r[1]),e.push(r[0],n/2,r[1])}return new Float32Array(e)}createTextureUVs(){let e=[];const t=1/this.segments;for(let n=0;n<this.segments;n++){let i=t*n,r=t*(n+1);e.push(i,0),e.push(r,0),e.push(i,1),e.push(i,1),e.push(r,0),e.push(r,1)}return new Float32Array(e)}}class Ul extends Ol{constructor(e,t){super(e,t),this.segmentsPerAxis=40,this.initialize()}createPositionPoints(){const e=[];let t=this.layer.radius;0===t&&(t=25),t>25&&(t=25);const n=this.layer.centralHorizontalAngle,i=this.layer.upperVerticalAngle+Math.PI/2,r=this.layer.lowerVerticalAngle+Math.PI/2,s=Math.PI/2-n/2,a=s+n,o=r-i,l=a-s,c=[];for(let e=0;e<=this.segmentsPerAxis;e++)for(let n=0;n<=this.segmentsPerAxis;n++){let r=t,s=a-l*(n/this.segmentsPerAxis),u=o*(e/this.segmentsPerAxis)+i;const h=Math.cos(s)*Math.sin(u),d=Math.cos(u),p=-Math.sin(s)*Math.sin(u);c.push([r*h,r*d,r*p])}const u=this.segmentsPerAxis+1;for(let t=0;t<this.segmentsPerAxis;t++)for(let n=0;n<this.segmentsPerAxis;n++)e.push(...c[n*u+t]),e.push(...c[n*u+t+1]),e.push(...c[(n+1)*u+t]),e.push(...c[(n+1)*u+t]),e.push(...c[n*u+t+1]),e.push(...c[(n+1)*u+t+1]);return new Float32Array(e)}createTextureUVs(){const e=[],t=[];for(let e=0;e<=this.segmentsPerAxis;e++)for(let n=0;n<=this.segmentsPerAxis;n++){const i=n/this.segmentsPerAxis,r=e/this.segmentsPerAxis;t.push([i,r])}const n=this.segmentsPerAxis+1;for(let i=0;i<this.segmentsPerAxis;i++)for(let r=0;r<this.segmentsPerAxis;r++)e.push(...t[r*n+i]),e.push(...t[r*n+i+1]),e.push(...t[(r+1)*n+i]),e.push(...t[(r+1)*n+i]),e.push(...t[r*n+i+1]),e.push(...t[(r+1)*n+i+1]);return new Float32Array(e)}}const zl={colorFormat:6408,mipLevels:1,layout:Ko.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0};class Bl extends el{constructor(e=zl){if(super(),!Zo(e.space))throw new TypeError("XRCubeLayer's space needs to be an XRReferenceSpace");switch(this.init=Object.assign(Object.assign({},zl),e),this.space=this.init.space,this.isStatic=this.init.isStatic,this.init.orientation?this.orientation=DOMPointReadOnly.fromPoint(this.init.orientation):this.orientation=new DOMPointReadOnly,this.init.layout){case Ko.default:case Ko["stereo-left-right"]:case Ko["stereo-top-bottom"]:throw new TypeError("Invalid layout format for XRCubeLayer")}this.layout=this.init.layout,this.needsRedraw=!0}initialize(e,t){super.initialize(e,t),this._allocateColorTexturesInternal(),this._allocateDepthStencilTexturesInternal()}_allocateColorTexturesInternal(){if(this._colorTextures=[],this._texturesMeta=[],this.layout===Ko.mono){const e=this._createCubeColorTexture();return this._texturesMeta.push(e),void this._colorTextures.push(e.texture)}{const e=this._createCubeColorTexture(),t=this._createCubeColorTexture();return this._texturesMeta.push(e,t),void this._colorTextures.push(e.texture,t.texture)}}_allocateDepthStencilTexturesInternal(){if(this._depthStencilTextures=[],this.init.depthFormat){if(this.context instanceof WebGLRenderingContext){if(!this.context.getExtension("WEBGL_depth_texture"))throw new TypeError("Depth textures not supported in the current context")}if(this.layout===Ko.mono){const e=this._createCubeDepthTexture();return void this._depthStencilTextures.push(e.texture)}{const e=this._createCubeDepthTexture(),t=this._createCubeDepthTexture();return void this._depthStencilTextures.push(e.texture,t.texture)}}}_createCubeColorTexture(){let e=this.context.createTexture(),t={width:this.init.viewPixelWidth,height:this.init.viewPixelHeight,layers:1,type:Yo.texture,textureFormat:this.init.colorFormat,texture:e};const n=this.context.getParameter(this.context.TEXTURE_BINDING_CUBE_MAP);this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,e);for(let e=0;e<6;e++)this.context.texImage2D(this.context.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,t.textureFormat,t.width,t.height,0,t.textureFormat,this.context.UNSIGNED_BYTE,null);return this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,n),t}_createCubeDepthTexture(){let e=this.context.createTexture(),t={width:this.init.viewPixelWidth,height:this.init.viewPixelHeight,layers:1,type:Yo.texture,textureFormat:this.init.depthFormat,texture:e};const n=this.context.getParameter(this.context.TEXTURE_BINDING_CUBE_MAP);this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,e);let i=this.init.depthFormat;this.context instanceof WebGL2RenderingContext&&(i===this.context.DEPTH_COMPONENT&&(i=this.context.DEPTH_COMPONENT24),i===this.context.DEPTH_STENCIL&&(i=this.context.DEPTH24_STENCIL8));for(let e=0;e<6;e++)this.context.texImage2D(this.context.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,i,t.width,t.height,0,t.textureFormat,this.context.UNSIGNED_INT,null);return this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,n),t}getTextureType(){return Yo.texture}}const Vl=e=>e,Gl=Vl`
|
|
776
|
+
attribute vec4 a_position;
|
|
777
|
+
uniform mat4 u_projectionMatrix;
|
|
778
|
+
uniform mat4 u_matrix;
|
|
779
|
+
varying vec3 v_normal;
|
|
780
|
+
|
|
781
|
+
void main() {
|
|
782
|
+
gl_Position = u_projectionMatrix * u_matrix * a_position;
|
|
783
|
+
|
|
784
|
+
v_normal = normalize(a_position.xyz);
|
|
785
|
+
}
|
|
786
|
+
`,Hl=Vl`
|
|
787
|
+
precision mediump float;
|
|
788
|
+
|
|
789
|
+
varying vec3 v_normal;
|
|
790
|
+
|
|
791
|
+
uniform samplerCube u_texture;
|
|
792
|
+
|
|
793
|
+
void main() {
|
|
794
|
+
gl_FragColor = textureCube(u_texture, normalize(v_normal));
|
|
795
|
+
}
|
|
796
|
+
`;class Wl{constructor(e,t){this.savedVaoState={vao:null,arrayBuffer:null},this.hasMipmap=!1,this.layer=e,this.gl=t,this.transformMatrix=El(),this.program=ml(t,Gl,Hl),this.programInfo={attribLocations:{a_position:t.getAttribLocation(this.program,"a_position")},uniformLocations:{u_matrix:t.getUniformLocation(this.program,"u_matrix"),u_texture:t.getUniformLocation(this.program,"u_texture"),u_projectionMatrix:t.getUniformLocation(this.program,"u_projectionMatrix")}},this._createVAOs()}saveVaoState(){this.savedVaoState.vao=this.gl.getParameter(this.vaoGl.VERTEX_ARRAY_BINDING),this.savedVaoState.arrayBuffer=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING)}restoreVaoState(){this.vaoGl.bindVertexArray(this.savedVaoState.vao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.savedVaoState.arrayBuffer),this.savedVaoState.vao=this.savedVaoState.arrayBuffer=null}render(e,t){this.saveVaoState();let n=this.gl,i=e.getBaseLayer(),r=t.getViewerPose(e.getReferenceSpace());const s=n.getParameter(n.ACTIVE_TEXTURE);for(let e of r.views){let t=i.getViewport(e);n.viewport(t.x,t.y,t.width,t.height),n.activeTexture(n.TEXTURE0);const r=n.getParameter(n.TEXTURE_BINDING_CUBE_MAP);if(this.layer.layout===Ko.stereo){const t="right"===e.eye?1:0;n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[t])}else n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[0]);this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),this._renderInternal(this.layer.orientation,e),n.activeTexture(s),n.bindTexture(n.TEXTURE_CUBE_MAP,r)}this.restoreVaoState()}createPositionPoints(){const e=.5;return new Float32Array([-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,-e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e,e,-e,e,-e,-e,e,e,e,e,-e,-e,e,e,e,e,e,e,e,-e,-e,-e,-e,e,-e,-e,-e,-e,e,-e,-e,e,e,-e,-e,e,-e,e,-e,-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e])}_renderInternal(e,t){let n=this.gl;const i=n.getParameter(n.CURRENT_PROGRAM);n.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao),Rl(this.transformMatrix,[e.x,e.y,e.z,e.w]),this._poseOrientationMatrix||(this._poseOrientationMatrix=El()),Rl(this._poseOrientationMatrix,[t.transform.inverse.orientation.x,t.transform.inverse.orientation.y,t.transform.inverse.orientation.z,t.transform.inverse.orientation.w]),Al(this.transformMatrix,this.transformMatrix,this._poseOrientationMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,t.projectionMatrix),n.uniform1i(this.programInfo.uniformLocations.u_texture,0);var r=n.TRIANGLES,s=this.positionPoints.length/3;n.drawArrays(r,0,s),this.vaoGl.bindVertexArray(null),n.useProgram(i)}_recalculateVertices(){this.positionPoints=this.createPositionPoints()}_createVAOs(){this._recalculateVertices();let e=this.gl;this.vaoGl=gl(e),this.saveVaoState();let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t);const n=this.positionPoints;e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW);var i=e.FLOAT;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,3,i,!1,0,0),this.restoreVaoState()}}class jl{constructor(){this.mode="inline",this.layers=[],this.views=[],this.initializedViews=!1,this.isPolyfillActive=!1,this.taskQueue=[]}requestAnimationFrame(e){this.injectedFrameCallback||(this.injectedFrameCallback=(t,n)=>{let i=this.context;if(!this.initializedViews&&this.referenceSpace){let e=n.getViewerPose(this.referenceSpace);e&&(this.views=e.views,this.initializedViews=!0)}if(this.isPolyfillActive&&this.initializedViews){this.tempFramebuffer||(this.tempFramebuffer=i.createFramebuffer()),i.bindFramebuffer(i.FRAMEBUFFER,this.tempFramebuffer);const e=i.getParameter(i.COLOR_CLEAR_VALUE),t=i.getParameter(i.FRAMEBUFFER_BINDING);i.clearColor(0,0,0,0);for(let e of this.layers)if(e instanceof dl)for(let t=0;t<e.colorTextures.length;t++){e.colorTexturesMeta[t].type===Yo["texture-array"]||(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.colorTextures[t],0),e.depthStencilTextures&&t<e.depthStencilTextures.length?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,e.depthStencilTextures[t],0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,null,0),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT))}i.bindFramebuffer(i.FRAMEBUFFER,t),i.clearColor(e[0],e[1],e[2],e[3])}if(e(t,n),this.isPolyfillActive&&this.initializedViews){let e=i.isEnabled(i.BLEND),t=i.isEnabled(i.DEPTH_TEST),r=i.isEnabled(i.CULL_FACE);const s=i.getParameter(i.FRAMEBUFFER_BINDING),a=i.getParameter(i.COLOR_CLEAR_VALUE);i.bindFramebuffer(i.FRAMEBUFFER,this.getBaseLayer().framebuffer),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.clearColor(a[0],a[1],a[2],a[3]),i.enable(i.BLEND),i.disable(i.DEPTH_TEST),i.disable(i.CULL_FACE);let o=i.getParameter(i.BLEND_SRC_RGB),l=i.getParameter(i.BLEND_SRC_ALPHA),c=i.getParameter(i.BLEND_DST_RGB),u=i.getParameter(i.BLEND_DST_ALPHA);i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA);for(let e of this.layers)if(this.renderers||(this.renderers=new WeakMap),e instanceof dl){this.renderers.has(e)||this.renderers.set(e,Ml(e,this.context));this.renderers.get(e).render(this)}else if(e instanceof cl){this.renderers.has(e)||this.renderers.set(e,new Fl(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof il){this.renderers.has(e)||this.renderers.set(e,new kl(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof al){this.renderers.has(e)||this.renderers.set(e,new Ul(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof Bl){this.renderers.has(e)||this.renderers.set(e,new Wl(e,this.context));this.renderers.get(e).render(this,n)}else{const t=e;if(null===t.framebuffer)continue;i instanceof WebGL2RenderingContext?(i.bindFramebuffer(i.READ_FRAMEBUFFER,t.framebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.getBaseLayer().framebuffer),i.blitFramebuffer(0,0,t.framebufferWidth,t.framebufferHeight,0,0,this.getBaseLayer().framebufferWidth,this.getBaseLayer().framebufferHeight,i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT,i.LINEAR)):console.warn("GL blitFramebuffer is not supported on WebGL1, so XRWebGLLayers may not show up properly when polyfilled.")}for(e||i.disable(i.BLEND),t&&i.enable(i.DEPTH_TEST),r&&i.enable(i.CULL_FACE),i.blendFuncSeparate(o,c,l,u),i.bindFramebuffer(i.FRAMEBUFFER,s);this.taskQueue.length>0;){this.taskQueue.shift()()}}}),this._requestAnimationFrame(this.injectedFrameCallback)}updateRenderState(e){if(this.existingBaseLayer=e.baseLayer,e.layers&&(this.layers=e.layers),this.activeRenderState||this.createActiveRenderState(),this.activeRenderState=Object.assign(Object.assign({},this.activeRenderState),e),!e.layers)return void this._updateRenderState(e);let t,n=Object.assign({},e);delete n.layers;for(let i of this.layers)if(i instanceof el){t=i.getContext();break}if(!t&&!this.context){console.log("No existing context! Have the session make one");const r=document.createElement("canvas");if(t=r.getContext("webgl2",{xrCompatible:!0}),t||(t=r.getContext("webgl",{xrCompatible:!0})),!t)throw new Error("No webGL support detected.");function s(){t.canvas.width=t.canvas.clientWidth*window.devicePixelRatio,t.canvas.height=t.canvas.clientHeight*window.devicePixelRatio}document.body.appendChild(t.canvas),window.addEventListener("resize",s),s()}this.createInternalLayer(t),this.isPolyfillActive=!0,this._updateRenderState(Object.assign(Object.assign({},n),{baseLayer:this.internalLayer}))}initializeSession(e){this.mode=e,this.requestReferenceSpace("local").then(e=>{this.referenceSpace=e}).catch(e=>{}),this.requestReferenceSpace("viewer").then(e=>{this.viewerSpace=e})}getBaseLayer(e){return this.internalLayer||this.existingBaseLayer||!e||this.createInternalLayer(e),this.internalLayer||this.existingBaseLayer}getReferenceSpace(){return this.referenceSpace?this.referenceSpace:this.viewerSpace}getViewerSpace(){return this.viewerSpace}queueTask(e){this.taskQueue.push(e)}get renderState(){return this.activeRenderState||this.createActiveRenderState(),this.activeRenderState}get internalViews(){return this.views}getViewIndex(e){for(let t=0;t<this.views.length;t++){let n=this.views[t];if(e.eye===n.eye&&e.recommendedViewportScale===n.recommendedViewportScale)return t}return-1}createInternalLayer(e){if(!e&&this.internalLayer)return this.internalLayer;if(e===this.context&&this.internalLayer)return this.internalLayer;const t=Jo();return this.internalLayer=new t.XRWebGLLayer(this,e),this.setContext(e),this.internalLayer}setContext(e){this.context=e,this.tempFramebuffer=e.createFramebuffer(),this.renderers=new WeakMap}createActiveRenderState(){const e=Jo();let t=Object.getOwnPropertyNames(e.XRRenderState.prototype);const n={};for(let e of t)n[e]=this._renderState[e];n.layers=[],this.activeRenderState=n}}class Xl{constructor(){this.viewport={x:0,y:0,width:0,height:0}}}class ql{constructor(e,t){this.session=e,this.context=t,this.subImageCache=new $l}createProjectionLayer(e=hl){const t=new dl(e);if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");return t.initialize(this.session,this.context),t}createQuadLayer(e=ol){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Ko.default)throw new TypeError("Trying to create a quad layer with default layout");const t=new cl(e);return t.initialize(this.session,this.context),t}createCylinderLayer(e=tl){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Ko.default)throw new TypeError("Cylinder Layer cannot have a default layout");const t=new il(e);return t.initialize(this.session,this.context),t}createEquirectLayer(e=rl){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Ko.default)throw new TypeError("Equirect Layer cannot have a default layout");if(!Zo(e.space))throw new TypeError("Equirect layer requires an XRReferenceSpace");let t=new al(e);return t.initialize(this.session,this.context),t}createCubeLayer(e){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(!(this.context instanceof WebGL2RenderingContext))throw new Error("XRCubeLayer only work on WebGL2");if(!Zo(e.space))throw new TypeError("XRCubeLayer requires a space of type XRReferenceSpace");let t=new Bl(e);return t.initialize(this.session,this.context),t}getSubImage(e,t,n="none"){if(e.isStatic&&!1===e.needsRedraw)throw new Error("Invalid state for subimage creation");let i=this.subImageCache.tryGetCachedSubImage(this.context,e,n);if(i)return i;let r=new Xl;if(e instanceof dl)throw new TypeError;if(e.layout===Ko.default)throw new TypeError;if(!this.validateStateofSubImageCreation(e,t))throw new Error("Invalid state for subimage creation");let s=0;if(e.layout===Ko.stereo){if("none"===n)throw new TypeError;"right"===n&&(s=1)}e.getTextureType()===Yo["texture-array"]?r.imageIndex=s:r.imageIndex=0;let a=0;e.getTextureType()===Yo.texture?(r.colorTexture=e.colorTextures[s],a=s):(r.colorTexture=e.colorTextures[0],a=0),e.depthStencilTextures&&e.depthStencilTextures.length?e.getTextureType()===Yo.texture?r.depthStencilTexture=e.depthStencilTextures[s]:r.depthStencilTexture=e.depthStencilTextures[0]:r.depthStencilTexture=null;const o=e.colorTexturesMeta[a];r.textureWidth=o.width,r.textureHeight=o.height;let l=1;return e.layout!==Ko["stereo-left-right"]&&e.layout!==Ko["stereo-top-bottom"]||(l=2),pl(r.viewport,o,e.layout,s,l),this.session.queueTask(()=>{e.needsRedraw=!1}),this.subImageCache.cacheSubImage(r,this.context,e,n),r}getViewSubImage(e,t){let n=this.subImageCache.tryGetCachedViewSubImage(this.context,e,t);if(n)return n;let i=new Xl,r=this.session;if(!r.internalViews||!r.internalViews.length)return console.warn("Tried to get view sub image before we have any views"),i;let s=r.getViewIndex(t),a=0;return e.getTextureType()===Yo["texture-array"]?i.imageIndex=s:i.imageIndex=0,e.layout===Ko.default&&e.getTextureType()===Yo.texture?(i.colorTexture=e.colorTextures[s],a=s):(i.colorTexture=e.colorTextures[0],a=0),0===e.depthStencilTextures.length?i.depthStencilTexture=null:e.layout===Ko.default&&e.getTextureType()===Yo.texture?i.depthStencilTexture=e.depthStencilTextures[s]:i.depthStencilTexture=e.depthStencilTextures[0],i.textureWidth=e.colorTexturesMeta[a].width,i.textureHeight=e.colorTexturesMeta[a].height,pl(i.viewport,e.colorTexturesMeta[a],e.layout,s,r.internalViews.length),e.needsRedraw=!1,this.subImageCache.cacheViewSubImage(i,this.context,e,t),i}validateStateofSubImageCreation(e,t){return t.session===e.session&&(this.session===e.session&&(this.context===e.context&&(!(!e.colorTextures||!e.colorTextures.length)&&(!e.isStatic||!1!==e.needsRedraw))))}}class $l{constructor(){this.cache=new Map,this.viewCache=new Map}cacheSubImage(e,t,n,i){let r=new Map;r.set(i,e);let s=new Map;s.set(n,r),this.cache.set(t,s)}tryGetCachedSubImage(e,t,n){var i,r;return null===(r=null===(i=this.cache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}cacheViewSubImage(e,t,n,i){let r=new Map;r.set(i,e);let s=new Map;s.set(n,r),this.viewCache.set(t,s)}tryGetCachedViewSubImage(e,t,n){var i,r;return null===(r=null===(i=this.viewCache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}}class Yl{constructor(){this.injected=!1;const e=Jo();this._injectPolyfill(e)}_injectPolyfill(e){if(!("xr"in e.navigator))throw new Error("WebXR Layers polyfill requires WebXR support.");!0===this.injected&&console.warn("Polyfill has already been injected..."),(e=>!!e.navigator.xr&&!(!e.XRMediaBinding||!e.XRWebGLBinding))(e)||(this._polyfillRequiredLayersFeature(e),this._polyfillXRSession(e),e.XRWebGLBinding=ql,e.XRMediaBinding=ul,this.injected=!0,console.log("Injected Layers Polyfill"))}_polyfillXRSession(e){e.XRSession.prototype._updateRenderState=e.XRSession.prototype.updateRenderState,e.XRSession.prototype._requestAnimationFrame=e.XRSession.prototype.requestAnimationFrame;let t=Object.getOwnPropertyDescriptor(e.XRSession.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"_renderState",t);let n=Object.getOwnPropertyDescriptor(jl.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"renderState",n);let i=Object.getOwnPropertyNames(jl.prototype);for(let t of i){let n=Object.getOwnPropertyDescriptor(jl.prototype,t);Object.defineProperty(e.XRSession.prototype,t,n)}}_polyfillRequiredLayersFeature(e){const t=e.navigator.xr.requestSession;Object.defineProperty(e.navigator.xr,"requestSessionInternal",{writable:!0}),e.navigator.xr.requestSessionInternal=t;Object.defineProperty(e.navigator.xr,"requestSession",{writable:!0}),e.navigator.xr.requestSession=(t,n)=>{const i=(n,i)=>e.navigator.xr.requestSessionInternal(n,i).then(e=>{Object.assign(e,new jl);let n=e;return n.initializeSession(t),Promise.resolve(n)});if("immersive-vr"!==t)return i(t,n);if(!n)return i(t,n);if(n.requiredFeatures&&n.requiredFeatures.indexOf("layers")>-1){const e=Object.assign({},n),r=[...n.requiredFeatures],s=r.indexOf("layers");return r.splice(s,1),e.requiredFeatures=r,i(t,e)}return i(t,n)}}}const Kl={ipd:.063,fovy:Math.PI/2,headsetPosition:new Ys(0,1.6,0),headsetQuaternion:new Ks,stereoEnabled:!1},Zl=Zr(),Jl=Zr();class Ql{constructor(e,t={}){var n,i,r,s,a,o,l,c;this.version=Bo;const u=new qs,h=new Qa(Za.Viewer,u),d={[Ja.Left]:new Xs(h),[Ja.Right]:new Xs(h),[Ja.None]:new Xs(h)},p=e.controllerConfig,f={};p&&Object.values(ma).forEach(e=>{p.layout[e]&&(f[e]=new Ea(p,e,u))});const m={[ma.Left]:new Oo(wo,ma.Left,u),[ma.Right]:new Oo(wo,ma.Right,u)},g=Wo(e.supportedFeatures)?new jo(h):void 0,v=null!==(n=t.canvasContainer)&&void 0!==n?n:document.createElement("div");v.dataset.webxr_runtime=`Immersive Web Emulation Runtime v${Bo}`,v.style.position="fixed",v.style.width="100%",v.style.height="100%",v.style.top="0",v.style.left="0",v.style.display="flex",v.style.justifyContent="center",v.style.alignItems="center",v.style.overflow="hidden",v.style.zIndex="999";const y=null===t.visibilityMask?void 0:null!==(i=t.visibilityMask)&&void 0!==i?i:e.visibilityMask,x=y?document.createElement("canvas"):void 0;x&&(x.dataset.webxrVisibilityMask=e.name,x.style.position="absolute",x.style.inset="0",x.style.width="100%",x.style.height="100%",x.style.pointerEvents="none",x.style.zIndex=4..toString()),this[_s]={name:e.name,supportedSessionModes:e.supportedSessionModes,supportedFeatures:e.supportedFeatures,supportedFrameRates:e.supportedFrameRates,isSystemKeyboardSupported:e.isSystemKeyboardSupported,internalNominalFrameRate:e.internalNominalFrameRate,environmentBlendModes:e.environmentBlendModes,interactionMode:e.interactionMode,userAgent:e.userAgent,position:null!==(r=t.headsetPosition)&&void 0!==r?r:Kl.headsetPosition.clone(),quaternion:null!==(s=t.headsetQuaternion)&&void 0!==s?s:Kl.headsetQuaternion.clone(),stereoEnabled:null!==(a=t.stereoEnabled)&&void 0!==a?a:Kl.stereoEnabled,ipd:null!==(o=t.ipd)&&void 0!==o?o:Kl.ipd,fovy:null!==(l=t.fovy)&&void 0!==l?l:Kl.fovy,visibilityMask:y,visibilityMaskEnabled:Boolean(y)&&(null===(c=t.visibilityMaskEnabled)||void 0===c||c),visibilityMaskCanvas:x,controllers:f,hands:m,gaze:g,primaryInputMode:"controller",pendingReferenceSpaceReset:!1,visibilityState:"visible",pendingVisibilityState:null,xrSystem:null,installedGlobalObject:null,previousNavigatorXRDescriptor:null,previousUserAgentDescriptor:null,previousGlobals:null,previousMakeXRCompatible:null,matrix:Ur(),globalSpace:u,viewerSpace:h,viewSpaces:d,canvasContainer:v,getViewport:(e,t)=>{const n=e.context.canvas,{width:i,height:r}=n,s=this[_s].stereoEnabled,a=t.eye;let o,l,c,u;switch(a){case Ja.None:o=0,l=0,c=i,u=r;break;case Ja.Left:o=0,l=0,c=s?i/2:i,u=r;break;case Ja.Right:o=i/2,l=0,c=s?i/2:0,u=r}const h=this[_s].viewportCache[a];if(h&&h.x===o&&h.y===l&&h.width===c&&h.height===u)return h;const d=new qo(o,l,c,u);return this[_s].viewportCache[a]=d,d},viewportCache:{},updateViews:()=>{Xr(this[_s].viewerSpace[zs].offsetMatrix,this[_s].quaternion.quat,this[_s].position.vec3),es(Zl,-this[_s].ipd/2,0,0),Wr(this[_s].viewSpaces[Ja.Left][zs].offsetMatrix,Zl),es(Jl,this[_s].ipd/2,0,0),Wr(this[_s].viewSpaces[Ja.Right][zs].offsetMatrix,Jl)},onBaseLayerSet:e=>{if(!e)return;const t=e.context.canvas;if(t.parentElement!==this[_s].canvasContainer){const e=this[_s].devui;if(e){const{devUICanvas:t,devUIContainer:n}=e;t.style.zIndex=3..toString(),n.style.zIndex=5..toString(),this[_s].canvasContainer.appendChild(e.devUICanvas),this[_s].canvasContainer.appendChild(e.devUIContainer)}const n=this[_s].sem;n&&(n.environmentCanvas.style.zIndex=1..toString(),this[_s].canvasContainer.appendChild(n.environmentCanvas)),this[_s].canvasData={canvas:t,parent:t.parentElement,width:t.width,height:t.height,zIndex:t.style.zIndex},t.style.zIndex=2..toString(),this[_s].canvasContainer.appendChild(t),this[_s].visibilityMaskCanvas&&this[_s].canvasContainer.appendChild(this[_s].visibilityMaskCanvas),document.body.appendChild(this[_s].canvasContainer)}t.width=window.innerWidth,t.height=window.innerHeight},onSessionEnd:()=>{var e,t;if(null===(t=null===(e=this[_s].devui)||void 0===e?void 0:e.onSessionEnd)||void 0===t||t.call(e),this[_s].canvasData){const{canvas:e,parent:t,width:n,height:i,zIndex:r}=this[_s].canvasData;e.width=n,e.height=i,e.style.zIndex=r,t?t.appendChild(e):this[_s].canvasContainer.removeChild(e);const s=this[_s].devui;s&&(this[_s].canvasContainer.removeChild(s.devUICanvas),this[_s].canvasContainer.removeChild(s.devUIContainer));const a=this[_s].sem;a&&this[_s].canvasContainer.removeChild(a.environmentCanvas);const o=this[_s].visibilityMaskCanvas;(null==o?void 0:o.parentElement)===this[_s].canvasContainer&&this[_s].canvasContainer.removeChild(o),document.body.removeChild(this[_s].canvasContainer),this[_s].canvasData=void 0,window.dispatchEvent(new Event("resize"))}},onFrameStart:e=>{var t;const n=performance.now(),i=this[_s].lastFrameTime>0?n-this[_s].lastFrameTime:16.67;if(this[_s].lastFrameTime=n,this[_s].remote&&this[_s].remote.update(i),null===(t=this[_s].actionPlayer)||void 0===t?void 0:t.playing)this[_s].actionPlayer.playFrame();else{const t=e.session;this[_s].pendingVisibilityState&&(this[_s].visibilityState=this[_s].pendingVisibilityState,this[_s].pendingVisibilityState=null,t.dispatchEvent(new to("visibilitychange",{session:t}))),"visible"===this[_s].visibilityState&&this.activeInputs.forEach(t=>{t.onFrameStart(e)}),this[_s].pendingReferenceSpaceReset&&(t[Fs].referenceSpaces.forEach(e=>{switch(e[Us].type){case Za.Local:case Za.LocalFloor:case Za.BoundedFloor:case Za.Unbounded:e.dispatchEvent(new Vo("reset",{referenceSpace:e}))}}),this[_s].pendingReferenceSpaceReset=!1)}this[_s].updateViews(),this.drawVisibilityMask()},controlMode:"manual",controlModeListeners:new Set,stateChangeListeners:new Set,remote:null,runtime:null,lastFrameTime:0},this[_s].runtime={kind:"emulated",getSession:()=>{var e,t,n,i,r,s;const a=this.activeSession;if(!a)return null;const o=a[Fs],l=a,c=null===(e=null==o?void 0:o.referenceSpaces)||void 0===e?void 0:e[0];return{mode:null!==(n=null!==(t=null==o?void 0:o.mode)&&void 0!==t?t:l.mode)&&void 0!==n?n:"immersive-vr",enabledFeatures:null!==(i=l.enabledFeatures)&&void 0!==i?i:[],visibilityState:null!==(r=l.visibilityState)&&void 0!==r?r:this.visibilityState,originOffsetMatrix:null!==(s=null==c?void 0:c[zs].offsetMatrix)&&void 0!==s?s:null,end:()=>{var e;return null===(e=l.end)||void 0===e?void 0:e.call(l)}}}},this[_s].remote=new pa(this),this[_s].updateViews()}drawVisibilityMask(){var e;const t=this[_s].visibilityMask,n=this[_s].visibilityMaskCanvas,i=null===(e=this[_s].canvasData)||void 0===e?void 0:e.canvas;if(!(this[_s].visibilityMaskEnabled&&t&&n&&i))return;const r=i.width,s=i.height;if(r<=0||s<=0)return;n.width===r&&n.height===s||(n.width=r,n.height=s);const a=n.getContext("2d");if(!a)return;a.clearRect(0,0,r,s),a.fillStyle="#000";const o=this[_s].stereoEnabled?["left","right"]:["left"],l=r/o.length;o.forEach((e,n)=>{const i=n*l,r=function(e,t,n,i){if(!Number.isFinite(t)||t<=0||t>=Math.PI||!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=0)return{x:0,y:0,width:0,height:0};const r=Math.tan(t/2),s=r*(n/i),a=$o(-Math.tan(e.angleLeft)/s,-1,1),o=$o(Math.tan(e.angleRight)/s,-1,1),l=$o(-Math.tan(e.angleDown)/r,-1,1),c=(a+1)/2*n,u=(o+1)/2*n,h=(1-$o(Math.tan(e.angleUp)/r,-1,1))/2*i,d=(1-l)/2*i;return{x:c,y:h,width:Math.max(0,u-c),height:Math.max(0,d-h)}}(t[e],this[_s].fovy,l,s);a.fillRect(i,0,l,s),a.clearRect(i+r.x,r.y,r.width,r.height)})}isNativeXRAvailable(){var e;const t=null===(e=globalThis.navigator)||void 0===e?void 0:e.xr;return Boolean(t)&&!(t instanceof Xo)}installRuntime(e){var t,n,i,r;if("native"===this[_s].runtime.kind)throw new DOMException("Cannot install the emulated runtime while a native override is installed.","InvalidStateError");const s=null!==(t=null==e?void 0:e.globalObject)&&void 0!==t?t:globalThis,a=null==e?void 0:e.polyfillLayers;if(this.isNativeXRAvailable()&&!(null==e?void 0:e.forceInstall))return void console.warn("IWER: a native WebXR runtime is already available on navigator.xr; skipping installRuntime. Pass { forceInstall: true } to override.");const o=new Map,l=new Map;this[_s].installedGlobalObject=s,this[_s].previousGlobals=o,this[_s].previousMakeXRCompatible=l;const c=e=>{e&&(l.set(e,{existed:"makeXRCompatible"in e,descriptor:Object.getOwnPropertyDescriptor(e,"makeXRCompatible")}),Object.defineProperty(e,"makeXRCompatible",{value:function(){return new Promise((e,t)=>{e(!0)})},configurable:!0}))};c(WebGL2RenderingContext.prototype),c(null===(n=globalThis.WebGLRenderingContext)||void 0===n?void 0:n.prototype),this[_s].xrSystem=new Xo(this),this[_s].previousNavigatorXRDescriptor=null!==(i=Object.getOwnPropertyDescriptor(globalThis.navigator,"xr"))&&void 0!==i?i:null,this[_s].previousUserAgentDescriptor=null!==(r=Object.getOwnPropertyDescriptor(navigator,"userAgent"))&&void 0!==r?r:null,Object.defineProperty(globalThis.navigator,"xr",{value:this[_s].xrSystem,configurable:!0}),Object.defineProperty(navigator,"userAgent",{value:this[_s].userAgent,writable:!1,configurable:!0,enumerable:!0});const u=(e,t)=>{o.set(e,{existed:e in s,value:s[e]}),s[e]=t};u("XRSystem",Xo),u("XRSession",xo),u("XRRenderState",eo),u("XRFrame",mo),u("XRSpace",Xs),u("XRReferenceSpace",Qa),u("XRJointSpace",_o),u("XRView",no),u("XRViewport",qo),u("XRRigidTransform",Wa),u("XRPose",io),u("XRViewerPose",so),u("XRJointPose",ro),u("XRInputSource",wa),u("XRInputSourceArray",_a),u("XRHand",bo),u("XRLayer",Fo),u("XRWebGLLayer",Uo),u("XRSessionEvent",to),u("XRInputSourceEvent",Sa),u("XRInputSourcesChangeEvent",Ya),u("XRReferenceSpaceEvent",Vo),a?new Yl:u("XRMediaBinding",void 0),u("XRWebGLBinding",za)}uninstallRuntime(){var e,t,n;const i=this[_s].previousGlobals,r=this[_s].installedGlobalObject;i&&r&&i.forEach(({existed:e,value:t},n)=>{e?r[n]=t:delete r[n]});const s=this[_s].previousNavigatorXRDescriptor;s?Object.defineProperty(globalThis.navigator,"xr",s):(null===(e=Object.getOwnPropertyDescriptor(globalThis.navigator,"xr"))||void 0===e?void 0:e.configurable)&&delete globalThis.navigator.xr;const a=this[_s].previousUserAgentDescriptor;a&&(null===(t=Object.getOwnPropertyDescriptor(navigator,"userAgent"))||void 0===t?void 0:t.configurable)&&Object.defineProperty(navigator,"userAgent",a),null===(n=this[_s].previousMakeXRCompatible)||void 0===n||n.forEach(({existed:e,descriptor:t},n)=>{e&&t?Object.defineProperty(n,"makeXRCompatible",t):delete n.makeXRCompatible}),this[_s].xrSystem=null,this[_s].installedGlobalObject=null,this[_s].previousGlobals=null,this[_s].previousMakeXRCompatible=null,this[_s].previousNavigatorXRDescriptor=null,this[_s].previousUserAgentDescriptor=null}installDevUI(e){this[_s].devui=new e(this)}installSEM(e){this[_s].sem=new e(this)}get supportedSessionModes(){return this[_s].supportedSessionModes}get supportedFeatures(){return this[_s].supportedFeatures}get supportedFrameRates(){return this[_s].supportedFrameRates}get isSystemKeyboardSupported(){return this[_s].isSystemKeyboardSupported}get internalNominalFrameRate(){return this[_s].internalNominalFrameRate}get stereoEnabled(){return this[_s].stereoEnabled}set stereoEnabled(e){this[_s].stereoEnabled=e}get ipd(){return this[_s].ipd}set ipd(e){this[_s].ipd=e}get fovy(){return this[_s].fovy}set fovy(e){this[_s].fovy=e}get visibilityMask(){return this[_s].visibilityMask}get visibilityMaskEnabled(){return this[_s].visibilityMaskEnabled}set visibilityMaskEnabled(e){const t=Boolean(this[_s].visibilityMask)&&e;this[_s].visibilityMaskEnabled=t,this[_s].visibilityMaskCanvas&&(this[_s].visibilityMaskCanvas.style.display=t?"":"none")}get position(){return this[_s].position}get quaternion(){return this[_s].quaternion}get viewerSpace(){var e;return(null===(e=this[_s].actionPlayer)||void 0===e?void 0:e.playing)?this[_s].actionPlayer.viewerSpace:this[_s].viewerSpace}get viewSpaces(){var e;return(null===(e=this[_s].actionPlayer)||void 0===e?void 0:e.playing)?this[_s].actionPlayer.viewSpaces:this[_s].viewSpaces}get controllers(){return this[_s].controllers}get hands(){return this[_s].hands}get gaze(){return this[_s].gaze}get primaryInputMode(){return this[_s].primaryInputMode}set primaryInputMode(e){"controller"===e||"hand"===e?this[_s].primaryInputMode=e:console.warn('primary input mode can only be "controller" or "hand"')}get activeInputs(){if("visible"!==this[_s].visibilityState)return[];const e="controller"===this[_s].primaryInputMode?Object.values(this[_s].controllers):Object.values(this[_s].hands);return(this[_s].gaze?[...e,this[_s].gaze]:e).filter(e=>e.connected)}get inputSources(){var e;return(null===(e=this[_s].actionPlayer)||void 0===e?void 0:e.playing)?this[_s].actionPlayer.inputSources:this.activeInputs.map(e=>e.inputSource)}get canvasContainer(){return this[_s].canvasContainer}get canvasDimensions(){if(this[_s].canvasData){const{width:e,height:t}=this[_s].canvasData.canvas;return{width:e,height:t}}}get appCanvas(){var e;return null===(e=this[_s].canvasData)||void 0===e?void 0:e.canvas}get activeSession(){var e;return null===(e=this[_s].xrSystem)||void 0===e?void 0:e[Es].activeSession}get sessionOffered(){var e;return Boolean(null===(e=this[_s].xrSystem)||void 0===e?void 0:e[Es].offeredSessionConfig)}get name(){return this[_s].name}grantOfferedSession(){const e=this[_s].xrSystem,t=null==e?void 0:e[Es];if(t&&t.offeredSessionConfig){const{resolve:n,reject:i,mode:r,options:s}=t.offeredSessionConfig;t.offeredSessionConfig=void 0,e.requestSession(r,s).then(n).catch(i)}}recenter(){const e=new Ys(-this.position.x,0,-this.position.z),t=new Ys(0,0,-1).applyQuaternion(this.quaternion);t.y=0,t.normalize();const n=Math.atan2(t.x,-t.z),i=(new Ks).setFromAxisAngle(new Ys(0,1,0),n);this.position.add(e),this.quaternion.multiply(i),[...Object.values(this[_s].controllers),...Object.values(this[_s].hands)].forEach(t=>{t.position.add(e),t.quaternion.multiply(i),t.position.applyQuaternion(i)}),this[_s].pendingReferenceSpaceReset=!0}get visibilityState(){return this[_s].visibilityState}updateVisibilityState(e){if(!Object.values(["visible","visible-blurred","hidden"]).includes(e))throw new DOMException("Invalid XRVisibilityState value","NotSupportedError");e!==this[_s].visibilityState&&(this[_s].pendingVisibilityState=e)}createActionPlayer(e,t,n={}){var i,r;const s=new zo(e,t,this[_s].ipd,n);return this[_s].actionPlayer=s,null===(r=(i=this[_s].runtime).onActionPlayerCreated)||void 0===r||r.call(i,s),s}get devui(){return this[_s].devui}get sem(){return this[_s].sem}get remote(){return this[_s].remote}get controlMode(){return this[_s].controlMode}set controlMode(e){if("manual"!==e&&"programmatic"!==e)return void console.warn('control mode can only be "manual" or "programmatic"');this[_s].controlMode!==e&&(this[_s].controlMode=e,this[_s].controlModeListeners.forEach(t=>t(e)))}onControlModeChange(e){return this[_s].controlModeListeners.add(e),()=>{this[_s].controlModeListeners.delete(e)}}onStateChange(e){return this[_s].stateChangeListeners.add(e),()=>{this[_s].stateChangeListeners.delete(e)}}notifyStateChange(){this[_s].stateChangeListeners.forEach(e=>e())}}const ec={mapping:fa.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"x-button",type:"binary"},{id:"y-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},tc={mapping:fa.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"a-button",type:"binary"},{id:"b-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},nc={profileId:"oculus-touch-v2",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:ec,gripOffsetMatrix:[.9925461411476135,4.673031295254759e-9,-.12186938524246216,0,.08617470413446426,.7071065306663513,.7018362283706665,0,.0861746296286583,-.70710688829422,.7018358707427979,0,-.003979847766458988,-.01585787907242775,.04964185878634453,1],numHapticActuators:1},right:{gamepad:tc,gripOffsetMatrix:[.9925461411476135,3.688163374704345e-8,.12186937034130096,0,-.08617469668388367,.7071066498756409,.7018361687660217,0,-.0861746147274971,-.7071068286895752,.7018359899520874,0,.003979853354394436,-.01585787907242775,.04964182525873184,1],numHapticActuators:1}}},ic={profileId:"oculus-touch-v3",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:ec,gripOffsetMatrix:[.9925461411476135,2.0823669899527886e-8,-.12186937034130096,0,.08617465198040009,.7071067094802856,.701836109161377,0,.08617466688156128,-.7071067690849304,.7018360495567322,0,-.003979838453233242,-.015857907012104988,.04964181408286095,1],numHapticActuators:1},right:{gamepad:tc,gripOffsetMatrix:[.9925461411476135,-8.329467959811154e-8,.12186941504478455,0,-.08617465943098068,.7071066498756409,.7018361687660217,0,-.08617471158504486,-.7071068286895752,.7018359303474426,0,.003979798872023821,-.015857888385653496,.049641866236925125,1],numHapticActuators:1}}},rc={profileId:"meta-quest-touch-pro",fallbackProfileIds:["oculus-touch-v2","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:ec,gripOffsetMatrix:[.9925461411476135,-1.5779937356796836e-8,-.12186935544013977,0,.08617467433214188,.7071067094802856,.701836109161377,0,.0861746296286583,-.7071067690849304,.7018360495567322,0,-.003979836590588093,-.015857847407460213,.049641840159893036,1],numHapticActuators:3},right:{gamepad:tc,gripOffsetMatrix:[.9925461411476135,9267653311439972e-26,.12186937034130096,0,-.08617467433214188,.7071067094802856,.7018361687660217,0,-.08617464452981949,-.7071067690849304,.7018360495567322,0,.003979847766458988,-.01585782691836357,.04964186251163483,1],numHapticActuators:3}}},sc={profileId:"meta-quest-touch-plus",fallbackProfileIds:["oculus-touch-v3","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:ec,gripOffsetMatrix:[.9925461411476135,1.0736208366779465e-8,-.12186933308839798,0,.08617459982633591,.70710688829422,.7018360495567322,0,.08617466688156128,-.7071067094802856,.7018362283706665,0,-.003979803062975407,-.015857873484492302,.04964187368750572,1],numHapticActuators:1},right:{gamepad:tc,gripOffsetMatrix:[.9925461411476135,-2.6238110351073374e-8,.12186934053897858,0,-.0861746147274971,.7071067690849304,.7018360495567322,0,-.08617465943098068,-.7071067094802856,.701836109161377,0,.003979838453233242,-.015857869759202003,.04964182525873184,1],numHapticActuators:1}}},ac=e=>e*Math.PI/180,oc={left:{angleLeft:ac(37),angleRight:ac(37),angleUp:ac(25),angleDown:ac(43)},right:{angleLeft:ac(37),angleRight:ac(37),angleUp:ac(25),angleDown:ac(43)}},lc={name:"Oculus Quest 1",controllerConfig:nc,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","hand-tracking"],supportedFrameRates:[72,80,90],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":go.Opaque,"immersive-ar":go.AlphaBlend},interactionMode:vo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 1) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},cc={name:"Meta Quest 2",controllerConfig:ic,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":go.Opaque,"immersive-ar":go.AlphaBlend},interactionMode:vo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 2) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},uc={name:"Meta Quest Pro",controllerConfig:rc,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking","gaze-tracking","eye-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":go.Opaque,"immersive-ar":go.AlphaBlend},interactionMode:vo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest Pro) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},hc={name:"Meta Quest 3",controllerConfig:sc,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking","depth-sensing"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":go.Opaque,"immersive-ar":go.AlphaBlend},interactionMode:vo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 3) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},dc={...hc,name:"Meta VR Glasses",supportedFrameRates:[72,90,96,100,120],visibilityMask:oc};class pc{constructor(){this.entries=[]}get size(){return this.entries.length}define(e,t,n){const i=Object.getOwnPropertyDescriptor(e,t);try{return Object.defineProperty(e,t,n),this.entries.push({target:e,key:t,descriptor:i}),!0}catch(e){return!1}}revert(){for(let e=this.entries.length-1;e>=0;e--){const{target:t,key:n,descriptor:i}=this.entries[e];try{i?Object.defineProperty(t,n,i):Reflect.deleteProperty(t,n)}catch(e){}}this.entries=[]}}const fc=Symbol.for("@iwer/native-override"),mc=["select","selectstart","selectend","squeeze","squeezestart","squeezeend"],gc="hand-tracking",vc=Math.PI/180,yc=Ur(),xc=Ur(),bc=Ur(),_c=Ur(),wc=Ur(),Sc=Ur(),Mc=Ur(),Tc=Ur(),Ec=Zr(),Ac=ls(),Rc=new Float32Array(1);function Cc(e,t){const n=function(e,t){let n=e;for(;n;){if(Object.prototype.hasOwnProperty.call(n,t))return n;n=Object.getPrototypeOf(n)}return null}(e,t),i=n?Object.getOwnPropertyDescriptor(n,t):void 0;return n&&i?{owner:n,descriptor:i}:null}function Pc(e){const t=Ur();for(let n=0;n<16;n++)t[n]=e.matrix[n];return t}function Ic(e,t,n){for(let i=0;i<16;i++)t[n+i]=e[i]}const Lc=Zr(),Dc=Zr(),Nc=ls(),Oc=ls();function Fc(e,t){if(qr(Lc,e),qr(Dc,t),function(e,t){var n=t[0]-e[0],i=t[1]-e[1],r=t[2]-e[2];return n*n+i*i+r*r}(Lc,Dc)>25e-6)return!1;Yr(Nc,e),Yr(Oc,t);const n=Math.abs(gs(Nc,Oc));return Math.min(n,1)>=Math.cos(vc/2)}function kc(e){return Number.isFinite(e)&&e>0}function Uc(e){return new DOMException(e,"InvalidStateError")}function zc(e){return new DOMException(e,"NotSupportedError")}function Bc(e){var t,n,i;const r=null!==(t=e.globalObject)&&void 0!==t?t:globalThis;return null!==(n=e.xrSystem)&&void 0!==n?n:null===(i=r.navigator)||void 0===i?void 0:i.xr}function Vc(e={}){var t;const n=null!==(t=e.globalObject)&&void 0!==t?t:globalThis,i=Bc(e),r=[],s=Boolean(i&&"function"==typeof i.requestSession&&function(e,t){const n=Object.getOwnPropertyDescriptor(e,t);if(n)return n.configurable||!0===n.writable;if(Object.isExtensible(e))return!0;const i=Cc(Object.getPrototypeOf(e),t);return Boolean(i&&(i.descriptor.configurable||!0===i.descriptor.writable))}(i,"requestSession"));return i?s||r.push("The native XRSystem.requestSession method cannot be patched."):r.push("navigator.xr is unavailable."),"function"!=typeof n.XRRigidTransform&&r.push("The native XRRigidTransform constructor is unavailable."),{supported:s&&"function"==typeof n.XRRigidTransform,requestSession:s,notes:r}}class Gc{constructor(e,t={}){var n,i,r;this.patches=new pc,this.sessionsByObject=new WeakMap,this.liveSessions=new Set,this.frameSessions=new WeakMap,this.spaces=new WeakMap,this.hitTestBindings=new WeakMap,this.syntheticEvents=new WeakSet,this.patchedFrameOwners=new WeakSet,this.patchedViewerFrameOwners=new WeakSet,this.patchedFillPosesOwners=new WeakSet,this.patchedJointPoseOwners=new WeakSet,this.patchedJointRadiiOwners=new WeakSet,this.patchedReferenceSpaceOwners=new WeakSet,this.patchedEnabledFeaturesOwners=new WeakSet,this.patchedInputSourceOwners=new WeakSet,this.patchedRafOwners=new WeakSet,this.patchedRequestReferenceSpaceOwners=new WeakSet,this.patchedHitTestOwners=new WeakSet,this.patchedHitTestResultOwners=new WeakSet,this.patchedCreateAnchorOwners=new WeakSet,this.instancePatchedReferenceSpaces=new WeakSet,this.rawGetPoseByOwner=new WeakMap,this.rawGetPoseByFrame=new WeakMap,this.rawRafByOwner=new WeakMap,this.rawRequestReferenceSpaceByOwner=new WeakMap,this.rawInputSourcesGetterByOwner=new WeakMap,this.rawTransformGetters=new WeakMap,this.transformReaders=new WeakMap,this.transformOverrides=new WeakMap,this.patchedTransformOwners=new WeakSet,this.instancePatchedFrameEpochs=new WeakMap,this.instancePatchedTransformEpochs=new WeakMap,this.warned=new Set,this.unhealthyFrameAdapters=new Set,this.installedState=!1,this.primarySession=null,this.previousRuntime=null,this.epoch=0,this.wiredPlayer=null,this.playbackFrame=null,this.detachedPlaybackFrame={},this.device=e,this.mode=null!==(n=t.mode)&&void 0!==n?n:"full",this.options={...t,mode:this.mode,onUnsupported:null!==(i=t.onUnsupported)&&void 0!==i?i:"warn"},this.globalObject=null!==(r=t.globalObject)&&void 0!==r?r:globalThis,this.xrSystem=Bc(t);const s=Vc({xrSystem:this.xrSystem,globalObject:this.globalObject});this.capabilityState={phase:"uninstalled",supported:s.supported,requestSession:!1,offerSession:!1,inputSources:!1,inputEvents:!1,brandedInputEvents:!1,enabledFeatures:!1,viewerSpaceTagging:!1,poseOverride:!1,batchPoses:!1,viewerPose:!1,viewTransforms:!1,handInput:!1,jointPoses:!1,actionPlayback:!1,anchors:!1,hitTest:!1,notes:[...s.notes]}}get installed(){return this.installedState}get capabilities(){return{...this.capabilityState,notes:[...this.capabilityState.notes]}}get sessions(){return Array.from(this.liveSessions,e=>({session:e.session,mode:e.mode,primary:e===this.primarySession,anchorSpace:e.anchorSpace}))}install(){if(this.installedState)return;const e=Bc(this.options);this.xrSystem=e;const t=Vc({xrSystem:e,globalObject:this.globalObject});if(Object.assign(this.capabilityState,{phase:"uninstalled",supported:t.supported,requestSession:!1,offerSession:!1,inputSources:!1,inputEvents:!1,brandedInputEvents:!1,enabledFeatures:!1,viewerSpaceTagging:!1,poseOverride:!1,batchPoses:!1,viewerPose:!1,viewTransforms:!1,handInput:!1,jointPoses:!1,actionPlayback:!1,anchors:!1,hitTest:!1,notes:[]}),this.warned.clear(),!e||!t.supported){const e=t.notes.length>0?t.notes:["Native WebXR override prerequisites are unavailable."];this.capabilityState.supported=!1;for(const t of e)this.note(t);if("throw"===this.options.onUnsupported)throw new Error(e.join(" "));return}if(this.device[_s].installedGlobalObject)throw Uc("Cannot install a native override while the emulated IWER runtime is installed.");const n=function(e){try{const t=Reflect.get(e,fc),n=Reflect.get(e,"requestSession"),i=null!=t?t:"function"==typeof n?Reflect.get(n,fc):null;if(null!==i&&"object"==typeof i&&"boolean"==typeof i.installed&&"function"==typeof i.uninstall)return i}catch(e){}return null}(e);if(n&&n!==this)throw Uc("A native IWER override is already installed on this XRSystem.");const i=this,r=t=>{const n=async function(n,r){if(this!==e||!function(e){return"immersive-vr"===e||"immersive-ar"===e}(n))return t.call(this,n,r);const s=i.prepareSessionRequest(r),a=await t.call(this,n,s.options);if("gaze-only"===i.options.mode&&0===s.gaze.enabled.length)return a;try{await i.attachSession(a,n,s.gaze.enabled)}catch(e){i.detachSession(a);if(s.gaze.required.length>0||0===s.gaze.enabled.length&&"throw"===i.options.onUnsupported){if(await a.end().catch(()=>{}),s.gaze.required.length>0&&(!(e instanceof DOMException)||"NotSupportedError"!==e.name))throw zc(i.errorText(e));throw e}i.note(`Native session override was skipped: ${i.errorText(e)}`,"session-attach-failed")}return a};return Object.defineProperty(n,fc,{value:this}),n},s=(t,n)=>{let i=this.patches.define(e,t,{configurable:!0,writable:!0,value:n});if(!i){const r=Cc(e,t);if(r&&"function"==typeof r.descriptor.value){const e=r.descriptor;i=this.patches.define(r.owner,t,{...e,value:n})}}return i};if(!s("requestSession",r(e.requestSession)))return void this.unsupported("Unable to patch native XRSystem.requestSession.");const a=Reflect.get(e,"offerSession");"function"==typeof a&&(s("offerSession",r(a))?this.capabilityState.offerSession=!0:this.note("The native XRSystem.offerSession method could not be patched; sessions created through it are not overridden.")),this.patches.define(e,fc,{configurable:!0,value:this}),this.previousRuntime=this.device[_s].runtime,this.device[_s].runtime={kind:"native",getSession:()=>{const e=this.primarySession;return!e||e.ended?null:{mode:e.mode,enabledFeatures:e.enabledFeatures,visibilityState:e.session.visibilityState,originOffsetMatrix:null,end:()=>e.session.end()}},onActionPlayerCreated:"full"===this.options.mode?e=>this.wirePlayer(e):void 0},this.installedState=!0,this.capabilityState.phase="installed",this.capabilityState.requestSession=!0}uninstall(){if(this.installedState){this.installedState=!1;for(const e of Array.from(this.liveSessions))this.detachAdapter(e,!0);this.unwirePlayer(),this.patches.revert(),this.previousRuntime&&(this.device[_s].runtime=this.previousRuntime,this.previousRuntime=null),this.resetPatchTracking(),this.playbackFrame=null,this.warned.clear(),Object.assign(this.capabilityState,{phase:"uninstalled",requestSession:!1,offerSession:!1,inputSources:!1,inputEvents:!1,brandedInputEvents:!1,enabledFeatures:!1,viewerSpaceTagging:!1,poseOverride:!1,batchPoses:!1,viewerPose:!1,viewTransforms:!1,handInput:!1,jointPoses:!1,actionPlayback:!1,anchors:!1,hitTest:!1,notes:[]})}}prepareSessionRequest(e){var t,n;const i=Array.from(null!==(t=null==e?void 0:e.requiredFeatures)&&void 0!==t?t:[]),r=Array.from(null!==(n=null==e?void 0:e.optionalFeatures)&&void 0!==n?n:[]),s=i.filter(Ho),a=r.filter(Ho),o=Wo(this.device.supportedFeatures);if(a.length>0&&!o&&this.note("Optional gaze tracking was not enabled because the selected IWER device profile does not advertise gaze support.","unsupported-optional-gaze"),s.length>0&&!o)throw zc(`Required gaze tracking is unavailable because the selected IWER device profile "${this.device.name}" does not advertise gaze support. Select a gaze-capable profile such as metaQuestPro.`);const l=o?Array.from(new Set([...s,...a])):[];if(!e)return{options:void 0,gaze:{required:s,optional:a,enabled:l}};const c={...e};return e.requiredFeatures&&(c.requiredFeatures=i.filter(e=>!Ho(e))),e.optionalFeatures&&(c.optionalFeatures=r.filter(e=>!Ho(e))),{options:c,gaze:{required:s,optional:a,enabled:l}}}failWhenGazeRequested(e){if(e.length>0)throw zc("Native override was uninstalled before the session could attach.")}async attachSession(e,t,n=[]){var i,r,s,a,o,l;if(!this.installedState)return void this.failWhenGazeRequested(n);if(this.sessionsByObject.has(e))return;const c=this.captureNativeRequestReferenceSpace(e),u=this.captureNativeRequestAnimationFrame(e),h="gaze-only"===this.options.mode?this.captureNativeInputSources(e):{read:()=>[],live:!1};let d,p;for(const t of["local-floor","local","unbounded"])try{d=await c.call(e,t),p=t;break}catch(e){}if(!d||!p)throw new Error("No native local-floor, local, or unbounded reference space is available.");if("local-floor"!==p&&this.note(`Native local-floor is unavailable; poses are anchored to "${p}" and are offset by the viewer's initial height.`),!this.installedState)return void this.failWhenGazeRequested(n);const f=h.read(),m={session:e,mode:t,anchorSpace:d,handTracking:this.sessionEnablesHandTracking(e),enabledFeatures:Object.freeze(Array.from(new Set([...Array.from(null!==(i=e.enabledFeatures)&&void 0!==i?i:[]),...n]))),syntheticGazeFeatures:Object.freeze([...n]),nativeRequestAnimationFrame:u,nativeRequestReferenceSpace:c,nativeInputSources:h.read,nativeInputSourcesLive:h.live,nativeSources:Object.freeze([...f]),patches:new pc,instancePatches:new pc,cleanupListeners:[],sources:Object.freeze("gaze-only"===this.options.mode?Array.from(f):[]),deviceBindings:[],playbackBindings:new Map,bindingByFacade:new Map,spaceTokens:new Set([d]),hitTests:new Set,baseSpaceCache:new Map,lastFrameTime:void 0,lastPreparedFrame:null,nativeViewerPoseValid:"full"===this.options.mode,nativeViewerMatrix:Ur(),framePreparationFailures:0,activeFrame:null,framesInstrumented:!1,pendingEvents:[],retainedSources:new Set,createAnchorAvailable:!0,hitTestResultsAvailable:!0,ended:!1};this.sessionsByObject.set(e,m),this.liveSessions.add(m),null!==(r=this.primarySession)&&void 0!==r||(this.primarySession=m),this.spaces.set(d,{adapter:m,localOffset:Ur()});const g=this.capabilityState.handInput;try{"full"===this.options.mode&&this.ensureReferenceSpacePatch(d,m),this.createDeviceBindings(m);const e=this.patchEnabledFeatures(m),t=this.patchInputSources(m),i=this.patchRequestAnimationFrame(m);m.framesInstrumented=i;const r="full"===this.options.mode&&this.patchRequestReferenceSpace(m);if("full"===this.options.mode&&this.patchRequestHitTestSource(m),this.installSessionListeners(m),!t){if(n.length>0)throw zc("Unable to expose the synthetic gaze input source.");this.unsupportedForSession(m,"Unable to override XRSession.inputSources.")}if(!i){if(n.length>0)throw zc("Unable to update the synthetic gaze input on native frames.");this.unsupportedForSession(m,"Unable to wrap XRSession.requestAnimationFrame.")}if("full"!==this.options.mode||r||this.note("XRReferenceSpace tagging is unavailable; viewer-relative offset spaces will use native behavior."),!e&&n.length>0)throw zc("Unable to expose the synthetic gaze feature through XRSession.enabledFeatures.");(s=this.capabilityState).inputSources||(s.inputSources=t),(a=this.capabilityState).inputEvents||(a.inputEvents=t&&i),(o=this.capabilityState).enabledFeatures||(o.enabledFeatures=e),(l=this.capabilityState).viewerSpaceTagging||(l.viewerSpaceTagging=r),"installed"===this.capabilityState.phase&&(this.capabilityState.phase="attached")}catch(e){throw this.capabilityState.handInput=g,this.detachAdapter(m),e}}sessionEnablesHandTracking(e){const t=e.enabledFeatures;return t?Array.prototype.includes.call(t,gc):this.device.supportedFeatures.includes(gc)}createDeviceBindings(e){if("full"===this.options.mode){for(const t of Object.values(this.device.controllers))e.deviceBindings.push(this.createInputBinding(e,"controller",t.inputSource,{trackedInput:t,exposeHand:!1}));if(e.handTracking)for(const t of Object.values(this.device.hands))e.deviceBindings.push(this.createInputBinding(e,"hand",t.inputSource,{trackedInput:t,exposeHand:!0}))}if(e.syntheticGazeFeatures.length>0){const t=this.device.gaze;if(!t)throw new Error("The selected device does not provide a synthetic gaze input.");e.deviceBindings.push(this.createInputBinding(e,"gaze",t.inputSource,{trackedInput:t,exposeHand:!1,available:"gaze-only"===this.options.mode?()=>e.nativeViewerPoseValid:void 0}))}}createInputBinding(e,t,n,i){const r=this.createSpaceToken(e);let s;this.spaces.set(r,{adapter:e,origin:()=>n.targetRaySpace,available:i.available,localOffset:Ur()}),n.gripSpace&&(s=this.createSpaceToken(e),this.spaces.set(s,{adapter:e,origin:()=>{var e;return null!==(e=n.gripSpace)&&void 0!==e?e:null},available:i.available,localOffset:Ur()}));const a=[];if(i.exposeHand&&n.hand)for(const t of Object.values(yo)){const r=n.hand.get(t);if(!r)continue;const s={name:t,space:this.createJointSpaceFacade(t),source:r};this.spaces.set(s.space,{adapter:e,origin:()=>s.source,available:i.available,localOffset:Ur(),joint:s}),a.push(s)}const o={kind:t,iwerSource:n,trackedInput:i.trackedInput,inputSource:void 0,targetRaySpace:r,gripSpace:s,joints:a,eventButtons:this.eventButtons(n),previousButtonValues:new Map,activeButtons:new Set,activeActions:new Set,pendingActions:new Set};return o.inputSource=this.createInputSourceFacade(o,e),this.resetButtonBaseline(o),e.bindingByFacade.set(o.inputSource,o),a.length>0&&(this.capabilityState.handInput=!0),o}playbackBinding(e,t){const n=e.playbackBindings.get(t);if(n)return n;const i=Boolean(t.hand)&&e.handTracking;t.hand&&!e.handTracking&&this.note(`Recorded hand joints are hidden because the native session does not enable the "${gc}" feature.`);const r=this.createInputBinding(e,"playback",t,{exposeHand:i});return e.playbackBindings.set(t,r),r}createSpaceToken(e){const t=new(this.getRigidTransformConstructor()),n=e.anchorSpace.getOffsetReferenceSpace(t);if(e.spaceTokens.has(n))throw new Error("Native getOffsetReferenceSpace(identity) reused a space object; stable synthetic input tokens require distinct objects.");return e.spaceTokens.add(n),n}createInputSourceFacade(e,t){var n;const i=this.constructorPrototype("XRInputSource"),r=Object.create(null!=i?i:Object.prototype),s=e.iwerSource,a=e.joints.length>0||!s.gamepad?null:this.createGamepadFacade(e,t);return Object.defineProperties(r,{handedness:{configurable:!0,enumerable:!0,value:s.handedness},targetRayMode:{configurable:!0,enumerable:!0,value:s.targetRayMode},profiles:{configurable:!0,enumerable:!0,value:Object.freeze([...s.profiles])},targetRaySpace:{configurable:!0,enumerable:!0,value:e.targetRaySpace},gripSpace:{configurable:!0,enumerable:!0,value:null!==(n=e.gripSpace)&&void 0!==n?n:null},gamepad:{configurable:!0,enumerable:!0,value:a},hand:{configurable:!0,enumerable:!0,value:e.joints.length>0?this.createHandFacade(e.joints):null}}),r}createHandFacade(e){const t=this.constructorPrototype("XRHand"),n=Object.create(null!=t?t:Object.prototype),i=new Map(e.map(e=>[e.name,e.space])),r=(e,t)=>{Object.defineProperty(n,e,{configurable:!0,writable:!0,value:t})};return Object.defineProperty(n,"size",{configurable:!0,enumerable:!0,get:()=>i.size}),r("get",e=>i.get(e)),r("has",e=>i.has(e)),r("keys",()=>i.keys()),r("values",()=>i.values()),r("entries",()=>i.entries()),r("forEach",function(e,t){i.forEach((i,r)=>{e.call(t,i,r,n)})}),r(Symbol.iterator,()=>i.entries()),n}createJointSpaceFacade(e){var t;const n=null!==(t=this.constructorPrototype("XRJointSpace"))&&void 0!==t?t:this.constructorPrototype("XRSpace"),i=Object.create(null!=n?n:Object.prototype);return Object.defineProperty(i,"jointName",{configurable:!0,enumerable:!0,value:e}),i}createGamepadFacade(e,t){const n=this.constructorPrototype("Gamepad"),i=Object.create(null!=n?n:Object.prototype),r=e.iwerSource.gamepad;let s=Object.freeze(r.axes.map(e=>null!=e?e:0));const a=Object.freeze(r.buttons.map(e=>Object.freeze({get pressed(){var t;return null!==(t=null==e?void 0:e.pressed)&&void 0!==t&&t},get touched(){var t;return null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t},get value(){var t;return null!==(t=null==e?void 0:e.value)&&void 0!==t?t:0}}))),o=Object.freeze([...r.hapticActuators]);return Object.defineProperties(i,{id:{configurable:!0,enumerable:!0,value:""},index:{configurable:!0,enumerable:!0,value:-1},connected:{configurable:!0,enumerable:!0,get:()=>{var n,i;return(null===(i=null===(n=e.trackedInput)||void 0===n?void 0:n.connected)||void 0===i||i)&&!t.ended}},timestamp:{configurable:!0,enumerable:!0,get:()=>{var e;return null!==(e=t.lastFrameTime)&&void 0!==e?e:0}},mapping:{configurable:!0,enumerable:!0,get:()=>r.mapping},axes:{configurable:!0,enumerable:!0,get:()=>{const e=r.axes.map(e=>null!=e?e:0);return(e.length!==s.length||e.some((e,t)=>e!==s[t]))&&(s=Object.freeze(e)),s}},buttons:{configurable:!0,enumerable:!0,get:()=>a},hapticActuators:{configurable:!0,enumerable:!0,get:()=>o},vibrationActuator:{configurable:!0,enumerable:!0,get:()=>r.vibrationActuator}}),i}eventButtons(e){const t=e.gamepad;return t?Object.values(t[Ts].buttonsMap).filter(e=>null!==e):[]}resetButtonBaseline(e){for(const t of e.eventButtons)e.previousButtonValues.set(t,t.value)}clearActionState(e){e.activeButtons.clear(),e.activeActions.clear(),e.pendingActions.clear()}captureNativeRequestAnimationFrame(e){const t=Cc(e,"requestAnimationFrame");if(!t||"function"!=typeof t.descriptor.value)throw new Error("Native XRSession.requestAnimationFrame is unavailable.");const n=this.rawRafByOwner.get(t.owner);if(n)return n;const i=t.descriptor.value;return this.rawRafByOwner.set(t.owner,i),i}captureNativeRequestReferenceSpace(e){const t=Cc(e,"requestReferenceSpace");if(!t||"function"!=typeof t.descriptor.value)throw new Error("Native XRSession.requestReferenceSpace is unavailable.");const n=this.rawRequestReferenceSpaceByOwner.get(t.owner);if(n)return n;const i=t.descriptor.value;return this.rawRequestReferenceSpaceByOwner.set(t.owner,i),i}captureNativeInputSources(e){const t=Cc(e,"inputSources");if(!t)throw new Error("Native XRSession.inputSources is unavailable.");let n=this.rawInputSourcesGetterByOwner.get(t.owner);if(!n&&t.descriptor.get&&(n=t.descriptor.get,this.rawInputSourcesGetterByOwner.set(t.owner,n)),n)return{read:()=>{var t;return Array.from(null!==(t=n.call(e))&&void 0!==t?t:[])},live:!0};if("value"in t.descriptor){const n=t.descriptor.value;return{read:()=>{const t=Object.getOwnPropertyDescriptor(e,"inputSources"),i=t&&"value"in t?t.value:n;return Array.from(null!=i?i:[])},live:!1}}throw new Error("Native XRSession.inputSources cannot be read.")}patchEnabledFeatures(e){var t,n;if(0===e.syntheticGazeFeatures.length)return!1;if(e.patches.define(e.session,"enabledFeatures",{configurable:!0,enumerable:!0,value:e.enabledFeatures})){const n=Array.from(null!==(t=e.session.enabledFeatures)&&void 0!==t?t:[]);return e.syntheticGazeFeatures.every(e=>n.includes(e))}const i=Cc(e.session,"enabledFeatures"),r=null==i?void 0:i.descriptor.get;if(!i||!r)return!1;if(!this.patchedEnabledFeaturesOwners.has(i.owner)){const e=this,t=this.patches.define(i.owner,"enabledFeatures",{...i.descriptor,get(){var t,n;return null!==(n=null===(t=e.sessionsByObject.get(this))||void 0===t?void 0:t.enabledFeatures)&&void 0!==n?n:r.call(this)}});if(!t)return!1;this.patchedEnabledFeaturesOwners.add(i.owner)}const s=Array.from(null!==(n=e.session.enabledFeatures)&&void 0!==n?n:[]);return e.syntheticGazeFeatures.every(e=>s.includes(e))}patchInputSources(e){if(e.patches.define(e.session,"inputSources",{configurable:!0,enumerable:!0,get:()=>e.sources}))return e.session.inputSources===e.sources;const t=Cc(e.session,"inputSources"),n=null==t?void 0:t.descriptor.get;if(!t||!n)return!1;if(!this.patchedInputSourceOwners.has(t.owner)){const e=this,i=this.patches.define(t.owner,"inputSources",{...t.descriptor,get(){var t,i;return null!==(i=null===(t=e.sessionsByObject.get(this))||void 0===t?void 0:t.sources)&&void 0!==i?i:n.call(this)}});if(!i)return!1;this.patchedInputSourceOwners.add(t.owner)}return e.session.inputSources===e.sources}patchRequestAnimationFrame(e){const t=this;if(e.patches.define(e.session,"requestAnimationFrame",{configurable:!0,writable:!0,value:function(n){return e.nativeRequestAnimationFrame.call(this,(i,r)=>{t.prepareFrameCallback(e,i,r);try{n(i,r)}finally{t.releaseFrameCallback(e,r)}})}}))return!0;const n=Cc(e.session,"requestAnimationFrame"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return!1;if(!this.patchedRafOwners.has(n.owner)){if(!this.patches.define(n.owner,"requestAnimationFrame",{...n.descriptor,value(e){const n=t.sessionsByObject.get(this);return n?n.nativeRequestAnimationFrame.call(this,(i,r)=>{t.prepareFrameCallback(n,i,r);try{e(i,r)}finally{t.releaseFrameCallback(n,r)}}):i.call(this,e)}}))return!1;this.patchedRafOwners.add(n.owner)}return!0}patchRequestReferenceSpace(e){const t=this;if(e.patches.define(e.session,"requestReferenceSpace",{configurable:!0,writable:!0,value:function(n){return e.nativeRequestReferenceSpace.call(this,n).then(i=>(t.tagRequestedReferenceSpace(e,i,n),t.ensureReferenceSpacePatch(i,e),i))}}))return!0;const n=Cc(e.session,"requestReferenceSpace"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return!1;if(!this.patchedRequestReferenceSpaceOwners.has(n.owner)){const e=this.patches.define(n.owner,"requestReferenceSpace",{...n.descriptor,value(e){const n=t.sessionsByObject.get(this);return n?n.nativeRequestReferenceSpace.call(this,e).then(i=>(t.tagRequestedReferenceSpace(n,i,e),t.ensureReferenceSpacePatch(i,n),i)):i.call(this,e)}});if(!e)return!1;this.patchedRequestReferenceSpaceOwners.add(n.owner)}return!0}patchRequestHitTestSource(e){const t=e.session.requestHitTestSource;if("function"!=typeof t)return;const n=this;if(e.patches.define(e.session,"requestHitTestSource",{configurable:!0,writable:!0,value:function(e){return n.handleRequestHitTestSource(this,t,e)}}))return;const i=Cc(e.session,"requestHitTestSource");if(!i||"function"!=typeof i.descriptor.value||this.patchedHitTestOwners.has(i.owner))return;const r=i.descriptor.value;this.patches.define(i.owner,"requestHitTestSource",{...i.descriptor,value(e){return n.handleRequestHitTestSource(this,r,e)}})&&this.patchedHitTestOwners.add(i.owner)}tagRequestedReferenceSpace(e,t,n){this.spaces.has(t)||"viewer"===n&&this.spaces.set(t,{adapter:e,origin:()=>this.currentViewerSpace(),localOffset:Ur()})}ensureReferenceSpacePatch(e,t){if(this.instancePatchedReferenceSpaces.has(e))return;const n=Cc(e,"getOffsetReferenceSpace"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return;const r=this,s=function(e){const t=r.spaces.get(this);if(!t||t.adapter.ended)return i.call(this,e);const n=i.call(this,e);return r.propagateSpaceMetadata(this,n,e),r.ensureReferenceSpacePatch(n,t.adapter),n};if(n.owner===e||this.patchedReferenceSpaceOwners.has(n.owner)){if(n.owner!==e)return}else{if(this.patches.define(n.owner,"getOffsetReferenceSpace",{...n.descriptor,value:s}))return void this.patchedReferenceSpaceOwners.add(n.owner)}t.patches.define(e,"getOffsetReferenceSpace",{configurable:!0,writable:!0,value:s})&&this.instancePatchedReferenceSpaces.add(e)}propagateSpaceMetadata(e,t,n){const i=this.spaces.get(e);if(!i)return;const r=Ur();Hr(r,i.localOffset,Pc(n)),this.spaces.set(t,{adapter:i.adapter,origin:i.origin,available:i.available,localOffset:r})}installSessionListeners(e){const{session:t}=e;if("full"===this.options.mode){const n=e=>{this.syntheticEvents.has(e)||e.stopImmediatePropagation()};for(const i of["inputsourceschange",...mc])t.addEventListener(i,n,!0),e.cleanupListeners.push(()=>t.removeEventListener(i,n,!0))}else{const n=t=>{if(!this.syntheticEvents.has(t)){try{if(!e.nativeInputSourcesLive){const n=t;if(null==n.added||null==n.removed)e.nativeSources=Object.freeze([...e.nativeInputSources()]);else{const t=new Set(Array.from(n.removed)),i=e.nativeSources.filter(e=>!t.has(e));for(const e of Array.from(n.added))i.includes(e)||i.push(e);e.nativeSources=Object.freeze(i)}}}catch(t){try{e.nativeSources=Object.freeze([...e.nativeInputSources()])}catch(e){this.note(`A native input-source change could not be reconciled; preserving the last known set: ${this.errorText(null!=e?e:t)}`,"gaze-only-native-input-change-failed")}}this.refreshInputSources(e,!0)}};t.addEventListener("inputsourceschange",n,!0),e.cleanupListeners.push(()=>t.removeEventListener("inputsourceschange",n,!0))}const n=()=>{var n;const i=this.sharedStateDriver();this.device[_s].visibilityState=null!==(n=null==i?void 0:i.session.visibilityState)&&void 0!==n?n:t.visibilityState,this.device[_s].pendingVisibilityState=null,void 0!==e.lastFrameTime&&this.refreshInputSources(e,!0)};t.addEventListener("visibilitychange",n),e.cleanupListeners.push(()=>t.removeEventListener("visibilitychange",n));const i=()=>this.detachAdapter(e);t.addEventListener("end",i,{once:!0}),e.cleanupListeners.push(()=>t.removeEventListener("end",i))}tick(e,t,n){e.ended||e.lastFrameTime===t&&e.lastPreparedFrame===n||(e.lastFrameTime=t,e.lastPreparedFrame=n,e.baseSpaceCache.clear(),"gaze-only"===this.options.mode&&this.syncDeviceViewerFromNative(e,n),e===this.sharedStateDriver()&&this.advanceSharedState(e,t),this.refreshInputSources(e,!0),this.drainPendingEvents(e,n),this.refreshInputSources(e,!0),this.dispatchButtonTransitions(e,n),this.updateHitTestSources(e))}syncDeviceViewerFromNative(e,t){e.nativeViewerPoseValid=!1;const n=Cc(t,"getViewerPose"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return void this.note("The native XRFrame.getViewerPose implementation is unavailable; synthetic gaze is untracked for this frame.","gaze-only-viewer-pose-unavailable");let r;try{r=i.call(t,e.anchorSpace)}catch(e){return}if(!r)return;const s=this.readNativeTransform(r);if(!s)return;const a=Pc(s);Br(e.nativeViewerMatrix,a),this.applyDeviceViewerMatrix(a),e.nativeViewerPoseValid=!0}applyDeviceViewerMatrix(e){qr(Ec,e),Yr(Ac,e),this.device.position.set(Ec[0],Ec[1],Ec[2]),this.device.quaternion.set(Ac[0],Ac[1],Ac[2],Ac[3]),this.device[_s].updateViews()}sharedStateDriver(){var e,t;return"visible"===(null===(e=this.primarySession)||void 0===e?void 0:e.session.visibilityState)?this.primarySession:null!==(t=Array.from(this.liveSessions).find(e=>"visible"===e.session.visibilityState))&&void 0!==t?t:this.primarySession}advanceSharedState(e,t){var n;const i=this.lastPrimaryTime;this.lastPrimaryTime=t;const r=void 0===i?16.67:Math.max(0,t-i);if("gaze-only"===this.options.mode)return this.device[_s].remote.update(r),e.nativeViewerPoseValid&&this.applyDeviceViewerMatrix(e.nativeViewerMatrix),this.device[_s].visibilityState=e.session.visibilityState,this.device[_s].pendingVisibilityState=null,void(null===(n=this.device.gaze)||void 0===n||n.updateTargetRaySpace());this.device[_s].remote.update(r),this.device[_s].visibilityState=e.session.visibilityState,this.device[_s].pendingVisibilityState=null;const s=this.device[_s].actionPlayer;s&&(s.playing||s[ys].manualFrameActive)?(this.wirePlayer(s),this.playbackFrame=s,this.capabilityState.actionPlayback=!0,s.playing&&s[ys].autoAdvance&&s.playFrame()):(this.playbackFrame=null,this.wiredPlayer&&this.wiredPlayer!==s&&this.unwirePlayer(),this.updateDeviceInputs()),this.device[_s].updateViews()}updateDeviceInputs(){var e,t,n,i,r;for(const s of this.device.activeInputs){s.updateTargetRaySpace();for(const i of null!==(t=null===(e=s.inputSource.gamepad)||void 0===e?void 0:e.buttons)&&void 0!==t?t:[])i instanceof va&&(i[Ts].lastFrameValue=null!==(n=i[Ts].immediateTransitionFrom)&&void 0!==n?n:i[Ts].value,i[Ts].immediateTransitionFrom=null,null!=i[Ts].pendingValue&&(i[Ts].value=i[Ts].pendingValue,i[Ts].pendingValue=null));null===(r=(i=s).updateHandPose)||void 0===r||r.call(i)}}prepareFrameCallback(e,t,n){if(!this.installedState||e.ended)return;const i=e.lastFrameTime!==t||e.lastPreparedFrame!==n;"gaze-only"===this.options.mode&&i&&(e.nativeViewerPoseValid=!1);try{i&&(e.instancePatches.revert(),this.epoch+=1),this.frameSessions.set(n,e),e.activeFrame=n,this.ensureFramePatches(n),this.tick(e,t,n),this.unhealthyFrameAdapters.delete(e)&&0===this.unhealthyFrameAdapters.size&&(this.capabilityState.supported=!0),e.framePreparationFailures=0}catch(t){"gaze-only"===this.options.mode&&(e.nativeViewerPoseValid=!1),e.framePreparationFailures+=1;const n=e.framePreparationFailures;n>=3&&(this.unhealthyFrameAdapters.add(e),this.capabilityState.supported=!1);try{1!==n&&3!==n&&60!==n||this.note(`Native frame preparation failed ${n} consecutive time${1===n?"":"s"}; the application frame was preserved${n>=3?" and the override was marked unsupported":""}: ${this.errorText(t)}`,`frame-preparation-failed-${n}`)}catch(e){}}}releaseFrameCallback(e,t){e.activeFrame===t&&(e.activeFrame=null)}activePlayer(){if(this.playbackFrame)return this.playbackFrame;const e=this.device[_s].actionPlayer;return e&&(e.playing||e[ys].manualFrameActive)?e:null}currentViewerSpace(){if("gaze-only"===this.options.mode)return this.device[_s].viewerSpace;const e=this.activePlayer();return e?e.viewerSpace:this.device[_s].viewerSpace}refreshInputSources(e,t){const n="visible"===e.session.visibilityState,i="gaze-only"===this.options.mode||n?this.expectedSources(e):[];if(n)for(const t of e.retainedSources)i.includes(t)||i.push(t);else{e.pendingEvents.length=0,e.retainedSources.clear();for(const t of e.bindingByFacade.values())t.pendingActions.clear()}const r=e.sources.filter(e=>!i.includes(e)),s=i.filter(t=>!e.sources.includes(t));if(0!==s.length||0!==r.length){for(const t of r){const i=e.bindingByFacade.get(t);if(i){if(n)for(const n of Array.from(i.activeActions))this.emitInputEvent(e,`${n}end`,t,!1);this.clearActionState(i),this.resetButtonBaseline(i)}}for(const t of s){const n=e.bindingByFacade.get(t);n&&(n.activeButtons.clear(),this.resetButtonBaseline(n))}if(n&&r.some(t=>{var n;return"gaze"===(null===(n=e.bindingByFacade.get(t))||void 0===n?void 0:n.kind)})&&this.releaseGazeCommitActions(e,i),e.sources=Object.freeze([...i]),t){const t="gaze-only"===this.options.mode?s.filter(t=>e.bindingByFacade.has(t)):s,n="gaze-only"===this.options.mode?r.filter(t=>e.bindingByFacade.has(t)):r;(t.length>0||n.length>0)&&this.dispatchInputSourcesChange(e,t,n)}}}expectedSources(e){if("gaze-only"===this.options.mode){const t=this.readNativeInputSources(e),n="visible"===e.session.visibilityState?this.connectedSources(e,"gaze"):[];return[...t,...n.filter(e=>!t.includes(e))]}const t=this.activePlayer();if(t)try{return t.inputSources.map(t=>this.playbackBinding(e,t).inputSource)}catch(e){return this.note(`Recorded input sources could not be published: ${this.errorText(e)}`,"recorded-input-publication-failed"),[]}const n=this.device.primaryInputMode,i=this.connectedSources(e,"gaze");return"hand"!==n||e.handTracking?[...this.connectedSources(e,n),...i]:(this.note(`Native hand input requires the "${gc}" feature on the browser session; no synthetic hand input sources are published while hand mode is selected.`),i)}readNativeInputSources(e){if(!e.nativeInputSourcesLive)return Array.from(e.nativeSources);try{const t=Array.from(e.nativeInputSources());return e.nativeSources=Object.freeze([...t]),t}catch(t){return this.note(`Native input sources could not be read; preserving the last known set: ${this.errorText(t)}`,"gaze-only-native-input-sources-unavailable"),e.sources.filter(t=>!e.bindingByFacade.has(t))}}releaseGazeCommitActions(e,t){const n=e===this.sharedStateDriver();for(const i of e.deviceBindings){if("gaze"===i.kind||!t.includes(i.inputSource))continue;const r=i.eventButtons.filter(e=>"select"===e[Ts].eventTrigger);if(0!==r.length){i.activeActions.has("select")&&(this.emitInputEvent(e,"selectend",i.inputSource,!1),i.activeActions.delete("select")),i.pendingActions.delete("select");for(const e of r)i.activeButtons.delete(e),n&&this.releaseButton(e),i.previousButtonValues.set(e,e.value)}}}releaseButton(e){e[Ts].value=0,e[Ts].pendingValue=0,e[Ts].lastFrameValue=0,e[Ts].immediateTransitionFrom=null}connectedSources(e,t){return e.deviceBindings.filter(e=>e.kind===t&&e.trackedInput.connected).map(e=>e.inputSource)}dispatchButtonTransitions(e,t){var n;const i=new Set(e.sources);for(const r of e.deviceBindings)if(i.has(r.inputSource))for(const i of r.eventButtons){const s=null!==(n=r.previousButtonValues.get(i))&&void 0!==n?n:0,a=i.value;r.previousButtonValues.set(i,a);const o=i[Ts].eventTrigger;o&&(0===s&&a>0?(r.activeButtons.add(i),this.dispatchInputEvent(e,`${o}start`,t,r.inputSource)):s>0&&0===a&&r.activeButtons.delete(i)&&(this.dispatchInputEvent(e,o,t,r.inputSource),this.dispatchInputEvent(e,`${o}end`,t,r.inputSource)))}}wirePlayer(e){if(this.wiredPlayer===e)return;this.unwirePlayer(),this.previousPlayerContext=e[ys].eventContext;const t=this,n={dispatchEvent:e=>(t.forwardPlaybackEvent(e),!0)};e.setEventContext({session:n,getFrame:()=>{var e,t;return null!==(t=null===(e=this.primarySession)||void 0===e?void 0:e.activeFrame)&&void 0!==t?t:this.detachedPlaybackFrame},onDiscontinuity:()=>{t.terminatePlaybackActions()}}),this.wiredPlayer=e}unwirePlayer(){const e=this.wiredPlayer;if(!e)return;this.wiredPlayer=null;const t=this.previousPlayerContext;this.previousPlayerContext=void 0;try{e.setEventContext(t)}catch(e){}}forwardPlaybackEvent(e){const t=e.inputSource;if(!t)return;const n=e.type,i=n.startsWith("select")?"select":n.startsWith("squeeze")?"squeeze":null;if(!i)return;const r=n.slice(i.length);if((""===r||"start"===r||"end"===r)&&""!==r)for(const e of this.liveSessions){let n;try{n=this.playbackBinding(e,t)}catch(e){this.note(`A recorded input event could not be bound to a native input source: ${this.errorText(e)}`,"recorded-input-binding-failed");continue}if("start"===r)this.terminatePlaybackAction(e,n,i),n.pendingActions.add(i),this.emitInputEvent(e,`${i}start`,n.inputSource,!0);else{if(!n.pendingActions.delete(i))continue;this.emitInputEvent(e,i,n.inputSource,!0),this.emitInputEvent(e,`${i}end`,n.inputSource,!0)}}}terminatePlaybackActions(){for(const e of this.liveSessions)for(const t of e.playbackBindings.values())for(const n of new Set([...t.pendingActions,...t.activeActions]))this.terminatePlaybackAction(e,t,n)}terminatePlaybackAction(e,t,n){if(!t.pendingActions.delete(n)&&!t.activeActions.has(n))return;const i=`${n}end`;e.pendingEvents.some(e=>e.inputSource===t.inputSource&&e.type===i)||this.emitInputEvent(e,i,t.inputSource,!0)}emitInputEvent(e,t,n,i){const r=e.activeFrame;r&&e.sources.includes(n)?this.dispatchInputEvent(e,t,r,n):(e.pendingEvents.length>=256&&this.compactPendingEvents(e),e.pendingEvents.push({type:t,inputSource:n}),i&&e.retainedSources.add(n))}compactPendingEvents(e){const t=new Map;let n;for(let i=0;i<e.pendingEvents.length;i++){const r=e.pendingEvents[i];if(r.type.endsWith("start")){const e=r.type.slice(0,-5);let n=t.get(r.inputSource);n||(n=new Map,t.set(r.inputSource,n)),n.has(e)||n.set(e,i);continue}if(!r.type.endsWith("end"))continue;const s=r.type.slice(0,-3),a=t.get(r.inputSource),o=null==a?void 0:a.get(s);void 0!==o&&(a.delete(s),(!n||o<n.startIndex)&&(n={startIndex:o,endIndex:i,inputSource:r.inputSource,trigger:s}))}if(!n)return;const{startIndex:i,endIndex:r,inputSource:s,trigger:a}=n,o=`${a}start`,l=`${a}end`;e.pendingEvents=e.pendingEvents.filter((e,t)=>t<i||t>r||e.inputSource!==s||e.type!==a&&e.type!==o&&e.type!==l),this.note("A native session fell too far behind; an oldest complete queued input action was discarded.")}drainPendingEvents(e,t){if(0===e.pendingEvents.length)return void e.retainedSources.clear();const n=e.pendingEvents.splice(0);e.retainedSources.clear();for(const i of n)this.dispatchInputEvent(e,i.type,t,i.inputSource)}dispatchInputEvent(e,t,n,i){this.recordDeliveredAction(e,t,i);const r=this.createEvent(t,"XRInputSourceEvent",{frame:n,inputSource:i});this.syntheticEvents.add(r),e.session.dispatchEvent(r)}recordDeliveredAction(e,t,n){const i=e.bindingByFacade.get(n);i&&(t.endsWith("start")?i.activeActions.add(t.slice(0,-5)):t.endsWith("end")&&i.activeActions.delete(t.slice(0,-3)))}dispatchInputSourcesChange(e,t,n){const i=this.createEvent("inputsourceschange","XRInputSourcesChangeEvent",{session:e.session,added:Object.freeze([...t]),removed:Object.freeze([...n])});this.syntheticEvents.add(i),e.session.dispatchEvent(i)}createEvent(e,t,n){const i=function(e){const t=e.Event;return"function"==typeof t?t:void 0}(this.globalObject);if(!i)throw new Error("Event constructor is unavailable.");const r=new i(e),s=this.constructorPrototype(t);if(s)try{Object.setPrototypeOf(r,s),"XRInputSourceEvent"===t&&(this.capabilityState.brandedInputEvents=!0)}catch(e){}for(const[e,t]of Object.entries(n))Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:t});return r}ensureFramePatches(e){var t,n,i;if(this.instancePatchedFrameEpochs.get(e)===this.epoch)return;const r=this.adapterForFrame(e),s=this.patchFrameGetPose(e),a=this.patchFrameFillPoses(e),o="full"===this.options.mode,l=!!o&&this.patchFrameGetViewerPose(e),c=!!o&&this.patchFrameGetJointPose(e),u=!!o&&this.patchFrameFillJointRadii(e);r&&o&&(this.recordAnchorAvailability(r,this.patchFrameCreateAnchor(e)),this.recordHitTestAvailability(r,this.patchFrameGetHitTestResults(e))),(t=this.capabilityState).poseOverride||(t.poseOverride=s),(n=this.capabilityState).batchPoses||(n.batchPoses=a),(i=this.capabilityState).jointPoses||(i.jointPoses=o&&c&&u),s||this.note("Unable to patch native XRFrame.getPose."),a||this.note("Unable to patch native XRFrame.fillPoses."),o&&!l&&this.note("Unable to patch native XRFrame.getViewerPose."),this.instancePatchedFrameEpochs.set(e,this.epoch)}patchFrameGetPose(e){const t=Cc(e,"getPose");if(t&&t.owner!==e&&this.patchedFrameOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){this.rawGetPoseByOwner.set(t.owner,n);const e=this.patches.define(t.owner,"getPose",{...t.descriptor,value(e,t){return i.handleGetPose(this,n,e,t)}});if(e)return this.patchedFrameOwners.add(t.owner),!0}return this.rawGetPoseByFrame.set(e,n),this.defineFrameMethod(e,"getPose",function(e,t){return i.handleGetPose(this,n,e,t)})}patchFrameGetViewerPose(e){const t=Cc(e,"getViewerPose");if(t&&t.owner!==e&&this.patchedViewerFrameOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"getViewerPose",{...t.descriptor,value(e){return i.handleGetViewerPose(this,n,e)}}))return this.patchedViewerFrameOwners.add(t.owner),!0}return this.defineFrameMethod(e,"getViewerPose",function(e){return i.handleGetViewerPose(this,n,e)})}patchFrameFillPoses(e){const t=Cc(e,"fillPoses");if(t&&t.owner!==e&&this.patchedFillPosesOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"fillPoses",{...t.descriptor,value(e,t,r){return i.handleFillPoses(this,n,e,t,r)}}))return this.patchedFillPosesOwners.add(t.owner),!0}return this.defineFrameMethod(e,"fillPoses",function(e,t,r){return i.handleFillPoses(this,n,e,t,r)})}patchFrameGetJointPose(e){const t=Cc(e,"getJointPose");if(t&&t.owner!==e&&this.patchedJointPoseOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"getJointPose",{...t.descriptor,value(e,t){return i.handleGetJointPose(this,n,e,t)}}))return this.patchedJointPoseOwners.add(t.owner),!0}return this.defineFrameMethod(e,"getJointPose",function(e,t){return i.handleGetJointPose(this,n,e,t)})}patchFrameFillJointRadii(e){const t=Cc(e,"fillJointRadii");if(t&&t.owner!==e&&this.patchedJointRadiiOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"fillJointRadii",{...t.descriptor,value(e,t){return i.handleFillJointRadii(this,n,e,t)}}))return this.patchedJointRadiiOwners.add(t.owner),!0}return this.defineFrameMethod(e,"fillJointRadii",function(e,t){return i.handleFillJointRadii(this,n,e,t)})}patchFrameCreateAnchor(e){const t=Cc(e,"createAnchor");if(t&&t.owner!==e&&this.patchedCreateAnchorOwners.has(t.owner))return"patched";const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return"unavailable";const i=this,r=function(e,t){return i.handleCreateAnchor(this,n,e,t)};if(t.owner!==e){if(this.patches.define(t.owner,"createAnchor",{...t.descriptor,value:r}))return this.patchedCreateAnchorOwners.add(t.owner),"patched"}return this.defineFrameMethod(e,"createAnchor",r)?"patched":"failed"}patchFrameGetHitTestResults(e){const t=Cc(e,"getHitTestResults");if(t&&t.owner!==e&&this.patchedHitTestResultOwners.has(t.owner))return"patched";const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return"unavailable";const i=this,r=function(e){return i.handleGetHitTestResults(this,n,e)};if(t.owner!==e){if(this.patches.define(t.owner,"getHitTestResults",{...t.descriptor,value:r}))return this.patchedHitTestResultOwners.add(t.owner),"patched"}return this.defineFrameMethod(e,"getHitTestResults",r)?"patched":"failed"}recordAnchorAvailability(e,t){"unavailable"!==t&&(e.createAnchorAvailable="patched"===t,"failed"===t&&this.note("Unable to override XRFrame.createAnchor on a native frame; anchors in IWER-controlled spaces are unavailable until a frame can be instrumented."))}recordHitTestAvailability(e,t){"unavailable"!==t&&(e.hitTestResultsAvailable="patched"===t,"failed"===t&&this.note("Unable to override XRFrame.getHitTestResults on a native frame; hit test sources in IWER-controlled spaces are unavailable until a frame can be instrumented."))}defineFrameMethod(e,t,n){const i=this.adapterForFrame(e);return!!i&&i.instancePatches.define(e,t,{configurable:!0,writable:!0,value:n})}handleGetPose(e,t,n,i){if(!this.installedState)return t.call(e,n,i);const r=this.spaces.get(n),s=this.spaces.get(i);if(!Boolean(r||s))return t.call(e,n,i);const a=this.adapterForFrame(e);if(!a)throw Uc("The IWER-controlled space was queried from a frame owned by another native session.");if(this.assertFrameActive(a,e,"getPose"),r&&r.adapter!==a||s&&s.adapter!==a)throw Uc("The IWER-controlled space belongs to a different native session.");if((null==r?void 0:r.available)&&!r.available()||(null==s?void 0:s.available)&&!s.available())return null;const o=this.effectivePoseMatrix(a,e,t,n,i);return o?(this.capabilityState.phase="active",this.createPoseFacade(o)):(this.note("A synthetic pose could not be resolved in the requested base space."),null)}handleGetJointPose(e,t,n,i){if(!this.installedState)return t.call(e,n,i);const r=this.spaces.get(n),s=this.spaces.get(i);if(!r&&!s)return t.call(e,n,i);if(r&&!r.joint)throw new TypeError("Failed to execute 'getJointPose' on 'XRFrame': parameter 1 is not of type 'XRJointSpace'.");const a=this.adapterForFrame(e);if(!a)throw Uc("The IWER-controlled joint space was queried from a frame owned by another native session.");if(this.assertFrameActive(a,e,"getJointPose"),r&&r.adapter!==a||s&&s.adapter!==a)throw Uc("The IWER-controlled joint space belongs to a different native session.");const o=this.nativeGetPose(e);if(!o)return this.note("The native XRFrame.getPose implementation is unavailable."),null;let l;if(null==r?void 0:r.joint){if(l=r.joint.source[ks].radius,!kc(l))return null}else{const i=t.call(e,n,a.anchorSpace);if(!i)return i;l=i.radius}const c=this.effectivePoseMatrix(a,e,o,n,i,!0);return c?this.createJointPoseFacade(c,l):(this.note("A synthetic joint pose could not be resolved in the requested base space."),null)}handleFillJointRadii(e,t,n,i){const r=Array.from(n);if(!this.installedState)return t.call(e,r,i);if(!r.some(e=>this.spaces.has(e)))return t.call(e,r,i);for(const e of r){const t=this.spaces.get(e);if(t&&!t.joint)throw new TypeError("Failed to execute 'fillJointRadii' on 'XRFrame': an element of jointSpaces is not of type 'XRJointSpace'.")}const s=this.adapterForFrame(e);if(!s)throw Uc("IWER-controlled joint radii were queried from a frame owned by another native session.");this.assertFrameActive(s,e,"fillJointRadii");for(const e of r){const t=this.spaces.get(e);if(t&&t.adapter!==s)throw Uc("An IWER-controlled joint space belongs to a different native session.")}if(r.length>i.length)throw new TypeError("The length of jointSpaces is larger than the number of elements in radii.");let a=!0;for(let n=0;n<r.length;n++){const o=this.spaces.get(r[n]);if((null==o?void 0:o.joint)&&o.adapter===s){const e=o.joint.source[ks].radius;kc(e)?i[n]=e:(i[n]=NaN,a=!1)}else{const s=t.call(e,[r[n]],Rc);i[n]=s?Rc[0]:NaN,a&&(a=s)}}return a}handleFillPoses(e,t,n,i,r){const s=Array.from(n);if(!this.installedState)return t.call(e,s,i,r);const a=this.spaces.get(i),o=Boolean(a)||s.some(e=>this.spaces.has(e));if(!o)return t.call(e,s,i,r);const l=this.adapterForFrame(e);if(!l)throw Uc("IWER-controlled poses were queried from a frame owned by another native session.");if(this.assertFrameActive(l,e,"fillPoses"),a&&a.adapter!==l||s.some(e=>{const t=this.spaces.get(e);return null!=t&&t.adapter!==l}))throw Uc("An IWER-controlled space belongs to a different native session.");if(r.length<16*s.length)throw new TypeError("The length of transforms is too small to hold a transform for every space.");const c=this.nativeGetPose(e);if(!c)return!1;let u=!0;for(let t=0;t<s.length;t++){const n=this.effectivePoseMatrix(l,e,c,s[t],i,!0);n?Ic(n,r,16*t):u=!1}return u}handleGetViewerPose(e,t,n){const i=t.call(e,n),r=this.adapterForFrame(e);if(!i||!r||!this.installedState)return i;const s=this.nativeGetPose(e);if(!s)return this.viewerOverrideFailure("The native XRFrame.getPose implementation could not be recovered.");const a=this.viewerToBaseMatrix(r,e,s,n);if(!a)return this.viewerOverrideFailure("The overridden viewer pose could not be resolved in the requested reference space.");const o=this.readNativeTransform(i);if(!o)return this.viewerOverrideFailure("The browser-owned XRViewerPose transform could not be read.");const l=Pc(o),c=[];if(!this.overrideTransform(r,i,this.rigidTransformFromMatrix(a)))return this.viewerOverrideFailure("The browser-owned XRViewerPose transform could not be overridden.");c.push(i);const u=Gr(wc,l);if(!u)return this.clearTransformOverrides(c),this.viewerOverrideFailure("The browser-owned XRViewerPose transform was not invertible.");for(const e of i.views){const t=this.readNativeTransform(e);if(!t)return this.clearTransformOverrides(c),this.viewerOverrideFailure("A browser-owned XRView transform could not be read.");const n=Pc(t),i=Ur();Hr(i,u,n);const s=Ur();if(Hr(s,a,i),!this.overrideTransform(r,e,this.rigidTransformFromMatrix(s)))return this.clearTransformOverrides(c),this.viewerOverrideFailure("A browser-owned XRView transform could not be overridden.");c.push(e)}return this.capabilityState.viewerPose=!0,this.capabilityState.viewTransforms=!0,this.capabilityState.phase="active",i}viewerOverrideFailure(e){return this.note(e),null}effectivePoseMatrix(e,t,n,i,r,s=!1){const a=this.spaces.get(i),o=this.spaces.get(r);if(a&&a.adapter!==e||o&&o.adapter!==e)return null;if(!a&&!o&&!s)return null;const l=a?this.controlledSpaceToAnchor(a,xc):this.nativePoseMatrix(n.call(t,i,e.anchorSpace));if(!l)return null;let c;if(o){const e=this.controlledSpaceToAnchor(o,_c);c=e?Gr(bc,e):null}else c=this.anchorToNativeBase(e,t,n,r);return c?zr(Hr(Sc,c,l)):null}viewerToBaseMatrix(e,t,n,i){const r=this.viewerMatrix(yc),s=this.spaces.get(i);let a;if(s){if(s.adapter!==e)return null;const t=this.controlledSpaceToAnchor(s,_c);a=t?Gr(bc,t):null}else a=this.anchorToNativeBase(e,t,n,i);return a?zr(Hr(Sc,a,r)):null}controlledSpaceToAnchor(e,t){if(e.available&&!e.available())return null;if(e.origin){const n=e.origin();if(!n)return null;$s.calculateGlobalOffsetMatrix(n,t)}else Vr(t);return Hr(t,t,e.localOffset),t}viewerMatrix(e){return $s.calculateGlobalOffsetMatrix(this.currentViewerSpace(),e)}anchorToNativeBase(e,t,n,i){if(e.baseSpaceCache.has(i)){const t=e.baseSpaceCache.get(i);return t?zr(t):null}const r=n.call(t,e.anchorSpace,i),s=this.nativePoseMatrix(r);return e.baseSpaceCache.set(i,s?zr(s):null),s}nativePoseMatrix(e){if(!e)return null;const t=this.readNativeTransform(e);return t?Pc(t):null}createPoseFacade(e){const t=this.constructorPrototype("XRPose"),n=Object.create(null!=t?t:Object.prototype);return Object.defineProperties(n,this.poseProperties(e)),n}createJointPoseFacade(e,t){var n;const i=null!==(n=this.constructorPrototype("XRJointPose"))&&void 0!==n?n:this.constructorPrototype("XRPose"),r=Object.create(null!=i?i:Object.prototype);return Object.defineProperties(r,{...this.poseProperties(e),radius:{configurable:!0,enumerable:!0,value:t}}),r}poseProperties(e){return{transform:{configurable:!0,enumerable:!0,value:this.rigidTransformFromMatrix(e)},emulatedPosition:{configurable:!0,enumerable:!0,value:!1},linearVelocity:{configurable:!0,enumerable:!0,value:null},angularVelocity:{configurable:!0,enumerable:!0,value:null}}}rigidTransformFromMatrix(e){return qr(Ec,e),Yr(Ac,e),new(this.getRigidTransformConstructor())({x:Ec[0],y:Ec[1],z:Ec[2],w:1},{x:Ac[0],y:Ac[1],z:Ac[2],w:Ac[3]})}getRigidTransformConstructor(){const e=this.globalObject.XRRigidTransform;if("function"!=typeof e)throw new Error("Native XRRigidTransform constructor is unavailable.");return e}readNativeTransform(e){let t=this.transformReaders.get(e);if(!t){const n=Cc(e,"transform");if(!n)return null;let i=this.rawTransformGetters.get(n.owner);if(!i&&n.descriptor.get&&(i=n.descriptor.get,this.rawTransformGetters.set(n.owner,i)),i)t=()=>i.call(e);else{if(!("value"in n.descriptor))return null;{const e=n.descriptor.value;t=()=>e}}this.transformReaders.set(e,t)}try{return t()}catch(e){return null}}overrideTransform(e,t,n){if(!this.readNativeTransform(t))return!1;this.transformOverrides.set(t,{epoch:this.epoch,transform:n});const i=Cc(t,"transform");if(!i)return!1;if(i.owner!==t&&this.patchedTransformOwners.has(i.owner))return!0;const r=this.rawTransformGetters.get(i.owner);if(i.owner!==t&&r&&!1!==i.descriptor.configurable){const e=this;if(this.patches.define(i.owner,"transform",{...i.descriptor,get(){const t=e.transformOverrides.get(this);return e.installedState&&t&&t.epoch===e.epoch?t.transform:r.call(this)}}))return this.patchedTransformOwners.add(i.owner),!0}if(this.instancePatchedTransformEpochs.get(t)===this.epoch)return!0;const s=this,a=e.instancePatches.define(t,"transform",{configurable:!0,get(){var e;const t=s.transformOverrides.get(this);return s.installedState&&t&&t.epoch===s.epoch?t.transform:null===(e=s.transformReaders.get(this))||void 0===e?void 0:e()}});return a?(this.instancePatchedTransformEpochs.set(t,this.epoch),!0):(this.transformOverrides.delete(t),!1)}clearTransformOverrides(e){for(const t of e)this.transformOverrides.delete(t)}nativeGetPose(e){var t;const n=this.rawGetPoseByFrame.get(e);if(n)return n;const i=Cc(e,"getPose");return i&&null!==(t=this.rawGetPoseByOwner.get(i.owner))&&void 0!==t?t:null}handleCreateAnchor(e,t,n,i){if(!this.installedState)return t.call(e,n,i);const r=this.spaces.get(i);if(!r)return t.call(e,n,i);try{const i=this.adapterForFrame(e);if(!i||i.ended)throw Uc("The IWER-controlled anchor space belongs to a different native session.");if(this.assertFrameActive(i,e,"createAnchor"),i!==r.adapter)throw Uc("The IWER-controlled anchor space belongs to a different native session.");if(!i.createAnchorAvailable)throw new DOMException("Anchors in IWER-controlled spaces are unavailable because XRFrame.createAnchor could not be overridden.","NotSupportedError");const s=this.controlledSpaceToAnchor(r,Mc);if(!s)throw Uc("The IWER-controlled anchor space could not be resolved for this frame.");const a=Hr(Ur(),s,Pc(n)),o=this.rigidTransformFromMatrix(a);return this.capabilityState.anchors=!0,t.call(e,o,i.anchorSpace)}catch(e){return Promise.reject(e)}}handleRequestHitTestSource(e,t,n){const i=this.installedState&&n?this.spaces.get(n.space):null;if(!i)return t.call(e,n);const r=this.sessionsByObject.get(e);if(!r||r!==i.adapter||r.ended)return Promise.reject(Uc("The IWER-controlled hit test space belongs to a different native session."));if(!r.hitTestResultsAvailable)return Promise.reject(new DOMException("Hit test sources in IWER-controlled spaces are unavailable because XRFrame.getHitTestResults could not be overridden.","NotSupportedError"));const s=this.controlledSpaceToAnchor(i,Tc);if(!s)return Promise.reject(Uc("The IWER-controlled hit test space could not be resolved."));const a={adapter:r,facade:void 0,space:n.space,requestedOptions:{...n,entityTypes:n.entityTypes?Array.from(n.entityTypes):void 0},nativeMethod:t,current:null,currentMatrix:null,pendingMatrix:null,pendingToken:0,failures:0,backoffFrames:0,cancelled:!1};return a.facade=this.createHitTestSourceFacade(a),r.hitTests.add(a),this.hitTestBindings.set(a.facade,a),this.capabilityState.hitTest=!0,this.requestBackingSource(a,s).then(()=>a.facade,e=>{throw this.disposeHitTestBinding(a),e})}createHitTestSourceFacade(e){const t=this.constructorPrototype("XRHitTestSource"),n=Object.create(null!=t?t:Object.prototype);return Object.defineProperty(n,"cancel",{configurable:!0,writable:!0,value:()=>{if(e.cancelled)throw Uc("The IWER-controlled hit test source has already been cancelled.");this.disposeHitTestBinding(e)}}),n}requestBackingSource(e,t){const n=++e.pendingToken;e.pendingMatrix=zr(t);const i=e.adapter;let r;try{const n=this.createDetachedOffsetSpace(i,t);r=Promise.resolve(e.nativeMethod.call(i.session,{...e.requestedOptions,space:n}))}catch(e){r=Promise.reject(e)}return r.then(t=>{if(n!==e.pendingToken||e.cancelled||i.ended||!this.installedState)return void this.cancelNativeHitTestSource(t);const r=e.current;e.current=t,e.currentMatrix=e.pendingMatrix,e.pendingMatrix=null,e.failures=0,e.backoffFrames=0,this.cancelNativeHitTestSource(r)},t=>{throw n!==e.pendingToken||e.cancelled||(e.pendingMatrix=null,e.failures+=1,e.backoffFrames=Math.min(2**Math.min(e.failures,5),32)),t})}createDetachedOffsetSpace(e,t){const n=this.rigidTransformFromMatrix(t),i=this.spaces.get(e.anchorSpace);this.spaces.delete(e.anchorSpace);try{return e.anchorSpace.getOffsetReferenceSpace(n)}finally{i&&this.spaces.set(e.anchorSpace,i)}}updateHitTestSources(e){if(0!==e.hitTests.size)for(const t of Array.from(e.hitTests)){if(t.cancelled)continue;if(t.pendingMatrix)continue;if(t.backoffFrames>0){t.backoffFrames-=1;continue}const e=this.spaces.get(t.space);if(!e)continue;const n=this.controlledSpaceToAnchor(e,Tc);n&&(t.currentMatrix&&Fc(t.currentMatrix,n)||this.requestBackingSource(t,n).catch(e=>{this.note(`A native hit test subscription could not follow its IWER-controlled space: ${this.errorText(e)}`,"hit-test-resubscribe-failed")}))}}handleGetHitTestResults(e,t,n){if(!this.installedState)return t.call(e,n);const i=this.hitTestBindings.get(n);if(!i)return t.call(e,n);if(i.cancelled)throw Uc("The IWER-controlled hit test source has been cancelled.");const r=this.adapterForFrame(e);if(!r||r!==i.adapter)throw Uc("The IWER-controlled hit test source belongs to a different native session.");if(r.framesInstrumented&&r.activeFrame!==e)throw Uc("Failed to execute 'getHitTestResults' on 'XRFrame': the frame is not active.");return i.current?t.call(e,i.current):[]}cancelNativeHitTestSource(e){if(e)try{e.cancel()}catch(e){}}disposeHitTestBinding(e){e.cancelled=!0,e.pendingToken+=1,e.pendingMatrix=null,this.cancelNativeHitTestSource(e.current),e.current=null,e.currentMatrix=null,e.adapter.hitTests.delete(e)}adapterForFrame(e){var t;const n=this.frameSessions.get(e);if(n&&!n.ended)return n;try{return null!==(t=this.sessionsByObject.get(e.session))&&void 0!==t?t:null}catch(e){return null}}assertFrameActive(e,t,n){if(e.framesInstrumented&&e.activeFrame!==t)throw Uc(`Failed to execute '${n}' on 'XRFrame': the frame is not active.`)}constructorPrototype(e){var t;const n=this.globalObject[e];return null!==(t=null==n?void 0:n.prototype)&&void 0!==t?t:null}detachSession(e){const t=this.sessionsByObject.get(e);t&&this.detachAdapter(t)}detachAdapter(e,t=!1){var n;if(e.ended)return;const i="gaze-only"===this.options.mode?e.sources.filter(t=>e.bindingByFacade.has(t)):[...e.sources],r=this.unhealthyFrameAdapters.delete(e);e.ended=!0;for(const t of e.cleanupListeners.splice(0))try{t()}catch(e){}const s=e===this.sharedStateDriver();for(const t of e.deviceBindings){for(const e of t.eventButtons)s&&this.releaseButton(e),t.previousButtonValues.set(e,e.value);t.activeButtons.clear()}for(const t of Array.from(e.hitTests))this.disposeHitTestBinding(t);if(e.instancePatches.revert(),e.patches.revert(),e.baseSpaceCache.clear(),e.activeFrame=null,e.lastPreparedFrame=null,this.sessionsByObject.delete(e.session),t){let t=[];if("full"===this.options.mode)try{t=Array.from(e.session.inputSources)}catch(e){}if(t.length>0||i.length>0)try{this.dispatchInputSourcesChange(e,t,i)}catch(e){}}e.sources=Object.freeze([]),e.deviceBindings.splice(0),e.playbackBindings.clear(),e.bindingByFacade.clear(),e.spaceTokens.clear(),e.pendingEvents.length=0,e.retainedSources.clear(),this.liveSessions.delete(e),r&&0===this.unhealthyFrameAdapters.size&&this.installedState&&(this.capabilityState.supported=!0),this.primarySession===e&&(this.primarySession=null!==(n=this.liveSessions.values().next().value)&&void 0!==n?n:null,this.lastPrimaryTime=void 0),0===this.liveSessions.size&&(this.unwirePlayer(),this.playbackFrame=null,this.device.remote.forceRelease())}resetPatchTracking(){this.sessionsByObject=new WeakMap,this.frameSessions=new WeakMap,this.spaces=new WeakMap,this.hitTestBindings=new WeakMap,this.syntheticEvents=new WeakSet,this.patchedFrameOwners=new WeakSet,this.patchedViewerFrameOwners=new WeakSet,this.patchedFillPosesOwners=new WeakSet,this.patchedJointPoseOwners=new WeakSet,this.patchedJointRadiiOwners=new WeakSet,this.patchedReferenceSpaceOwners=new WeakSet,this.patchedEnabledFeaturesOwners=new WeakSet,this.patchedInputSourceOwners=new WeakSet,this.patchedRafOwners=new WeakSet,this.patchedRequestReferenceSpaceOwners=new WeakSet,this.instancePatchedReferenceSpaces=new WeakSet,this.patchedHitTestOwners=new WeakSet,this.patchedHitTestResultOwners=new WeakSet,this.patchedCreateAnchorOwners=new WeakSet,this.rawGetPoseByOwner=new WeakMap,this.rawGetPoseByFrame=new WeakMap,this.rawRafByOwner=new WeakMap,this.rawRequestReferenceSpaceByOwner=new WeakMap,this.rawInputSourcesGetterByOwner=new WeakMap,this.rawTransformGetters=new WeakMap,this.transformReaders=new WeakMap,this.transformOverrides=new WeakMap,this.patchedTransformOwners=new WeakSet,this.instancePatchedFrameEpochs=new WeakMap,this.instancePatchedTransformEpochs=new WeakMap,this.unhealthyFrameAdapters.clear(),this.lastPrimaryTime=void 0}unsupportedForSession(e,t){if("throw"===this.options.onUnsupported)throw this.detachAdapter(e),new Error(t);this.note(t)}unsupported(e){if(this.capabilityState.supported=!1,this.note(e),"throw"===this.options.onUnsupported)throw new Error(e)}note(e,t=e){this.warned.has(t)||(this.warned.add(t),this.capabilityState.notes.push(e),console.warn(`[IWER native override] ${e}`))}errorText(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}}const Hc=Vi(e=>({mode:"off",commitHand:"right",setMode:t=>e({mode:t}),setCommitHand:t=>e({commitHand:t})}));const Wc=en.td`
|
|
797
|
+
text-align: right;
|
|
798
|
+
color: ${tn};
|
|
799
|
+
padding: 0 8px 0 0;
|
|
800
|
+
font-weight: bold;
|
|
801
|
+
`,jc=en.td`
|
|
802
|
+
text-align: left;
|
|
803
|
+
color: ${nn};
|
|
804
|
+
padding: 0;
|
|
805
|
+
`,Xc=en(Un)`
|
|
806
|
+
position: absolute;
|
|
807
|
+
top: calc(100% + 8px);
|
|
808
|
+
left: ${({$left:e})=>`${e}px`};
|
|
809
|
+
width: ${248}px;
|
|
810
|
+
box-sizing: border-box;
|
|
811
|
+
gap: ${wn};
|
|
812
|
+
padding: 8px;
|
|
813
|
+
overflow: visible;
|
|
814
|
+
z-index: 10;
|
|
815
|
+
`,qc=en.div`
|
|
816
|
+
min-height: 26px;
|
|
817
|
+
display: flex;
|
|
818
|
+
align-items: center;
|
|
819
|
+
gap: 8px;
|
|
820
|
+
padding: 0 2px 4px;
|
|
821
|
+
|
|
822
|
+
&:focus {
|
|
823
|
+
outline: none;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
&:focus-visible {
|
|
827
|
+
outline: 2px solid ${on};
|
|
828
|
+
outline-offset: 1px;
|
|
829
|
+
border-radius: ${Dn};
|
|
830
|
+
}
|
|
831
|
+
`,$c=en.strong`
|
|
832
|
+
flex: 1;
|
|
833
|
+
font-size: 14px;
|
|
834
|
+
font-weight: 600;
|
|
835
|
+
letter-spacing: -0.01em;
|
|
836
|
+
`,Yc=en.button`
|
|
837
|
+
width: 100%;
|
|
838
|
+
min-height: 42px;
|
|
839
|
+
box-sizing: border-box;
|
|
840
|
+
display: grid;
|
|
841
|
+
grid-template-columns: 18px minmax(0, 1fr) 16px;
|
|
842
|
+
align-items: center;
|
|
843
|
+
gap: 8px;
|
|
844
|
+
padding: 6px 8px;
|
|
845
|
+
border: 1px solid
|
|
846
|
+
${({$selected:e})=>e?On:"rgba(255, 255, 255, 0.04)"};
|
|
847
|
+
border-radius: ${Dn};
|
|
848
|
+
background: ${({$selected:e})=>e?Fn:"transparent"};
|
|
849
|
+
color: ${({$selected:e,$unavailable:t})=>t?nn:e?on:tn};
|
|
850
|
+
cursor: ${({$unavailable:e})=>e?"default":"pointer"};
|
|
851
|
+
text-align: left;
|
|
852
|
+
font-family:
|
|
853
|
+
system-ui,
|
|
854
|
+
-apple-system,
|
|
855
|
+
'Segoe UI',
|
|
856
|
+
Roboto,
|
|
857
|
+
sans-serif;
|
|
858
|
+
&:hover {
|
|
859
|
+
background: ${({$selected:e,$unavailable:t})=>t?e?Fn:"transparent":e?"rgba(45, 127, 249, 0.24)":"rgba(255, 255, 255, 0.07)"};
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
&:focus {
|
|
863
|
+
outline: none;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
&:focus-visible {
|
|
867
|
+
outline: 2px solid ${on};
|
|
868
|
+
outline-offset: 1px;
|
|
869
|
+
}
|
|
870
|
+
`,Kc=en.span`
|
|
871
|
+
min-width: 0;
|
|
872
|
+
display: flex;
|
|
873
|
+
flex-direction: column;
|
|
874
|
+
gap: 1px;
|
|
875
|
+
`,Zc=en.span`
|
|
876
|
+
font-size: 12px;
|
|
877
|
+
font-weight: 600;
|
|
878
|
+
line-height: 15px;
|
|
879
|
+
`,Jc=en.span`
|
|
880
|
+
color: ${nn};
|
|
881
|
+
font-size: 10px;
|
|
882
|
+
font-weight: 400;
|
|
883
|
+
line-height: 13px;
|
|
884
|
+
`,Qc=en.div`
|
|
885
|
+
padding: 5px 2px 3px;
|
|
886
|
+
color: ${nn};
|
|
887
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
888
|
+
font-size: 10px;
|
|
889
|
+
font-weight: 600;
|
|
890
|
+
letter-spacing: 0.04em;
|
|
891
|
+
text-transform: uppercase;
|
|
892
|
+
`,eu=en.div`
|
|
893
|
+
display: grid;
|
|
894
|
+
grid-auto-flow: column;
|
|
895
|
+
grid-auto-columns: 1fr;
|
|
896
|
+
gap: 2px;
|
|
897
|
+
padding: 2px;
|
|
898
|
+
border-radius: ${Dn};
|
|
899
|
+
background: ${({$unavailable:e})=>e?"rgba(20, 20, 22, 0.42)":Nn};
|
|
900
|
+
`,tu=en.button`
|
|
901
|
+
height: ${Ln};
|
|
902
|
+
min-width: 0;
|
|
903
|
+
padding: 0 6px;
|
|
904
|
+
overflow: hidden;
|
|
905
|
+
border: 1px solid
|
|
906
|
+
${({$selected:e,$unavailable:t})=>e?t?"rgba(255, 255, 255, 0.08)":On:"transparent"};
|
|
907
|
+
border-radius: 6px;
|
|
908
|
+
background: ${({$selected:e,$unavailable:t})=>e?t?"rgba(255, 255, 255, 0.04)":Fn:"transparent"};
|
|
909
|
+
color: ${({$selected:e,$unavailable:t})=>t?nn:e?on:nn};
|
|
910
|
+
cursor: ${({$unavailable:e})=>e?"not-allowed":"pointer"};
|
|
911
|
+
font-family:
|
|
912
|
+
system-ui,
|
|
913
|
+
-apple-system,
|
|
914
|
+
'Segoe UI',
|
|
915
|
+
Roboto,
|
|
916
|
+
sans-serif;
|
|
917
|
+
font-size: 11px;
|
|
918
|
+
font-weight: 600;
|
|
919
|
+
white-space: nowrap;
|
|
920
|
+
|
|
921
|
+
&:hover {
|
|
922
|
+
color: ${({$unavailable:e})=>e?nn:tn};
|
|
923
|
+
background: ${({$selected:e,$unavailable:t})=>t?e?"rgba(255, 255, 255, 0.04)":"transparent":e?"rgba(45, 127, 249, 0.24)":"rgba(255, 255, 255, 0.06)"};
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
&:focus {
|
|
927
|
+
outline: none;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
&:focus-visible {
|
|
931
|
+
outline: 2px solid ${on};
|
|
932
|
+
outline-offset: 1px;
|
|
933
|
+
}
|
|
934
|
+
`,nu=en.div`
|
|
935
|
+
display: grid;
|
|
936
|
+
grid-template-columns: 8px minmax(0, 1fr);
|
|
937
|
+
align-items: start;
|
|
938
|
+
gap: 7px;
|
|
939
|
+
padding: 7px 8px;
|
|
940
|
+
border-radius: ${Dn};
|
|
941
|
+
background: ${Nn};
|
|
942
|
+
color: ${nn};
|
|
943
|
+
font-size: 10px;
|
|
944
|
+
line-height: 14px;
|
|
945
|
+
`,iu=en.span`
|
|
946
|
+
width: 6px;
|
|
947
|
+
height: 6px;
|
|
948
|
+
margin-top: 4px;
|
|
949
|
+
border-radius: 50%;
|
|
950
|
+
background: ${({$tone:e})=>"active"===e?on:"error"===e?sn:nn};
|
|
951
|
+
box-shadow: ${({$tone:e})=>"active"===e?`0 0 6px ${ln}`:"none"};
|
|
952
|
+
`,ru=en.div`
|
|
953
|
+
display: grid;
|
|
954
|
+
gap: 4px;
|
|
955
|
+
padding: 2px;
|
|
956
|
+
`,su=en.div`
|
|
957
|
+
display: grid;
|
|
958
|
+
grid-template-columns: 42px minmax(0, 1fr);
|
|
959
|
+
align-items: center;
|
|
960
|
+
gap: 7px;
|
|
961
|
+
color: ${nn};
|
|
962
|
+
font-size: 10px;
|
|
963
|
+
line-height: 13px;
|
|
964
|
+
|
|
965
|
+
> :first-child {
|
|
966
|
+
justify-self: center;
|
|
967
|
+
}
|
|
968
|
+
`,au=en.span`
|
|
969
|
+
min-width: 20px;
|
|
970
|
+
box-sizing: border-box;
|
|
971
|
+
padding: 2px 4px;
|
|
972
|
+
border: 1px solid ${un};
|
|
973
|
+
border-radius: 5px;
|
|
974
|
+
color: ${tn};
|
|
975
|
+
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
976
|
+
font-size: 10px;
|
|
977
|
+
text-align: center;
|
|
978
|
+
`;function ou(e){var t;const n=e.activeSession;return{supported:Wo(e.supportedFeatures),sessionActive:null!=n,negotiated:Boolean(null==n?void 0:n.enabledFeatures.some(e=>"gaze-tracking"===e||"eye-tracking"===e)),connected:Boolean(null===(t=e.gaze)||void 0===t?void 0:t.connected)}}function lu(e,t){const[n,i]=c.useState(0);return c.useLayoutEffect(()=>{if(!e)return;const n=()=>{const e=t.current,n=null==e?void 0:e.offsetParent;if(!e||!n)return;const r=e.getBoundingClientRect(),s=n.getBoundingClientRect(),a=Math.max(8,Math.min(r.left+r.width/2-124,window.innerWidth-248-8));i(a-s.left)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e,t]),n}function cu(e,t){c.useEffect(()=>{if(!e)return;const n=window.requestAnimationFrame(()=>{var e;const n=t.current,i=null==n?void 0:n.querySelector('[data-autofocus="true"]'),r=null==n?void 0:n.querySelector("button:not([disabled]), input:not([disabled])");null===(e=null!=i?i:r)||void 0===e||e.focus()});return()=>window.cancelAnimationFrame(n)},[e,t])}const uu=["meeting_room","living_room","music_room","office_large","office_small"];function hu(e){var t;const n=e.sem,i=null!==(t=null==n?void 0:n.environments)&&void 0!==t?t:uu,r=i.filter(e=>{var t,i;return"legacy-scan"===(null===(i=null===(t=null==n?void 0:n.environmentInfo)||void 0===t?void 0:t.call(n,e))||void 0===i?void 0:i.kind)}),s=i.filter(e=>!r.includes(e));return s.length&&r.length?[{label:void 0,ids:s},{label:"Legacy scans",ids:r}]:[{label:void 0,ids:i}]}const du=en.div`
|
|
979
|
+
color: ${nn};
|
|
980
|
+
font-size: 10px;
|
|
981
|
+
letter-spacing: 0.04em;
|
|
982
|
+
text-transform: uppercase;
|
|
983
|
+
padding: 8px 10px 2px;
|
|
984
|
+
`,pu=Vi(e=>({infoPanelOpen:!1,envDropDownOpen:!1,headsetOpen:!1,inputMenuOpen:!1,gazePanelOpen:!1,setInfoPanelOpen:t=>e(()=>({infoPanelOpen:t})),setEnvDropDownOpen:t=>e(()=>({envDropDownOpen:t})),setHeadsetOpen:t=>e(()=>({headsetOpen:t})),setInputMenuOpen:t=>e(()=>({inputMenuOpen:t})),setGazePanelOpen:t=>e(()=>({gazePanelOpen:t}))}));const fu=[{value:"off",label:"Off"},{value:"cursor",label:"Cursor"},{value:"head-locked",label:"Head"}],mu=[{value:"left",label:"Left"},{value:"right",label:"Right"}],gu=({xrDevice:e,inputLayer:t})=>{var n,i,r;const[s,a]=c.useState(Boolean(null===(n=e.sem)||void 0===n?void 0:n.planesVisible)),[o,l]=c.useState(Boolean(null===(i=e.sem)||void 0===i?void 0:i.boundingBoxesVisible)),[h,d]=c.useState(Boolean(null===(r=e.sem)||void 0===r?void 0:r.meshesVisible)),p=void 0!==e.visibilityMask,[f,m]=c.useState(e.visibilityMaskEnabled),{inputMode:g,setInputMode:v}=Nr(),y=Hc(e=>e.mode),x=Hc(e=>e.setMode),b=Hc(e=>e.commitHand),_=Hc(e=>e.setCommitHand),w=function(e){const[t,n]=c.useState(()=>ou(e));return c.useEffect(()=>{const t=()=>{const t=ou(e);n(e=>e.supported===t.supported&&e.sessionActive===t.sessionActive&&e.negotiated===t.negotiated&&e.connected===t.connected?e:t)};t();const i=window.setInterval(t,500);return()=>window.clearInterval(i)},[e]),t}(e),S=c.useRef(null),M=c.useRef(null),T=c.useRef(null),E=c.useRef(null),A=c.useRef(null),R=c.useRef(null),C=c.useRef(null),P=c.useRef(null),I=c.useRef(null),{infoPanelOpen:L,setInfoPanelOpen:D,envDropDownOpen:N,setEnvDropDownOpen:O,headsetOpen:F,setHeadsetOpen:k,inputMenuOpen:U,setInputMenuOpen:z,gazePanelOpen:B,setGazePanelOpen:V}=pu(),G=lu(U,M),H=lu(B,T),W=lu(F,E),j=lu(N,A);cu(U,R),cu(B,C),cu(F,P),cu(N,I),c.useEffect(()=>{if(!(U||B||F||N))return;const e=()=>{z(!1),V(!1),k(!1),O(!1)},t=t=>{const n=S.current;n&&t.composedPath().includes(n)||e()},n=t=>{if("Escape"!==t.key)return;const n=Boolean(S.current&&t.composedPath().includes(S.current)),i=U?M.current:B?T.current:F?E.current:A.current;e(),n&&(null==i||i.focus())};return document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",n),()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",n)}},[N,B,F,U,O,V,k,z]);const X="off"===y?g:"hand"===g&&"cursor"===y?"gaze-hands":null,q="off"!==y&&w.sessionActive&&w.negotiated&&w.connected?"active":"off"!==y&&w.sessionActive&&w.negotiated&&!w.connected?"error":"idle",$=w.supported?"off"===y?"Off · the app receives no gaze input":w.sessionActive?w.negotiated?w.connected?"Streaming to the XR session":"Source disconnected · far rays are active":"Session didn't request gaze-tracking":"Ready · enter XR to publish gaze":"No eye tracking on this profile · choose a gaze-capable device",Y=e=>{t.setGazeCommitHand(e),_(e),Gi({gazeCommitHand:e})},K=(n,i)=>{const r="controller"===n?"controller":"hand",s="gaze-hands"===n?"cursor":"off";v(r),e.primaryInputMode=r,t.setGazeMode(s),x(t.currentGazeMode),Gi({inputMode:r,gazeMode:s}),z(!1),i&&window.requestAnimationFrame(()=>{var e;return null===(e=M.current)||void 0===e?void 0:e.focus()})},Z=e=>{w.supported&&(e=>{t.setGazeMode(e),x(t.currentGazeMode),Gi({gazeMode:e})})(e)},J=e=>e?on:nn,Q=t=>{return u.jsx(Tn,{style:{fontSize:"12px",width:"100%",justifyContent:"start",borderRadius:"8px",padding:"6px 10px"},onClick:n=>{var i;"none"===t?e.sem.deleteAll():null===(i=e.sem.loadDefaultEnvironment(t))||void 0===i||i.catch(e=>console.error(`Could not load environment ${t}`,e)),Gi({environment:t}),O(!1),0===n.detail&&window.requestAnimationFrame(()=>{var e;return null===(e=A.current)||void 0===e?void 0:e.focus()})},children:(n=t,n.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "))},t);var n};return u.jsxs("div",{style:{display:"flex",justifyContent:"center",flexDirection:"row",alignItems:"center",gap:"6px",padding:"8px"},children:[u.jsxs("div",{ref:S,style:{position:"relative"},children:[u.jsxs(Mn,{children:[u.jsx(Tn,{title:"Reset device transforms",onClick:()=>t.resetDeviceTransforms(),children:u.jsx(Fi,{name:"rotate-ccw",size:16})}),u.jsx(Tn,{title:"cursor"===y?"Pointer lock is unavailable while cursor gaze is active":"Play mode (lock pointer)",disabled:"cursor"===y,onClick:()=>{t.lockPointer(),O(!1),D(!1)},children:u.jsx(Fi,{name:"circle-play",size:16})}),u.jsx(Tn,{ref:M,title:"Select input mode","aria-expanded":U,"aria-controls":U?"iwer-input-mode-menu":void 0,$open:U,onClick:()=>{z(!U),k(!1),V(!1),O(!1),D(!1)},children:u.jsx(Fi,{name:"hand"===g&&"cursor"===y?"eye":"controller"===g?"gamepad-2":"hand",size:16})}),u.jsx(Tn,{ref:T,title:"Configure gaze emulation","aria-expanded":B,"aria-controls":B?"iwer-gaze-settings":void 0,$active:"off"!==y,$open:B,onClick:()=>{V(!B),k(!1),z(!1),O(!1),D(!1)},children:u.jsx(Fi,{name:"scan-eye",size:16,color:"error"===q?sn:void 0})}),u.jsx(Tn,{ref:E,title:"Headset position","aria-expanded":F,"aria-controls":F?"iwer-headset-settings":void 0,$open:F,onClick:()=>{k(!F),z(!1),V(!1),O(!1),D(!1)},children:u.jsx(Fi,{name:"glasses",size:16})}),u.jsx(Tn,{"aria-label":"Field-of-view mask","aria-pressed":f,disabled:!p,title:p?(f?"Disable":"Enable")+" field-of-view mask":"Field-of-view mask unavailable for this device profile",onClick:()=>{e.visibilityMaskEnabled=!e.visibilityMaskEnabled,m(e.visibilityMaskEnabled),Gi({visibilityMaskEnabled:e.visibilityMaskEnabled})},children:u.jsx(Fi,{name:"scan",size:16,color:p?f?on:nn:rn})}),e.sem&&u.jsxs(u.Fragment,{children:[u.jsx(zn,{$horizontal:!1}),u.jsx(Tn,{ref:A,title:"Select emulated environment","aria-expanded":N,"aria-controls":N?"iwer-environment-menu":void 0,$open:N,onClick:()=>{O(!N),z(!1),V(!1),k(!1),D(!1)},children:u.jsx(Fi,{name:"armchair",size:16})}),u.jsx(Tn,{title:"Toggle plane visibility",onClick:()=>{e.sem.planesVisible=!s,a(!s)},children:u.jsx(Fi,{name:"layers",size:16,color:J(s)})}),u.jsx(Tn,{title:"Toggle bounding-box visibility",onClick:()=>{e.sem.boundingBoxesVisible=!o,l(!o)},children:u.jsx(Fi,{name:"box",size:16,color:J(o)})}),u.jsx(Tn,{title:"Toggle mesh visibility",onClick:()=>{e.sem.meshesVisible=!h,d(!h)},children:u.jsx(Fi,{name:"shapes",size:16,color:J(h)})})]}),u.jsx(zn,{$horizontal:!1}),u.jsx(Tn,{title:"Save current device pose as the default for this site",onClick:()=>{const e=t.captureDefaultPose();t.applyDefaultPose(e),Gi({defaultPose:e})},children:u.jsx(Fi,{name:"save",size:16})}),u.jsx(zn,{$horizontal:!1}),u.jsx(Tn,{title:"Exit XR session",onClick:()=>{var t;return null===(t=e.activeSession)||void 0===t?void 0:t.end()},children:u.jsx(Fi,{name:"log-out",size:16})})]}),U&&u.jsxs(Xc,{ref:R,id:"iwer-input-mode-menu",role:"group","aria-label":"Input mode",$left:G,children:[u.jsxs(qc,{children:[u.jsx(Fi,{name:"gamepad-2",size:15}),u.jsx($c,{children:"Input setup"})]}),u.jsxs(Yc,{type:"button","aria-pressed":"controller"===X,"data-autofocus":"controller"===X,$selected:"controller"===X,onClick:e=>K("controller",0===e.detail),children:[u.jsx(Fi,{name:"gamepad-2",size:15}),u.jsxs(Kc,{children:[u.jsx(Zc,{children:"Controllers"}),u.jsx(Jc,{children:"Ray + trigger"})]}),"controller"===X?u.jsx(Fi,{name:"circle-dot",size:14,color:on}):u.jsx("span",{"aria-hidden":"true"})]}),u.jsxs(Yc,{type:"button","aria-pressed":"hand"===X,"data-autofocus":"hand"===X,$selected:"hand"===X,onClick:e=>K("hand",0===e.detail),children:[u.jsx(Fi,{name:"hand",size:15}),u.jsxs(Kc,{children:[u.jsx(Zc,{children:"Hands"}),u.jsx(Jc,{children:"Ray, poke + grab"})]}),"hand"===X?u.jsx(Fi,{name:"circle-dot",size:14,color:on}):u.jsx("span",{"aria-hidden":"true"})]}),u.jsxs(Yc,{type:"button","aria-pressed":"gaze-hands"===X,"data-autofocus":"gaze-hands"===X,"aria-disabled":!w.supported,"aria-describedby":w.supported?void 0:"iwer-gaze-preset-hint",$selected:"gaze-hands"===X,$unavailable:!w.supported,title:w.supported?"Use cursor gaze with hand pinch":"Select a gaze-capable device profile first",onClick:e=>{w.supported&&K("gaze-hands",0===e.detail)},children:[u.jsx(Fi,{name:"eye",size:15}),u.jsxs(Kc,{children:[u.jsx(Zc,{children:"Gaze + Hands"}),u.jsx(Jc,{children:"Look, then pinch"})]}),"gaze-hands"===X?u.jsx(Fi,{name:"circle-dot",size:14,color:on}):u.jsx("span",{"aria-hidden":"true"})]}),!w.supported&&u.jsx(Jc,{id:"iwer-gaze-preset-hint",style:{padding:"4px"},children:"Needs an eye-tracking profile, such as Meta Quest Pro."}),null==X&&u.jsxs(Jc,{style:{padding:"5px 4px 2px"},children:["Custom · ","controller"===g?"Controllers":"Hands"," + ","head-locked"===y?"head gaze":"cursor gaze"]})]}),B&&u.jsxs(Xc,{ref:C,id:"iwer-gaze-settings",role:"group","aria-label":"Gaze emulation settings",$left:H,children:[u.jsxs(qc,{children:[u.jsx(Fi,{name:"eye",size:15}),u.jsx($c,{children:"Gaze emulation"}),u.jsx(Bn,{title:"Close gaze settings",onClick:e=>{var t;V(!1),0===e.detail&&(null===(t=T.current)||void 0===t||t.focus())},children:u.jsx(Fi,{name:"circle-x",size:14})})]}),u.jsxs(nu,{"aria-live":"polite",children:[u.jsx(iu,{$tone:q}),u.jsx("span",{children:$})]}),u.jsx(Qc,{id:"iwer-gaze-mode-label",children:"Gaze mode"}),u.jsx(eu,{role:"radiogroup","aria-label":"Gaze mode","aria-labelledby":"iwer-gaze-mode-label","aria-disabled":!w.supported,$unavailable:!w.supported,children:fu.map(({value:e,label:t})=>u.jsx(tu,{type:"button",role:"radio","aria-checked":y===e,"aria-disabled":!w.supported,tabIndex:y===e?0:-1,"data-autofocus":y===e,$selected:y===e,$unavailable:!w.supported,onClick:()=>Z(e),onKeyDown:t=>((e,t)=>{var n,i;if(!w.supported)return;const r="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0;if(0===r)return;e.preventDefault();const s=fu.findIndex(e=>e.value===t),a=fu[(s+r+fu.length)%fu.length];Z(a.value);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.querySelectorAll('[role="radio"]');null===(i=null==o?void 0:o["off"===a.value?0:"cursor"===a.value?1:2])||void 0===i||i.focus()})(t,e),children:t},e))}),u.jsx(Qc,{id:"iwer-gaze-hand-label",children:"Commit hand"}),u.jsx(eu,{role:"radiogroup","aria-label":"Gaze commit hand","aria-labelledby":"iwer-gaze-hand-label","aria-disabled":"off"===y||!w.supported,$unavailable:"off"===y||!w.supported,children:mu.map(({value:e,label:t})=>u.jsx(tu,{type:"button",role:"radio","aria-checked":b===e,"aria-disabled":"off"===y||!w.supported,tabIndex:b===e?0:-1,$selected:b===e,$unavailable:"off"===y||!w.supported,onClick:()=>{"off"!==y&&w.supported&&Y(e)},onKeyDown:t=>((e,t)=>{var n,i;if("off"===y||!w.supported)return;const r="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0;if(0===r)return;e.preventDefault();const s=mu.findIndex(e=>e.value===t),a=mu[(s+r+mu.length)%mu.length];Y(a.value);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.querySelectorAll('[role="radio"]');null===(i=null==o?void 0:o["left"===a.value?0:1])||void 0===i||i.focus()})(t,e),children:t},e))}),u.jsxs(Jc,{style:{padding:"3px 2px 1px"},children:["hand"===g?"Pinch":"Trigger"," confirms the gaze target."]}),"cursor"===y&&w.sessionActive&&w.connected&&u.jsxs(u.Fragment,{children:[u.jsx(zn,{}),u.jsx(Qc,{children:"Cursor controls"}),u.jsxs(ru,{children:[u.jsxs(su,{children:[u.jsx(Fi,{name:"mouse-left",size:14}),u.jsxs("span",{children:["Aim + commit · drag to move"," ","hand"===g?"hand":"controller"]})]}),u.jsxs(su,{children:[u.jsx(Fi,{name:"mouse-right",size:14}),u.jsx("span",{children:"Drag to look around"})]}),u.jsxs(su,{children:[u.jsx(Fi,{name:"mouse",size:14}),u.jsx("span",{children:"While held, wheel to adjust depth"})]}),u.jsxs(su,{children:[u.jsx(au,{children:"Space"}),u.jsx("span",{children:"Reset commit-hand pose"})]})]}),u.jsx(Jc,{style:{padding:"3px 2px 1px"},children:"Play mode is unavailable while cursor gaze is on."})]})]}),F&&u.jsxs(Xc,{ref:P,id:"iwer-headset-settings",role:"group","aria-label":"Headset position",$left:W,children:[u.jsxs(qc,{tabIndex:-1,"data-autofocus":"true",style:{fontSize:"13px",fontWeight:600},children:[u.jsx(Fi,{name:"glasses",size:15}),e.name]}),u.jsx(zn,{}),u.jsx(Mr,{vector:t.combinedCameraPosition,label:"Pos"})]}),N&&u.jsxs(Xc,{ref:I,id:"iwer-environment-menu",role:"group","aria-label":"Emulated environment",$left:j,children:[hu(e).map(({label:e,ids:t})=>{const n=t.map(Q);if(!e)return u.jsx(c.Fragment,{children:n},"current");const i="iwer-environment-group-"+e.replace(/\W+/g,"-");return u.jsxs("div",{role:"group","aria-labelledby":i,children:[u.jsx(du,{id:i,children:e}),n]},e)}),Q("none")]})]}),u.jsxs(Mn,{children:[u.jsx(Tn,{title:"About IWER",onClick:()=>{D(!L),z(!1),V(!1),k(!1),O(!1)},children:u.jsx(Fi,{name:"iwer",size:16})}),u.jsx(Tn,{title:"Report issues",onClick:()=>window.open("https://github.com/meta-quest/immersive-web-emulation-runtime/issues","_blank"),children:u.jsx(Fi,{name:"bug",size:16})})]}),L&&u.jsxs(Un,{style:{top:"50vh",left:"50vw",transform:"translate(-50%, -50%)",maxWidth:"240px",gap:"4px",padding:"16px"},children:[u.jsx("div",{style:{display:"flex",justifyContent:"end"},children:u.jsx(Bn,{$isRed:!0,onClick:()=>D(!1),children:u.jsx(Fi,{name:"circle-x",size:14})})}),u.jsx("div",{style:{display:"flex",justifyContent:"center"},children:u.jsx(Fi,{name:"iwer",size:72})}),u.jsxs("p",{style:{textAlign:"center",padding:"0 5px",margin:"0"},children:[u.jsx("b",{children:"Immersive Web Emulation Runtime"})," (IWER) is a free, open-source WebXR developer tool created by Meta Platforms, Inc."]}),u.jsx("table",{style:{width:"100%",borderCollapse:"collapse",display:"flex",justifyContent:"center",fontSize:"12px",padding:"8px"},children:u.jsxs("tbody",{children:[u.jsxs("tr",{children:[u.jsx(Wc,{children:"IWER"}),u.jsxs(jc,{children:["v",e.version]})]}),u.jsxs("tr",{children:[u.jsx(Wc,{children:"DevUI"}),u.jsxs(jc,{children:["v",e.devui.version]})]}),e.sem&&u.jsxs("tr",{children:[u.jsx(Wc,{children:"SEM"}),u.jsxs(jc,{children:["v",e.sem.version]})]})]})}),u.jsx(Sn,{style:{borderRadius:yn},onClick:()=>window.open("https://github.com/meta-quest/immersive-web-emulation-runtime/blob/main/LICENSE","_blank"),children:"MIT License"}),u.jsx(Sn,{style:{borderRadius:yn},onClick:()=>window.open("https://github.com/meta-quest/immersive-web-emulation-runtime","_blank"),children:"View Source on GitHub"})]})]})},vu="185",yu=1,xu=3,bu=0,_u=1,wu=2,Su=100,Mu=101,Tu=102,Eu=200,Au=201,Ru=202,Cu=203,Pu=204,Iu=205,Lu=206,Du=207,Nu=208,Ou=209,Fu=210,ku=211,Uu=212,zu=213,Bu=214,Vu=0,Gu=1,Hu=2,Wu=3,ju=4,Xu=5,qu=6,$u=7,Yu=0,Ku=1,Zu=2,Ju=0,Qu=1,eh=2,th=3,nh=4,ih=5,rh=6,sh=7,ah="attached",oh="detached",lh=300,ch=301,uh=302,hh=303,dh=304,ph=306,fh=1e3,mh=1001,gh=1002,vh=1003,yh=1004,xh=1005,bh=1006,_h=1007,wh=1008,Sh=1009,Mh=1010,Th=1011,Eh=1012,Ah=1013,Rh=1014,Ch=1015,Ph=1016,Ih=1017,Lh=1018,Dh=1020,Nh=35902,Oh=35899,Fh=1021,kh=1022,Uh=1023,zh=1026,Bh=1027,Vh=1028,Gh=1029,Hh=1030,Wh=1031,jh=1033,Xh=33776,qh=33777,$h=33778,Yh=33779,Kh=35840,Zh=35841,Jh=35842,Qh=35843,ed=36196,td=37492,nd=37496,id=37488,rd=37489,sd=37490,ad=37491,od=37808,ld=37809,cd=37810,ud=37811,hd=37812,dd=37813,pd=37814,fd=37815,md=37816,gd=37817,vd=37818,yd=37819,xd=37820,bd=37821,_d=36492,wd=36494,Sd=36495,Md=36283,Td=36284,Ed=36285,Ad=36286,Rd=2300,Cd=2301,Pd=2302,Id=2303,Ld=2400,Dd=2401,Nd=2402,Od=2500,Fd=2501,kd="",Ud="srgb",zd="srgb-linear",Bd="linear",Vd="srgb",Gd=7680,Hd=512,Wd=513,jd=514,Xd=515,qd=516,$d=517,Yd=518,Kd=519,Zd=35044,Jd="300 es",Qd=2e3,ep=2001;const tp={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function np(e,t){return new tp[e](t)}function ip(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rp(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function sp(){const e=rp("canvas");return e.style.display="block",e}const ap={};let op=null;function lp(...e){const t="THREE."+e.shift();op?op("log",t,...e):console.log(t,...e)}function cp(e){const t=e[0];if("string"==typeof t&&t.startsWith("TSL:")){const t=e[1];t&&t.isStackTrace?e[0]+=" "+t.getLocation():e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function up(...e){const t="THREE."+(e=cp(e)).shift();if(op)op("warn",t,...e);else{const n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function hp(...e){const t="THREE."+(e=cp(e)).shift();if(op)op("error",t,...e);else{const n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function dp(...e){const t=e.join(" ");t in ap||(ap[t]=!0,up(...e))}const pp={[Vu]:1,[Hu]:6,[ju]:7,[Wu]:5,[Gu]:0,[qu]:2,[$u]:4,[Xu]:3};class fp{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return void 0!==n&&(void 0!==n[e]&&-1!==n[e].indexOf(t))}removeEventListener(e,t){const n=this._listeners;if(void 0===n)return;const i=n[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){const t=this._listeners;if(void 0===t)return;const n=t[e.type];if(void 0!==n){e.target=this;const t=n.slice(0);for(let n=0,i=t.length;n<i;n++)t[n].call(this,e);e.target=null}}}const mp=["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 gp=1234567;const vp=Math.PI/180,yp=180/Math.PI;function xp(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(mp[255&e]+mp[e>>8&255]+mp[e>>16&255]+mp[e>>24&255]+"-"+mp[255&t]+mp[t>>8&255]+"-"+mp[t>>16&15|64]+mp[t>>24&255]+"-"+mp[63&n|128]+mp[n>>8&255]+"-"+mp[n>>16&255]+mp[n>>24&255]+mp[255&i]+mp[i>>8&255]+mp[i>>16&255]+mp[i>>24&255]).toLowerCase()}function bp(e,t,n){return Math.max(t,Math.min(n,e))}function _p(e,t){return(e%t+t)%t}function wp(e,t,n){return(1-n)*e+n*t}function Sp(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Mp(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const Tp={DEG2RAD:vp,RAD2DEG:yp,generateUUID:xp,clamp:bp,euclideanModulo:_p,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:wp,damp:function(e,t,n,i){return wp(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(_p(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(gp=e);let t=gp+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*vp},radToDeg:function(e){return e*yp},isPowerOfTwo:function(e){return!(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((t+i)/2),u=a((t+i)/2),h=s((t-i)/2),d=a((t-i)/2),p=s((i-t)/2),f=a((i-t)/2);switch(r){case"XYX":e.set(o*u,l*h,l*d,o*c);break;case"YZY":e.set(l*d,o*u,l*h,o*c);break;case"ZXZ":e.set(l*h,l*d,o*u,o*c);break;case"XZX":e.set(o*u,l*f,l*p,o*c);break;case"YXY":e.set(l*p,o*u,l*f,o*c);break;case"ZYZ":e.set(l*f,l*p,o*u,o*c);break;default:up("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Mp,denormalize:Sp};let Ep=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=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("THREE.Vector2: 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("THREE.Vector2: 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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=bp(this.x,e.x,t.x),this.y=bp(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=bp(this.x,e,t),this.y=bp(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(bp(n,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(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(bp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ap=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,a){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],h=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(u!==f||o!==h||l!==d||c!==p){let e=o*h+l*d+c*p+u*f;e<0&&(h=-h,d=-d,p=-p,f=-f,e=-e);let t=1-a;if(e<.9995){const n=Math.acos(e),i=Math.sin(n);t=Math.sin(t*n)/i,o=o*t+h*(a=Math.sin(a*n)/i),l=l*t+d*a,c=c*t+p*a,u=u*t+f*a}else{o=o*t+h*a,l=l*t+d*a,c=c*t+p*a,u=u*t+f*a;const e=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=e,l*=e,c*=e,u*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=r[s],h=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*u+o*d-l*h,e[t+1]=o*p+c*h+l*u-a*d,e[t+2]=l*p+c*d+a*h-o*u,e[t+3]=c*p-a*u-o*h-l*d,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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 n=e._x,i=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),u=a(r/2),h=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"YXZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"ZXY":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"ZYX":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"YZX":this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p;break;case"XZY":this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p;break;default:up("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],l=t[2],c=t[6],u=t[10],h=n+a+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(s-i)*e}else if(n>a&&n>u){const e=2*Math.sqrt(1+n-a-u);this._w=(c-o)/e,this._x=.25*e,this._y=(i+s)/e,this._z=(r+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-n-u);this._w=(r-l)/e,this._x=(i+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+u-n-a);this._w=(s-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(bp(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),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 0===e?(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 n=e._x,i=e._y,r=e._z,s=e._w,a=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,r=e._z,s=e._w,a=this.dot(e);a<0&&(n=-n,i=-i,r=-r,s=-s,a=-a);let o=1-t;if(a<.9995){const e=Math.acos(a),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*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}},Rp=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,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("THREE.Vector3: 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("THREE.Vector3: 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(Pp.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Pp.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,s=e.y,a=e.z,o=e.w,l=2*(s*i-a*n),c=2*(a*t-r*i),u=2*(r*n-s*t);return this.x=t+o*l+s*u-a*c,this.y=n+o*c+a*l-r*u,this.z=i+o*u+r*c-s*l,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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=bp(this.x,e.x,t.x),this.y=bp(this.y,e.y,t.y),this.z=bp(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=bp(this.x,e,t),this.y=bp(this.y,e,t),this.z=bp(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(bp(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Cp.copy(this).projectOnVector(e),this.sub(Cp)}reflect(e){return this.sub(Cp.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(bp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Cp=new Rp,Pp=new Ap;class Ip{static{Ip.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,a,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l)}set(e,t,n,i,r,s,a,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],u=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],b=i[2],_=i[5],w=i[8];return r[0]=s*f+a*v+o*b,r[3]=s*m+a*y+o*_,r[6]=s*g+a*x+o*w,r[1]=l*f+c*v+u*b,r[4]=l*m+c*y+u*_,r[7]=l*g+c*x+u*w,r[2]=h*f+d*v+p*b,r[5]=h*m+d*y+p*_,r[8]=h*g+d*x+p*w,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],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*s*c-t*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],u=c*s-a*l,h=a*o-c*r,d=l*r-s*o,p=t*u+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=u*f,e[1]=(i*l-c*n)*f,e[2]=(a*n-i*s)*f,e[3]=h*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-a*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(s*t-n*r)*f,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,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-i*l,i*o,-i*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return dp("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lp.makeScale(e,t)),this}rotate(e){return dp("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lp.makeRotation(-e)),this}translate(e,t){return dp("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lp.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Lp=new Ip,Dp=(new Ip).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Np=(new Ip).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Op(){const e={enabled:!0,workingColorSpace:zd,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n?(this.spaces[t].transfer===Vd&&(e.r=kp(e.r),e.g=kp(e.g),e.b=kp(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Vd&&(e.r=Up(e.r),e.g=Up(e.g),e.b=Up(e.b)),e):e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===kd?Bd:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return dp("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return dp("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return e.define({[zd]:{primaries:t,whitePoint:i,transfer:Bd,toXYZ:Dp,fromXYZ:Np,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ud},outputColorSpaceConfig:{drawingBufferColorSpace:Ud}},[Ud]:{primaries:t,whitePoint:i,transfer:Vd,toXYZ:Dp,fromXYZ:Np,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ud}}}),e}const Fp=Op();function kp(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Up(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let zp;class Bp{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{void 0===zp&&(zp=rp("canvas")),zp.width=e.width,zp.height=e.height;const t=zp.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=zp}return n.toDataURL(t)}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=rp("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e<r.length;e++)r[e]=255*kp(r[e]/255);return n.putImageData(i,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*kp(t[e]/255)):t[e]=kp(t[e]);return{data:t,width:e.width,height:e.height}}return up("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Vp=0;class Gp{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Vp++}),this.uuid=xp(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(Hp(i[t].image)):e.push(Hp(i[t]))}else e=Hp(i);n.url=e}return t||(e.images[this.uuid]=n),n}}function Hp(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Bp.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(up("Texture: Unable to serialize Texture."),{})}let Wp=0;const jp=new Rp;class Xp extends fp{constructor(e=Xp.DEFAULT_IMAGE,t=Xp.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=Sh,l=Xp.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Wp++}),this.uuid=xp(),this.name="",this.source=new Gp(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Ep(0,0),this.repeat=new Ep(1,1),this.center=new Ep(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ip,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,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,this.normalized=!1}get width(){return this.source.getSize(jp).x}get height(){return this.source.getSize(jp).y}get depth(){return this.source.getSize(jp).z}get image(){return this.source.data}set image(e){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.normalized=e.normalized,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 n=e[t];if(void 0===n){up(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n:up(`Texture.setValues(): property '${t}' does not exist.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={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,normalized:this.normalized,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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==lh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case fh:e.x=e.x-Math.floor(e.x);break;case mh:e.x=e.x<0?0:1;break;case gh:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case fh:e.y=e.y-Math.floor(e.y);break;case mh:e.y=e.y<0?0:1;break;case gh:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}Xp.DEFAULT_IMAGE=null,Xp.DEFAULT_MAPPING=lh,Xp.DEFAULT_ANISOTROPY=1;class qp{static{qp.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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("THREE.Vector4: 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("THREE.Vector4: 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=void 0!==e.w?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,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+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,n,i,r;const s=.01,a=.1,o=e.elements,l=o[0],c=o[4],u=o[8],h=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-h)<s&&Math.abs(u-f)<s&&Math.abs(p-m)<s){if(Math.abs(c+h)<a&&Math.abs(u+f)<a&&Math.abs(p+m)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,o=(d+1)/2,v=(g+1)/2,y=(c+h)/4,x=(u+f)/4,b=(p+m)/4;return e>o&&e>v?e<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=y/n,r=x/n):o>v?o<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=y/i,r=b/i):v<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=x/r,i=b/r),this.set(n,i,r,t),this}let v=Math.sqrt((m-p)*(m-p)+(u-f)*(u-f)+(h-c)*(h-c));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(u-f)/v,this.z=(h-c)/v,this.w=Math.acos((l+d+g-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=bp(this.x,e.x,t.x),this.y=bp(this.y,e.y,t.y),this.z=bp(this.z,e.z,t.z),this.w=bp(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=bp(this.x,e,t),this.y=bp(this.y,e,t),this.z=bp(this.z,e,t),this.w=bp(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(bp(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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 $p extends fp{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:bh,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new qp(0,0,e,t),this.scissorTest=!1,this.viewport=new qp(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},r=new Xp(i),s=n.count;for(let e=0;e<s;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:bh,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==e.mapping&&(t.mapping=e.mapping),void 0!==e.wrapS&&(t.wrapS=e.wrapS),void 0!==e.wrapT&&(t.wrapT=e.wrapT),void 0!==e.wrapR&&(t.wrapR=e.wrapR),void 0!==e.magFilter&&(t.magFilter=e.magFilter),void 0!==e.minFilter&&(t.minFilter=e.minFilter),void 0!==e.format&&(t.format=e.format),void 0!==e.type&&(t.type=e.type),void 0!==e.anisotropy&&(t.anisotropy=e.anisotropy),void 0!==e.colorSpace&&(t.colorSpace=e.colorSpace),void 0!==e.flipY&&(t.flipY=e.flipY),void 0!==e.generateMipmaps&&(t.generateMipmaps=e.generateMipmaps),void 0!==e.internalFormat&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){this.textures[e].setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,!0!==this.textures[i].isData3DTexture&&(this.textures[i].isArrayTexture=this.textures[i].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,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new Gp(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Yp extends $p{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Kp extends Xp{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=vh,this.minFilter=vh,this.wrapR=mh,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Zp extends Xp{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=vh,this.minFilter=vh,this.wrapR=mh,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Jp{static{Jp.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,a,o,l,c,u,h,d,p,f,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l,c,u,h,d,p,f,m)}set(e,t,n,i,r,s,a,o,l,c,u,h,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,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 Jp).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return 0===this.determinantAffine()?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(0===e.determinantAffine())return this.identity();const t=this.elements,n=e.elements,i=1/Qp.setFromMatrixColumn(e,0).length(),r=1/Qp.setFromMatrixColumn(e,1).length(),s=1/Qp.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=s*c,n=s*u,i=a*c,r=a*u;t[0]=o*c,t[4]=-o*u,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,n=o*u,i=l*c,r=l*u;t[0]=e+r*a,t[4]=i*a-n,t[8]=s*l,t[1]=s*u,t[5]=s*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,n=o*u,i=l*c,r=l*u;t[0]=e-r*a,t[4]=-s*u,t[8]=i+n*a,t[1]=n+i*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,n=s*u,i=a*c,r=a*u;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*u,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=r-e*u,t[8]=i*u+n,t[1]=u,t[5]=s*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=s*c,t[9]=n*u-i,t[2]=i*u-n,t[6]=a*c,t[10]=r*u+e}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(tf,e,nf)}lookAt(e,t,n){const i=this.elements;return af.subVectors(e,t),0===af.lengthSq()&&(af.z=1),af.normalize(),rf.crossVectors(n,af),0===rf.lengthSq()&&(1===Math.abs(n.z)?af.x+=1e-4:af.z+=1e-4,af.normalize(),rf.crossVectors(n,af)),rf.normalize(),sf.crossVectors(af,rf),i[0]=rf.x,i[4]=sf.x,i[8]=af.x,i[1]=rf.y,i[5]=sf.y,i[9]=af.y,i[2]=rf.z,i[6]=sf.z,i[10]=af.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],b=n[15],_=i[0],w=i[4],S=i[8],M=i[12],T=i[1],E=i[5],A=i[9],R=i[13],C=i[2],P=i[6],I=i[10],L=i[14],D=i[3],N=i[7],O=i[11],F=i[15];return r[0]=s*_+a*T+o*C+l*D,r[4]=s*w+a*E+o*P+l*N,r[8]=s*S+a*A+o*I+l*O,r[12]=s*M+a*R+o*L+l*F,r[1]=c*_+u*T+h*C+d*D,r[5]=c*w+u*E+h*P+d*N,r[9]=c*S+u*A+h*I+d*O,r[13]=c*M+u*R+h*L+d*F,r[2]=p*_+f*T+m*C+g*D,r[6]=p*w+f*E+m*P+g*N,r[10]=p*S+f*A+m*I+g*O,r[14]=p*M+f*R+m*L+g*F,r[3]=v*_+y*T+x*C+b*D,r[7]=v*w+y*E+x*P+b*N,r[11]=v*S+y*A+x*I+b*O,r[15]=v*M+y*R+x*L+b*F,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],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],l=e[13],c=e[2],u=e[6],h=e[10],d=e[14],p=e[3],f=e[7],m=e[11],g=e[15],v=o*d-l*h,y=a*d-l*u,x=a*h-o*u,b=s*d-l*c,_=s*h-o*c,w=s*u-a*c;return t*(f*v-m*y+g*x)-n*(p*v-m*b+g*_)+i*(p*y-f*b+g*w)-r*(p*x-f*_+m*w)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],a=e[9],o=e[2],l=e[6],c=e[10];return t*(s*c-a*l)-n*(r*c-a*o)+i*(r*l-s*o)}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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=t*a-n*s,y=t*o-i*s,x=t*l-r*s,b=n*o-i*a,_=n*l-r*a,w=i*l-r*o,S=c*f-u*p,M=c*m-h*p,T=c*g-d*p,E=u*m-h*f,A=u*g-d*f,R=h*g-d*m,C=v*R-y*A+x*E+b*T-_*M+w*S;if(0===C)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/C;return e[0]=(a*R-o*A+l*E)*P,e[1]=(i*A-n*R-r*E)*P,e[2]=(f*w-m*_+g*b)*P,e[3]=(h*_-u*w-d*b)*P,e[4]=(o*T-s*R-l*M)*P,e[5]=(t*R-i*T+r*M)*P,e[6]=(m*x-p*w-g*y)*P,e[7]=(c*w-h*x+d*y)*P,e[8]=(s*A-a*T+l*S)*P,e[9]=(n*T-t*A-r*S)*P,e[10]=(p*_-f*x+g*v)*P,e[11]=(u*x-c*_-d*v)*P,e[12]=(a*M-s*E-o*S)*P,e[13]=(t*E-n*M+i*S)*P,e[14]=(f*y-p*b-m*v)*P,e[15]=(c*b-u*y+h*v)*P,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,s=e.x,a=e.y,o=e.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,l=r+r,c=s+s,u=a+a,h=r*l,d=r*c,p=r*u,f=s*c,m=s*u,g=a*u,v=o*l,y=o*c,x=o*u,b=n.x,_=n.y,w=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*_,i[5]=(1-(h+g))*_,i[6]=(m+v)*_,i[7]=0,i[8]=(p+y)*w,i[9]=(m-v)*w,i[10]=(1-(h+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinantAffine();if(0===r)return n.set(1,1,1),t.identity(),this;let s=Qp.set(i[0],i[1],i[2]).length();const a=Qp.set(i[4],i[5],i[6]).length(),o=Qp.set(i[8],i[9],i[10]).length();r<0&&(s=-s),ef.copy(this);const l=1/s,c=1/a,u=1/o;return ef.elements[0]*=l,ef.elements[1]*=l,ef.elements[2]*=l,ef.elements[4]*=c,ef.elements[5]*=c,ef.elements[6]*=c,ef.elements[8]*=u,ef.elements[9]*=u,ef.elements[10]*=u,t.setFromRotationMatrix(ef),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,s,a=2e3,o=!1){const l=this.elements,c=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let p,f;if(o)p=r/(s-r),f=s*r/(s-r);else if(a===Qd)p=-(s+r)/(s-r),f=-2*s*r/(s-r);else{if(a!==ep)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);p=-s/(s-r),f=-s*r/(s-r)}return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2e3,o=!1){const l=this.elements,c=2/(t-e),u=2/(n-i),h=-(t+e)/(t-e),d=-(n+i)/(n-i);let p,f;if(o)p=1/(s-r),f=s/(s-r);else if(a===Qd)p=-2/(s-r),f=-(s+r)/(s-r);else{if(a!==ep)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=-1/(s-r),f=-r/(s-r)}return l[0]=c,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=u,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Qp=new Rp,ef=new Jp,tf=new Rp(0,0,0),nf=new Rp(1,1,1),rf=new Rp,sf=new Rp,af=new Rp,of=new Jp,lf=new Ap;class cf{constructor(e=0,t=0,n=0,i=cf.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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,n=!0){const i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],u=i[2],h=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(bp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-bp(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(bp(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-bp(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(bp(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-bp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:up("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return of.makeRotationFromQuaternion(e),this.setFromRotationMatrix(of,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lf.setFromEuler(this),this.setFromQuaternion(lf,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],void 0!==e[3]&&(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}}cf.DEFAULT_ORDER="XYZ";class uf{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return 0!==(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let hf=0;const df=new Rp,pf=new Ap,ff=new Jp,mf=new Rp,gf=new Rp,vf=new Rp,yf=new Ap,xf=new Rp(1,0,0),bf=new Rp(0,1,0),_f=new Rp(0,0,1),wf={type:"added"},Sf={type:"removed"},Mf={type:"childadded",child:null},Tf={type:"childremoved",child:null};class Ef extends fp{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:hf++}),this.uuid=xp(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ef.DEFAULT_UP.clone();const e=new Rp,t=new cf,n=new Ap,i=new Rp(1,1,1);t._onChange(function(){n.setFromEuler(t,!1)}),n._onChange(function(){t.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Jp},normalMatrix:{value:new Ip}}),this.matrix=new Jp,this.matrixWorld=new Jp,this.matrixAutoUpdate=Ef.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ef.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uf,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.static=!1,this.userData={},this.pivot=null}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 pf.setFromAxisAngle(e,t),this.quaternion.multiply(pf),this}rotateOnWorldAxis(e,t){return pf.setFromAxisAngle(e,t),this.quaternion.premultiply(pf),this}rotateX(e){return this.rotateOnAxis(xf,e)}rotateY(e){return this.rotateOnAxis(bf,e)}rotateZ(e){return this.rotateOnAxis(_f,e)}translateOnAxis(e,t){return df.copy(e).applyQuaternion(this.quaternion),this.position.add(df.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xf,e)}translateY(e){return this.translateOnAxis(bf,e)}translateZ(e){return this.translateOnAxis(_f,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ff.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?mf.copy(e):mf.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),gf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ff.lookAt(gf,mf,this.up):ff.lookAt(mf,gf,this.up),this.quaternion.setFromRotationMatrix(ff),i&&(ff.extractRotation(i.matrixWorld),pf.setFromRotationMatrix(ff),this.quaternion.premultiply(pf.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(hp("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(wf),Mf.child=e,this.dispatchEvent(Mf),Mf.child=null):hp("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Sf),Tf.child=e,this.dispatchEvent(Tf),Tf.child=null),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ff.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),ff.multiply(e.parent.matrixWorld)),e.applyMatrix4(ff),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(wf),Mf.child=e,this.dispatchEvent(Mf),Mf.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 n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gf,e,vf),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gf,yf,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(null!==e){const t=e.x,n=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){t[n].updateMatrixWorld(e)}}updateWorldMatrix(e,t,n=!1){const i=this.parent;if(!0===e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),!0===t){const e=this.children;for(let t=0,i=e.length;t<i;t++){e[t].updateWorldMatrix(!1,!0,n)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),!1!==this.static&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),null!==this.pivot&&(i.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(e=>({...e})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const i=n[t];r(e.shapes,i)}else r(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(r(e.materials,this.material[n]));i.material=t}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];i.animations.push(r(e.animations,n))}}if(t){const t=s(e.geometries),i=s(e.materials),r=s(e.textures),a=s(e.images),o=s(e.shapes),l=s(e.skeletons),c=s(e.animations),u=s(e.nodes);t.length>0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=i,n;function s(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}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.pivot=null!==e.pivot?e.pivot.clone():null,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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}Ef.DEFAULT_UP=new Rp(0,1,0),Ef.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ef.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Af extends Ef{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Rf={type:"move"};class Cf{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Af,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Af,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Rp,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Rp),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Af,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Rp,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Rp,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){s=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,n),r=this._getHandJoint(l,i);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&a>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,o.eventsEnabled&&o.dispatchEvent({type:"gripUpdated",data:e,target:this})));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Rf)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Af;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Pf={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},If={h:0,s:0,l:0},Lf={h:0,s:0,l:0};function Df(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class Nf{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ud){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Fp.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Fp.workingColorSpace){return this.r=e,this.g=t,this.b=n,Fp.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Fp.workingColorSpace){if(e=_p(e,1),t=bp(t,0,1),n=bp(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=Df(r,i,e+1/3),this.g=Df(r,i,e),this.b=Df(r,i,e-1/3)}return Fp.colorSpaceToWorking(this,i),this}setStyle(e,t=Ud){function n(t){void 0!==t&&parseFloat(t)<1&&up("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(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(a))return n(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(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:up("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);up("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ud){const n=Pf[e.toLowerCase()];return void 0!==n?this.setHex(n,t):up("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=kp(e.r),this.g=kp(e.g),this.b=kp(e.b),this}copyLinearToSRGB(e){return this.r=Up(e.r),this.g=Up(e.g),this.b=Up(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ud){return Fp.workingToColorSpace(Of.copy(this),e),65536*Math.round(bp(255*Of.r,0,255))+256*Math.round(bp(255*Of.g,0,255))+Math.round(bp(255*Of.b,0,255))}getHexString(e=Ud){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Fp.workingColorSpace){Fp.workingToColorSpace(Of.copy(this),t);const n=Of.r,i=Of.g,r=Of.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=c<=.5?e/(s+a):e/(2-s-a),s){case n:o=(i-r)/e+(i<r?6:0);break;case i:o=(r-n)/e+2;break;case r:o=(n-i)/e+4}o/=6}return e.h=o,e.s=l,e.l=c,e}getRGB(e,t=Fp.workingColorSpace){return Fp.workingToColorSpace(Of.copy(this),t),e.r=Of.r,e.g=Of.g,e.b=Of.b,e}getStyle(e=Ud){Fp.workingToColorSpace(Of.copy(this),e);const t=Of.r,n=Of.g,i=Of.b;return e!==Ud?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(e,t,n){return this.getHSL(If),this.setHSL(If.h+e,If.s+t,If.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(If),e.getHSL(Lf);const n=wp(If.h,Lf.h,t),i=wp(If.s,Lf.s,t),r=wp(If.l,Lf.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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 Of=new Nf;Nf.NAMES=Pf;class Ff{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Nf(e),this.density=t}clone(){return new Ff(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class kf{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Nf(e),this.near=t,this.far=n}clone(){return new kf(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Uf extends Ef{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 cf,this.environmentIntensity=1,this.environmentRotation=new cf,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(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),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const zf=new Rp,Bf=new Rp,Vf=new Rp,Gf=new Rp,Hf=new Rp,Wf=new Rp,jf=new Rp,Xf=new Rp,qf=new Rp,$f=new Rp,Yf=new qp,Kf=new qp,Zf=new qp;class Jf{constructor(e=new Rp,t=new Rp,n=new Rp){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zf.subVectors(e,t),i.cross(zf);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){zf.subVectors(i,t),Bf.subVectors(n,t),Vf.subVectors(e,t);const s=zf.dot(zf),a=zf.dot(Bf),o=zf.dot(Vf),l=Bf.dot(Bf),c=Bf.dot(Vf),u=s*l-a*a;if(0===u)return r.set(0,0,0),null;const h=1/u,d=(l*o-a*c)*h,p=(s*c-a*o)*h;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,Gf)&&(Gf.x>=0&&Gf.y>=0&&Gf.x+Gf.y<=1)}static getInterpolation(e,t,n,i,r,s,a,o){return null===this.getBarycoord(e,t,n,i,Gf)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Gf.x),o.addScaledVector(s,Gf.y),o.addScaledVector(a,Gf.z),o)}static getInterpolatedAttribute(e,t,n,i,r,s){return Yf.setScalar(0),Kf.setScalar(0),Zf.setScalar(0),Yf.fromBufferAttribute(e,t),Kf.fromBufferAttribute(e,n),Zf.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Yf,r.x),s.addScaledVector(Kf,r.y),s.addScaledVector(Zf,r.z),s}static isFrontFacing(e,t,n,i){return zf.subVectors(n,t),Bf.subVectors(e,t),zf.cross(Bf).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 zf.subVectors(this.c,this.b),Bf.subVectors(this.a,this.b),.5*zf.cross(Bf).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Jf.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Jf.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Jf.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Jf.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Jf.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let s,a;Hf.subVectors(i,n),Wf.subVectors(r,n),Xf.subVectors(e,n);const o=Hf.dot(Xf),l=Wf.dot(Xf);if(o<=0&&l<=0)return t.copy(n);qf.subVectors(e,i);const c=Hf.dot(qf),u=Wf.dot(qf);if(c>=0&&u<=c)return t.copy(i);const h=o*u-c*l;if(h<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(n).addScaledVector(Hf,s);$f.subVectors(e,r);const d=Hf.dot($f),p=Wf.dot($f);if(p>=0&&d<=p)return t.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Wf,a);const m=c*p-d*u;if(m<=0&&u-c>=0&&d-p>=0)return jf.subVectors(r,i),a=(u-c)/(u-c+(d-p)),t.copy(i).addScaledVector(jf,a);const g=1/(m+f+h);return s=f*g,a=h*g,t.copy(n).addScaledVector(Hf,s).addScaledVector(Wf,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Qf{constructor(e=new Rp(1/0,1/0,1/0),t=new Rp(-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,n=e.length;t<n;t+=3)this.expandByPoint(tm.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(tm.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=tm.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 n=e.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===t&&void 0!==i&&!0!==e.isInstancedMesh)for(let t=0,n=i.count;t<n;t++)!0===e.isMesh?e.getVertexPosition(t,tm):tm.fromBufferAttribute(i,t),tm.applyMatrix4(e.matrixWorld),this.expandByPoint(tm);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),nm.copy(e.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),nm.copy(n.boundingBox)),nm.applyMatrix4(e.matrixWorld),this.union(nm)}const i=e.children;for(let e=0,n=i.length;e<n;e++)this.expandByObject(i[e],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,tm),tm.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(cm),um.subVectors(this.max,cm),im.subVectors(e.a,cm),rm.subVectors(e.b,cm),sm.subVectors(e.c,cm),am.subVectors(rm,im),om.subVectors(sm,rm),lm.subVectors(im,sm);let t=[0,-am.z,am.y,0,-om.z,om.y,0,-lm.z,lm.y,am.z,0,-am.x,om.z,0,-om.x,lm.z,0,-lm.x,-am.y,am.x,0,-om.y,om.x,0,-lm.y,lm.x,0];return!!pm(t,im,rm,sm,um)&&(t=[1,0,0,0,1,0,0,0,1],!!pm(t,im,rm,sm,um)&&(hm.crossVectors(am,om),t=[hm.x,hm.y,hm.z],pm(t,im,rm,sm,um)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,tm).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(tm).length()),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()||(em[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),em[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),em[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),em[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),em[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),em[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),em[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),em[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(em)),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 em=[new Rp,new Rp,new Rp,new Rp,new Rp,new Rp,new Rp,new Rp],tm=new Rp,nm=new Qf,im=new Rp,rm=new Rp,sm=new Rp,am=new Rp,om=new Rp,lm=new Rp,cm=new Rp,um=new Rp,hm=new Rp,dm=new Rp;function pm(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){dm.fromArray(e,s);const a=r.x*Math.abs(dm.x)+r.y*Math.abs(dm.y)+r.z*Math.abs(dm.z),o=t.dot(dm),l=n.dot(dm),c=i.dot(dm);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const fm=mm();function mm(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,s[e]=t|n}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function gm(e){Math.abs(e)>65504&&up("DataUtils.toHalfFloat(): Value out of range."),e=bp(e,-65504,65504),fm.floatView[0]=e;const t=fm.uint32View[0],n=t>>23&511;return fm.baseTable[n]+((8388607&t)>>fm.shiftTable[n])}function vm(e){const t=e>>10;return fm.uint32View[0]=fm.mantissaTable[fm.offsetTable[t]+(1023&e)]+fm.exponentTable[t],fm.floatView[0]}const ym=new Rp,xm=new Ep;let bm=0;class _m extends fp{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:bm++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=Zd,this.updateRanges=[],this.gpuType=Ch,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)xm.fromBufferAttribute(this,t),xm.applyMatrix3(e),this.setXY(t,xm.x,xm.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)ym.fromBufferAttribute(this,t),ym.applyMatrix3(e),this.setXYZ(t,ym.x,ym.y,ym.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ym.fromBufferAttribute(this,t),ym.applyMatrix4(e),this.setXYZ(t,ym.x,ym.y,ym.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ym.fromBufferAttribute(this,t),ym.applyNormalMatrix(e),this.setXYZ(t,ym.x,ym.y,ym.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ym.fromBufferAttribute(this,t),ym.transformDirection(e),this.setXYZ(t,ym.x,ym.y,ym.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Sp(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Mp(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Sp(t,this.array)),t}setX(e,t){return this.normalized&&(t=Mp(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Sp(t,this.array)),t}setY(e,t){return this.normalized&&(t=Mp(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=Sp(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Mp(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=Sp(t,this.array)),t}setW(e,t){return this.normalized&&(t=Mp(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array),i=Mp(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array),i=Mp(i,this.array),r=Mp(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,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!==Zd&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class wm extends _m{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Sm extends _m{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Mm extends _m{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Tm=new Qf,Em=new Rp,Am=new Rp;class Rm{constructor(e=new Rp,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 n=this.center;void 0!==t?n.copy(t):Tm.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;t<r;t++)i=Math.max(i,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);return t.copy(e),n>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;Em.subVectors(e,this.center);const t=Em.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(Em,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Am.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Em.copy(e.center).add(Am)),this.expandByPoint(Em.copy(e.center).sub(Am))),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}}let Cm=0;const Pm=new Jp,Im=new Ef,Lm=new Rp,Dm=new Qf,Nm=new Qf,Om=new Rp;class Fm extends fp{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Cm++}),this.uuid=xp(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(function(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}(e)?Sm:wm)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,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 void 0!==this.attributes[e]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new Ip).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Pm.makeRotationFromQuaternion(e),this.applyMatrix4(Pm),this}rotateX(e){return Pm.makeRotationX(e),this.applyMatrix4(Pm),this}rotateY(e){return Pm.makeRotationY(e),this.applyMatrix4(Pm),this}rotateZ(e){return Pm.makeRotationZ(e),this.applyMatrix4(Pm),this}translate(e,t,n){return Pm.makeTranslation(e,t,n),this.applyMatrix4(Pm),this}scale(e,t,n){return Pm.makeScale(e,t,n),this.applyMatrix4(Pm),this}lookAt(e){return Im.lookAt(e),Im.updateMatrix(),this.applyMatrix4(Im.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lm).negate(),this.translate(Lm.x,Lm.y,Lm.z),this}setFromPoints(e){const t=this.getAttribute("position");if(void 0===t){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n];t.push(i.x,i.y,i.z||0)}this.setAttribute("position",new Mm(t,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const n=e[i];t.setXYZ(i,n.x,n.y,n.z||0)}e.length>t.count&&up("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Qf);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return hp("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Rp(-1/0,-1/0,-1/0),new Rp(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Dm.setFromBufferAttribute(n),this.morphTargetsRelative?(Om.addVectors(this.boundingBox.min,Dm.min),this.boundingBox.expandByPoint(Om),Om.addVectors(this.boundingBox.max,Dm.max),this.boundingBox.expandByPoint(Om)):(this.boundingBox.expandByPoint(Dm.min),this.boundingBox.expandByPoint(Dm.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&hp('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Rm);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return hp("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new Rp,1/0);if(e){const n=this.boundingSphere.center;if(Dm.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Nm.setFromBufferAttribute(n),this.morphTargetsRelative?(Om.addVectors(Dm.min,Nm.min),Dm.expandByPoint(Om),Om.addVectors(Dm.max,Nm.max),Dm.expandByPoint(Om)):(Dm.expandByPoint(Nm.min),Dm.expandByPoint(Nm.max))}Dm.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)Om.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(Om));if(t)for(let r=0,s=t.length;r<s;r++){const s=t[r],a=this.morphTargetsRelative;for(let t=0,r=s.count;t<r;t++)Om.fromBufferAttribute(s,t),a&&(Lm.fromBufferAttribute(e,t),Om.add(Lm)),i=Math.max(i,n.distanceToSquared(Om))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&hp('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(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void hp("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=t.position,i=t.normal,r=t.uv;let s=this.getAttribute("tangent");void 0!==s&&s.count===n.count||(s=new _m(new Float32Array(4*n.count),4),this.setAttribute("tangent",s));const a=[],o=[];for(let e=0;e<n.count;e++)a[e]=new Rp,o[e]=new Rp;const l=new Rp,c=new Rp,u=new Rp,h=new Ep,d=new Ep,p=new Ep,f=new Rp,m=new Rp;function g(e,t,i){l.fromBufferAttribute(n,e),c.fromBufferAttribute(n,t),u.fromBufferAttribute(n,i),h.fromBufferAttribute(r,e),d.fromBufferAttribute(r,t),p.fromBufferAttribute(r,i),c.sub(l),u.sub(l),d.sub(h),p.sub(h);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(f.copy(c).multiplyScalar(p.y).addScaledVector(u,-d.y).multiplyScalar(s),m.copy(u).multiplyScalar(d.x).addScaledVector(c,-p.x).multiplyScalar(s),a[e].add(f),a[t].add(f),a[i].add(f),o[e].add(m),o[t].add(m),o[i].add(m))}let v=this.groups;0===v.length&&(v=[{start:0,count:e.count}]);for(let t=0,n=v.length;t<n;++t){const n=v[t],i=n.start;for(let t=i,r=i+n.count;t<r;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}const y=new Rp,x=new Rp,b=new Rp,_=new Rp;function w(e){b.fromBufferAttribute(i,e),_.copy(b);const t=a[e];y.copy(t),y.sub(b.multiplyScalar(b.dot(t))).normalize(),x.crossVectors(_,t);const n=x.dot(o[e])<0?-1:1;s.setXYZW(e,y.x,y.y,y.z,n)}for(let t=0,n=v.length;t<n;++t){const n=v[t],i=n.start;for(let t=i,r=i+n.count;t<r;t+=3)w(e.getX(t+0)),w(e.getX(t+1)),w(e.getX(t+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n||n.count!==t.count)n=new _m(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const i=new Rp,r=new Rp,s=new Rp,a=new Rp,o=new Rp,l=new Rp,c=new Rp,u=new Rp;if(e)for(let h=0,d=e.count;h<d;h+=3){const d=e.getX(h+0),p=e.getX(h+1),f=e.getX(h+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,f),c.subVectors(s,r),u.subVectors(i,r),c.cross(u),a.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),a.add(c),o.add(c),l.add(c),n.setXYZ(d,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),s.fromBufferAttribute(t,e+2),c.subVectors(s,r),u.subVectors(i,r),c.cross(u),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Om.fromBufferAttribute(e,t),Om.normalize(),e.setXYZ(t,Om.x,Om.y,Om.z)}toNonIndexed(){function e(e,t){const n=e.array,i=e.itemSize,r=e.normalized,s=new n.constructor(t.length*i);let a=0,o=0;for(let r=0,l=t.length;r<l;r++){a=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*i;for(let e=0;e<i;e++)s[o++]=n[a++]}return new _m(s,i,r)}if(null===this.index)return up("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Fm,n=this.index.array,i=this.attributes;for(const r in i){const s=e(i[r],n);t.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],a=r[i];for(let t=0,i=a.length;t<i;t++){const i=e(a[t],n);s.push(i)}t.morphAttributes[i]=s}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let e=0,n=s.length;e<n;e++){const n=s[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=void 0!==this.parameters&&!0===this._transformed?"BufferGeometry":this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters&&!0!==this._transformed){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],s=[];for(let t=0,i=n.length;t<i;t++){const i=n[t];s.push(i.toJSON(e.data))}s.length>0&&(i[t]=s,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere=a.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 n=e.index;null!==n&&this.setIndex(n.clone());const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e<r;e++)n.push(i[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let e=0,t=s.length;e<t;e++){const t=s[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class km{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Zd,this.updateRanges=[],this.version=0,this.uuid=xp()}onUploadCallback(){}set needsUpdate(e){!0===e&&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,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=xp()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=xp()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(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 Um=new Rp;class zm{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}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,n=this.data.count;t<n;t++)Um.fromBufferAttribute(this,t),Um.applyMatrix4(e),this.setXYZ(t,Um.x,Um.y,Um.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Um.fromBufferAttribute(this,t),Um.applyNormalMatrix(e),this.setXYZ(t,Um.x,Um.y,Um.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Um.fromBufferAttribute(this,t),Um.transformDirection(e),this.setXYZ(t,Um.x,Um.y,Um.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Sp(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Mp(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Mp(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Mp(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Mp(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Mp(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=Sp(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Sp(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Sp(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Sp(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array),i=Mp(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array),i=Mp(i,this.array),r=Mp(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(void 0===e){lp("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new _m(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new zm(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){lp("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Bm,Vm=0;class Gm extends fp{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Vm++}),this.uuid=xp(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Pu,this.blendDst=Iu,this.blendEquation=Su,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Nf(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gd,this.stencilZFail=Gd,this.stencilZPass=Gd,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(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){up(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:up(`Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==Pu&&(n.blendSrc=this.blendSrc),this.blendDst!==Iu&&(n.blendDst=this.blendDst),this.blendEquation!==Su&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Gd&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Gd&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Gd&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}fromJSON(e,t){if(void 0!==e.uuid&&(this.uuid=e.uuid),void 0!==e.name&&(this.name=e.name),void 0!==e.color&&void 0!==this.color&&this.color.setHex(e.color),void 0!==e.roughness&&(this.roughness=e.roughness),void 0!==e.metalness&&(this.metalness=e.metalness),void 0!==e.sheen&&(this.sheen=e.sheen),void 0!==e.sheenColor&&(this.sheenColor=(new Nf).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(this.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==this.emissive&&this.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==this.specular&&this.specular.setHex(e.specular),void 0!==e.specularIntensity&&(this.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==this.specularColor&&this.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(this.shininess=e.shininess),void 0!==e.clearcoat&&(this.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(this.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.dispersion&&(this.dispersion=e.dispersion),void 0!==e.iridescence&&(this.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(this.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(this.transmission=e.transmission),void 0!==e.thickness&&(this.thickness=e.thickness),void 0!==e.attenuationDistance&&(this.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==this.attenuationColor&&this.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(this.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(this.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(this.fog=e.fog),void 0!==e.flatShading&&(this.flatShading=e.flatShading),void 0!==e.blending&&(this.blending=e.blending),void 0!==e.combine&&(this.combine=e.combine),void 0!==e.side&&(this.side=e.side),void 0!==e.shadowSide&&(this.shadowSide=e.shadowSide),void 0!==e.opacity&&(this.opacity=e.opacity),void 0!==e.transparent&&(this.transparent=e.transparent),void 0!==e.alphaTest&&(this.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(this.alphaHash=e.alphaHash),void 0!==e.depthFunc&&(this.depthFunc=e.depthFunc),void 0!==e.depthTest&&(this.depthTest=e.depthTest),void 0!==e.depthWrite&&(this.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(this.colorWrite=e.colorWrite),void 0!==e.blendSrc&&(this.blendSrc=e.blendSrc),void 0!==e.blendDst&&(this.blendDst=e.blendDst),void 0!==e.blendEquation&&(this.blendEquation=e.blendEquation),void 0!==e.blendSrcAlpha&&(this.blendSrcAlpha=e.blendSrcAlpha),void 0!==e.blendDstAlpha&&(this.blendDstAlpha=e.blendDstAlpha),void 0!==e.blendEquationAlpha&&(this.blendEquationAlpha=e.blendEquationAlpha),void 0!==e.blendColor&&void 0!==this.blendColor&&this.blendColor.setHex(e.blendColor),void 0!==e.blendAlpha&&(this.blendAlpha=e.blendAlpha),void 0!==e.stencilWriteMask&&(this.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(this.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(this.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(this.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(this.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(this.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(this.stencilZPass=e.stencilZPass),void 0!==e.stencilWrite&&(this.stencilWrite=e.stencilWrite),void 0!==e.wireframe&&(this.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(this.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(this.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(this.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(this.rotation=e.rotation),void 0!==e.linewidth&&(this.linewidth=e.linewidth),void 0!==e.dashSize&&(this.dashSize=e.dashSize),void 0!==e.gapSize&&(this.gapSize=e.gapSize),void 0!==e.scale&&(this.scale=e.scale),void 0!==e.polygonOffset&&(this.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(this.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(this.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(this.dithering=e.dithering),void 0!==e.alphaToCoverage&&(this.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(this.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(this.forceSinglePass=e.forceSinglePass),void 0!==e.allowOverride&&(this.allowOverride=e.allowOverride),void 0!==e.visible&&(this.visible=e.visible),void 0!==e.toneMapped&&(this.toneMapped=e.toneMapped),void 0!==e.userData&&(this.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),void 0!==e.size&&(this.size=e.size),void 0!==e.sizeAttenuation&&(this.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(this.map=t[e.map]||null),void 0!==e.matcap&&(this.matcap=t[e.matcap]||null),void 0!==e.alphaMap&&(this.alphaMap=t[e.alphaMap]||null),void 0!==e.bumpMap&&(this.bumpMap=t[e.bumpMap]||null),void 0!==e.bumpScale&&(this.bumpScale=e.bumpScale),void 0!==e.normalMap&&(this.normalMap=t[e.normalMap]||null),void 0!==e.normalMapType&&(this.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),this.normalScale=(new Ep).fromArray(t)}return void 0!==e.displacementMap&&(this.displacementMap=t[e.displacementMap]||null),void 0!==e.displacementScale&&(this.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(this.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(this.roughnessMap=t[e.roughnessMap]||null),void 0!==e.metalnessMap&&(this.metalnessMap=t[e.metalnessMap]||null),void 0!==e.emissiveMap&&(this.emissiveMap=t[e.emissiveMap]||null),void 0!==e.emissiveIntensity&&(this.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(this.specularMap=t[e.specularMap]||null),void 0!==e.specularIntensityMap&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),void 0!==e.specularColorMap&&(this.specularColorMap=t[e.specularColorMap]||null),void 0!==e.envMap&&(this.envMap=t[e.envMap]||null),void 0!==e.envMapRotation&&this.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(this.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(this.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(this.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(this.lightMap=t[e.lightMap]||null),void 0!==e.lightMapIntensity&&(this.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(this.aoMap=t[e.aoMap]||null),void 0!==e.aoMapIntensity&&(this.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(this.gradientMap=t[e.gradientMap]||null),void 0!==e.clearcoatMap&&(this.clearcoatMap=t[e.clearcoatMap]||null),void 0!==e.clearcoatRoughnessMap&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),void 0!==e.clearcoatNormalMap&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),void 0!==e.clearcoatNormalScale&&(this.clearcoatNormalScale=(new Ep).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(this.iridescenceMap=t[e.iridescenceMap]||null),void 0!==e.iridescenceThicknessMap&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),void 0!==e.transmissionMap&&(this.transmissionMap=t[e.transmissionMap]||null),void 0!==e.thicknessMap&&(this.thicknessMap=t[e.thicknessMap]||null),void 0!==e.anisotropyMap&&(this.anisotropyMap=t[e.anisotropyMap]||null),void 0!==e.sheenColorMap&&(this.sheenColorMap=t[e.sheenColorMap]||null),void 0!==e.sheenRoughnessMap&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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 n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,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.allowOverride=e.allowOverride,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){!0===e&&this.version++}}class Hm extends Gm{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Nf(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}}const Wm=new Rp,jm=new Rp,Xm=new Rp,qm=new Ep,$m=new Ep,Ym=new Jp,Km=new Rp,Zm=new Rp,Jm=new Rp,Qm=new Ep,eg=new Ep,tg=new Ep;class ng extends Ef{constructor(e=new Hm){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Bm){Bm=new Fm;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new km(e,5);Bm.setIndex([0,1,2,0,2,3]),Bm.setAttribute("position",new zm(t,3,0,!1)),Bm.setAttribute("uv",new zm(t,2,3,!1))}this.geometry=Bm,this.material=e,this.center=new Ep(.5,.5),this.count=1}raycast(e,t){null===e.camera&&hp('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),jm.setFromMatrixScale(this.matrixWorld),Ym.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Xm.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&jm.multiplyScalar(-Xm.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;ig(Km.set(-.5,-.5,0),Xm,s,jm,i,r),ig(Zm.set(.5,-.5,0),Xm,s,jm,i,r),ig(Jm.set(.5,.5,0),Xm,s,jm,i,r),Qm.set(0,0),eg.set(1,0),tg.set(1,1);let a=e.ray.intersectTriangle(Km,Zm,Jm,!1,Wm);if(null===a&&(ig(Zm.set(-.5,.5,0),Xm,s,jm,i,r),eg.set(0,1),a=e.ray.intersectTriangle(Km,Jm,Zm,!1,Wm),null===a))return;const o=e.ray.origin.distanceTo(Wm);o<e.near||o>e.far||t.push({distance:o,point:Wm.clone(),uv:Jf.getInterpolation(Wm,Km,Zm,Jm,Qm,eg,tg,new Ep),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function ig(e,t,n,i,r,s){qm.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?($m.x=s*qm.x-r*qm.y,$m.y=r*qm.x+s*qm.y):$m.copy(qm),e.copy(t),e.x+=$m.x,e.y+=$m.y,e.applyMatrix4(Ym)}const rg=new Rp,sg=new Rp;class ag extends Ef{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 e=0,n=t.length;e<n;e++){const n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let r;for(r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const e=t.splice(n,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let i=t[n].distance;if(t[n].object.visible&&(i-=i*t[n].hysteresis),e<i)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){rg.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(rg);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){rg.setFromMatrixPosition(e.matrixWorld),sg.setFromMatrixPosition(this.matrixWorld);const n=rg.distanceTo(sg)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i<r;i++){let e=t[i].distance;if(t[i].object.visible&&(e-=e*t[i].hysteresis),!(n>=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;i<r;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let e=0,i=n.length;e<i;e++){const i=n[e];t.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return t}}const og=new Rp,lg=new Rp,cg=new Rp,ug=new Rp,hg=new Rp,dg=new Rp,pg=new Rp;class fg{constructor(e=new Rp,t=new Rp(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,og)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=og.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(og.copy(this.origin).addScaledVector(this.direction,t),og.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){lg.copy(e).add(t).multiplyScalar(.5),cg.copy(t).sub(e).normalize(),ug.copy(this.origin).sub(lg);const r=.5*e.distanceTo(t),s=-this.direction.dot(cg),a=ug.dot(this.direction),o=-ug.dot(cg),l=ug.lengthSq(),c=Math.abs(1-s*s);let u,h,d,p;if(c>0)if(u=s*o-a,h=s*a-o,p=r*c,u>=0)if(h>=-p)if(h<=p){const e=1/c;u*=e,h*=e,d=u*(u+s*h+2*a)+h*(s*u+h+2*o)+l}else h=r,u=Math.max(0,-(s*h+a)),d=-u*u+h*(h+2*o)+l;else h=-r,u=Math.max(0,-(s*h+a)),d=-u*u+h*(h+2*o)+l;else h<=-p?(u=Math.max(0,-(-s*r+a)),h=u>0?-r:Math.min(Math.max(-r,-o),r),d=-u*u+h*(h+2*o)+l):h<=p?(u=0,h=Math.min(Math.max(-r,-o),r),d=h*(h+2*o)+l):(u=Math.max(0,-(s*r+a)),h=u>0?r:Math.min(Math.max(-r,-o),r),d=-u*u+h*(h+2*o)+l);else h=s>0?-r:r,u=Math.max(0,-(s*h+a)),d=-u*u+h*(h+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(lg).addScaledVector(cg,h),d}intersectSphere(e,t){og.subVectors(e.center,this.origin);const n=og.dot(this.direction),i=og.dot(og)-n*n,r=e.radius*e.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),c>=0?(r=(e.min.y-h.y)*c,s=(e.max.y-h.y)*c):(r=(e.max.y-h.y)*c,s=(e.min.y-h.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),u>=0?(a=(e.min.z-h.z)*u,o=(e.max.z-h.z)*u):(a=(e.max.z-h.z)*u,o=(e.min.z-h.z)*u),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,og)}intersectTriangle(e,t,n,i,r){hg.subVectors(t,e),dg.subVectors(n,e),pg.crossVectors(hg,dg);let s,a=this.direction.dot(pg);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}ug.subVectors(this.origin,e);const o=s*this.direction.dot(dg.crossVectors(ug,dg));if(o<0)return null;const l=s*this.direction.dot(hg.cross(ug));if(l<0)return null;if(o+l>a)return null;const c=-s*ug.dot(pg);return c<0?null:this.at(c/a,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 mg extends Gm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Nf(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 cf,this.combine=0,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 gg=new Jp,vg=new fg,yg=new Rm,xg=new Rp,bg=new Rp,_g=new Rp,wg=new Rp,Sg=new Rp,Mg=new Rp,Tg=new Rp,Eg=new Rp;class Ag extends Ef{constructor(e=new Fm,t=new mg){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),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(r&&a){Mg.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=a[n],o=r[n];0!==i&&(Sg.fromBufferAttribute(o,e),s?Mg.addScaledVector(Sg,i):Mg.addScaledVector(Sg.sub(t),i))}t.add(Mg)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),yg.copy(n.boundingSphere),yg.applyMatrix4(r),vg.copy(e.ray).recast(e.near),!1===yg.containsPoint(vg.origin)){if(null===vg.intersectSphere(yg,xg))return;if(vg.origin.distanceToSquared(xg)>(e.far-e.near)**2)return}gg.copy(r).invert(),vg.copy(e.ray).applyMatrix4(gg),null!==n.boundingBox&&!1===vg.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,vg)}}_computeIntersections(e,t,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,u=r.attributes.normal,h=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=h.length;r<o;r++){const o=h[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){i=Rg(this,p,e,n,l,c,u,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,t.push(i))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){i=Rg(this,s,e,n,l,c,u,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),t.push(i))}}else if(void 0!==o)if(Array.isArray(s))for(let r=0,a=h.length;r<a;r++){const a=h[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){i=Rg(this,p,e,n,l,c,u,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,t.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){i=Rg(this,s,e,n,l,c,u,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),t.push(i))}}}}function Rg(e,t,n,i,r,s,a,o,l,c){e.getVertexPosition(o,bg),e.getVertexPosition(l,_g),e.getVertexPosition(c,wg);const u=function(e,t,n,i,r,s,a,o){let l;if(l=1===t.side?i.intersectTriangle(a,s,r,!0,o):i.intersectTriangle(r,s,a,0===t.side,o),null===l)return null;Eg.copy(o),Eg.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(Eg);return c<n.near||c>n.far?null:{distance:c,point:Eg.clone(),object:e}}(e,t,n,i,bg,_g,wg,Tg);if(u){const e=new Rp;Jf.getBarycoord(Tg,bg,_g,wg,e),r&&(u.uv=Jf.getInterpolatedAttribute(r,o,l,c,e,new Ep)),s&&(u.uv1=Jf.getInterpolatedAttribute(s,o,l,c,e,new Ep)),a&&(u.normal=Jf.getInterpolatedAttribute(a,o,l,c,e,new Rp),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const t={a:o,b:l,c:c,normal:new Rp,materialIndex:0};Jf.getNormal(bg,_g,wg,t.normal),u.face=t,u.barycoord=e}return u}const Cg=new qp,Pg=new qp,Ig=new qp,Lg=new qp,Dg=new Jp,Ng=new Rp,Og=new Rm,Fg=new Jp,kg=new fg;class Ug extends Ag{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ah,this.bindMatrix=new Jp,this.bindMatrixInverse=new Jp,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new Qf),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ng),this.boundingBox.expandByPoint(Ng)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Rm),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ng),this.boundingSphere.expandByPoint(Ng)}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,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Og.copy(this.boundingSphere),Og.applyMatrix4(i),!1!==e.ray.intersectsSphere(Og)&&(Fg.copy(i).invert(),kg.copy(e.ray).applyMatrix4(Fg),null!==this.boundingBox&&!1===kg.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,kg)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(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 qp,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ah?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===oh?this.bindMatrixInverse.copy(this.bindMatrix).invert():up("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Pg.fromBufferAttribute(i.attributes.skinIndex,e),Ig.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4?(Cg.copy(t),t.set(0,0,0,0)):(Cg.set(...t,1),t.set(0,0,0)),Cg.applyMatrix4(this.bindMatrix);for(let e=0;e<4;e++){const i=Ig.getComponent(e);if(0!==i){const r=Pg.getComponent(e);Dg.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),t.addScaledVector(Lg.copy(Cg).applyMatrix4(Dg),i)}}return t.isVector4&&(t.w=Cg.w),t.applyMatrix4(this.bindMatrixInverse)}}class zg extends Ef{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Bg extends Xp{constructor(e=null,t=1,n=1,i,r,s,a,o,l=1003,c=1003,u,h){super(null,s,a,o,l,c,i,r,u,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Vg=new Jp,Gg=new Jp;class Hg{constructor(e=[],t=[]){this.uuid=xp(),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(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){up("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Jp)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new Jp;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=e.length;i<r;i++){const r=e[i]?e[i].matrixWorld:Gg;Vg.multiplyMatrices(r,t[i]),Vg.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new Hg(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Bg(t,e,e,Uh,Ch);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const i=e.bones[n];let r=t[i];void 0===r&&(up("Skeleton: No bone found with UUID:",i),r=new zg),this.bones.push(r),this.boneInverses.push((new Jp).fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const r=t[i];e.bones.push(r.uuid);const s=n[i];e.boneInverses.push(s.toArray())}return e}}class Wg extends _m{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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 jg=new Jp,Xg=new Jp,qg=[],$g=new Qf,Yg=new Jp,Kg=new Ag,Zg=new Rm;class Jg extends Ag{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Wg(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,Yg)}computeBoundingBox(){const e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Qf),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,jg),$g.copy(e.boundingBox).applyMatrix4(jg),this.boundingBox.union($g)}computeBoundingSphere(){const e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new Rm),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,jg),Zg.copy(e.boundingSphere).applyMatrix4(jg),this.boundingSphere.union(Zg)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.morphTexture&&(this.morphTexture=e.morphTexture.clone()),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return null===this.instanceColor?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,16*e)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=i[r+e]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Kg.geometry=this.geometry,Kg.material=this.material,void 0!==Kg.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Zg.copy(this.boundingSphere),Zg.applyMatrix4(n),!1!==e.ray.intersectsSphere(Zg)))for(let r=0;r<i;r++){this.getMatrixAt(r,jg),Xg.multiplyMatrices(n,jg),Kg.matrixWorld=Xg,Kg.raycast(e,qg);for(let e=0,n=qg.length;e<n;e++){const n=qg[e];n.instanceId=r,n.object=this,t.push(n)}qg.length=0}}setColorAt(e,t){return null===this.instanceColor&&(this.instanceColor=new Wg(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),t.toArray(this.instanceColor.array,3*e),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,16*e),this}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new Bg(new Float32Array(i*this.count),i,this.count,Vh,Ch));const r=this.morphTexture.source.data.data;let s=0;for(let e=0;e<n.length;e++)s+=n[e];const a=this.geometry.morphTargetsRelative?1:1-s,o=i*e;return r[o]=a,r.set(n,o+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Qg=new Rp,ev=new Rp,tv=new Ip;class nv{constructor(e=new Rp(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Qg.subVectors(n,t).cross(ev.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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,n=!0){const i=e.delta(Qg),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return!0===n&&(s<0||s>1)?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||tv.getNormalMatrix(e),i=this.coplanarPoint(Qg).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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 iv=new Rm,rv=new Ep(.5,.5),sv=new Rp;class av{constructor(e=new nv,t=new nv,n=new nv,i=new nv,r=new nv,s=new nv){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3,n=!1){const i=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],y=r[13],x=r[14],b=r[15];if(i[0].setComponents(l-s,d-c,g-p,b-v).normalize(),i[1].setComponents(l+s,d+c,g+p,b+v).normalize(),i[2].setComponents(l+a,d+u,g+f,b+y).normalize(),i[3].setComponents(l-a,d-u,g-f,b-y).normalize(),n)i[4].setComponents(o,h,m,x).normalize(),i[5].setComponents(l-o,d-h,g-m,b-x).normalize();else if(i[4].setComponents(l-o,d-h,g-m,b-x).normalize(),t===Qd)i[5].setComponents(l+o,d+h,g+m,b+x).normalize();else{if(t!==ep)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);i[5].setComponents(o,h,m,x).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),iv.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),iv.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(iv)}intersectsSprite(e){iv.center.set(0,0,0);const t=rv.distanceTo(e.center);return iv.radius=.7071067811865476+t,iv.applyMatrix4(e.matrixWorld),this.intersectsSphere(iv)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<i)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(sv.x=i.normal.x>0?e.max.x:e.min.x,sv.y=i.normal.y>0?e.max.y:e.min.y,sv.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(sv)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const ov=new Jp;class lv{constructor(){this.coordinateSystem=Qd,this._frustums=[],this._count=0}setFromArrayCamera(e){const t=e.cameras,n=this._frustums;for(let e=0;e<t.length;e++){const i=t[e];ov.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),void 0===n[e]&&(n[e]=new av),n[e].setFromProjectionMatrix(ov,i.coordinateSystem,i.reversedDepth)}return this._count=t.length,this}intersectsObject(e){const t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){const t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){const t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){const t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){const t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;const t=this._frustums,n=e._frustums;for(let i=0;i<e._count;i++)void 0===t[i]&&(t[i]=new av),t[i].copy(n[i]);return this._count=e._count,this}clone(){return(new lv).copy(this)}}function cv(e,t){return e-t}function uv(e,t){return e.z-t.z}function hv(e,t){return t.z-e.z}class dv{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=e,a.count=t,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const pv=new Jp,fv=new Nf(1,1,1),mv=new av,gv=new lv,vv=new Qf,yv=new Rm,xv=new Rp,bv=new Rp,_v=new Rp,wv=new dv,Sv=new Ag,Mv=[];function Tv(e,t,n=0){const i=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){const r=e.count;for(let s=0;s<r;s++)for(let r=0;r<i;r++)t.setComponent(s+n,r,e.getComponent(s,r))}else t.array.set(e.array,n*i);t.needsUpdate=!0}function Ev(e,t){if(e.constructor!==t.constructor){const n=Math.min(e.length,t.length);for(let i=0;i<n;i++)t[i]=e[i]}else{const n=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,n))}}class Av extends Ag{constructor(e,t,n=2*t,i){super(new Fm,i),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=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,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(4*this._maxInstanceCount);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Bg(t,e,e,Uh,Ch);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Bg(t,e,e,Gh,Rh);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Bg(t,e,e,Uh,Ch);n.colorSpace=Fp.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in e.attributes){const r=e.getAttribute(i),{array:s,itemSize:a,normalized:o}=r,l=new s.constructor(n*a),c=new _m(l,a,o);t.setAttribute(i,c)}if(null!==e.getIndex()){const e=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new _m(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(Boolean(e.getIndex())!==Boolean(t.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.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||!1===t[e].active)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||!1===t[e].active)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(){null===this.boundingBox&&(this.boundingBox=new Qf);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(!1===t[n].active)continue;const i=t[n].geometryIndex;this.getMatrixAt(n,pv),this.getBoundingBoxAt(i,vv).applyMatrix4(pv),e.union(vv)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Rm);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(!1===t[n].active)continue;const i=t[n].geometryIndex;this.getMatrixAt(n,pv),this.getBoundingSphereAt(i,yv).applyMatrix4(pv),e.union(yv)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(cv),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));const i=this._matricesTexture;pv.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(fv.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={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;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===t?e.getAttribute("position").count:t;const s=e.getIndex();if(null!==s&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?s.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(cv),a=this._availableGeometryIds.shift(),r[a]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),s=t.getIndex(),a=this._geometryInfo[e];if(i&&s.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(const e in n.attributes){const i=t.getAttribute(e),r=n.getAttribute(e);Tv(i,r,o);const s=i.itemSize;for(let e=i.count,t=l;e<t;e++){const t=o+e;for(let e=0;e<s;e++)r.setComponent(t,e,0)}r.needsUpdate=!0,r.addUpdateRange(o*s,l*s)}if(i){const e=a.indexStart,n=a.reservedIndexCount;a.indexCount=t.getIndex().count;for(let t=0;t<s.count;t++)r.setX(e+t,o+s.getX(t));for(let t=s.count,i=n;t<i;t++)r.setX(e+t,o);r.needsUpdate=!0,r.addUpdateRange(e,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,null!==t.boundingBox&&(a.boundingBox=t.boundingBox.clone()),a.boundingSphere=null,null!==t.boundingSphere&&(a.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||!1===t[e].active)return this;const n=this._instanceInfo;for(let t=0,i=n.length;t<i;t++)n[t].active&&n[t].geometryIndex===e&&this.deleteInstance(t);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 n=this._geometryInfo,i=n.map((e,t)=>t).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),r=this.geometry;for(let s=0,a=n.length;s<a;s++){const a=i[s],o=n[a];if(!1!==o.active){if(null!==r.index){if(o.indexStart!==t){const{indexStart:n,vertexStart:i,reservedIndexCount:s}=o,a=r.index,l=a.array,c=e-i;for(let e=n;e<n+s;e++)l[e]=l[e]+c;a.array.copyWithin(t,n,n+s),a.addUpdateRange(t,s),a.needsUpdate=!0,o.indexStart=t}t+=o.reservedIndexCount}if(o.vertexStart!==e){const{vertexStart:t,reservedVertexCount:n}=o,i=r.attributes;for(const r in i){const s=i[r],{array:a,itemSize:o}=s;a.copyWithin(e*o,t*o,(t+n)*o),s.addUpdateRange(e*o,n*o),s.needsUpdate=!0}o.vertexStart=e}e+=o.reservedVertexCount,o.start=r.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingBox){const e=new Qf,t=n.index,r=n.attributes.position;for(let n=i.start,s=i.start+i.count;n<s;n++){let i=n;t&&(i=t.getX(i)),e.expandByPoint(xv.fromBufferAttribute(r,i))}i.boundingBox=e}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingSphere){const t=new Rm;this.getBoundingBoxAt(e,vv),vv.getCenter(t.center);const r=n.index,s=n.attributes.position;let a=0;for(let e=i.start,n=i.start+i.count;e<n;e++){let n=e;r&&(n=r.getX(n)),xv.fromBufferAttribute(s,n),a=Math.max(a,t.center.distanceToSquared(xv))}t.radius=Math.sqrt(a),i.boundingSphere=t}return t.copy(i.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,16*e),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,16*e)}setColorAt(e,t){return this.validateInstanceId(e),null===this._colorsTexture&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,4*e),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),null===this._colorsTexture?t.isVector4?t.set(1,1,1,1):t.setRGB(1,1,1):t.fromArray(this._colorsTexture.image.data,4*e)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t||(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 n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(cv);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw new Error(`THREE.BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const i=new Int32Array(e),r=new Int32Array(e);Ev(this._multiDrawCounts,i),Ev(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=e;const s=this._indirectTexture,a=this._matricesTexture,o=this._colorsTexture;s.dispose(),this._initIndirectTexture(),Ev(s.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),Ev(a.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),Ev(o.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(e=>e.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw new Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw new Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`)}const i=this.geometry;i.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Fm,this._initializeGeometry(i));const r=this.geometry;i.index&&Ev(i.index.array,r.index.array);for(const e in i.attributes)Ev(i.attributes[e].array,r.attributes[e].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,s=this.geometry;Sv.material=this.material,Sv.geometry.index=s.index,Sv.geometry.attributes=s.attributes,null===Sv.geometry.boundingBox&&(Sv.geometry.boundingBox=new Qf),null===Sv.geometry.boundingSphere&&(Sv.geometry.boundingSphere=new Rm);for(let s=0,a=n.length;s<a;s++){if(!n[s].visible||!n[s].active)continue;const a=n[s].geometryIndex,o=i[a];Sv.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(s,Sv.matrixWorld).premultiply(r),this.getBoundingBoxAt(a,Sv.geometry.boundingBox),this.getBoundingSphereAt(a,Sv.geometry.boundingSphere),Sv.raycast(e,Mv);for(let e=0,n=Mv.length;e<n;e++){const n=Mv[e];n.object=this,n.batchId=s,t.push(n)}Mv.length=0}Sv.material=null,Sv.geometry.index=null,Sv.geometry.attributes={},Sv.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=null!==e.boundingBox?e.boundingBox.clone():null,this.boundingSphere=null!==e.boundingSphere?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(e=>({...e,boundingBox:null!==e.boundingBox?e.boundingBox.clone():null,boundingSphere:null!==e.boundingSphere?e.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),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(),null!==this._colorsTexture&&(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,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex();let a=null===s?1:s.array.BYTES_PER_ELEMENT,o=1;r.wireframe&&(o=2,a=i.attributes.position.count>65535?4:2);const l=this._instanceInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,d=this.perObjectFrustumCulled,p=this._indirectTexture,f=p.image.data,m=n.isArrayCamera?gv:mv;d&&(n.isArrayCamera?m.setFromArrayCamera(n):(pv.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),m.setFromProjectionMatrix(pv,n.coordinateSystem,n.reversedDepth)));let g=0;if(this.sortObjects){pv.copy(this.matrixWorld).invert(),xv.setFromMatrixPosition(n.matrixWorld).applyMatrix4(pv),bv.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(pv);for(let e=0,t=l.length;e<t;e++)if(l[e].visible&&l[e].active){const t=l[e].geometryIndex;this.getMatrixAt(e,pv),this.getBoundingSphereAt(t,yv).applyMatrix4(pv);let n=!1;if(d&&(n=!m.intersectsSphere(yv)),!n){const n=h[t],i=_v.subVectors(yv.center,xv).dot(bv);wv.push(n.start,n.count,i,e)}}const e=wv.list,t=this.customSort;null===t?e.sort(r.transparent?hv:uv):t.call(this,e,n);for(let t=0,n=e.length;t<n;t++){const n=e[t];c[g]=n.start*a*o,u[g]=n.count*o,f[g]=n.index,g++}wv.reset()}else for(let e=0,t=l.length;e<t;e++)if(l[e].visible&&l[e].active){const t=l[e].geometryIndex;let n=!1;if(d&&(this.getMatrixAt(e,pv),this.getBoundingSphereAt(t,yv).applyMatrix4(pv),n=!m.intersectsSphere(yv)),!n){const n=h[t];c[g]=n.start*a*o,u[g]=n.count*o,f[g]=e,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,r,s){this.onBeforeRender(e,null,i,r,s)}}class Rv extends Gm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Nf(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 Cv=new Rp,Pv=new Rp,Iv=new Jp,Lv=new fg,Dv=new Rm,Nv=new Rp,Ov=new Rp;class Fv extends Ef{constructor(e=new Fm,t=new Rv){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(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,i=t.count;e<i;e++)Cv.fromBufferAttribute(t,e-1),Pv.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Cv.distanceTo(Pv);e.setAttribute("lineDistance",new Mm(n,1))}else up("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Dv.copy(n.boundingSphere),Dv.applyMatrix4(i),Dv.radius+=r,!1===e.ray.intersectsSphere(Dv))return;Iv.copy(i).invert(),Lv.copy(e.ray).applyMatrix4(Iv);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,c=n.index,u=n.attributes.position;if(null!==c){const n=Math.max(0,s.start),i=Math.min(c.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=c.getX(r),i=c.getX(r+1),s=kv(this,e,Lv,o,n,i,r);s&&t.push(s)}if(this.isLineLoop){const r=c.getX(i-1),s=c.getX(n),a=kv(this,e,Lv,o,r,s,i-1);a&&t.push(a)}}else{const n=Math.max(0,s.start),i=Math.min(u.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=kv(this,e,Lv,o,r,r+1,r);n&&t.push(n)}if(this.isLineLoop){const r=kv(this,e,Lv,o,i-1,n,i-1);r&&t.push(r)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function kv(e,t,n,i,r,s,a){const o=e.geometry.attributes.position;Cv.fromBufferAttribute(o,r),Pv.fromBufferAttribute(o,s);if(n.distanceSqToSegment(Cv,Pv,Nv,Ov)>i)return;Nv.applyMatrix4(e.matrixWorld);const l=t.ray.origin.distanceTo(Nv);return l<t.near||l>t.far?void 0:{distance:l,point:Ov.clone().applyMatrix4(e.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:e}}const Uv=new Rp,zv=new Rp;class Bv extends Fv{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e<i;e+=2)Uv.fromBufferAttribute(t,e),zv.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+Uv.distanceTo(zv);e.setAttribute("lineDistance",new Mm(n,1))}else up("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Vv extends Fv{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Gv extends Gm{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Nf(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 Hv=new Jp,Wv=new fg,jv=new Rm,Xv=new Rp;class qv extends Ef{constructor(e=new Fm,t=new Gv){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 n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),jv.copy(n.boundingSphere),jv.applyMatrix4(i),jv.radius+=r,!1===e.ray.intersectsSphere(jv))return;Hv.copy(i).invert(),Wv.copy(e.ray).applyMatrix4(Hv);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);n<r;n++){const r=l.getX(n);Xv.fromBufferAttribute(c,r),$v(Xv,r,o,i,e,t,this)}}else{for(let n=Math.max(0,s.start),r=Math.min(c.count,s.start+s.count);n<r;n++)Xv.fromBufferAttribute(c,n),$v(Xv,n,o,i,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function $v(e,t,n,i,r,s,a){const o=Wv.distanceSqToPoint(e);if(o<n){const n=new Rp;Wv.closestPointToPoint(e,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Yv extends Xp{constructor(e,t,n,i,r=1006,s=1006,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const c=this;"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(function t(){c.needsUpdate=!0,c._requestVideoFrameCallbackId=e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class Kv extends Xp{constructor(e,t,n,i,r,s,a,o,l,c,u,h){super(null,s,a,o,l,c,i,r,u,h),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Zv extends Xp{constructor(e=[],t=301,n,i,r,s,a,o,l,c){super(e,t,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Jv extends Xp{constructor(e,t,n=1014,i,r,s,a=1003,o=1003,l,c=1026,u=1){if(c!==zh&&c!==Bh)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:u},i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Gp(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class Qv extends Jv{constructor(e,t=1014,n=301,i,r,s=1003,a=1003,o,l=1026){const c={width:e,height:e,depth:1},u=[c,c,c,c,c,c];super(e,e,t,n,i,r,s,a,o,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class ey extends Xp{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class ty extends Fm{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],u=[];let h=0,d=0;function p(e,t,n,i,r,s,p,f,m,g,v){const y=s/m,x=p/g,b=s/2,_=p/2,w=f/2,S=m+1,M=g+1;let T=0,E=0;const A=new Rp;for(let s=0;s<M;s++){const a=s*x-_;for(let o=0;o<S;o++){const h=o*y-b;A[e]=h*i,A[t]=a*r,A[n]=w,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[n]=f>0?1:-1,c.push(A.x,A.y,A.z),u.push(o/m),u.push(1-s/g),T+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const n=h+t+S*e,i=h+t+S*(e+1),r=h+(t+1)+S*(e+1),s=h+(t+1)+S*e;o.push(n,i,s),o.push(i,r,s),E+=6}a.addGroup(d,E,v),d+=E,h+=T}p("z","y","x",-1,-1,n,t,e,s,r,0),p("z","y","x",1,-1,n,t,-e,s,r,1),p("x","z","y",1,1,e,n,t,i,s,2),p("x","z","y",1,-1,e,n,-t,i,s,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new Mm(l,3)),this.setAttribute("normal",new Mm(c,3)),this.setAttribute("uv",new Mm(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ty(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class ny extends Fm{constructor(e=1,t=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:r},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));const s=[],a=[],o=[],l=[],c=t/2,u=Math.PI/2*e,h=t,d=2*u+h,p=2*n+r,f=i+1,m=new Rp,g=new Rp;for(let v=0;v<=p;v++){let y=0,x=0,b=0,_=0;if(v<=n){const t=v/n,i=t*Math.PI/2;x=-c-e*Math.cos(i),b=e*Math.sin(i),_=-e*Math.cos(i),y=t*u}else if(v<=n+r){const i=(v-n)/r;x=i*t-c,b=e,_=0,y=u+i*h}else{const t=(v-n-r)/n,i=t*Math.PI/2;x=c+e*Math.sin(i),b=e*Math.cos(i),_=e*Math.sin(i),y=u+h+t*u}const w=Math.max(0,Math.min(1,y/d));let S=0;0===v?S=.5/i:v===p&&(S=-.5/i);for(let e=0;e<=i;e++){const t=e/i,n=t*Math.PI*2,r=Math.sin(n),s=Math.cos(n);g.x=-b*s,g.y=x,g.z=b*r,a.push(g.x,g.y,g.z),m.set(-b*s,_,b*r),m.normalize(),o.push(m.x,m.y,m.z),l.push(t+S,w)}if(v>0){const e=(v-1)*f;for(let t=0;t<i;t++){const n=e+t,i=e+t+1,r=v*f+t,a=v*f+t+1;s.push(n,i,r),s.push(i,a,r)}}}this.setIndex(s),this.setAttribute("position",new Mm(a,3)),this.setAttribute("normal",new Mm(o,3)),this.setAttribute("uv",new Mm(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ny(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class iy extends Fm{constructor(e=1,t=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],s=[],a=[],o=[],l=new Rp,c=new Ep;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let r=0,u=3;r<=t;r++,u+=3){const h=n+r/t*i;l.x=e*Math.cos(h),l.y=e*Math.sin(h),s.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(s[u]/e+1)/2,c.y=(s[u+1]/e+1)/2,o.push(c.x,c.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new Mm(s,3)),this.setAttribute("normal",new Mm(a,3)),this.setAttribute("uv",new Mm(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new iy(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ry extends Fm{constructor(e=1,t=1,n=1,i=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],u=[],h=[],d=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const r=p,s=new Ep,f=new Rp;let v=0;const y=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*x,0),h.push(0,x,0),d.push(.5,.5),p++;const b=p;for(let e=0;e<=i;e++){const t=e/i*o+a,n=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*x,f.z=y*n,u.push(f.x,f.y,f.z),h.push(0,x,0),s.x=.5*n+.5,s.y=.5*r*x+.5,d.push(s.x,s.y),p++}for(let e=0;e<i;e++){const t=r+e,i=b+e;!0===n?c.push(i,i+1,t):c.push(i+1,i,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const s=new Rp,v=new Rp;let y=0;const x=(t-e)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,y=g*(t-e)+e;for(let e=0;e<=i;e++){const t=e/i,r=t*o+a,l=Math.sin(r),f=Math.cos(r);v.x=y*l,v.y=-g*n+m,v.z=y*f,u.push(v.x,v.y,v.z),s.set(l,x,f).normalize(),h.push(s.x,s.y,s.z),d.push(t,1-g),c.push(p++)}f.push(c)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const s=f[i][n],a=f[i+1][n],o=f[i+1][n+1],l=f[i][n+1];(e>0||0!==i)&&(c.push(s,a,l),y+=3),(t>0||i!==r-1)&&(c.push(a,o,l),y+=3)}l.addGroup(g,y,0),g+=y}(),!1===s&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Mm(u,3)),this.setAttribute("normal",new Mm(h,3)),this.setAttribute("uv",new Mm(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ry(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class sy extends ry{constructor(e=1,t=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,e,t,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(e){return new sy(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ay extends Fm{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],s=[];function a(e,t,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)s[i][e]=0===e&&i===r?a:a.clone().lerp(o,e/l)}for(let e=0;e<r;e++)for(let t=0;t<2*(r-e)-1;t++){const n=Math.floor(t/2);t%2==0?(o(s[e][n+1]),o(s[e+1][n]),o(s[e][n])):(o(s[e][n+1]),o(s[e+1][n+1]),o(s[e+1][n]))}}function o(e){r.push(e.x,e.y,e.z)}function l(t,n){const i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function c(e,t,n,i){i<0&&1===e.x&&(s[t]=e.x-1),0===n.x&&0===n.z&&(s[t]=i/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}function h(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}!function(e){const n=new Rp,i=new Rp,r=new Rp;for(let s=0;s<t.length;s+=3)l(t[s+0],n),l(t[s+1],i),l(t[s+2],r),a(n,i,r,e)}(i),function(e){const t=new Rp;for(let n=0;n<r.length;n+=3)t.x=r[n+0],t.y=r[n+1],t.z=r[n+2],t.normalize().multiplyScalar(e),r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z}(n),function(){const e=new Rp;for(let t=0;t<r.length;t+=3){e.x=r[t+0],e.y=r[t+1],e.z=r[t+2];const n=u(e)/2/Math.PI+.5,i=h(e)/Math.PI+.5;s.push(n,1-i)}(function(){const e=new Rp,t=new Rp,n=new Rp,i=new Rp,a=new Ep,o=new Ep,l=new Ep;for(let h=0,d=0;h<r.length;h+=9,d+=6){e.set(r[h+0],r[h+1],r[h+2]),t.set(r[h+3],r[h+4],r[h+5]),n.set(r[h+6],r[h+7],r[h+8]),a.set(s[d+0],s[d+1]),o.set(s[d+2],s[d+3]),l.set(s[d+4],s[d+5]),i.copy(e).add(t).add(n).divideScalar(3);const p=u(i);c(a,d+0,e,p),c(o,d+2,t,p),c(l,d+4,n,p)}})(),function(){for(let e=0;e<s.length;e+=6){const t=s[e+0],n=s[e+2],i=s[e+4],r=Math.max(t,n,i),a=Math.min(t,n,i);r>.9&&a<.1&&(t<.2&&(s[e+0]+=1),n<.2&&(s[e+2]+=1),i<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new Mm(r,3)),this.setAttribute("normal",new Mm(r.slice(),3)),this.setAttribute("uv",new Mm(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ay(e.vertices,e.indices,e.radius,e.detail)}}class oy extends ay{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[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],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new oy(e.radius,e.detail)}}const ly=new Rp,cy=new Rp,uy=new Rp,hy=new Jf;class dy extends Fm{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),r=Math.cos(vp*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let e=0;e<o;e+=3){s?(l[0]=s.getX(e),l[1]=s.getX(e+1),l[2]=s.getX(e+2)):(l[0]=e,l[1]=e+1,l[2]=e+2);const{a:t,b:n,c:o}=hy;if(t.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),hy.getNormal(uy),u[0]=`${Math.round(t.x*i)},${Math.round(t.y*i)},${Math.round(t.z*i)}`,u[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,u[2]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let e=0;e<3;e++){const t=(e+1)%3,n=u[e],i=u[t],s=hy[c[e]],a=hy[c[t]],o=`${n}_${i}`,p=`${i}_${n}`;p in h&&h[p]?(uy.dot(h[p].normal)<=r&&(d.push(s.x,s.y,s.z),d.push(a.x,a.y,a.z)),h[p]=null):o in h||(h[o]={index0:l[e],index1:l[t],normal:uy.clone()})}}for(const e in h)if(h[e]){const{index0:t,index1:n}=h[e];ly.fromBufferAttribute(a,t),cy.fromBufferAttribute(a,n),d.push(ly.x,ly.y,ly.z),d.push(cy.x,cy.y,cy.z)}this.setAttribute("position",new Mm(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class py{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){up("Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/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 n,i=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)n=this.getPoint(s/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const r=n.length;let s;s=t||e*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new Ep:new Rp);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new Rp,i=[],r=[],s=[],a=new Rp,o=new Jp;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Rp)}r[0]=new Rp,s[0]=new Rp;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),h<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(bp(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(bp(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,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 fy extends py{constructor(e=0,t=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t=new Ep){const n=t,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=s?0:i),!0!==this.aClockwise||s||(r===i?r=-i:r-=i);const a=this.aStartAngle+e*r;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=o-this.aX,i=l-this.aY;o=n*e-i*t+this.aX,l=n*t+i*e+this.aY}return n.set(o,l)}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 my extends fy{constructor(e,t,n,i,r,s){super(e,t,n,n,i,r,s),this.isArcCurve=!0,this.type="ArcCurve"}}function gy(){let e=0,t=0,n=0,i=0;function r(r,s,a,o){e=r,t=a,n=-3*r+3*s-2*a-o,i=2*r-2*s+a+o}return{initCatmullRom:function(e,t,n,i,s){r(t,n,s*(n-e),s*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,s,a,o){let l=(t-e)/s-(n-e)/(s+a)+(n-t)/a,c=(n-t)/a-(i-t)/(a+o)+(i-n)/o;l*=a,c*=a,r(t,n,l,c)},calc:function(r){const s=r*r;return e+t*r+n*s+i*(s*r)}}}const vy=new Rp,yy=new Rp,xy=new gy,by=new gy,_y=new gy;class wy extends py{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new Rp){const n=t,i=this.points,r=i.length,s=(r-(this.closed?0:1))*e;let a,o,l=Math.floor(s),c=s-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(yy.subVectors(i[0],i[1]).add(i[0]),a=yy);const u=i[l%r],h=i[(l+1)%r];if(this.closed||l+2<r?o=i[(l+2)%r]:(vy.subVectors(i[r-1],i[r-2]).add(i[r-1]),o=vy),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(h),e),i=Math.pow(h.distanceToSquared(o),e);n<1e-4&&(n=1),t<1e-4&&(t=n),i<1e-4&&(i=n),xy.initNonuniformCatmullRom(a.x,u.x,h.x,o.x,t,n,i),by.initNonuniformCatmullRom(a.y,u.y,h.y,o.y,t,n,i),_y.initNonuniformCatmullRom(a.z,u.z,h.z,o.z,t,n,i)}else"catmullrom"===this.curveType&&(xy.initCatmullRom(a.x,u.x,h.x,o.x,this.tension),by.initCatmullRom(a.y,u.y,h.y,o.y,this.tension),_y.initCatmullRom(a.z,u.z,h.z,o.z,this.tension));return n.set(xy.calc(c),by.calc(c),_y.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.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,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.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,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Rp).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Sy(e,t,n,i,r){const s=.5*(i-t),a=.5*(r-n),o=e*e;return(2*n-2*i+s+a)*(e*o)+(-3*n+3*i-2*s-a)*o+s*e+n}function My(e,t,n,i){return function(e,t){const n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,i)}function Ty(e,t,n,i,r){return function(e,t){const n=1-e;return n*n*n*t}(e,t)+function(e,t){const n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,i)+function(e,t){return e*e*e*t}(e,r)}class Ey extends py{constructor(e=new Ep,t=new Ep,n=new Ep,i=new Ep){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Ep){const n=t,i=this.v0,r=this.v1,s=this.v2,a=this.v3;return n.set(Ty(e,i.x,r.x,s.x,a.x),Ty(e,i.y,r.y,s.y,a.y)),n}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 Ay extends py{constructor(e=new Rp,t=new Rp,n=new Rp,i=new Rp){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Rp){const n=t,i=this.v0,r=this.v1,s=this.v2,a=this.v3;return n.set(Ty(e,i.x,r.x,s.x,a.x),Ty(e,i.y,r.y,s.y,a.y),Ty(e,i.z,r.z,s.z,a.z)),n}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 Ry extends py{constructor(e=new Ep,t=new Ep){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ep){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ep){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 Cy extends py{constructor(e=new Rp,t=new Rp){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new Rp){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Rp){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 Py extends py{constructor(e=new Ep,t=new Ep,n=new Ep){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ep){const n=t,i=this.v0,r=this.v1,s=this.v2;return n.set(My(e,i.x,r.x,s.x),My(e,i.y,r.y,s.y)),n}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 Iy extends py{constructor(e=new Rp,t=new Rp,n=new Rp){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Rp){const n=t,i=this.v0,r=this.v1,s=this.v2;return n.set(My(e,i.x,r.x,s.x),My(e,i.y,r.y,s.y),My(e,i.z,r.z,s.z)),n}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 Ly extends py{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ep){const n=t,i=this.points,r=(i.length-1)*e,s=Math.floor(r),a=r-s,o=i[0===s?s:s-1],l=i[s],c=i[s>i.length-2?i.length-1:s+1],u=i[s>i.length-3?i.length-1:s+2];return n.set(Sy(a,o.x,l.x,c.x,u.x),Sy(a,o.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Ep).fromArray(n))}return this}}var Dy=Object.freeze({__proto__:null,ArcCurve:my,CatmullRomCurve3:wy,CubicBezierCurve:Ey,CubicBezierCurve3:Ay,EllipseCurve:fy,LineCurve:Ry,LineCurve3:Cy,QuadraticBezierCurve:Py,QuadraticBezierCurve3:Iy,SplineCurve:Ly});class Ny extends py{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 n=!0===e.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Dy[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const e=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,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 n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const s=r[i],a=s.isEllipseCurve?2*e:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,o=s.getPoints(a);for(let e=0;e<o.length;e++){const i=o[e];n&&n.equals(i)||(t.push(i),n=i)}}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,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new Dy[n.type]).fromJSON(n))}return this}}class Oy extends Ny{constructor(e){super(),this.type="Path",this.currentPoint=new Ep,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;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 n=new Ry(this.currentPoint.clone(),new Ep(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new Py(this.currentPoint.clone(),new Ep(e,t),new Ep(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,s){const a=new Ey(this.currentPoint.clone(),new Ep(e,t),new Ep(n,i),new Ep(r,s));return this.curves.push(a),this.currentPoint.set(r,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Ly(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,n,i,r,s),this}absarc(e,t,n,i,r,s){return this.absellipse(e,t,n,n,i,r,s),this}ellipse(e,t,n,i,r,s,a,o){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,i,r,s,a,o),this}absellipse(e,t,n,i,r,s,a,o){const l=new fy(e,t,n,i,r,s,a,o);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),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 Fy extends Oy{constructor(e){super(e),this.uuid=xp(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].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,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new Oy).fromJSON(n))}return this}}function ky(e,t,n=2){const i=t&&t.length,r=i?t[0]*n:e.length;let s=Uy(e,0,r,n,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c;if(i&&(s=function(e,t,n,i){const r=[];for(let n=0,s=t.length;n<s;n++){const a=Uy(e,t[n]*i,n<s-1?t[n+1]*i:e.length,i,!1);a===a.next&&(a.steiner=!0),r.push(Yy(a))}r.sort(jy);for(let e=0;e<r.length;e++)n=Xy(r[e],n);return n}(e,t,s,n)),e.length>80*n){o=e[0],l=e[1];let t=o,i=l;for(let s=n;s<r;s+=n){const n=e[s],r=e[s+1];n<o&&(o=n),r<l&&(l=r),n>t&&(t=n),r>i&&(i=r)}c=Math.max(t-o,i-l),c=0!==c?32767/c:0}return By(s,a,n,o,l,c,0),a}function Uy(e,t,n,i,r){let s;if(r===function(e,t,n,i){let r=0;for(let s=t,a=n-i;s<n;s+=i)r+=(e[a]-e[s])*(e[s+1]+e[a+1]),a=s;return r}(e,t,n,i)>0)for(let r=t;r<n;r+=i)s=ax(r/i|0,e[r],e[r+1],s);else for(let r=n-i;r>=t;r-=i)s=ax(r/i|0,e[r],e[r+1],s);return s&&ex(s,s.next)&&(ox(s),s=s.next),s}function zy(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!ex(i,i.next)&&0!==Qy(i.prev,i,i.next))i=i.next;else{if(ox(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function By(e,t,n,i,r,s,a){if(!e)return;!a&&s&&function(e,t,n,i){let r=e;do{0===r.z&&(r.z=$y(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n=1;do{let i,r=e;e=null;let s=null;for(t=0;r;){t++;let a=r,o=0;for(let e=0;e<n&&(o++,a=a.nextZ,a);e++);let l=n;for(;o>0||l>0&&a;)0!==o&&(0===l||!a||r.z<=a.z)?(i=r,r=r.nextZ,o--):(i=a,a=a.nextZ,l--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;r=a}s.nextZ=null,n*=2}while(t>1)}(r)}(e,i,r,s);let o=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(s?Gy(e,i,r,s):Vy(e))t.push(l.i,e.i,c.i),ox(e),e=c.next,o=c.next;else if((e=c)===o){a?1===a?By(e=Hy(zy(e),t),t,n,i,r,s,2):2===a&&Wy(e,t,n,i,r,s):By(zy(e),t,n,i,r,s,1);break}}}function Vy(e){const t=e.prev,n=e,i=e.next;if(Qy(t,n,i)>=0)return!1;const r=t.x,s=n.x,a=i.x,o=t.y,l=n.y,c=i.y,u=Math.min(r,s,a),h=Math.min(o,l,c),d=Math.max(r,s,a),p=Math.max(o,l,c);let f=i.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Zy(r,o,s,l,a,c,f.x,f.y)&&Qy(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Gy(e,t,n,i){const r=e.prev,s=e,a=e.next;if(Qy(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,u=r.y,h=s.y,d=a.y,p=Math.min(o,l,c),f=Math.min(u,h,d),m=Math.max(o,l,c),g=Math.max(u,h,d),v=$y(p,f,t,n,i),y=$y(m,g,t,n,i);let x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Zy(o,u,l,h,c,d,x.x,x.y)&&Qy(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==a&&Zy(o,u,l,h,c,d,b.x,b.y)&&Qy(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Zy(o,u,l,h,c,d,x.x,x.y)&&Qy(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==a&&Zy(o,u,l,h,c,d,b.x,b.y)&&Qy(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Hy(e,t){let n=e;do{const i=n.prev,r=n.next.next;!ex(i,r)&&tx(i,n,n.next,r)&&rx(i,r)&&rx(r,i)&&(t.push(i.i,n.i,r.i),ox(n),ox(n.next),n=e=r),n=n.next}while(n!==e);return zy(n)}function Wy(e,t,n,i,r,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Jy(a,e)){let o=sx(a,e);return a=zy(a,a.next),o=zy(o,o.next),By(a,t,n,i,r,s,0),void By(o,t,n,i,r,s,0)}e=e.next}a=a.next}while(a!==e)}function jy(e,t){let n=e.x-t.x;if(0===n&&(n=e.y-t.y,0===n)){n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return n}function Xy(e,t){const n=function(e,t){let n=t;const i=e.x,r=e.y;let s,a=-1/0;if(ex(e,n))return n;do{if(ex(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>a&&(a=e,s=n.x<n.next.x?n:n.next,e===i))return s}n=n.next}while(n!==t);if(!s)return null;const o=s,l=s.x,c=s.y;let u=1/0;n=s;do{if(i>=n.x&&n.x>=l&&i!==n.x&&Ky(r<c?i:a,r,l,c,r<c?a:i,r,n.x,n.y)){const t=Math.abs(r-n.y)/(i-n.x);rx(n,e)&&(t<u||t===u&&(n.x>s.x||n.x===s.x&&qy(s,n)))&&(s=n,u=t)}n=n.next}while(n!==o);return s}(e,t);if(!n)return t;const i=sx(n,e);return zy(i,i.next),zy(n,n.next)}function qy(e,t){return Qy(e.prev,e,t.prev)<0&&Qy(t.next,e,e.next)<0}function $y(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Yy(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function Ky(e,t,n,i,r,s,a,o){return(r-a)*(t-o)>=(e-a)*(s-o)&&(e-a)*(i-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function Zy(e,t,n,i,r,s,a,o){return!(e===a&&t===o)&&Ky(e,t,n,i,r,s,a,o)}function Jy(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&tx(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(rx(e,t)&&rx(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(Qy(e.prev,e,t.prev)||Qy(e,t.prev,t))||ex(e,t)&&Qy(e.prev,e,e.next)>0&&Qy(t.prev,t,t.next)>0)}function Qy(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function ex(e,t){return e.x===t.x&&e.y===t.y}function tx(e,t,n,i){const r=ix(Qy(e,t,n)),s=ix(Qy(e,t,i)),a=ix(Qy(n,i,e)),o=ix(Qy(n,i,t));return r!==s&&a!==o||(!(0!==r||!nx(e,n,t))||(!(0!==s||!nx(e,i,t))||(!(0!==a||!nx(n,e,i))||!(0!==o||!nx(n,t,i)))))}function nx(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ix(e){return e>0?1:e<0?-1:0}function rx(e,t){return Qy(e.prev,e,e.next)<0?Qy(e,t,e.next)>=0&&Qy(e,e.prev,t)>=0:Qy(e,t,e.prev)<0||Qy(e,e.next,t)<0}function sx(e,t){const n=lx(e.i,e.x,e.y),i=lx(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function ax(e,t,n,i){const r=lx(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ox(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function lx(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class cx{static triangulate(e,t,n=2){return ky(e,t,n)}}class ux{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return.5*n}static isClockWise(e){return ux.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];hx(e),dx(n,e);let s=e.length;t.forEach(hx);for(let e=0;e<t.length;e++)i.push(s),s+=t[e].length,dx(n,t[e]);const a=cx.triangulate(n,i);for(let e=0;e<a.length;e+=3)r.push(a.slice(e,e+3));return r}}function hx(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function dx(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class px extends Fm{constructor(e=new Fy([new Ep(.5,.5),new Ep(-.5,.5),new Ep(-.5,-.5),new Ep(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let t=0,n=e.length;t<n;t++){s(e[t])}function s(e){const s=[],a=void 0!==t.curveSegments?t.curveSegments:12,o=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:.2,h=void 0!==t.bevelSize?t.bevelSize:u-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const f=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:fx;let g,v,y,x,b,_=!1;if(f){g=f.getSpacedPoints(o),_=!0,c=!1;const e=!!f.isCatmullRomCurve3&&f.closed;v=f.computeFrenetFrames(o,e),y=new Rp,x=new Rp,b=new Rp}c||(p=0,u=0,h=0,d=0);const w=e.extractPoints(a);let S=w.shape;const M=w.holes;if(!ux.isClockWise(S)){S=S.reverse();for(let e=0,t=M.length;e<t;e++){const t=M[e];ux.isClockWise(t)&&(M[e]=t.reverse())}}function T(e){const t=1e-10*1e-10;let n=e[0];for(let i=1;i<=e.length;i++){const r=i%e.length,s=e[r],a=s.x-n.x,o=s.y-n.y,l=a*a+o*o,c=Math.max(Math.abs(s.x),Math.abs(s.y),Math.abs(n.x),Math.abs(n.y));l<=t*c*c?(e.splice(r,1),i--):n=s}}T(S),M.forEach(T);const E=M.length,A=S;for(let e=0;e<E;e++){const t=M[e];S=S.concat(t)}function R(e,t,n){return t||hp("ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}const C=S.length;function P(e,t,n){let i,r,s;const a=e.x-t.x,o=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=a*a+o*o,h=a*c-o*l;if(Math.abs(h)>Number.EPSILON){const h=Math.sqrt(u),d=Math.sqrt(l*l+c*c),p=t.x-o/h,f=t.y+a/h,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-e.x,r=f+o*m-e.y;const g=i*i+r*r;if(g<=2)return new Ep(i,r);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(c)&&(e=!0),e?(i=-o,r=a,s=Math.sqrt(u)):(i=a,r=o,s=Math.sqrt(u/2))}return new Ep(i/s,r/s)}const I=[];for(let e=0,t=A.length,n=t-1,i=e+1;e<t;e++,n++,i++)n===t&&(n=0),i===t&&(i=0),I[e]=P(A[e],A[n],A[i]);const L=[];let D,N,O=I.concat();for(let e=0,t=E;e<t;e++){const t=M[e];D=[];for(let e=0,n=t.length,i=n-1,r=e+1;e<n;e++,i++,r++)i===n&&(i=0),r===n&&(r=0),D[e]=P(t[e],t[i],t[r]);L.push(D),O=O.concat(D)}if(0===p)N=ux.triangulateShape(A,M);else{const e=[],t=[];for(let n=0;n<p;n++){const i=n/p,r=u*Math.cos(i*Math.PI/2),s=h*Math.sin(i*Math.PI/2)+d;for(let t=0,n=A.length;t<n;t++){const n=R(A[t],I[t],s);z(n.x,n.y,-r),0===i&&e.push(n)}for(let e=0,n=E;e<n;e++){const n=M[e];D=L[e];const a=[];for(let e=0,t=n.length;e<t;e++){const t=R(n[e],D[e],s);z(t.x,t.y,-r),0===i&&a.push(t)}0===i&&t.push(a)}}N=ux.triangulateShape(e,t)}const F=N.length,k=h+d;for(let e=0;e<C;e++){const t=c?R(S[e],O[e],k):S[e];_?(x.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),b.copy(g[0]).add(x).add(y),z(b.x,b.y,b.z)):z(t.x,t.y,0)}for(let e=1;e<=o;e++)for(let t=0;t<C;t++){const n=c?R(S[t],O[t],k):S[t];_?(x.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),b.copy(g[e]).add(x).add(y),z(b.x,b.y,b.z)):z(n.x,n.y,l/o*e)}for(let e=p-1;e>=0;e--){const t=e/p,n=u*Math.cos(t*Math.PI/2),i=h*Math.sin(t*Math.PI/2)+d;for(let e=0,t=A.length;e<t;e++){const t=R(A[e],I[e],i);z(t.x,t.y,l+n)}for(let e=0,t=M.length;e<t;e++){const t=M[e];D=L[e];for(let e=0,r=t.length;e<r;e++){const r=R(t[e],D[e],i);_?z(r.x,r.y+g[o-1].y,g[o-1].x+n):z(r.x,r.y,l+n)}}}function U(e,t){let n=e.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=o+2*p;e<n;e++){const n=C*e,s=C*(e+1);V(t+i+n,t+r+n,t+r+s,t+i+s)}}}function z(e,t,n){s.push(e),s.push(t),s.push(n)}function B(e,t,r){G(e),G(t),G(r);const s=i.length/3,a=m.generateTopUV(n,i,s-3,s-2,s-1);H(a[0]),H(a[1]),H(a[2])}function V(e,t,r,s){G(e),G(t),G(s),G(t),G(r),G(s);const a=i.length/3,o=m.generateSideWallUV(n,i,a-6,a-3,a-2,a-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}function G(e){i.push(s[3*e+0]),i.push(s[3*e+1]),i.push(s[3*e+2])}function H(e){r.push(e.x),r.push(e.y)}!function(){const e=i.length/3;if(c){let e=0,t=C*e;for(let e=0;e<F;e++){const n=N[e];B(n[2]+t,n[1]+t,n[0]+t)}e=o+2*p,t=C*e;for(let e=0;e<F;e++){const n=N[e];B(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<F;e++){const t=N[e];B(t[2],t[1],t[0])}for(let e=0;e<F;e++){const t=N[e];B(t[0]+C*o,t[1]+C*o,t[2]+C*o)}}n.addGroup(e,i.length/3-e,0)}(),function(){const e=i.length/3;let t=0;U(A,t),t+=A.length;for(let e=0,n=M.length;e<n;e++){const n=M[e];U(n,t),t+=n.length}n.addGroup(e,i.length/3-e,1)}()}this.setAttribute("position",new Mm(i,3)),this.setAttribute("uv",new Mm(r,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,i=e.length;t<i;t++){const i=e[t];n.shapes.push(i.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const r=t[e.shapes[i]];n.push(r)}const i=e.options.extrudePath;return void 0!==i&&(e.options.extrudePath=(new Dy[i.type]).fromJSON(i)),new px(n,e.options)}}const fx={generateTopUV:function(e,t,n,i,r){const s=t[3*n],a=t[3*n+1],o=t[3*i],l=t[3*i+1],c=t[3*r],u=t[3*r+1];return[new Ep(s,a),new Ep(o,l),new Ep(c,u)]},generateSideWallUV:function(e,t,n,i,r,s){const a=t[3*n],o=t[3*n+1],l=t[3*n+2],c=t[3*i],u=t[3*i+1],h=t[3*i+2],d=t[3*r],p=t[3*r+1],f=t[3*r+2],m=t[3*s],g=t[3*s+1],v=t[3*s+2];return Math.abs(o-u)<Math.abs(a-c)?[new Ep(a,1-l),new Ep(c,1-h),new Ep(d,1-f),new Ep(m,1-v)]:[new Ep(o,1-l),new Ep(u,1-h),new Ep(p,1-f),new Ep(g,1-v)]}};class mx extends ay{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[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],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new mx(e.radius,e.detail)}}class gx extends Fm{constructor(e=[new Ep(0,-.5),new Ep(.5,0),new Ep(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=bp(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/t,u=new Rp,h=new Ep,d=new Rp,p=new Rp,f=new Rp;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=t;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*f,s.push(u.x,u.y,u.z),h.x=r/t,h.y=n/(e.length-1),a.push(h.x,h.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*f;l.push(i,c,d)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){const i=t+n*e.length,s=i,a=i+e.length,o=i+e.length+1,l=i+1;r.push(s,a,l),r.push(o,l,a)}this.setIndex(r),this.setAttribute("position",new Mm(s,3)),this.setAttribute("uv",new Mm(a,2)),this.setAttribute("normal",new Mm(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gx(e.points,e.segments,e.phiStart,e.phiLength)}}class vx extends ay{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new vx(e.radius,e.detail)}}class yx extends Fm{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,s=t/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,u=e/a,h=t/o,d=[],p=[],f=[],m=[];for(let e=0;e<c;e++){const t=e*h-s;for(let n=0;n<l;n++){const i=n*u-r;p.push(i,-t,0),f.push(0,0,1),m.push(n/a),m.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<a;t++){const n=t+l*e,i=t+l*(e+1),r=t+1+l*(e+1),s=t+1+l*e;d.push(n,i,s),d.push(i,r,s)}this.setIndex(d),this.setAttribute("position",new Mm(p,3)),this.setAttribute("normal",new Mm(f,3)),this.setAttribute("uv",new Mm(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yx(e.width,e.height,e.widthSegments,e.heightSegments)}}class xx extends Fm{constructor(e=.5,t=1,n=32,i=1,r=0,s=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:s},n=Math.max(3,n);const a=[],o=[],l=[],c=[];let u=e;const h=(t-e)/(i=Math.max(1,i)),d=new Rp,p=new Ep;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=r+e/n*s;d.x=u*Math.cos(i),d.y=u*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,c.push(p.x,p.y)}u+=h}for(let e=0;e<i;e++){const t=e*(n+1);for(let e=0;e<n;e++){const i=e+t,r=i,s=i+n+1,o=i+n+2,l=i+1;a.push(r,s,l),a.push(s,o,l)}}this.setIndex(a),this.setAttribute("position",new Mm(o,3)),this.setAttribute("normal",new Mm(l,3)),this.setAttribute("uv",new Mm(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xx(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class bx extends Fm{constructor(e=new Fy([new Ep(0,.5),new Ep(-.5,-.5),new Ep(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],s=[];let a=0,o=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(a,o,t),a+=o,o=0;function l(e){const a=i.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===ux.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===ux.isClockWise(t)&&(u[e]=t.reverse())}const h=ux.triangulateShape(c,u);for(let e=0,t=u.length;e<t;e++){const t=u[e];c=c.concat(t)}for(let e=0,t=c.length;e<t;e++){const t=c[e];i.push(t.x,t.y,0),r.push(0,0,1),s.push(t.x,t.y)}for(let e=0,t=h.length;e<t;e++){const t=h[e],i=t[0]+a,r=t[1]+a,s=t[2]+a;n.push(i,r,s),o+=3}}this.setIndex(n),this.setAttribute("position",new Mm(i,3)),this.setAttribute("normal",new Mm(r,3)),this.setAttribute("uv",new Mm(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,i=e.length;n<i;n++){const i=e[n];t.shapes.push(i.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const r=t[e.shapes[i]];n.push(r)}return new bx(n,e.curveSegments)}}class _x extends Fm{constructor(e=1,t=32,n=16,i=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const o=Math.min(s+a,Math.PI);let l=0;const c=[],u=new Rp,h=new Rp,d=[],p=[],f=[],m=[];for(let d=0;d<=n;d++){const g=[],v=d/n,y=s+v*a,x=e*Math.cos(y),b=Math.sqrt(e*e-x*x);let _=0;0===d&&0===s?_=.5/t:d===n&&o===Math.PI&&(_=-.5/t);for(let e=0;e<=t;e++){const n=e/t,s=i+n*r;u.x=-b*Math.cos(s),u.y=x,u.z=b*Math.sin(s),p.push(u.x,u.y,u.z),h.copy(u).normalize(),f.push(h.x,h.y,h.z),m.push(n+_,1-v),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let i=0;i<t;i++){const t=c[e][i+1],r=c[e][i],a=c[e+1][i],l=c[e+1][i+1];(0!==e||s>0)&&d.push(t,r,l),(e!==n-1||o<Math.PI)&&d.push(r,a,l)}this.setIndex(d),this.setAttribute("position",new Mm(p,3)),this.setAttribute("normal",new Mm(f,3)),this.setAttribute("uv",new Mm(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _x(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class wx extends ay{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new wx(e.radius,e.detail)}}class Sx extends Fm{constructor(e=1,t=.4,n=12,i=48,r=2*Math.PI,s=0,a=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r,thetaStart:s,thetaLength:a},n=Math.floor(n),i=Math.floor(i);const o=[],l=[],c=[],u=[],h=new Rp,d=new Rp,p=new Rp;for(let o=0;o<=n;o++){const f=s+o/n*a;for(let s=0;s<=i;s++){const a=s/i*r;d.x=(e+t*Math.cos(f))*Math.cos(a),d.y=(e+t*Math.cos(f))*Math.sin(a),d.z=t*Math.sin(f),l.push(d.x,d.y,d.z),h.x=e*Math.cos(a),h.y=e*Math.sin(a),p.subVectors(d,h).normalize(),c.push(p.x,p.y,p.z),u.push(s/i),u.push(o/n)}}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*e+t-1,r=(i+1)*(e-1)+t-1,s=(i+1)*(e-1)+t,a=(i+1)*e+t;o.push(n,r,a),o.push(r,s,a)}this.setIndex(o),this.setAttribute("position",new Mm(l,3)),this.setAttribute("normal",new Mm(c,3)),this.setAttribute("uv",new Mm(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sx(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Mx extends Fm{constructor(e=1,t=.4,n=64,i=8,r=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],u=new Rp,h=new Rp,d=new Rp,p=new Rp,f=new Rp,m=new Rp,g=new Rp;for(let a=0;a<=n;++a){const y=a/n*r*Math.PI*2;v(y,r,s,e,d),v(y+.01,r,s,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let e=0;e<=i;++e){const r=e/i*Math.PI*2,s=-t*Math.cos(r),p=t*Math.sin(r);u.x=d.x+(s*g.x+p*f.x),u.y=d.y+(s*g.y+p*f.y),u.z=d.z+(s*g.z+p*f.z),o.push(u.x,u.y,u.z),h.subVectors(u,d).normalize(),l.push(h.x,h.y,h.z),c.push(a/n),c.push(e/i)}}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*(e-1)+(t-1),r=(i+1)*e+(t-1),s=(i+1)*e+t,o=(i+1)*(e-1)+t;a.push(n,r,o),a.push(r,s,o)}function v(e,t,n,i,r){const s=Math.cos(e),a=Math.sin(e),o=n/t*e,l=Math.cos(o);r.x=i*(2+l)*.5*s,r.y=i*(2+l)*a*.5,r.z=i*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new Mm(o,3)),this.setAttribute("normal",new Mm(l,3)),this.setAttribute("uv",new Mm(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mx(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Tx extends Fm{constructor(e=new Iy(new Rp(-1,-1,0),new Rp(-1,1,0),new Rp(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const s=e.computeFrenetFrames(t,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const a=new Rp,o=new Rp,l=new Ep;let c=new Rp;const u=[],h=[],d=[],p=[];function f(r){c=e.getPointAt(r/t,c);const l=s.normals[r],d=s.binormals[r];for(let e=0;e<=i;e++){const t=e/i*Math.PI*2,r=Math.sin(t),s=-Math.cos(t);o.x=s*l.x+r*d.x,o.y=s*l.y+r*d.y,o.z=s*l.z+r*d.z,o.normalize(),h.push(o.x,o.y,o.z),a.x=c.x+n*o.x,a.y=c.y+n*o.y,a.z=c.z+n*o.z,u.push(a.x,a.y,a.z)}}!function(){for(let e=0;e<t;e++)f(e);f(!1===r?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=i;n++)l.x=e/t,l.y=n/i,d.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=i;t++){const n=(i+1)*(e-1)+(t-1),r=(i+1)*e+(t-1),s=(i+1)*e+t,a=(i+1)*(e-1)+t;p.push(n,r,a),p.push(r,s,a)}}()}(),this.setIndex(p),this.setAttribute("position",new Mm(u,3)),this.setAttribute("normal",new Mm(h,3)),this.setAttribute("uv",new Mm(d,2))}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 Tx((new Dy[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Ex extends Fm{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,i=new Rp,r=new Rp;if(null!==e.index){const s=e.attributes.position,a=e.index;let o=e.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let e=0,l=o.length;e<l;++e){const l=o[e],c=l.start;for(let e=c,o=c+l.count;e<o;e+=3)for(let o=0;o<3;o++){const l=a.getX(e+o),c=a.getX(e+(o+1)%3);i.fromBufferAttribute(s,l),r.fromBufferAttribute(s,c),!0===Ax(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{const s=e.attributes.position;for(let e=0,a=s.count/3;e<a;e++)for(let a=0;a<3;a++){const o=3*e+a,l=3*e+(a+1)%3;i.fromBufferAttribute(s,o),r.fromBufferAttribute(s,l),!0===Ax(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new Mm(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Ax(e,t,n){const i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var Rx=Object.freeze({__proto__:null,BoxGeometry:ty,CapsuleGeometry:ny,CircleGeometry:iy,ConeGeometry:sy,CylinderGeometry:ry,DodecahedronGeometry:oy,EdgesGeometry:dy,ExtrudeGeometry:px,IcosahedronGeometry:mx,LatheGeometry:gx,OctahedronGeometry:vx,PlaneGeometry:yx,PolyhedronGeometry:ay,RingGeometry:xx,ShapeGeometry:bx,SphereGeometry:_x,TetrahedronGeometry:wx,TorusGeometry:Sx,TorusKnotGeometry:Mx,TubeGeometry:Tx,WireframeGeometry:Ex});class Cx extends Gm{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Nf(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}}function Px(e){const t={};for(const n in e){t[n]={};for(const i in e[n]){const r=e[n][i];if(Lx(r))r.isRenderTargetTexture?(up("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null):t[n][i]=r.clone();else if(Array.isArray(r))if(Lx(r[0])){const e=[];for(let t=0,n=r.length;t<n;t++)e[t]=r[t].clone();t[n][i]=e}else t[n][i]=r.slice();else t[n][i]=r}}return t}function Ix(e){const t={};for(let n=0;n<e.length;n++){const i=Px(e[n]);for(const e in i)t[e]=i[e]}return t}function Lx(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function Dx(e){const t=e.getRenderTarget();return null===t?e.outputColorSpace:!0===t.isXRRenderTarget?t.texture.colorSpace:Fp.workingColorSpace}const Nx={clone:Px,merge:Ix};class Ox extends Gm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",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,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Px(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}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 n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),void 0!==e.uniforms)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=(new Nf).setHex(i.value);break;case"v2":this.uniforms[n].value=(new Ep).fromArray(i.value);break;case"v3":this.uniforms[n].value=(new Rp).fromArray(i.value);break;case"v4":this.uniforms[n].value=(new qp).fromArray(i.value);break;case"m3":this.uniforms[n].value=(new Ip).fromArray(i.value);break;case"m4":this.uniforms[n].value=(new Jp).fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(void 0!==e.defines&&(this.defines=e.defines),void 0!==e.vertexShader&&(this.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(this.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(this.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)this.extensions[t]=e.extensions[t];return void 0!==e.lights&&(this.lights=e.lights),void 0!==e.clipping&&(this.clipping=e.clipping),this}}class Fx extends Ox{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class kx extends Gm{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Nf(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 Nf(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ep(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 cf,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 Ux extends kx{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 Ep(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return bp(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Nf(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 Nf(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Nf(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 zx extends Gm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Nf(16777215),this.specular=new Nf(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nf(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ep(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new cf,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 Bx extends Gm{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Nf(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nf(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ep(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 Vx extends Gm{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ep(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 Gx extends Gm{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Nf(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nf(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ep(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new cf,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 Hx extends Gm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 Wx extends Gm{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 jx extends Gm{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Nf(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ep(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 Xx extends Rv{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 qx(e,t){return e&&e.constructor!==t?"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e):e}function $x(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort(function(t,n){return e[t]-e[n]}),n}function Yx(e,t,n){const i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r}function Kx(e,t,n,i){let r=1,s=e[0];for(;void 0!==s&&void 0===s[i];)s=e[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(t.push(s.time),n.push(...a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(t.push(s.time),a.toArray(n,n.length)),s=e[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(t.push(s.time),n.push(a)),s=e[r++]}while(void 0!==s)}class Zx{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let s=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){const a=t[1];e<a&&(n=2,r=a);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}for(;n<s;){const i=n+s>>>1;e<t[i]?s=i:n=i+1}if(i=t[n],r=t[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let e=0;e!==i;++e)t[e]=n[r+e];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class Jx extends Zx{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ld,endingEnd:Ld}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,s=e+1,a=i[r],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case Dd:r=e,a=2*t-n;break;case Nd:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case Dd:s=e,o=2*n-t;break;case Nd:s=1,o=n+i[1]-i[0];break;default:s=e-1,o=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-n),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),f=p*p,m=f*p,g=-h*m+2*h*f-h*p,v=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let e=0;e!==a;++e)r[e]=g*s[c+e]+v*s[l+e]+y*s[o+e]+x*s[u+e];return r}}class Qx extends Zx{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=(n-t)/(i-t),u=1-c;for(let e=0;e!==a;++e)r[e]=s[l+e]*u+s[o+e]*c;return r}}class eb extends Zx{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class tb extends Zx{interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=this.inTangents,u=this.outTangents;if(!c||!u){const e=(n-t)/(i-t),c=1-e;for(let t=0;t!==a;++t)r[t]=s[l+t]*c+s[o+t]*e;return r}const h=2*a,d=e-1;for(let p=0;p!==a;++p){const a=s[l+p],f=s[o+p],m=d*h+2*p,g=u[m],v=u[m+1],y=e*h+2*p,x=c[y],b=c[y+1];let _,w,S,M,T,E=(n-t)/(i-t);for(let e=0;e<8;e++){_=E*E,w=_*E,S=1-E,M=S*S,T=M*S;const e=T*t+3*M*E*g+3*S*_*x+w*i-n;if(Math.abs(e)<1e-10)break;const r=3*M*(g-t)+6*S*E*(x-g)+3*_*(i-x);if(Math.abs(r)<1e-10)break;E-=e/r,E=Math.max(0,Math.min(1,E))}r[p]=T*a+3*M*E*v+3*S*_*b+w*f}return r}}class nb{constructor(e,t,n,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=qx(t,this.TimeBufferType),this.values=qx(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:qx(e.times,Array),values:qx(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new eb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Qx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Jx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new tb(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Rd:t=this.InterpolantFactoryMethodDiscrete;break;case Cd:t=this.InterpolantFactoryMethodLinear;break;case Pd:t=this.InterpolantFactoryMethodSmooth;break;case Id:t=this.InterpolantFactoryMethodBezier}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return up("KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Rd;case this.InterpolantFactoryMethodLinear:return Cd;case this.InterpolantFactoryMethodSmooth:return Pd;case this.InterpolantFactoryMethodBezier:return Id}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,s=i-1;for(;r!==i&&n[r]<e;)++r;for(;-1!==s&&n[s]>t;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(hp("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(hp("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){hp("KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==s&&s>i){hp("KeyframeTrack: Out of order keys.",this,t,i,s),e=!1;break}s=i}if(void 0!==i&&ip(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){hp("KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Pd,r=e.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=e[a];if(o!==e[a+1]&&(1!==a||o!==e[0]))if(i)r=!0;else{const e=a*n,i=e-n,s=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[i+a]||n!==t[s+a]){r=!0;break}}}if(r){if(a!==s){e[s]=e[a];const i=a*n,r=s*n;for(let e=0;e!==n;++e)t[r+e]=t[i+e]}++s}}if(r>0){e[s]=e[r];for(let e=r*n,i=s*n,a=0;a!==n;++a)t[i+a]=t[e+a];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}nb.prototype.ValueTypeName="",nb.prototype.TimeBufferType=Float32Array,nb.prototype.ValueBufferType=Float32Array,nb.prototype.DefaultInterpolation=Cd;class ib extends nb{constructor(e,t,n){super(e,t,n)}}ib.prototype.ValueTypeName="bool",ib.prototype.ValueBufferType=Array,ib.prototype.DefaultInterpolation=Rd,ib.prototype.InterpolantFactoryMethodLinear=void 0,ib.prototype.InterpolantFactoryMethodSmooth=void 0;class rb extends nb{constructor(e,t,n,i){super(e,t,n,i)}}rb.prototype.ValueTypeName="color";class sb extends nb{constructor(e,t,n,i){super(e,t,n,i)}}sb.prototype.ValueTypeName="number";class ab extends Zx{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Ap.slerpFlat(r,0,s,l-a,s,l,o);return r}}class ob extends nb{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new ab(this.times,this.values,this.getValueSize(),e)}}ob.prototype.ValueTypeName="quaternion",ob.prototype.InterpolantFactoryMethodSmooth=void 0;class lb extends nb{constructor(e,t,n){super(e,t,n)}}lb.prototype.ValueTypeName="string",lb.prototype.ValueBufferType=Array,lb.prototype.DefaultInterpolation=Rd,lb.prototype.InterpolantFactoryMethodLinear=void 0,lb.prototype.InterpolantFactoryMethodSmooth=void 0;class cb extends nb{constructor(e,t,n,i){super(e,t,n,i)}}cb.prototype.ValueTypeName="vector";class ub{constructor(e="",t=-1,n=[],i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=xp(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(hb(n[e]).scale(i));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=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,i=n.length;e!==i;++e)t.push(nb.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,s=[];for(let e=0;e<r;e++){let a=[],o=[];a.push((e+r-1)%r,e,(e+1)%r),o.push(0,1,0);const l=$x(a);a=Yx(a,1,l),o=Yx(o,1,l),i||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new sb(".morphTargetInfluences["+t[e].name+"]",a,o).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],s=n.name.match(r);if(s&&s.length>1){const e=s[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const s=[];for(const e in i)s.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return s}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,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 t=0;t<this.tracks.length;t++)e.push(this.tracks[t].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 hb(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sb;case"vector":case"vector2":case"vector3":case"vector4":return cb;case"color":return rb;case"quaternion":return ob;case"bool":case"boolean":return ib;case"string":return lb}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];Kx(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const db={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(pb(e)||(this.files[e]=t))},get:function(e){if(!1!==this.enabled&&!pb(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function pb(e){try{const t=e.slice(e.indexOf(":")+1);return"blob:"===new URL(t).protocol}catch(e){return!1}}class fb{constructor(e,t,n){const i=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,!1===s&&void 0!==i.onStart&&i.onStart(e,a,o),s=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,o),a===o&&(s=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return e=e.normalize("NFC"),r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],i=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}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 mb=new fb;class gb{constructor(e){this.manager=void 0!==e?e:mb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,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}}gb.DEFAULT_MATERIAL_NAME="__DEFAULT";const vb={};class yb extends Error{constructor(e,t){super(e),this.response=t}}class xb extends gb{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=db.get(`file:${e}`);if(void 0!==r)return this.manager.itemStart(e),void setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);if(void 0!==vb[e])return void vb[e].push({onLoad:t,onProgress:n,onError:i});vb[e]=[],vb[e].push({onLoad:t,onProgress:n,onError:i});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(s).then(t=>{if(200===t.status||0===t.status){if(0===t.status&&up("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=vb[e],i=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then(({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(i)}e.enqueue(r),t()}},t=>{e.error(t)})}()}});return new Response(l)}throw new yb(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>(new DOMParser).parseFromString(e,a));case"json":return e.json();default:if(""===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then(e=>i.decode(e))}}}).then(t=>{db.add(`file:${e}`,t);const n=vb[e];delete vb[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onLoad&&i.onLoad(t)}}).catch(t=>{const n=vb[e];if(void 0===n)throw this.manager.itemError(e),t;delete vb[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onError&&i.onError(t)}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}}const bb=new WeakMap;class _b extends gb{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=db.get(`image:${e}`);if(void 0!==s){if(!0===s.complete)r.manager.itemStart(e),setTimeout(function(){t&&t(s),r.manager.itemEnd(e)},0);else{let e=bb.get(s);void 0===e&&(e=[],bb.set(s,e)),e.push({onLoad:t,onError:i})}return s}const a=rp("img");function o(){c(),t&&t(this);const n=bb.get(this)||[];for(let e=0;e<n.length;e++){const t=n[e];t.onLoad&&t.onLoad(this)}bb.delete(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),db.remove(`image:${e}`);const n=bb.get(this)||[];for(let e=0;e<n.length;e++){const i=n[e];i.onError&&i.onError(t)}bb.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),db.add(`image:${e}`,a),r.manager.itemStart(e),a.src=e,a}}class wb extends Ef{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Nf(e),this.intensity=t}dispose(){this.dispatchEvent({type:"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,t}}class Sb extends wb{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ef.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Nf(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Mb=new Jp,Tb=new Rp,Eb=new Rp;class Ab{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ep(512,512),this.mapType=Sh,this.map=null,this.mapPass=null,this.matrix=new Jp,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new av,this._frameExtents=new Ep(1,1),this._viewportCount=1,this._viewports=[new qp(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Tb.setFromMatrixPosition(e.matrixWorld),t.position.copy(Tb),Eb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Eb),t.updateMatrixWorld(),Mb.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Mb,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===ep||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Mb)}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.biasNode=e.biasNode,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Rb=new Rp,Cb=new Ap,Pb=new Rp;class Ib extends Ef{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jp,this.projectionMatrix=new Jp,this.projectionMatrixInverse=new Jp,this.coordinateSystem=Qd,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.matrixWorld.decompose(Rb,Cb,Pb),1===Pb.x&&1===Pb.y&&1===Pb.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Rb,Cb,Pb.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Rb,Cb,Pb),1===Pb.x&&1===Pb.y&&1===Pb.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Rb,Cb,Pb.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const Lb=new Rp,Db=new Ep,Nb=new Ep;class Ob extends Ib{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*yp*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*vp*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*yp*Math.atan(Math.tan(.5*vp*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,n){Lb.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Lb.x,Lb.y).multiplyScalar(-e/Lb.z),Lb.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Lb.x,Lb.y).multiplyScalar(-e/Lb.z)}getViewSize(e,t){return this.getViewBounds(e,Db,Nb),t.subVectors(Nb,Db)}setViewOffset(e,t,n,i,r,s){this.aspect=e/t,null===this.view&&(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*vp*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/e,t-=s.offsetY*n/a,i*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Fb extends Ab{constructor(){super(new Ob(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=2*yp*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class kb extends wb{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ef.DEFAULT_UP),this.updateMatrix(),this.target=new Ef,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Fb}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.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.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class Ub extends Ab{constructor(){super(new Ob(90,1,.5,500)),this.isPointLightShadow=!0}}class zb extends wb{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Ub}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.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}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Bb extends Ib{constructor(e=-1,t=1,n=1,i=-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=n,this.bottom=i,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=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){null===this.view&&(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,s=n+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}class Vb extends Ab{constructor(){super(new Bb(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Gb extends wb{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ef.DEFAULT_UP),this.updateMatrix(),this.target=new Ef,this.shadow=new Vb}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Hb extends wb{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Wb extends wb{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}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 jb{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Rp)}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 n=e.x,i=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*i),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*n),t.addScaledVector(s[4],n*i*1.092548),t.addScaledVector(s[5],i*r*1.092548),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],n*r*1.092548),t.addScaledVector(s[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*i),t.addScaledVector(s[2],1.023328*r),t.addScaledVector(s[3],1.023328*n),t.addScaledVector(s[4],.858086*n*i),t.addScaledVector(s[5],.858086*i*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],.858086*n*r),t.addScaledVector(s[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],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 n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class Xb extends wb{constructor(e=new jb,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}const qb={};class $b extends gb{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,s=new xb(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):hp(t),r.manager.itemError(e)}},n,i)}parse(e){const t=this.createMaterialFromType(e.type);return t.fromJSON(e,this.textures),t}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return $b.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:Cx,SpriteMaterial:Hm,RawShaderMaterial:Fx,ShaderMaterial:Ox,PointsMaterial:Gv,MeshPhysicalMaterial:Ux,MeshStandardMaterial:kx,MeshPhongMaterial:zx,MeshToonMaterial:Bx,MeshNormalMaterial:Vx,MeshLambertMaterial:Gx,MeshDepthMaterial:Hx,MeshDistanceMaterial:Wx,MeshBasicMaterial:mg,MeshMatcapMaterial:jx,LineDashedMaterial:Xx,LineBasicMaterial:Rv,Material:Gm,...qb}[e];let n;return void 0===t?(dp(`MaterialLoader: Unknown material type "${e}". Use .registerMaterial() before starting the deserialization process.`),n=new Gm):n=new t,n}static registerMaterial(e,t){qb[e]=t}}class Yb{static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===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 Kb extends Fm{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 Zb extends gb{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new xb(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):hp(t),r.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(e,i){if(void 0!==t[i])return t[i];const r=e.interleavedBuffers[i],s=function(e,t){if(void 0!==n[t])return n[t];const i=e.arrayBuffers,r=i[t],s=new Uint32Array(r).buffer;return n[t]=s,s}(e,r.buffer),a=np(r.type,s),o=new km(a,r.stride);return o.uuid=r.uuid,t[i]=o,o}const r=e.isInstancedBufferGeometry?new Kb:new Fm,s=e.data.index;if(void 0!==s){const e=np(s.type,s.array);r.setIndex(new _m(e,1))}const a=e.data.attributes;for(const t in a){const n=a[t];let s;if(n.isInterleavedBufferAttribute){const t=i(e.data,n.data);s=new zm(t,n.itemSize,n.offset,n.normalized)}else{const e=np(n.type,n.array);s=new(n.isInstancedBufferAttribute?Wg:_m)(e,n.itemSize,n.normalized)}void 0!==n.name&&(s.name=n.name),void 0!==n.usage&&s.setUsage(n.usage),r.setAttribute(t,s)}const o=e.data.morphAttributes;if(o)for(const t in o){const n=o[t],s=[];for(let t=0,r=n.length;t<r;t++){const r=n[t];let a;if(r.isInterleavedBufferAttribute){const t=i(e.data,r.data);a=new zm(t,r.itemSize,r.offset,r.normalized)}else{const e=np(r.type,r.array);a=new _m(e,r.itemSize,r.normalized)}void 0!==r.name&&(a.name=r.name),s.push(a)}r.morphAttributes[t]=s}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const t=l[e];r.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;return void 0!==c&&(r.boundingSphere=(new Rm).fromJSON(c)),e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}}const Jb={};const Qb={UVMapping:lh,CubeReflectionMapping:ch,CubeRefractionMapping:uh,EquirectangularReflectionMapping:hh,EquirectangularRefractionMapping:dh,CubeUVReflectionMapping:ph},e_={RepeatWrapping:fh,ClampToEdgeWrapping:mh,MirroredRepeatWrapping:gh},t_={NearestFilter:vh,NearestMipmapNearestFilter:yh,NearestMipmapLinearFilter:xh,LinearFilter:bh,LinearMipmapNearestFilter:_h,LinearMipmapLinearFilter:wh},n_=new WeakMap;let i_;class r_{static getContext(){return void 0===i_&&(i_=new(window.AudioContext||window.webkitAudioContext)),i_}static setContext(e){i_=e}}const s_=new Jp,a_=new Jp,o_=new Jp;const l_=-90;class c_ extends Ef{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ob(l_,1,e,t);i.layers=this.layers,this.add(i);const r=new Ob(l_,1,e,t);r.layers=this.layers,this.add(r);const s=new Ob(l_,1,e,t);s.layers=this.layers,this.add(s);const a=new Ob(l_,1,e,t);a.layers=this.layers,this.add(a);const o=new Ob(l_,1,e,t);o.layers=this.layers,this.add(o);const l=new Ob(l_,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(const e of t)this.remove(e);if(e===Qd)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.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),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==ep)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.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),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;m=!0===e.isWebGLRenderer?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,i),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,i),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,2,i),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,i),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,4,i),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,c),e.setRenderTarget(u,h,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class u_ extends Ob{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class h_{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,void 0!==e.hidden&&(this._pageVisibilityHandler=d_.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(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 null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==e?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function d_(){!1===this._document.hidden&&this.reset()}const p_=new Rp,f_=new Ap,m_=new Rp,g_=new Rp,v_=new Rp;class y_ extends Ef{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(!0===this.isPlaying)return void up("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void up("Audio: this Audio has no playback control.");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(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;up("Audio: this Audio has no playback control.")}stop(e=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this;up("Audio: this Audio has no playback control.")}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(!1!==this._connected){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=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,!0===this.isPlaying&&void 0!==this.source.detune&&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(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;up("Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return!1===this.hasPlaybackControl?(up("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;up("Audio: this Audio has no playback control.")}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),"buffer"!==e.sourceType?(up("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 x_=new Rp,b_=new Ap,__=new Rp,w_=new Rp;class S_{constructor(e,t,n){let i,r,s;switch(this.binding=e,this.valueSize=n,t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,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 n=this.buffer,i=this.valueSize,r=e*i+i;let s=this.cumulativeWeight;if(0===s){for(let e=0;e!==i;++e)n[r+e]=n[e];s=t}else{s+=t;const e=t/s;this._mixBufferRegion(n,r,0,e,i)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const e=t*this._origIndex;this._mixBufferRegion(n,i,e,1-r,t)}s>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=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 n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Ap.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const s=this._workIndex*r;Ap.multiplyQuaternionsFlat(e,s,e,t,e,n),Ap.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[n+s]*i}}}const M_="\\[\\]\\.:\\/",T_=new RegExp("["+M_+"]","g"),E_="[^"+M_+"]",A_="[^"+M_.replace("\\.","")+"]",R_=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",E_)+/(WCOD+)?/.source.replace("WCOD",A_)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",E_)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",E_)+"$"),C_=["material","materials","bones","map"];class P_{constructor(e,t,n){this.path=t,this.parsedPath=n||P_.parseTrackName(t),this.node=P_.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new P_.Composite(e,t,n):new P_(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(T_,"")}static parseTrackName(e){const t=R_.exec(e);if(null===t)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==C_.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i<e.length;i++){const r=e[i];if(r.name===t||r.uuid===t)return r;const s=n(r.children);if(s)return s}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_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 n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=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,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=P_.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void up("PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=t.objectIndex;switch(n){case"materials":if(!e.material)return void hp("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void hp("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void hp("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===i){i=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void hp("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void hp("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[n])return void hp("PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==i){if(void 0===e[i])return void hp("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[i]}}const s=e[i];if(void 0===s){return void hp("PropertyBinding: Trying to update property for track: "+t.nodeName+"."+i+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,!0===e.isMaterial?a=this.Versioning.NeedsUpdate:!0===e.isObject3D&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!e.geometry)return void hp("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void hp("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}P_.Composite=class{constructor(e,t,n){const i=n||P_.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},P_.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},P_.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},P_.prototype.GetterByBindingType=[P_.prototype._getValue_direct,P_.prototype._getValue_array,P_.prototype._getValue_arrayElement,P_.prototype._getValue_toArray],P_.prototype.SetterByBindingTypeAndVersioning=[[P_.prototype._setValue_direct,P_.prototype._setValue_direct_setNeedsUpdate,P_.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[P_.prototype._setValue_array,P_.prototype._setValue_array_setNeedsUpdate,P_.prototype._setValue_array_setMatrixWorldNeedsUpdate],[P_.prototype._setValue_arrayElement,P_.prototype._setValue_arrayElement_setNeedsUpdate,P_.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[P_.prototype._setValue_fromArray,P_.prototype._setValue_fromArray_setNeedsUpdate,P_.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class I_{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,s=r.length,a=new Array(s),o={endingStart:Ld,endingEnd:Ld};for(let e=0;e!==s;++e){const t=r[e].createInterpolant(null);a[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,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&&0!==this.timeScale&&null===this._startTime&&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,n=!1){if(e.fadeOut(t),this.fadeIn(t),!0===n){const n=this._clip.duration,i=e._clip.duration,r=i/n,s=n/i;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,r,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(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,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/s,l[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);const s=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===Fd)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(s),t[n].accumulateAdditive(a);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(s),t[n].accumulate(i,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(0===t?this.paused=!0:(null!==this._restoreTimeScale&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping())}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const s=2202===n;if(0===e)return-1===r||!s||1&~r?i:t-i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this._loopCount=r,this.time=i;if(s&&!(1&~r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Dd,i.endingEnd=Dd):(i.endingStart=e?this.zeroSlopeAtStart?Dd:Ld:Nd,i.endingEnd=t?this.zeroSlopeAtEnd?Dd:Ld:Nd)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}const L_=new Float32Array(1);class D_{constructor(e){this.value=e}clone(){return new D_(void 0===this.value.clone?this.value:this.value.clone())}}let N_=0;const O_=new Jp;class F_{constructor(e,t,n=0,i=1/0){this.ray=new fg(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new uf,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.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):hp("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return O_.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(O_),this}intersectObject(e,t=!0,n=[]){return U_(e,this,n,t),n.sort(k_),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)U_(e[i],this,n,t);return n.sort(k_),n}}function k_(e,t){return e.distance-t.distance}function U_(e,t,n,i){let r=!0;if(e.layers.test(t.layers)){!1===e.raycast(t,n)&&(r=!1)}if(!0===r&&!0===i){const i=e.children;for(let e=0,r=i.length;e<r;e++)U_(i[e],t,n,!0)}}class z_{static{z_.prototype.isMatrix2=!0}constructor(e,t,n,i){this.elements=[1,0,0,1],void 0!==e&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}const B_=new Ep;class V_{constructor(e=new Ep(1/0,1/0),t=new Ep(-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,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=B_.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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,B_).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 G_=new Rp,H_=new Rp,W_=new Rp,j_=new Rp,X_=new Rp,q_=new Rp,$_=new Rp;const Y_=new Rp;const K_=new Rp,Z_=new Jp,J_=new Jp;function Q_(e){const t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push(...Q_(e.children[n]));return t}const ew=new Rp,tw=new Nf,nw=new Nf;class iw extends Bv{constructor(e=10,t=10,n=4473924,i=8947848){n=new Nf(n),i=new Nf(i);const r=t/2,s=e/t,a=e/2,o=[],l=[];for(let e=0,c=0,u=-a;e<=t;e++,u+=s){o.push(-a,0,u,a,0,u),o.push(u,0,-a,u,0,a);const t=e===r?n:i;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new Fm;c.setAttribute("position",new Mm(o,3)),c.setAttribute("color",new Mm(l,3));super(c,new Rv({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const rw=new Rp,sw=new Rp,aw=new Rp;const ow=new Rp,lw=new Ib;function cw(e,t,n,i,r,s,a){ow.set(r,s,a).unproject(i);const o=t[e];if(void 0!==o){const e=n.getAttribute("position");for(let t=0,n=o.length;t<n;t++)e.setXYZ(o[t],ow.x,ow.y,ow.z)}}const uw=new Qf;const hw=new Rp;let dw,pw;function fw(e,t,n,i){const r=function(e){switch(e){case Sh:case Mh:return{byteLength:1,components:1};case Eh:case Th:case Ph:return{byteLength:2,components:1};case Ih:case Lh:return{byteLength:2,components:4};case Rh:case Ah:case Ch:return{byteLength:4,components:1};case Nh:case Oh:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}(i);switch(n){case Fh:return e*t;case Vh:case Gh:return e*t/r.components*r.byteLength;case Hh:case Wh:return e*t*2/r.components*r.byteLength;case kh:return e*t*3/r.components*r.byteLength;case Uh:case jh:return e*t*4/r.components*r.byteLength;case Xh:case qh:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case $h:case Yh:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Zh:case Qh:return Math.max(e,16)*Math.max(t,8)/4;case Kh:case Jh:return Math.max(e,8)*Math.max(t,8)/2;case ed:case td:case id:case rd:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case nd:case sd:case ad:case od:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case ld:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case cd:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case ud:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case hd:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case dd:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case pd:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case fd:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case md:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case gd:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case vd:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case yd:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case xd:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case bd:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case _d:case wd:case Sd:return Math.ceil(e/4)*Math.ceil(t/4)*16;case Md:case Td:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Ed:case Ad:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function mw(){let e=null,t=!1,n=null,i=null;function r(t,s){n(t,s),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&null!==e&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){null!==e&&e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function gw(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=t.get(n);if(void 0===r)t.set(n,function(t,n){const i=t.array,r=t.usage,s=i.byteLength,a=e.createBuffer();let o;if(e.bindBuffer(n,a),e.bufferData(n,i,r),t.onUploadCallback(),i instanceof Float32Array)o=e.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)o=e.HALF_FLOAT;else if(i instanceof Uint16Array)o=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=e.SHORT;else if(i instanceof Uint32Array)o=e.UNSIGNED_INT;else if(i instanceof Int32Array)o=e.INT;else if(i instanceof Int8Array)o=e.BYTE;else if(i instanceof Uint8Array)o=e.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=e.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version,size:s}}(n,i));else if(r.version<n.version){if(r.size!==n.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.");!function(t,n,i){const r=n.array,s=n.updateRanges;if(e.bindBuffer(i,t),0===s.length)e.bufferSubData(i,0,r);else{s.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<s.length;e++){const n=s[t],i=s[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++t,s[t]=i)}s.length=t+1;for(let t=0,n=s.length;t<n;t++){const n=s[t];e.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:vu}})),"undefined"!=typeof window&&(window.__THREE__IWER__?up("WARNING: Multiple instances of Three.js being imported."):window.__THREE__IWER__=vu);const vw={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif\n#include <lightprobes_pars_fragment>",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid 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 ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\treturn 0.5 / max( gv + gl, EPSILON );\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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 ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\n#endif\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid 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 ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid 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) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",lightprobes_pars_fragment:"#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t\t#ifdef FLIP_SIDED\n\t\t\tvBitangent = - vBitangent;\n\t\t#endif\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},yw={common:{diffuse:{value:new Nf(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ip},alphaMap:{value:null},alphaMapTransform:{value:new Ip},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ip}},envmap:{envMap:{value:null},envMapRotation:{value:new Ip},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ip}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ip}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ip},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ip},normalScale:{value:new Ep(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ip},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ip}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ip}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ip}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Nf(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new Rp},probesMax:{value:new Rp},probesResolution:{value:new Rp}},points:{diffuse:{value:new Nf(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ip},alphaTest:{value:0},uvTransform:{value:new Ip}},sprite:{diffuse:{value:new Nf(16777215)},opacity:{value:1},center:{value:new Ep(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ip},alphaMap:{value:null},alphaMapTransform:{value:new Ip},alphaTest:{value:0}}},xw={basic:{uniforms:Ix([yw.common,yw.specularmap,yw.envmap,yw.aomap,yw.lightmap,yw.fog]),vertexShader:vw.meshbasic_vert,fragmentShader:vw.meshbasic_frag},lambert:{uniforms:Ix([yw.common,yw.specularmap,yw.envmap,yw.aomap,yw.lightmap,yw.emissivemap,yw.bumpmap,yw.normalmap,yw.displacementmap,yw.fog,yw.lights,{emissive:{value:new Nf(0)},envMapIntensity:{value:1}}]),vertexShader:vw.meshlambert_vert,fragmentShader:vw.meshlambert_frag},phong:{uniforms:Ix([yw.common,yw.specularmap,yw.envmap,yw.aomap,yw.lightmap,yw.emissivemap,yw.bumpmap,yw.normalmap,yw.displacementmap,yw.fog,yw.lights,{emissive:{value:new Nf(0)},specular:{value:new Nf(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:vw.meshphong_vert,fragmentShader:vw.meshphong_frag},standard:{uniforms:Ix([yw.common,yw.envmap,yw.aomap,yw.lightmap,yw.emissivemap,yw.bumpmap,yw.normalmap,yw.displacementmap,yw.roughnessmap,yw.metalnessmap,yw.fog,yw.lights,{emissive:{value:new Nf(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:vw.meshphysical_vert,fragmentShader:vw.meshphysical_frag},toon:{uniforms:Ix([yw.common,yw.aomap,yw.lightmap,yw.emissivemap,yw.bumpmap,yw.normalmap,yw.displacementmap,yw.gradientmap,yw.fog,yw.lights,{emissive:{value:new Nf(0)}}]),vertexShader:vw.meshtoon_vert,fragmentShader:vw.meshtoon_frag},matcap:{uniforms:Ix([yw.common,yw.bumpmap,yw.normalmap,yw.displacementmap,yw.fog,{matcap:{value:null}}]),vertexShader:vw.meshmatcap_vert,fragmentShader:vw.meshmatcap_frag},points:{uniforms:Ix([yw.points,yw.fog]),vertexShader:vw.points_vert,fragmentShader:vw.points_frag},dashed:{uniforms:Ix([yw.common,yw.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:vw.linedashed_vert,fragmentShader:vw.linedashed_frag},depth:{uniforms:Ix([yw.common,yw.displacementmap]),vertexShader:vw.depth_vert,fragmentShader:vw.depth_frag},normal:{uniforms:Ix([yw.common,yw.bumpmap,yw.normalmap,yw.displacementmap,{opacity:{value:1}}]),vertexShader:vw.meshnormal_vert,fragmentShader:vw.meshnormal_frag},sprite:{uniforms:Ix([yw.sprite,yw.fog]),vertexShader:vw.sprite_vert,fragmentShader:vw.sprite_frag},background:{uniforms:{uvTransform:{value:new Ip},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:vw.background_vert,fragmentShader:vw.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ip}},vertexShader:vw.backgroundCube_vert,fragmentShader:vw.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:vw.cube_vert,fragmentShader:vw.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:vw.equirect_vert,fragmentShader:vw.equirect_frag},distance:{uniforms:Ix([yw.common,yw.displacementmap,{referencePosition:{value:new Rp},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:vw.distance_vert,fragmentShader:vw.distance_frag},shadow:{uniforms:Ix([yw.lights,yw.fog,{color:{value:new Nf(0)},opacity:{value:1}}]),vertexShader:vw.shadow_vert,fragmentShader:vw.shadow_frag}};xw.physical={uniforms:Ix([xw.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ip},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ip},clearcoatNormalScale:{value:new Ep(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ip},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ip},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ip},sheen:{value:0},sheenColor:{value:new Nf(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ip},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ip},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ip},transmissionSamplerSize:{value:new Ep},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ip},attenuationDistance:{value:0},attenuationColor:{value:new Nf(0)},specularColor:{value:new Nf(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ip},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ip},anisotropyVector:{value:new Ep},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ip}}]),vertexShader:vw.meshphysical_vert,fragmentShader:vw.meshphysical_frag};const bw={r:0,b:0,g:0},_w=new Jp,ww=new Ip;function Sw(e,t,n,i,r,s){const a=new Nf(0);let o,l,c=!0===r?0:1,u=null,h=0,d=null;function p(e){let n=!0===e.isScene?e.background:null;if(n&&n.isTexture){const i=e.backgroundBlurriness>0;n=t.get(n,i)}return n}function f(t,i){t.getRGB(bw,Dx(e)),n.buffers.color.setClear(bw.r,bw.g,bw.b,i,s)}return{getClearColor:function(){return a},setClearColor:function(e,t=1){a.set(e),c=t,f(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,f(a,c)},render:function(t){let i=!1;const r=p(t);null===r?f(a,c):r&&r.isColor&&(f(r,1),i=!0);const o=e.xr.getEnvironmentBlendMode();"additive"===o?n.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===o&&n.buffers.color.setClear(0,0,0,0,s),(e.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const r=p(n);r&&(r.isCubeTexture||r.mapping===ph)?(void 0===l&&(l=new Ag(new ty(1e4,1e4,1e4),new Ox({name:"BackgroundCubeMaterial",uniforms:Px(xw.backgroundCube.uniforms),vertexShader:xw.backgroundCube.vertexShader,fragmentShader:xw.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=r,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(_w.makeRotationFromEuler(n.backgroundRotation)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&l.material.uniforms.backgroundRotation.value.premultiply(ww),l.material.toneMapped=Fp.getTransfer(r.colorSpace)!==Vd,u===r&&h===r.version&&d===e.toneMapping||(l.material.needsUpdate=!0,u=r,h=r.version,d=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):r&&r.isTexture&&(void 0===o&&(o=new Ag(new yx(2,2),new Ox({name:"BackgroundMaterial",uniforms:Px(xw.background.uniforms),vertexShader:xw.background.vertexShader,fragmentShader:xw.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=r,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=Fp.getTransfer(r.colorSpace)!==Vd,!0===r.matrixAutoUpdate&&r.updateMatrix(),o.material.uniforms.uvTransform.value.copy(r.matrix),u===r&&h===r.version&&d===e.toneMapping||(o.material.needsUpdate=!0,u=r,h=r.version,d=e.toneMapping),o.layers.enableAll(),t.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function Mw(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=c(null);let s=r,a=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],i=[],r=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function u(){const e=s.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function h(e){d(e,0)}function d(t,n){const i=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;i[t]=1,0===r[t]&&(e.enableVertexAttribArray(t),r[t]=1),a[t]!==n&&(e.vertexAttribDivisor(t,n),a[t]=n)}function p(){const t=s.newAttributes,n=s.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function f(t,n,i,r,s,a,o){!0===o?e.vertexAttribIPointer(t,n,i,s,a):e.vertexAttribPointer(t,n,i,r,s,a)}function m(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let v=!1;const y=function(t,n,r,s){const a=!0===s.wireframe;let o=i[n.id];void 0===o&&(o={},i[n.id]=o);const l=!0===t.isInstancedMesh?t.id:0;let u=o[l];void 0===u&&(u={},o[l]=u);let h=u[r.id];void 0===h&&(h={},u[r.id]=h);let d=h[a];void 0===d&&(d=c(e.createVertexArray()),h[a]=d);return d}(n,m,l,r);s!==y&&(s=y,o(s.object)),v=function(e,t,n,i){const r=s.attributes,a=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){const n=r[t];let i=a[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}}return s.attributesNum!==o||s.index!==i}(n,m,l,g),v&&function(e,t,n,i){const r={},a=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){let n=a[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(n,i,r,s){u();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=t.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,p=l.bytesPerElement,m=u===e.INT||u===e.UNSIGNED_INT||o.gpuType===Ah;if(o.isInterleavedBufferAttribute){const t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)d(r.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)f(r.location+e,a/r.locationSize,u,i,l*p,(g+a/r.locationSize*e)*p,m)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)d(r.location+e,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)f(r.location+e,a/r.locationSize,u,i,a*p,a/r.locationSize*e*p,m)}}else if(void 0!==l){const t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}p()}(n,r,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const e in i){const t=i[e];for(const e in t){const n=t[e];for(const e in n){const t=n[e];for(const e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;const t=i[e.id];for(const e in t){const n=t[e];for(const e in n){const t=n[e];for(const e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e.id]},releaseStatesOfObject:function(e){for(const t in i){const n=i[t],r=!0===e.isInstancedMesh?e.id:0,s=n[r];if(void 0!==s){for(const e in s){const t=s[e];for(const e in t)l(t[e].object),delete t[e];delete s[e]}delete n[r],0===Object.keys(n).length&&delete i[t]}}},releaseStatesOfProgram:function(e){for(const t in i){const n=i[t];for(const t in n){const i=n[t];if(void 0===i[e.id])continue;const r=i[e.id];for(const e in r)l(r[e].object),delete r[e];delete i[e.id]}}},initAttributes:u,enableAttribute:h,disableUnusedAttributes:p}}function Tw(e,t,n){let i;this.setMode=function(e){i=e},this.render=function(t,r){e.drawArrays(i,t,r),n.update(r,i,1)},this.renderInstances=function(t,r,s){0!==s&&(e.drawArraysInstanced(i,t,r,s),n.update(r,i,s))},this.renderMultiDraw=function(e,r,s){if(0===s)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,r,0,s);let a=0;for(let e=0;e<s;e++)a+=r[e];n.update(a,i,1)}}function Ew(e,t,n,i){let r;function s(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(up("WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control");!0===n.reversedDepthBuffer&&!1===c&&up("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(t){return t===Uh||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===Ph&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==Sh&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Ch&&!r)},precision:a,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function Aw(e){const t=this;let n=null,i=0,r=!1,s=!1;const a=new nv,o=new Ip,l={value:null,needsUpdate:!1};function c(e,n,i,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const t=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==s;++t,n+=4)a.copy(e[t]).applyMatrix4(r,o),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(a,o,u){const h=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,f=e.get(a);if(!r||null===h||0===h.length||s&&!p)s?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);t.numPlanes=i,t.numIntersection=0}();else{const e=s?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(h,o,t,u);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}ww.set(-1,0,0,0,1,0,0,0,1);const Rw=[.125,.215,.35,.446,.526,.582],Cw=20,Pw=new Bb,Iw=new Nf;let Lw=null,Dw=0,Nw=0,Ow=!1;const Fw=new Rp;class kw{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,n=.1,i=100,r={}){const{size:s=256,position:a=Fw}=r;Lw=this._renderer.getRenderTarget(),Dw=this._renderer.getActiveCubeFace(),Nw=this._renderer.getActiveMipmapLevel(),Ow=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,a),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Vw(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Bw(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(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(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Lw,Dw,Nw),this._renderer.xr.enabled=Ow,e.scissorTest=!1,zw(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ch||e.mapping===uh?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Lw=this._renderer.getRenderTarget(),Dw=this._renderer.getActiveCubeFace(),Nw=this._renderer.getActiveMipmapLevel(),Ow=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:bh,minFilter:bh,generateMipmaps:!1,type:Ph,format:Uh,colorSpace:zd,depthBuffer:!1},i=Uw(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Uw(e,t,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){const t=[],n=[],i=[];let r=e;const s=e-4+1+Rw.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);t.push(s);let o=1/s;a>e-4?o=Rw[a-e+4-1]:0===a&&(o=0),n.push(o);const l=1/(s-2),c=-l,u=1+l,h=[c,c,u,c,u,u,c,c,u,u,c,u],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),y=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let e=0;e<d;e++){const t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),y.set(h,m*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const b=new Fm;b.setAttribute("position",new _m(v,f)),b.setAttribute("uv",new _m(y,m)),b.setAttribute("faceIndex",new _m(x,g)),i.push(new Ag(b,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(Cw),r=new Rp(0,1,0),s=new Ox({name:"SphericalGaussianBlur",defines:{n:Cw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Gw(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(i,e,t),this._ggxMaterial=function(e,t,n){const i=new Ox({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Gw(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return i}(i,e,t)}return i}_compileMaterial(e){const t=new Ag(new Fm,e);this._renderer.compile(t,Pw)}_sceneToCubeUV(e,t,n,i,r){const s=new Ob(90,1,t,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,u=l.toneMapping;l.getClearColor(Iw),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new Ag(new ty,new mg({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const h=this._backgroundBox,d=h.material;let p=!1;const f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,p=!0):(d.color.copy(Iw),p=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(s.up.set(0,a[t],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x+o[t],r.y,r.z)):1===n?(s.up.set(0,0,a[t]),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y+o[t],r.z)):(s.up.set(0,a[t],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y,r.z+o[t]));const c=this._cubeSize;zw(i,n*c,t>2?c:0,c,c),l.setRenderTarget(i),p&&l.render(h,s),l.render(e,s)}l.toneMapping=u,l.autoClear=c,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ch||e.mapping===uh;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Vw()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Bw());const r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;r.uniforms.envMap.value=e;const a=this._cubeSize;zw(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Pw)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let t=1;t<i;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,a=this._lodMeshes[n];a.material=s;const o=s.uniforms,l=n/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c)*(0+1.25*l),{_lodMax:h}=this,d=this._sizeLods[n],p=3*d*(n>h-4?n-h+4:0),f=4*(this._cubeSize-d);o.envMap.value=e.texture,o.roughness.value=u,o.mipInt.value=h-t,zw(r,p,f,3*d,2*d),i.setRenderTarget(r),i.render(a,Pw),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,zw(e,p,f,3*d,2*d),i.setRenderTarget(e),i.render(a,Pw)}_blur(e,t,n,i,r){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,n,i,"latitudinal",r),this._halfBlur(s,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&hp("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const u=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*h):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):Cw;f>Cw&&up(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<Cw;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<f&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===s,a&&(u.poleAxis.value=a);const{_lodMax:v}=this;u.dTheta.value=d,u.mipInt.value=v-n;const y=this._sizeLods[i];zw(t,3*y*(i>v-4?i-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(c,Pw)}}function Uw(e,t,n){const i=new Yp(e,t,n);return i.texture.mapping=ph,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function zw(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Bw(){return new Ox({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Gw(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Vw(){return new Ox({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Gw(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Gw(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}class Hw extends Yp{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Zv(i),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 n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new ty(5,5,5),r=new Ox({name:"CubemapFromEquirect",uniforms:Px(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;const s=new Ag(i,r),a=t.minFilter;t.minFilter===wh&&(t.minFilter=bh);return new c_(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}function Ww(e){let t=new WeakMap,n=new WeakMap,i=null;function r(e,t){return t===hh?e.mapping=ch:t===dh&&(e.mapping=uh),e}function s(e){const n=e.target;n.removeEventListener("dispose",s);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}function a(e){const t=e.target;t.removeEventListener("dispose",a);const i=n.get(t);void 0!==i&&(n.delete(t),i.dispose())}return{get:function(o,l=!1){return null==o?null:l?function(t){if(t&&t.isTexture){const r=t.mapping,s=r===hh||r===dh,o=r===ch||r===uh;if(s||o){let r=n.get(t);const l=void 0!==r?r.texture.pmremVersion:0;if(t.isRenderTargetTexture&&t.pmremVersion!==l)return null===i&&(i=new kw(e)),r=s?i.fromEquirectangular(t,r):i.fromCubemap(t,r),r.texture.pmremVersion=t.pmremVersion,n.set(t,r),r.texture;if(void 0!==r)return r.texture;{const l=t.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(l)?(null===i&&(i=new kw(e)),r=s?i.fromEquirectangular(t):i.fromCubemap(t),r.texture.pmremVersion=t.pmremVersion,n.set(t,r),t.addEventListener("dispose",a),r.texture):null}}}return t}(o):function(n){if(n&&n.isTexture){const i=n.mapping;if(i===hh||i===dh){if(t.has(n)){return r(t.get(n).texture,n.mapping)}{const i=n.image;if(i&&i.height>0){const a=new Hw(i.height);return a.fromEquirectangularTexture(e,n),t.set(n,a),n.addEventListener("dispose",s),r(a.texture,n.mapping)}return null}}}return n}(o)},dispose:function(){t=new WeakMap,n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function jw(e){const t={};function n(n){if(void 0!==t[n])return t[n];const i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&dp("WebGLRenderer: "+e+" extension not supported."),t}}}function Xw(e,t,n,i){const r={},s=new WeakMap;function a(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(t.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){const n=[],i=e.index,r=e.attributes.position;let a=0;if(void 0===r)return;if(null!==i){const e=i.array;a=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],s=e[t+2];n.push(i,r,r,s,s,i)}}else{const e=r.array;a=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}const o=new(r.count>=65535?Sm:wm)(n,1);o.version=a;const l=s.get(e);l&&t.remove(l),s.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",a),r[t.id]=!0,n.memory.geometries++),t},update:function(n){const i=n.attributes;for(const n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=s.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return s.get(e)}}}function qw(e,t,n){let i,r,s;this.setMode=function(e){i=e},this.setIndex=function(e){r=e.type,s=e.bytesPerElement},this.render=function(t,a){e.drawElements(i,a,r,t*s),n.update(a,i,1)},this.renderInstances=function(t,a,o){0!==o&&(e.drawElementsInstanced(i,a,r,t*s,o),n.update(a,i,o))},this.renderMultiDraw=function(e,s,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,s,0,r,e,0,a);let o=0;for(let e=0;e<a;e++)o+=s[e];n.update(o,i,1)}}function $w(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:hp("WebGLInfo: Unknown draw mode:",i)}}}}function Yw(e,t,n){const i=new WeakMap,r=new qp;return{update:function(s,a,o){const l=s.morphTargetInfluences,c=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=void 0!==c?c.length:0;let h=i.get(a);if(void 0===h||h.count!==u){void 0!==h&&h.texture.dispose();const d=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,f=void 0!==a.morphAttributes.color,m=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let y=0;!0===d&&(y=1),!0===p&&(y=2),!0===f&&(y=3);let x=a.attributes.position.count*y,b=1;x>t.maxTextureSize&&(b=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const _=new Float32Array(x*b*4*u),w=new Kp(_,x,b,u);w.type=Ch,w.needsUpdate=!0;const S=4*y;for(let T=0;T<u;T++){const E=m[T],A=g[T],R=v[T],C=x*b*4*T;for(let P=0;P<E.count;P++){const I=P*S;!0===d&&(r.fromBufferAttribute(E,P),_[C+I+0]=r.x,_[C+I+1]=r.y,_[C+I+2]=r.z,_[C+I+3]=0),!0===p&&(r.fromBufferAttribute(A,P),_[C+I+4]=r.x,_[C+I+5]=r.y,_[C+I+6]=r.z,_[C+I+7]=0),!0===f&&(r.fromBufferAttribute(R,P),_[C+I+8]=r.x,_[C+I+9]=r.y,_[C+I+10]=r.z,_[C+I+11]=4===R.itemSize?r.w:1)}}function M(){w.dispose(),i.delete(a),a.removeEventListener("dispose",M)}h={count:u,texture:w,size:new Ep(x,b)},i.set(a,h),a.addEventListener("dispose",M)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(e,"morphTexture",s.morphTexture,n);else{let L=0;for(let N=0;N<l.length;N++)L+=l[N];const D=a.morphTargetsRelative?1:1-L;o.getUniforms().setValue(e,"morphTargetBaseInfluence",D),o.getUniforms().setValue(e,"morphTargetInfluences",l)}o.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),o.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}}}class Kw{constructor(e,t,n){if(this.renderer=e,this.DEFAULT_NUMVIEWS=2,this.maxNumViews=0,this.gl=n,this.extensions=t,this.available=this.extensions.has("OCULUS_multiview"),this.available){const e=this.extensions.get("OCULUS_multiview");this.maxNumViews=this.gl.getParameter(e.MAX_VIEWS_OVR),this.mat4=[],this.mat3=[],this.cameraArray=[];for(var i=0;i<this.maxNumViews;i++)this.mat4[i]=new Jp,this.mat3[i]=new Ip}}getCameraArray(e){return e.isArrayCamera?e.cameras:(this.cameraArray[0]=e,this.cameraArray)}updateCameraProjectionMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].projectionMatrix);t.setValue(this.gl,"projectionMatrices",this.mat4)}updateCameraViewMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].matrixWorldInverse);t.setValue(this.gl,"viewMatrices",this.mat4)}updateObjectMatricesUniforms(e,t,n){for(var i=this.getCameraArray(t),r=0;r<i.length;r++)this.mat4[r].multiplyMatrices(i[r].matrixWorldInverse,e.matrixWorld),this.mat3[r].getNormalMatrix(this.mat4[r]);n.setValue(this.gl,"modelViewMatrices",this.mat4),n.setValue(this.gl,"normalMatrices",this.mat3)}}function Zw(e,t,n,i,r){let s=new WeakMap;function a(e){const t=e.target;t.removeEventListener("dispose",a),i.releaseStatesOfObject(t),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(i){const o=r.render.frame,l=i.geometry,c=t.get(i,l);if(s.get(c)!==o&&(t.update(c),s.set(c,o)),i.isInstancedMesh&&(!1===i.hasEventListener("dispose",a)&&i.addEventListener("dispose",a),s.get(i)!==o&&(n.update(i.instanceMatrix,e.ARRAY_BUFFER),null!==i.instanceColor&&n.update(i.instanceColor,e.ARRAY_BUFFER),s.set(i,o))),i.isSkinnedMesh){const e=i.skeleton;s.get(e)!==o&&(e.update(),s.set(e,o))}return c},dispose:function(){s=new WeakMap}}}const Jw={[Qu]:"LINEAR_TONE_MAPPING",[eh]:"REINHARD_TONE_MAPPING",[th]:"CINEON_TONE_MAPPING",[nh]:"ACES_FILMIC_TONE_MAPPING",[rh]:"AGX_TONE_MAPPING",[sh]:"NEUTRAL_TONE_MAPPING",[ih]:"CUSTOM_TONE_MAPPING"};function Qw(e,t,n,i,r,s){const a=new Yp(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,depthTexture:r?new Jv(t,n):void 0}),o=new Yp(t,n,{type:Ph,depthBuffer:!1,stencilBuffer:!1}),l=new Fm;l.setAttribute("position",new Mm([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Mm([0,2,0,0,2,0],2));const c=new Fx({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),u=new Ag(l,c),h=new Bb(-1,1,1,-1,0,1);let d,p=null,f=null,m=!1,g=null,v=[],y=!1;this.setSize=function(e,t){a.setSize(e,t),o.setSize(e,t);for(let n=0;n<v.length;n++){const i=v[n];i.setSize&&i.setSize(e,t)}},this.setEffects=function(e){v=e,y=v.length>0&&!0===v[0].isRenderPass;const t=a.width,n=a.height;for(let e=0;e<v.length;e++){const i=v[e];i.setSize&&i.setSize(t,n)}},this.begin=function(e,t){if(m)return!1;if(0===e.toneMapping&&0===v.length)return!1;if(g=t,null!==t){const e=t.width,n=t.height;a.width===e&&a.height===n||this.setSize(e,n)}return!1===y&&e.setRenderTarget(a),d=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return y},this.end=function(e,t){e.toneMapping=d,m=!0;let n=a,i=o;for(let r=0;r<v.length;r++){const s=v[r];if(!1!==s.enabled&&(s.render(e,i,n,t),!1!==s.needsSwap)){const e=n;n=i,i=e}}if(p!==e.outputColorSpace||f!==e.toneMapping){p=e.outputColorSpace,f=e.toneMapping,c.defines={},Fp.getTransfer(p)===Vd&&(c.defines.SRGB_TRANSFER="");const t=Jw[f];t&&(c.defines[t]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(g),e.render(u,h),g=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const eS=new Xp,tS=new Jv(1,1),nS=new Kp,iS=new Zp,rS=new Zv,sS=[],aS=[],oS=new Float32Array(16),lS=new Float32Array(9),cS=new Float32Array(4);function uS(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let s=sS[r];if(void 0===s&&(s=new Float32Array(r),sS[r]=s),0!==t){i.toArray(s,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(s,r)}return s}function hS(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function dS(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function pS(e,t){let n=aS[t];void 0===n&&(n=new Int32Array(t),aS[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function fS(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function mS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(hS(n,t))return;e.uniform2fv(this.addr,t),dS(n,t)}}function gS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(hS(n,t))return;e.uniform3fv(this.addr,t),dS(n,t)}}function vS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(hS(n,t))return;e.uniform4fv(this.addr,t),dS(n,t)}}function yS(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(hS(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),dS(n,t)}else{if(hS(n,i))return;cS.set(i),e.uniformMatrix2fv(this.addr,!1,cS),dS(n,i)}}function xS(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(hS(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),dS(n,t)}else{if(hS(n,i))return;lS.set(i),e.uniformMatrix3fv(this.addr,!1,lS),dS(n,i)}}function bS(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(hS(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),dS(n,t)}else{if(hS(n,i))return;oS.set(i),e.uniformMatrix4fv(this.addr,!1,oS),dS(n,i)}}function _S(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function wS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(hS(n,t))return;e.uniform2iv(this.addr,t),dS(n,t)}}function SS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(hS(n,t))return;e.uniform3iv(this.addr,t),dS(n,t)}}function MS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(hS(n,t))return;e.uniform4iv(this.addr,t),dS(n,t)}}function TS(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function ES(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(hS(n,t))return;e.uniform2uiv(this.addr,t),dS(n,t)}}function AS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(hS(n,t))return;e.uniform3uiv(this.addr,t),dS(n,t)}}function RS(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(hS(n,t))return;e.uniform4uiv(this.addr,t),dS(n,t)}}function CS(e,t,n){const i=this.cache,r=n.allocateTextureUnit();let s;i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),this.type===e.SAMPLER_2D_SHADOW?(tS.compareFunction=n.isReversedDepthBuffer()?Yd:Xd,s=tS):s=eS,n.setTexture2D(t||s,r)}function PS(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||iS,r)}function IS(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||rS,r)}function LS(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||nS,r)}function DS(e,t){e.uniform1fv(this.addr,t)}function NS(e,t){const n=uS(t,this.size,2);e.uniform2fv(this.addr,n)}function OS(e,t){const n=uS(t,this.size,3);e.uniform3fv(this.addr,n)}function FS(e,t){const n=uS(t,this.size,4);e.uniform4fv(this.addr,n)}function kS(e,t){const n=uS(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function US(e,t){const n=uS(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function zS(e,t){const n=uS(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function BS(e,t){e.uniform1iv(this.addr,t)}function VS(e,t){e.uniform2iv(this.addr,t)}function GS(e,t){e.uniform3iv(this.addr,t)}function HS(e,t){e.uniform4iv(this.addr,t)}function WS(e,t){e.uniform1uiv(this.addr,t)}function jS(e,t){e.uniform2uiv(this.addr,t)}function XS(e,t){e.uniform3uiv(this.addr,t)}function qS(e,t){e.uniform4uiv(this.addr,t)}function $S(e,t,n){const i=this.cache,r=t.length,s=pS(n,r);let a;hS(i,s)||(e.uniform1iv(this.addr,s),dS(i,s)),a=this.type===e.SAMPLER_2D_SHADOW?tS:eS;for(let e=0;e!==r;++e)n.setTexture2D(t[e]||a,s[e])}function YS(e,t,n){const i=this.cache,r=t.length,s=pS(n,r);hS(i,s)||(e.uniform1iv(this.addr,s),dS(i,s));for(let e=0;e!==r;++e)n.setTexture3D(t[e]||iS,s[e])}function KS(e,t,n){const i=this.cache,r=t.length,s=pS(n,r);hS(i,s)||(e.uniform1iv(this.addr,s),dS(i,s));for(let e=0;e!==r;++e)n.setTextureCube(t[e]||rS,s[e])}function ZS(e,t,n){const i=this.cache,r=t.length,s=pS(n,r);hS(i,s)||(e.uniform1iv(this.addr,s),dS(i,s));for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||nS,s[e])}class JS{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return fS;case 35664:return mS;case 35665:return gS;case 35666:return vS;case 35674:return yS;case 35675:return xS;case 35676:return bS;case 5124:case 35670:return _S;case 35667:case 35671:return wS;case 35668:case 35672:return SS;case 35669:case 35673:return MS;case 5125:return TS;case 36294:return ES;case 36295:return AS;case 36296:return RS;case 35678:case 36198:case 36298:case 36306:case 35682:return CS;case 35679:case 36299:case 36307:return PS;case 35680:case 36300:case 36308:case 36293:return IS;case 36289:case 36303:case 36311:case 36292:return LS}}(t.type)}}class QS{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return DS;case 35664:return NS;case 35665:return OS;case 35666:return FS;case 35674:return kS;case 35675:return US;case 35676:return zS;case 5124:case 35670:return BS;case 35667:case 35671:return VS;case 35668:case 35672:return GS;case 35669:case 35673:return HS;case 5125:return WS;case 36294:return jS;case 36295:return XS;case 36296:return qS;case 35678:case 36198:case 36298:case 36306:case 35682:return $S;case 35679:case 36299:case 36307:return YS;case 35680:case 36300:case 36308:case 36293:return KS;case 36289:case 36303:case 36311:case 36292:return ZS}}(t.type)}}class eM{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,s=i.length;r!==s;++r){const s=i[r];s.setValue(e,t[s.id],n)}}}const tM=/(\w+)(\])?(\[|\.)?/g;function nM(e,t){e.seq.push(t),e.map[t.id]=t}function iM(e,t,n){const i=e.name,r=i.length;for(tM.lastIndex=0;;){const s=tM.exec(i),a=tM.lastIndex;let o=s[1];const l="]"===s[2],c=s[3];if(l&&(o|=0),void 0===c||"["===c&&a+2===r){nM(n,void 0===c?new JS(o,e,t):new QS(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new eM(o),nM(n,e)),n=e}}}class rM{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);iM(n,e.getUniformLocation(t,n.name),this)}const i=[],r=[];for(const t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(t):r.push(t);i.length>0&&(this.seq=i.concat(r))}setValue(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){const s=t[r],a=n[s.id];!1!==a.needsUpdate&&s.setValue(e,a.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function sM(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let aM=0;const oM=new Ip;function lM(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const i=parseInt(s[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const n=e.split("\n"),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let e=r;e<s;e++){const r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function cM(e,t){const n=function(e){Fp._getMatrix(oM,Fp.workingColorSpace,e);const t=`mat3( ${oM.elements.map(e=>e.toFixed(4))} )`;switch(Fp.getTransfer(e)){case Bd:return[t,"LinearTransferOETF"];case Vd:return[t,"sRGBTransferOETF"];default:return up("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}const uM={[Qu]:"Linear",[eh]:"Reinhard",[th]:"Cineon",[nh]:"ACESFilmic",[rh]:"AgX",[sh]:"Neutral",[ih]:"Custom"};function hM(e,t){const n=uM[t];return void 0===n?(up("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const dM=new Rp;function pM(){Fp.getLuminanceCoefficients(dM);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${dM.x.toFixed(4)}, ${dM.y.toFixed(4)}, ${dM.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function fM(e){return""!==e}function mM(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function gM(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const vM=/^[ \t]*#include +<([\w\d./]+)>/gm;function yM(e){return e.replace(vM,bM)}const xM=new Map;function bM(e,t){let n=vw[t];if(void 0===n){const e=xM.get(t);if(void 0===e)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">");n=vw[e],up('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return yM(n)}const _M=/#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 wM(e){return e.replace(_M,SM)}function SM(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function MM(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}const TM={[yu]:"SHADOWMAP_TYPE_PCF",[xu]:"SHADOWMAP_TYPE_VSM"};const EM={[ch]:"ENVMAP_TYPE_CUBE",[uh]:"ENVMAP_TYPE_CUBE",[ph]:"ENVMAP_TYPE_CUBE_UV"};const AM={[uh]:"ENVMAP_MODE_REFRACTION"};const RM={[Yu]:"ENVMAP_BLENDING_MULTIPLY",[Ku]:"ENVMAP_BLENDING_MIX",[Zu]:"ENVMAP_BLENDING_ADD"};function CM(e,t,n,i){const r=e.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=function(e){return TM[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(n),c=function(e){return!1===e.envMap?"ENVMAP_TYPE_CUBE":EM[e.envMapMode]||"ENVMAP_TYPE_CUBE"}(n),u=function(e){return!1===e.envMap?"ENVMAP_MODE_REFLECTION":AM[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}(n),h=function(e){return!1===e.envMap?"ENVMAP_BLENDING_NONE":RM[e.combine]||"ENVMAP_BLENDING_NONE"}(n),d=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(fM).join("\n")}(n),f=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(s),m=r.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";const x=n.numMultiviewViews;n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(fM).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(fM).join("\n"),v.length>0&&(v+="\n")):(g=[MM(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.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","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(fM).join("\n"),v=[MM(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?vw.tonemapping_pars_fragment:"",0!==n.toneMapping?hM("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",vw.colorspace_pars_fragment,cM("linearToOutputTexel",n.outputColorSpace),pM(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(fM).join("\n")),a=yM(a),a=mM(a,n),a=gM(a,n),o=yM(o),o=mM(o,n),o=gM(o,n),a=wM(a),o=wM(o),!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Jd?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Jd?"":"#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("\n")+"\n"+v,x>0&&(g=["#extension GL_OVR_multiview : require","layout(num_views = "+x+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+g,g=g.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+x+"];","uniform mat4 projectionMatrices["+x+"];","uniform mat4 viewMatrices["+x+"];","uniform mat3 normalMatrices["+x+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),v=["#extension GL_OVR_multiview : require","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+v,v=v.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+x+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n"))));const b=y+g+a,_=y+v+o,w=sM(r,r.VERTEX_SHADER,b),S=sM(r,r.FRAGMENT_SHADER,_);function M(t){if(e.debug.checkShaderErrors){const n=r.getProgramInfoLog(m)||"",i=r.getShaderInfoLog(w)||"",s=r.getShaderInfoLog(S)||"",a=n.trim(),o=i.trim(),l=s.trim();let c=!0,u=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(c=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,m,w,S);else{const e=lM(r,w,"vertex"),n=lM(r,S,"fragment");hp("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+a+"\n"+e+"\n"+n)}else""!==a?up("WebGLProgram: Program Info Log:",a):""!==o&&""!==l||(u=!1);u&&(t.diagnostics={runnable:c,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:v}})}r.deleteShader(w),r.deleteShader(S),T=new rM(r,m),E=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r),s=i.name;let a=1;i.type===e.FLOAT_MAT2&&(a=2),i.type===e.FLOAT_MAT3&&(a=3),i.type===e.FLOAT_MAT4&&(a=4),n[s]={type:i.type,location:e.getAttribLocation(t,s),locationSize:a}}return n}(r,m)}let T,E;r.attachShader(m,w),r.attachShader(m,S),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.hasPositionAttribute&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===T&&M(this),T},this.getAttributes=function(){return void 0===E&&M(this),E};let A=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===A&&(A=r.getProgramParameter(m,37297)),A},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=aM++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=S,this.numMultiviewViews=x,this}let PM=0;class IM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return!1===i.has(t)&&(i.add(t),t.usedTimes++),!1===i.has(n)&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new LM(e),t.set(e,n)),n}}class LM{constructor(e){this.id=PM++,this.code=e,this.usedTimes=0}}function DM(e,t,n,i,r,s){const a=new uf,o=new IM,l=new Set,c=[],u=new Map,h=i.logarithmicDepthBuffer;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 f(e){return l.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(r,a,c,u,m,g){const v=u.fog,y=m.geometry,x=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?u.environment:null,b=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,_=t.get(r.envMap||x,b),w=_&&_.mapping===ph?_.image.height:null,S=p[r.type];null!==r.precision&&(d=i.getMaxPrecision(r.precision),d!==r.precision&&up("WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead."));const M=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==M?M.length:0;let E,A,R,C,P=0;if(void 0!==y.morphAttributes.position&&(P=1),void 0!==y.morphAttributes.normal&&(P=2),void 0!==y.morphAttributes.color&&(P=3),S){const e=xw[S];E=e.vertexShader,A=e.fragmentShader}else{E=r.vertexShader,A=r.fragmentShader;const e=o.getVertexShaderStage(r),t=o.getFragmentShaderStage(r);o.update(r,e,t),R=e.id,C=t.id}const I=e.getRenderTarget(),L=e.state.buffers.depth.getReversed(),D=I&&I.isWebGLMultiviewRenderTarget?I.numViews:0,N=!0===m.isInstancedMesh,O=!0===m.isBatchedMesh,F=!!r.map,k=!!r.matcap,U=!!_,z=!!r.aoMap,B=!!r.lightMap,V=!!r.bumpMap&&!1===r.wireframe,G=!!r.normalMap,H=!!r.displacementMap,W=!!r.emissiveMap,j=!!r.metalnessMap,X=!!r.roughnessMap,q=r.anisotropy>0,$=r.clearcoat>0,Y=r.dispersion>0,K=r.iridescence>0,Z=r.sheen>0,J=r.transmission>0,Q=q&&!!r.anisotropyMap,ee=$&&!!r.clearcoatMap,te=$&&!!r.clearcoatNormalMap,ne=$&&!!r.clearcoatRoughnessMap,ie=K&&!!r.iridescenceMap,re=K&&!!r.iridescenceThicknessMap,se=Z&&!!r.sheenColorMap,ae=Z&&!!r.sheenRoughnessMap,oe=!!r.specularMap,le=!!r.specularColorMap,ce=!!r.specularIntensityMap,ue=J&&!!r.transmissionMap,he=J&&!!r.thicknessMap,de=!!r.gradientMap,pe=!!r.alphaMap,fe=r.alphaTest>0,me=!!r.alphaHash,ge=!!r.extensions;let ve=0;r.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(ve=e.toneMapping));const ye={shaderID:S,shaderType:r.type,shaderName:r.name,vertexShader:E,fragmentShader:A,defines:r.defines,customVertexShaderID:R,customFragmentShaderID:C,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,batching:O,batchingColor:O&&null!==m._colorsTexture,instancing:N,instancingColor:N&&null!==m.instanceColor,instancingMorph:N&&null!==m.morphTexture,numMultiviewViews:D,outputColorSpace:null===I?e.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:Fp.workingColorSpace,alphaToCoverage:!!r.alphaToCoverage,map:F,matcap:k,envMap:U,envMapMode:U&&_.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:B,bumpMap:V,normalMap:G,displacementMap:H,emissiveMap:W,normalMapObjectSpace:G&&1===r.normalMapType,normalMapTangentSpace:G&&0===r.normalMapType,packedNormalMap:G&&0===r.normalMapType&&(xe=r.normalMap.format,xe===Hh||xe===sd||xe===Ed),metalnessMap:j,roughnessMap:X,anisotropy:q,anisotropyMap:Q,clearcoat:$,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,dispersion:Y,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:Z,sheenColorMap:se,sheenRoughnessMap:ae,specularMap:oe,specularColorMap:le,specularIntensityMap:ce,transmission:J,transmissionMap:ue,thicknessMap:he,gradientMap:de,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:pe,alphaTest:fe,alphaHash:me,combine:r.combine,mapUv:F&&f(r.map.channel),aoMapUv:z&&f(r.aoMap.channel),lightMapUv:B&&f(r.lightMap.channel),bumpMapUv:V&&f(r.bumpMap.channel),normalMapUv:G&&f(r.normalMap.channel),displacementMapUv:H&&f(r.displacementMap.channel),emissiveMapUv:W&&f(r.emissiveMap.channel),metalnessMapUv:j&&f(r.metalnessMap.channel),roughnessMapUv:X&&f(r.roughnessMap.channel),anisotropyMapUv:Q&&f(r.anisotropyMap.channel),clearcoatMapUv:ee&&f(r.clearcoatMap.channel),clearcoatNormalMapUv:te&&f(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&f(r.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&f(r.iridescenceMap.channel),iridescenceThicknessMapUv:re&&f(r.iridescenceThicknessMap.channel),sheenColorMapUv:se&&f(r.sheenColorMap.channel),sheenRoughnessMapUv:ae&&f(r.sheenRoughnessMap.channel),specularMapUv:oe&&f(r.specularMap.channel),specularColorMapUv:le&&f(r.specularColorMap.channel),specularIntensityMapUv:ce&&f(r.specularIntensityMap.channel),transmissionMapUv:ue&&f(r.transmissionMap.channel),thicknessMapUv:he&&f(r.thicknessMap.channel),alphaMapUv:pe&&f(r.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(G||q),vertexNormals:!!y.attributes.normal,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===m.isPoints&&!!y.attributes.uv&&(F||pe),fog:!!v,useFog:!0===r.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===y.attributes.normal&&!1===G&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:h,reversedDepthBuffer:L,skinning:!0===m.isSkinnedMesh,hasPositionAttribute:void 0!==y.attributes.position,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,morphTextureStride:P,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numSpotLightMaps:a.spotLightMap.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numSpotLightShadowsWithMaps:a.numSpotLightShadowsWithMaps,numLightProbes:a.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:F&&!0===r.map.isVideoTexture&&Fp.getTransfer(r.map.colorSpace)===Vd,decodeVideoTextureEmissive:W&&!0===r.emissiveMap.isVideoTexture&&Fp.getTransfer(r.emissiveMap.colorSpace)===Vd,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:ge&&!0===r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&!0===r.extensions.multiDraw||O)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};var xe;return ye.vertexUv1s=l.has(1),ye.vertexUv2s=l.has(2),ye.vertexUv3s=l.has(3),l.clear(),ye},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){a.disableAll(),t.instancing&&a.enable(0);t.instancingColor&&a.enable(1);t.instancingMorph&&a.enable(2);t.matcap&&a.enable(3);t.envMap&&a.enable(4);t.normalMapObjectSpace&&a.enable(5);t.normalMapTangentSpace&&a.enable(6);t.clearcoat&&a.enable(7);t.iridescence&&a.enable(8);t.alphaTest&&a.enable(9);t.vertexColors&&a.enable(10);t.vertexAlphas&&a.enable(11);t.vertexUv1s&&a.enable(12);t.vertexUv2s&&a.enable(13);t.vertexUv3s&&a.enable(14);t.vertexTangents&&a.enable(15);t.anisotropy&&a.enable(16);t.alphaHash&&a.enable(17);t.batching&&a.enable(18);t.dispersion&&a.enable(19);t.batchingColor&&a.enable(20);t.gradientMap&&a.enable(21);t.packedNormalMap&&a.enable(22);t.vertexNormals&&a.enable(23);e.push(a.mask),a.disableAll(),t.fog&&a.enable(0);t.useFog&&a.enable(1);t.flatShading&&a.enable(2);t.logarithmicDepthBuffer&&a.enable(3);t.reversedDepthBuffer&&a.enable(4);t.skinning&&a.enable(5);t.morphTargets&&a.enable(6);t.morphNormals&&a.enable(7);t.morphColors&&a.enable(8);t.premultipliedAlpha&&a.enable(9);t.shadowMapEnabled&&a.enable(10);t.doubleSided&&a.enable(11);t.flipSided&&a.enable(12);t.useDepthPacking&&a.enable(13);t.dithering&&a.enable(14);t.transmission&&a.enable(15);t.sheen&&a.enable(16);t.opaque&&a.enable(17);t.pointsUvs&&a.enable(18);t.decodeVideoTexture&&a.enable(19);t.decodeVideoTextureEmissive&&a.enable(20);t.alphaToCoverage&&a.enable(21);t.numLightProbeGrids>0&&a.enable(22);t.hasPositionAttribute&&a.enable(23);t.numMultiviewViews&&a.enable(24);e.push(a.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=p[e.type];let n;if(t){const e=xw[t];n=Nx.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i=u.get(n);return void 0!==i?++i.usedTimes:(i=new CM(e,n,t,r),c.push(i),u.set(n,i)),i},releaseProgram:function(e){if(0===--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),u.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){o.remove(e)},programs:c,dispose:function(){o.dispose()}}}function NM(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function OM(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.materialVariant!==t.materialVariant?e.materialVariant-t.materialVariant:e.z!==t.z?e.z-t.z:e.id-t.id}function FM(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function kM(){const e=[];let t=0;const n=[],i=[],r=[];function s(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function a(n,i,r,a,o,l){let c=e[t];return void 0===c?(c={id:n.id,object:n,geometry:i,material:r,materialVariant:s(n),groupOrder:a,renderOrder:n.renderOrder,z:o,group:l},e[t]=c):(c.id=n.id,c.object=n,c.geometry=i,c.material=r,c.materialVariant=s(n),c.groupOrder=a,c.renderOrder=n.renderOrder,c.z=o,c.group=l),t++,c}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.push(u):!0===s.transparent?r.push(u):n.push(u)},unshift:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.unshift(u):!0===s.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n<i;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t,s){n.length>1&&n.sort(e||OM),i.length>1&&i.sort(t||FM),r.length>1&&r.sort(t||FM),s&&(n.reverse(),i.reverse(),r.reverse())}}}function UM(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new kM,e.set(t,[r])):n>=i.length?(r=new kM,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function zM(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Rp,color:new Nf};break;case"SpotLight":n={position:new Rp,direction:new Rp,color:new Nf,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Rp,color:new Nf,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Rp,skyColor:new Nf,groundColor:new Nf};break;case"RectAreaLight":n={color:new Nf,position:new Rp,halfWidth:new Rp,halfHeight:new Rp}}return e[t.id]=n,n}}}let BM=0;function VM(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function GM(e){const t=new zM,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ep};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ep,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),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 e=0;e<9;e++)i.probe.push(new Rp);const r=new Rp,s=new Jp,a=new Jp;return{setup:function(r){let s=0,a=0,o=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0;r.sort(VM);for(let e=0,x=r.length;e<x;e++){const x=r[e],b=x.color,_=x.intensity,w=x.distance;let S=null;if(x.shadow&&x.shadow.map&&(S=x.shadow.map.texture.format===Hh?x.shadow.map.texture:x.shadow.map.depthTexture||x.shadow.map.texture),x.isAmbientLight)s+=b.r*_,a+=b.g*_,o+=b.b*_;else if(x.isLightProbe){for(let e=0;e<9;e++)i.probe[e].addScaledVector(x.sh.coefficients[e],_);y++}else if(x.isDirectionalLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,i.directionalShadow[l]=t,i.directionalShadowMap[l]=S,i.directionalShadowMatrix[l]=x.shadow.matrix,p++}i.directional[l]=e,l++}else if(x.isSpotLight){const e=t.get(x);e.position.setFromMatrixPosition(x.matrixWorld),e.color.copy(b).multiplyScalar(_),e.distance=w,e.coneCos=Math.cos(x.angle),e.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),e.decay=x.decay,i.spot[u]=e;const r=x.shadow;if(x.map&&(i.spotLightMap[g]=x.map,g++,r.updateMatrices(x),x.castShadow&&v++),i.spotLightMatrix[u]=r.matrix,x.castShadow){const e=n.get(x);e.shadowIntensity=r.intensity,e.shadowBias=r.bias,e.shadowNormalBias=r.normalBias,e.shadowRadius=r.radius,e.shadowMapSize=r.mapSize,i.spotShadow[u]=e,i.spotShadowMap[u]=S,m++}u++}else if(x.isRectAreaLight){const e=t.get(x);e.color.copy(b).multiplyScalar(_),e.halfWidth.set(.5*x.width,0,0),e.halfHeight.set(0,.5*x.height,0),i.rectArea[h]=e,h++}else if(x.isPointLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),e.distance=x.distance,e.decay=x.decay,x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,i.pointShadow[c]=t,i.pointShadowMap[c]=S,i.pointShadowMatrix[c]=x.shadow.matrix,f++}i.point[c]=e,c++}else if(x.isHemisphereLight){const e=t.get(x);e.skyColor.copy(x.color).multiplyScalar(_),e.groundColor.copy(x.groundColor).multiplyScalar(_),i.hemi[d]=e,d++}}h>0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=yw.LTC_FLOAT_1,i.rectAreaLTC2=yw.LTC_FLOAT_2):(i.rectAreaLTC1=yw.LTC_HALF_1,i.rectAreaLTC2=yw.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const x=i.hash;x.directionalLength===l&&x.pointLength===c&&x.spotLength===u&&x.rectAreaLength===h&&x.hemiLength===d&&x.numDirectionalShadows===p&&x.numPointShadows===f&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===y||(i.directional.length=l,i.spot.length=u,i.rectArea.length=h,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=y,x.directionalLength=l,x.pointLength=c,x.spotLength=u,x.rectAreaLength=h,x.hemiLength=d,x.numDirectionalShadows=p,x.numPointShadows=f,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=y,i.version=BM++)},setupView:function(e,t){let n=0,o=0,l=0,c=0,u=0;const h=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(h),n++}else if(d.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),e.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(h),l++}else if(d.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),a.identity(),s.copy(d.matrixWorld),s.premultiply(h),a.extractRotation(s),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(a),e.halfHeight.applyMatrix4(a),c++}else if(d.isPointLight){const e=i.point[o];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),o++}else if(d.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(h),u++}}},state:i}}function HM(e){const t=new GM(e),n=[],i=[],r=[];const s={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:function(e){s.camera=e,n.length=0,i.length=0,r.length=0},state:s,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)},pushLightProbeGrid:function(e){r.push(e)}}}function WM(e){let t=new WeakMap;return{get:function(n,i=0){const r=t.get(n);let s;return void 0===r?(s=new HM(e),t.set(n,[s])):i>=r.length?(s=new HM(e),r.push(s)):s=r[i],s},dispose:function(){t=new WeakMap}}}const jM=[new Rp(1,0,0),new Rp(-1,0,0),new Rp(0,1,0),new Rp(0,-1,0),new Rp(0,0,1),new Rp(0,0,-1)],XM=[new Rp(0,-1,0),new Rp(0,-1,0),new Rp(0,0,1),new Rp(0,0,-1),new Rp(0,-1,0),new Rp(0,-1,0)],qM=new Jp,$M=new Rp,YM=new Rp;function KM(e,t,n){let i=new av;const r=new Ep,s=new Ep,a=new qp,o=new Hx,l=new Wx,c={},u=n.maxTextureSize,h={[bu]:1,[_u]:0,[wu]:2},d=new Ox({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ep},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new Fm;f.setAttribute("position",new _m(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Ag(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function y(n,i){const s=t.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Yp(r.x,r.y,{format:Hh,type:Ph})),d.uniforms.shadow_pass.value=n.map.depthTexture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,s,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,s,p,m,null)}function x(t,n,i,r){let s=null;const a=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const e=s.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r,n.addEventListener("dispose",_)),s=r}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],s.alphaMap=n.alphaMap,s.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=i}return s}function b(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=t.update(n),l=n.material;if(Array.isArray(l)){const t=i.groups;for(let c=0,u=t.length;c<u;c++){const u=t[c],h=l[u.materialIndex];if(h&&h.visible){const t=x(n,h,a,o);n.onBeforeShadow(e,n,r,s,i,t,u),e.renderBufferDirect(s,null,i,t,n,u),n.onAfterShadow(e,n,r,s,i,t,u)}}}else if(l.visible){const t=x(n,l,a,o);n.onBeforeShadow(e,n,r,s,i,t,null),e.renderBufferDirect(s,null,i,t,n,null),n.onAfterShadow(e,n,r,s,i,t,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)b(l[e],r,s,a,o)}function _(e){e.target.removeEventListener("dispose",_);for(const t in c){const n=c[t],i=e.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(t,n,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;2===this.type&&(up("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=1);const l=e.getRenderTarget(),c=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.state;d.setBlending(0),!0===d.buffers.depth.getReversed()?d.buffers.color.setClear(0,0,0,0):d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=v!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let l=0,c=t.length;l<c;l++){const c=t[l],h=c.shadow;if(void 0===h){up("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;r.copy(h.mapSize);const f=h.getFrameExtents();r.multiply(f),s.copy(h.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/f.x),r.x=s.x*f.x,h.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/f.y),r.y=s.y*f.y,h.mapSize.y=s.y));const m=e.state.buffers.depth.getReversed();if(h.camera._reversedDepth=m,null===h.map||!0===p){if(null!==h.map&&(null!==h.map.depthTexture&&(h.map.depthTexture.dispose(),h.map.depthTexture=null),h.map.dispose()),3===this.type){if(c.isPointLight){up("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}h.map=new Yp(r.x,r.y,{format:Hh,type:Ph,minFilter:bh,magFilter:bh,generateMipmaps:!1}),h.map.texture.name=c.name+".shadowMap",h.map.depthTexture=new Jv(r.x,r.y,Ch),h.map.depthTexture.name=c.name+".shadowMapDepth",h.map.depthTexture.format=zh,h.map.depthTexture.compareFunction=null,h.map.depthTexture.minFilter=vh,h.map.depthTexture.magFilter=vh}else c.isPointLight?(h.map=new Hw(r.x),h.map.depthTexture=new Qv(r.x,Rh)):(h.map=new Yp(r.x,r.y),h.map.depthTexture=new Jv(r.x,r.y,Rh)),h.map.depthTexture.name=c.name+".shadowMap",h.map.depthTexture.format=zh,1===this.type?(h.map.depthTexture.compareFunction=m?Yd:Xd,h.map.depthTexture.minFilter=bh,h.map.depthTexture.magFilter=bh):(h.map.depthTexture.compareFunction=null,h.map.depthTexture.minFilter=vh,h.map.depthTexture.magFilter=vh);h.camera.updateProjectionMatrix()}const g=h.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<g;t++){if(h.map.isWebGLCubeRenderTarget)e.setRenderTarget(h.map,t),e.clear();else{0===t&&(e.setRenderTarget(h.map),e.clear());const n=h.getViewport(t);a.set(s.x*n.x,s.y*n.y,s.x*n.z,s.y*n.w),d.viewport(a)}if(c.isPointLight){const e=h.camera,n=h.matrix,i=c.distance||e.far;i!==e.far&&(e.far=i,e.updateProjectionMatrix()),$M.setFromMatrixPosition(c.matrixWorld),e.position.copy($M),YM.copy(e.position),YM.add(jM[t]),e.up.copy(XM[t]),e.lookAt(YM),e.updateMatrixWorld(),n.makeTranslation(-$M.x,-$M.y,-$M.z),qM.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),h._frustum.setFromProjectionMatrix(qM,e.coordinateSystem,e.reversedDepth)}else h.updateMatrices(c);i=h.getFrustum(),b(n,o,h.camera,c,this.type)}!0!==h.isPointLightShadow&&3===this.type&&y(h,o),h.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(l,c,h)}}function ZM(e,t){const n=new function(){let t=!1;const n=new qp;let i=null;const r=new qp(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,s,a,o){!0===o&&(t*=a,i*=a,s*=a),n.set(t,i,s,a),!1===r.equals(n)&&(e.clearColor(t,i,s,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,s=null,a=null;return{setReversed:function(e){if(i!==e){const n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;const r=a;a=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(t){t?V(e.DEPTH_TEST):G(e.DEPTH_TEST)},setMask:function(t){r===t||n||(e.depthMask(t),r=t)},setFunc:function(t){if(i&&(t=pp[t]),s!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}s=t}},setLocked:function(e){n=e},setClear:function(t){a!==t&&(a=t,i&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,r=null,s=null,a=null,i=!1}}},r=new function(){let t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null;return{setTest:function(n){t||(n?V(e.STENCIL_TEST):G(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&s===a||(e.stencilFunc(t,n,a),i=t,r=n,s=a)},setOp:function(t,n,i){a===t&&o===n&&l===i||(e.stencilOp(t,n,i),a=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null}}},s=new WeakMap,a=new WeakMap;let o={},l={},c={},u=new WeakMap,h=[],d=null,p=!1,f=null,m=null,g=null,v=null,y=null,x=null,b=null,_=new Nf(0,0,0),w=0,S=!1,M=null,T=null,E=null,A=null,R=null;const C=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let P=!1,I=0;const L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(L)[1]),P=I>=1):-1!==L.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),P=I>=2);let D=null,N={};const O=e.getParameter(e.SCISSOR_BOX),F=e.getParameter(e.VIEWPORT),k=(new qp).fromArray(O),U=(new qp).fromArray(F);function z(t,n,i,r){const s=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let a=0;a<i;a++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage2D(n+a,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,s);return a}const B={};function V(t){!0!==o[t]&&(e.enable(t),o[t]=!0)}function G(t){!1!==o[t]&&(e.disable(t),o[t]=!1)}B[e.TEXTURE_2D]=z(e.TEXTURE_2D,e.TEXTURE_2D,1),B[e.TEXTURE_CUBE_MAP]=z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),B[e.TEXTURE_2D_ARRAY]=z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),B[e.TEXTURE_3D]=z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),V(e.DEPTH_TEST),i.setFunc(3),X(!1),q(1),V(e.CULL_FACE),j(0);const H={[Su]:e.FUNC_ADD,[Mu]:e.FUNC_SUBTRACT,[Tu]:e.FUNC_REVERSE_SUBTRACT};H[103]=e.MIN,H[104]=e.MAX;const W={[Eu]:e.ZERO,[Au]:e.ONE,[Ru]:e.SRC_COLOR,[Pu]:e.SRC_ALPHA,[Fu]:e.SRC_ALPHA_SATURATE,[Nu]:e.DST_COLOR,[Lu]:e.DST_ALPHA,[Cu]:e.ONE_MINUS_SRC_COLOR,[Iu]:e.ONE_MINUS_SRC_ALPHA,[Ou]:e.ONE_MINUS_DST_COLOR,[Du]:e.ONE_MINUS_DST_ALPHA,[ku]:e.CONSTANT_COLOR,[Uu]:e.ONE_MINUS_CONSTANT_COLOR,[zu]:e.CONSTANT_ALPHA,[Bu]:e.ONE_MINUS_CONSTANT_ALPHA};function j(t,n,i,r,s,a,o,l,c,u){if(0!==t){if(!1===p&&(V(e.BLEND),p=!0),5===t)s=s||n,a=a||i,o=o||r,n===m&&s===y||(e.blendEquationSeparate(H[n],H[s]),m=n,y=s),i===g&&r===v&&a===x&&o===b||(e.blendFuncSeparate(W[i],W[r],W[a],W[o]),g=i,v=r,x=a,b=o),!1!==l.equals(_)&&c===w||(e.blendColor(l.r,l.g,l.b,c),_.copy(l),w=c),f=t,S=!1;else if(t!==f||u!==S){if(m===Su&&y===Su||(e.blendEquation(e.FUNC_ADD),m=Su,y=Su),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:hp("WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:hp("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:hp("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:hp("WebGLState: Invalid blending: ",t)}g=null,v=null,x=null,b=null,_.set(0,0,0),w=0,f=t,S=u}}else!0===p&&(G(e.BLEND),p=!1)}function X(t){M!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),M=t)}function q(t){0!==t?(V(e.CULL_FACE),t!==T&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):G(e.CULL_FACE),T=t}function $(t,n,r){t?(V(e.POLYGON_OFFSET_FILL),A===n&&R===r||(A=n,R=r,i.getReversed()&&(n=-n),e.polygonOffset(n,r))):G(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:V,disable:G,bindFramebuffer:function(t,n){return c[t]!==n&&(e.bindFramebuffer(t,n),c[t]=n,t===e.DRAW_FRAMEBUFFER&&(c[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(c[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=h,r=!1;if(t){i=u.get(n),void 0===i&&(i=[],u.set(n,i));const s=t.textures;if(i.length!==s.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=s.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=s.length,r=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,r=!0);r&&e.drawBuffers(i)},useProgram:function(t){return d!==t&&(e.useProgram(t),d=t,!0)},setBlending:j,setMaterial:function(t,s){2===t.side?G(e.CULL_FACE):V(e.CULL_FACE);let a=1===t.side;s&&(a=!a),X(a),1===t.blending&&!1===t.transparent?j(0):j(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),n.setMask(t.colorWrite);const o=t.stencilWrite;r.setTest(o),o&&(r.setMask(t.stencilWriteMask),r.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),r.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),$(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?V(e.SAMPLE_ALPHA_TO_COVERAGE):G(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:X,setCullFace:q,setLineWidth:function(t){t!==E&&(P&&e.lineWidth(t),E=t)},setPolygonOffset:$,setScissorTest:function(t){t?V(e.SCISSOR_TEST):G(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+C-1),D!==t&&(e.activeTexture(t),D=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===D?e.TEXTURE0+C-1:D);let r=N[i];void 0===r&&(r={type:void 0,texture:void 0},N[i]=r),r.type===t&&r.texture===n||(D!==i&&(e.activeTexture(i),D=i),e.bindTexture(t,n||B[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=N[D];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){hp("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){hp("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){hp("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){hp("WebGLState:",e)}},pixelStorei:function(t,n){l[t]!==n&&(e.pixelStorei(t,n),l[t]=n)},getParameter:function(t){return void 0!==l[t]?l[t]:e.getParameter(t)},updateUBOMapping:function(t,n){let i=a.get(n);void 0===i&&(i=new WeakMap,a.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){const i=a.get(n).get(t);s.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),s.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){hp("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){hp("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){hp("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){hp("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){hp("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){hp("WebGLState:",e)}},scissor:function(t){!1===k.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),k.copy(t))},viewport:function(t){!1===U.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),U.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),o={},l={},D=null,N={},c={},u=new WeakMap,h=[],d=null,p=!1,f=null,m=null,g=null,v=null,y=null,x=null,b=null,_=new Nf(0,0,0),w=0,S=!1,M=null,T=null,E=null,A=null,R=null,k.set(0,0,e.canvas.width,e.canvas.height),U.set(0,0,e.canvas.width,e.canvas.height),n.reset(),i.reset(),r.reset()}}}function JM(e,t,n,i,r,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=t.has("OCULUS_multiview")?t.get("OCULUS_multiview"):null,u=new Ep,h=new WeakMap,d=new Set;let p;const f=new WeakMap;let m=[],g=!1,v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function y(e,t){return v?new OffscreenCanvas(e,t):rp("canvas")}function x(e,t,n){let i=1;const r=$(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===p&&(p=y(n,s));const a=t?y(n,s):p;a.width=n,a.height=s;return a.getContext("2d").drawImage(e,0,0,n,s),up("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in e&&up("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function b(e){return e.generateMipmaps}function _(t){e.generateMipmap(t)}function w(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function S(n,i,r,s,a,o=!1){if(null!==n){if(void 0!==e[n])return e[n];up("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l;s&&(l=t.get("EXT_texture_norm16"),l||up("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let c=i;if(i===e.RED&&(r===e.FLOAT&&(c=e.R32F),r===e.HALF_FLOAT&&(c=e.R16F),r===e.UNSIGNED_BYTE&&(c=e.R8),r===e.UNSIGNED_SHORT&&l&&(c=l.R16_EXT),r===e.SHORT&&l&&(c=l.R16_SNORM_EXT)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.R8UI),r===e.UNSIGNED_SHORT&&(c=e.R16UI),r===e.UNSIGNED_INT&&(c=e.R32UI),r===e.BYTE&&(c=e.R8I),r===e.SHORT&&(c=e.R16I),r===e.INT&&(c=e.R32I)),i===e.RG&&(r===e.FLOAT&&(c=e.RG32F),r===e.HALF_FLOAT&&(c=e.RG16F),r===e.UNSIGNED_BYTE&&(c=e.RG8),r===e.UNSIGNED_SHORT&&l&&(c=l.RG16_EXT),r===e.SHORT&&l&&(c=l.RG16_SNORM_EXT)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.RG8UI),r===e.UNSIGNED_SHORT&&(c=e.RG16UI),r===e.UNSIGNED_INT&&(c=e.RG32UI),r===e.BYTE&&(c=e.RG8I),r===e.SHORT&&(c=e.RG16I),r===e.INT&&(c=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.RGB8UI),r===e.UNSIGNED_SHORT&&(c=e.RGB16UI),r===e.UNSIGNED_INT&&(c=e.RGB32UI),r===e.BYTE&&(c=e.RGB8I),r===e.SHORT&&(c=e.RGB16I),r===e.INT&&(c=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(c=e.RGBA16UI),r===e.UNSIGNED_INT&&(c=e.RGBA32UI),r===e.BYTE&&(c=e.RGBA8I),r===e.SHORT&&(c=e.RGBA16I),r===e.INT&&(c=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_SHORT&&l&&(c=l.RGB16_EXT),r===e.SHORT&&l&&(c=l.RGB16_SNORM_EXT),r===e.UNSIGNED_INT_5_9_9_9_REV&&(c=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(c=e.R11F_G11F_B10F)),i===e.RGBA){const t=o?Bd:Fp.getTransfer(a);r===e.FLOAT&&(c=e.RGBA32F),r===e.HALF_FLOAT&&(c=e.RGBA16F),r===e.UNSIGNED_BYTE&&(c=t===Vd?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT&&l&&(c=l.RGBA16_EXT),r===e.SHORT&&l&&(c=l.RGBA16_SNORM_EXT),r===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)}return c!==e.R16F&&c!==e.R32F&&c!==e.RG16F&&c!==e.RG32F&&c!==e.RGBA16F&&c!==e.RGBA32F||t.get("EXT_color_buffer_float"),c}function M(t,n){let i;return t?null===n||n===Rh||n===Dh?i=e.DEPTH24_STENCIL8:n===Ch?i=e.DEPTH32F_STENCIL8:n===Eh&&(i=e.DEPTH24_STENCIL8,up("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Rh||n===Dh?i=e.DEPTH_COMPONENT24:n===Ch?i=e.DEPTH_COMPONENT32F:n===Eh&&(i=e.DEPTH_COMPONENT16),i}function T(e,t){return!0===b(e)||e.isFramebufferTexture&&e.minFilter!==vh&&e.minFilter!==bh?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=f.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&R(e),0===Object.keys(r).length&&f.delete(n)}i.remove(e)}(t),t.isVideoTexture&&h.delete(t),t.isHTMLTexture&&d.delete(t)}function A(t){const n=t.target;n.removeEventListener("dispose",A),function(t){const n=i.get(t);t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=t.textures;for(let t=0,n=r.length;t<n;t++){const n=i.get(r[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),a.memory.textures--),i.remove(r[t])}i.remove(t)}(n)}function R(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const r=t.source;delete f.get(r)[n.__cacheKey],a.memory.textures--}let C=0;function P(t,r){const s=i.get(t);if(t.isVideoTexture&&function(e){const t=a.render.frame;h.get(e)!==t&&(h.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&s.__version!==t.version){const e=t.image;if(null===e)up("WebGLRenderer: Texture marked for update but no image data found.");else if(!1===e.complete)up("WebGLRenderer: Texture marked for update but image is incomplete");else if(U(s,t,r))return}else t.isExternalTexture&&(s.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}function I(t,r){const s=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version?U(s,t,r):(t.isExternalTexture&&(s.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+r))}const L={[fh]:e.REPEAT,[mh]:e.CLAMP_TO_EDGE,[gh]:e.MIRRORED_REPEAT},D={[vh]:e.NEAREST,[yh]:e.NEAREST_MIPMAP_NEAREST,[xh]:e.NEAREST_MIPMAP_LINEAR,[bh]:e.LINEAR,[_h]:e.LINEAR_MIPMAP_NEAREST,[wh]:e.LINEAR_MIPMAP_LINEAR},N={[Hd]:e.NEVER,[Kd]:e.ALWAYS,[Wd]:e.LESS,[Xd]:e.LEQUAL,[jd]:e.EQUAL,[Yd]:e.GEQUAL,[qd]:e.GREATER,[$d]:e.NOTEQUAL};function O(n,s){if(s.type!==Ch||!1!==t.has("OES_texture_float_linear")||s.magFilter!==bh&&s.magFilter!==_h&&s.magFilter!==xh&&s.magFilter!==wh&&s.minFilter!==bh&&s.minFilter!==_h&&s.minFilter!==xh&&s.minFilter!==wh||up("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,L[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,L[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,D[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,D[s.minFilter]),s.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,N[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(s.magFilter===vh)return;if(s.minFilter!==xh&&s.minFilter!==wh)return;if(s.type===Ch&&!1===t.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function F(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const r=n.source;let s=f.get(r);void 0===s&&(s={},f.set(r,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[t.__cacheKey];void 0!==r&&(s[t.__cacheKey].usedTimes--,0===r.usedTimes&&R(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return i}function k(e,t,n){return Math.floor(Math.floor(e/n)/t)}function U(t,a,o){if(g)return a.isPendingDeferredUpload||(a.isPendingDeferredUpload=!0,m.push({textureProperties:t,texture:a,slot:o})),!1;let l=e.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=e.TEXTURE_3D);const c=F(t,a),u=a.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const h=i.get(u);if(u.version!==h.__version||!0===c){n.activeTexture(e.TEXTURE0+o);if(!1===("undefined"!=typeof ImageBitmap&&a.image instanceof ImageBitmap)){const t=Fp.getPrimaries(Fp.workingColorSpace),i=a.colorSpace===kd?null:Fp.getPrimaries(a.colorSpace),r=a.colorSpace===kd||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,r)}n.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment);let t=x(a.image,!1,r.maxTextureSize);t=q(a,t);const i=s.convert(a.format,a.colorSpace),p=s.convert(a.type);let f,m=S(a.internalFormat,i,p,a.normalized,a.colorSpace,a.isVideoTexture);O(l,a);const g=a.mipmaps,v=!0!==a.isVideoTexture,y=void 0===h.__version||!0===c,w=u.dataReady,E=T(a,t);if(a.isDepthTexture)m=M(a.format===Bh,a.type),y&&(v?n.texStorage2D(e.TEXTURE_2D,1,m,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,i,p,null));else if(a.isDataTexture)if(g.length>0){v&&y&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,r=g.length;t<r;t++)f=g[t],v?w&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,i,p,f.data):n.texImage2D(e.TEXTURE_2D,t,m,f.width,f.height,0,i,p,f.data);a.generateMipmaps=!1}else v?(y&&n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height),w&&function(t,i,r,s){const a=t.updateRanges;if(0===a.length)n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,r,s,i.data);else{a.sort((e,t)=>e.start-t.start);let o=0;for(let e=1;e<a.length;e++){const t=a[o],n=a[e],r=t.start+t.count,s=k(n.start,i.width,4),l=k(t.start,i.width,4);n.start<=r+1&&s===l&&k(n.start+n.count-1,i.width,4)===s?t.count=Math.max(t.count,n.start+n.count-t.start):(++o,a[o]=n)}a.length=o+1;const l=n.getParameter(e.UNPACK_ROW_LENGTH),c=n.getParameter(e.UNPACK_SKIP_PIXELS),u=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,i.width);for(let t=0,o=a.length;t<o;t++){const o=a[t],l=Math.floor(o.start/4),c=Math.ceil(o.count/4),u=l%i.width,h=Math.floor(l/i.width),d=c,p=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,u),n.pixelStorei(e.UNPACK_SKIP_ROWS,h),n.texSubImage2D(e.TEXTURE_2D,0,u,h,d,p,r,s,i.data)}t.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,l),n.pixelStorei(e.UNPACK_SKIP_PIXELS,c),n.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}(a,t,i,p)):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,i,p,t.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){v&&y&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,g[0].width,g[0].height,t.depth);for(let r=0,s=g.length;r<s;r++)if(f=g[r],a.format!==Uh)if(null!==i)if(v){if(w)if(a.layerUpdates.size>0){const t=fw(f.width,f.height,a.format,a.type);for(const s of a.layerUpdates){const a=f.data.subarray(s*t/f.data.BYTES_PER_ELEMENT,(s+1)*t/f.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,s,f.width,f.height,1,i,a)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,0,f.width,f.height,t.depth,i,f.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,r,m,f.width,f.height,t.depth,0,f.data,0,0);else up("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else v?w&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,0,f.width,f.height,t.depth,i,p,f.data):n.texImage3D(e.TEXTURE_2D_ARRAY,r,m,f.width,f.height,t.depth,0,i,p,f.data)}else{v&&y&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,r=g.length;t<r;t++)f=g[t],a.format!==Uh?null!==i?v?w&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,i,f.data):n.compressedTexImage2D(e.TEXTURE_2D,t,m,f.width,f.height,0,f.data):up("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):v?w&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,i,p,f.data):n.texImage2D(e.TEXTURE_2D,t,m,f.width,f.height,0,i,p,f.data)}else if(a.isDataArrayTexture)if(v){if(y&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,t.width,t.height,t.depth),w)if(a.layerUpdates.size>0){const r=fw(t.width,t.height,a.format,a.type);for(const s of a.layerUpdates){const a=t.data.subarray(s*r/t.data.BYTES_PER_ELEMENT,(s+1)*r/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,s,t.width,t.height,1,i,p,a)}a.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,i,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,i,p,t.data);else if(a.isData3DTexture)v?(y&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),w&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,i,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,i,p,t.data);else if(a.isFramebufferTexture){if(y)if(v)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let r=t.width,s=t.height;for(let t=0;t<E;t++)n.texImage2D(e.TEXTURE_2D,t,m,r,s,0,i,p,null),r>>=1,s>>=1}}else if(a.isHTMLTexture){if("texElementImage2D"in e){const n=e.canvas;if(n.hasAttribute("layoutsubtree")||n.setAttribute("layoutsubtree","true"),t.parentNode!==n)return n.appendChild(t),d.add(a),n.onpaint=e=>{const t=e.changedElements;for(const e of d)t.includes(e.image)&&(e.needsUpdate=!0)},void n.requestPaint();if(3===e.texElementImage2D.length)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{const n=0,i=e.RGBA,r=e.RGBA,s=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,n,i,r,s,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(g.length>0){if(v&&y){const t=$(g[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,r=g.length;t<r;t++)f=g[t],v?w&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,i,p,f):n.texImage2D(e.TEXTURE_2D,t,m,i,p,f);a.generateMipmaps=!1}else if(v){if(y){const i=$(t);n.texStorage2D(e.TEXTURE_2D,E,m,i.width,i.height)}w&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,i,p,t)}else n.texImage2D(e.TEXTURE_2D,0,m,i,p,t);b(a)&&_(l),h.__version=u.version,a.onUpdate&&a.onUpdate(a)}return t.__version=a.version,!0}function z(t,r,a,l,u,h){const d=s.convert(a.format,a.colorSpace),p=s.convert(a.type),f=S(a.internalFormat,d,p,a.normalized,a.colorSpace),m=i.get(r),g=i.get(a);if(g.__renderTarget=r,!m.__hasExternalTextures){const t=Math.max(1,r.width>>h),i=Math.max(1,r.height>>h);!0===r.isWebGLMultiviewRenderTarget?n.texStorage3D(e.TEXTURE_2D_ARRAY,0,f,r.width,r.height,r.numViews):u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,h,f,t,i,r.depth,0,d,p,null):n.texImage2D(u,h,f,t,i,0,d,p,null)}n.bindFramebuffer(e.FRAMEBUFFER,t);const v=X(r);!0===r.isWebGLMultiviewRenderTarget?v?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,j(r),0,r.numViews):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,0,r.numViews):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&(v?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,g.__webglTexture,0,j(r)):e.framebufferTexture2D(e.FRAMEBUFFER,l,u,g.__webglTexture,h)),n.bindFramebuffer(e.FRAMEBUFFER,null)}function B(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),!0===n.isWebGLMultiviewRenderTarget){const t=X(n),r=n.numViews,s=n.depthTexture;let a=e.DEPTH_COMPONENT24,o=e.DEPTH_ATTACHMENT;s&&s.isDepthTexture&&(s.type===Ch?a=e.DEPTH_COMPONENT32F:s.type===Dh&&(a=e.DEPTH24_STENCIL8,o=e.DEPTH_STENCIL_ATTACHMENT));let l=i.get(n.depthTexture).__webglTexture;void 0===l&&(l=e.createTexture(),e.bindTexture(e.TEXTURE_2D_ARRAY,l),e.texStorage3D(e.TEXTURE_2D_ARRAY,1,a,n.width,n.height,r)),t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,o,l,0,j(n),0,r):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,o,l,0,0,r)}else if(n.depthBuffer){const i=n.depthTexture,s=i&&i.isDepthTexture?i.type:null,a=M(n.stencilBuffer,s),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;X(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,j(n),a,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,j(n),a,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,a,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i<t.length;i++){const a=t[i],l=s.convert(a.format,a.colorSpace),c=s.convert(a.type),u=S(a.internalFormat,l,c,a.normalized,a.colorSpace);X(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,j(n),u,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,j(n),u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function V(t,r,a){const l=!0===r.isWebGLCubeRenderTarget;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const u=i.get(r.depthTexture);if(u.__renderTarget=r,u.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),l){if(void 0===u.__webglInit&&(u.__webglInit=!0,r.depthTexture.addEventListener("dispose",E)),void 0===u.__webglTexture){u.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,u.__webglTexture),O(e.TEXTURE_CUBE_MAP,r.depthTexture);const t=s.convert(r.depthTexture.format),i=s.convert(r.depthTexture.type);let a;r.depthTexture.format===zh?a=e.DEPTH_COMPONENT24:r.depthTexture.format===Bh&&(a=e.DEPTH24_STENCIL8);for(let n=0;n<6;n++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,a,r.width,r.height,0,t,i,null)}}else 1!=r.depthTexture.image.depth?I(r.depthTexture,0):P(r.depthTexture,0);const h=u.__webglTexture,d=j(r);if(!0===r.isWebGLMultiviewRenderTarget){const t=X(r),n=r.numViews;if(r.depthTexture.format===zh)t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,h,0,d,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,h,0,0,n);else{if(r.depthTexture.format!==Bh)throw new Error("Unknown depthTexture format");t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,h,0,d,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,h,0,0,n)}}else{const t=l?e.TEXTURE_CUBE_MAP_POSITIVE_X+a:e.TEXTURE_2D,n=r.depthTexture.format===Bh?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(r.depthTexture.format===zh)X(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,n,t,h,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,n,t,h,0);else{if(r.depthTexture.format!==Bh)throw new Error("THREE.WebGLTextures: Unknown depthTexture format.");X(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,n,t,h,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,n,t,h,0)}}}function G(t){const r=i.get(t),s=!0===t.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==t.depthTexture){const e=t.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),e){const t=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer)if(s)for(let e=0;e<6;e++)V(r.__webglFramebuffer[e],t,e);else{const e=t.texture.mipmaps;e&&e.length>0?V(r.__webglFramebuffer[0],t,0):V(r.__webglFramebuffer,t,0)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),B(r.__webglDepthbuffer[i],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,s)}}else{const i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),B(r.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}const H=[],W=[];function j(e){return Math.min(r.maxSamples,e.samples)}function X(e){const n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function q(e,t){const n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==zd&&n!==kd&&(Fp.getTransfer(n)===Vd?i===Uh&&r===Sh||up("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):hp("WebGLTextures: Unsupported texture color space:",n)),t}function $(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(u.width=e.naturalWidth||e.width,u.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(u.width=e.displayWidth,u.height=e.displayHeight):(u.width=e.width,u.height=e.height),u}this.allocateTextureUnit=function(){const e=C;return e>=r.maxTextures&&up("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),C+=1,e},this.resetTextureUnits=function(){C=0},this.getTextureUnits=function(){return C},this.setTextureUnits=function(e){C=e},this.setTexture2D=P,this.setTexture2DArray=I,this.setTexture3D=function(t,r){const s=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version?U(s,t,r):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,a){const o=i.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&o.__version!==t.version?function(t,a,o){if(6!==a.image.length)return;const l=F(t,a),c=a.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const u=i.get(c);if(c.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=Fp.getPrimaries(Fp.workingColorSpace),i=a.colorSpace===kd?null:Fp.getPrimaries(a.colorSpace),h=a.colorSpace===kd||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let e=0;e<6;e++)f[e]=d||p?p?a.image[e].image:a.image[e]:x(a.image[e],!0,r.maxCubemapSize),f[e]=q(a,f[e]);const m=f[0],g=s.convert(a.format,a.colorSpace),v=s.convert(a.type),y=S(a.internalFormat,g,v,a.normalized,a.colorSpace),w=!0!==a.isVideoTexture,M=void 0===u.__version||!0===l,E=c.dataReady;let A,R=T(a,m);if(O(e.TEXTURE_CUBE_MAP,a),d){w&&M&&n.texStorage2D(e.TEXTURE_CUBE_MAP,R,y,m.width,m.height);for(let t=0;t<6;t++){A=f[t].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];a.format!==Uh?null!==g?w?E&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,r.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,y,r.width,r.height,0,r.data):up("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,y,r.width,r.height,0,g,v,r.data)}}}else{if(A=a.mipmaps,w&&M){A.length>0&&R++;const t=$(f[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,R,y,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f[t].width,f[t].height,g,v,f[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,f[t].width,f[t].height,0,g,v,f[t].data);for(let i=0;i<A.length;i++){const r=A[i].image[t].image;w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,y,r.width,r.height,0,g,v,r.data)}}else{w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,v,f[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,g,v,f[t]);for(let i=0;i<A.length;i++){const r=A[i];w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,g,v,r.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,y,g,v,r.image[t])}}}b(a)&&_(e.TEXTURE_CUBE_MAP),u.__version=c.version,a.onUpdate&&a.onUpdate(a)}t.__version=a.version}(o,t,a):n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture,e.TEXTURE0+a)},this.rebindTextures=function(t,n,r){const s=i.get(t);void 0!==n&&z(s.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&G(t)},this.uploadTexture=U,this.setupRenderTarget=function(t){const r=t.texture,o=i.get(t),l=i.get(r);t.addEventListener("dispose",A);const c=t.textures,u=!0===t.isWebGLCubeRenderTarget,h=c.length>1;if(h||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,a.memory.textures++),u){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[t][n]=e.createFramebuffer()}else o.__webglFramebuffer[t]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let t=0;t<r.mipmaps.length;t++)o.__webglFramebuffer[t]=e.createFramebuffer()}else o.__webglFramebuffer=e.createFramebuffer();if(h)for(let t=0,n=c.length;t<n;t++){const n=i.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),a.memory.textures++)}if(t.samples>0&&!1===X(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=s.convert(i.format,i.colorSpace),a=s.convert(i.type),l=S(i.internalFormat,r,a,i.normalized,i.colorSpace,!0===t.isXRRenderTarget),u=j(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,o.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(o.__webglDepthRenderbuffer=e.createRenderbuffer(),B(o.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),O(e.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)z(o.__webglFramebuffer[n][i],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else z(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);b(r)&&_(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(h){for(let r=0,s=c.length;r<s;r++){const s=c[r],a=i.get(s);let l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(l,a.__webglTexture),O(l,s),z(o.__webglFramebuffer,t,s,e.COLOR_ATTACHMENT0+r,l,0),b(s)&&_(l)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),!0===t.isWebGLMultiviewRenderTarget&&(i=e.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),O(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)z(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,i,n);else z(o.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0,i,0);b(r)&&_(i),n.unbindTexture()}(t.depthBuffer||!0===t.isWebGLMultiviewRenderTarget)&&this.setupDepthRenderbuffer(t)},this.updateRenderTargetMipmap=function(e){const t=e.textures;for(let r=0,s=t.length;r<s;r++){const s=t[r];if(b(s)){const t=w(e),r=i.get(s).__webglTexture;n.bindTexture(t,r),_(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===X(t)){const r=t.textures,s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=i.get(t),h=r.length>1;if(h)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer);const d=t.texture.mipmaps;d&&d.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<r.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),h){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);const t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,s,a,0,0,s,a,o,e.NEAREST),!0===l&&(H.length=0,W.length=0,H.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(H.push(c),W.push(c),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,W)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),h)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);const s=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,s,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&l){const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthTexture=V,this.setupDepthRenderbuffer=G,this.setupFrameBufferTexture=z,this.useMultisampledRTT=X,this.runDeferredUploads=function(){const e=g;g=!1;for(const e of m)U(e.textureProperties,e.texture,e.slot),e.texture.isPendingDeferredUpload=!1;m=[],g=e},this.setDeferTextureUploads=function(e){g=e},this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function QM(e,t){return{convert:function(n,i=""){let r;const s=Fp.getTransfer(i);if(n===Sh)return e.UNSIGNED_BYTE;if(n===Ih)return e.UNSIGNED_SHORT_4_4_4_4;if(n===Lh)return e.UNSIGNED_SHORT_5_5_5_1;if(n===Nh)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===Oh)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===Mh)return e.BYTE;if(n===Th)return e.SHORT;if(n===Eh)return e.UNSIGNED_SHORT;if(n===Ah)return e.INT;if(n===Rh)return e.UNSIGNED_INT;if(n===Ch)return e.FLOAT;if(n===Ph)return e.HALF_FLOAT;if(n===Fh)return e.ALPHA;if(n===kh)return e.RGB;if(n===Uh)return e.RGBA;if(n===zh)return e.DEPTH_COMPONENT;if(n===Bh)return e.DEPTH_STENCIL;if(n===Vh)return e.RED;if(n===Gh)return e.RED_INTEGER;if(n===Hh)return e.RG;if(n===Wh)return e.RG_INTEGER;if(n===jh)return e.RGBA_INTEGER;if(n===Xh||n===qh||n===$h||n===Yh)if(s===Vd){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Xh)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===qh)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===$h)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Yh)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Xh)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===qh)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===$h)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Yh)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Kh||n===Zh||n===Jh||n===Qh){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Kh)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Zh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Jh)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Qh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===ed||n===td||n===nd||n===id||n===rd||n===sd||n===ad){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===ed||n===td)return s===Vd?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===nd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===id)return r.COMPRESSED_R11_EAC;if(n===rd)return r.COMPRESSED_SIGNED_R11_EAC;if(n===sd)return r.COMPRESSED_RG11_EAC;if(n===ad)return r.COMPRESSED_SIGNED_RG11_EAC}if(n===od||n===ld||n===cd||n===ud||n===hd||n===dd||n===pd||n===fd||n===md||n===gd||n===vd||n===yd||n===xd||n===bd){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===od)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ld)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===cd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ud)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===hd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===dd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===pd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===fd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===md)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===gd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===vd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===yd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===xd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===bd)return s===Vd?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===_d||n===wd||n===Sd){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(n===_d)return s===Vd?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===wd)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Sd)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Md||n===Td||n===Ed||n===Ad){if(r=t.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===Md)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Td)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ed)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ad)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Dh?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class eT extends Yp{constructor(e,t,n,i={}){super(e,t,i),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=n}copy(e){return super.copy(e),this.numViews=e.numViews,this}}eT.prototype.isWebGLMultiviewRenderTarget=!0;class tT{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const n=new ey(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new Ox({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ag(new yx(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class nT extends fp{constructor(e,t,n,i){super();const r=this;let s=null,a=1;var o=null;let l=null,c="local-floor",u=1,h=null,d=null;var p=[];let f=null,m=null,g=null,v=null;const y="undefined"!=typeof XRWebGLBinding,x=new tT,b={},_=t.getContextAttributes();let w=null,S=null;const M=[],T=[],E=new Ep;let A=null;const R=new Ob;R.viewport=new qp;const C=new Ob;C.viewport=new qp;const P=[R,C],I=new u_;let L=null,D=null;function N(e){const t=T.indexOf(e.inputSource);if(-1===t)return;const n=M[t];void 0!==n&&(n.update(e.inputSource,e.frame,h||l),n.dispatchEvent({type:e.type,data:e.inputSource}))}function O(){s.removeEventListener("select",N),s.removeEventListener("selectstart",N),s.removeEventListener("selectend",N),s.removeEventListener("squeeze",N),s.removeEventListener("squeezestart",N),s.removeEventListener("squeezeend",N),s.removeEventListener("end",O),s.removeEventListener("inputsourceschange",F);for(let e=0;e<M.length;e++){const t=T[e];null!==t&&(T[e]=null,M[e].disconnect(t))}L=null,D=null,x.reset();for(const e in b)delete b[e];r.isPresenting=!1,e.setRenderTarget(w),g=null,m=null,f=null,s=null,S=null,V.stop(),e.setPixelRatio(A),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}function F(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=T.indexOf(n);i>=0&&(T[i]=null,M[i].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=T.indexOf(n);if(-1===i){for(let e=0;e<M.length;e++){if(e>=T.length){T.push(n),i=e;break}if(null===T[e]){T[e]=n,i=e;break}}if(-1===i)break}const r=M[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.layersEnabled=!1,this.isPresenting=!1,this.isMultiview=!1,this.getCameraPose=function(){return d},this.getController=function(e){let t=M[e];return void 0===t&&(t=new Cf,M[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=M[e];return void 0===t&&(t=new Cf,M[e]=t),t.getGripSpace()},this.getHand=function(e){let t=M[e];return void 0===t&&(t=new Cf,M[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){a=e,!0===r.isPresenting&&up("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){c=e,!0===r.isPresenting&&up("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||l},this.setReferenceSpace=function(e){h=e},this.getBaseLayer=function(){return null!==m?m:g},this.getBinding=function(){return null===f&&y&&(f=new XRWebGLBinding(s,t)),f},this.getFrame=function(){return v},this.getRenderTarget=function(){return S},this.getSession=function(){return s},this.setSession=async function(o){if(s=o,null!==s){w=e.getRenderTarget(),s.addEventListener("select",N),s.addEventListener("selectstart",N),s.addEventListener("selectend",N),s.addEventListener("squeeze",N),s.addEventListener("squeezestart",N),s.addEventListener("squeezeend",N),s.addEventListener("end",O),s.addEventListener("inputsourceschange",F),!0!==_.xrCompatible&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(E);if(y&&"createProjectionLayer"in XRWebGLBinding.prototype){let o=null,l=null,c=null;_.depth&&(c=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,o=_.stencil?Bh:zh,l=_.stencil?Dh:Rh),r.isMultiview=i&&n.has("OCULUS_multiview");const u={colorFormat:t.RGBA8,depthFormat:c,scaleFactor:a};r.isMultiview&&(u.textureType="texture-array"),f=this.getBinding(),m=f.createProjectionLayer(u),s.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1);const h={format:Uh,type:Sh,depthTexture:new Jv(m.textureWidth,m.textureHeight,l,void 0,void 0,void 0,void 0,void 0,void 0,o),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:!1===m.ignoreDepthValues,resolveStencilBuffer:!1===m.ignoreDepthValues};if(r.isMultiview){const e=n.get("OCULUS_multiview");this.maxNumViews=t.getParameter(e.MAX_VIEWS_OVR),S=new eT(m.textureWidth,m.textureHeight,2,h)}else S=new Yp(m.textureWidth,m.textureHeight,h)}else{const n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(s,t,n),s.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),S=new Yp(g.framebufferWidth,g.framebufferHeight,{format:Uh,type:Sh,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:!1===g.ignoreDepthValues,resolveStencilBuffer:!1===g.ignoreDepthValues})}S.isXRRenderTarget=!0,this.setFoveation(u),h=null,l=await s.requestReferenceSpace(c),V.setContext(s),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==s)return s.environmentBlendMode},this.addLayer=function(e){window.XRWebGLBinding&&this.layersEnabled&&s&&(p.push(e),this.updateLayers())},this.removeLayer=function(e){p.splice(p.indexOf(e),1),window.XRWebGLBinding&&this.layersEnabled&&s&&this.updateLayers()},this.updateLayers=function(){var e=p.map(function(e){return e});e.unshift(s.renderState.layers[0]),s.updateRenderState({layers:e})},this.getDepthTexture=function(){return x.getDepthTexture()};const k=new Rp,U=new Rp;function z(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.setPoseTarget=function(e){void 0!==e&&(o=e)},this.updateCamera=function(e){if(null===s)return;let t=e.near,n=e.far;null!==x.texture&&(x.depthNear>0&&(t=x.depthNear),x.depthFar>0&&(n=x.depthFar)),I.near=C.near=R.near=t,I.far=C.far=R.far=n,L===I.near&&D===I.far||(s.updateRenderState({depthNear:I.near,depthFar:I.far}),L=I.near,D=I.far),I.layers.mask=6|e.layers.mask,R.layers.mask=-5&I.layers.mask,C.layers.mask=-3&I.layers.mask;const i=I.cameras;var r=o||e;const a=r.parent;z(I,a);for(let e=0;e<i.length;e++)z(i[e],a);2===i.length?function(e,t,n){k.setFromMatrixPosition(t.matrixWorld),U.setFromMatrixPosition(n.matrixWorld);const i=k.distanceTo(U),r=t.projectionMatrix.elements,s=n.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],u=(r[8]-1)/r[0],h=(s[8]+1)/s[0],d=a*u,p=a*h,f=i/(-u+h),m=f*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=a+f,n=o+f,r=d-m,s=p+(i-m),u=l*o/n*t,h=c*o/n*t;e.projectionMatrix.makePerspective(r,s,u,h,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(I,R,C):I.projectionMatrix.copy(R.projectionMatrix),function(e,t,n){t.matrixWorld.decompose(t.position,t.quaternion,t.scale),null===n.parent?n.matrix.copy(t.matrixWorld):(n.matrix.copy(n.parent.matrixWorld),n.matrix.invert(),n.matrix.multiply(t.matrixWorld));n.matrix.decompose(n.position,n.quaternion,n.scale),n.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*yp*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,I,r)},this.getCamera=function(){return I},this.getFoveation=function(){if(null!==m||null!==g)return u},this.setFoveation=function(e){u=e,null!==m&&(m.fixedFoveation=e),null!==g&&void 0!==g.fixedFoveation&&(g.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==x.texture},this.getDepthSensingMesh=function(){return x.getMesh(I)},this.getCameraTexture=function(e){return b[e]};let B=null;const V=new mw;V.setAnimationLoop(function(t,n){if(d=n.getViewerPose(h||l),v=n,null!==d){const t=d.views;null!==g&&(e.setRenderTargetFramebuffer(S,g.framebuffer),e.setRenderTarget(S));let n=!1;t.length!==I.cameras.length&&(I.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i];let s=null;if(null!==g)s=g.getViewport(r);else{const t=f.getViewSubImage(m,r);s=t.viewport,0===i&&(e.setRenderTargetTextures(S,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(S))}let a=P[i];void 0===a&&(a=new Ob,a.layers.enable(i),a.viewport=new qp,P[i]=a),a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(r.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(I.matrix.copy(a.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),!0===n&&I.cameras.push(a)}const i=s.enabledFeatures;if(i&&i.includes("depth-sensing")&&"gpu-optimized"==s.depthUsage&&y){f=r.getBinding();const e=f.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&x.init(e,s.renderState)}if(i&&i.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let e=0;e<t.length;e++){const n=t[e].camera;if(n){let e=b[n];e||(e=new ey,b[n]=e);const t=f.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<M.length;e++){const t=T[e],i=M[e];null!==t&&void 0!==i&&i.update(t,n,h||l)}B&&B(t,n),n.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:n}),v=null}),this.setAnimationLoop=function(e){B=e},this.dispose=function(){}}}const iT=new Jp,rT=new Ip;function sT(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);const r=t.get(i),s=r.envMap,a=r.envMapRotation;s&&(e.envMap.value=s,e.envMapRotation.value.setFromMatrix4(iT.makeRotationFromEuler(a)).transpose(),s.isCubeTexture&&!1===s.isRenderTargetTexture&&e.envMapRotation.value.premultiply(rT),e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Dx(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,s,a,o){r.isNodeMaterial?r.uniformsNeedUpdate=!1:r.isMeshBasicMaterial?i(e,r):r.isMeshLambertMaterial?(i(e,r),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(i(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,a):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function aT(e,t,n,i){let r={},s={},a=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,n,i,r){if(!0===function(e,t,n,i){const r=e.value,s=t+"_"+n;if(void 0===i[s])return"number"==typeof r||"boolean"==typeof r?i[s]=r:ArrayBuffer.isView(r)?i[s]=r.slice():i[s]=r.clone(),!0;{const e=i[s];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[s]=r,!0}else{if(ArrayBuffer.isView(r))return!0;if(!1===e.equals(r))return e.copy(r),!0}}return!1}(t,n,i,r)){const n=t.__offset,i=t.value;if(Array.isArray(i)){let e=0;for(let n=0;n<i.length;n++){const r=i[n],s=u(r);c(r,t.__data,e),"number"==typeof r||"boolean"==typeof r||r.isMatrix3||ArrayBuffer.isView(r)||(e+=s.storage/Float32Array.BYTES_PER_ELEMENT)}}else c(i,t.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,n,t.__data)}}function c(e,t,n){"number"==typeof e||"boolean"==typeof e?t[0]=e:e.isMatrix3?(t[0]=e.elements[0],t[1]=e.elements[1],t[2]=e.elements[2],t[3]=0,t[4]=e.elements[3],t[5]=e.elements[4],t[6]=e.elements[5],t[7]=0,t[8]=e.elements[6],t[9]=e.elements[7],t[10]=e.elements[8],t[11]=0):ArrayBuffer.isView(e)?t.set(new e.constructor(e.buffer,e.byteOffset,t.length)):e.toArray(t,n)}function u(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?up("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):up("WebGLRenderer: Unsupported uniform value type.",e),t}function h(t){const n=t.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,c){let d=r[n.id];void 0===d&&(!function(e){const t=e.uniforms;let n=0;const i=16;for(let e=0,r=t.length;e<r;e++){const r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){const t=r[e],s=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=s.length;e<r;e++){const r=u(s[e]),a=n%i,o=a%r.boundary,l=a+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),t.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e<o;e++)if(-1===a.indexOf(e))return a.push(e),e;return hp("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),r=t.__size,s=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,s),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=d,n.addEventListener("dispose",h));const p=c.program;i.updateUBOMapping(n,p);const f=t.render.frame;s[n.id]!==f&&(!function(t){const n=r[t.id],i=t.uniforms,s=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let e=0,t=i.length;e<t;e++){const t=i[e];if(Array.isArray(t))for(let n=0,i=t.length;n<i;n++)l(t[n],e,n,s);else l(t,e,0,s)}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),s[n.id]=f)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);a=[],r={},s={}}}}rT.set(-1,0,0,0,1,0,0,0,1);const oT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let lT=null;class cT{constructor(e={}){const{canvas:t=sp(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:d=Sh,multiviewStereo:p=!1}=e;let f;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;const m=d,g=new Set([jh,Wh,Gh]),v=new Set([Sh,Rh,Eh,Dh,Ih,Lh]),y=new Uint32Array(4),x=new Int32Array(4),b=new Rp;let _=null,w=null;const S=[],M=[];let T=null;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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let A=!1,R=null,C=null,P=null,I=null;this._outputColorSpace=Ud;let L=0,D=0,N=null,O=-1,F=null;const k=new qp,U=new qp;let z=null;const B=new Nf(0);let V=0,G=t.width,H=t.height,W=1,j=null,X=null;const q=new qp(0,0,G,H),$=new qp(0,0,G,H);let Y=!1;const K=new av;let Z=!1,J=!1;const Q=new Jp,ee=new Rp,te=new qp,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ie=!1;function re(){return null===N?W:1}let se,ae,oe,le,ce,ue,he,de,pe,fe,me,ge,ve,ye,xe,be,_e,we,Se,Me,Te,Ee,Ae,Re,Ce=n;function Pe(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${vu}`),t.addEventListener("webglcontextlost",De,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Oe,!1),null===Ce){const t="webgl2";if(Ce=Pe(t,e),null===Ce)throw Pe(t)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(e){throw hp("WebGLRenderer: "+e.message),e}function Ie(){se=new jw(Ce),se.init(),Ee=new QM(Ce,se),ae=new Ew(Ce,se,e,Ee),oe=new ZM(Ce,se),ae.reversedDepthBuffer&&h&&oe.buffers.depth.setReversed(!0),C=Ce.createFramebuffer(),P=Ce.createFramebuffer(),I=Ce.createFramebuffer(),le=new $w(Ce),ce=new NM,ue=new JM(Ce,se,oe,ce,ae,Ee,le),he=new Ww(E),de=new gw(Ce),Ae=new Mw(Ce,de),pe=new Xw(Ce,de,le,Ae),fe=new Zw(Ce,pe,de,Ae,le),Se=new Yw(Ce,ae,ue),xe=new Aw(ce),me=new DM(E,he,se,ae,Ae,xe),ge=new sT(E,ce),ve=new UM,ye=new WM(se),we=new Sw(E,he,oe,fe,f,o),_e=new Kw(E,se,Ce),be=new KM(E,fe,ae),Re=new aT(Ce,le,ae,oe),Me=new Tw(Ce,se,le),Te=new qw(Ce,se,le),le.programs=me.programs,E.capabilities=ae,E.extensions=se,E.properties=ce,E.renderLists=ve,E.shadowMap=be,E.state=oe,E.info=le}Ie(),m!==Sh&&(T=new Qw(m,t.width,t.height,a,i,r));const Le=new nT(E,Ce,se,p);function De(e){e.preventDefault(),lp("WebGLRenderer: Context Lost."),A=!0}function Ne(){lp("WebGLRenderer: Context Restored."),A=!1;const e=le.autoReset,t=be.enabled,n=be.autoUpdate,i=be.needsUpdate,r=be.type;Ie(),le.autoReset=e,be.enabled=t,be.autoUpdate=n,be.needsUpdate=i,be.type=r}function Oe(e){hp("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Fe(e){const t=e.target;t.removeEventListener("dispose",Fe),function(e){(function(e){const t=ce.get(e).programs;void 0!==t&&(t.forEach(function(e){me.releaseProgram(e)}),e.isShaderMaterial&&me.releaseShaderCache(e))})(e),ce.remove(e)}(t)}function ke(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,qe(e,t,n),e.side=0,e.needsUpdate=!0,qe(e,t,n),e.side=2):qe(e,t,n)}this.xr=Le,this.getContext=function(){return Ce},this.getContextAttributes=function(){return Ce.getContextAttributes()},this.forceContextLoss=function(){const e=se.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=se.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(e){void 0!==e&&(W=e,this.setSize(G,H,!1))},this.getSize=function(e){return e.set(G,H)},this.setSize=function(e,n,i=!0){Le.isPresenting?up("WebGLRenderer: Can't change size while VR device is presenting."):(G=e,H=n,t.width=Math.floor(e*W),t.height=Math.floor(n*W),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),null!==T&&T.setSize(t.width,t.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(G*W,H*W).floor()},this.setDrawingBufferSize=function(e,n,i){G=e,H=n,W=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m!==Sh){if(e)for(let t=0;t<e.length;t++)if(!0===e[t].isOutputPass){up("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}T.setEffects(e||[])}else hp("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(e){return e.copy(k)},this.getViewport=function(e){return e.copy(q)},this.setViewport=function(e,t,n,i){e.isVector4?q.set(e.x,e.y,e.z,e.w):q.set(e,t,n,i),oe.viewport(k.copy(q).multiplyScalar(W).round())},this.getScissor=function(e){return e.copy($)},this.setScissor=function(e,t,n,i){e.isVector4?$.set(e.x,e.y,e.z,e.w):$.set(e,t,n,i),oe.scissor(U.copy($).multiplyScalar(W).round())},this.getScissorTest=function(){return Y},this.setScissorTest=function(e){oe.setScissorTest(Y=e)},this.setOpaqueSort=function(e){j=e},this.setTransparentSort=function(e){X=e},this.getClearColor=function(e){return e.copy(we.getClearColor())},this.setClearColor=function(){we.setClearColor(...arguments)},this.getClearAlpha=function(){return we.getClearAlpha()},this.setClearAlpha=function(){we.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==N){const t=N.texture.format;e=g.has(t)}if(e){const e=N.texture.type,t=v.has(e),n=we.getClearColor(),i=we.getClearAlpha(),r=n.r,s=n.g,a=n.b;t?(y[0]=r,y[1]=s,y[2]=a,y[3]=i,Ce.clearBufferuiv(Ce.COLOR,0,y)):(x[0]=r,x[1]=s,x[2]=a,x[3]=i,Ce.clearBufferiv(Ce.COLOR,0,x))}else i|=Ce.COLOR_BUFFER_BIT}t&&(i|=Ce.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(i|=Ce.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==i&&Ce.clear(i)},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.setNodesHandler=function(e){e.setRenderer(this),R=e},this.dispose=function(){t.removeEventListener("webglcontextlost",De,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Oe,!1),we.dispose(),ve.dispose(),ye.dispose(),ce.dispose(),he.dispose(),fe.dispose(),Ae.dispose(),Re.dispose(),me.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",ze),Le.removeEventListener("sessionend",Be),Ve.stop()},this.renderBufferDirect=function(e,t,n,i,r,s){null===t&&(t=ne);const a=r.isMesh&&r.matrixWorld.determinantAffine()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=ne);ue.resetTextureUnits();const s=t.fog,a=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?t.environment:null,o=null===N?E.outputColorSpace:!0===N.isXRRenderTarget?N.texture.colorSpace:Fp.workingColorSpace,l=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,c=he.get(i.envMap||a,l),u=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,h=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,f=!!n.morphAttributes.color;let m=0;i.toneMapped&&(null!==N&&!0!==N.isXRRenderTarget||(m=E.toneMapping));const g=N&&N.isWebGLMultiviewRenderTarget?N.numViews:0,v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,y=void 0!==v?v.length:0,x=ce.get(i),_=w.state.lights;if(!0===Z&&(!0===J||e!==F)){const t=e===F&&i.id===O;xe.setState(i,e,t)}let S=!1;i.version===x.__version?x.needsLights&&x.lightsStateVersion!==_.state.version||x.outputColorSpace!==o||r.isBatchedMesh&&!1===x.batching?S=!0:r.isBatchedMesh||!0!==x.batching?r.isBatchedMesh&&!0===x.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===x.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===x.instancing?S=!0:r.isInstancedMesh||!0!==x.instancing?r.isSkinnedMesh&&!1===x.skinning?S=!0:r.isSkinnedMesh||!0!==x.skinning?r.isInstancedMesh&&!0===x.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===x.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===x.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===x.instancingMorph&&null!==r.morphTexture||x.envMap!==c||!0===i.fog&&x.fog!==s?S=!0:void 0===x.numClippingPlanes||x.numClippingPlanes===xe.numPlanes&&x.numIntersection===xe.numIntersection?(x.vertexAlphas!==u||x.vertexTangents!==h||x.morphTargets!==d||x.morphNormals!==p||x.morphColors!==f||x.toneMapping!==m||x.morphTargetsCount!==y||!!x.lightProbeGrid!=w.state.lightProbeGridArray.length>0||x.numMultiviewViews!==g)&&(S=!0):S=!0:S=!0:S=!0:S=!0:(S=!0,x.__version=i.version);let M=x.currentProgram;!0===S&&(M=qe(i,t,r),R&&i.isNodeMaterial&&R.onUpdateProgram(i,M,x));let T=!1,A=!1,C=!1;const P=M.getUniforms(),I=x.uniforms;oe.useProgram(M.program)&&(T=!0,A=!0,C=!0);i.id!==O&&(O=i.id,A=!0);if(x.needsLights){const e=function(e,t){if(0===e.length)return null;if(1===e.length)return null!==e[0].texture?e[0]:null;b.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t<n;t++){const n=e[t];if(null!==n.texture&&n.boundingBox.containsPoint(b))return n}return null}(w.state.lightProbeGridArray,r);x.lightProbeGrid!==e&&(x.lightProbeGrid=e,A=!0)}if(T||F!==e){if(M.numMultiviewViews>0)_e.updateCameraProjectionMatricesUniform(e,P),_e.updateCameraViewMatricesUniform(e,P);else{oe.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),P.setValue(Ce,"projectionMatrix",e.projectionMatrix),P.setValue(Ce,"viewMatrix",e.matrixWorldInverse)}const t=P.map.cameraPosition;void 0!==t&&t.setValue(Ce,ee.setFromMatrixPosition(e.matrixWorld)),ae.logarithmicDepthBuffer&&P.setValue(Ce,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(Ce,"isOrthographic",!0===e.isOrthographicCamera),F!==e&&(F=e,A=!0,C=!0)}x.needsLights&&(_.state.directionalShadowMap.length>0&&P.setValue(Ce,"directionalShadowMap",_.state.directionalShadowMap,ue),_.state.spotShadowMap.length>0&&P.setValue(Ce,"spotShadowMap",_.state.spotShadowMap,ue),_.state.pointShadowMap.length>0&&P.setValue(Ce,"pointShadowMap",_.state.pointShadowMap,ue));if(r.isSkinnedMesh){P.setOptional(Ce,r,"bindMatrix"),P.setOptional(Ce,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(Ce,"boneTexture",e.boneTexture,ue))}r.isBatchedMesh&&(P.setOptional(Ce,r,"batchingTexture"),P.setValue(Ce,"batchingTexture",r._matricesTexture,ue),P.setOptional(Ce,r,"batchingIdTexture"),P.setValue(Ce,"batchingIdTexture",r._indirectTexture,ue),P.setOptional(Ce,r,"batchingColorTexture"),null!==r._colorsTexture&&P.setValue(Ce,"batchingColorTexture",r._colorsTexture,ue));const L=n.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||Se.update(r,n,M);(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(Ce,"receiveShadow",r.receiveShadow));(i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial)&&null===i.envMap&&null!==t.environment&&(I.envMapIntensity.value=t.environmentIntensity);void 0!==I.dfgLUT&&(I.dfgLUT.value=(null===lT&&(lT=new Bg(oT,16,16,Hh,Ph),lT.name="DFG_LUT",lT.minFilter=bh,lT.magFilter=bh,lT.wrapS=mh,lT.wrapT=mh,lT.generateMipmaps=!1,lT.needsUpdate=!0),lT));if(A){if(P.setValue(Ce,"toneMappingExposure",E.toneMappingExposure),x.needsLights&&(k=C,(D=I).ambientLightColor.needsUpdate=k,D.lightProbe.needsUpdate=k,D.directionalLights.needsUpdate=k,D.directionalLightShadows.needsUpdate=k,D.pointLights.needsUpdate=k,D.pointLightShadows.needsUpdate=k,D.spotLights.needsUpdate=k,D.spotLightShadows.needsUpdate=k,D.rectAreaLights.needsUpdate=k,D.hemisphereLights.needsUpdate=k),s&&!0===i.fog&&ge.refreshFogUniforms(I,s),ge.refreshMaterialUniforms(I,i,W,H,w.state.transmissionRenderTarget[e.id]),x.needsLights&&x.lightProbeGrid){const e=x.lightProbeGrid;I.probesSH.value=e.texture,I.probesMin.value.copy(e.boundingBox.min),I.probesMax.value.copy(e.boundingBox.max),I.probesResolution.value.copy(e.resolution)}rM.upload(Ce,$e(x),I,ue)}var D,k;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(rM.upload(Ce,$e(x),I,ue),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&P.setValue(Ce,"center",r.center);M.numMultiviewViews>0?_e.updateObjectMatricesUniforms(r,e,P):(P.setValue(Ce,"modelViewMatrix",r.modelViewMatrix),P.setValue(Ce,"normalMatrix",r.normalMatrix));if(P.setValue(Ce,"modelMatrix",r.matrixWorld),void 0!==i.uniformsGroups){const e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++){const n=e[t];Re.update(n,M),Re.bind(n,M)}}return M}(e,t,n,i,r);oe.setMaterial(i,a);let l=n.index,c=1;if(!0===i.wireframe){if(l=pe.getWireframeAttribute(n),void 0===l)return;c=2}const u=n.drawRange,h=n.attributes.position;let d=u.start*c,p=(u.start+u.count)*c;null!==s&&(d=Math.max(d,s.start*c),p=Math.min(p,(s.start+s.count)*c)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=h&&(d=Math.max(d,0),p=Math.min(p,h.count));const f=p-d;if(f<0||f===1/0)return;let m;Ae.setup(r,i,o,n,l);let g=Me;if(null!==l&&(m=de.get(l),g=Te,g.setIndex(m)),r.isMesh)!0===i.wireframe?(oe.setLineWidth(i.wireframeLinewidth*re()),g.setMode(Ce.LINES)):g.setMode(Ce.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),oe.setLineWidth(e*re()),r.isLineSegments?g.setMode(Ce.LINES):r.isLineLoop?g.setMode(Ce.LINE_LOOP):g.setMode(Ce.LINE_STRIP)}else r.isPoints?g.setMode(Ce.POINTS):r.isSprite&&g.setMode(Ce.TRIANGLES);if(r.isBatchedMesh)if(se.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const e=r._multiDrawStarts,t=r._multiDrawCounts,n=r._multiDrawCount,s=l?de.get(l).bytesPerElement:1,a=ce.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)a.setValue(Ce,"_gl_DrawID",i),g.render(e[i]/s,t[i])}else if(r.isInstancedMesh)g.renderInstances(d,f,r.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);g.renderInstances(d,f,t)}else g.render(d,f)},this.compile=function(e,t,n=null){null===n&&(n=e),w=ye.get(n),w.init(t),M.push(w),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(w.pushLight(e),e.castShadow&&w.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(w.pushLight(e),e.castShadow&&w.pushShadow(e))}),w.setupLights();const i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++){const s=t[r];ke(s,n,e),i.add(s)}else ke(t,n,e),i.add(t)}),w=M.pop(),i},this.compileAsync=function(e,t,n=null){const i=this.compile(e,t,n);return new Promise(t=>{function n(){i.forEach(function(e){ce.get(e).currentProgram.isReady()&&i.delete(e)}),0!==i.size?setTimeout(n,10):t(e)}null!==se.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let Ue=null;function ze(){Ve.stop()}function Be(){Ve.start()}const Ve=new mw;function Ge(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLightProbeGrid)w.pushLightProbeGrid(e);else if(e.isLight)w.pushLight(e),e.castShadow&&w.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||K.intersectsSprite(e)){i&&te.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Q);const t=fe.update(e),r=e.material;r.visible&&_.push(e,t,r,n,te.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||K.intersectsObject(e))){const t=fe.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),te.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),te.copy(t.boundingSphere.center)),te.applyMatrix4(e.matrixWorld).applyMatrix4(Q)),Array.isArray(r)){const i=t.groups;for(let s=0,a=i.length;s<a;s++){const a=i[s],o=r[a.materialIndex];o&&o.visible&&_.push(e,t,o,n,te.z,a)}}else r.visible&&_.push(e,t,r,n,te.z,null)}const r=e.children;for(let e=0,s=r.length;e<s;e++)Ge(r[e],t,n,i)}function He(e,t,n,i){const{opaque:r,transmissive:s,transparent:a}=e;w.setupLightsView(n),!0===Z&&xe.setGlobalState(E.clippingPlanes,n),i&&oe.viewport(k.copy(i)),r.length>0&&je(r,t,n),s.length>0&&je(s,t,n),a.length>0&&je(a,t,n),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function We(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===w.state.transmissionRenderTarget[i.id]){const e=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[i.id]=new Yp(1,1,{generateMipmaps:!0,type:e?Ph:Sh,minFilter:wh,samples:Math.max(4,ae.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Fp.workingColorSpace})}const s=w.state.transmissionRenderTarget[i.id],a=i.viewport||k;s.setSize(a.z*E.transmissionResolutionScale,a.w*E.transmissionResolutionScale);const o=E.getRenderTarget(),l=E.getActiveCubeFace(),c=E.getActiveMipmapLevel();E.setRenderTarget(s),E.getClearColor(B),V=E.getClearAlpha(),V<1&&E.setClearColor(16777215,.5),E.clear(),ie&&we.render(n);const u=E.toneMapping;E.toneMapping=0;const h=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),w.setupLightsView(i),!0===Z&&xe.setGlobalState(E.clippingPlanes,i),je(e,n,i),ue.updateMultisampleRenderTarget(s),ue.updateRenderTargetMipmap(s),!1===se.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,s=t.length;r<s;r++){const s=t[r],{object:a,geometry:o,material:l,group:c}=s;if(2===l.side&&a.layers.test(i.layers)){const t=l.side;l.side=1,l.needsUpdate=!0,Xe(a,n,i,o,l,c),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(ue.updateMultisampleRenderTarget(s),ue.updateRenderTargetMipmap(s))}E.setRenderTarget(o,l,c),E.setClearColor(B,V),void 0!==h&&(i.viewport=h),E.toneMapping=u}function je(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r<s;r++){const s=e[r],{object:a,geometry:o,group:l}=s;let c=s.material;!0===c.allowOverride&&null!==i&&(c=i),a.layers.test(n.layers)&&Xe(a,t,n,o,c,l)}}function Xe(e,t,n,i,r,s){e.onBeforeRender(E,t,n,i,r,s),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(E,t,n,i,e,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,E.renderBufferDirect(n,t,i,r,e,s),r.side=0,r.needsUpdate=!0,E.renderBufferDirect(n,t,i,r,e,s),r.side=2):E.renderBufferDirect(n,t,i,r,e,s),e.onAfterRender(E,t,n,i,r,s)}function qe(e,t,n){!0!==t.isScene&&(t=ne);const i=ce.get(e),r=w.state.lights,s=w.state.shadowsArray,a=r.state.version,o=me.getParameters(e,r.state,s,t,n,w.state.lightProbeGridArray),l=me.getProgramCacheKey(o);let c=i.programs;i.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,i.fog=t.fog;const u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;i.envMap=he.get(e.envMap||i.environment,u),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",Fe),c=new Map,i.programs=c);let h=c.get(l);if(void 0!==h){if(i.currentProgram===h&&i.lightsStateVersion===a)return Ye(e,o),h}else o.uniforms=me.getUniforms(e),null!==R&&e.isNodeMaterial&&R.build(e,n,o),e.onBeforeCompile(o,E),h=me.acquireProgram(o,l),c.set(l,h),i.uniforms=o.uniforms;const d=i.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=xe.uniform),Ye(e,o),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=a,i.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),i.lightProbeGrid=w.state.lightProbeGridArray.length>0,i.currentProgram=h,i.uniformsList=null,h}function $e(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=rM.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function Ye(e,t){const n=ce.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping,n.numMultiviewViews=t.numMultiviewViews}var Ke;Ve.setAnimationLoop(function(e){Ue&&Ue(e)}),"undefined"!=typeof self&&Ve.setContext(self),this.setAnimationLoop=function(e){Ue=e,Le.setAnimationLoop(e),null===e?Ve.stop():Ve.start()},Le.addEventListener("sessionstart",ze),Le.addEventListener("sessionend",Be),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void hp("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===A)return;null!==R&&R.renderStart(e,t);const n=!0===Le.enabled&&!0===Le.isPresenting,i=null!==T&&(null===N||n)&&T.begin(E,N);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0!==Le.enabled||!0!==Le.isPresenting||null!==T&&!1!==T.isCompositing()||(!0===Le.cameraAutoUpdate&&Le.updateCamera(t),t=Le.getCamera()),!0===e.isScene&&e.onBeforeRender(E,e,t,N),w=ye.get(e,M.length),w.init(t),w.state.textureUnits=ue.getTextureUnits(),M.push(w),Q.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),K.setFromProjectionMatrix(Q,Qd,t.reversedDepth),J=this.localClippingEnabled,Z=xe.init(this.clippingPlanes,J),_=ve.get(e,S.length),_.init(),S.push(_),!0===Le.enabled&&!0===Le.isPresenting){const e=E.xr.getDepthSensingMesh();null!==e&&Ge(e,t,-1/0,E.sortObjects)}Ge(e,t,0,E.sortObjects),_.finish(),!0===E.sortObjects&&_.sort(j,X,t.reversedDepth),ie=!1===Le.enabled||!1===Le.isPresenting||!1===Le.hasDepthSensing(),ie&&we.addToRenderList(_,e),this.info.render.frame++,!0===this.info.autoReset&&this.info.reset(),!0===Z&&xe.beginShadows();const r=w.state.shadowsArray;be.render(r,e,t),!0===Z&&xe.endShadows();if(!1===(i&&T.hasRenderPass())){const n=_.opaque,i=_.transmissive;if(w.setupLights(),t.isArrayCamera){const r=t.cameras;if(i.length>0)for(let t=0,s=r.length;t<s;t++){We(n,i,e,r[t])}if(ie&&we.render(e),Le.enabled&&Le.isMultiview)ue.setDeferTextureUploads(!0),He(_,e,t,t.cameras[0].viewport);else for(let t=0,n=r.length;t<n;t++){const n=r[t];He(_,e,n,n.viewport)}}else i.length>0&&We(n,i,e,t),ie&&we.render(e),He(_,e,t)}null!==N&&0===D&&(ue.updateMultisampleRenderTarget(N),ue.updateRenderTargetMipmap(N)),i&&T.end(E),!0===e.isScene&&e.onAfterRender(E,e,t),Ae.resetDefaultState(),O=-1,F=null,M.pop(),M.length>0?(w=M[M.length-1],ue.setTextureUnits(w.state.textureUnits),!0===Z&&xe.setGlobalState(E.clippingPlanes,w.state.camera)):w=null,S.pop(),_=S.length>0?S[S.length-1]:null,null!==R&&R.renderEnd()},this.setTexture2D=(Ke=!1,function(e,t){e&&e.isWebGLRenderTarget&&(Ke||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Ke=!0),e=e.texture),ue.setTexture2D(e,t)}),this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(e,t,n){const i=ce.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1!==i.__autoAllocateDepthBuffer||N&&N.isWebGLMultiviewRenderTarget||(i.__useRenderToTexture=!1),ce.get(e.texture).__webglTexture=t,ce.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const n=ce.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){null===e&&this.xr.isPresenting&&(e=this.xr.getRenderTarget()),N=e,L=t,D=n;let i=null,r=!1,s=!1;if(e){const a=ce.get(e);if(void 0!==a.__useDefaultFramebuffer)return oe.bindFramebuffer(Ce.FRAMEBUFFER,a.__webglFramebuffer),k.copy(e.viewport),U.copy(e.scissor),z=e.scissorTest,oe.viewport(k),oe.scissor(U),oe.setScissorTest(z),void(O=-1);if(void 0===a.__webglFramebuffer)ue.setupRenderTarget(e);else if(a.__hasExternalTextures)ue.rebindTextures(e,ce.get(e.texture).__webglTexture,ce.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(a.__boundDepthTexture!==t){if(null!==t&&ce.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");ue.setupDepthRenderbuffer(e)}}const o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);const l=ce.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(l[t])?l[t][n]:l[t],r=!0):i=e.samples>0&&!1===ue.useMultisampledRTT(e)?ce.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,k.copy(e.viewport),U.copy(e.scissor),z=e.scissorTest}else k.copy(q).multiplyScalar(W).floor(),U.copy($).multiplyScalar(W).floor(),z=Y;0!==n&&(i=C);if(oe.bindFramebuffer(Ce.FRAMEBUFFER,i)&&oe.drawBuffers(e,i),oe.viewport(k),oe.scissor(U),oe.setScissorTest(z),r){const i=ce.get(e.texture);Ce.framebufferTexture2D(Ce.FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,Ce.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=t;for(let t=0;t<e.textures.length;t++){const r=ce.get(e.textures[t]);Ce.framebufferTextureLayer(Ce.FRAMEBUFFER,Ce.COLOR_ATTACHMENT0+t,r.__webglTexture,n,i)}}else if(null!==e&&0!==n){const t=ce.get(e.texture);Ce.framebufferTexture2D(Ce.FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,Ce.TEXTURE_2D,t.__webglTexture,n)}O=-1},this.readRenderTargetPixels=function(e,t,n,i,r,s,a,o=0){if(!e||!e.isWebGLRenderTarget)return void hp("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ce.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){oe.bindFramebuffer(Ce.FRAMEBUFFER,l);try{const a=e.textures[o],l=a.format,c=a.type;if(e.textures.length>1&&Ce.readBuffer(Ce.COLOR_ATTACHMENT0+o),!ae.textureFormatReadable(l))return void hp("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!ae.textureTypeReadable(c))return void hp("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&Ce.readPixels(t,n,i,r,Ee.convert(l),Ee.convert(c),s)}finally{const e=null!==N?ce.get(N).__webglFramebuffer:null;oe.bindFramebuffer(Ce.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,r,s,a,o=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ce.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r){oe.bindFramebuffer(Ce.FRAMEBUFFER,l);const a=e.textures[o],c=a.format,u=a.type;if(e.textures.length>1&&Ce.readBuffer(Ce.COLOR_ATTACHMENT0+o),!ae.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ae.textureTypeReadable(u))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const h=Ce.createBuffer();Ce.bindBuffer(Ce.PIXEL_PACK_BUFFER,h),Ce.bufferData(Ce.PIXEL_PACK_BUFFER,s.byteLength,Ce.STREAM_READ),Ce.readPixels(t,n,i,r,Ee.convert(c),Ee.convert(u),0);const d=null!==N?ce.get(N).__webglFramebuffer:null;oe.bindFramebuffer(Ce.FRAMEBUFFER,d);const p=Ce.fenceSync(Ce.SYNC_GPU_COMMANDS_COMPLETE,0);return Ce.flush(),await function(e,t,n){return new Promise(function(i,r){setTimeout(function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}},n)})}(Ce,p,4),Ce.bindBuffer(Ce.PIXEL_PACK_BUFFER,h),Ce.getBufferSubData(Ce.PIXEL_PACK_BUFFER,0,s),Ce.deleteBuffer(h),Ce.deleteSync(p),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),s=Math.floor(e.image.height*i),a=null!==t?t.x:0,o=null!==t?t.y:0;ue.setTexture2D(e,0),Ce.copyTexSubImage2D(Ce.TEXTURE_2D,n,0,0,a,o,r,s),oe.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,i=null,r=0,s=0){let a,o,l,c,u,h,d,p,f;const m=e.isCompressedTexture?e.mipmaps[s]:e.image;if(null!==n)a=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,u=n.min.y,h=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-r);a=Math.floor(m.width*t),o=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,u=0,h=0}null!==i?(d=i.x,p=i.y,f=i.z):(d=0,p=0,f=0);const g=Ee.convert(t.format),v=Ee.convert(t.type);let y;t.isData3DTexture?(ue.setTexture3D(t,0),y=Ce.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ue.setTexture2DArray(t,0),y=Ce.TEXTURE_2D_ARRAY):(ue.setTexture2D(t,0),y=Ce.TEXTURE_2D),oe.activeTexture(Ce.TEXTURE0),oe.pixelStorei(Ce.UNPACK_FLIP_Y_WEBGL,t.flipY),oe.pixelStorei(Ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),oe.pixelStorei(Ce.UNPACK_ALIGNMENT,t.unpackAlignment);const x=oe.getParameter(Ce.UNPACK_ROW_LENGTH),b=oe.getParameter(Ce.UNPACK_IMAGE_HEIGHT),_=oe.getParameter(Ce.UNPACK_SKIP_PIXELS),w=oe.getParameter(Ce.UNPACK_SKIP_ROWS),S=oe.getParameter(Ce.UNPACK_SKIP_IMAGES);oe.pixelStorei(Ce.UNPACK_ROW_LENGTH,m.width),oe.pixelStorei(Ce.UNPACK_IMAGE_HEIGHT,m.height),oe.pixelStorei(Ce.UNPACK_SKIP_PIXELS,c),oe.pixelStorei(Ce.UNPACK_SKIP_ROWS,u),oe.pixelStorei(Ce.UNPACK_SKIP_IMAGES,h);const M=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=ce.get(e),i=ce.get(t),m=ce.get(n.__renderTarget),g=ce.get(i.__renderTarget);oe.bindFramebuffer(Ce.READ_FRAMEBUFFER,m.__webglFramebuffer),oe.bindFramebuffer(Ce.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<l;n++)M&&(Ce.framebufferTextureLayer(Ce.READ_FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,ce.get(e).__webglTexture,r,h+n),Ce.framebufferTextureLayer(Ce.DRAW_FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,ce.get(t).__webglTexture,s,f+n)),Ce.blitFramebuffer(c,u,a,o,d,p,a,o,Ce.DEPTH_BUFFER_BIT,Ce.NEAREST);oe.bindFramebuffer(Ce.READ_FRAMEBUFFER,null),oe.bindFramebuffer(Ce.DRAW_FRAMEBUFFER,null)}else if(0!==r||e.isRenderTargetTexture||ce.has(e)){const n=ce.get(e),i=ce.get(t);oe.bindFramebuffer(Ce.READ_FRAMEBUFFER,P),oe.bindFramebuffer(Ce.DRAW_FRAMEBUFFER,I);for(let e=0;e<l;e++)M?Ce.framebufferTextureLayer(Ce.READ_FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,n.__webglTexture,r,h+e):Ce.framebufferTexture2D(Ce.READ_FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,Ce.TEXTURE_2D,n.__webglTexture,r),T?Ce.framebufferTextureLayer(Ce.DRAW_FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,i.__webglTexture,s,f+e):Ce.framebufferTexture2D(Ce.DRAW_FRAMEBUFFER,Ce.COLOR_ATTACHMENT0,Ce.TEXTURE_2D,i.__webglTexture,s),0!==r?Ce.blitFramebuffer(c,u,a,o,d,p,a,o,Ce.COLOR_BUFFER_BIT,Ce.NEAREST):T?Ce.copyTexSubImage3D(y,s,d,p,f+e,c,u,a,o):Ce.copyTexSubImage2D(y,s,d,p,c,u,a,o);oe.bindFramebuffer(Ce.READ_FRAMEBUFFER,null),oe.bindFramebuffer(Ce.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?Ce.texSubImage3D(y,s,d,p,f,a,o,l,g,v,m.data):t.isCompressedArrayTexture?Ce.compressedTexSubImage3D(y,s,d,p,f,a,o,l,g,m.data):Ce.texSubImage3D(y,s,d,p,f,a,o,l,g,v,m):e.isDataTexture?Ce.texSubImage2D(Ce.TEXTURE_2D,s,d,p,a,o,g,v,m.data):e.isCompressedTexture?Ce.compressedTexSubImage2D(Ce.TEXTURE_2D,s,d,p,m.width,m.height,g,m.data):Ce.texSubImage2D(Ce.TEXTURE_2D,s,d,p,a,o,g,v,m);oe.pixelStorei(Ce.UNPACK_ROW_LENGTH,x),oe.pixelStorei(Ce.UNPACK_IMAGE_HEIGHT,b),oe.pixelStorei(Ce.UNPACK_SKIP_PIXELS,_),oe.pixelStorei(Ce.UNPACK_SKIP_ROWS,w),oe.pixelStorei(Ce.UNPACK_SKIP_IMAGES,S),0===s&&t.generateMipmaps&&Ce.generateMipmap(y),oe.unbindTexture()},this.initRenderTarget=function(e){void 0===ce.get(e).__webglFramebuffer&&ue.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?ue.setTextureCube(e,0):e.isData3DTexture?ue.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ue.setTexture2DArray(e,0):ue.setTexture2D(e,0),oe.unbindTexture()},this.resetState=function(){L=0,D=0,N=null,oe.reset(),Ae.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Qd}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Fp._getDrawingBufferColorSpace(e),t.unpackColorSpace=Fp._getUnpackColorSpace()}}var uT=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:Su,AddOperation:2,AdditiveAnimationBlendMode:Fd,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:Fh,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Hb,AnimationAction:I_,AnimationClip:ub,AnimationLoader:class extends gb{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new xb(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):hp(t),r.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=ub.parse(e[n]);t.push(i)}return t}},AnimationMixer:class extends fp{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,s=e._propertyBindings,a=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let e=0;e!==r;++e){const r=i[e],l=r.name;let u=c[l];if(void 0!==u)++u.referenceCount,s[e]=u;else{if(u=s[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,o,l));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;u=new S_(P_.create(n,l,i),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,o,l),s[e]=u}a[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0===n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}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 null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,r=this._actionsByClip;let s=r[t];if(void 0===s)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{const t=s.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,l=o[o.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,o[c]=l,o.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0===--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let s=i[t];void 0===s&&(s={},i[t]=s),s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,a=s[i],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete a[r],0===Object.keys(a).length&&delete s[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new Qx(new Float32Array(2),new Float32Array(2),1,L_),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const i=t||this._root,r=i.uuid;let s="string"==typeof e?ub.findByName(i,e):e;const a=null!==s?s.uuid:e,o=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==s?s.blendMode:Od),void 0!==o){const e=o.actionByRoot[r];if(void 0!==e&&e.blendMode===n)return e;l=o.knownActions[0],null===s&&(s=l._clip)}if(null===s)return null;const c=new I_(this,s,t,n);return this._bindAction(c,l),this._addInactiveAction(c,a,r),c}existingAction(e,t){const n=t||this._root,i=n.uuid,r="string"==typeof e?ub.findByName(n,e):e,s=r?r.uuid:e,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(i,e,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)a[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const e=r.knownActions;for(let n=0,i=e.length;n!==i;++n){const i=e[n];this._deactivateAction(i);const r=i._cacheIndex,s=t[t.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,s._cacheIndex=r,t[r]=s,t.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const e in n){const i=n[e].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[t];if(void 0!==i)for(const e in i){const t=i[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=xp(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;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,n=this._paths,i=this._parsedPaths,r=this._bindings,s=r.length;let a,o=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],h=u.uuid;let d=t[h];if(void 0===d){d=o++,t[h]=d,e.push(u);for(let e=0,t=s;e!==t;++e)r[e].push(new P_(u,n[e],i[e]))}else if(d<l){a=e[d];const o=--l,c=e[o];t[c.uuid]=d,e[d]=c,t[h]=o,e[o]=u;for(let e=0,t=s;e!==t;++e){const t=r[e],s=t[o];let a=t[d];t[d]=s,void 0===a&&(a=new P_(u,n[e],i[e])),t[o]=a}}else e[d]!==a&&hp("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,l=t[o];if(void 0!==l&&l>=r){const s=r++,c=e[s];t[c.uuid]=l,e[l]=c,t[o]=s,e[s]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[s],r=t[l];t[l]=i,t[s]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=e.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=t[o];if(void 0!==l)if(delete t[o],l<r){const a=--r,o=e[a],c=--s,u=e[c];t[o.uuid]=l,e[l]=o,t[u.uuid]=a,e[a]=u,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[a],r=t[c];t[l]=i,t[a]=r,t.pop()}}else{const r=--s,a=e[r];r>0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,u=new Array(l);i=r.length,n[e]=i,s.push(e),a.push(t),r.push(u);for(let n=c,i=o.length;n!==i;++n){const i=o[n];u[n]=new P_(i,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];t[e[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},AnimationUtils:class{static convertArray(e,t){return qx(e,t)}static isTypedArray(e){return ip(e)}static getKeyframeOrder(e){return $x(e)}static sortedArray(e,t,n){return Yx(e,t,n)}static flattenJSON(e,t,n,i){Kx(e,t,n,i)}static subclip(e,t,n,i,r=30){return function(e,t,n,i,r=30){const s=e.clone();s.name=t;const a=[];for(let e=0;e<s.tracks.length;++e){const t=s.tracks[e],o=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const s=t.times[e]*r;if(!(s<n||s>=i)){l.push(t.times[e]);for(let n=0;n<o;++n)c.push(t.values[e*o+n])}}0!==l.length&&(t.times=qx(l,t.times.constructor),t.values=qx(c,t.values.constructor),a.push(t))}s.tracks=a;let o=1/0;for(let e=0;e<s.tracks.length;++e)o>s.tracks[e].times[0]&&(o=s.tracks[e].times[0]);for(let e=0;e<s.tracks.length;++e)s.tracks[e].shift(-1*o);return s.resetDuration(),s}(e,t,n,i,r)}static makeClipAdditive(e,t=0,n=e,i=30){return function(e,t=0,n=e,i=30){i<=0&&(i=30);const r=n.tracks.length,s=t/i;for(let t=0;t<r;++t){const i=n.tracks[t],r=i.ValueTypeName;if("bool"===r||"string"===r)continue;const a=e.tracks.find(function(e){return e.name===i.name&&e.ValueTypeName===r});if(void 0===a)continue;let o=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let c=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const h=i.times.length-1;let d;if(s<=i.times[0]){const e=o,t=l-o;d=i.values.slice(e,t)}else if(s>=i.times[h]){const e=h*l+o,t=e+l-o;d=i.values.slice(e,t)}else{const e=i.createInterpolant(),t=o,n=l-o;e.evaluate(s),d=e.resultBuffer.slice(t,n)}"quaternion"===r&&(new Ap).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let e=0;e<p;++e){const t=e*u+c;if("quaternion"===r)Ap.multiplyQuaternionsFlat(a.values,t,d,0,a.values,t);else{const e=u-2*c;for(let n=0;n<e;++n)a.values[t+n]-=d[n]}}}return e.blendMode=Fd,e}(e,t,n,i)}},ArcCurve:my,ArrayCamera:u_,ArrowHelper:class extends Ef{constructor(e=new Rp(0,0,1),t=new Rp(0,0,0),n=1,i=16776960,r=.2*n,s=.2*r){super(),this.type="ArrowHelper",void 0===dw&&(dw=new Fm,dw.setAttribute("position",new Mm([0,0,0,0,1,0],3)),pw=new sy(.5,1,5,1),pw.translate(0,-.5,0)),this.position.copy(t),this.line=new Fv(dw,new Rv({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ag(pw,new mg({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,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{hw.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(hw,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),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()}},AttachedBindMode:ah,Audio:y_,AudioAnalyser:class{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 n=0;n<t.length;n++)e+=t[n];return e/t.length}},AudioContext:r_,AudioListener:class extends Ef{constructor(){super(),this.type="AudioListener",this.context=r_.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new h_}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(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 null!==this.filter?(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),this._timer.update();const t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(p_,f_,m_),g_.set(0,0,-1).applyQuaternion(f_),v_.set(0,1,0).applyQuaternion(f_),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(p_.x,e),t.positionY.linearRampToValueAtTime(p_.y,e),t.positionZ.linearRampToValueAtTime(p_.z,e),t.forwardX.linearRampToValueAtTime(g_.x,e),t.forwardY.linearRampToValueAtTime(g_.y,e),t.forwardZ.linearRampToValueAtTime(g_.z,e),t.upX.linearRampToValueAtTime(v_.x,e),t.upY.linearRampToValueAtTime(v_.y,e),t.upZ.linearRampToValueAtTime(v_.z,e)}else t.setPosition(p_.x,p_.y,p_.z),t.setOrientation(g_.x,g_.y,g_.z,v_.x,v_.y,v_.z)}},AudioLoader:class extends gb{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new xb(this.manager);function a(t){i?i(t):hp(t),r.manager.itemError(e)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{const i=n.slice(0),s=r_.getContext(),o=e+"#decode";r.manager.itemStart(o),s.decodeAudioData(i,function(e){t(e),r.manager.itemEnd(o)}).catch(function(e){a(e),r.manager.itemEnd(o)})}catch(e){a(e)}},n,i)}},AxesHelper:class extends Bv{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new Fm;n.setAttribute("position",new Mm(t,3)),n.setAttribute("color",new Mm([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new Rv({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const i=new Nf,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:Av,BezierInterpolant:tb,Bone:zg,BooleanKeyframeTrack:ib,Box2:V_,Box3:Qf,Box3Helper:class extends Bv{constructor(e,t=16776960){const n=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]),i=new Fm;i.setIndex(new _m(n,1)),i.setAttribute("position",new Mm([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Rv({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()}},BoxGeometry:ty,BoxHelper:class extends Bv{constructor(e,t=16776960){const n=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]),i=new Float32Array(24),r=new Fm;r.setIndex(new _m(n,1)),r.setAttribute("position",new _m(i,3)),super(r,new Rv({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&uw.setFromObject(this.object),uw.isEmpty())return;const e=uw.min,t=uw.max,n=this.geometry.attributes.position,i=n.array;i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,n.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()}},BufferAttribute:_m,BufferGeometry:Fm,BufferGeometryLoader:Zb,ByteType:Mh,Cache:db,Camera:Ib,CameraHelper:class extends Bv{constructor(e){const t=new Fm,n=new Rv({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],s={};function a(e,t){o(e),o(t)}function o(e){i.push(0,0,0),r.push(0,0,0),void 0===s[e]&&(s[e]=[]),s[e].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new Mm(i,3)),t.setAttribute("color",new Mm(r,3)),super(t,n),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 l=new Nf(16755200),c=new Nf(16711680),u=new Nf(43775),h=new Nf(16777215),d=new Nf(3355443);this.setColors(l,c,u,h,d)}setColors(e,t,n,i,r){const s=this.geometry.getAttribute("color");return s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,n.r,n.g,n.b),s.setXYZ(33,n.r,n.g,n.b),s.setXYZ(34,n.r,n.g,n.b),s.setXYZ(35,n.r,n.g,n.b),s.setXYZ(36,n.r,n.g,n.b),s.setXYZ(37,n.r,n.g,n.b),s.setXYZ(38,i.r,i.g,i.b),s.setXYZ(39,i.r,i.g,i.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap;let n,i;if(lw.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)n=1,i=0;else if(this.camera.coordinateSystem===Qd)n=-1,i=1;else{if(this.camera.coordinateSystem!==ep)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);n=0,i=1}cw("c",t,e,lw,0,0,n),cw("t",t,e,lw,0,0,i),cw("n1",t,e,lw,-1,-1,n),cw("n2",t,e,lw,1,-1,n),cw("n3",t,e,lw,-1,1,n),cw("n4",t,e,lw,1,1,n),cw("f1",t,e,lw,-1,-1,i),cw("f2",t,e,lw,1,-1,i),cw("f3",t,e,lw,-1,1,i),cw("f4",t,e,lw,1,1,i),cw("u1",t,e,lw,.7,1.1,n),cw("u2",t,e,lw,-.7,1.1,n),cw("u3",t,e,lw,0,2,n),cw("cf1",t,e,lw,-1,0,i),cw("cf2",t,e,lw,1,0,i),cw("cf3",t,e,lw,0,-1,i),cw("cf4",t,e,lw,0,1,i),cw("cn1",t,e,lw,-1,0,n),cw("cn2",t,e,lw,1,0,n),cw("cn3",t,e,lw,0,-1,n),cw("cn4",t,e,lw,0,1,n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends Xp{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},CapsuleGeometry:ny,CatmullRomCurve3:wy,CineonToneMapping:3,CircleGeometry:iy,ClampToEdgeWrapping:mh,Clock:class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,up("Clock: This module has been deprecated. Please use THREE.Timer instead.")}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}},Color:Nf,ColorKeyframeTrack:rb,ColorManagement:Fp,Compatibility:{TEXTURE_COMPARE:"depthTextureCompare"},CompressedArrayTexture:class extends Kv{constructor(e,t,n,i,r,s){super(e,t,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=mh,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends Kv{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,ch),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},CompressedTexture:Kv,CompressedTextureLoader:class extends gb{constructor(e){super(e)}load(e,t,n,i){const r=this,s=[],a=new Kv,o=new xb(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;function c(c){o.load(e[c],function(e){const n=r.parse(e,!0);s[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=bh),a.image=s,a.format=n.format,a.needsUpdate=!0,t&&t(a))},n,i)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)c(t);else o.load(e,function(e){const n=r.parse(e,!0);if(n.isCubemap){const e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){s[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)s[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),s[t].format=n.format,s[t].width=n.width,s[t].height=n.height}a.image=s}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=bh),a.format=n.format,a.needsUpdate=!0,t&&t(a)},n,i);return a}},ConeGeometry:sy,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:class extends fp{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){void 0!==e?(null!==this.domElement&&this.disconnect(),this.domElement=e):up("Controls: connect() now requires an element.")}disconnect(){}dispose(){}update(){}},CubeCamera:c_,CubeDepthTexture:Qv,CubeReflectionMapping:ch,CubeRefractionMapping:uh,CubeTexture:Zv,CubeTextureLoader:class extends gb{constructor(e){super(e)}load(e,t,n,i){const r=new Zv;r.colorSpace=Ud;const s=new _b(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(n){s.load(e[n],function(e){r.images[n]=e,a++,6===a&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}for(let t=0;t<e.length;++t)o(t);return r}},CubeUVReflectionMapping:ph,CubicBezierCurve:Ey,CubicBezierCurve3:Ay,CubicInterpolant:Jx,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:py,CurvePath:Ny,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:ry,Cylindrical:class{constructor(e=1,t=0,n=0){this.radius=e,this.theta=t,this.y=n}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,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,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Zp,DataArrayTexture:Kp,DataTexture:Bg,DataTextureLoader:class extends gb{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new Bg,a=new xb(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,function(e){let n;try{n=r.parse(e)}catch(e){return void(void 0!==i?i(e):hp(e))}r._applyTexData(s,n),t&&t(s,n)},n,i),s}createDataTexture(e){const t=new Bg;return this._applyTexData(t,this.parse(e)),t}_applyTexData(e,t){void 0!==t.image?e.image=t.image:void 0!==t.data&&(e.image.width=t.width,e.image.height=t.height,e.image.data=t.data),e.wrapS=void 0!==t.wrapS?t.wrapS:mh,e.wrapT=void 0!==t.wrapT?t.wrapT:mh,e.magFilter=void 0!==t.magFilter?t.magFilter:bh,e.minFilter=void 0!==t.minFilter?t.minFilter:bh,e.anisotropy=void 0!==t.anisotropy?t.anisotropy:1,void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.mipmaps&&(e.mipmaps=t.mipmaps,e.minFilter=wh),1===t.mipmapCount&&(e.minFilter=bh),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),e.needsUpdate=!0}},DataUtils:class{static toHalfFloat(e){return gm(e)}static fromHalfFloat(e){return vm(e)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:mb,DepthFormat:zh,DepthStencilFormat:Bh,DepthTexture:Jv,DetachedBindMode:oh,DirectionalLight:Gb,DirectionalLightHelper:class extends Ef{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===t&&(t=1);let i=new Fm;i.setAttribute("position",new Mm([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Rv({fog:!1,toneMapped:!1});this.lightPlane=new Fv(i,r),this.add(this.lightPlane),i=new Fm,i.setAttribute("position",new Mm([0,0,0,0,0,1],3)),this.targetLine=new Fv(i,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.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),rw.setFromMatrixPosition(this.light.matrixWorld),sw.setFromMatrixPosition(this.light.target.matrixWorld),aw.subVectors(sw,rw),this.lightPlane.lookAt(sw),void 0!==this.color?(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(sw),this.targetLine.scale.z=aw.length()}},DiscreteInterpolant:eb,DodecahedronGeometry:oy,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:dy,EllipseCurve:fy,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:hh,EquirectangularRefractionMapping:dh,Euler:cf,EventDispatcher:fp,ExternalTexture:ey,ExtrudeGeometry:px,FileLoader:xb,Float16BufferAttribute:class extends _m{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=vm(this.array[e*this.itemSize]);return this.normalized&&(t=Sp(t,this.array)),t}setX(e,t){return this.normalized&&(t=Mp(t,this.array)),this.array[e*this.itemSize]=gm(t),this}getY(e){let t=vm(this.array[e*this.itemSize+1]);return this.normalized&&(t=Sp(t,this.array)),t}setY(e,t){return this.normalized&&(t=Mp(t,this.array)),this.array[e*this.itemSize+1]=gm(t),this}getZ(e){let t=vm(this.array[e*this.itemSize+2]);return this.normalized&&(t=Sp(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Mp(t,this.array)),this.array[e*this.itemSize+2]=gm(t),this}getW(e){let t=vm(this.array[e*this.itemSize+3]);return this.normalized&&(t=Sp(t,this.array)),t}setW(e,t){return this.normalized&&(t=Mp(t,this.array)),this.array[e*this.itemSize+3]=gm(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array)),this.array[e+0]=gm(t),this.array[e+1]=gm(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array),i=Mp(i,this.array)),this.array[e+0]=gm(t),this.array[e+1]=gm(n),this.array[e+2]=gm(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=Mp(t,this.array),n=Mp(n,this.array),i=Mp(i,this.array),r=Mp(r,this.array)),this.array[e+0]=gm(t),this.array[e+1]=gm(n),this.array[e+2]=gm(i),this.array[e+3]=gm(r),this}},Float32BufferAttribute:Mm,FloatType:Ch,Fog:kf,FogExp2:Ff,FramebufferTexture:class extends Xp{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=vh,this.minFilter=vh,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:av,FrustumArray:lv,GLBufferAttribute:class{constructor(e,t,n,i,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.normalized=s,this.version=0}set needsUpdate(e){!0===e&&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}},GLSL1:"100",GLSL3:Jd,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:Yd,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:iw,Group:Af,HTMLTexture:class extends Xp{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;const c=e?e.parentNode:null;null!==c&&"requestPaint"in c&&(c.onpaint=()=>{this.needsUpdate=!0},c.requestPaint())}dispose(){const e=this.image?this.image.parentNode:null;null!==e&&"onpaint"in e&&(e.onpaint=null),super.dispose()}},HalfFloatType:Ph,HemisphereLight:Sb,HemisphereLightHelper:class extends Ef{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new vx(t);i.rotateY(.5*Math.PI),this.material=new mg({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),s=new Float32Array(3*r.count);i.setAttribute("color",new _m(s,3)),this.add(new Ag(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");tw.copy(this.light.color),nw.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){const i=e<n/2?tw:nw;t.setXYZ(e,i.r,i.g,i.b)}t.needsUpdate=!0}this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),e.lookAt(ew.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:mx,ImageBitmapLoader:class extends gb{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&up("ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&up("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=db.get(`image-bitmap:${e}`);if(void 0!==s)return r.manager.itemStart(e),s.then?void s.then(n=>{!0===n_.has(s)?(i&&i(n_.get(s)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(n),r.manager.itemEnd(e))}):void setTimeout(function(){t&&t(s),r.manager.itemEnd(e)},0);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(e,a).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(n){db.add(`image-bitmap:${e}`,n),t&&t(n),r.manager.itemEnd(e)}).catch(function(t){i&&i(t),n_.set(o,t),db.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});db.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ImageLoader:_b,ImageUtils:Bp,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Wg,InstancedBufferGeometry:Kb,InstancedInterleavedBuffer:class extends km{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}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}},InstancedMesh:Jg,Int16BufferAttribute:class extends _m{constructor(e,t,n){super(new Int16Array(e),t,n)}},Int32BufferAttribute:class extends _m{constructor(e,t,n){super(new Int32Array(e),t,n)}},Int8BufferAttribute:class extends _m{constructor(e,t,n){super(new Int8Array(e),t,n)}},IntType:Ah,InterleavedBuffer:km,InterleavedBufferAttribute:zm,Interpolant:Zx,InterpolateBezier:Id,InterpolateDiscrete:Rd,InterpolateLinear:Cd,InterpolateSmooth:Pd,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:Gd,KeyframeTrack:nb,LOD:ag,LatheGeometry:gx,Layers:uf,LessCompare:513,LessDepth:2,LessEqualCompare:Xd,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:wb,LightProbe:Xb,Line:Fv,Line3:class{constructor(e=new Rp,t=new Rp){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){G_.subVectors(e,this.start),H_.subVectors(this.end,this.start);const n=H_.dot(H_);if(0===n)return 0;let i=H_.dot(G_)/n;return t&&(i=bp(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=q_,n=$_){const i=1e-8*1e-8;let r,s;const a=this.start,o=e.start,l=this.end,c=e.end;W_.subVectors(l,a),j_.subVectors(c,o),X_.subVectors(a,o);const u=W_.dot(W_),h=j_.dot(j_),d=j_.dot(X_);if(u<=i&&h<=i)return t.copy(a),n.copy(o),t.sub(n),t.dot(t);if(u<=i)r=0,s=d/h,s=bp(s,0,1);else{const e=W_.dot(X_);if(h<=i)s=0,r=bp(-e/u,0,1);else{const t=W_.dot(j_),n=u*h-t*t;r=0!==n?bp((t*d-e*h)/n,0,1):0,s=(t*r+d)/h,s<0?(s=0,r=bp(-e/u,0,1)):s>1&&(s=1,r=bp((t-e)/u,0,1))}}return t.copy(a).addScaledVector(W_,r),n.copy(o).addScaledVector(j_,s),t.distanceToSquared(n)}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)}},LineBasicMaterial:Rv,LineCurve:Ry,LineCurve3:Cy,LineDashedMaterial:Xx,LineLoop:Vv,LineSegments:Bv,LinearFilter:bh,LinearInterpolant:Qx,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:wh,LinearMipmapNearestFilter:_h,LinearSRGBColorSpace:zd,LinearToneMapping:1,LinearTransfer:Bd,Loader:gb,LoaderUtils:Yb,LoadingManager:fb,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:Gm,MaterialBlending:6,MaterialLoader:$b,MathUtils:Tp,Matrix2:z_,Matrix3:Ip,Matrix4:Jp,MaxEquation:104,Mesh:Ag,MeshBasicMaterial:mg,MeshDepthMaterial:Hx,MeshDistanceMaterial:Wx,MeshLambertMaterial:Gx,MeshMatcapMaterial:jx,MeshNormalMaterial:Vx,MeshPhongMaterial:zx,MeshPhysicalMaterial:Ux,MeshStandardMaterial:kx,MeshToonMaterial:Bx,MinEquation:103,MirroredRepeatWrapping:gh,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:vh,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:xh,NearestMipmapNearestFilter:yh,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:kd,NoNormalPacking:"",NoToneMapping:0,NormalAnimationBlendMode:Od,NormalBlending:1,NormalGAPacking:"ga",NormalRGPacking:"rg",NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:sb,Object3D:Ef,ObjectLoader:class extends gb{constructor(e){super(e)}load(e,t,n,i){const r=this,s=""===this.path?Yb.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const a=new xb(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){let s=null;try{s=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void hp("ObjectLoader: Can't parse "+e+".",t.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+e)),void hp("ObjectLoader: Can't load "+e);r.parse(s,t)},n,i)}async loadAsync(e,t){const n=""===this.path?Yb.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const i=new xb(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(e,t);let s;try{s=JSON.parse(r)}catch(t){throw new Error("THREE.ObjectLoader: Can't parse "+e+". "+t.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(s)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=this.parseImages(e.images,function(){void 0!==t&&t(l)}),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,n),c=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,c),this.bindLightTargets(l),void 0!==t){let e=!1;for(const t in s)if(s[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),s=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,s),o=this.parseObject(e.object,i,a,s,t),l=this.parseSkeletons(e.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}static registerGeometry(e,t){Jb[e]=t}parseShapes(e){const t={};if(void 0!==e)for(let n=0,i=e.length;n<i;n++){const i=(new Fy).fromJSON(e[n]);t[i.uuid]=i}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(e){e.isBone&&(i[e.uuid]=e)}),void 0!==e)for(let t=0,r=e.length;t<r;t++){const r=(new Hg).fromJSON(e[t],i);n[r.uuid]=r}return n}parseGeometries(e,t){const n={};if(void 0!==e){const i=new Zb;for(let r=0,s=e.length;r<s;r++){let s;const a=e[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=i.parse(a);break;case"Geometry":if("THREE"in window&&"LegacyJSONLoader"in THREE)s=(new THREE.LegacyJSONLoader).parse(a,this.resourcePath).geometry;else console.error('THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');break;default:a.type in Rx?s=Rx[a.type].fromJSON(a,t):a.type in Jb?s=Jb[a.type].fromJSON(a,t):up(`ObjectLoader: Unknown geometry type "${a.type}". Use .registerGeometry() before starting the deserialization process.`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),n[a.uuid]=s}}return n}parseMaterials(e,t){const n={},i={};if(void 0!==e){const r=new $b;r.setTextures(t);for(let t=0,s=e.length;t<s;t++){const s=e[t];void 0===n[s.uuid]&&(n[s.uuid]=r.parse(s)),i[s.uuid]=n[s.uuid]}}return i}parseAnimations(e){const t={};if(void 0!==e)for(let n=0;n<e.length;n++){const i=e[n],r=ub.parse(i);t[r.uuid]=r}return t}parseImages(e,t){const n=this,i={};let r;function s(e){if("string"==typeof e){const t=e;return function(e){return e=n.manager.resolveURL(e),n.manager.itemStart(e),r.load(e,function(){n.manager.itemEnd(e)},void 0,function(){n.manager.itemError(e),n.manager.itemEnd(e)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}return e.data?{data:np(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const n=new fb(t);r=new _b(n),r.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.url;if(Array.isArray(r)){const e=[];for(let t=0,n=r.length;t<n;t++){const n=s(r[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new Bg(n.data,n.width,n.height)))}i[n.uuid]=new Gp(e)}else{const e=s(n.url);i[n.uuid]=new Gp(e)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function r(e){if("string"==typeof e){const n=e,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await i.loadAsync(r)}return e.data?{data:np(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){i=new _b(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){const i=e[t],s=i.url;if(Array.isArray(s)){const e=[];for(let t=0,n=s.length;t<n;t++){const n=s[t],i=await r(n);null!==i&&(i instanceof HTMLImageElement?e.push(i):e.push(new Bg(i.data,i.width,i.height)))}n[i.uuid]=new Gp(e)}else{const e=await r(i.url);n[i.uuid]=new Gp(e)}}}return n}parseTextures(e,t){function n(e,t){return"number"==typeof e?e:(up("ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const i={};if(void 0!==e)for(let r=0,s=e.length;r<s;r++){const s=e[r];void 0===s.image&&up('ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&up("ObjectLoader: Undefined image",s.image);const a=t[s.image],o=a.data;let l;Array.isArray(o)?(l=new Zv,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Bg:new Xp,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=s.uuid,void 0!==s.name&&(l.name=s.name),void 0!==s.mapping&&(l.mapping=n(s.mapping,Qb)),void 0!==s.channel&&(l.channel=s.channel),void 0!==s.offset&&l.offset.fromArray(s.offset),void 0!==s.repeat&&l.repeat.fromArray(s.repeat),void 0!==s.center&&l.center.fromArray(s.center),void 0!==s.rotation&&(l.rotation=s.rotation),void 0!==s.wrap&&(l.wrapS=n(s.wrap[0],e_),l.wrapT=n(s.wrap[1],e_)),void 0!==s.format&&(l.format=s.format),void 0!==s.internalFormat&&(l.internalFormat=s.internalFormat),void 0!==s.type&&(l.type=s.type),void 0!==s.colorSpace&&(l.colorSpace=s.colorSpace),void 0!==s.minFilter&&(l.minFilter=n(s.minFilter,t_)),void 0!==s.magFilter&&(l.magFilter=n(s.magFilter,t_)),void 0!==s.anisotropy&&(l.anisotropy=s.anisotropy),void 0!==s.flipY&&(l.flipY=s.flipY),void 0!==s.generateMipmaps&&(l.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(l.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(l.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(l.compareFunction=s.compareFunction),void 0!==s.normalized&&(l.normalized=s.normalized),void 0!==s.userData&&(l.userData=s.userData),i[s.uuid]=l}return i}parseObject(e,t,n,i,r){let s,a,o;function l(e){return void 0===t[e]&&up("ObjectLoader: Undefined geometry",e),t[e]}function c(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let i=0,r=e.length;i<r;i++){const r=e[i];void 0===n[r]&&up("ObjectLoader: Undefined material",r),t.push(n[r])}return t}return void 0===n[e]&&up("ObjectLoader: Undefined material",e),n[e]}}function u(e){return void 0===i[e]&&up("ObjectLoader: Undefined texture",e),i[e]}switch(e.type){case"Scene":s=new Uf,void 0!==e.background&&(Number.isInteger(e.background)?s.background=new Nf(e.background):s.background=u(e.background)),void 0!==e.environment&&(s.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?s.fog=new kf(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(s.fog=new Ff(e.fog.color,e.fog.density)),""!==e.fog.name&&(s.fog.name=e.fog.name)),void 0!==e.backgroundBlurriness&&(s.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(s.backgroundIntensity=e.backgroundIntensity),void 0!==e.backgroundRotation&&s.backgroundRotation.fromArray(e.backgroundRotation),void 0!==e.environmentIntensity&&(s.environmentIntensity=e.environmentIntensity),void 0!==e.environmentRotation&&s.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":s=new Ob(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(s.focus=e.focus),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.filmGauge&&(s.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(s.filmOffset=e.filmOffset),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"OrthographicCamera":s=new Bb(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"AmbientLight":s=new Hb(e.color,e.intensity);break;case"DirectionalLight":s=new Gb(e.color,e.intensity),s.target=e.target||"";break;case"PointLight":s=new zb(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":s=new Wb(e.color,e.intensity,e.width,e.height);break;case"SpotLight":s=new kb(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),s.target=e.target||"";break;case"HemisphereLight":s=new Sb(e.color,e.groundColor,e.intensity);break;case"LightProbe":const t=(new jb).fromArray(e.sh);s=new Xb(t,e.intensity);break;case"SkinnedMesh":a=l(e.geometry),o=c(e.material),s=new Ug(a,o),void 0!==e.bindMode&&(s.bindMode=e.bindMode),void 0!==e.bindMatrix&&s.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(s.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),o=c(e.material),s=new Ag(a,o);break;case"InstancedMesh":a=l(e.geometry),o=c(e.material);const n=e.count,i=e.instanceMatrix,r=e.instanceColor;s=new Jg(a,o,n),s.instanceMatrix=new Wg(new Float32Array(i.array),16),void 0!==r&&(s.instanceColor=new Wg(new Float32Array(r.array),r.itemSize));break;case"BatchedMesh":a=l(e.geometry),o=c(e.material),s=new Av(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=e.perObjectFrustumCulled,s.sortObjects=e.sortObjects,s._drawRanges=e.drawRanges,s._reservedRanges=e.reservedRanges,s._geometryInfo=e.geometryInfo.map(e=>{let t=null,n=null;return void 0!==e.boundingBox&&(t=(new Qf).fromJSON(e.boundingBox)),void 0!==e.boundingSphere&&(n=(new Rm).fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:n}}),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=u(e.matricesTexture.uuid),s._indirectTexture=u(e.indirectTexture.uuid),void 0!==e.colorsTexture&&(s._colorsTexture=u(e.colorsTexture.uuid)),void 0!==e.boundingSphere&&(s.boundingSphere=(new Rm).fromJSON(e.boundingSphere)),void 0!==e.boundingBox&&(s.boundingBox=(new Qf).fromJSON(e.boundingBox));break;case"LOD":s=new ag;break;case"Line":s=new Fv(l(e.geometry),c(e.material));break;case"LineLoop":s=new Vv(l(e.geometry),c(e.material));break;case"LineSegments":s=new Bv(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":s=new qv(l(e.geometry),c(e.material));break;case"Sprite":s=new ng(c(e.material));break;case"Group":s=new Af;break;case"Bone":s=new zg;break;default:s=new Ef}if(s.uuid=e.uuid,void 0!==e.name&&(s.name=e.name),void 0!==e.matrix?(s.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==e.position&&s.position.fromArray(e.position),void 0!==e.rotation&&s.rotation.fromArray(e.rotation),void 0!==e.quaternion&&s.quaternion.fromArray(e.quaternion),void 0!==e.scale&&s.scale.fromArray(e.scale)),void 0!==e.up&&s.up.fromArray(e.up),void 0!==e.pivot&&(s.pivot=(new Rp).fromArray(e.pivot)),void 0!==e.morphTargetDictionary&&(s.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),void 0!==e.morphTargetInfluences&&(s.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.castShadow&&(s.castShadow=e.castShadow),void 0!==e.receiveShadow&&(s.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(s.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(s.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(s.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(s.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&s.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(s.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(s.visible=e.visible),void 0!==e.frustumCulled&&(s.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(s.renderOrder=e.renderOrder),void 0!==e.static&&(s.static=e.static),void 0!==e.userData&&(s.userData=e.userData),void 0!==e.layers&&(s.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)s.add(this.parseObject(a[e],t,n,i,r))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const n=t[e];s.animations.push(r[n])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(s.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const n=t[e],i=s.getObjectByProperty("uuid",n.object);void 0!==i&&s.addLevel(i,n.distance,n.hysteresis)}}return s}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse(function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){const n=t[e.skeleton];void 0===n?up("ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,i=e.getObjectByProperty("uuid",n);t.target=void 0!==i?i:new Ef}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:vx,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:Iu,OneMinusSrcColorFactor:203,OrthographicCamera:Bb,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:kw,Path:Oy,PerspectiveCamera:Ob,Plane:nv,PlaneGeometry:yx,PlaneHelper:class extends Fv{constructor(e,t=1,n=16776960){const i=n,r=new Fm;r.setAttribute("position",new Mm([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new Rv({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const s=new Fm;s.setAttribute("position",new Mm([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new Ag(s,new mg({color:i,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()}},PointLight:zb,PointLightHelper:class extends Ag{constructor(e,t,n){super(new _x(t,4,2),new mg({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:qv,PointsMaterial:Gv,PolarGridHelper:class extends Bv{constructor(e=10,t=16,n=8,i=64,r=4473924,s=8947848){r=new Nf(r),s=new Nf(s);const a=[],o=[];if(t>1)for(let n=0;n<t;n++){const i=n/t*(2*Math.PI),l=Math.sin(i)*e,c=Math.cos(i)*e;a.push(0,0,0),a.push(l,0,c);const u=1&n?r:s;o.push(u.r,u.g,u.b),o.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){const l=1&t?r:s,c=e-e/n*t;for(let e=0;e<i;e++){let t=e/i*(2*Math.PI),n=Math.sin(t)*c,r=Math.cos(t)*c;a.push(n,0,r),o.push(l.r,l.g,l.b),t=(e+1)/i*(2*Math.PI),n=Math.sin(t)*c,r=Math.cos(t)*c,a.push(n,0,r),o.push(l.r,l.g,l.b)}}const l=new Fm;l.setAttribute("position",new Mm(a,3)),l.setAttribute("color",new Mm(o,3));super(l,new Rv({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:ay,PositionalAudio:class extends y_{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,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(x_,b_,__),w_.set(0,0,1).applyQuaternion(b_);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(x_.x,e),t.positionY.linearRampToValueAtTime(x_.y,e),t.positionZ.linearRampToValueAtTime(x_.z,e),t.orientationX.linearRampToValueAtTime(w_.x,e),t.orientationY.linearRampToValueAtTime(w_.y,e),t.orientationZ.linearRampToValueAtTime(w_.z,e)}else t.setPosition(x_.x,x_.y,x_.z),t.setOrientation(w_.x,w_.y,w_.z)}},PropertyBinding:P_,PropertyMixer:S_,QuadraticBezierCurve:Py,QuadraticBezierCurve3:Iy,Quaternion:Ap,QuaternionKeyframeTrack:ob,QuaternionLinearInterpolant:ab,R11_EAC_Format:id,RED_GREEN_RGTC2_Format:Ed,RED_RGTC1_Format:Md,REVISION:vu,RG11_EAC_Format:sd,RGBADepthPacking:3201,RGBAFormat:Uh,RGBAIntegerFormat:jh,RGBA_ASTC_10x10_Format:yd,RGBA_ASTC_10x5_Format:md,RGBA_ASTC_10x6_Format:gd,RGBA_ASTC_10x8_Format:vd,RGBA_ASTC_12x10_Format:xd,RGBA_ASTC_12x12_Format:bd,RGBA_ASTC_4x4_Format:od,RGBA_ASTC_5x4_Format:ld,RGBA_ASTC_5x5_Format:cd,RGBA_ASTC_6x5_Format:ud,RGBA_ASTC_6x6_Format:hd,RGBA_ASTC_8x5_Format:dd,RGBA_ASTC_8x6_Format:pd,RGBA_ASTC_8x8_Format:fd,RGBA_BPTC_Format:_d,RGBA_ETC2_EAC_Format:nd,RGBA_PVRTC_2BPPV1_Format:Qh,RGBA_PVRTC_4BPPV1_Format:Jh,RGBA_S3TC_DXT1_Format:qh,RGBA_S3TC_DXT3_Format:$h,RGBA_S3TC_DXT5_Format:Yh,RGBDepthPacking:3202,RGBFormat:kh,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:wd,RGB_BPTC_UNSIGNED_Format:Sd,RGB_ETC1_Format:ed,RGB_ETC2_Format:td,RGB_PVRTC_2BPPV1_Format:Zh,RGB_PVRTC_4BPPV1_Format:Kh,RGB_S3TC_DXT1_Format:Xh,RGDepthPacking:3203,RGFormat:Hh,RGIntegerFormat:Wh,RawShaderMaterial:Fx,Ray:fg,Raycaster:F_,RectAreaLight:Wb,RedFormat:Vh,RedIntegerFormat:Gh,ReinhardToneMapping:2,RenderTarget:$p,RenderTarget3D:class extends $p{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Zp(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:fh,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:xx,SIGNED_R11_EAC_Format:rd,SIGNED_RED_GREEN_RGTC2_Format:Ad,SIGNED_RED_RGTC1_Format:Td,SIGNED_RG11_EAC_Format:ad,SRGBColorSpace:Ud,SRGBTransfer:Vd,Scene:Uf,ShaderChunk:vw,ShaderLib:xw,ShaderMaterial:Ox,ShadowMaterial:Cx,Shape:Fy,ShapeGeometry:bx,ShapePath:class{constructor(){this.type="ShapePath",this.color=new Nf,this.subPaths=[],this.currentPath=null,this.userData={}}moveTo(e,t){return this.currentPath=new Oy,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,s){return this.currentPath.bezierCurveTo(e,t,n,i,r,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(){function e(e,t){let n=!1;const i=t.length;for(let r=0,s=i-1;r<i;s=r++){const i=t[r],a=t[s];i.y>e.y!=a.y>e.y&&e.x<(a.x-i.x)*(e.y-i.y)/(a.y-i.y)+i.x&&(n=!n)}return n}function t(t,n){const i=n.getCenter(new Ep);if(e(i,t))return i;const r=i.y,s=[],a=t.length;for(let e=0;e<a;e++){const n=t[e],i=t[(e+1)%a];if(n.y>r!=i.y>r){const e=n.x+(r-n.y)*(i.x-n.x)/(i.y-n.y);s.push(e)}}return s.length>1&&(s.sort((e,t)=>e-t),i.x=(s[0]+s[1])/2),i}let n=this.userData.style&&this.userData.style.fillRule||"nonzero";"nonzero"!==n&&"evenodd"!==n&&(up('Fill-rule "'+n+'" is not supported, falling back to "nonzero".'),n="nonzero");const i="nonzero"===n?e=>0!==e:e=>!!(1&e),r=[];for(const e of this.subPaths){const n=e.getPoints();if(n.length<3)continue;const i=ux.area(n);if(0===i)continue;const s=new V_;for(let e=0;e<n.length;e++)s.expandByPoint(n[e]);r.push({subPath:e,points:n,boundingBox:s,interiorPoint:t(n,s),absArea:Math.abs(i),winding:i<0?-1:1,container:null,exclude:!1,role:null})}r.sort((e,t)=>t.absArea-e.absArea);for(let t=0;t<r.length;t++){const n=r[t];let s=0;for(let i=t-1;i>=0;i--){const t=r[i];if(t.boundingBox.containsBox(n.boundingBox)&&e(n.interiorPoint,t.points)){n.container=t.exclude?t.container:t,s=t.winding,n.winding+=s;break}}i(n.winding)===i(s)&&(n.exclude=!0)}for(const e of r)e.exclude||(e.role=null===e.container||"hole"===e.container.role?"outer":"hole");const s=[],a=new Map;for(const e of r){if(e.exclude||"outer"!==e.role)continue;const t=new Fy;t.curves=e.subPath.curves,s.push(t),a.set(e,t)}for(const e of r){if(e.exclude||"hole"!==e.role)continue;const t=a.get(e.container);if(!t)continue;const n=new Oy;n.curves=e.subPath.curves,t.holes.push(n)}return s}},ShapeUtils:ux,ShortType:Th,Skeleton:Hg,SkeletonHelper:class extends Bv{constructor(e){const t=Q_(e),n=new Fm,i=[],r=[];for(let e=0;e<t.length;e++){const n=t[e];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}n.setAttribute("position",new Mm(i,3)),n.setAttribute("color",new Mm(r,3));super(n,new Rv({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const s=new Nf(255),a=new Nf(65280);this.setColors(s,a)}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");J_.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(Z_.multiplyMatrices(J_,r.matrixWorld),K_.setFromMatrixPosition(Z_),i.setXYZ(n,K_.x,K_.y,K_.z),Z_.multiplyMatrices(J_,r.parent.matrixWorld),K_.setFromMatrixPosition(Z_),i.setXYZ(n+1,K_.x,K_.y,K_.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const n=this.geometry.getAttribute("color");for(let i=0;i<n.count;i+=2)n.setXYZ(i,e.r,e.g,e.b),n.setXYZ(i+1,t.r,t.g,t.b);return n.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Ug,Source:Gp,Sphere:Rm,SphereGeometry:_x,Spherical:class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=bp(this.phi,e,Math.PI-e),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(bp(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:jb,SplineCurve:Ly,SpotLight:kb,SpotLightHelper:class extends Ef{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Fm,i=[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 e=0,t=1,n=32;e<n;e++,t++){const r=e/n*Math.PI*2,s=t/n*Math.PI*2;i.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}n.setAttribute("position",new Mm(i,3));const r=new Rv({fog:!1,toneMapped:!1});this.cone=new Bv(n,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.matrixWorldNeedsUpdate=!0;const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Y_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Y_),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:ng,SpriteMaterial:Hm,SrcAlphaFactor:Pu,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Zd,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ob,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ob,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,o_.copy(e.projectionMatrix);const n=t.eyeSep/2,i=n*t.near/t.focus,r=t.near*Math.tan(vp*t.fov*.5)/t.zoom;let s,a;a_.elements[12]=-n,s_.elements[12]=n,s=-r*t.aspect+i,a=r*t.aspect+i,o_.elements[0]=2*t.near/(a-s),o_.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(o_),s=-r*t.aspect-i,a=r*t.aspect-i,o_.elements[0]=2*t.near/(a-s),o_.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(o_)}this.cameraL.matrix.copy(e.matrixWorld).multiply(a_),this.cameraL.matrixWorldNeedsUpdate=!0,this.cameraR.matrix.copy(e.matrixWorld).multiply(s_),this.cameraR.matrixWorldNeedsUpdate=!0}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:lb,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:wx,Texture:Xp,TextureLoader:class extends gb{constructor(e){super(e)}load(e,t,n,i){const r=new Xp,s=new _b(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)},n,i),r}},TextureUtils:class{static contain(e,t){return function(e,t){const n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}(e,t)}static cover(e,t){return function(e,t){const n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}(e,t)}static fill(e){return function(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}(e)}static getByteLength(e,t,n,i){return fw(e,t,n,i)}},Timer:h_,TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:Sx,TorusKnotGeometry:Mx,Triangle:Jf,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:Tx,UVMapping:lh,Uint16BufferAttribute:wm,Uint32BufferAttribute:Sm,Uint8BufferAttribute:class extends _m{constructor(e,t,n){super(new Uint8Array(e),t,n)}},Uint8ClampedBufferAttribute:class extends _m{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},Uniform:D_,UniformsGroup:class extends fp{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:N_++}),this.name="",this.usage=Zd,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return-1!==t&&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 e=0,n=t.length;e<n;e++){const n=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0;e<n.length;e++)this.uniforms.push(n[e].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:yw,UniformsUtils:Nx,UnsignedByteType:Sh,UnsignedInt101111Type:Oh,UnsignedInt248Type:Dh,UnsignedInt5999Type:Nh,UnsignedIntType:Rh,UnsignedShort4444Type:Ih,UnsignedShort5551Type:Lh,UnsignedShortType:Eh,VSMShadowMap:3,Vector2:Ep,Vector3:Rp,Vector4:qp,VectorKeyframeTrack:cb,VideoFrameTexture:class extends Yv{constructor(e,t,n,i,r,s,a,o){super({},e,t,n,i,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},VideoTexture:Yv,WebGL3DRenderTarget:class extends Yp{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Zp(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Yp{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Kp(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:Qd,WebGLCubeRenderTarget:Hw,WebGLRenderTarget:Yp,WebGLRenderer:cT,WebGLUtils:QM,WebGPUCoordinateSystem:ep,WebXRController:Cf,WireframeGeometry:Ex,WrapAroundEnding:Nd,ZeroCurvatureEnding:Ld,ZeroFactor:200,ZeroSlopeEnding:Dd,ZeroStencilOp:0,createCanvasElement:sp,error:hp,getConsoleFunction:function(){return op},log:lp,setConsoleFunction:function(e){op=e},warn:up,warnOnce:dp});const hT=["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"];const dT=new Jp,pT=new Jp,fT={x:"XYZ",y:"YXZ",z:"ZXY"};function mT(e,t,n,i,r,s){dT.copy(n),null!=r&&dT.premultiply(pT.copy(r).invert());const a=new Rp,o=new Ap,l=new Rp;let c;dT.decompose(a,o,l),ET(a,i.initialTargetPosition,s.translate??!0);const u=s.rotate??!0;if(!1===u)o.copy(i.initialTargetQuaternion),c=i.initialTargetRotation.clone();else if(Array.isArray(u)||!0===u||"string"!=typeof u&&!Array.isArray(u)&&!0===u.x&&!0===u.y&&!0===u.z)c=(new cf).setFromQuaternion(o,i.initialTargetRotation.order);else if("string"==typeof u){const e=fT[u];c=(new cf).setFromQuaternion(o,e);for(const t of e){const e=t.toLowerCase();e!==u&&(c[e]=0)}c.order=i.initialTargetRotation.order,o.setFromEuler(c)}else c=function(e,t,n){let i="",r="";for(const e of t.order)!1===n[e.toLowerCase()]?r+=e:i+=e;const s=i+r,a=(new cf).setFromQuaternion(e,s);for(const e of s){const i=e.toLowerCase();a[i]=AT(i,a[i],t[i],n)}return e.setFromEuler(a),a}(o,i.initialTargetRotation,u);return"object"==typeof s.scale&&s.scale.uniform||ET(l,i.initialTargetScale,s.scale??!0),{pointerAmount:t,position:a,quaternion:o,rotation:c,scale:l,time:e}}const gT=new nv,vT=new Rp,yT=new Rp,xT=new Rp,bT=new Ap;function _T(e,t,n){return gT.normal.copy(e),gT.constant=0,function(e,t){if(0===t.x)return void e.set(1,0,0);if(0===t.y)return void e.set(0,1,0);if(0===t.z)return void e.set(0,0,1);e.set(-t.y,t.x,0)}(vT,gT.normal),yT.copy(vT),yT.applyQuaternion(bT.copy(t).invert().premultiply(n)),gT.projectPoint(vT,vT).normalize(),gT.projectPoint(yT,yT).normalize(),(xT.crossVectors(vT,gT.normal).dot(yT)<0?1:-1)*vT.angleTo(yT)}const wT=new Rp,ST=new nv,MT=new Rp,TT=new Rp;function ET(e,t,n){if(Array.isArray(n))switch(n.length){case 0:return void e.copy(t);case 1:return e.sub(t),HT(e,n[0]instanceof Rp?n[0]:wT.fromArray(n[0])),void e.add(t);case 2:return wT.crossVectors(n[0]instanceof Rp?n[0]:MT.fromArray(n[0]),n[1]instanceof Rp?n[1]:TT.fromArray(n[1])),ST.setFromNormalAndCoplanarPoint(wT,t),void ST.projectPoint(e,e)}else e.x=AT("x",e.x,t.x,n),e.y=AT("y",e.y,t.y,n),e.z=AT("z",e.z,t.z,n)}function AT(e,t,n,i){if("boolean"==typeof i)return i?t:n;if("string"==typeof i)return i===e?t:n;const r=i[e];return!1===r?n:Array.isArray(r)?function(e,t,n){return Math.max(t,Math.min(n,e))}(t,...r):t}function RT(e=!0,t,n,i,r,s){if(e){switch(t.length){case 0:case 3:return;case 1:return void function(e,t,n,i,r){const s=null==r?0:1-Math.abs(t.dot(r));if(null==r||s<.001)return void GT(i,e,t);VT.subVectors(n,e);const a=t.dot(r),o=t.dot(VT),l=r.dot(VT),c=1-a*a,u=(o-a*l)/c;if((a*o-l)/c<0)return void GT(i,e,t);VT.copy(i),i.copy(e).addScaledVector(t,u)}(n,...t,i,r,s);case 2:return void function(e,t,n,i,r,s){BT.crossVectors(e,t).normalize(),zT.setFromNormalAndCoplanarPoint(BT,n);const a=null==s?0:Math.abs(BT.dot(s));if(null==s||a<.01)return void zT.projectPoint(r,r);const o=zT.distanceToPoint(i),l=-o/s.dot(zT.normal);if(l<0)return void zT.projectPoint(r,r);VT.copy(r),r.copy(i).addScaledVector(s,l)}(...t,n,i,r,s)}throw new Error(`space cannot be ${t.length}D but received (${t.map(e=>e.toArray().join("/")).join("; ")})`)}}const CT={x:new Rp(1,0,0),y:new Rp(0,1,0),z:new Rp(0,0,1)};function PT(e,t,n,i,r){if(!1!==i){if(!0===i)return e[0]=CT.x,e[1]=CT.y,void(e[2]=CT.z);if("string"!=typeof i)if(Array.isArray(i))for(const s of i)FT(e,t,n,s,r);else!1!==i.x&&FT(e,t,n,"x",r),!1!==i.y&&FT(e,t,n,"y",r),!1!==i.z&&FT(e,t,n,"z",r);else FT(e,t,n,i,r)}}const IT=new Ap,LT=new cf,DT=new Rp,NT=new Rp,OT=new Rp;function FT(e,t,n,i,r){if(Array.isArray(i)?DT.set(...i):i instanceof Rp?DT.copy(i):DT.copy(CT[i]),"translate"===r)return DT.applyQuaternion(t),void UT(e,DT);if("scale"===r)return Array.isArray(i)?IT.identity():IT.setFromEuler(n),IT.premultiply(t),DT.applyQuaternion(IT),void UT(e,DT);if(Array.isArray(i))LT.set(0,0,0);else{LT.copy(n);for(let e=2;e>=0;e--){const t=n.order[e].toLowerCase();if(LT[t]=0,t===i)break}}IT.setFromEuler(LT).premultiply(t),DT.normalize(),NT.set(0,1,0),DT.dot(NT)>.99&&NT.set(0,0,1),OT.crossVectors(DT,NT).normalize(),NT.copy(OT),OT.applyQuaternion(IT),UT(e,OT),OT.crossVectors(DT,NT).normalize(),OT.applyQuaternion(IT),UT(e,OT)}const kT=new Rp;function UT(e,t){3!==e.length&&(0!==e.length?1!==e.length?(kT.crossVectors(e[0],e[1]),Math.abs(kT.dot(t))<.001||e.push(t.clone())):Math.abs(e[0].dot(t))<.999&&e.push(t.clone()):e.push(t.clone()))}const zT=new nv,BT=new Rp,VT=new Rp;function GT(e,t,n){e.sub(t),HT(e,n),e.add(t)}function HT(e,t){const n=e.dot(t);e.copy(t).multiplyScalar(n)}const WT=new Jp,jT=new Jp,XT=new Rp,qT=new Rp,$T=new Ap,YT=new Rp(1,1,1),KT=[];const ZT=new Rp,JT=new Rp,QT=new Rp,eE=new Rp,tE=new Rp,nE=new Rp,iE=new Rp,rE=new Jp,sE=new Jp,aE=new Jp,oE=new Ap,lE=new Ap,cE=[];const uE=new Rp,hE=new Rp,dE=new Rp,pE=new Rp,fE=new Rp,mE=new Ap,gE=new Ap,vE=new Jp,yE=new Rp,xE=[];class bE{t1;t2;_position;_quaternion;_rotation;_scale;constructor(e,t){this.t1=e,this.t2=t}get time(){return this.t1.time-this.t2.time}get position(){return this._position??=this.t1.position.clone().sub(this.t2.position)}get quaternion(){return this._quaternion??=this.t2.quaternion.clone().invert().premultiply(this.t1.quaternion)}get rotation(){return this._rotation??=(new cf).setFromQuaternion(this.quaternion)}get scale(){return this._scale??=this.t1.scale.clone().sub(this.t2.scale)}}class _E{cancel;previous;memo;event;initial;current;first;last;_delta;_offset;constructor(e){this.cancel=e}start(e,t){this.event=e,this.previous=void 0,this.current=t,this.initial=t,this.first=!0,this.last=!1,this.memo=void 0,this._delta=void 0,this._offset=void 0}update(e,t){this.event=e,this.previous=this.current,this.current=t,this.first=!1,this.last=!1,this._delta=void 0,this._offset=void 0}end(e){this.event=e,this.first=!1,this.last=!0,this._delta=void 0,this._offset=void 0}get delta(){if(null!=this.previous)return this._delta??=new bE(this.current,this.previous)}get offset(){return this._offset??=new bE(this.current,this.initial)}}function wE(e,t){if("sphere"===e.details.type)return!1;if("lines"===e.details.type){const{line:n}=e.details;return t.copy(n.end).sub(n.start).normalize(),!0}return"screen-ray"===e.details.type?(t.copy(e.details.direction),!0):(t.set(0,0,-1).applyQuaternion(e.pointerQuaternion),!0)}const SE=new Rp;class ME{target;getOptions;outputState;latestMoveEvent;inputState=new Map;capturedObjects=new Map;initialTargetPosition=new Rp;initialTargetQuaternion=new Ap;initialTargetRotation=new cf;initialTargetScale=new Rp;initialTargetParentWorldMatrix;prevTwoPointerDeltaRotation;prevTranslateAsDeltaRotation;prevAngle;handlers={onPointerDown:this.onPointerDown.bind(this),onPointerMove:this.onPointerMove.bind(this),onPointerEnd:this.onPointerEnd.bind(this)};constructor(e,t=()=>({})){this.target=e,this.getOptions=t,this.outputState=new _E(this.cancel.bind(this))}firstOnPointer(e){const t=this.getTarget();if(null==t)return;const n=wE(e,SE)?SE.clone():void 0;e.intersection.details.type,this.inputState.set(e.pointerId,{pointerWorldDirection:n,pointerWorldPoint:e.point,pointerWorldOrigin:e.pointerPosition,pointerWorldQuaternion:e.pointerQuaternion,initialPointerWorldPoint:e.point.clone(),initialPointerWorldDirection:n?.clone(),initialPointerWorldQuaternion:e.pointerQuaternion.clone(),prevPointerWorldQuaternion:e.pointerQuaternion}),this.save(),1===this.inputState.size&&this.outputState.start(e,{pointerAmount:1,time:e.timeStamp,position:this.initialTargetPosition.clone(),quaternion:this.initialTargetQuaternion.clone(),rotation:this.initialTargetRotation.clone(),scale:this.initialTargetScale.clone()}),this.outputState.memo=this.apply(t)}onPointerDown(e){!1!==this.getOptions().filter?.(e)&&(this.stopPropagation(e),this.capturePointer(e.pointerId,e.object)&&this.firstOnPointer(e))}onPointerMove(e){if(!this.capturedObjects.has(e.pointerId))return;this.stopPropagation(e);const t=this.inputState.get(e.pointerId);null!=t?(this.latestMoveEvent=e,t.pointerWorldPoint=e.point,t.prevPointerWorldQuaternion=t.pointerWorldQuaternion,t.pointerWorldQuaternion=e.pointerQuaternion,t.pointerWorldOrigin=e.pointerPosition,null!=t.pointerWorldDirection&&wE(e,t.pointerWorldDirection)):this.firstOnPointer(e)}cancel(){if(0===this.capturedObjects.size)return;for(const[e,t]of this.capturedObjects)t.releasePointerCapture(e);this.capturedObjects.clear(),this.inputState.clear(),this.outputState.end(void 0);const e=this.getTarget();null!=e&&this.apply(e)}onPointerEnd(e){const t=this.capturedObjects.get(e.pointerId);null!=t&&(this.stopPropagation(e),this.releasePointer(e.pointerId,t,e))}update(e){const t=this.getTarget();if(null==t||0===this.inputState.size||null==this.latestMoveEvent&&!1===(this.getOptions().alwaysUpdate??!1))return;const n=this.getOptions();let i;if("as-rotate"===n.translate||"as-rotate-and-scale"===n.translate||"as-scale"===n.translate){n.translate,this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0;const[r]=this.inputState.values(),s=t.matrixWorld,a=t.parent?.matrixWorld;i=function(e,t,n,i,r,s){if(null==r?mE.identity():r.decompose(uE,mE,hE),xE.length=0,"as-scale"===s.translate&&PT(xE,mE,n.initialTargetRotation,s.scale??!0,"scale"),"as-scale"!=s.translate&&PT(xE,mE,n.initialTargetRotation,s.rotate??!0,"rotate"),vE.makeTranslation(n.initialTargetPosition),null!=n.initialTargetParentWorldMatrix&&vE.premultiply(n.initialTargetParentWorldMatrix),pE.setFromMatrixPosition(vE),RT(s.projectRays,xE,t.initialPointerWorldPoint,t.pointerWorldOrigin,pE,void 0),pE.negate().add(t.initialPointerWorldPoint),fE.setFromMatrixPosition(i),RT(s.projectRays,xE,t.initialPointerWorldPoint,t.pointerWorldOrigin,fE,void 0),RT(s.projectRays,xE,t.initialPointerWorldPoint,t.pointerWorldOrigin,hE.copy(t.pointerWorldPoint),t.pointerWorldDirection),fE.negate().add(hE),"as-scale"===s.translate?mE.copy(n.initialTargetQuaternion):(uE.copy(pE),null!=n.prevTranslateAsDeltaRotation&&uE.applyQuaternion(n.prevTranslateAsDeltaRotation),uE.normalize(),hE.copy(fE).normalize(),mE.setFromUnitVectors(uE,hE),null==n.prevTranslateAsDeltaRotation?n.prevTranslateAsDeltaRotation=new Ap:mE.multiply(n.prevTranslateAsDeltaRotation),n.prevTranslateAsDeltaRotation.copy(mE),null!=n.initialTargetParentWorldMatrix&&(gE.setFromRotationMatrix(n.initialTargetParentWorldMatrix),mE.multiply(gE.normalize()),mE.premultiply(gE.invert())),mE.multiply(n.initialTargetQuaternion)),"as-rotate"===s.translate)yE.set(1,1,1);else if("object"==typeof s.scale&&s.scale.uniform)yE.setScalar(fE.length()/pE.length());else if("as-rotate-and-scale"===s.translate){vE.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale),null!=n.initialTargetParentWorldMatrix&&vE.premultiply(n.initialTargetParentWorldMatrix),vE.decompose(hE,gE,dE),uE.copy(pE).applyQuaternion(gE.invert()).divide(dE),uE.x=Math.abs(uE.x),uE.y=Math.abs(uE.y),uE.z=Math.abs(uE.z);const e=Math.max(...uE.toArray());uE.divideScalar(e),yE.set(1,1,1),yE.addScaledVector(uE,fE.length()/pE.length()-1)}else null!=n.initialTargetParentWorldMatrix?(n.initialTargetParentWorldMatrix.decompose(uE,gE,hE),gE.multiply(n.initialTargetQuaternion)):gE.copy(n.initialTargetQuaternion),uE.copy(pE).applyQuaternion(gE.invert()),null!=r?(r.decompose(hE,gE,dE),gE.multiply(n.initialTargetQuaternion)):gE.copy(n.initialTargetQuaternion),hE.copy(fE).applyQuaternion(gE.invert()),yE.x=Math.abs(uE.x)<.001?1:Math.abs(hE.x/uE.x),yE.y=Math.abs(uE.y)<.001?1:Math.abs(hE.y/uE.y),yE.z=Math.abs(uE.z)<.001?1:Math.abs(hE.z/uE.z);return yE.multiply(n.initialTargetScale),vE.compose(n.initialTargetPosition,mE,yE),mT(e,1,vE,n,void 0,s)}(e,r,this,s,a,n)}else if(1===this.inputState.size){this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0,this.prevTranslateAsDeltaRotation=void 0;const[r]=this.inputState.values();i=function(e,t,n,i,r){return null==i?$T.identity():i.decompose(XT,$T,qT),KT.length=0,PT(KT,$T,n.initialTargetRotation,r.translate??!0,"translate"),jT.makeRotationFromQuaternion($T.copy(t.initialPointerWorldQuaternion).invert()).multiply(WT.makeTranslation(XT.copy(t.initialPointerWorldPoint).negate())),null!=n.initialTargetParentWorldMatrix&&jT.multiply(n.initialTargetParentWorldMatrix),RT(r.projectRays,KT,t.initialPointerWorldPoint,t.pointerWorldOrigin,XT.copy(t.pointerWorldPoint),t.pointerWorldDirection),$T.copy(t.pointerWorldQuaternion),!1===(r.rotate??!0)&&$T.copy(t.initialPointerWorldQuaternion),WT.compose(XT,$T,YT).multiply(jT).multiply(jT.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale)),mT(e,1,WT,n,i,r)}(e,r,this,t.parent?.matrixWorld,n)}else{this.prevTranslateAsDeltaRotation=void 0;const[r,s]=this.inputState.values();i=function(e,t,n,i,r,s){null==r?oE.identity():r.decompose(QT,oE,eE),cE.length=0,PT(cE,oE,i.initialTargetRotation,s.translate??!0,"translate"),PT(cE,oE,i.initialTargetRotation,s.rotate??!0,"rotate"),PT(cE,oE,i.initialTargetRotation,s.scale??!0,"scale"),RT(s.projectRays,cE,t.initialPointerWorldPoint,t.pointerWorldOrigin,QT.copy(t.pointerWorldPoint),t.pointerWorldDirection),RT(s.projectRays,cE,n.initialPointerWorldPoint,n.pointerWorldOrigin,eE.copy(n.pointerWorldPoint),n.pointerWorldDirection),ZT.copy(n.initialPointerWorldPoint).sub(t.initialPointerWorldPoint),JT.copy(eE).sub(QT),QT.copy(ZT),null!=i.prevTwoPointerDeltaRotation&&QT.applyQuaternion(i.prevTwoPointerDeltaRotation),QT.normalize(),eE.copy(JT).normalize(),oE.setFromUnitVectors(QT,eE),null==i.prevTwoPointerDeltaRotation?i.prevTwoPointerDeltaRotation=new Ap:oE.multiply(i.prevTwoPointerDeltaRotation),i.prevTwoPointerDeltaRotation.copy(oE);const a=.5*(_T(eE,t.prevPointerWorldQuaternion,t.pointerWorldQuaternion)+_T(eE,n.prevPointerWorldQuaternion,n.pointerWorldQuaternion))+(i.prevAngle??0);if(i.prevAngle=a,oE.premultiply(lE.setFromAxisAngle(eE,a)),aE.compose(i.initialTargetPosition,i.initialTargetQuaternion,i.initialTargetScale),null!=i.initialTargetParentWorldMatrix&&aE.premultiply(i.initialTargetParentWorldMatrix),"object"==typeof s.scale&&s.scale.uniform)iE.setScalar(JT.length()/ZT.length());else{aE.decompose(tE,lE,nE),QT.copy(ZT).applyQuaternion(lE.invert()).divide(nE),QT.x=Math.abs(QT.x),QT.y=Math.abs(QT.y),QT.z=Math.abs(QT.z);const e=Math.max(...QT.toArray());QT.divideScalar(e),iE.set(1,1,1),iE.addScaledVector(QT,JT.length()/ZT.length()-1)}return rE.makeTranslation(QT.copy(JT).multiplyScalar(.5).add(t.pointerWorldPoint)).multiply(sE.makeRotationFromQuaternion(oE)).multiply(sE.makeRotationFromQuaternion(lE.invert())).multiply(sE.makeScale(iE.x,iE.y,iE.z)).multiply(sE.makeRotationFromQuaternion(lE.invert())).multiply(sE.makeTranslation(QT.copy(ZT).multiplyScalar(.5).add(t.initialPointerWorldPoint).negate())).multiply(aE),mT(e,2,rE,i,r,s)}(e,r,s,this,t.parent?.matrixWorld,n)}this.outputState.update(this.latestMoveEvent,i),this.outputState.memo=this.apply(t),this.latestMoveEvent=void 0}getTarget(){return this.target instanceof Ef?this.target:this.target?.current}capturePointer(e,t){if(this.capturedObjects.has(e))return!1;const{multitouch:n,translate:i}=this.getOptions();return(!1!==(n??!0)&&"string"!=typeof i||1!==this.capturedObjects.size)&&(this.capturedObjects.set(e,t),t.setPointerCapture(e),!0)}releasePointer(e,t,n){const i=this.getTarget();null!=i&&this.capturedObjects.delete(e)&&(this.inputState.delete(e),t.releasePointerCapture(e),this.inputState.size>0?this.save():(this.outputState.end(n),this.apply(i)))}stopPropagation(e){null!=e&&(this.getOptions()?.stopPropagation??1)&&e.stopPropagation()}apply(e){return(this.getOptions().apply??EE)(this.outputState,e)}getState(){return 0===this.inputState.size?void 0:this.outputState}save(){const e=this.getTarget();if(null!=e){e.updateWorldMatrix(!0,!1),this.prevAngle=void 0,this.prevTwoPointerDeltaRotation=void 0,this.prevTranslateAsDeltaRotation=void 0,this.initialTargetParentWorldMatrix=e.parent?.matrixWorld.clone(),e.matrixAutoUpdate?(this.initialTargetPosition.copy(e.position),this.initialTargetQuaternion.copy(e.quaternion),this.initialTargetRotation.copy(e.rotation),this.initialTargetScale.copy(e.scale)):(e.matrix.decompose(this.initialTargetPosition,this.initialTargetQuaternion,this.initialTargetScale),this.initialTargetRotation.setFromQuaternion(this.initialTargetQuaternion,e.rotation.order));for(const e of this.inputState.values())null!=e.pointerWorldDirection&&e.initialPointerWorldDirection?.copy(e.pointerWorldDirection),e.initialPointerWorldPoint.copy(e.pointerWorldPoint),e.initialPointerWorldQuaternion.copy(e.pointerWorldQuaternion)}}bind(e){const{onPointerDown:t,onPointerMove:n,onPointerEnd:i}=this.handlers;return e.addEventListener("pointerdown",t),e.addEventListener("pointermove",n),e.addEventListener("pointercancel",i),e.addEventListener("pointerup",i),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointermove",n),e.removeEventListener("pointercancel",i),e.removeEventListener("pointerup",i),this.cancel()}}capture(e,t){return this.capturePointer(e,t)?()=>this.releasePointer(e,t,void 0):TE}}function TE(){}function EE(e,t){t.position.copy(e.current.position),t.rotation.order=e.current.rotation.order,t.quaternion.copy(e.current.quaternion),t.scale.copy(e.current.scale)}class AE{target;getOptions;handles=[];hoveredTagMap=new Map;hoverSubscriptions=[];applySubscriptions=[];space;constructor(e,t){this.target=e,this.getOptions=t}getSpace(){return this.space??"world"}getTarget(){return this.target instanceof Ef?this.target:this.target.current}getHandleOptions(e,t){const n=this.getOptions?.(),i=t?.();return{...n,...i,apply:(t,r)=>(this.onApply(e,t,r),(i?.apply??n?.apply??EE)?.(t,r))}}registerHandle(e,t,n){const i={object:t,store:e,tag:n};this.handles.push(i);const r=e.bind(t),s=this.onPointerEnter.bind(this,n),a=this.onPointerLeave.bind(this);return t.addEventListener("pointerenter",s),t.addEventListener("pointerleave",a),()=>{const t=this.handles.indexOf(i);-1!=t&&this.handles.splice(t,1),r(),e.cancel()}}subscribeHover(e){return this.hoverSubscriptions.push(e),e(Array.from(this.hoveredTagMap.values())),()=>{const t=this.hoverSubscriptions.indexOf(e);-1!==t&&this.hoverSubscriptions.splice(t,1)}}subscribeApply(e){return this.applySubscriptions.push(e),()=>{const t=this.applySubscriptions.indexOf(e);-1!==t&&this.applySubscriptions.splice(t,1)}}update(e){for(const{store:t}of this.handles)t.update(e)}onPointerEnter(e,t){this.hoveredTagMap.set(t.pointerId,e),this.updateHover()}onPointerLeave(e){this.hoveredTagMap.delete(e.pointerId),this.updateHover()}updateHover(){const e=Array.from(this.hoveredTagMap.values());for(const t of this.hoverSubscriptions)t(e)}onApply(e,t,n){for(const i of this.applySubscriptions)i(e,t,n)}}const RE={depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0};function CE(e,t,n,{color:i,hoverColor:r,hoverOpacity:s,opacity:a,disabled:o=!1}){return null==r&&null==s||o?(t.color.set(i),t.opacity=a??1,void(o&&(t.opacity*=.5,t.color.lerp(new Nf(1,1,1),.5)))):(r??=i,e.subscribeHover(e=>{const o=e.some(e=>e.includes(n));t.color.set(o?r:i),t.opacity=(o?s:a)??1}))}const PE=new Ap,IE=new Fm;IE.setAttribute("position",new Mm([-1e3,0,0,1e3,0,0],3));class LE extends Bv{context;rotationOffset;constructor(e,t){super(IE),this.context=e,this.rotationOffset=t,this.renderOrder=1/0}update(){this.quaternion.setFromEuler(this.rotationOffset);const e=this.context.getTarget();"world"===this.context.getSpace()&&null!=e&&(e.getWorldQuaternion(PE).invert(),this.quaternion.premultiply(PE))}bind(e){this.material=new Rv({...RE,color:this.material.color??"white",opacity:this.material.opacity??1});const t=this.context.subscribeHover(t=>{const n=t.some(t=>t.includes(e));this.visible=n}),n=this.context.subscribeApply((e,t)=>{if(t.last)return void this.position.set(0,0,0);this.position.copy(t.initial.position).sub(t.current.position);const n=this.context.getTarget();null!=n&&(PE.copy(n.quaternion).invert(),this.position.applyQuaternion(PE))});return()=>{this.material.dispose(),t(),n()}}}class DE extends Af{context;axis;store;options;tag;constructor(e,t,n,i){super(),this.context=e,this.axis=t,this.tag=(n??"")+t,this.store=new ME(e.target,()=>e.getHandleOptions(this.tag,i))}}function NE(e,t=!0){if(!1===t)return{options:!1,disabled:!0};if(!0===t){const t={x:!1,y:!1,z:!1,e:!1};for(const n of e)t[n]=!0;return{options:t,disabled:!1}}if("disabled"===t)return{options:{x:!0,y:!0,z:!0,e:!0},disabled:!0};if("string"==typeof t)return{options:t===e&&{x:!1,y:!1,z:!1,e:!1,[e]:!0},disabled:!1};const n={x:!1,y:!1,z:!1,e:!1};let i=!1;for(const r of e){let e=t[r]??!0;if(!1===e)return{options:!1,disabled:!0};"disabled"===e&&(i=!0,e=!0),n[r]=e}return{options:n,disabled:i}}const OE=new Rp,FE=new Rp;function kE(e,t,n,i){if(!n)return i;let r;return t instanceof Bb?r=(t.top-t.bottom)/t.zoom:(t.getWorldPosition(OE),e.getWorldPosition(FE),r=OE.distanceTo(FE)*Math.min(1.9*Math.tan(Math.PI*t.fov/360)/t.zoom,7)),r*i/4}const UE=new ry(0,.04,.1,12);UE.translate(0,.05,0);const zE=new ry(.0075,.0075,.5,3);zE.translate(0,.25,0);const BE=new cf(0,0,-Math.PI/2),VE=new cf(0,0,Math.PI/2);class GE extends DE{invert;showArrowBody;constructor(e,t,n="",i,r=!1,s=!0){super(e,t,n,()=>({scale:!1,rotate:!1,translate:null!=i?[i]:this.options,multitouch:!1})),this.invert=r,this.showArrowBody=s}bind(e,t,n){const{options:i,disabled:r}=NE(this.axis,n);if(!1===i)return;this.options=i;const s=this.invert?VE:BE,a=new mg(RE),o=CE(this.context,a,this.tag,{color:e,hoverColor:t,disabled:r}),l=new Ag(UE,a);let c,u;if(l.renderOrder=1/0,l.position.x=this.invert?-.5:.5,l.rotation.copy(s),this.add(l),this.showArrowBody){const t=new mg(RE);c=CE(this.context,t,this.tag,{color:e,hoverColor:16777024,disabled:r}),u=new Ag(zE,t),u.renderOrder=1/0,u.rotation.copy(s),this.add(u)}const h=new Ag(new ry(.13,0,.6,4));h.pointerEventsOrder=1/0,h.position.x=this.invert?-.3:.3,h.rotation.copy(s),h.visible=!1,this.add(h);const d=r?void 0:this.context.registerHandle(this.store,h,this.tag);return()=>{a.dispose(),d?.(),o?.(),c?.(),this.remove(l),null!=u&&this.remove(u),this.remove(h)}}}class HE extends DE{constructor(e,t,n="",i){super(e,t,n,()=>({translate:i??this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=NE(this.axis,n);if(!1===i)return;this.options=i;const s=new mg(RE),a=CE(this.context,s,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new Ag(new ty(.2,.2,.01),s);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{s.dispose(),o.geometry.dispose(),l?.(),a?.(),this.remove(o)}}}const WE=new Ap;class jE extends DE{constructor(e){super(e,"xyz","",()=>({translate:this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e){const{options:t,disabled:n}=NE(this.axis,e);if(!1===t)return;this.options=t;const i=new mg(RE),r=CE(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,hoverOpacity:1,disabled:n}),s=new Ag(new vx(.1,0),i);s.renderOrder=1/0,this.add(s);const a=new Ag(new vx(.2,0));a.pointerEventsOrder=1/0,a.visible=!1,this.add(a);const o=n?void 0:this.context.registerHandle(this.store,a,this.tag);return()=>{i.dispose(),s.geometry.dispose(),a.geometry.dispose(),o?.(),r?.(),this.remove(s),this.remove(a)}}}const XE=new Rp,qE=new Ap,$E=new Ap,YE=(new Ap).setFromEuler(new cf(0,0,Math.PI/2)),KE=(new Ap).setFromEuler(new cf(0,-Math.PI/2,0)),ZE=new Ap,JE=(new Ap).setFromEuler(new cf(0,-Math.PI/2,0)),QE=(new Ap).setFromEuler(new cf(Math.PI/2,0,0));class eA extends Af{context;size;fixed;free;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;scaleGroup=new Af;xAxis=new Rp;yAxis=new Rp;zAxis=new Rp;negXAxis=new Rp;negYAxis=new Rp;negZAxis=new Rp;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.add(this.scaleGroup),this.free=new jE(this.context),this.scaleGroup.add(this.free),this.translationX=new GE(this.context,"x",void 0,this.xAxis),this.scaleGroup.add(this.translationX),this.translationY=new GE(this.context,"y",void 0,this.yAxis),this.scaleGroup.add(this.translationY),this.translationZ=new GE(this.context,"z",void 0,this.zAxis),this.scaleGroup.add(this.translationZ),this.translationNegX=new GE(this.context,"x",void 0,this.negXAxis,!0,!1),this.scaleGroup.add(this.translationNegX),this.translationNegY=new GE(this.context,"y",void 0,this.negYAxis,!0,!1),this.scaleGroup.add(this.translationNegY),this.translationNegZ=new GE(this.context,"z",void 0,this.negZAxis,!0,!1),this.scaleGroup.add(this.translationNegZ),this.translationXY=new HE(this.context,"xy",void 0,[this.xAxis,this.yAxis]),this.scaleGroup.add(this.translationXY),this.translationXZ=new HE(this.context,"xz",void 0,[this.xAxis,this.zAxis]),this.scaleGroup.add(this.translationXZ),this.translationYZ=new HE(this.context,"yz",void 0,[this.yAxis,this.zAxis]),this.scaleGroup.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.xAxis.set(1,0,0),this.yAxis.set(0,1,0),this.zAxis.set(0,0,1),this.free.quaternion.identity(),this.translationX.quaternion.copy($E),this.translationY.quaternion.copy(YE),this.translationZ.quaternion.copy(KE),this.translationNegX.quaternion.copy($E),this.translationNegY.quaternion.copy(YE),this.translationNegZ.quaternion.copy(KE),this.translationXY.quaternion.copy(ZE),this.translationYZ.quaternion.copy(JE),this.translationXZ.quaternion.copy(QE);const t=this.context.getSpace(),n=this.context.getTarget();"world"==t&&null!=n?(n.getWorldQuaternion(qE).invert(),this.free.quaternion.premultiply(qE),this.translationX.quaternion.premultiply(qE),this.translationY.quaternion.premultiply(qE),this.translationZ.quaternion.premultiply(qE),this.translationNegX.quaternion.premultiply(qE),this.translationNegY.quaternion.premultiply(qE),this.translationNegZ.quaternion.premultiply(qE),this.translationXY.quaternion.premultiply(qE),this.translationYZ.quaternion.premultiply(qE),this.translationXZ.quaternion.premultiply(qE),null!=n.parent&&(n.parent.getWorldQuaternion(qE).invert(),this.xAxis.applyQuaternion(qE),this.yAxis.applyQuaternion(qE),this.zAxis.applyQuaternion(qE))):null!=n&&(this.xAxis.applyQuaternion(n.quaternion),this.yAxis.applyQuaternion(n.quaternion),this.zAxis.applyQuaternion(n.quaternion)),this.negXAxis.copy(this.xAxis).negate(),this.negYAxis.copy(this.yAxis).negate(),this.negZAxis.copy(this.zAxis).negate(),this.scaleGroup.scale.setScalar(1),null!=n&&(n.getWorldScale(XE),this.scaleGroup.scale.divide(XE)),this.scaleGroup.scale.multiplyScalar(kE(this,e,this.fixed??!0,this.size??1))}bind(e){const t=function(e,t){const n=new Ag(new vx(.01,2),new mg(RE));n.renderOrder=1/0,n.visible=!1,e.add(n);const i=new Ag(new vx(.01,2),new mg(RE));i.renderOrder=1/0,i.visible=!1,e.add(i);const r=new Fm;r.setAttribute("position",new Mm([0,0,0,1,1,1],3));const s=new Bv(r,new Rv(RE));s.renderOrder=1/0,s.visible=!1,e.add(s);const a=t.subscribeApply((e,r)=>{i.position.set(0,0,0),n.position.copy(r.initial.position).sub(r.current.position);const a=t.getTarget();null!=a&&(WE.copy(a.quaternion).invert(),n.position.applyQuaternion(WE)),s.position.set(0,0,0),s.scale.copy(n.position),n.visible=!r.last,s.visible=!r.last,i.visible=!r.last});return()=>{n.geometry.dispose(),n.material.dispose(),i.geometry.dispose(),i.material.dispose(),s.geometry.dispose(),s.material.dispose(),e.remove(n),e.remove(i),e.remove(s),a()}}(this,this.context),n=this.translationX.bind(16711680,16776960,e),i=this.translationY.bind(65280,16776960,e),r=this.translationZ.bind(255,16776960,e),s=this.translationNegX.bind(16711680,16776960,e),a=this.translationNegY.bind(65280,16776960,e),o=this.translationNegZ.bind(255,16776960,e),l=this.translationXY.bind(255,16776960,e),c=this.translationYZ.bind(16711680,16776960,e),u=this.translationXZ.bind(65280,16776960,e),h=this.free.bind(e);return()=>{t(),n?.(),i?.(),r?.(),s?.(),a?.(),o?.(),l?.(),c?.(),u?.(),h?.()}}}const tA=new cf(0,0,-Math.PI/2),nA=new cf(0,0,Math.PI/2);class iA extends DE{invert;showHandleLine;constructor(e,t,n="",i=!1,r=!0){super(e,t,n,()=>({scale:this.options,rotate:!1,translate:"as-scale",multitouch:!1})),this.invert=i,this.showHandleLine=r}bind(e,t,n){const{options:i,disabled:r}=NE(this.axis,n);if(!1===i)return;this.options=i;const s=this.invert?nA:tA,a=new Af;a.position.x=this.invert?-.5:.5,a.rotation.copy(s),this.add(a);const o=new mg(RE),l=CE(this.context,o,this.tag,{color:e,hoverColor:t,disabled:r}),c=new Ag(new ty(.08,.08,.08),o);let u,h,d;if(c.renderOrder=1/0,c.rotation.copy(s),a.add(c),this.showHandleLine){d=new Af,d.rotation.copy(s),this.add(d);const n=new mg(RE);u=CE(this.context,n,this.tag,{color:e,hoverColor:t,disabled:r}),h=new Ag(new ry(.0075,.0075,.5,3),n),h.renderOrder=1/0,h.position.y=.25,d.add(h)}const p=new Af;p.visible=!1,p.rotation.copy(s),p.position.x=this.invert?-.3:.3,this.add(p);const f=new Ag(new ry(.2,0,.5,4));f.pointerEventsOrder=1/0,f.position.y=.04,p.add(f);const m=r?void 0:this.context.registerHandle(this.store,f,this.tag);return()=>{o.dispose(),f.geometry.dispose(),c.geometry.dispose(),h?.geometry.dispose(),m?.(),l?.(),u?.(),null!=d&&this.remove(d),this.remove(p),this.remove(a)}}}class rA extends DE{constructor(e,t,n=""){super(e,t,n,()=>({translate:"as-scale",scale:this.options,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=NE(this.axis,n);if(!1===i)return;this.options=i;const s=new mg(RE),a=CE(this.context,s,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new Ag(new ty(.2,.2,.01),s);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{s.dispose(),o.geometry.dispose(),l?.(),a?.(),this.remove(o)}}}const sA=new cf(0,0,-Math.PI/2),aA=new cf(0,0,Math.PI/2);class oA extends DE{actualAxis;invert;constructor(e,t="",n,i=!1){super(e,"xyz",t,()=>({scale:{uniform:!0,...this.options},rotate:!1,translate:"as-scale",multitouch:!1})),this.actualAxis=n,this.invert=i}bind(e,t,n){const{options:i,disabled:r}=NE(this.actualAxis,n);if(!1===i)return;this.options=i;const s=this.invert?aA:sA,a=new Af;a.position.x=this.invert?-.7:.7,a.rotation.copy(s),this.add(a);const o=new mg(RE),l=CE(this.context,o,this.tag,{color:e,hoverColor:t,opacity:.5,hoverOpacity:1,disabled:r}),c=new Ag(new ty(.08,.08,.08),o);c.renderOrder=1/0,c.rotation.copy(s),a.add(c);const u=new Ag(new ty(.15,.15,.15),o);u.visible=!1,u.pointerEventsOrder=1/0,u.rotation.copy(s),a.add(u);const h=r?void 0:this.context.registerHandle(this.store,u,this.tag);return()=>{o.dispose(),c.geometry.dispose(),h?.(),l?.(),this.remove(a)}}}const lA=new Rp;class cA extends Af{context;size;fixed;scaleX;scaleY;scaleZ;scaleNegX;scaleNegY;scaleNegZ;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.scaleX=new oA(this.context,void 0,"x"),this.add(this.scaleX),this.scaleY=new oA(this.context,void 0,"y"),this.scaleY.rotation.z=Math.PI/2,this.add(this.scaleY),this.scaleZ=new oA(this.context,void 0,"z"),this.scaleZ.rotation.y=-Math.PI/2,this.add(this.scaleZ),this.scaleNegX=new oA(this.context,void 0,"x",!0),this.add(this.scaleNegX),this.scaleNegY=new oA(this.context,void 0,"y",!0),this.scaleNegY.rotation.z=Math.PI/2,this.add(this.scaleNegY),this.scaleNegZ=new oA(this.context,void 0,"z",!0),this.scaleNegZ.rotation.y=-Math.PI/2,this.add(this.scaleNegZ),this.translationX=new iA(this.context,"x"),this.add(this.translationX),this.translationY=new iA(this.context,"y"),this.translationY.rotation.z=Math.PI/2,this.add(this.translationY),this.translationZ=new iA(this.context,"z"),this.translationZ.rotation.y=-Math.PI/2,this.add(this.translationZ),this.translationNegX=new iA(this.context,"x",void 0,!0,!1),this.add(this.translationNegX),this.translationNegY=new iA(this.context,"y",void 0,!0,!1),this.translationNegY.rotation.z=Math.PI/2,this.add(this.translationNegY),this.translationNegZ=new iA(this.context,"z",void 0,!0,!1),this.translationNegZ.rotation.y=-Math.PI/2,this.add(this.translationNegZ),this.translationXY=new rA(this.context,"xy"),this.add(this.translationXY),this.translationXZ=new rA(this.context,"xz"),this.translationXZ.rotation.x=Math.PI/2,this.add(this.translationXZ),this.translationYZ=new rA(this.context,"yz"),this.translationYZ.rotation.y=-Math.PI/2,this.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(lA),this.scale.divide(lA)),this.scale.multiplyScalar(kE(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.scaleX.bind(16777215,16776960,e),n=this.scaleY.bind(16777215,16776960,e),i=this.scaleZ.bind(16777215,16776960,e),r=this.scaleNegX.bind(16777215,16776960,e),s=this.scaleNegY.bind(16777215,16776960,e),a=this.scaleNegZ.bind(16777215,16776960,e),o=this.translationX.bind(16711680,16776960,e),l=this.translationY.bind(65280,16776960,e),c=this.translationZ.bind(255,16776960,e),u=this.translationNegX.bind(16711680,16776960,e),h=this.translationNegY.bind(65280,16776960,e),d=this.translationNegZ.bind(255,16776960,e),p=this.translationXY.bind(255,16776960,e),f=this.translationYZ.bind(16711680,16776960,e),m=this.translationXZ.bind(65280,16776960,e);return()=>{o?.(),l?.(),c?.(),u?.(),h?.(),d?.(),p?.(),f?.(),m?.(),t?.(),n?.(),i?.(),r?.(),s?.(),a?.()}}}const uA={x:{vector1:new Rp(0,0,-1),vector2:new Rp(0,-1,0),rotationOffset:new Ap,axis:[1,0,0]},y:{vector1:new Rp(0,0,-1),vector2:new Rp(-1,0,-1),rotationOffset:(new Ap).setFromEuler(new cf(0,0,Math.PI/2)),axis:[0,1,0]},z:{vector1:new Rp(-1,0,0),vector2:new Rp(0,-1,0),rotationOffset:(new Ap).setFromEuler(new cf(0,Math.PI/2,0)),axis:[0,0,1]}},hA=new Rp,dA=new Rp,pA=new Rp,fA=new Rp,mA=new Ap;class gA extends DE{direction=new Rp(1,0,0);constructor(e,t,n=""){super(e,t,n,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){const{rotationOffset:t,vector1:n,vector2:i}=uA[this.axis];e.getWorldPosition(hA),this.getWorldPosition(dA).sub(hA),pA.copy(n),fA.copy(i);const r=this.context.getTarget(),s=this.context.getSpace();"local"===s&&null!=r&&(r.getWorldQuaternion(mA),pA.applyQuaternion(mA),fA.applyQuaternion(mA)),fA.crossVectors(pA,fA);const a=dA.dot(fA);fA.multiplyScalar(a),dA.sub(fA),this.quaternion.setFromUnitVectors(pA,dA.normalize()),"local"===s&&null!=r&&(r.getWorldQuaternion(mA),this.quaternion.multiply(mA)),this.quaternion.multiply(t),null!=r?.parent?(r.parent.matrixWorld.decompose(hA,mA,dA),mA.invert(),this.quaternion.premultiply(mA)):mA.identity(),null==this.store.getState()&&(this.direction.fromArray(uA[this.axis].axis),this.direction.applyQuaternion("local"===s&&null!=r?r?.quaternion:mA)),null!=r&&this.quaternion.premultiply(mA.copy(r.quaternion).invert())}bind(e,t){const{options:n,disabled:i}=NE(this.axis,t);if(!1===n)return;this.options=n;const r=new mg(RE),s=CE(this.context,r,this.tag,{color:e,hoverColor:16776960,disabled:i}),a=new Ag(AA(.5,.5),r);a.renderOrder=1/0,this.add(a);const o=new Ag(new Sx(.5,.1,4,24));o.visible=!1,o.pointerEventsOrder=1/0,o.rotation.set(0,-Math.PI/2,-Math.PI/2),this.add(o);const l=i?void 0:this.context.registerHandle(this.store,o,this.tag);return()=>{r.dispose(),o.geometry.dispose(),a.geometry.dispose(),l?.(),s?.(),this.remove(o),this.remove(a)}}}const vA=new Rp,yA=new Rp,xA=new Rp(1,0,0),bA=new Ap;class _A extends DE{constructor(e,t=""){super(e,"xyz",t,()=>({scale:!1,translate:"as-rotate",rotate:this.options,multitouch:!1}))}update(e){e.getWorldPosition(vA),this.getWorldPosition(yA).sub(vA),this.quaternion.setFromUnitVectors(xA,yA.normalize());const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(vA,bA,yA),bA.invert(),this.quaternion.premultiply(bA)),null!=t&&(bA.copy(t.quaternion).invert(),this.quaternion.premultiply(bA))}bind(e){const{options:t,disabled:n}=NE(this.axis,e);if(!1===t)return;this.options=t;const i=new mg(RE),r=CE(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,disabled:n}),s=new Ag(AA(.5,1),i);s.renderOrder=1/0,this.add(s);const a=new Ag(new _x(.25,10,8));a.visible=!1,a.pointerEventsOrder=1/0,this.add(a);const o=n?void 0:this.context.registerHandle(this.store,a,this.tag);return()=>{this.pointerEvents="none",i.dispose(),a.geometry.dispose(),s.geometry.dispose(),o?.(),r?.(),this.remove(a),this.remove(s)}}}const wA=new Rp,SA=new Rp,MA=new Rp(1,0,0),TA=new Ap;class EA extends DE{direction=new Rp(1,0,0);constructor(e,t=""){super(e,"e",t,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){e.getWorldPosition(wA),this.getWorldPosition(this.direction).sub(wA).normalize(),this.quaternion.setFromUnitVectors(MA,this.direction);const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(wA,TA,SA),TA.invert(),this.quaternion.premultiply(TA),this.direction.applyQuaternion(TA)),null!=t&&(TA.copy(t.quaternion).invert(),this.quaternion.premultiply(TA)),this.direction.negate()}bind(e){const{options:t,disabled:n}=NE(this.axis,e);if(!1===t)return;this.options=t;const i=new mg(RE),r=CE(this.context,i,this.tag,{color:16776960,hoverColor:16776960,opacity:.5,disabled:n}),s=new Ag(AA(.75,1),i);s.renderOrder=1/0,this.add(s);const a=new Ag(new Sx(.75,.1,2,24),new mg({color:"white"}));a.visible=!1,a.rotation.y=Math.PI/2,a.pointerEventsOrder=1/0,this.add(a);const o=n?void 0:this.context.registerHandle(this.store,a,this.tag);return()=>{i.dispose(),a.geometry.dispose(),s.geometry.dispose(),o?.(),r?.(),this.remove(a),this.remove(s)}}}function AA(e,t){const n=new Sx(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}const RA=new Rp;class CA extends Af{context;fixed;size;rotationX;rotationY;rotationZ;free;screen;constructor(e,t,n){super(),this.context=e,this.fixed=t,this.size=n,this.rotationX=new gA(this.context,"x"),this.add(this.rotationX),this.rotationY=new gA(this.context,"y"),this.add(this.rotationY),this.rotationZ=new gA(this.context,"z"),this.add(this.rotationZ),this.free=new _A(this.context),this.add(this.free),this.screen=new EA(this.context),this.add(this.screen)}update(e){this.updateWorldMatrix(!0,!1),this.rotationX.update(e),this.rotationY.update(e),this.rotationZ.update(e),this.free.update(e),this.screen.update(e),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(RA),this.scale.divide(RA)),this.scale.multiplyScalar(kE(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.rotationX.bind(16711680,e),n=this.rotationY.bind(65280,e),i=this.rotationZ.bind(255,e),r=this.screen.bind(e),s=this.free.bind(e);return()=>{t?.(),n?.(),i?.(),r?.(),s?.()}}}const PA=new cf,IA=new cf(0,0,Math.PI/2),LA=new cf(0,-Math.PI/2,0);class DA extends Af{xAxisHighlight;yAxisHighlight;zAxisHighlight;handles;context;constructor(e){super(),this.context=new AE(this,e),this.xAxisHighlight=new LE(this.context,PA),this.add(this.xAxisHighlight),this.yAxisHighlight=new LE(this.context,IA),this.add(this.yAxisHighlight),this.zAxisHighlight=new LE(this.context,LA),this.add(this.zAxisHighlight)}set space(e){this.context.space=e}get space(){return this.context.space}update(e,t){this.context.update(e),this.xAxisHighlight.update(),this.yAxisHighlight.update(),this.zAxisHighlight.update(),this.handles?.update(t)}bind(e,t){const n=this.xAxisHighlight.bind("x"),i=this.yAxisHighlight.bind("y"),r=this.zAxisHighlight.bind("z");switch(e){case"rotate":this.handles=new CA(this.context);break;case"scale":this.handles=new cA(this.context);break;case"translate":this.handles=new eA(this.context)}this.add(this.handles);const s=this.handles.bind(t);return()=>{null!=this.handles&&this.remove(this.handles),this.handles=void 0,s(),n(),i(),r()}}}new cf;class NA{nativeEvent;NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;relatedTarget=null;get altKey(){return this.getFromNative("altKey",!1)}get button(){return this.getFromNative("button",0)}get buttons(){return this.getFromNative("buttons",0)}get clientX(){return this.getFromNative("clientX",0)}get clientY(){return this.getFromNative("clientY",0)}get ctrlKey(){return this.getFromNative("ctrlKey",!1)}get layerX(){return this.getFromNative("layerX",0)}get layerY(){return this.getFromNative("layerY",0)}get metaKey(){return this.getFromNative("metaKey",!1)}get movementX(){return this.getFromNative("movementX",0)}get movementY(){return this.getFromNative("movementY",0)}get offsetX(){return this.getFromNative("offsetX",0)}get offsetY(){return this.getFromNative("offsetY",0)}get pageX(){return this.getFromNative("pageX",0)}get pageY(){return this.getFromNative("pageY",0)}get screenX(){return this.getFromNative("screenX",0)}get screenY(){return this.getFromNative("screenY",0)}get shiftKey(){return this.getFromNative("shiftKey",!1)}get x(){return this.getFromNative("x",0)}get y(){return this.getFromNative("y",0)}get detail(){return this.getFromNative("detail",0)}get view(){return this.getFromNative("view",null)}get which(){return this.getFromNative("which",0)}get cancelBubble(){return this.getFromNative("cancelBubble",!1)}get composed(){return this.getFromNative("composed",!1)}get eventPhase(){return this.getFromNative("eventPhase",0)}get isTrusted(){return this.getFromNative("isTrusted",!1)}get returnValue(){return this.getFromNative("returnValue",!1)}get timeStamp(){return this.getFromNative("timeStamp",0)}get cancelable(){return this.getFromNative("cancelable",!1)}get defaultPrevented(){return this.getFromNative("defaultPrevented",!1)}constructor(e){this.nativeEvent=e}getFromNative(e,t){return e in this.nativeEvent?this.nativeEvent[e]:t}}const OA=new Rp;class FA extends NA{type;bubbles;internalPointer;intersection;camera;currentObject;object;propagationState;get pointerId(){return this.internalPointer.id}get pointerType(){return this.internalPointer.type}get pointerState(){return this.internalPointer.state}get distance(){return this.intersection.distance}get distanceToRay(){return this.intersection.distanceToRay}get point(){return this.intersection.point}get index(){return this.intersection.index}get face(){return this.intersection.face}get faceIndex(){return this.intersection.faceIndex}get uv(){return this.intersection.uv}get uv1(){return this.intersection.uv1}get normal(){return this.intersection.normal}get instanceId(){return this.intersection.instanceId}get pointOnLine(){return this.intersection.pointOnLine}get batchId(){return this.intersection.batchId}get pointerPosition(){return this.intersection.pointerPosition}get pointerQuaternion(){return this.intersection.pointerQuaternion}get pointOnFace(){return this.intersection.pointOnFace}get localPoint(){return this.intersection.localPoint}get details(){return this.intersection.details}get target(){return this.object}get currentTarget(){return this.currentObject}get eventObject(){return this.currentObject}get srcElement(){return this.currentObject}_pointer;get pointer(){return null==this._pointer&&(OA.copy(this.intersection.point).project(this.camera),this._pointer=new Ep(OA.x,OA.y)),this._pointer}_ray;get ray(){if(null!=this._ray)return this._ray;switch(this.intersection.details.type){case"screen-ray":case"ray":case"sphere":return this._ray=new fg(this.intersection.pointerPosition,new Rp(0,0,-1).applyQuaternion(this.intersection.pointerQuaternion));case"lines":return this._ray=new fg(this.intersection.details.line.start,this.intersection.details.line.end.clone().sub(this.intersection.details.line.start).normalize())}}_intersections=[];get intersections(){return null==this._intersections&&(this._intersections=[{...this.intersection,eventObject:this.currentObject}]),this._intersections}_unprojectedPoint;get unprojectedPoint(){if(null==this._unprojectedPoint){const e=this.pointer;this._unprojectedPoint=new Rp(e.x,e.y,0).unproject(this.camera)}return this._unprojectedPoint}get stopped(){return this.propagationState.stoppedImmediate||this.propagationState.stopped}get stoppedImmediate(){return this.propagationState.stoppedImmediate}get delta(){throw new Error("not supported")}constructor(e,t,n,i,r,s,a=r.object,o=a,l={stopped:!t,stoppedImmediate:!1}){super(n),this.type=e,this.bubbles=t,this.internalPointer=i,this.intersection=r,this.camera=s,this.currentObject=a,this.object=o,this.propagationState=l}stopPropagation(){this.propagationState.stopped=!0}stopImmediatePropagation(){this.propagationState.stoppedImmediate=!0}retarget(e){return new FA(this.type,this.bubbles,this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target,this.propagationState)}}class kA extends FA{get deltaX(){return this.nativeEvent.deltaX}get deltaY(){return this.nativeEvent.deltaY}get deltaZ(){return this.nativeEvent.deltaZ}constructor(e,t,n,i,r,s){super("wheel",!0,e,t,n,i,r,s)}retarget(e){return new kA(this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target)}}function UA(e){zA(e,e.currentObject)}function zA(e,t){if(null==t)return;const n=function(e,t){if(null!=e._listeners&&t in e._listeners)return e._listeners[t];let n;e.isVoidObject&&"click"===t&&null!=e.parent?.__r3f&&(n=e.parent.__r3f.root.getState().onPointerMissed);null!=e.__r3f&&(n=e.__r3f.handlers[BA[t]]);if(null==n)return;return[n]}(t,e.type);if(null!=n&&n.length>0){const i=e.retarget(t),r=n.length;for(let e=0;e<r&&!i.stoppedImmediate;e++)n[e](i)}e.stopped||zA(e,t.parent)}const BA={click:"onClick",contextmenu:"onContextMenu",dblclick:"onDoubleClick",pointercancel:"onPointerCancel",pointerdown:"onPointerDown",pointerenter:"onPointerEnter",pointerleave:"onPointerLeave",pointermove:"onPointerMove",pointerout:"onPointerOut",pointerover:"onPointerOver",pointerup:"onPointerUp",wheel:"onWheel"},VA=Object.keys(BA);const GA=new _x(1e10),HA=new Map;function WA(e){let t=HA.get(e);return null==t&&(t=new Ag(GA),t.isVoidObject=!0,t.parent=e,t.pointerEventsOrder=-1/0,HA.set(e,t)),t}function jA(e,t){return t?!e:e}function XA(e,t,n,i=!1,r,s,a){const o=i||function(e,t){if(t.ancestorsHaveListeners)return!0;if("pointer"===e&&t.ancestorsHavePointerListeners)return!0;if("wheel"===e&&t.ancestorsHaveWheelListeners)return!0;if(null!=t.__r3f&&t.__r3f?.eventCount>0){if("wheel"===e&&null!=t.__r3f.handlers.onWheel)return!0;if("pointer"===e&&Object.keys(t.__r3f.handlers).some(e=>"onWheel"!=e))return!0}if(null==t._listeners)return!1;if("wheel"===e){const e=t._listeners.wheel;return null!=e&&e.length>0}const n=Object.entries(t._listeners),i=n.length;for(let e=0;e<i;e++){const t=n[e];if("wheel"!==t[0]&&(VA.includes(t[0])&&null!=t[1]&&t[1].length>0))return!0}return!1}(e,t),l=t.pointerEvents??r,c=l??t.defaultPointerEvents??"listener",u=t.pointerEventsType??s??"all",h=t.pointerEventsOrder??a??0,d=function(e,t,n){if("none"===t)return!1;if("listener"===t&&!e)return!1;if("all"===n)return!0;if("function"==typeof n)return({id:e,type:t,state:i})=>n(e,t,i);let i,r;return"deny"in n?(r=!0,i=n.deny):(r=!1,i=n.allow),Array.isArray(i)?e=>jA(i.includes(e.type),r):e=>jA(i===e.type,r)}(o,c,u),p=n.length;if(1===p)(!0===d||"function"==typeof d&&d(n[0]))&&qA(n[0],t,c,u,h);else if(!0===d)for(let e=0;e<p;e++)qA(n[e],t,c,u,h);else if("function"==typeof d)for(let e=0;e<p;e++){const i=n[e];d(i)&&qA(i,t,c,u,h)}if(0===t.children.length||!1===t.intersectChildren)return;const f=t.interactableDescendants??t.children,m=f.length;for(let t=0;t<m;t++)XA(e,f[t],n,o,l,u,h)}function qA({intersector:e,options:t},n,i,r,s){!1!==t.filter?.(n,i,r,s)&&e.executeIntersection(n,s)}function $A(e,t=0,n,i=0){return t!=i?i-t:e.distance-n.distance}const YA=1e7;const KA=Symbol("buttonsDownTime"),ZA=Symbol("buttonsClickTime");function JA(e){return globalThis.pointerEventspointerMap?.get(e)}globalThis.pointerEventspointerMap??=new Map,Ef.prototype.setPointerCapture=function(e){JA(e)?.setCapture(this)},Ef.prototype.releasePointerCapture=function(e){const t=JA(e);null!=t&&t.hasCaptured(this)&&t.setCapture(void 0)},Ef.prototype.hasPointerCapture=function(e){return JA(e)?.hasCaptured(this)??!1};class QA{id;type;state;intersector;getCamera;onMoveCommited;parentSetPointerCapture;parentReleasePointerCapture;options;prevIntersection;intersection;prevEnabled=!0;enabled=!0;wheelIntersection;pointerEntered=[];pointerEnteredHelper=[];pointerCapture;buttonsDownTime=new Map;buttonsDown=new Set;wasMoved=!1;onFirstMove=[];constructor(e,t,n,i,r,s,a,o,l={}){this.id=e,this.type=t,this.state=n,this.intersector=i,this.getCamera=r,this.onMoveCommited=s,this.parentSetPointerCapture=a,this.parentReleasePointerCapture=o,this.options=l,globalThis.pointerEventspointerMap?.set(e,this)}getPointerCapture(){return this.pointerCapture}hasCaptured(e){return this.pointerCapture?.object===e}setCapture(e){this.pointerCapture?.object!==e&&(this.clearPointerCapture(),null!=e&&null!=this.intersection&&(this.pointerCapture={object:e,intersection:this.intersection},this.parentSetPointerCapture?.()))}getButtonsDown(){return this.buttonsDown}getIntersection(){return this.intersection}getEnabled(){return this.enabled}setEnabled(e,t,n=!0){this.enabled!==e&&(e||null==this.pointerCapture||this.clearPointerCapture(),this.enabled=e,n&&this.commit(t,!1))}computeIntersection(e,t,n){return null!=this.pointerCapture?this.intersector.intersectPointerCapture(this.pointerCapture,n):(this.intersector.startIntersection(n),XA(e,t,[this]),this.intersector.finalizeIntersection(t))}setIntersection(e){this.intersection=e}commit(e,t){const n=this.getCamera(),i=this.prevEnabled?this.prevIntersection:void 0,r=this.enabled?this.intersection:void 0;null!=i&&i.object!=r?.object&&UA(new FA("pointerout",!0,e,this,i,n));const s=this.pointerEntered;this.pointerEntered=[],this.pointerEnteredHelper.length=0,eR(r?.object,this.pointerEntered,s,this.pointerEnteredHelper);const a=s.length;for(let t=0;t<a;t++){const r=s[t];UA(new FA("pointerleave",!1,e,this,i,n,r))}null!=r&&i?.object!=r.object&&UA(new FA("pointerover",!0,e,this,r,n));for(let t=this.pointerEnteredHelper.length-1;t>=0;t--){const i=this.pointerEnteredHelper[t];UA(new FA("pointerenter",!1,e,this,r,n,i))}if(t&&null!=r&&UA(new FA("pointermove",!0,e,this,r,n)),this.prevIntersection=this.intersection,this.prevEnabled=this.enabled,!this.wasMoved&&this.intersector.isReady()){this.wasMoved=!0;const e=this.onFirstMove.length;for(let t=0;t<e;t++)this.onFirstMove[t](n);this.onFirstMove.length=0}this.onMoveCommited?.(this)}move(e,t){this.intersection=this.computeIntersection("pointer",e,t),this.commit(t,!0)}over(e,t){this.wasMoved||(this.intersection=this.computeIntersection("pointer",e,t),this.commit(t,!1))}emitMove(e){null!=this.intersection&&UA(new FA("pointermove",!0,e,this,this.intersection,this.getCamera()))}down(e){if(this.buttonsDown.add(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.down.bind(this,e));if(null==this.intersection)return;UA(new FA("pointerdown",!0,e,this,this.intersection,this.getCamera()));const{object:t}=this.intersection;t[KA]??=new Map,t[KA].set(e.button,e.timeStamp),this.buttonsDownTime.set(e.button,e.timeStamp)}up(e){if(this.buttonsDown.delete(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.up.bind(this,e));if(null==this.intersection)return;const{clickThesholdMs:t,contextMenuButton:n=2,dblClickThresholdMs:i=500,clickThresholdMs:r=t??300}=this.options;this.clearPointerCapture();const s=function(e,t,n,i,r){if(null==t)return!1;const s=t.get(n);if(null==s)return!1;if(i-s>r)return!1;if(s!=e.get(n))return!1;return!0}(this.buttonsDownTime,this.intersection.object[KA],e.button,e.timeStamp,r),a=this.getCamera();if(s&&e.button===n&&UA(new FA("contextmenu",!0,e,this,this.intersection,a)),UA(new FA("pointerup",!0,e,this,this.intersection,a)),!s||e.button===n)return;UA(new FA("click",!0,e,this,this.intersection,a));const{object:o}=this.intersection,l=o[ZA]??=new Map,c=l.get(e.button);null==c||e.timeStamp-c>i?l.set(e.button,e.timeStamp):(UA(new FA("dblclick",!0,e,this,this.intersection,a)),l.delete(e.button))}cancel(e){this.buttonsDown.clear(),this.buttonsDownTime.clear(),this.clearPointerCapture(),this.onFirstMove.length=0,this.enabled&&this.wasMoved&&null!=this.intersection&&UA(new FA("pointercancel",!0,e,this,this.intersection,this.getCamera()))}wheel(e,t,n=!1){if(!this.enabled)return;if(!this.wasMoved&&n)return void this.onFirstMove.push(this.wheel.bind(this,e,t,n));n||(this.wheelIntersection=this.computeIntersection("wheel",e,t));const i=n?this.intersection:this.wheelIntersection;null!=i&&UA(new kA(t,this,i,this.getCamera()))}emitWheel(e,t=!1){if(!this.enabled)return;if(!this.wasMoved&&t)return void this.onFirstMove.push(this.emitWheel.bind(this,e,t));const n=t?this.intersection:this.wheelIntersection;null!=n&&UA(new kA(e,this,n,this.getCamera()))}exit(e){(this.buttonsDown.size>0||null!=this.pointerCapture)&&this.cancel(e),this.wasMoved&&(this.intersection=void 0,this.commit(e,!1)),this.onFirstMove.length=0,this.wasMoved=!1}clearPointerCapture(){null!=this.pointerCapture&&(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0)}}function eR(e,t,n,i){if(null==e)return;const r=n.indexOf(e);-1!=r?n.splice(r,1):i.push(e),t.push(e),eR(e.parent,t,n,i)}const tR=new Jf,nR=new Jf,iR=new Ep,rR=new Ep,sR=new Ep,aR=new Rp,oR=new Jp,lR=new Rp;function cR(e,t,n){lR.copy(t).applyMatrix4(oR.copy(n.matrixWorld).invert());const i=n.geometry.attributes.uv;if(null==i||!(i instanceof _m))return!1;let r;return function(e,t){const n=e.geometry.drawRange;if(null!=e.geometry.index){const i=e.geometry.index,r=Math.max(0,n.start),s=Math.min(i.count,n.start+n.count);for(let e=r;e<s;e+=3)t(i.getX(e),i.getX(e+1),i.getX(e+2));return}const i=e.geometry.attributes.position;if(null==i)return;const r=Math.max(0,n.start),s=Math.min(i.count,n.start+n.count);for(let e=r;e<s;e+=3)t(e,e+1,e+2)}(n,(e,t,s)=>{n.getVertexPosition(e,tR.a),n.getVertexPosition(t,tR.b),n.getVertexPosition(s,tR.c);const a=tR.closestPointToPoint(lR,aR).distanceTo(lR);null!=r&&a>=r||(r=a,nR.copy(tR),iR.fromBufferAttribute(i,e),rR.fromBufferAttribute(i,t),sR.fromBufferAttribute(i,s))}),null!=r&&(nR.closestPointToPoint(lR,aR),nR.getInterpolation(aR,iR,rR,sR,e),!0)}new Jp;const uR=new Jp,hR=new Rp,dR=new Ep,pR=new Rp;class fR{prepareTransformation;options;raycaster=new F_;cameraQuaternion=new Ap;fromPosition=new Rp;fromQuaternion=new Ap;coords=new Ep;viewPlane=new nv;intersects=[];pointerEventsOrders=[];constructor(e,t){this.prepareTransformation=e,this.options=t}isReady(){return!0}intersectPointerCapture({intersection:e,object:t},n){const i=e.details;if("screen-ray"!=i.type)throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a camera ray intersector`);if(!this.startIntersection(n))return e;this.viewPlane.constant-=i.distanceViewPlane;const r=this.raycaster.ray.intersectPlane(this.viewPlane,new Rp);if(null==r)return e;e.object.updateWorldMatrix(!0,!1),function(e,t,n){const i=t.normal??t.face?.normal;null!=i&&(e.setFromNormalAndCoplanarPoint(i,t.localPoint),e.applyMatrix4(n))}(this.viewPlane,e,e.object.matrixWorld);let s=e.uv;return e.object instanceof Ag&&cR(dR,r,e.object)&&(s=dR.clone()),{...e,details:{...i,direction:this.raycaster.ray.direction.clone(),screenPoint:this.coords.clone()},uv:s,object:t,point:r,pointOnFace:r,pointerPosition:this.raycaster.ray.origin.clone(),pointerQuaternion:this.cameraQuaternion.clone()}}startIntersection(e){const t=this.prepareTransformation(e,this.coords);return null!=t&&(t.updateWorldMatrix(!0,!1),t.matrixWorld.decompose(this.fromPosition,this.fromQuaternion,hR),this.raycaster.setFromCamera(this.coords,t),this.viewPlane.setFromNormalAndCoplanarPoint(t.getWorldDirection(pR),this.raycaster.ray.origin),!0)}executeIntersection(e,t){const n=this.intersects.length;e.raycast(this.raycaster,this.intersects),function(e,t,n){for(;n>0;)e.push(t),--n}(this.pointerEventsOrders,t,this.intersects.length-n)}finalizeIntersection(e){const t=this.fromPosition.clone(),n=this.cameraQuaternion.clone(),i=this.raycaster.ray.direction.clone(),r=function(e,t,{customSort:n=$A}={}){let i,r,s;const a=e.length;for(let o=0;o<a;o++){const a=e[o],l=t?.[o];(null==i||n(a,l,i,r)<0)&&(s=o,i=a,r=l)}return s}(this.intersects,this.pointerEventsOrders,this.options),s=null==r?void 0:this.intersects[r];return this.intersects.length=0,this.pointerEventsOrders.length=0,null==s?function(e,t,n,i,r,s=0){const a=t.direction.clone().multiplyScalar(YA),o=YA;return{distance:o+s,object:WA(e),point:a,normal:t.origin.clone().sub(a).normalize(),details:n(a,o),pointerPosition:i,pointerQuaternion:r,pointOnFace:a,localPoint:a}}(e,this.raycaster.ray,(e,t)=>({type:"screen-ray",distanceViewPlane:t,screenPoint:this.coords.clone(),direction:i}),t,n):(s.object.updateWorldMatrix(!0,!1),uR.copy(s.object.matrixWorld).invert(),Object.assign(s,{details:{type:"screen-ray",distanceViewPlane:this.viewPlane.distanceToPoint(s.point),screenPoint:this.coords.clone(),direction:i},pointOnFace:s.point,pointerPosition:t,pointerQuaternion:n,localPoint:s.point.clone().applyMatrix4(uR)}))}}new Jp,new Jp;let mR=99412;function gR(e,t,n){if(!(t instanceof globalThis.MouseEvent))return n.set(0,0);const{width:i,height:r,top:s,left:a}=e.getBoundingClientRect(),o=t.clientX-a,l=t.clientY-s;return n.set(o/i*2-1,-l/r*2+1)}function vR(e,t,n,i){return function(e,t,n,i,r,s,a={}){const o=a?.forwardPointerCapture??!0,l=new Map,c=a.pointerTypePrefix??"forward-",u=(e,u)=>{let h=l.get(e.pointerId);return null!=h||(h=new QA(mR++,`${c}${e.pointerType}`,e.pointerState,new fR((e,n)=>(i(e,n),t()),a),t,void 0,o?r.bind(null,e.pointerId):void 0,o?s.bind(null,e.pointerId):void 0,a),"move"!=u&&"wheel"!=u&&(h.setIntersection(h.computeIntersection("pointer",n,e)),h.commit(e,!1)),l.set(e.pointerId,h)),h},h=new Map,d=new Map,p=[],f=[],m=(e,t,i)=>{switch(e){case"move":case"over":return void i.move(n,t);case"wheel":return void i.wheel(n,t);case"cancel":return void i.cancel(t);case"down":if(!yR(t))return;return void i.down(t);case"up":if(!yR(t))return;return void i.up(t);case"exit":return d.delete(i),h.delete(i),void i.exit(t)}},g=(e,t)=>{const n=u(t,e);"move"===e&&d.set(n,t),"wheel"===e&&h.set(n,t),a.batchEvents??1?f.push({type:e,event:t}):m(e,t,n)},v=g.bind(null,"move"),y=g.bind(null,"over"),x=g.bind(null,"cancel"),b=g.bind(null,"down"),_=g.bind(null,"up"),w=g.bind(null,"wheel"),S=g.bind(null,"exit");return e.addEventListener("pointermove",v),e.addEventListener("pointerover",y),e.addEventListener("pointercancel",x),e.addEventListener("pointerdown",b),e.addEventListener("pointerup",_),e.addEventListener("wheel",w),e.addEventListener("pointerleave",S),{destroy(){e.removeEventListener("pointermove",v),e.removeEventListener("pointerover",y),e.removeEventListener("pointercancel",x),e.removeEventListener("pointerdown",b),e.removeEventListener("pointerup",_),e.removeEventListener("wheel",w),e.removeEventListener("pointerleave",S),d.clear(),h.clear()},update(){const e=f.length;for(let t=0;t<e;t++){const{type:e,event:n}=f[t],i=u(n,e);"move"!==e||(p.push(i),d.get(i)==n)?"wheel"!==e||h.get(i)==n?m(e,n,i):i.emitWheel(n):i.emitMove(n)}if(f.length=0,a.intersectEveryFrame)for(const[e,t]of d.entries())p.includes(e)||e.move(n,t);p.length=0}}}(e,"function"==typeof t?t:()=>t,n,gR.bind(null,e),e.setPointerCapture.bind(e),t=>{e.hasPointerCapture(t)&&e.releasePointerCapture(t)},{pointerTypePrefix:"screen-",...i})}function yR(e){return null!=e.button}class xR{constructor(e){var t;this.xrDevice=e,this.combinedCameraPosition=new Rp,this.isPointerLocked=!1,this.vec3=new Rp,this.quat=new Ap,this.quatB=new Ap,this.quatInv=new Ap,this.quatMouse=new Ap,this.euler=new cf,this.keyState={ShiftLeft:!1,KeyW:!1,KeyA:!1,KeyS:!1,KeyD:!1,ArrowUp:!1,ArrowDown:!1},this.lastTime=0,this.preferredConnectedGazeMode="head-locked",this.gazeCommitHand="right",this.gazePointerId=null,this.gazeHeadsetDragActive=!1,this.gazeLastPointer={x:0,y:0},this.gazeForward=new Rp(0,0,-1),this.gazeDirection=new Rp,this.gazeQuaternion=new Ap,this.isInProgrammaticMode=!1,this.interactionsEnabled=!0,this.scene=new Uf,this.gazeMode=(null===(t=e.gaze)||void 0===t?void 0:t.connected)?"head-locked":"off",this.camera=new Ob(50,window.innerWidth/window.innerHeight,.1,40),this.playerRig=new Af,this.cameraRig=new Af,this.scene.add(this.playerRig),this.playerRig.add(this.cameraRig),this.cameraRig.position.fromArray(e.position.vec3),this.cameraRig.quaternion.fromArray(e.quaternion.quat),this.cameraRig.add(this.camera),this.camera.position.x-=e.ipd/2;const n=new Ag(new xx(.25,.27,32),new mg({color:16777215,side:0}));n.rotateX(-Math.PI/2),this.scene.add(n),this.renderer=new cT({alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.setClearColor(0,0),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.transformHandles=new Map,["left","right"].forEach(t=>{const n=new DA;n.scale.setScalar(.1),n.position.fromArray(e.controllers[t].position.vec3),n.quaternion.fromArray(e.controllers[t].quaternion.quat),this.cameraRig.attach(n),n.userData={defaultPosition:n.position.toArray(),defaultQuaternion:n.quaternion.toArray()},n.userData.setMode=e=>{var t,i;null===(i=(t=n.userData).modeCleanup)||void 0===i||i.call(t),n.userData.modeCleanup=n.bind(e),n.userData.mode=e},n.userData.setMode("translate"),n.space="local",this.transformHandles.set(t,n),n.addEventListener("click",()=>{"translate"===n.userData.mode?n.userData.setMode("rotate"):n.userData.setMode("translate")})}),window.transformHandles=this.transformHandles,this.mouseMoveHandler=t=>{if(!this.isPointerLocked||this.isInProgrammaticMode)return;const n=t.movementX||t.mozMovementX||t.webkitMovementX||0,i=t.movementY||t.mozMovementY||t.webkitMovementY||0;this.playerRig.rotation.y-=.002*n,this.cameraRig.rotation.x-=.002*i,e.quaternion.copy(this.cameraRig.getWorldQuaternion(this.quatMouse))},this.cameraRig.getWorldPosition(this.combinedCameraPosition),this.headsetDefaultPosition=this.cameraRig.position.clone(),this.headsetDefaultQuaternion=this.cameraRig.quaternion.clone(),this.forwardHtmlEvents=vR(this.renderer.domElement,()=>this.camera,this.scene).update,this.pointerLockChangeHandlerBound=this.pointerLockChangeHandler.bind(this),this.gazePointerDownHandlerBound=this.gazePointerDownHandler.bind(this),this.gazePointerMoveHandlerBound=this.gazePointerMoveHandler.bind(this),this.gazePointerUpHandlerBound=this.gazePointerUpHandler.bind(this),this.gazeWheelHandlerBound=this.gazeWheelHandler.bind(this),this.gazeContextMenuHandlerBound=this.gazeContextMenuHandler.bind(this),this.windowBlurHandlerBound=()=>{this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1},this.documentVisibilityHandlerBound=()=>{"visible"!==document.visibilityState&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1)},this.keyDownHandlerBound=this.keyDownHandler.bind(this),this.keyUpHandlerBound=this.keyUpHandler.bind(this),document.addEventListener("pointerlockchange",this.pointerLockChangeHandlerBound,!1),document.addEventListener("mozpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.addEventListener("webkitpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.addEventListener("keydown",this.keyDownHandlerBound,!1),document.addEventListener("keyup",this.keyUpHandlerBound,!1),this.renderer.domElement.addEventListener("pointerdown",this.gazePointerDownHandlerBound),this.renderer.domElement.addEventListener("pointermove",this.gazePointerMoveHandlerBound),this.renderer.domElement.addEventListener("pointerup",this.gazePointerUpHandlerBound),this.renderer.domElement.addEventListener("pointercancel",this.gazePointerUpHandlerBound),this.renderer.domElement.addEventListener("wheel",this.gazeWheelHandlerBound,{passive:!1}),this.renderer.domElement.addEventListener("contextmenu",this.gazeContextMenuHandlerBound),window.addEventListener("blur",this.windowBlurHandlerBound),document.addEventListener("visibilitychange",this.documentVisibilityHandlerBound)}lockPointer(){!this.isInProgrammaticMode&&this.interactionsEnabled&&"cursor"!==this.gazeMode&&(this.renderer.domElement.requestPointerLock=this.renderer.domElement.requestPointerLock||this.renderer.domElement.mozRequestPointerLock||this.renderer.domElement.webkitRequestPointerLock,this.renderer.domElement.requestPointerLock())}pointerLockChangeHandler(){this.isPointerLocked=document.pointerLockElement===this.renderer.domElement||document.mozPointerLockElement===this.renderer.domElement||document.webkitPointerLockElement===this.renderer.domElement,this.isPointerLocked?document.addEventListener("mousemove",this.mouseMoveHandler,!1):document.removeEventListener("mousemove",this.mouseMoveHandler,!1)}get currentGazeMode(){return this.gazeMode}get currentGazeCommitHand(){return this.gazeCommitHand}applyGazeModePresentation(e){var t;this.gazeMode=e,"cursor"===e&&this.isPointerLocked&&(null===(t=document.exitPointerLock)||void 0===t||t.call(document));const n="cursor"===e;this.renderer.domElement.style.cursor=n?"crosshair":"",this.renderer.domElement.style.touchAction=n?"none":"",this.setTransformHandleRoutingSuppressed(n)}setGazeMode(e){this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1;const t=this.xrDevice.gaze;t?("off"!==e&&(this.preferredConnectedGazeMode=e),t.connected="off"!==e,"head-locked"===e&&t.quaternion.set(0,0,0,1),this.applyGazeModePresentation(e)):this.applyGazeModePresentation("off")}setProgrammaticMode(e){const t=this.isInProgrammaticMode;if(this.isInProgrammaticMode=e,!t||e)return;const n=this.xrDevice.gaze,i=(null==n?void 0:n.connected)?this.preferredConnectedGazeMode:"off";i!==this.gazeMode&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1,this.applyGazeModePresentation(i))}setGazeCommitHand(e){e!==this.gazeCommitHand&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1,this.gazeCommitHand=e)}onSessionEnd(){this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1}setTransformHandleRoutingSuppressed(e){this.transformHandles.forEach(t=>{var n,i;e&&!t.userData.gazeSuppressed?(null===(i=(n=t.userData).modeCleanup)||void 0===i||i.call(n),t.userData.modeCleanup=void 0,t.userData.gazeSuppressed=!0):!e&&t.userData.gazeSuppressed&&(t.userData.gazeSuppressed=!1,t.userData.setMode(t.userData.mode))})}gazeInteractionEnabled(){var e;return"cursor"===this.gazeMode&&Boolean(null===(e=this.xrDevice.gaze)||void 0===e?void 0:e.connected)&&"visible"===this.xrDevice.visibilityState&&this.interactionsEnabled&&!this.isInProgrammaticMode&&Boolean(this.xrDevice.activeSession)}updateGazeFromPointer(e,t){if(!this.gazeInteractionEnabled()||this.gazeCommitActive)return;const n=function(e,t,n,i,r){if(n.width<=0||n.height<=0)return[0,0,-1];const s=i?n.width/2:n.width,a=e-n.left,o=(i&&a>=s?a-s:a)/s*2-1,l=1-(t-n.top)/n.height*2,c=Math.tan(r/2),u=o*(s/n.height)*c,h=l*c,d=Math.hypot(u,h,-1);return[u/d,h/d,-1/d]}(e,t,this.renderer.domElement.getBoundingClientRect(),this.xrDevice.stereoEnabled,this.xrDevice.fovy);this.gazeDirection.fromArray(n),this.gazeQuaternion.setFromUnitVectors(this.gazeForward,this.gazeDirection),this.xrDevice.gaze.quaternion.copy(this.gazeQuaternion)}beginGazeCommit(){if(this.gazeCommitActive||this.gazeCommitPendingRelease)return;const e=this.xrDevice.primaryInputMode,t=this.gazeCommitHand,n="hand"===e?this.xrDevice.hands[t]:this.xrDevice.controllers[t];(null==n?void 0:n.connected)&&(this.writeGazeCommitValue({mode:e,handedness:t},1,!1),this.gazeCommitActive={mode:e,handedness:t})}writeGazeCommitValue(e,t,n){if("hand"===e.mode){const i=this.xrDevice.hands[e.handedness];n?null==i||i.setPinchValueImmediate(t):null==i||i.updatePinchValue(t)}else{const i=this.xrDevice.controllers[e.handedness];n?null==i||i.setButtonValueImmediate("trigger",t):null==i||i.updateButtonValue("trigger",t)}}releaseGazeCommit(e){var t,n,i,r,s;const a=this.gazeCommitActive,o=null===(t=this.gazeCommitPendingRelease)||void 0===t?void 0:t.source,l=this.gazePointerId;if(this.gazePointerId=null,null!==l&&(null===(i=(n=this.renderer.domElement).hasPointerCapture)||void 0===i?void 0:i.call(n,l))&&(null===(s=(r=this.renderer.domElement).releasePointerCapture)||void 0===s||s.call(r,l)),e)return this.gazeCommitPendingRelease=void 0,o&&this.writeGazeCommitValue(o,0,!0),a&&a!==o&&this.writeGazeCommitValue(a,0,!0),void(this.gazeCommitActive=void 0);a&&(this.gazeCommitPendingRelease={source:a,queuedForFrame:!1},this.gazeCommitActive=void 0)}schedulePendingGazeRelease(){const e=this.gazeCommitPendingRelease;e&&queueMicrotask(()=>{this.gazeCommitPendingRelease===e&&(e.queuedForFrame?this.gazeCommitPendingRelease=void 0:(this.writeGazeCommitValue(e.source,0,!1),e.queuedForFrame=!0))})}gazeCommitSourceIsActive(){const e=this.gazeCommitActive;if(!e||this.xrDevice.primaryInputMode!==e.mode)return!1;const t="hand"===e.mode?this.xrDevice.hands[e.handedness]:this.xrDevice.controllers[e.handedness];return Boolean(null==t?void 0:t.connected)}moveCommitInput(e,t){const n=this.gazeCommitActive;if(!n)return;const i=this.transformHandles.get(n.handedness);if(!i)return;const r=this.renderer.domElement.getBoundingClientRect(),s=Math.max(.25,Math.abs(i.position.z)),a=2*Math.tan(this.xrDevice.fovy/2)*s/Math.max(r.height,1);i.position.x+=e*a,i.position.y-=t*a,this.syncDeviceTransforms()}moveCommitInputDepth(e){const t=this.gazeCommitActive;if(!t)return;const n=this.transformHandles.get(t.handedness);if(!n)return;const i=this.renderer.domElement.getBoundingClientRect(),r=Math.max(.25,Math.abs(n.position.z)),s=2*Math.tan(this.xrDevice.fovy/2)*r/Math.max(i.height,1);n.position.z-=e*s*.5,this.syncDeviceTransforms()}gazePointerDownHandler(e){var t,n;null===this.gazePointerId&&this.gazeInteractionEnabled()&&(0!==e.button&&2!==e.button||(e.preventDefault(),e.stopPropagation(),this.gazePointerId=e.pointerId,this.gazeLastPointer={x:e.clientX,y:e.clientY},null===(n=(t=this.renderer.domElement).setPointerCapture)||void 0===n||n.call(t,e.pointerId),0===e.button?(this.updateGazeFromPointer(e.clientX,e.clientY),this.beginGazeCommit()):this.gazeHeadsetDragActive=!0))}gazePointerMoveHandler(e){if(null!==this.gazePointerId&&this.gazePointerId!==e.pointerId)return;const t=e.clientX-this.gazeLastPointer.x,n=e.clientY-this.gazeLastPointer.y;return this.gazeLastPointer={x:e.clientX,y:e.clientY},this.gazeInteractionEnabled()?this.gazeCommitActive?(e.preventDefault(),void this.moveCommitInput(t,n)):this.gazeHeadsetDragActive?(e.preventDefault(),this.playerRig.rotation.y-=.002*t,this.cameraRig.rotation.x-=.002*n,void this.xrDevice.quaternion.copy(this.cameraRig.getWorldQuaternion(this.quatMouse))):void this.updateGazeFromPointer(e.clientX,e.clientY):void 0}gazePointerUpHandler(e){var t,n,i,r;this.gazePointerId===e.pointerId&&(this.gazeCommitActive&&this.releaseGazeCommit(!1),this.gazeHeadsetDragActive=!1,this.gazePointerId=null,(null===(n=(t=this.renderer.domElement).hasPointerCapture)||void 0===n?void 0:n.call(t,e.pointerId))&&(null===(r=(i=this.renderer.domElement).releasePointerCapture)||void 0===r||r.call(i,e.pointerId)))}gazeWheelHandler(e){this.gazeInteractionEnabled()&&this.gazeCommitActive&&(e.preventDefault(),e.stopPropagation(),this.moveCommitInputDepth(e.deltaY))}gazeContextMenuHandler(e){"cursor"===this.gazeMode&&e.preventDefault()}resetInputTransform(e){const t=this.transformHandles.get(e);t&&(t.position.fromArray(t.userData.defaultPosition),t.quaternion.fromArray(t.userData.defaultQuaternion),this.syncDeviceTransforms())}keyDownHandler(e){const{keyState:t}=this;if(e.code in t&&(t[e.code]=!0),!this.isInProgrammaticMode){if("cursor"===this.gazeMode&&"Space"===e.code){if(e.composedPath().some(e=>{if("object"!=typeof e||null===e)return!1;const t=e;return!0===t.isContentEditable||"string"==typeof t.tagName&&["A","BUTTON","INPUT","SELECT","TEXTAREA"].includes(t.tagName)}))return;return e.preventDefault(),void this.resetInputTransform(this.gazeCommitHand)}t.ShiftLeft&&t.ArrowUp&&(this.cameraRig.position.y+=.05),t.ShiftLeft&&t.ArrowDown&&(this.cameraRig.position.y-=.05)}}keyUpHandler(e){const{keyState:t}=this;e.code in t&&(t[e.code]=!1)}movePlayerRig(e){const{playerRig:t,keyState:n,vec3:i}=this;i.set((n.KeyD?1:0)-(n.KeyA?1:0),0,(n.KeyS?1:0)-(n.KeyW?1:0)),i.lengthSq()>0&&n.ShiftLeft&&(i.normalize().multiplyScalar(2*e).applyQuaternion(t.quaternion),t.position.add(i))}resetDeviceTransforms(){const{playerRig:e,cameraRig:t,transformHandles:n}=this;t.position.copy(this.headsetDefaultPosition),t.quaternion.copy(this.headsetDefaultQuaternion),e.position.set(0,0,0),e.quaternion.set(0,0,0,1),n.forEach(e=>{e.position.fromArray(e.userData.defaultPosition),e.quaternion.fromArray(e.userData.defaultQuaternion)})}captureDefaultPose(){const e=this.cameraRig.getWorldPosition(this.vec3).toArray(),t=this.cameraRig.getWorldQuaternion(this.quat).toArray(),n={},i={};return this.transformHandles.forEach((e,t)=>{const r=e.getWorldPosition(this.vec3).toArray(),s=e.getWorldQuaternion(this.quat).toArray(),a={position:r,quaternion:s};n[t]=a,i[t]={position:[...r],quaternion:[...s]}}),{headset:{position:e,quaternion:t},controllers:n,hands:i}}applyDefaultPose(e){const{headset:t,controllers:n,hands:i}=e;this.headsetDefaultPosition.fromArray(t.position),this.headsetDefaultQuaternion.fromArray(t.quaternion),this.quatInv.copy(this.headsetDefaultQuaternion).invert(),this.transformHandles.forEach((e,t)=>{var r;const s=null!==(r=null==n?void 0:n[t])&&void 0!==r?r:null==i?void 0:i[t];s&&(this.vec3.fromArray(s.position).sub(this.headsetDefaultPosition).applyQuaternion(this.quatInv),this.quat.fromArray(s.quaternion).premultiply(this.quatInv),e.userData.defaultPosition=this.vec3.toArray(),e.userData.defaultQuaternion=this.quat.toArray())}),this.resetDeviceTransforms(),this.combinedCameraPosition.copy(this.headsetDefaultPosition)}syncDeviceTransforms(){const{xrDevice:e,cameraRig:t,transformHandles:n}=this;e.position.copy(t.getWorldPosition(this.vec3)),e.quaternion.copy(t.getWorldQuaternion(this.quat)),n.forEach((t,n)=>{const i="controller"===e.primaryInputMode?e.controllers[n]:e.hands[n];i.position.copy(t.getWorldPosition(this.vec3)),i.quaternion.copy(t.getWorldQuaternion(this.quat))})}syncFromDevice(){const{xrDevice:e,playerRig:t,cameraRig:n,transformHandles:i}=this;this.syncGazeModeFromDevice();const r=e.position,s=e.quaternion;this.combinedCameraPosition.set(r.x,r.y,r.z),this.quatB.set(s.x,s.y,s.z,s.w),this.euler.setFromQuaternion(this.quatB,"YXZ"),t.position.set(r.x,0,r.z),t.rotation.set(0,this.euler.y,0),n.position.set(0,r.y,0),this.quat.setFromEuler(this.euler.set(0,this.euler.y,0,"YXZ")),n.quaternion.multiplyQuaternions(this.quat.invert(),this.quatB),t.updateMatrixWorld(!0),n.getWorldQuaternion(this.quatInv).invert(),i.forEach((t,i)=>{const r="controller"===e.primaryInputMode?e.controllers[i]:e.hands[i],s=this.vec3.set(r.position.x,r.position.y,r.position.z);n.worldToLocal(s),t.position.copy(s),this.quatB.set(r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w),this.quatB.premultiply(this.quatInv),t.quaternion.copy(this.quatB)})}syncGazeModeFromDevice(){var e;const t=(null===(e=this.xrDevice.gaze)||void 0===e?void 0:e.connected)?"head-locked":"off";t!==this.gazeMode&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1,this.applyGazeModePresentation(t))}setInteractionsEnabled(e){this.interactionsEnabled=e,e||(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1),!e&&this.isPointerLocked&&document.exitPointerLock()}renderScene(e){!this.gazeCommitActive||this.gazeInteractionEnabled()&&this.gazeCommitSourceIsActive()||(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1),this.schedulePendingGazeRelease();const t=this.xrDevice.fovy/Math.PI*180;let n=!1;this.camera.fov!==t&&(this.camera.fov=t,n=!0);const i=this.xrDevice.canvasDimensions;if(i){const e=this.renderer.domElement;(e.width!==i.width||e.height!==i.height)&&(this.camera.aspect=i.width/i.height,this.renderer.setSize(i.width,i.height),n=!0)}n&&this.camera.updateProjectionMatrix(),this.isInProgrammaticMode||(this.isPointerLocked?this.cameraRig.getWorldPosition(this.combinedCameraPosition):(this.cameraRig.position.y=this.combinedCameraPosition.y,this.playerRig.position.x=this.combinedCameraPosition.x,this.playerRig.position.z=this.combinedCameraPosition.z)),"cursor"!==this.gazeMode&&this.forwardHtmlEvents(),this.transformHandles.forEach((t,n)=>{const i="controller"===this.xrDevice.primaryInputMode?this.xrDevice.controllers[n]:this.xrDevice.hands[n],r=Boolean(null==i?void 0:i.connected);t.visible=r&&!this.isPointerLocked&&!this.isInProgrammaticMode&&"cursor"!==this.gazeMode,r&&t.update(e,this.camera)});const r=Math.min((e-this.lastTime)/1e3,.1);this.isInProgrammaticMode||(this.movePlayerRig(r),this.syncDeviceTransforms()),this.renderer.render(this.scene,this.camera),this.lastTime=e}get domElement(){return this.renderer.domElement}dispose(){this.releaseGazeCommit(!0),this.setTransformHandleRoutingSuppressed(!1),this.renderer.dispose(),document.removeEventListener("pointerlockchange",this.pointerLockChangeHandlerBound,!1),document.removeEventListener("mozpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.removeEventListener("webkitpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.removeEventListener("mousemove",this.mouseMoveHandler,!1),document.removeEventListener("keydown",this.keyDownHandlerBound,!1),document.removeEventListener("keyup",this.keyUpHandlerBound,!1),this.renderer.domElement.removeEventListener("pointerdown",this.gazePointerDownHandlerBound),this.renderer.domElement.removeEventListener("pointermove",this.gazePointerMoveHandlerBound),this.renderer.domElement.removeEventListener("pointerup",this.gazePointerUpHandlerBound),this.renderer.domElement.removeEventListener("pointercancel",this.gazePointerUpHandlerBound),this.renderer.domElement.removeEventListener("wheel",this.gazeWheelHandlerBound),this.renderer.domElement.removeEventListener("contextmenu",this.gazeContextMenuHandlerBound),window.removeEventListener("blur",this.windowBlurHandlerBound),document.removeEventListener("visibilitychange",this.documentVisibilityHandlerBound)}}var bR,_R,wR={exports:{}},SR={},MR={exports:{}},TR={};function ER(){return _R||(_R=1,MR.exports=(bR||(bR=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var i=n-1>>>1,s=e[i];if(!(0<r(s,t)))break e;e[i]=t,e[n]=s,n=i}}function n(e){return 0===e.length?null:e[0]}function i(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var i=0,s=e.length,a=s>>>1;i<a;){var o=2*(i+1)-1,l=e[o],c=o+1,u=e[c];if(0>r(l,n))c<s&&0>r(u,l)?(e[i]=u,e[c]=n,i=c):(e[i]=l,e[o]=n,i=o);else{if(!(c<s&&0>r(u,n)))break e;e[i]=u,e[c]=n,i=c}}}return t}function r(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();e.unstable_now=function(){return a.now()-o}}var l=[],c=[],u=1,h=null,d=3,p=!1,f=!1,m=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,x="undefined"!=typeof setImmediate?setImmediate:null;function b(e){for(var r=n(c);null!==r;){if(null===r.callback)i(c);else{if(!(r.startTime<=e))break;i(c),r.sortIndex=r.expirationTime,t(l,r)}r=n(c)}}function _(e){if(m=!1,b(e),!f)if(null!==n(l))f=!0,S||(S=!0,w());else{var t=n(c);null!==t&&I(_,t.startTime-e)}}var w,S=!1,M=-1,T=5,E=-1;function A(){return!(!g&&e.unstable_now()-E<T)}function R(){if(g=!1,S){var t=e.unstable_now();E=t;var r=!0;try{e:{f=!1,m&&(m=!1,y(M),M=-1),p=!0;var s=d;try{t:{for(b(t),h=n(l);null!==h&&!(h.expirationTime>t&&A());){var a=h.callback;if("function"==typeof a){h.callback=null,d=h.priorityLevel;var o=a(h.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof o){h.callback=o,b(t),r=!0;break t}h===n(l)&&i(l),b(t)}else i(l);h=n(l)}if(null!==h)r=!0;else{var u=n(c);null!==u&&I(_,u.startTime-t),r=!1}}break e}finally{h=null,d=s,p=!1}r=void 0}}finally{r?w():S=!1}}}if("function"==typeof x)w=function(){x(R)};else if("undefined"!=typeof MessageChannel){var C=new MessageChannel,P=C.port2;C.port1.onmessage=R,w=function(){P.postMessage(null)}}else w=function(){v(R,0)};function I(t,n){M=v(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_next=function(e){switch(d){case 1:case 2:case 3:var t=3;break;default:t=d}var n=d;d=t;try{return e()}finally{d=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=d;d=e;try{return t()}finally{d=n}},e.unstable_scheduleCallback=function(i,r,s){var a=e.unstable_now();switch(s="object"==typeof s&&null!==s&&"number"==typeof(s=s.delay)&&0<s?a+s:a,i){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return i={id:u++,callback:r,priorityLevel:i,startTime:s,expirationTime:o=s+o,sortIndex:-1},s>a?(i.sortIndex=s,t(c,i),null===n(l)&&i===n(c)&&(m?(y(M),M=-1):m=!0,I(_,s-a))):(i.sortIndex=o,t(l,i),f||p||(f=!0,S||(S=!0,w()))),i},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(e){var t=d;return function(){var n=d;d=t;try{return e.apply(this,arguments)}finally{d=n}}}}(TR)),TR)),MR.exports}var AR,RR,CR,PR={exports:{}},IR={};function LR(){if(AR)return IR;AR=1;var e=l;function t(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var i={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");var s=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function a(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return IR.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,IR.createPortal=function(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(t(299));return function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:r,key:null==i?null:""+i,children:e,containerInfo:t,implementation:n}}(e,n,null,i)},IR.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},IR.preconnect=function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,i.d.C(e,t))},IR.prefetchDNS=function(e){"string"==typeof e&&i.d.D(e)},IR.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=a(n,t.crossOrigin),s="string"==typeof t.integrity?t.integrity:void 0,o="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?i.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:s,fetchPriority:o}):"script"===n&&i.d.X(e,{crossOrigin:r,integrity:s,fetchPriority:o,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},IR.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=a(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&i.d.M(e)},IR.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=a(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},IR.preloadModule=function(e,t){if("string"==typeof e)if(t){var n=a(t.as,t.crossOrigin);i.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else i.d.m(e)},IR.requestFormReset=function(e){i.d.r(e)},IR.unstable_batchedUpdates=function(e,t){return e(t)},IR.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},IR.useFormStatus=function(){return s.H.useHostTransitionStatus()},IR.version="19.2.8",IR}!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),wR.exports=function(){if(CR)return SR;CR=1;var e=ER(),t=l,n=(RR||(RR=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),PR.exports=LR()),PR.exports);function i(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function a(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function o(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function c(e){if(s(e)!==e)throw Error(i(188))}function u(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=u(e)))return t;e=e.sibling}return null}var h=Object.assign,d=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),x=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),E=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function R(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||e["@@iterator"])?e:null}var C=Symbol.for("react.client.reference");function P(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===C?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case m:return"Fragment";case v:return"Profiler";case g:return"StrictMode";case _:return"Suspense";case w:return"SuspenseList";case T:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case f:return"Portal";case x:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case b:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case S:return null!==(t=e.displayName||null)?t:P(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return P(e(t))}catch(e){}}return null}var I=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N={pending:!1,data:null,method:null,action:null},O=[],F=-1;function k(e){return{current:e}}function U(e){0>F||(e.current=O[F],O[F]=null,F--)}function z(e,t){F++,O[F]=e.current,e.current=t}var B,V,G=k(null),H=k(null),W=k(null),j=k(null);function X(e,t){switch(z(W,t),z(H,e),z(G,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?mh(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=gh(t=mh(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}U(G),z(G,e)}function q(){U(G),U(H),U(W)}function $(e){null!==e.memoizedState&&z(j,e);var t=G.current,n=gh(t,e.type);t!==n&&(z(H,e),z(G,n))}function Y(e){H.current===e&&(U(G),U(H)),j.current===e&&(U(j),ld._currentValue=N)}function K(e){if(void 0===B)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);B=t&&t[1]||"",V=-1<e.stack.indexOf("\n at")?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+B+e+V}var Z=!1;function J(e,t){if(!e||Z)return"";Z=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var i=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){i=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){i=e}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(e){if(e&&i&&"string"==typeof e.stack)return[e.stack,i.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var s=i.DetermineComponentFrameRoot(),a=s[0],o=s[1];if(a&&o){var l=a.split("\n"),c=o.split("\n");for(r=i=0;i<l.length&&!l[i].includes("DetermineComponentFrameRoot");)i++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(i===l.length||r===c.length)for(i=l.length-1,r=c.length-1;1<=i&&0<=r&&l[i]!==c[r];)r--;for(;1<=i&&0<=r;i--,r--)if(l[i]!==c[r]){if(1!==i||1!==r)do{if(i--,0>--r||l[i]!==c[r]){var u="\n"+l[i].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=i&&0<=r);break}}}finally{Z=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?K(n):""}function Q(e,t){switch(e.tag){case 26:case 27:case 5:return K(e.type);case 16:return K("Lazy");case 13:return e.child!==t&&null!==t?K("Suspense Fallback"):K("Suspense");case 19:return K("SuspenseList");case 0:case 15:return J(e.type,!1);case 11:return J(e.type.render,!1);case 1:return J(e.type,!0);case 31:return K("Activity");default:return""}}function ee(e){try{var t="",n=null;do{t+=Q(e,n),n=e,e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}var te=Object.prototype.hasOwnProperty,ne=e.unstable_scheduleCallback,ie=e.unstable_cancelCallback,re=e.unstable_shouldYield,se=e.unstable_requestPaint,ae=e.unstable_now,oe=e.unstable_getCurrentPriorityLevel,le=e.unstable_ImmediatePriority,ce=e.unstable_UserBlockingPriority,ue=e.unstable_NormalPriority,he=e.unstable_LowPriority,de=e.unstable_IdlePriority,pe=e.log,fe=e.unstable_setDisableYieldValue,me=null,ge=null;function ve(e){if("function"==typeof pe&&fe(e),ge&&"function"==typeof ge.setStrictMode)try{ge.setStrictMode(me,e)}catch(e){}}var ye=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(xe(e)/be|0)|0},xe=Math.log,be=Math.LN2,_e=256,we=262144,Se=4194304;function Me(e){var t=42&e;if(0!==t)return t;switch(e&-e){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 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Te(e,t,n){var i=e.pendingLanes;if(0===i)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes;e=e.warmLanes;var o=134217727&i;return 0!==o?0!==(i=o&~s)?r=Me(i):0!==(a&=o)?r=Me(a):n||0!==(n=o&~e)&&(r=Me(n)):0!==(o=i&~s)?r=Me(o):0!==a?r=Me(a):n||0!==(n=i&~e)&&(r=Me(n)),0===r?0:0!==t&&t!==r&&0===(t&s)&&((s=r&-r)>=(n=t&-t)||32===s&&4194048&n)?t:r}function Ee(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+5e3;default:return-1}}function Re(){var e=Se;return!(62914560&(Se<<=1))&&(Se=4194304),e}function Ce(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Pe(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ie(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-ye(t);e.entangledLanes|=t,e.entanglements[i]=1073741824|e.entanglements[i]|261930&n}function Le(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-ye(n),r=1<<i;r&t|e[i]&t&&(e[i]|=t),n&=~r}}function De(e,t){var n=t&-t;return 0!==((n=42&n?1:Ne(n))&(e.suspendedLanes|t))?0:n}function Ne(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Oe(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Fe(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:Md(e.type)}function ke(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}var Ue=Math.random().toString(36).slice(2),ze="__reactFiber$"+Ue,Be="__reactProps$"+Ue,Ve="__reactContainer$"+Ue,Ge="__reactEvents$"+Ue,He="__reactListeners$"+Ue,We="__reactHandles$"+Ue,je="__reactResources$"+Ue,Xe="__reactMarker$"+Ue;function qe(e){delete e[ze],delete e[Be],delete e[Ge],delete e[He],delete e[We]}function $e(e){var t=e[ze];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ve]||n[ze]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Nh(e);null!==e;){if(n=e[ze])return n;e=Nh(e)}return t}n=(e=n).parentNode}return null}function Ye(e){if(e=e[ze]||e[Ve]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function Ke(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(i(33))}function Ze(e){var t=e[je];return t||(t=e[je]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Je(e){e[Xe]=!0}var Qe=new Set,et={};function tt(e,t){nt(e,t),nt(e+"Capture",t)}function nt(e,t){for(et[e]=t,e=0;e<t.length;e++)Qe.add(t[e])}var it=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]*$"),rt={},st={};function at(e,t,n){if(r=t,te.call(st,r)||!te.call(rt,r)&&(it.test(r)?st[r]=!0:(rt[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var i=t.toLowerCase().slice(0,5);if("data-"!==i&&"aria-"!==i)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function ot(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function lt(e,t,n,i){if(null===i)e.removeAttribute(n);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+i)}}function ct(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ut(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function ht(e){if(!e._valueTracker){var t=ut(e)?"checked":"value";e._valueTracker=function(e,t,n){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==i&&"function"==typeof i.get&&"function"==typeof i.set){var r=i.get,s=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){n=""+e,s.call(this,e)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function dt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),i="";return e&&(i=ut(e)?e.checked?"true":"false":e.value),(e=i)!==n&&(t.setValue(e),!0)}function pt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var ft=/[\n"\\]/g;function mt(e){return e.replace(ft,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function gt(e,t,n,i,r,s,a,o){e.name="",null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&"boolean"!=typeof a?e.type=a:e.removeAttribute("type"),null!=t?"number"===a?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ct(t)):e.value!==""+ct(t)&&(e.value=""+ct(t)):"submit"!==a&&"reset"!==a||e.removeAttribute("value"),null!=t?yt(e,a,ct(t)):null!=n?yt(e,a,ct(n)):null!=i&&e.removeAttribute("value"),null==r&&null!=s&&(e.defaultChecked=!!s),null!=r&&(e.checked=r&&"function"!=typeof r&&"symbol"!=typeof r),null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.name=""+ct(o):e.removeAttribute("name")}function vt(e,t,n,i,r,s,a,o){if(null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s&&(e.type=s),null!=t||null!=n){if(("submit"===s||"reset"===s)&&null==t)return void ht(e);n=null!=n?""+ct(n):"",t=null!=t?""+ct(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}i="function"!=typeof(i=null!=i?i:r)&&"symbol"!=typeof i&&!!i,e.checked=o?e.checked:!!i,e.defaultChecked=!!i,null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&"boolean"!=typeof a&&(e.name=a),ht(e)}function yt(e,t,n){"number"===t&&pt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function xt(e,t,n,i){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&i&&(e[n].defaultSelected=!0)}else{for(n=""+ct(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(i&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function bt(e,t,n){null==t||((t=""+ct(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ct(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function _t(e,t,n,r){if(null==t){if(null!=r){if(null!=n)throw Error(i(92));if(I(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}null==n&&(n=""),t=n}n=ct(t),e.defaultValue=n,(r=e.textContent)===n&&""!==r&&null!==r&&(e.value=r),ht(e)}function wt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var St=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 Mt(e,t,n){var i=0===t.indexOf("--");null==n||"boolean"==typeof n||""===n?i?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":i?e.setProperty(t,n):"number"!=typeof n||0===n||St.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Tt(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(i(62));if(e=e.style,null!=n){for(var r in n)!n.hasOwnProperty(r)||null!=t&&t.hasOwnProperty(r)||(0===r.indexOf("--")?e.setProperty(r,""):"float"===r?e.cssFloat="":e[r]="");for(var s in t)r=t[s],t.hasOwnProperty(s)&&n[s]!==r&&Mt(e,s,r)}else for(var a in t)t.hasOwnProperty(a)&&Mt(e,a,t[a])}function Et(e){if(-1===e.indexOf("-"))return!1;switch(e){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 At=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"]]),Rt=/^[\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 Ct(e){return Rt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Pt(){}var It=null;function Lt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Dt=null,Nt=null;function Ot(e){var t=Ye(e);if(t&&(e=t.stateNode)){var n=e[Be]||null;e:switch(e=t.stateNode,t.type){case"input":if(gt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+mt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=r[Be]||null;if(!s)throw Error(i(90));gt(r,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name)}}for(t=0;t<n.length;t++)(r=n[t]).form===e.form&&dt(r)}break e;case"textarea":bt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&xt(e,!!n.multiple,t,!1)}}}var Ft=!1;function kt(e,t,n){if(Ft)return e(t,n);Ft=!0;try{return e(t)}finally{if(Ft=!1,(null!==Dt||null!==Nt)&&(Zc(),Dt&&(t=Dt,e=Nt,Nt=Dt=null,Ot(t),e)))for(t=0;t<e.length;t++)Ot(e[t])}}function Ut(e,t){var n=e.stateNode;if(null===n)return null;var r=n[Be]||null;if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(i(231,t,typeof n));return n}var zt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Bt=!1;if(zt)try{var Vt={};Object.defineProperty(Vt,"passive",{get:function(){Bt=!0}}),window.addEventListener("test",Vt,Vt),window.removeEventListener("test",Vt,Vt)}catch(e){Bt=!1}var Gt=null,Ht=null,Wt=null;function jt(){if(Wt)return Wt;var e,t,n=Ht,i=n.length,r="value"in Gt?Gt.value:Gt.textContent,s=r.length;for(e=0;e<i&&n[e]===r[e];e++);var a=i-e;for(t=1;t<=a&&n[i-t]===r[s-t];t++);return Wt=r.slice(e,1<t?1-t:void 0)}function Xt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function qt(){return!0}function $t(){return!1}function Yt(e){function t(t,n,i,r,s){for(var a in this._reactName=t,this._targetInst=i,this.type=n,this.nativeEvent=r,this.target=s,this.currentTarget=null,e)e.hasOwnProperty(a)&&(t=e[a],this[a]=t?t(r):r[a]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?qt:$t,this.isPropagationStopped=$t,this}return h(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=qt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=qt)},persist:function(){},isPersistent:qt}),t}var Kt,Zt,Jt,Qt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},en=Yt(Qt),tn=h({},Qt,{view:0,detail:0}),nn=Yt(tn),rn=h({},tn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Jt&&(Jt&&"mousemove"===e.type?(Kt=e.screenX-Jt.screenX,Zt=e.screenY-Jt.screenY):Zt=Kt=0,Jt=e),Kt)},movementY:function(e){return"movementY"in e?e.movementY:Zt}}),sn=Yt(rn),an=Yt(h({},rn,{dataTransfer:0})),on=Yt(h({},tn,{relatedTarget:0})),ln=Yt(h({},Qt,{animationName:0,elapsedTime:0,pseudoElement:0})),cn=Yt(h({},Qt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),un=Yt(h({},Qt,{data:0})),hn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dn={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"},pn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=pn[e])&&!!t[e]}function mn(){return fn}var gn=Yt(h({},tn,{key:function(e){if(e.key){var t=hn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Xt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?dn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mn,charCode:function(e){return"keypress"===e.type?Xt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Xt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),vn=Yt(h({},rn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),yn=Yt(h({},tn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mn})),xn=Yt(h({},Qt,{propertyName:0,elapsedTime:0,pseudoElement:0})),bn=Yt(h({},rn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),_n=Yt(h({},Qt,{newState:0,oldState:0})),wn=[9,13,27,32],Sn=zt&&"CompositionEvent"in window,Mn=null;zt&&"documentMode"in document&&(Mn=document.documentMode);var Tn=zt&&"TextEvent"in window&&!Mn,En=zt&&(!Sn||Mn&&8<Mn&&11>=Mn),An=String.fromCharCode(32),Rn=!1;function Cn(e,t){switch(e){case"keyup":return-1!==wn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var In=!1,Ln={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 Dn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Ln[e.type]:"textarea"===t}function Nn(e,t,n,i){Dt?Nt?Nt.push(i):Nt=[i]:Dt=i,0<(t=th(t,"onChange")).length&&(n=new en("onChange","change",null,n,i),e.push({event:n,listeners:t}))}var On=null,Fn=null;function kn(e){qu(e,0)}function Un(e){if(dt(Ke(e)))return e}function zn(e,t){if("change"===e)return t}var Bn=!1;if(zt){var Vn;if(zt){var Gn="oninput"in document;if(!Gn){var Hn=document.createElement("div");Hn.setAttribute("oninput","return;"),Gn="function"==typeof Hn.oninput}Vn=Gn}else Vn=!1;Bn=Vn&&(!document.documentMode||9<document.documentMode)}function Wn(){On&&(On.detachEvent("onpropertychange",jn),Fn=On=null)}function jn(e){if("value"===e.propertyName&&Un(Fn)){var t=[];Nn(t,Fn,e,Lt(e)),kt(kn,t)}}function Xn(e,t,n){"focusin"===e?(Wn(),Fn=n,(On=t).attachEvent("onpropertychange",jn)):"focusout"===e&&Wn()}function qn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Un(Fn)}function $n(e,t){if("click"===e)return Un(t)}function Yn(e,t){if("input"===e||"change"===e)return Un(t)}var Kn="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function Zn(e,t){if(Kn(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!te.call(t,r)||!Kn(e[r],t[r]))return!1}return!0}function Jn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Qn(e,t){var n,i=Jn(e);for(e=0;i;){if(3===i.nodeType){if(n=e+i.textContent.length,e<=t&&n>=t)return{node:i,offset:t-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Jn(i)}}function ei(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?ei(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ti(e){for(var t=pt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=pt((e=t.contentWindow).document)}return t}function ni(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var ii=zt&&"documentMode"in document&&11>=document.documentMode,ri=null,si=null,ai=null,oi=!1;function li(e,t,n){var i=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;oi||null==ri||ri!==pt(i)||(i="selectionStart"in(i=ri)&&ni(i)?{start:i.selectionStart,end:i.selectionEnd}:{anchorNode:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset},ai&&Zn(ai,i)||(ai=i,0<(i=th(si,"onSelect")).length&&(t=new en("onSelect","select",null,t,n),e.push({event:t,listeners:i}),t.target=ri)))}function ci(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ui={animationend:ci("Animation","AnimationEnd"),animationiteration:ci("Animation","AnimationIteration"),animationstart:ci("Animation","AnimationStart"),transitionrun:ci("Transition","TransitionRun"),transitionstart:ci("Transition","TransitionStart"),transitioncancel:ci("Transition","TransitionCancel"),transitionend:ci("Transition","TransitionEnd")},hi={},di={};function pi(e){if(hi[e])return hi[e];if(!ui[e])return e;var t,n=ui[e];for(t in n)if(n.hasOwnProperty(t)&&t in di)return hi[e]=n[t];return e}zt&&(di=document.createElement("div").style,"AnimationEvent"in window||(delete ui.animationend.animation,delete ui.animationiteration.animation,delete ui.animationstart.animation),"TransitionEvent"in window||delete ui.transitionend.transition);var fi=pi("animationend"),mi=pi("animationiteration"),gi=pi("animationstart"),vi=pi("transitionrun"),yi=pi("transitionstart"),xi=pi("transitioncancel"),bi=pi("transitionend"),_i=new Map,wi="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(" ");function Si(e,t){_i.set(e,t),tt(t,[e])}wi.push("scrollEnd");var Mi="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},Ti=[],Ei=0,Ai=0;function Ri(){for(var e=Ei,t=Ai=Ei=0;t<e;){var n=Ti[t];Ti[t++]=null;var i=Ti[t];Ti[t++]=null;var r=Ti[t];Ti[t++]=null;var s=Ti[t];if(Ti[t++]=null,null!==i&&null!==r){var a=i.pending;null===a?r.next=r:(r.next=a.next,a.next=r),i.pending=r}0!==s&&Li(n,r,s)}}function Ci(e,t,n,i){Ti[Ei++]=e,Ti[Ei++]=t,Ti[Ei++]=n,Ti[Ei++]=i,Ai|=i,e.lanes|=i,null!==(e=e.alternate)&&(e.lanes|=i)}function Pi(e,t,n,i){return Ci(e,t,n,i),Di(e)}function Ii(e,t){return Ci(e,null,null,t),Di(e)}function Li(e,t,n){e.lanes|=n;var i=e.alternate;null!==i&&(i.lanes|=n);for(var r=!1,s=e.return;null!==s;)s.childLanes|=n,null!==(i=s.alternate)&&(i.childLanes|=n),22===s.tag&&(null===(e=s.stateNode)||1&e._visibility||(r=!0)),e=s,s=s.return;return 3===e.tag?(s=e.stateNode,r&&null!==t&&(r=31-ye(n),null===(i=(e=s.hiddenUpdates)[r])?e[r]=[t]:i.push(t),t.lane=536870912|n),s):null}function Di(e){if(50<Gc)throw Gc=0,Hc=null,Error(i(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Ni={};function Oi(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,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 Fi(e,t,n,i){return new Oi(e,t,n,i)}function ki(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Ui(e,t){var n=e.alternate;return null===n?((n=Fi(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function zi(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Bi(e,t,n,r,s,a){var o=0;if(r=e,"function"==typeof e)ki(e)&&(o=1);else if("string"==typeof e)o=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,G.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case T:return(e=Fi(31,n,t,s)).elementType=T,e.lanes=a,e;case m:return Vi(n.children,s,a,t);case g:o=8,s|=24;break;case v:return(e=Fi(12,n,t,2|s)).elementType=v,e.lanes=a,e;case _:return(e=Fi(13,n,t,s)).elementType=_,e.lanes=a,e;case w:return(e=Fi(19,n,t,s)).elementType=w,e.lanes=a,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case x:o=10;break e;case y:o=9;break e;case b:o=11;break e;case S:o=14;break e;case M:o=16,r=null;break e}o=29,n=Error(i(130,null===e?"null":typeof e,"")),r=null}return(t=Fi(o,n,t,s)).elementType=e,t.type=r,t.lanes=a,t}function Vi(e,t,n,i){return(e=Fi(7,e,i,t)).lanes=n,e}function Gi(e,t,n){return(e=Fi(6,e,null,t)).lanes=n,e}function Hi(e){var t=Fi(18,null,null,0);return t.stateNode=e,t}function Wi(e,t,n){return(t=Fi(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ji=new WeakMap;function Xi(e,t){if("object"==typeof e&&null!==e){var n=ji.get(e);return void 0!==n?n:(t={value:e,source:t,stack:ee(t)},ji.set(e,t),t)}return{value:e,source:t,stack:ee(t)}}var qi=[],$i=0,Yi=null,Ki=0,Zi=[],Ji=0,Qi=null,er=1,tr="";function nr(e,t){qi[$i++]=Ki,qi[$i++]=Yi,Yi=e,Ki=t}function ir(e,t,n){Zi[Ji++]=er,Zi[Ji++]=tr,Zi[Ji++]=Qi,Qi=e;var i=er;e=tr;var r=32-ye(i)-1;i&=~(1<<r),n+=1;var s=32-ye(t)+r;if(30<s){var a=r-r%5;s=(i&(1<<a)-1).toString(32),i>>=a,r-=a,er=1<<32-ye(t)+r|n<<r|i,tr=s+e}else er=1<<s|n<<r|i,tr=e}function rr(e){null!==e.return&&(nr(e,1),ir(e,1,0))}function sr(e){for(;e===Yi;)Yi=qi[--$i],qi[$i]=null,Ki=qi[--$i],qi[$i]=null;for(;e===Qi;)Qi=Zi[--Ji],Zi[Ji]=null,tr=Zi[--Ji],Zi[Ji]=null,er=Zi[--Ji],Zi[Ji]=null}function ar(e,t){Zi[Ji++]=er,Zi[Ji++]=tr,Zi[Ji++]=Qi,er=t.id,tr=t.overflow,Qi=e}var or=null,lr=null,cr=!1,ur=null,hr=!1,dr=Error(i(519));function pr(e){throw xr(Xi(Error(i(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),dr}function fr(e){var t=e.stateNode,n=e.type,i=e.memoizedProps;switch(t[ze]=e,t[Be]=i,n){case"dialog":$u("cancel",t),$u("close",t);break;case"iframe":case"object":case"embed":$u("load",t);break;case"video":case"audio":for(n=0;n<ju.length;n++)$u(ju[n],t);break;case"source":$u("error",t);break;case"img":case"image":case"link":$u("error",t),$u("load",t);break;case"details":$u("toggle",t);break;case"input":$u("invalid",t),vt(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":$u("invalid",t);break;case"textarea":$u("invalid",t),_t(t,i.value,i.defaultValue,i.children)}"string"!=typeof(n=i.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===i.suppressHydrationWarning||oh(t.textContent,n)?(null!=i.popover&&($u("beforetoggle",t),$u("toggle",t)),null!=i.onScroll&&$u("scroll",t),null!=i.onScrollEnd&&$u("scrollend",t),null!=i.onClick&&(t.onclick=Pt),t=!0):t=!1,t||pr(e,!0)}function mr(e){for(or=e.return;or;)switch(or.tag){case 5:case 31:case 13:return void(hr=!1);case 27:case 3:return void(hr=!0);default:or=or.return}}function gr(e){if(e!==or)return!1;if(!cr)return mr(e),cr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||vh(e.type,e.memoizedProps)),t=!t),t&&lr&&pr(e),mr(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dh(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dh(e)}else 27===n?(n=lr,Mh(e.type)?(e=Lh,Lh=null,lr=e):lr=n):lr=or?Ih(e.stateNode.nextSibling):null;return!0}function vr(){lr=or=null,cr=!1}function yr(){var e=ur;return null!==e&&(null===Rc?Rc=e:Rc.push.apply(Rc,e),ur=null),e}function xr(e){null===ur?ur=[e]:ur.push(e)}var br=k(null),_r=null,wr=null;function Sr(e,t,n){z(br,t._currentValue),t._currentValue=n}function Mr(e){e._currentValue=br.current,U(br)}function Tr(e,t,n){for(;null!==e;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==i&&(i.childLanes|=t)):null!==i&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===n)break;e=e.return}}function Er(e,t,n,r){var s=e.child;for(null!==s&&(s.return=e);null!==s;){var a=s.dependencies;if(null!==a){var o=s.child;a=a.firstContext;e:for(;null!==a;){var l=a;a=s;for(var c=0;c<t.length;c++)if(l.context===t[c]){a.lanes|=n,null!==(l=a.alternate)&&(l.lanes|=n),Tr(a.return,n,e),r||(o=null);break e}a=l.next}}else if(18===s.tag){if(null===(o=s.return))throw Error(i(341));o.lanes|=n,null!==(a=o.alternate)&&(a.lanes|=n),Tr(o,n,e),o=null}else o=s.child;if(null!==o)o.return=s;else for(o=s;null!==o;){if(o===e){o=null;break}if(null!==(s=o.sibling)){s.return=o.return,o=s;break}o=o.return}s=o}}function Ar(e,t,n,r){e=null;for(var s=t,a=!1;null!==s;){if(!a)if(524288&s.flags)a=!0;else if(262144&s.flags)break;if(10===s.tag){var o=s.alternate;if(null===o)throw Error(i(387));if(null!==(o=o.memoizedProps)){var l=s.type;Kn(s.pendingProps.value,o.value)||(null!==e?e.push(l):e=[l])}}else if(s===j.current){if(null===(o=s.alternate))throw Error(i(387));o.memoizedState.memoizedState!==s.memoizedState.memoizedState&&(null!==e?e.push(ld):e=[ld])}s=s.return}null!==e&&Er(t,e,n,r),t.flags|=262144}function Rr(e){for(e=e.firstContext;null!==e;){if(!Kn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Cr(e){_r=e,wr=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Pr(e){return Lr(_r,e)}function Ir(e,t){return null===_r&&Cr(e),Lr(e,t)}function Lr(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===wr){if(null===e)throw Error(i(308));wr=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wr=wr.next=t;return n}var Dr="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Nr=e.unstable_scheduleCallback,Or=e.unstable_NormalPriority,Fr={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function kr(){return{controller:new Dr,data:new Map,refCount:0}}function Ur(e){e.refCount--,0===e.refCount&&Nr(Or,function(){e.controller.abort()})}var zr=null,Br=0,Vr=0,Gr=null;function Hr(){if(0===--Br&&null!==zr){null!==Gr&&(Gr.status="fulfilled");var e=zr;zr=null,Vr=0,Gr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Wr=L.S;L.S=function(e,t){Ic=ae(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===zr){var n=zr=[];Br=0,Vr=Bu(),Gr={status:"pending",value:void 0,then:function(e){n.push(e)}}}Br++,t.then(Hr,Hr)}(0,t),null!==Wr&&Wr(e,t)};var jr=k(null);function Xr(){var e=jr.current;return null!==e?e:dc.pooledCache}function qr(e,t){z(jr,null===t?jr.current:t.pool)}function $r(){var e=Xr();return null===e?null:{parent:Fr._currentValue,pool:e}}var Yr=Error(i(460)),Kr=Error(i(474)),Zr=Error(i(542)),Jr={then:function(){}};function Qr(e){return"fulfilled"===(e=e.status)||"rejected"===e}function es(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Pt,Pt),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw rs(e=t.reason),e;default:if("string"==typeof t.status)t.then(Pt,Pt);else{if(null!==(e=dc)&&100<e.shellSuspendCounter)throw Error(i(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw rs(e=t.reason),e}throw ns=t,Yr}}function ts(e){try{return(0,e._init)(e._payload)}catch(e){if(null!==e&&"object"==typeof e&&"function"==typeof e.then)throw ns=e,Yr;throw e}}var ns=null;function is(){if(null===ns)throw Error(i(459));var e=ns;return ns=null,e}function rs(e){if(e===Yr||e===Zr)throw Error(i(483))}var ss=null,as=0;function os(e){var t=as;return as+=1,null===ss&&(ss=[]),es(ss,e,t)}function ls(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function cs(e,t){if(t.$$typeof===d)throw Error(i(525));throw e=Object.prototype.toString.call(t),Error(i(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function us(e){function t(t,n){if(e){var i=t.deletions;null===i?(t.deletions=[n],t.flags|=16):i.push(n)}}function n(n,i){if(!e)return null;for(;null!==i;)t(n,i),i=i.sibling;return null}function r(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function s(e,t){return(e=Ui(e,t)).index=0,e.sibling=null,e}function a(t,n,i){return t.index=i,e?null!==(i=t.alternate)?(i=i.index)<n?(t.flags|=67108866,n):i:(t.flags|=67108866,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,i){return null===t||6!==t.tag?((t=Gi(n,e.mode,i)).return=e,t):((t=s(t,n)).return=e,t)}function c(e,t,n,i){var r=n.type;return r===m?h(e,t,n.props.children,i,n.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===M&&ts(r)===t.type)?(ls(t=s(t,n.props),n),t.return=e,t):(ls(t=Bi(n.type,n.key,n.props,null,e.mode,i),n),t.return=e,t)}function u(e,t,n,i){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Wi(n,e.mode,i)).return=e,t):((t=s(t,n.children||[])).return=e,t)}function h(e,t,n,i,r){return null===t||7!==t.tag?((t=Vi(n,e.mode,i,r)).return=e,t):((t=s(t,n)).return=e,t)}function d(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Gi(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case p:return ls(n=Bi(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case f:return(t=Wi(t,e.mode,n)).return=e,t;case M:return d(e,t=ts(t),n)}if(I(t)||R(t))return(t=Vi(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return d(e,os(t),n);if(t.$$typeof===x)return d(e,Ir(e,t),n);cs(e,t)}return null}function g(e,t,n,i){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==r?null:l(e,t,""+n,i);if("object"==typeof n&&null!==n){switch(n.$$typeof){case p:return n.key===r?c(e,t,n,i):null;case f:return n.key===r?u(e,t,n,i):null;case M:return g(e,t,n=ts(n),i)}if(I(n)||R(n))return null!==r?null:h(e,t,n,i,null);if("function"==typeof n.then)return g(e,t,os(n),i);if(n.$$typeof===x)return g(e,t,Ir(e,n),i);cs(e,n)}return null}function v(e,t,n,i,r){if("string"==typeof i&&""!==i||"number"==typeof i||"bigint"==typeof i)return l(t,e=e.get(n)||null,""+i,r);if("object"==typeof i&&null!==i){switch(i.$$typeof){case p:return c(t,e=e.get(null===i.key?n:i.key)||null,i,r);case f:return u(t,e=e.get(null===i.key?n:i.key)||null,i,r);case M:return v(e,t,n,i=ts(i),r)}if(I(i)||R(i))return h(t,e=e.get(n)||null,i,r,null);if("function"==typeof i.then)return v(e,t,n,os(i),r);if(i.$$typeof===x)return v(e,t,n,Ir(t,i),r);cs(t,i)}return null}function y(l,c,u,h){if("object"==typeof u&&null!==u&&u.type===m&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case p:e:{for(var b=u.key;null!==c;){if(c.key===b){if((b=u.type)===m){if(7===c.tag){n(l,c.sibling),(h=s(c,u.props.children)).return=l,l=h;break e}}else if(c.elementType===b||"object"==typeof b&&null!==b&&b.$$typeof===M&&ts(b)===c.type){n(l,c.sibling),ls(h=s(c,u.props),u),h.return=l,l=h;break e}n(l,c);break}t(l,c),c=c.sibling}u.type===m?((h=Vi(u.props.children,l.mode,h,u.key)).return=l,l=h):(ls(h=Bi(u.type,u.key,u.props,null,l.mode,h),u),h.return=l,l=h)}return o(l);case f:e:{for(b=u.key;null!==c;){if(c.key===b){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){n(l,c.sibling),(h=s(c,u.children||[])).return=l,l=h;break e}n(l,c);break}t(l,c),c=c.sibling}(h=Wi(u,l.mode,h)).return=l,l=h}return o(l);case M:return y(l,c,u=ts(u),h)}if(I(u))return function(i,s,o,l){for(var c=null,u=null,h=s,p=s=0,f=null;null!==h&&p<o.length;p++){h.index>p?(f=h,h=null):f=h.sibling;var m=g(i,h,o[p],l);if(null===m){null===h&&(h=f);break}e&&h&&null===m.alternate&&t(i,h),s=a(m,s,p),null===u?c=m:u.sibling=m,u=m,h=f}if(p===o.length)return n(i,h),cr&&nr(i,p),c;if(null===h){for(;p<o.length;p++)null!==(h=d(i,o[p],l))&&(s=a(h,s,p),null===u?c=h:u.sibling=h,u=h);return cr&&nr(i,p),c}for(h=r(h);p<o.length;p++)null!==(f=v(h,i,p,o[p],l))&&(e&&null!==f.alternate&&h.delete(null===f.key?p:f.key),s=a(f,s,p),null===u?c=f:u.sibling=f,u=f);return e&&h.forEach(function(e){return t(i,e)}),cr&&nr(i,p),c}(l,c,u,h);if(R(u)){if("function"!=typeof(b=R(u)))throw Error(i(150));return function(s,o,l,c){if(null==l)throw Error(i(151));for(var u=null,h=null,p=o,f=o=0,m=null,y=l.next();null!==p&&!y.done;f++,y=l.next()){p.index>f?(m=p,p=null):m=p.sibling;var x=g(s,p,y.value,c);if(null===x){null===p&&(p=m);break}e&&p&&null===x.alternate&&t(s,p),o=a(x,o,f),null===h?u=x:h.sibling=x,h=x,p=m}if(y.done)return n(s,p),cr&&nr(s,f),u;if(null===p){for(;!y.done;f++,y=l.next())null!==(y=d(s,y.value,c))&&(o=a(y,o,f),null===h?u=y:h.sibling=y,h=y);return cr&&nr(s,f),u}for(p=r(p);!y.done;f++,y=l.next())null!==(y=v(p,s,f,y.value,c))&&(e&&null!==y.alternate&&p.delete(null===y.key?f:y.key),o=a(y,o,f),null===h?u=y:h.sibling=y,h=y);return e&&p.forEach(function(e){return t(s,e)}),cr&&nr(s,f),u}(l,c,u=b.call(u),h)}if("function"==typeof u.then)return y(l,c,os(u),h);if(u.$$typeof===x)return y(l,c,Ir(l,u),h);cs(l,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(l,c.sibling),(h=s(c,u)).return=l,l=h):(n(l,c),(h=Gi(u,l.mode,h)).return=l,l=h),o(l)):n(l,c)}return function(e,t,n,i){try{as=0;var r=y(e,t,n,i);return ss=null,r}catch(t){if(t===Yr||t===Zr)throw t;var s=Fi(29,t,null,e.mode);return s.lanes=i,s.return=e,s}}}var hs=us(!0),ds=us(!1),ps=!1;function fs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ms(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function gs(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function vs(e,t,n){var i=e.updateQueue;if(null===i)return null;if(i=i.shared,2&hc){var r=i.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=Di(e),Li(e,null,n),t}return Ci(e,i,t,n),Di(e)}function ys(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Le(e,n)}}function xs(e,t){var n=e.updateQueue,i=e.alternate;if(null!==i&&n===(i=i.updateQueue)){var r=null,s=null;if(null!==(n=n.firstBaseUpdate)){do{var a={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===s?r=s=a:s=s.next=a,n=n.next}while(null!==n);null===s?r=s=t:s=s.next=t}else r=s=t;return n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:i.shared,callbacks:i.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bs=!1;function _s(){if(bs&&null!==Gr)throw Gr}function ws(e,t,n,i){bs=!1;var r=e.updateQueue;ps=!1;var s=r.firstBaseUpdate,a=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var l=o,c=l.next;l.next=null,null===a?s=c:a.next=c,a=l;var u=e.alternate;null!==u&&(o=(u=u.updateQueue).lastBaseUpdate)!==a&&(null===o?u.firstBaseUpdate=c:o.next=c,u.lastBaseUpdate=l)}if(null!==s){var d=r.baseState;for(a=0,u=c=l=null,o=s;;){var p=-536870913&o.lane,f=p!==o.lane;if(f?(fc&p)===p:(i&p)===p){0!==p&&p===Vr&&(bs=!0),null!==u&&(u=u.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var m=e,g=o;p=t;var v=n;switch(g.tag){case 1:if("function"==typeof(m=g.payload)){d=m.call(v,d,p);break e}d=m;break e;case 3:m.flags=-65537&m.flags|128;case 0:if(null==(p="function"==typeof(m=g.payload)?m.call(v,d,p):m))break e;d=h({},d,p);break e;case 2:ps=!0}}null!==(p=o.callback)&&(e.flags|=64,f&&(e.flags|=8192),null===(f=r.callbacks)?r.callbacks=[p]:f.push(p))}else f={lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===u?(c=u=f,l=d):u=u.next=f,a|=p;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(f=o).next,f.next=null,r.lastBaseUpdate=f,r.shared.pending=null}}null===u&&(l=d),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=u,null===s&&(r.shared.lanes=0),wc|=a,e.lanes=a,e.memoizedState=d}}function Ss(e,t){if("function"!=typeof e)throw Error(i(191,e));e.call(t)}function Ms(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)Ss(n[e],t)}var Ts=k(null),Es=k(0);function As(e,t){z(Es,e=bc),z(Ts,t),bc=e|t.baseLanes}function Rs(){z(Es,bc),z(Ts,Ts.current)}function Cs(){bc=Es.current,U(Ts),U(Es)}var Ps=k(null),Is=null;function Ls(e){var t=e.alternate;z(ks,1&ks.current),z(Ps,e),null===Is&&(null===t||null!==Ts.current||null!==t.memoizedState)&&(Is=e)}function Ds(e){z(ks,ks.current),z(Ps,e),null===Is&&(Is=e)}function Ns(e){22===e.tag?(z(ks,ks.current),z(Ps,e),null===Is&&(Is=e)):Os()}function Os(){z(ks,ks.current),z(Ps,Ps.current)}function Fs(e){U(Ps),Is===e&&(Is=null),U(ks)}var ks=k(0);function Us(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Ch(n)||Ph(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var zs=0,Bs=null,Vs=null,Gs=null,Hs=!1,Ws=!1,js=!1,Xs=0,qs=0,$s=null,Ys=0;function Ks(){throw Error(i(321))}function Zs(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Kn(e[n],t[n]))return!1;return!0}function Js(e,t,n,i,r,s){return zs=s,Bs=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,L.H=null===e||null===e.memoizedState?fo:mo,js=!1,s=n(i,r),js=!1,Ws&&(s=ea(t,n,i,r)),Qs(e),s}function Qs(e){L.H=po;var t=null!==Vs&&null!==Vs.next;if(zs=0,Gs=Vs=Bs=null,Hs=!1,qs=0,$s=null,t)throw Error(i(300));null===e||Io||null!==(e=e.dependencies)&&Rr(e)&&(Io=!0)}function ea(e,t,n,r){Bs=e;var s=0;do{if(Ws&&($s=null),qs=0,Ws=!1,25<=s)throw Error(i(301));if(s+=1,Gs=Vs=null,null!=e.updateQueue){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,null!=a.memoCache&&(a.memoCache.index=0)}L.H=go,a=t(n,r)}while(Ws);return a}function ta(){var e=L.H,t=e.useState()[0];return t="function"==typeof t.then?oa(t):t,e=e.useState()[0],(null!==Vs?Vs.memoizedState:null)!==e&&(Bs.flags|=1024),t}function na(){var e=0!==Xs;return Xs=0,e}function ia(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function ra(e){if(Hs){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Hs=!1}zs=0,Gs=Vs=Bs=null,Ws=!1,qs=Xs=0,$s=null}function sa(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Gs?Bs.memoizedState=Gs=e:Gs=Gs.next=e,Gs}function aa(){if(null===Vs){var e=Bs.alternate;e=null!==e?e.memoizedState:null}else e=Vs.next;var t=null===Gs?Bs.memoizedState:Gs.next;if(null!==t)Gs=t,Vs=e;else{if(null===e){if(null===Bs.alternate)throw Error(i(467));throw Error(i(310))}e={memoizedState:(Vs=e).memoizedState,baseState:Vs.baseState,baseQueue:Vs.baseQueue,queue:Vs.queue,next:null},null===Gs?Bs.memoizedState=Gs=e:Gs=Gs.next=e}return Gs}function oa(e){var t=qs;return qs+=1,null===$s&&($s=[]),e=es($s,e,t),t=Bs,null===(null===Gs?t.memoizedState:Gs.next)&&(t=t.alternate,L.H=null===t||null===t.memoizedState?fo:mo),e}function la(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return oa(e);if(e.$$typeof===x)return Pr(e)}throw Error(i(438,String(e)))}function ca(e){var t=null,n=Bs.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var i=Bs.alternate;null!==i&&null!==(i=i.updateQueue)&&null!=(i=i.memoCache)&&(t={data:i.data.map(function(e){return e.slice()}),index:0})}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},Bs.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),i=0;i<e;i++)n[i]=E;return t.index++,n}function ua(e,t){return"function"==typeof t?t(e):t}function ha(e){return da(aa(),Vs,e)}function da(e,t,n){var r=e.queue;if(null===r)throw Error(i(311));r.lastRenderedReducer=n;var s=e.baseQueue,a=r.pending;if(null!==a){if(null!==s){var o=s.next;s.next=a.next,a.next=o}t.baseQueue=s=a,r.pending=null}if(a=e.baseState,null===s)e.memoizedState=a;else{var l=o=null,c=null,u=t=s.next,h=!1;do{var d=-536870913&u.lane;if(d!==u.lane?(fc&d)===d:(zs&d)===d){var p=u.revertLane;if(0===p)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),d===Vr&&(h=!0);else{if((zs&p)===p){u=u.next,p===Vr&&(h=!0);continue}d={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=d,o=a):c=c.next=d,Bs.lanes|=p,wc|=p}d=u.action,js&&n(a,d),a=u.hasEagerState?u.eagerState:n(a,d)}else p={lane:d,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=p,o=a):c=c.next=p,Bs.lanes|=d,wc|=d;u=u.next}while(null!==u&&u!==t);if(null===c?o=a:c.next=l,!Kn(a,e.memoizedState)&&(Io=!0,h&&null!==(n=Gr)))throw n;e.memoizedState=a,e.baseState=o,e.baseQueue=c,r.lastRenderedState=a}return null===s&&(r.lanes=0),[e.memoizedState,r.dispatch]}function pa(e){var t=aa(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,a=t.memoizedState;if(null!==s){n.pending=null;var o=s=s.next;do{a=e(a,o.action),o=o.next}while(o!==s);Kn(a,t.memoizedState)||(Io=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function fa(e,t,n){var r=Bs,s=aa(),a=cr;if(a){if(void 0===n)throw Error(i(407));n=n()}else n=t();var o=!Kn((Vs||s).memoizedState,n);if(o&&(s.memoizedState=n,Io=!0),s=s.queue,za(va.bind(null,r,s,e),[e]),s.getSnapshot!==t||o||null!==Gs&&1&Gs.memoizedState.tag){if(r.flags|=2048,Na(9,{destroy:void 0},ga.bind(null,r,s,n,t),null),null===dc)throw Error(i(349));a||127&zs||ma(r,t,n)}return n}function ma(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Bs.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Bs.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function ga(e,t,n,i){t.value=n,t.getSnapshot=i,ya(t)&&xa(e)}function va(e,t,n){return n(function(){ya(t)&&xa(e)})}function ya(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Kn(e,n)}catch(e){return!0}}function xa(e){var t=Ii(e,2);null!==t&&Xc(t,e,2)}function ba(e){var t=sa();if("function"==typeof e){var n=e;if(e=n(),js){ve(!0);try{n()}finally{ve(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ua,lastRenderedState:e},t}function _a(e,t,n,i){return e.baseState=n,da(e,Vs,"function"==typeof i?i:ua)}function wa(e,t,n,r,s){if(co(e))throw Error(i(485));if(null!==(e=t.action)){var a={payload:s,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};null!==L.T?n(!0):a.isTransition=!1,r(a),null===(n=t.pending)?(a.next=t.pending=a,Sa(t,a)):(a.next=n.next,t.pending=n.next=a)}}function Sa(e,t){var n=t.action,i=t.payload,r=e.state;if(t.isTransition){var s=L.T,a={};L.T=a;try{var o=n(r,i),l=L.S;null!==l&&l(a,o),Ma(e,t,o)}catch(n){Ea(e,t,n)}finally{null!==s&&null!==a.types&&(s.types=a.types),L.T=s}}else try{Ma(e,t,s=n(r,i))}catch(n){Ea(e,t,n)}}function Ma(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){Ta(e,t,n)},function(n){return Ea(e,t,n)}):Ta(e,t,n)}function Ta(e,t,n){t.status="fulfilled",t.value=n,Aa(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,Sa(e,n)))}function Ea(e,t,n){var i=e.pending;if(e.pending=null,null!==i){i=i.next;do{t.status="rejected",t.reason=n,Aa(t),t=t.next}while(t!==i)}e.action=null}function Aa(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ra(e,t){return t}function Ca(e,t){if(cr){var n=dc.formState;if(null!==n){e:{var i=Bs;if(cr){if(lr){t:{for(var r=lr,s=hr;8!==r.nodeType;){if(!s){r=null;break t}if(null===(r=Ih(r.nextSibling))){r=null;break t}}r="F!"===(s=r.data)||"F"===s?r:null}if(r){lr=Ih(r.nextSibling),i="F!"===r.data;break e}}pr(i)}i=!1}i&&(t=n[0])}}return(n=sa()).memoizedState=n.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:t},n.queue=i,n=ao.bind(null,Bs,i),i.dispatch=n,i=ba(!1),s=lo.bind(null,Bs,!1,i.queue),r={state:t,dispatch:null,action:e,pending:null},(i=sa()).queue=r,n=wa.bind(null,Bs,r,s,n),r.dispatch=n,i.memoizedState=e,[t,n,!1]}function Pa(e){return Ia(aa(),Vs,e)}function Ia(e,t,n){if(t=da(e,t,Ra)[0],e=ha(ua)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var i=oa(t)}catch(e){if(e===Yr)throw Zr;throw e}else i=t;var r=(t=aa()).queue,s=r.dispatch;return n!==t.memoizedState&&(Bs.flags|=2048,Na(9,{destroy:void 0},La.bind(null,r,n),null)),[i,s,e]}function La(e,t){e.action=t}function Da(e){var t=aa(),n=Vs;if(null!==n)return Ia(t,n,e);aa(),t=t.memoizedState;var i=(n=aa()).queue.dispatch;return n.memoizedState=e,[t,i,!1]}function Na(e,t,n,i){return e={tag:e,create:n,deps:i,inst:t,next:null},null===(t=Bs.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Bs.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(i=n.next,n.next=e,e.next=i,t.lastEffect=e),e}function Oa(){return aa().memoizedState}function Fa(e,t,n,i){var r=sa();Bs.flags|=e,r.memoizedState=Na(1|t,{destroy:void 0},n,void 0===i?null:i)}function ka(e,t,n,i){var r=aa();i=void 0===i?null:i;var s=r.memoizedState.inst;null!==Vs&&null!==i&&Zs(i,Vs.memoizedState.deps)?r.memoizedState=Na(t,s,n,i):(Bs.flags|=e,r.memoizedState=Na(1|t,s,n,i))}function Ua(e,t){Fa(8390656,8,e,t)}function za(e,t){ka(2048,8,e,t)}function Ba(e){var t=aa().memoizedState;return function(e){Bs.flags|=4;var t=Bs.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Bs.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&hc)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Va(e,t){return ka(4,2,e,t)}function Ga(e,t){return ka(4,4,e,t)}function Ha(e,t){if("function"==typeof t){e=e();var n=t(e);return function(){"function"==typeof n?n():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function Wa(e,t,n){n=null!=n?n.concat([e]):null,ka(4,4,Ha.bind(null,t,e),n)}function ja(){}function Xa(e,t){var n=aa();t=void 0===t?null:t;var i=n.memoizedState;return null!==t&&Zs(t,i[1])?i[0]:(n.memoizedState=[e,t],e)}function qa(e,t){var n=aa();t=void 0===t?null:t;var i=n.memoizedState;if(null!==t&&Zs(t,i[1]))return i[0];if(i=e(),js){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i}function $a(e,t,n){return void 0===n||1073741824&zs&&!(261930&fc)?e.memoizedState=t:(e.memoizedState=n,e=jc(),Bs.lanes|=e,wc|=e,n)}function Ya(e,t,n,i){return Kn(n,t)?n:null!==Ts.current?(e=$a(e,n,i),Kn(e,t)||(Io=!0),e):42&zs&&(!(1073741824&zs)||261930&fc)?(e=jc(),Bs.lanes|=e,wc|=e,t):(Io=!0,e.memoizedState=n)}function Ka(e,t,n,i,r){var s=D.p;D.p=0!==s&&8>s?s:8;var a,o,l,c=L.T,u={};L.T=u,lo(e,!1,t,n);try{var h=r(),d=L.S;if(null!==d&&d(u,h),null!==h&&"object"==typeof h&&"function"==typeof h.then){var p=(a=i,o=[],l={status:"pending",value:null,reason:null,then:function(e){o.push(e)}},h.then(function(){l.status="fulfilled",l.value=a;for(var e=0;e<o.length;e++)(0,o[e])(a)},function(e){for(l.status="rejected",l.reason=e,e=0;e<o.length;e++)(0,o[e])(void 0)}),l);oo(e,t,p,Wc())}else oo(e,t,i,Wc())}catch(n){oo(e,t,{then:function(){},status:"rejected",reason:n},Wc())}finally{D.p=s,null!==c&&null!==u.types&&(c.types=u.types),L.T=c}}function Za(){}function Ja(e,t,n,r){if(5!==e.tag)throw Error(i(476));var s=Qa(e).queue;Ka(e,s,t,N,null===n?Za:function(){return eo(e),n(r)})}function Qa(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:N,baseState:N,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ua,lastRenderedState:N},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ua,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function eo(e){var t=Qa(e);null===t.next&&(t=e.alternate.memoizedState),oo(e,t.next.queue,{},Wc())}function to(){return Pr(ld)}function no(){return aa().memoizedState}function io(){return aa().memoizedState}function ro(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Wc(),i=vs(t,e=gs(n),n);return null!==i&&(Xc(i,t,n),ys(i,t,n)),t={cache:kr()},void(e.payload=t)}t=t.return}}function so(e,t,n){var i=Wc();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},co(e)?uo(t,n):null!==(n=Pi(e,t,n,i))&&(Xc(n,e,i),ho(n,t,i))}function ao(e,t,n){oo(e,t,n,Wc())}function oo(e,t,n,i){var r={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(co(e))uo(t,r);else{var s=e.alternate;if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=s(a,n);if(r.hasEagerState=!0,r.eagerState=o,Kn(o,a))return Ci(e,t,r,0),null===dc&&Ri(),!1}catch(e){}if(null!==(n=Pi(e,t,r,i)))return Xc(n,e,i),ho(n,t,i),!0}return!1}function lo(e,t,n,r){if(r={lane:2,revertLane:Bu(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},co(e)){if(t)throw Error(i(479))}else null!==(t=Pi(e,n,r,2))&&Xc(t,e,2)}function co(e){var t=e.alternate;return e===Bs||null!==t&&t===Bs}function uo(e,t){Ws=Hs=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ho(e,t,n){if(4194048&n){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Le(e,n)}}var po={readContext:Pr,use:la,useCallback:Ks,useContext:Ks,useEffect:Ks,useImperativeHandle:Ks,useLayoutEffect:Ks,useInsertionEffect:Ks,useMemo:Ks,useReducer:Ks,useRef:Ks,useState:Ks,useDebugValue:Ks,useDeferredValue:Ks,useTransition:Ks,useSyncExternalStore:Ks,useId:Ks,useHostTransitionStatus:Ks,useFormState:Ks,useActionState:Ks,useOptimistic:Ks,useMemoCache:Ks,useCacheRefresh:Ks};po.useEffectEvent=Ks;var fo={readContext:Pr,use:la,useCallback:function(e,t){return sa().memoizedState=[e,void 0===t?null:t],e},useContext:Pr,useEffect:Ua,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,Fa(4194308,4,Ha.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fa(4194308,4,e,t)},useInsertionEffect:function(e,t){Fa(4,2,e,t)},useMemo:function(e,t){var n=sa();t=void 0===t?null:t;var i=e();if(js){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=sa();if(void 0!==n){var r=n(t);if(js){ve(!0);try{n(t)}finally{ve(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=so.bind(null,Bs,e),[i.memoizedState,e]},useRef:function(e){return e={current:e},sa().memoizedState=e},useState:function(e){var t=(e=ba(e)).queue,n=ao.bind(null,Bs,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ja,useDeferredValue:function(e,t){return $a(sa(),e,t)},useTransition:function(){var e=ba(!1);return e=Ka.bind(null,Bs,e.queue,!0,!1),sa().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Bs,s=sa();if(cr){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===dc)throw Error(i(349));127&fc||ma(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Ua(va.bind(null,r,a,e),[e]),r.flags|=2048,Na(9,{destroy:void 0},ga.bind(null,r,a,n,t),null),n},useId:function(){var e=sa(),t=dc.identifierPrefix;if(cr){var n=tr;t="_"+t+"R_"+(n=(er&~(1<<32-ye(er)-1)).toString(32)+n),0<(n=Xs++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=Ys++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:to,useFormState:Ca,useActionState:Ca,useOptimistic:function(e){var t=sa();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=lo.bind(null,Bs,!0,n),n.dispatch=t,[e,t]},useMemoCache:ca,useCacheRefresh:function(){return sa().memoizedState=ro.bind(null,Bs)},useEffectEvent:function(e){var t=sa(),n={impl:e};return t.memoizedState=n,function(){if(2&hc)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},mo={readContext:Pr,use:la,useCallback:Xa,useContext:Pr,useEffect:za,useImperativeHandle:Wa,useInsertionEffect:Va,useLayoutEffect:Ga,useMemo:qa,useReducer:ha,useRef:Oa,useState:function(){return ha(ua)},useDebugValue:ja,useDeferredValue:function(e,t){return Ya(aa(),Vs.memoizedState,e,t)},useTransition:function(){var e=ha(ua)[0],t=aa().memoizedState;return["boolean"==typeof e?e:oa(e),t]},useSyncExternalStore:fa,useId:no,useHostTransitionStatus:to,useFormState:Pa,useActionState:Pa,useOptimistic:function(e,t){return _a(aa(),0,e,t)},useMemoCache:ca,useCacheRefresh:io};mo.useEffectEvent=Ba;var go={readContext:Pr,use:la,useCallback:Xa,useContext:Pr,useEffect:za,useImperativeHandle:Wa,useInsertionEffect:Va,useLayoutEffect:Ga,useMemo:qa,useReducer:pa,useRef:Oa,useState:function(){return pa(ua)},useDebugValue:ja,useDeferredValue:function(e,t){var n=aa();return null===Vs?$a(n,e,t):Ya(n,Vs.memoizedState,e,t)},useTransition:function(){var e=pa(ua)[0],t=aa().memoizedState;return["boolean"==typeof e?e:oa(e),t]},useSyncExternalStore:fa,useId:no,useHostTransitionStatus:to,useFormState:Da,useActionState:Da,useOptimistic:function(e,t){var n=aa();return null!==Vs?_a(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:ca,useCacheRefresh:io};function vo(e,t,n,i){n=null==(n=n(i,t=e.memoizedState))?t:h({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}go.useEffectEvent=Ba;var yo={enqueueSetState:function(e,t,n){e=e._reactInternals;var i=Wc(),r=gs(i);r.payload=t,null!=n&&(r.callback=n),null!==(t=vs(e,r,i))&&(Xc(t,e,i),ys(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=Wc(),r=gs(i);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=vs(e,r,i))&&(Xc(t,e,i),ys(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Wc(),i=gs(n);i.tag=2,null!=t&&(i.callback=t),null!==(t=vs(e,i,n))&&(Xc(t,e,n),ys(t,e,n))}};function xo(e,t,n,i,r,s,a){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(i,s,a):!(t.prototype&&t.prototype.isPureReactComponent&&Zn(n,i)&&Zn(r,s))}function bo(e,t,n,i){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,i),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,i),t.state!==e&&yo.enqueueReplaceState(t,t.state,null)}function _o(e,t){var n=t;if("ref"in t)for(var i in n={},t)"ref"!==i&&(n[i]=t[i]);if(e=e.defaultProps)for(var r in n===t&&(n=h({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function wo(e){Mi(e)}function So(e){console.error(e)}function Mo(e){Mi(e)}function To(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Eo(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ao(e,t,n){return(n=gs(n)).tag=3,n.payload={element:null},n.callback=function(){To(e,t)},n}function Ro(e){return(e=gs(e)).tag=3,e}function Co(e,t,n,i){var r=n.type.getDerivedStateFromError;if("function"==typeof r){var s=i.value;e.payload=function(){return r(s)},e.callback=function(){Eo(t,n,i)}}var a=n.stateNode;null!==a&&"function"==typeof a.componentDidCatch&&(e.callback=function(){Eo(t,n,i),"function"!=typeof r&&(null===Nc?Nc=new Set([this]):Nc.add(this));var e=i.stack;this.componentDidCatch(i.value,{componentStack:null!==e?e:""})})}var Po=Error(i(461)),Io=!1;function Lo(e,t,n,i){t.child=null===e?ds(t,null,n,i):hs(t,e.child,n,i)}function Do(e,t,n,i,r){n=n.render;var s=t.ref;if("ref"in i){var a={};for(var o in i)"ref"!==o&&(a[o]=i[o])}else a=i;return Cr(t),i=Js(e,t,n,a,s,r),o=na(),null===e||Io?(cr&&o&&rr(t),t.flags|=1,Lo(e,t,i,r),t.child):(ia(e,t,r),nl(e,t,r))}function No(e,t,n,i,r){if(null===e){var s=n.type;return"function"!=typeof s||ki(s)||void 0!==s.defaultProps||null!==n.compare?((e=Bi(n.type,null,i,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,Oo(e,t,s,i,r))}if(s=e.child,!il(e,r)){var a=s.memoizedProps;if((n=null!==(n=n.compare)?n:Zn)(a,i)&&e.ref===t.ref)return nl(e,t,r)}return t.flags|=1,(e=Ui(s,i)).ref=t.ref,e.return=t,t.child=e}function Oo(e,t,n,i,r){if(null!==e){var s=e.memoizedProps;if(Zn(s,i)&&e.ref===t.ref){if(Io=!1,t.pendingProps=i=s,!il(e,r))return t.lanes=e.lanes,nl(e,t,r);131072&e.flags&&(Io=!0)}}return Go(e,t,n,i,r)}function Fo(e,t,n,i){var r=i.children,s=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===i.mode){if(128&t.flags){if(s=null!==s?s.baseLanes|n:n,null!==e){for(i=t.child=e.child,r=0;null!==i;)r=r|i.lanes|i.childLanes,i=i.sibling;i=r&~s}else i=0,t.child=null;return Uo(e,t,s,n,i)}if(!(536870912&n))return i=t.lanes=536870912,Uo(e,t,null!==s?s.baseLanes|n:n,n,i);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&qr(0,null!==s?s.cachePool:null),null!==s?As(t,s):Rs(),Ns(t)}else null!==s?(qr(0,s.cachePool),As(t,s),Os(),t.memoizedState=null):(null!==e&&qr(0,null),Rs(),Os());return Lo(e,t,r,n),t.child}function ko(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Uo(e,t,n,i,r){var s=Xr();return s=null===s?null:{parent:Fr._currentValue,pool:s},t.memoizedState={baseLanes:n,cachePool:s},null!==e&&qr(0,null),Rs(),Ns(t),null!==e&&Ar(e,t,i,!0),t.childLanes=r,null}function zo(e,t){return(t=Zo({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Bo(e,t,n){return hs(t,e.child,null,n),(e=zo(t,t.pendingProps)).flags|=2,Fs(t),t.memoizedState=null,e}function Vo(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(i(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Go(e,t,n,i,r){return Cr(t),n=Js(e,t,n,i,void 0,r),i=na(),null===e||Io?(cr&&i&&rr(t),t.flags|=1,Lo(e,t,n,r),t.child):(ia(e,t,r),nl(e,t,r))}function Ho(e,t,n,i,r,s){return Cr(t),t.updateQueue=null,n=ea(t,i,n,r),Qs(e),i=na(),null===e||Io?(cr&&i&&rr(t),t.flags|=1,Lo(e,t,n,s),t.child):(ia(e,t,s),nl(e,t,s))}function Wo(e,t,n,i,r){if(Cr(t),null===t.stateNode){var s=Ni,a=n.contextType;"object"==typeof a&&null!==a&&(s=Pr(a)),s=new n(i,s),t.memoizedState=null!==s.state&&void 0!==s.state?s.state:null,s.updater=yo,t.stateNode=s,s._reactInternals=t,(s=t.stateNode).props=i,s.state=t.memoizedState,s.refs={},fs(t),a=n.contextType,s.context="object"==typeof a&&null!==a?Pr(a):Ni,s.state=t.memoizedState,"function"==typeof(a=n.getDerivedStateFromProps)&&(vo(t,n,a,i),s.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof s.getSnapshotBeforeUpdate||"function"!=typeof s.UNSAFE_componentWillMount&&"function"!=typeof s.componentWillMount||(a=s.state,"function"==typeof s.componentWillMount&&s.componentWillMount(),"function"==typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount(),a!==s.state&&yo.enqueueReplaceState(s,s.state,null),ws(t,i,s,r),_s(),s.state=t.memoizedState),"function"==typeof s.componentDidMount&&(t.flags|=4194308),i=!0}else if(null===e){s=t.stateNode;var o=t.memoizedProps,l=_o(n,o);s.props=l;var c=s.context,u=n.contextType;a=Ni,"object"==typeof u&&null!==u&&(a=Pr(u));var h=n.getDerivedStateFromProps;u="function"==typeof h||"function"==typeof s.getSnapshotBeforeUpdate,o=t.pendingProps!==o,u||"function"!=typeof s.UNSAFE_componentWillReceiveProps&&"function"!=typeof s.componentWillReceiveProps||(o||c!==a)&&bo(t,s,i,a),ps=!1;var d=t.memoizedState;s.state=d,ws(t,i,s,r),_s(),c=t.memoizedState,o||d!==c||ps?("function"==typeof h&&(vo(t,n,h,i),c=t.memoizedState),(l=ps||xo(t,n,l,i,d,c,a))?(u||"function"!=typeof s.UNSAFE_componentWillMount&&"function"!=typeof s.componentWillMount||("function"==typeof s.componentWillMount&&s.componentWillMount(),"function"==typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount()),"function"==typeof s.componentDidMount&&(t.flags|=4194308)):("function"==typeof s.componentDidMount&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=c),s.props=i,s.state=c,s.context=a,i=l):("function"==typeof s.componentDidMount&&(t.flags|=4194308),i=!1)}else{s=t.stateNode,ms(e,t),u=_o(n,a=t.memoizedProps),s.props=u,h=t.pendingProps,d=s.context,c=n.contextType,l=Ni,"object"==typeof c&&null!==c&&(l=Pr(c)),(c="function"==typeof(o=n.getDerivedStateFromProps)||"function"==typeof s.getSnapshotBeforeUpdate)||"function"!=typeof s.UNSAFE_componentWillReceiveProps&&"function"!=typeof s.componentWillReceiveProps||(a!==h||d!==l)&&bo(t,s,i,l),ps=!1,d=t.memoizedState,s.state=d,ws(t,i,s,r),_s();var p=t.memoizedState;a!==h||d!==p||ps||null!==e&&null!==e.dependencies&&Rr(e.dependencies)?("function"==typeof o&&(vo(t,n,o,i),p=t.memoizedState),(u=ps||xo(t,n,u,i,d,p,l)||null!==e&&null!==e.dependencies&&Rr(e.dependencies))?(c||"function"!=typeof s.UNSAFE_componentWillUpdate&&"function"!=typeof s.componentWillUpdate||("function"==typeof s.componentWillUpdate&&s.componentWillUpdate(i,p,l),"function"==typeof s.UNSAFE_componentWillUpdate&&s.UNSAFE_componentWillUpdate(i,p,l)),"function"==typeof s.componentDidUpdate&&(t.flags|=4),"function"==typeof s.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof s.componentDidUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof s.getSnapshotBeforeUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=p),s.props=i,s.state=p,s.context=l,i=u):("function"!=typeof s.componentDidUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof s.getSnapshotBeforeUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),i=!1)}return s=i,Vo(e,t),i=!!(128&t.flags),s||i?(s=t.stateNode,n=i&&"function"!=typeof n.getDerivedStateFromError?null:s.render(),t.flags|=1,null!==e&&i?(t.child=hs(t,e.child,null,r),t.child=hs(t,null,n,r)):Lo(e,t,n,r),t.memoizedState=s.state,e=t.child):e=nl(e,t,r),e}function jo(e,t,n,i){return vr(),t.flags|=256,Lo(e,t,n,i),t.child}var Xo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qo(e){return{baseLanes:e,cachePool:$r()}}function $o(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=Tc),e}function Yo(e,t,n){var r,s=t.pendingProps,a=!1,o=!!(128&t.flags);if((r=o)||(r=(null===e||null!==e.memoizedState)&&!!(2&ks.current)),r&&(a=!0,t.flags&=-129),r=!!(32&t.flags),t.flags&=-33,null===e){if(cr){if(a?Ls(t):Os(),(e=lr)?null!==(e=null!==(e=Rh(e,hr))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Qi?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Hi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw pr(t);return Ph(e)?t.lanes=32:t.lanes=536870912,null}var l=s.children;return s=s.fallback,a?(Os(),l=Zo({mode:"hidden",children:l},a=t.mode),s=Vi(s,a,n,null),l.return=t,s.return=t,l.sibling=s,t.child=l,(s=t.child).memoizedState=qo(n),s.childLanes=$o(e,r,n),t.memoizedState=Xo,ko(null,s)):(Ls(t),Ko(t,l))}var c=e.memoizedState;if(null!==c&&null!==(l=c.dehydrated)){if(o)256&t.flags?(Ls(t),t.flags&=-257,t=Jo(e,t,n)):null!==t.memoizedState?(Os(),t.child=e.child,t.flags|=128,t=null):(Os(),l=s.fallback,a=t.mode,s=Zo({mode:"visible",children:s.children},a),(l=Vi(l,a,n,null)).flags|=2,s.return=t,l.return=t,s.sibling=l,t.child=s,hs(t,e.child,null,n),(s=t.child).memoizedState=qo(n),s.childLanes=$o(e,r,n),t.memoizedState=Xo,t=ko(null,s));else if(Ls(t),Ph(l)){if(r=l.nextSibling&&l.nextSibling.dataset)var u=r.dgst;r=u,(s=Error(i(419))).stack="",s.digest=r,xr({value:s,source:null,stack:null}),t=Jo(e,t,n)}else if(Io||Ar(e,t,n,!1),r=0!==(n&e.childLanes),Io||r){if(null!==(r=dc)&&0!==(s=De(r,n))&&s!==c.retryLane)throw c.retryLane=s,Ii(e,s),Xc(r,e,s),Po;Ch(l)||ru(),t=Jo(e,t,n)}else Ch(l)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,lr=Ih(l.nextSibling),or=t,cr=!0,ur=null,hr=!1,null!==e&&ar(t,e),(t=Ko(t,s.children)).flags|=4096);return t}return a?(Os(),l=s.fallback,a=t.mode,u=(c=e.child).sibling,(s=Ui(c,{mode:"hidden",children:s.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?l=Ui(u,l):(l=Vi(l,a,n,null)).flags|=2,l.return=t,s.return=t,s.sibling=l,t.child=s,ko(null,s),s=t.child,null===(l=e.child.memoizedState)?l=qo(n):(null!==(a=l.cachePool)?(c=Fr._currentValue,a=a.parent!==c?{parent:c,pool:c}:a):a=$r(),l={baseLanes:l.baseLanes|n,cachePool:a}),s.memoizedState=l,s.childLanes=$o(e,r,n),t.memoizedState=Xo,ko(e.child,s)):(Ls(t),e=(n=e.child).sibling,(n=Ui(n,{mode:"visible",children:s.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function Ko(e,t){return(t=Zo({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Zo(e,t){return(e=Fi(22,e,null,t)).lanes=0,e}function Jo(e,t,n){return hs(t,e.child,null,n),(e=Ko(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Qo(e,t,n){e.lanes|=t;var i=e.alternate;null!==i&&(i.lanes|=t),Tr(e.return,t,n)}function el(e,t,n,i,r,s){var a=e.memoizedState;null===a?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r,treeForkCount:s}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=i,a.tail=n,a.tailMode=r,a.treeForkCount=s)}function tl(e,t,n){var i=t.pendingProps,r=i.revealOrder,s=i.tail;i=i.children;var a=ks.current,o=!!(2&a);if(o?(a=1&a|2,t.flags|=128):a&=1,z(ks,a),Lo(e,t,i,n),i=cr?Ki:0,!o&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Qo(e,n,t);else if(19===e.tag)Qo(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===Us(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),el(t,!1,r,n,s,i);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===Us(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}el(t,!0,n,null,s,i);break;case"together":el(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function nl(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),wc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ar(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=Ui(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Ui(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function il(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Rr(e))}function rl(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Io=!0;else{if(!(il(e,n)||128&t.flags))return Io=!1,function(e,t,n){switch(t.tag){case 3:X(t,t.stateNode.containerInfo),Sr(0,Fr,e.memoizedState.cache),vr();break;case 27:case 5:$(t);break;case 4:X(t,t.stateNode.containerInfo);break;case 10:Sr(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Ds(t),null;break;case 13:var i=t.memoizedState;if(null!==i)return null!==i.dehydrated?(Ls(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Yo(e,t,n):(Ls(t),null!==(e=nl(e,t,n))?e.sibling:null);Ls(t);break;case 19:var r=!!(128&e.flags);if((i=0!==(n&t.childLanes))||(Ar(e,t,n,!1),i=0!==(n&t.childLanes)),r){if(i)return tl(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),z(ks,ks.current),i)break;return null;case 22:return t.lanes=0,Fo(e,t,n,t.pendingProps);case 24:Sr(0,Fr,e.memoizedState.cache)}return nl(e,t,n)}(e,t,n);Io=!!(131072&e.flags)}else Io=!1,cr&&1048576&t.flags&&ir(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(e=ts(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var s=e.$$typeof;if(s===b){t.tag=11,t=Do(null,t,e,r,n);break e}if(s===S){t.tag=14,t=No(null,t,e,r,n);break e}}throw t=P(e)||e,Error(i(306,t,""))}ki(e)?(r=_o(e,r),t.tag=1,t=Wo(null,t,e,r,n)):(t.tag=0,t=Go(null,t,e,r,n))}return t;case 0:return Go(e,t,t.type,t.pendingProps,n);case 1:return Wo(e,t,r=t.type,s=_o(r,t.pendingProps),n);case 3:e:{if(X(t,t.stateNode.containerInfo),null===e)throw Error(i(387));r=t.pendingProps;var a=t.memoizedState;s=a.element,ms(e,t),ws(t,r,null,n);var o=t.memoizedState;if(r=o.cache,Sr(0,Fr,r),r!==a.cache&&Er(t,[Fr],n,!0),_s(),r=o.element,a.isDehydrated){if(a={element:r,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=a,t.memoizedState=a,256&t.flags){t=jo(e,t,r,n);break e}if(r!==s){xr(s=Xi(Error(i(424)),t)),t=jo(e,t,r,n);break e}for(e=9===(e=t.stateNode.containerInfo).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,lr=Ih(e.firstChild),or=t,cr=!0,ur=null,hr=!0,n=ds(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(vr(),r===s){t=nl(e,t,n);break e}Lo(e,t,r,n)}t=t.child}return t;case 26:return Vo(e,t),null===e?(n=Hh(t.type,null,t.pendingProps,null))?t.memoizedState=n:cr||(n=t.type,e=t.pendingProps,(r=fh(W.current).createElement(n))[ze]=t,r[Be]=e,uh(r,n,e),Je(r),t.stateNode=r):t.memoizedState=Hh(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return $(t),null===e&&cr&&(r=t.stateNode=Oh(t.type,t.pendingProps,W.current),or=t,hr=!0,s=lr,Mh(t.type)?(Lh=s,lr=Ih(r.firstChild)):lr=s),Lo(e,t,t.pendingProps.children,n),Vo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&cr&&((s=r=lr)&&(null!==(r=function(e,t,n,i){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(i){if(!e[Xe])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(s=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(s!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((s=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&s&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var s=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===s)return e}if(null===(e=Ih(e.nextSibling)))break}return null}(r,t.type,t.pendingProps,hr))?(t.stateNode=r,or=t,lr=Ih(r.firstChild),hr=!1,s=!0):s=!1),s||pr(t)),$(t),s=t.type,a=t.pendingProps,o=null!==e?e.memoizedProps:null,r=a.children,vh(s,a)?r=null:null!==o&&vh(s,o)&&(t.flags|=32),null!==t.memoizedState&&(s=Js(e,t,ta,null,null,n),ld._currentValue=s),Vo(e,t),Lo(e,t,r,n),t.child;case 6:return null===e&&cr&&((e=n=lr)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=Ih(e.nextSibling)))return null}return e}(n,t.pendingProps,hr))?(t.stateNode=n,or=t,lr=null,e=!0):e=!1),e||pr(t)),null;case 13:return Yo(e,t,n);case 4:return X(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=hs(t,null,r,n):Lo(e,t,r,n),t.child;case 11:return Do(e,t,t.type,t.pendingProps,n);case 7:return Lo(e,t,t.pendingProps,n),t.child;case 8:case 12:return Lo(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Sr(0,t.type,r.value),Lo(e,t,r.children,n),t.child;case 9:return s=t.type._context,r=t.pendingProps.children,Cr(t),r=r(s=Pr(s)),t.flags|=1,Lo(e,t,r,n),t.child;case 14:return No(e,t,t.type,t.pendingProps,n);case 15:return Oo(e,t,t.type,t.pendingProps,n);case 19:return tl(e,t,n);case 31:return function(e,t,n){var r=t.pendingProps,s=!!(128&t.flags);if(t.flags&=-129,null===e){if(cr){if("hidden"===r.mode)return e=zo(t,r),t.lanes=536870912,ko(null,e);if(Ds(t),(e=lr)?null!==(e=null!==(e=Rh(e,hr))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Qi?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Hi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw pr(t);return t.lanes=536870912,null}return zo(t,r)}var a=e.memoizedState;if(null!==a){var o=a.dehydrated;if(Ds(t),s)if(256&t.flags)t.flags&=-257,t=Bo(e,t,n);else{if(null===t.memoizedState)throw Error(i(558));t.child=e.child,t.flags|=128,t=null}else if(Io||Ar(e,t,n,!1),s=0!==(n&e.childLanes),Io||s){if(null!==(r=dc)&&0!==(o=De(r,n))&&o!==a.retryLane)throw a.retryLane=o,Ii(e,o),Xc(r,e,o),Po;ru(),t=Bo(e,t,n)}else e=a.treeContext,lr=Ih(o.nextSibling),or=t,cr=!0,ur=null,hr=!1,null!==e&&ar(t,e),(t=zo(t,r)).flags|=4096;return t}return(e=Ui(e.child,{mode:r.mode,children:r.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return Fo(e,t,n,t.pendingProps);case 24:return Cr(t),r=Pr(Fr),null===e?(null===(s=Xr())&&(s=dc,a=kr(),s.pooledCache=a,a.refCount++,null!==a&&(s.pooledCacheLanes|=n),s=a),t.memoizedState={parent:r,cache:s},fs(t),Sr(0,Fr,s)):(0!==(e.lanes&n)&&(ms(e,t),ws(t,null,null,n),_s()),s=e.memoizedState,a=t.memoizedState,s.parent!==r?(s={parent:r,cache:r},t.memoizedState=s,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=s),Sr(0,Fr,r)):(r=a.cache,Sr(0,Fr,r),r!==s.cache&&Er(t,[Fr],n,!0))),Lo(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function sl(e){e.flags|=4}function al(e,t,n,i,r){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&r)===r)if(e.stateNode.complete)e.flags|=8192;else{if(!tu())throw ns=Jr,Kr;e.flags|=8192}}else e.flags&=-16777217}function ol(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!nd(t)){if(!tu())throw ns=Jr,Kr;e.flags|=8192}}function ll(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Re():536870912,e.lanes|=t,Ec|=t)}function cl(e,t){if(!cr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var i=null;null!==n;)null!==n.alternate&&(i=n),n=n.sibling;null===i?t||null===e.tail?e.tail=null:e.tail.sibling=null:i.sibling=null}}function ul(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,i=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=65011712&r.subtreeFlags,i|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=i,e.childLanes=n,t}function hl(e,t,n){var r=t.pendingProps;switch(sr(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return ul(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Mr(Fr),q(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(gr(t)?sl(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,yr())),ul(t),null;case 26:var s=t.type,a=t.memoizedState;return null===e?(sl(t),null!==a?(ul(t),ol(t,a)):(ul(t),al(t,s,0,0,n))):a?a!==e.memoizedState?(sl(t),ul(t),ol(t,a)):(ul(t),t.flags&=-16777217):((e=e.memoizedProps)!==r&&sl(t),ul(t),al(t,s,0,0,n)),null;case 27:if(Y(t),n=W.current,s=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&sl(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}e=G.current,gr(t)?fr(t):(e=Oh(s,r,n),t.stateNode=e,sl(t))}return ul(t),null;case 5:if(Y(t),s=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&sl(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}if(a=G.current,gr(t))fr(t);else{var o=fh(W.current);switch(a){case 1:a=o.createElementNS("http://www.w3.org/2000/svg",s);break;case 2:a=o.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;default:switch(s){case"svg":a=o.createElementNS("http://www.w3.org/2000/svg",s);break;case"math":a=o.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;case"script":(a=o.createElement("div")).innerHTML="<script><\/script>",a=a.removeChild(a.firstChild);break;case"select":a="string"==typeof r.is?o.createElement("select",{is:r.is}):o.createElement("select"),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a="string"==typeof r.is?o.createElement(s,{is:r.is}):o.createElement(s)}}a[ze]=t,a[Be]=r;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)a.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=a;e:switch(uh(a,s,r),s){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&sl(t)}}return ul(t),al(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&sl(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(i(166));if(e=W.current,gr(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(s=or))switch(s.tag){case 27:case 5:r=s.memoizedProps}e[ze]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||oh(e.nodeValue,n)))||pr(t,!0)}else(e=fh(e).createTextNode(r))[ze]=t,t.stateNode=e}return ul(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=gr(t),null!==n){if(null===e){if(!r)throw Error(i(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));e[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),e=!1}else n=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(Fs(t),t):(Fs(t),null);if(128&t.flags)throw Error(i(558))}return ul(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(s=gr(t),null!==r&&null!==r.dehydrated){if(null===e){if(!s)throw Error(i(318));if(!(s=null!==(s=t.memoizedState)?s.dehydrated:null))throw Error(i(317));s[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),s=!1}else s=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=s),s=!0;if(!s)return 256&t.flags?(Fs(t),t):(Fs(t),null)}return Fs(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(s=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(s=r.alternate.memoizedState.cachePool.pool),a=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(a=r.memoizedState.cachePool.pool),a!==s&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ll(t,t.updateQueue),ul(t),null);case 4:return q(),null===e&&Zu(t.stateNode.containerInfo),ul(t),null;case 10:return Mr(t.type),ul(t),null;case 19:if(U(ks),null===(r=t.memoizedState))return ul(t),null;if(s=!!(128&t.flags),null===(a=r.rendering))if(s)cl(r,!1);else{if(0!==_c||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(a=Us(e))){for(t.flags|=128,cl(r,!1),e=a.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)zi(n,e),n=n.sibling;return z(ks,1&ks.current|2),cr&&nr(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&ae()>Lc&&(t.flags|=128,s=!0,cl(r,!1),t.lanes=4194304)}else{if(!s)if(null!==(e=Us(a))){if(t.flags|=128,s=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),cl(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate&&!cr)return ul(t),null}else 2*ae()-r.renderingStartTime>Lc&&536870912!==n&&(t.flags|=128,s=!0,cl(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(null!==(e=r.last)?e.sibling=a:t.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ae(),e.sibling=null,n=ks.current,z(ks,s?1&n|2:1&n),cr&&nr(t,r.treeForkCount),e):(ul(t),null);case 22:case 23:return Fs(t),Cs(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(ul(t),6&t.subtreeFlags&&(t.flags|=8192)):ul(t),null!==(n=t.updateQueue)&&ll(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&U(jr),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Mr(Fr),ul(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function dl(e,t){switch(sr(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Mr(Fr),q(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Y(t),null;case 31:if(null!==t.memoizedState){if(Fs(t),null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(Fs(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return U(ks),null;case 4:return q(),null;case 10:return Mr(t.type),null;case 22:case 23:return Fs(t),Cs(),null!==e&&U(jr),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Mr(Fr),null;default:return null}}function pl(e,t){switch(sr(t),t.tag){case 3:Mr(Fr),q();break;case 26:case 27:case 5:Y(t);break;case 4:q();break;case 31:null!==t.memoizedState&&Fs(t);break;case 13:Fs(t);break;case 19:U(ks);break;case 10:Mr(t.type);break;case 22:case 23:Fs(t),Cs(),null!==e&&U(jr);break;case 24:Mr(Fr)}}function fl(e,t){try{var n=t.updateQueue,i=null!==n?n.lastEffect:null;if(null!==i){var r=i.next;n=r;do{if((n.tag&e)===e){i=void 0;var s=n.create,a=n.inst;i=s(),a.destroy=i}n=n.next}while(n!==r)}}catch(e){_u(t,t.return,e)}}function ml(e,t,n){try{var i=t.updateQueue,r=null!==i?i.lastEffect:null;if(null!==r){var s=r.next;i=s;do{if((i.tag&e)===e){var a=i.inst,o=a.destroy;if(void 0!==o){a.destroy=void 0,r=t;var l=n,c=o;try{c()}catch(e){_u(r,l,e)}}}i=i.next}while(i!==s)}}catch(e){_u(t,t.return,e)}}function gl(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ms(t,n)}catch(t){_u(e,e.return,t)}}}function vl(e,t,n){n.props=_o(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){_u(e,t,n)}}function yl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;default:i=e.stateNode}"function"==typeof n?e.refCleanup=n(i):n.current=i}}catch(n){_u(e,t,n)}}function xl(e,t){var n=e.ref,i=e.refCleanup;if(null!==n)if("function"==typeof i)try{i()}catch(n){_u(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){_u(e,t,n)}else n.current=null}function bl(e){var t=e.type,n=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&i.focus();break e;case"img":n.src?i.src=n.src:n.srcSet&&(i.srcset=n.srcSet)}}catch(t){_u(e,e.return,t)}}function _l(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var s=null,a=null,o=null,l=null,c=null,u=null,h=null;for(f in n){var d=n[f];if(n.hasOwnProperty(f)&&null!=d)switch(f){case"checked":case"value":break;case"defaultValue":c=d;default:r.hasOwnProperty(f)||lh(e,t,f,null,r,d)}}for(var p in r){var f=r[p];if(d=n[p],r.hasOwnProperty(p)&&(null!=f||null!=d))switch(p){case"type":a=f;break;case"name":s=f;break;case"checked":u=f;break;case"defaultChecked":h=f;break;case"value":o=f;break;case"defaultValue":l=f;break;case"children":case"dangerouslySetInnerHTML":if(null!=f)throw Error(i(137,t));break;default:f!==d&&lh(e,t,p,f,r,d)}}return void gt(e,o,l,c,u,h,a,s);case"select":for(a in f=o=l=p=null,n)if(c=n[a],n.hasOwnProperty(a)&&null!=c)switch(a){case"value":break;case"multiple":f=c;default:r.hasOwnProperty(a)||lh(e,t,a,null,r,c)}for(s in r)if(a=r[s],c=n[s],r.hasOwnProperty(s)&&(null!=a||null!=c))switch(s){case"value":p=a;break;case"defaultValue":l=a;break;case"multiple":o=a;default:a!==c&&lh(e,t,s,a,r,c)}return t=l,n=o,r=f,void(null!=p?xt(e,!!n,p,!1):!!r!=!!n&&(null!=t?xt(e,!!n,t,!0):xt(e,!!n,n?[]:"",!1)));case"textarea":for(l in f=p=null,n)if(s=n[l],n.hasOwnProperty(l)&&null!=s&&!r.hasOwnProperty(l))switch(l){case"value":case"children":break;default:lh(e,t,l,null,r,s)}for(o in r)if(s=r[o],a=n[o],r.hasOwnProperty(o)&&(null!=s||null!=a))switch(o){case"value":p=s;break;case"defaultValue":f=s;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=s)throw Error(i(91));break;default:s!==a&&lh(e,t,o,s,r,a)}return void bt(e,p,f);case"option":for(var m in n)p=n[m],n.hasOwnProperty(m)&&null!=p&&!r.hasOwnProperty(m)&&("selected"===m?e.selected=!1:lh(e,t,m,null,r,p));for(c in r)p=r[c],f=n[c],!r.hasOwnProperty(c)||p===f||null==p&&null==f||("selected"===c?e.selected=p&&"function"!=typeof p&&"symbol"!=typeof p:lh(e,t,c,p,r,f));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 g in n)p=n[g],n.hasOwnProperty(g)&&null!=p&&!r.hasOwnProperty(g)&&lh(e,t,g,null,r,p);for(u in r)if(p=r[u],f=n[u],r.hasOwnProperty(u)&&p!==f&&(null!=p||null!=f))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:lh(e,t,u,p,r,f)}return;default:if(Et(t)){for(var v in n)p=n[v],n.hasOwnProperty(v)&&void 0!==p&&!r.hasOwnProperty(v)&&ch(e,t,v,void 0,r,p);for(h in r)p=r[h],f=n[h],!r.hasOwnProperty(h)||p===f||void 0===p&&void 0===f||ch(e,t,h,p,r,f);return}}for(var y in n)p=n[y],n.hasOwnProperty(y)&&null!=p&&!r.hasOwnProperty(y)&&lh(e,t,y,null,r,p);for(d in r)p=r[d],f=n[d],!r.hasOwnProperty(d)||p===f||null==p&&null==f||lh(e,t,d,p,r,f)}(r,e.type,n,t),r[Be]=t}catch(t){_u(e,e.return,t)}}function wl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Mh(e.type)||4===e.tag}function Sl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||wl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Mh(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Ml(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=Pt));else if(4!==i&&(27===i&&Mh(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(Ml(e,t,n),e=e.sibling;null!==e;)Ml(e,t,n),e=e.sibling}function Tl(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==i&&(27===i&&Mh(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(Tl(e,t,n),e=e.sibling;null!==e;)Tl(e,t,n),e=e.sibling}function El(e){var t=e.stateNode,n=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);uh(t,i,n),t[ze]=e,t[Be]=n}catch(t){_u(e,e.return,t)}}var Al=!1,Rl=!1,Cl=!1,Pl="function"==typeof WeakSet?WeakSet:Set,Il=null;function Ll(e,t,n){var i=n.flags;switch(n.tag){case 0:case 11:case 15:Xl(e,n),4&i&&fl(5,n);break;case 1:if(Xl(e,n),4&i)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){_u(n,n.return,e)}else{var r=_o(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){_u(n,n.return,e)}}64&i&&gl(n),512&i&&yl(n,n.return);break;case 3:if(Xl(e,n),64&i&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ms(e,t)}catch(e){_u(n,n.return,e)}}break;case 27:null===t&&4&i&&El(n);case 26:case 5:Xl(e,n),null===t&&4&i&&bl(n),512&i&&yl(n,n.return);break;case 12:Xl(e,n);break;case 31:Xl(e,n),4&i&&Ul(e,n);break;case 13:Xl(e,n),4&i&&zl(e,n),64&i&&null!==(e=n.memoizedState)&&null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var i=function(){t(),n.removeEventListener("DOMContentLoaded",i)};n.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}(e,n=Tu.bind(null,n));break;case 22:if(!(i=null!==n.memoizedState||Al)){t=null!==t&&null!==t.memoizedState||Rl,r=Al;var s=Rl;Al=i,(Rl=t)&&!s?$l(e,n,!!(8772&n.subtreeFlags)):Xl(e,n),Al=r,Rl=s}break;case 30:break;default:Xl(e,n)}}function Dl(e){var t=e.alternate;null!==t&&(e.alternate=null,Dl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(t=e.stateNode)&&qe(t),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Nl=null,Ol=!1;function Fl(e,t,n){for(n=n.child;null!==n;)kl(e,t,n),n=n.sibling}function kl(e,t,n){if(ge&&"function"==typeof ge.onCommitFiberUnmount)try{ge.onCommitFiberUnmount(me,n)}catch(e){}switch(n.tag){case 26:Rl||xl(n,t),Fl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Rl||xl(n,t);var i=Nl,r=Ol;Mh(n.type)&&(Nl=n.stateNode,Ol=!1),Fl(e,t,n),Fh(n.stateNode),Nl=i,Ol=r;break;case 5:Rl||xl(n,t);case 6:if(i=Nl,r=Ol,Nl=null,Fl(e,t,n),Ol=r,null!==(Nl=i))if(Ol)try{(9===Nl.nodeType?Nl.body:"HTML"===Nl.nodeName?Nl.ownerDocument.body:Nl).removeChild(n.stateNode)}catch(e){_u(n,t,e)}else try{Nl.removeChild(n.stateNode)}catch(e){_u(n,t,e)}break;case 18:null!==Nl&&(Ol?(Th(9===(e=Nl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Gd(e)):Th(Nl,n.stateNode));break;case 4:i=Nl,r=Ol,Nl=n.stateNode.containerInfo,Ol=!0,Fl(e,t,n),Nl=i,Ol=r;break;case 0:case 11:case 14:case 15:ml(2,n,t),Rl||ml(4,n,t),Fl(e,t,n);break;case 1:Rl||(xl(n,t),"function"==typeof(i=n.stateNode).componentWillUnmount&&vl(n,t,i)),Fl(e,t,n);break;case 21:Fl(e,t,n);break;case 22:Rl=(i=Rl)||null!==n.memoizedState,Fl(e,t,n),Rl=i;break;default:Fl(e,t,n)}}function Ul(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)){e=e.dehydrated;try{Gd(e)}catch(e){_u(t,t.return,e)}}}function zl(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))try{Gd(e)}catch(e){_u(t,t.return,e)}}function Bl(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Pl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Pl),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var i=Eu.bind(null,e,t);t.then(i,i)}})}function Vl(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var s=n[r],a=e,o=t,l=o;e:for(;null!==l;){switch(l.tag){case 27:if(Mh(l.type)){Nl=l.stateNode,Ol=!1;break e}break;case 5:Nl=l.stateNode,Ol=!1;break e;case 3:case 4:Nl=l.stateNode.containerInfo,Ol=!0;break e}l=l.return}if(null===Nl)throw Error(i(160));kl(a,o,s),Nl=null,Ol=!1,null!==(a=s.alternate)&&(a.return=null),s.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Hl(t,e),t=t.sibling}var Gl=null;function Hl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Vl(t,e),Wl(e),4&r&&(ml(3,e,e.return),fl(3,e),ml(5,e,e.return));break;case 1:Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),64&r&&Al&&null!==(e=e.updateQueue)&&null!==(r=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?r:n.concat(r));break;case 26:var s=Gl;if(Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),4&r){var a=null!==n?n.memoizedState:null;if(r=e.memoizedState,null===n)if(null===r)if(null===e.stateNode){e:{r=e.type,n=e.memoizedProps,s=s.ownerDocument||s;t:switch(r){case"title":(!(a=s.getElementsByTagName("title")[0])||a[Xe]||a[ze]||"http://www.w3.org/2000/svg"===a.namespaceURI||a.hasAttribute("itemprop"))&&(a=s.createElement(r),s.head.insertBefore(a,s.querySelector("head > title"))),uh(a,r,n),a[ze]=e,Je(a),r=a;break e;case"link":var o=ed("link","href",s).get(r+(n.href||""));if(o)for(var l=0;l<o.length;l++)if((a=o[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&a.getAttribute("rel")===(null==n.rel?null:n.rel)&&a.getAttribute("title")===(null==n.title?null:n.title)&&a.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){o.splice(l,1);break t}uh(a=s.createElement(r),r,n),s.head.appendChild(a);break;case"meta":if(o=ed("meta","content",s).get(r+(n.content||"")))for(l=0;l<o.length;l++)if((a=o[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&a.getAttribute("name")===(null==n.name?null:n.name)&&a.getAttribute("property")===(null==n.property?null:n.property)&&a.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&a.getAttribute("charset")===(null==n.charSet?null:n.charSet)){o.splice(l,1);break t}uh(a=s.createElement(r),r,n),s.head.appendChild(a);break;default:throw Error(i(468,r))}a[ze]=e,Je(a),r=a}e.stateNode=r}else td(s,e.type,e.stateNode);else e.stateNode=Yh(s,r,e.memoizedProps);else a!==r?(null===a?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):a.count--,null===r?td(s,e.type,e.stateNode):Yh(s,r,e.memoizedProps)):null===r&&null!==e.stateNode&&_l(e,e.memoizedProps,n.memoizedProps)}break;case 27:Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),null!==n&&4&r&&_l(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),32&e.flags){s=e.stateNode;try{wt(s,"")}catch(t){_u(e,e.return,t)}}4&r&&null!=e.stateNode&&_l(e,s=e.memoizedProps,null!==n?n.memoizedProps:s),1024&r&&(Cl=!0);break;case 6:if(Vl(t,e),Wl(e),4&r){if(null===e.stateNode)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){_u(e,e.return,t)}}break;case 3:if(Qh=null,s=Gl,Gl=zh(t.containerInfo),Vl(t,e),Gl=s,Wl(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Gd(t.containerInfo)}catch(t){_u(e,e.return,t)}Cl&&(Cl=!1,jl(e));break;case 4:r=Gl,Gl=zh(e.stateNode.containerInfo),Vl(t,e),Wl(e),Gl=r;break;case 12:default:Vl(t,e),Wl(e);break;case 31:case 19:Vl(t,e),Wl(e),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 13:Vl(t,e),Wl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Pc=ae()),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 22:s=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Al,h=Rl;if(Al=u||s,Rl=h||c,Vl(t,e),Rl=h,Al=u,Wl(e),8192&r)e:for(t=e.stateNode,t._visibility=s?-2&t._visibility:1|t._visibility,s&&(null===n||c||Al||Rl||ql(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(a=c.stateNode,s)"function"==typeof(o=a.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{l=c.stateNode;var d=c.memoizedProps.style,p=null!=d&&d.hasOwnProperty("display")?d.display:null;l.style.display=null==p||"boolean"==typeof p?"":(""+p).trim()}}catch(e){_u(c,c.return,e)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=s?"":c.memoizedProps}catch(e){_u(c,c.return,e)}}}else if(18===t.tag){if(null===n){c=t;try{var f=c.stateNode;s?Eh(f,!0):Eh(c.stateNode,!1)}catch(e){_u(c,c.return,e)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&r&&null!==(r=e.updateQueue)&&null!==(n=r.retryQueue)&&(r.retryQueue=null,Bl(e,n));case 30:case 21:}}function Wl(e){var t=e.flags;if(2&t){try{for(var n,r=e.return;null!==r;){if(wl(r)){n=r;break}r=r.return}if(null==n)throw Error(i(160));switch(n.tag){case 27:var s=n.stateNode;Tl(e,Sl(e),s);break;case 5:var a=n.stateNode;32&n.flags&&(wt(a,""),n.flags&=-33),Tl(e,Sl(e),a);break;case 3:case 4:var o=n.stateNode.containerInfo;Ml(e,Sl(e),o);break;default:throw Error(i(161))}}catch(t){_u(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function jl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;jl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Xl(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Ll(e,t.alternate,t),t=t.sibling}function ql(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ml(4,t,t.return),ql(t);break;case 1:xl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&vl(t,t.return,n),ql(t);break;case 27:Fh(t.stateNode);case 26:case 5:xl(t,t.return),ql(t);break;case 22:null===t.memoizedState&&ql(t);break;default:ql(t)}e=e.sibling}}function $l(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var i=t.alternate,r=e,s=t,a=s.flags;switch(s.tag){case 0:case 11:case 15:$l(r,s,n),fl(4,s);break;case 1:if($l(r,s,n),"function"==typeof(r=(i=s).stateNode).componentDidMount)try{r.componentDidMount()}catch(e){_u(i,i.return,e)}if(null!==(r=(i=s).updateQueue)){var o=i.stateNode;try{var l=r.shared.hiddenCallbacks;if(null!==l)for(r.shared.hiddenCallbacks=null,r=0;r<l.length;r++)Ss(l[r],o)}catch(e){_u(i,i.return,e)}}n&&64&a&&gl(s),yl(s,s.return);break;case 27:El(s);case 26:case 5:$l(r,s,n),n&&null===i&&4&a&&bl(s),yl(s,s.return);break;case 12:$l(r,s,n);break;case 31:$l(r,s,n),n&&4&a&&Ul(r,s);break;case 13:$l(r,s,n),n&&4&a&&zl(r,s);break;case 22:null===s.memoizedState&&$l(r,s,n),yl(s,s.return);break;case 30:break;default:$l(r,s,n)}t=t.sibling}}function Yl(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Ur(n))}function Kl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ur(e))}function Zl(e,t,n,i){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Jl(e,t,n,i),t=t.sibling}function Jl(e,t,n,i){var r=t.flags;switch(t.tag){case 0:case 11:case 15:Zl(e,t,n,i),2048&r&&fl(9,t);break;case 1:case 31:case 13:default:Zl(e,t,n,i);break;case 3:Zl(e,t,n,i),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ur(e)));break;case 12:if(2048&r){Zl(e,t,n,i),e=t.stateNode;try{var s=t.memoizedProps,a=s.id,o=s.onPostCommit;"function"==typeof o&&o(a,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(e){_u(t,t.return,e)}}else Zl(e,t,n,i);break;case 23:break;case 22:s=t.stateNode,a=t.alternate,null!==t.memoizedState?2&s._visibility?Zl(e,t,n,i):ec(e,t):2&s._visibility?Zl(e,t,n,i):(s._visibility|=2,Ql(e,t,n,i,!!(10256&t.subtreeFlags)||!1)),2048&r&&Yl(a,t);break;case 24:Zl(e,t,n,i),2048&r&&Kl(t.alternate,t)}}function Ql(e,t,n,i,r){for(r=r&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var s=e,a=t,o=n,l=i,c=a.flags;switch(a.tag){case 0:case 11:case 15:Ql(s,a,o,l,r),fl(8,a);break;case 23:break;case 22:var u=a.stateNode;null!==a.memoizedState?2&u._visibility?Ql(s,a,o,l,r):ec(s,a):(u._visibility|=2,Ql(s,a,o,l,r)),r&&2048&c&&Yl(a.alternate,a);break;case 24:Ql(s,a,o,l,r),r&&2048&c&&Kl(a.alternate,a);break;default:Ql(s,a,o,l,r)}t=t.sibling}}function ec(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,i=t,r=i.flags;switch(i.tag){case 22:ec(n,i),2048&r&&Yl(i.alternate,i);break;case 24:ec(n,i),2048&r&&Kl(i.alternate,i);break;default:ec(n,i)}t=t.sibling}}var tc=8192;function nc(e,t,n){if(e.subtreeFlags&tc)for(e=e.child;null!==e;)ic(e,t,n),e=e.sibling}function ic(e,t,n){switch(e.tag){case 26:nc(e,t,n),e.flags&tc&&null!==e.memoizedState&&function(e,t,n,i){if(!("stylesheet"!==n.type||"string"==typeof i.media&&!1===matchMedia(i.media).matches||4&n.state.loading)){if(null===n.instance){var r=Wh(i.href),s=t.querySelector(jh(r));if(s)return null!==(t=s._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=rd.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=s,void Je(s);s=t.ownerDocument||t,i=Xh(i),(r=kh.get(r))&&Zh(i,r),Je(s=s.createElement("link"));var a=s;a._p=new Promise(function(e,t){a.onload=e,a.onerror=t}),uh(s,"link",i),n.instance=s}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=rd.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Gl,e.memoizedState,e.memoizedProps);break;case 5:default:nc(e,t,n);break;case 3:case 4:var i=Gl;Gl=zh(e.stateNode.containerInfo),nc(e,t,n),Gl=i;break;case 22:null===e.memoizedState&&(null!==(i=e.alternate)&&null!==i.memoizedState?(i=tc,tc=16777216,nc(e,t,n),tc=i):nc(e,t,n))}}function rc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function sc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Il=i,lc(i,e)}rc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)ac(e),e=e.sibling}function ac(e){switch(e.tag){case 0:case 11:case 15:sc(e),2048&e.flags&&ml(9,e,e.return);break;case 3:case 12:default:sc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,oc(e)):sc(e)}}function oc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Il=i,lc(i,e)}rc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ml(8,t,t.return),oc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,oc(t));break;default:oc(t)}e=e.sibling}}function lc(e,t){for(;null!==Il;){var n=Il;switch(n.tag){case 0:case 11:case 15:ml(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var i=n.memoizedState.cachePool.pool;null!=i&&i.refCount++}break;case 24:Ur(n.memoizedState.cache)}if(null!==(i=n.child))i.return=n,Il=i;else e:for(n=e;null!==Il;){var r=(i=Il).sibling,s=i.return;if(Dl(i),i===n){Il=null;break e}if(null!==r){r.return=s,Il=r;break e}Il=s}}}var cc={getCacheForType:function(e){var t=Pr(Fr),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Pr(Fr).controller.signal}},uc="function"==typeof WeakMap?WeakMap:Map,hc=0,dc=null,pc=null,fc=0,mc=0,gc=null,vc=!1,yc=!1,xc=!1,bc=0,_c=0,wc=0,Sc=0,Mc=0,Tc=0,Ec=0,Ac=null,Rc=null,Cc=!1,Pc=0,Ic=0,Lc=1/0,Dc=null,Nc=null,Oc=0,Fc=null,kc=null,Uc=0,zc=0,Bc=null,Vc=null,Gc=0,Hc=null;function Wc(){return 2&hc&&0!==fc?fc&-fc:null!==L.T?Bu():Fe()}function jc(){if(0===Tc)if(536870912&fc&&!cr)Tc=536870912;else{var e=we;!(3932160&(we<<=1))&&(we=262144),Tc=e}return null!==(e=Ps.current)&&(e.flags|=32),Tc}function Xc(e,t,n){(e!==dc||2!==mc&&9!==mc)&&null===e.cancelPendingCommit||(Qc(e,0),Kc(e,fc,Tc,!1)),Pe(e,n),2&hc&&e===dc||(e===dc&&(!(2&hc)&&(Sc|=n),4===_c&&Kc(e,fc,Tc,!1)),Du(e))}function qc(e,t,n){if(6&hc)throw Error(i(327));for(var r=!n&&!(127&t)&&0===(t&e.expiredLanes)||Ee(e,t),s=r?function(e,t){var n=hc;hc|=2;var r=nu(),s=iu();dc!==e||fc!==t?(Dc=null,Lc=ae()+500,Qc(e,t)):yc=Ee(e,t);e:for(;;)try{if(0!==mc&&null!==pc){t=pc;var a=gc;t:switch(mc){case 1:mc=0,gc=null,uu(e,t,a,1);break;case 2:case 9:if(Qr(a)){mc=0,gc=null,cu(t);break}t=function(){2!==mc&&9!==mc||dc!==e||(mc=7),Du(e)},a.then(t,t);break e;case 3:mc=7;break e;case 4:mc=5;break e;case 7:Qr(a)?(mc=0,gc=null,cu(t)):(mc=0,gc=null,uu(e,t,a,7));break;case 5:var o=null;switch(pc.tag){case 26:o=pc.memoizedState;case 5:case 27:var l=pc;if(o?nd(o):l.stateNode.complete){mc=0,gc=null;var c=l.sibling;if(null!==c)pc=c;else{var u=l.return;null!==u?(pc=u,hu(u)):pc=null}break t}}mc=0,gc=null,uu(e,t,a,5);break;case 6:mc=0,gc=null,uu(e,t,a,6);break;case 8:Jc(),_c=6;break e;default:throw Error(i(462))}}ou();break}catch(t){eu(e,t)}return wr=_r=null,L.H=r,L.A=s,hc=n,null!==pc?0:(dc=null,fc=0,Ri(),_c)}(e,t):su(e,t,!0),a=r;;){if(0===s){yc&&!r&&Kc(e,t,0,!1);break}if(n=e.current.alternate,!a||Yc(n)){if(2===s){if(a=t,e.errorRecoveryDisabledLanes&a)var o=0;else o=0!=(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var l=e;s=Ac;var c=l.current.memoizedState.isDehydrated;if(c&&(Qc(l,o).flags|=256),2!==(o=su(l,o,!1))){if(xc&&!c){l.errorRecoveryDisabledLanes|=a,Sc|=a,s=4;break e}a=Rc,Rc=s,null!==a&&(null===Rc?Rc=a:Rc.push.apply(Rc,a))}s=o}if(a=!1,2!==s)continue}}if(1===s){Qc(e,0),Kc(e,t,0,!0);break}e:{switch(r=e,a=s){case 0:case 1:throw Error(i(345));case 4:if((4194048&t)!==t)break;case 6:Kc(r,t,Tc,!vc);break e;case 2:Rc=null;break;case 3:case 5:break;default:throw Error(i(329))}if((62914560&t)===t&&10<(s=Pc+300-ae())){if(Kc(r,t,Tc,!vc),0!==Te(r,0,!0))break e;Uc=t,r.timeoutHandle=xh($c.bind(null,r,n,Rc,Dc,Cc,t,Tc,Sc,Ec,vc,a,"Throttled",-0,0),s)}else $c(r,n,Rc,Dc,Cc,t,Tc,Sc,Ec,vc,a,null,-0,0)}break}s=su(e,t,!1),a=!1}Du(e)}function $c(e,t,n,i,r,s,a,o,l,c,u,h,d,p){if(e.timeoutHandle=-1,8192&(h=t.subtreeFlags)||!(16785408&~h)){ic(t,s,h={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Pt});var f=(62914560&s)===s?Pc-ae():(4194048&s)===s?Ic-ae():0;if(f=function(e,t){return e.stylesheets&&0===e.count&&ad(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var i=setTimeout(function(){if(e.stylesheets&&ad(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===id&&(id=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),i=0;i<n.length;i++){var r=n[i],s=r.transferSize,a=r.initiatorType,o=r.duration;if(s&&o&&hh(a)){for(a=0,o=r.responseEnd,i+=1;i<n.length;i++){var l=n[i],c=l.startTime;if(c>o)break;var u=l.transferSize,h=l.initiatorType;u&&hh(h)&&(a+=u*((l=l.responseEnd)<o?1:(o-c)/(l-c)))}if(--i,t+=8*(s+a)/(r.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var r=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&ad(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>id?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}(h,f),null!==f)return Uc=s,e.cancelPendingCommit=f(pu.bind(null,e,t,s,n,i,r,a,o,l,u,h,null,d,p)),void Kc(e,s,a,!c)}pu(e,t,s,n,i,r,a,o,l)}function Yc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&null!==(n=t.updateQueue)&&null!==(n=n.stores))for(var i=0;i<n.length;i++){var r=n[i],s=r.getSnapshot;r=r.value;try{if(!Kn(s(),r))return!1}catch(e){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Kc(e,t,n,i){t&=~Mc,t&=~Sc,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var r=t;0<r;){var s=31-ye(r),a=1<<s;i[s]=-1,r&=~a}0!==n&&Ie(e,n,t)}function Zc(){return!!(6&hc)||(Nu(0),!1)}function Jc(){if(null!==pc){if(0===mc)var e=pc.return;else wr=_r=null,ra(e=pc),ss=null,as=0,e=pc;for(;null!==e;)pl(e.alternate,e),e=e.return;pc=null}}function Qc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,bh(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Uc=0,Jc(),dc=e,pc=n=Ui(e.current,null),fc=t,mc=0,gc=null,vc=!1,yc=Ee(e,t),xc=!1,Ec=Tc=Mc=Sc=wc=_c=0,Rc=Ac=null,Cc=!1,8&t&&(t|=32&t);var i=e.entangledLanes;if(0!==i)for(e=e.entanglements,i&=t;0<i;){var r=31-ye(i),s=1<<r;t|=e[r],i&=~s}return bc=t,Ri(),n}function eu(e,t){Bs=null,L.H=po,t===Yr||t===Zr?(t=is(),mc=3):t===Kr?(t=is(),mc=4):mc=t===Po?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,gc=t,null===pc&&(_c=1,To(e,Xi(t,e.current)))}function tu(){var e=Ps.current;return null===e||((4194048&fc)===fc?null===Is:!!((62914560&fc)===fc||536870912&fc)&&e===Is)}function nu(){var e=L.H;return L.H=po,null===e?po:e}function iu(){var e=L.A;return L.A=cc,e}function ru(){_c=4,vc||(4194048&fc)!==fc&&null!==Ps.current||(yc=!0),!(134217727&wc)&&!(134217727&Sc)||null===dc||Kc(dc,fc,Tc,!1)}function su(e,t,n){var i=hc;hc|=2;var r=nu(),s=iu();dc===e&&fc===t||(Dc=null,Qc(e,t)),t=!1;var a=_c;e:for(;;)try{if(0!==mc&&null!==pc){var o=pc,l=gc;switch(mc){case 8:Jc(),a=6;break e;case 3:case 2:case 9:case 6:null===Ps.current&&(t=!0);var c=mc;if(mc=0,gc=null,uu(e,o,l,c),n&&yc){a=0;break e}break;default:c=mc,mc=0,gc=null,uu(e,o,l,c)}}au(),a=_c;break}catch(t){eu(e,t)}return t&&e.shellSuspendCounter++,wr=_r=null,hc=i,L.H=r,L.A=s,null===pc&&(dc=null,fc=0,Ri()),a}function au(){for(;null!==pc;)lu(pc)}function ou(){for(;null!==pc&&!re();)lu(pc)}function lu(e){var t=rl(e.alternate,e,bc);e.memoizedProps=e.pendingProps,null===t?hu(e):pc=t}function cu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Ho(n,t,t.pendingProps,t.type,void 0,fc);break;case 11:t=Ho(n,t,t.pendingProps,t.type.render,t.ref,fc);break;case 5:ra(t);default:pl(n,t),t=rl(n,t=pc=zi(t,bc),bc)}e.memoizedProps=e.pendingProps,null===t?hu(e):pc=t}function uu(e,t,n,r){wr=_r=null,ra(t),ss=null,as=0;var s=t.return;try{if(function(e,t,n,r,s){if(n.flags|=32768,null!==r&&"object"==typeof r&&"function"==typeof r.then){if(null!==(t=n.alternate)&&Ar(t,n,s,!0),null!==(n=Ps.current)){switch(n.tag){case 31:case 13:return null===Is?ru():null===n.alternate&&0===_c&&(_c=3),n.flags&=-257,n.flags|=65536,n.lanes=s,r===Jr?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([r]):t.add(r),wu(e,r,s)),!1;case 22:return n.flags|=65536,r===Jr?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([r]):n.add(r),wu(e,r,s)),!1}throw Error(i(435,n.tag))}return wu(e,r,s),ru(),!1}if(cr)return null!==(t=Ps.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=s,r!==dr&&xr(Xi(e=Error(i(422),{cause:r}),n))):(r!==dr&&xr(Xi(t=Error(i(423),{cause:r}),n)),(e=e.current.alternate).flags|=65536,s&=-s,e.lanes|=s,r=Xi(r,n),xs(e,s=Ao(e.stateNode,r,s)),4!==_c&&(_c=2)),!1;var a=Error(i(520),{cause:r});if(a=Xi(a,n),null===Ac?Ac=[a]:Ac.push(a),4!==_c&&(_c=2),null===t)return!0;r=Xi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=s&-s,n.lanes|=e,xs(n,e=Ao(n.stateNode,r,e)),!1;case 1:if(t=n.type,a=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===a||"function"!=typeof a.componentDidCatch||null!==Nc&&Nc.has(a))))return n.flags|=65536,s&=-s,n.lanes|=s,Co(s=Ro(s),e,n,r),xs(n,s),!1}n=n.return}while(null!==n);return!1}(e,s,t,n,fc))return _c=1,To(e,Xi(n,e.current)),void(pc=null)}catch(t){if(null!==s)throw pc=s,t;return _c=1,To(e,Xi(n,e.current)),void(pc=null)}32768&t.flags?(cr||1===r?e=!0:yc||536870912&fc?e=!1:(vc=e=!0,(2===r||9===r||3===r||6===r)&&null!==(r=Ps.current)&&13===r.tag&&(r.flags|=16384)),du(t,e)):hu(t)}function hu(e){var t=e;do{if(32768&t.flags)return void du(t,vc);e=t.return;var n=hl(t.alternate,t,bc);if(null!==n)return void(pc=n);if(null!==(t=t.sibling))return void(pc=t);pc=t=e}while(null!==t);0===_c&&(_c=5)}function du(e,t){do{var n=dl(e.alternate,e);if(null!==n)return n.flags&=32767,void(pc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(pc=e);pc=e=n}while(null!==e);_c=6,pc=null}function pu(e,t,n,r,s,a,o,l,c){e.cancelPendingCommit=null;do{yu()}while(0!==Oc);if(6&hc)throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(a=t.lanes|t.childLanes,function(e,t,n,i,r,s){var a=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=a&~n;0<n;){var u=31-ye(n),h=1<<u;o[u]=0,l[u]=-1;var d=c[u];if(null!==d)for(c[u]=null,u=0;u<d.length;u++){var p=d[u];null!==p&&(p.lane&=-536870913)}n&=~h}0!==i&&Ie(e,i,0),0!==s&&0===r&&0!==e.tag&&(e.suspendedLanes|=s&~(a&~t))}(e,n,a|=Ai,o,l,c),e===dc&&(pc=dc=null,fc=0),kc=t,Fc=e,Uc=n,zc=a,Bc=s,Vc=r,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,ne(ue,function(){return xu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(13878&t.flags),13878&t.subtreeFlags||r){r=L.T,L.T=null,s=D.p,D.p=2,o=hc,hc|=4;try{!function(e,t){if(e=e.containerInfo,dh=vd,ni(e=ti(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch(e){n=null;break e}var o=0,l=-1,c=-1,u=0,h=0,d=e,p=null;t:for(;;){for(var f;d!==n||0!==s&&3!==d.nodeType||(l=o+s),d!==a||0!==r&&3!==d.nodeType||(c=o+r),3===d.nodeType&&(o+=d.nodeValue.length),null!==(f=d.firstChild);)p=d,d=f;for(;;){if(d===e)break t;if(p===n&&++u===s&&(l=o),p===a&&++h===r&&(c=o),null!==(f=d.nextSibling))break;p=(d=p).parentNode}d=f}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(ph={focusedElem:e,selectionRange:n},vd=!1,Il=t;null!==Il;)if(e=(t=Il).child,1028&t.subtreeFlags&&null!==e)e.return=t,Il=e;else for(;null!==Il;){switch(a=(t=Il).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(s=e[n]).ref.impl=s.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==a){e=void 0,n=t,s=a.memoizedProps,a=a.memoizedState,r=n.stateNode;try{var m=_o(n.type,s);e=r.getSnapshotBeforeUpdate(m,a),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){_u(n,n.return,e)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Ah(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ah(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(i(163))}if(null!==(e=t.sibling)){e.return=t.return,Il=e;break}Il=t.return}}(e,t)}finally{hc=o,D.p=s,L.T=r}}Oc=1,fu(),mu(),gu()}}function fu(){if(1===Oc){Oc=0;var e=Fc,t=kc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=L.T,L.T=null;var i=D.p;D.p=2;var r=hc;hc|=4;try{Hl(t,e);var s=ph,a=ti(e.containerInfo),o=s.focusedElem,l=s.selectionRange;if(a!==o&&o&&o.ownerDocument&&ei(o.ownerDocument.documentElement,o)){if(null!==l&&ni(o)){var c=l.start,u=l.end;if(void 0===u&&(u=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(u,o.value.length);else{var h=o.ownerDocument||document,d=h&&h.defaultView||window;if(d.getSelection){var p=d.getSelection(),f=o.textContent.length,m=Math.min(l.start,f),g=void 0===l.end?m:Math.min(l.end,f);!p.extend&&m>g&&(a=g,g=m,m=a);var v=Qn(o,m),y=Qn(o,g);if(v&&y&&(1!==p.rangeCount||p.anchorNode!==v.node||p.anchorOffset!==v.offset||p.focusNode!==y.node||p.focusOffset!==y.offset)){var x=h.createRange();x.setStart(v.node,v.offset),p.removeAllRanges(),m>g?(p.addRange(x),p.extend(y.node,y.offset)):(x.setEnd(y.node,y.offset),p.addRange(x))}}}}for(h=[],p=o;p=p.parentNode;)1===p.nodeType&&h.push({element:p,left:p.scrollLeft,top:p.scrollTop});for("function"==typeof o.focus&&o.focus(),o=0;o<h.length;o++){var b=h[o];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}vd=!!dh,ph=dh=null}finally{hc=r,D.p=i,L.T=n}}e.current=t,Oc=2}}function mu(){if(2===Oc){Oc=0;var e=Fc,t=kc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=L.T,L.T=null;var i=D.p;D.p=2;var r=hc;hc|=4;try{Ll(e,t.alternate,t)}finally{hc=r,D.p=i,L.T=n}}Oc=3}}function gu(){if(4===Oc||3===Oc){Oc=0,se();var e=Fc,t=kc,n=Uc,i=Vc;10256&t.subtreeFlags||10256&t.flags?Oc=5:(Oc=0,kc=Fc=null,vu(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Nc=null),Oe(n),t=t.stateNode,ge&&"function"==typeof ge.onCommitFiberRoot)try{ge.onCommitFiberRoot(me,t,void 0,!(128&~t.current.flags))}catch(e){}if(null!==i){t=L.T,r=D.p,D.p=2,L.T=null;try{for(var s=e.onRecoverableError,a=0;a<i.length;a++){var o=i[a];s(o.value,{componentStack:o.stack})}}finally{L.T=t,D.p=r}}3&Uc&&yu(),Du(e),r=e.pendingLanes,261930&n&&42&r?e===Hc?Gc++:(Gc=0,Hc=e):Gc=0,Nu(0)}}function vu(e,t){0===(e.pooledCacheLanes&=t)&&null!=(t=e.pooledCache)&&(e.pooledCache=null,Ur(t))}function yu(){return fu(),mu(),gu(),xu()}function xu(){if(5!==Oc)return!1;var e=Fc,t=zc;zc=0;var n=Oe(Uc),r=L.T,s=D.p;try{D.p=32>n?32:n,L.T=null,n=Bc,Bc=null;var a=Fc,o=Uc;if(Oc=0,kc=Fc=null,Uc=0,6&hc)throw Error(i(331));var l=hc;if(hc|=4,ac(a.current),Jl(a,a.current,o,n),hc=l,Nu(0,!1),ge&&"function"==typeof ge.onPostCommitFiberRoot)try{ge.onPostCommitFiberRoot(me,a)}catch(e){}return!0}finally{D.p=s,L.T=r,vu(e,t)}}function bu(e,t,n){t=Xi(n,t),null!==(e=vs(e,t=Ao(e.stateNode,t,2),2))&&(Pe(e,2),Du(e))}function _u(e,t,n){if(3===e.tag)bu(e,e,n);else for(;null!==t;){if(3===t.tag){bu(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===Nc||!Nc.has(i))){e=Xi(n,e),null!==(i=vs(t,n=Ro(2),2))&&(Co(n,i,t,e),Pe(i,2),Du(i));break}}t=t.return}}function wu(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new uc;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(xc=!0,r.add(n),e=Su.bind(null,e,t,n),t.then(e,e))}function Su(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,dc===e&&(fc&n)===n&&(4===_c||3===_c&&(62914560&fc)===fc&&300>ae()-Pc?!(2&hc)&&Qc(e,0):Mc|=n,Ec===fc&&(Ec=0)),Du(e)}function Mu(e,t){0===t&&(t=Re()),null!==(e=Ii(e,t))&&(Pe(e,t),Du(e))}function Tu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Mu(e,n)}function Eu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,s=e.memoizedState;null!==s&&(n=s.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),Mu(e,n)}var Au=null,Ru=null,Cu=!1,Pu=!1,Iu=!1,Lu=0;function Du(e){e!==Ru&&null===e.next&&(null===Ru?Au=Ru=e:Ru=Ru.next=e),Pu=!0,Cu||(Cu=!0,wh(function(){6&hc?ne(le,Ou):Fu()}))}function Nu(e,t){if(!Iu&&Pu){Iu=!0;do{for(var n=!1,i=Au;null!==i;){if(0!==e){var r=i.pendingLanes;if(0===r)var s=0;else{var a=i.suspendedLanes,o=i.pingedLanes;s=(1<<31-ye(42|e)+1)-1,s=201326741&(s&=r&~(a&~o))?201326741&s|1:s?2|s:0}0!==s&&(n=!0,zu(i,s))}else s=fc,!(3&(s=Te(i,i===dc?s:0,null!==i.cancelPendingCommit||-1!==i.timeoutHandle)))||Ee(i,s)||(n=!0,zu(i,s));i=i.next}}while(n);Iu=!1}}function Ou(){Fu()}function Fu(){Pu=Cu=!1;var e,t=0;0!==Lu&&((e=window.event)&&"popstate"===e.type?e!==yh&&(yh=e,1):(yh=null,0))&&(t=Lu);for(var n=ae(),i=null,r=Au;null!==r;){var s=r.next,a=ku(r,n);0===a?(r.next=null,null===i?Au=s:i.next=s,null===s&&(Ru=i)):(i=r,(0!==t||3&a)&&(Pu=!0)),r=s}0!==Oc&&5!==Oc||Nu(t),0!==Lu&&(Lu=0)}function ku(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,s=-62914561&e.pendingLanes;0<s;){var a=31-ye(s),o=1<<a,l=r[a];-1===l?0!==(o&n)&&0===(o&i)||(r[a]=Ae(o,t)):l<=t&&(e.expiredLanes|=o),s&=~o}if(n=fc,n=Te(e,e===(t=dc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),i=e.callbackNode,0===n||e===t&&(2===mc||9===mc)||null!==e.cancelPendingCommit)return null!==i&&null!==i&&ie(i),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Ee(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==i&&ie(i),Oe(n)){case 2:case 8:n=ce;break;case 32:default:n=ue;break;case 268435456:n=de}return i=Uu.bind(null,e),n=ne(n,i),e.callbackPriority=t,e.callbackNode=n,t}return null!==i&&null!==i&&ie(i),e.callbackPriority=2,e.callbackNode=null,2}function Uu(e,t){if(0!==Oc&&5!==Oc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(yu()&&e.callbackNode!==n)return null;var i=fc;return 0===(i=Te(e,e===dc?i:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(qc(e,i,t),ku(e,ae()),null!=e.callbackNode&&e.callbackNode===n?Uu.bind(null,e):null)}function zu(e,t){if(yu())return null;qc(e,t,!0)}function Bu(){if(0===Lu){var e=Vr;0===e&&(e=_e,!(261888&(_e<<=1))&&(_e=256)),Lu=e}return Lu}function Vu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Ct(""+e)}function Gu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Hu=0;Hu<wi.length;Hu++){var Wu=wi[Hu];Si(Wu.toLowerCase(),"on"+(Wu[0].toUpperCase()+Wu.slice(1)))}Si(fi,"onAnimationEnd"),Si(mi,"onAnimationIteration"),Si(gi,"onAnimationStart"),Si("dblclick","onDoubleClick"),Si("focusin","onFocus"),Si("focusout","onBlur"),Si(vi,"onTransitionRun"),Si(yi,"onTransitionStart"),Si(xi,"onTransitionCancel"),Si(bi,"onTransitionEnd"),nt("onMouseEnter",["mouseout","mouseover"]),nt("onMouseLeave",["mouseout","mouseover"]),nt("onPointerEnter",["pointerout","pointerover"]),nt("onPointerLeave",["pointerout","pointerover"]),tt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),tt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),tt("onBeforeInput",["compositionend","keypress","textInput","paste"]),tt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ju="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(" "),Xu=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ju));function qu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var i=e[n],r=i.event;i=i.listeners;e:{var s=void 0;if(t)for(var a=i.length-1;0<=a;a--){var o=i[a],l=o.instance,c=o.currentTarget;if(o=o.listener,l!==s&&r.isPropagationStopped())break e;s=o,r.currentTarget=c;try{s(r)}catch(e){Mi(e)}r.currentTarget=null,s=l}else for(a=0;a<i.length;a++){if(l=(o=i[a]).instance,c=o.currentTarget,o=o.listener,l!==s&&r.isPropagationStopped())break e;s=o,r.currentTarget=c;try{s(r)}catch(e){Mi(e)}r.currentTarget=null,s=l}}}}function $u(e,t){var n=t[Ge];void 0===n&&(n=t[Ge]=new Set);var i=e+"__bubble";n.has(i)||(Ju(t,e,2,!1),n.add(i))}function Yu(e,t,n){var i=0;t&&(i|=4),Ju(n,e,i,t)}var Ku="_reactListening"+Math.random().toString(36).slice(2);function Zu(e){if(!e[Ku]){e[Ku]=!0,Qe.forEach(function(t){"selectionchange"!==t&&(Xu.has(t)||Yu(t,!1,e),Yu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Ku]||(t[Ku]=!0,Yu("selectionchange",!1,t))}}function Ju(e,t,n,i){switch(Md(t)){case 2:var r=yd;break;case 8:r=xd;break;default:r=bd}n=r.bind(null,t,n,e),r=void 0,!Bt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),i?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function Qu(e,t,n,i,r){var a=i;if(!(1&t||2&t||null===i))e:for(;;){if(null===i)return;var o=i.tag;if(3===o||4===o){var l=i.stateNode.containerInfo;if(l===r)break;if(4===o)for(o=i.return;null!==o;){var c=o.tag;if((3===c||4===c)&&o.stateNode.containerInfo===r)return;o=o.return}for(;null!==l;){if(null===(o=$e(l)))return;if(5===(c=o.tag)||6===c||26===c||27===c){i=a=o;continue e}l=l.parentNode}}i=i.return}kt(function(){var i=a,r=Lt(n),o=[];e:{var l=_i.get(e);if(void 0!==l){var c=en,u=e;switch(e){case"keypress":if(0===Xt(n))break e;case"keydown":case"keyup":c=gn;break;case"focusin":u="focus",c=on;break;case"focusout":u="blur",c=on;break;case"beforeblur":case"afterblur":c=on;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=sn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=an;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=yn;break;case fi:case mi:case gi:c=ln;break;case bi:c=xn;break;case"scroll":case"scrollend":c=nn;break;case"wheel":c=bn;break;case"copy":case"cut":case"paste":c=cn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=vn;break;case"toggle":case"beforetoggle":c=_n}var h=!!(4&t),d=!h&&("scroll"===e||"scrollend"===e),p=h?null!==l?l+"Capture":null:l;h=[];for(var f,m=i;null!==m;){var g=m;if(f=g.stateNode,5!==(g=g.tag)&&26!==g&&27!==g||null===f||null===p||null!=(g=Ut(m,p))&&h.push(eh(m,g,f)),d)break;m=m.return}0<h.length&&(l=new c(l,u,null,n,r),o.push({event:l,listeners:h}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(l="mouseover"===e||"pointerover"===e)||n===It||!(u=n.relatedTarget||n.fromElement)||!$e(u)&&!u[Ve])&&(c||l)&&(l=r.window===r?r:(l=r.ownerDocument)?l.defaultView||l.parentWindow:window,c?(c=i,null!==(u=(u=n.relatedTarget||n.toElement)?$e(u):null)&&(d=s(u),h=u.tag,u!==d||5!==h&&27!==h&&6!==h)&&(u=null)):(c=null,u=i),c!==u)){if(h=sn,g="onMouseLeave",p="onMouseEnter",m="mouse","pointerout"!==e&&"pointerover"!==e||(h=vn,g="onPointerLeave",p="onPointerEnter",m="pointer"),d=null==c?l:Ke(c),f=null==u?l:Ke(u),(l=new h(g,m+"leave",c,n,r)).target=d,l.relatedTarget=f,g=null,$e(r)===i&&((h=new h(p,m+"enter",u,n,r)).target=f,h.relatedTarget=d,g=h),d=g,c&&u)e:{for(h=nh,m=u,f=0,g=p=c;g;g=h(g))f++;g=0;for(var v=m;v;v=h(v))g++;for(;0<f-g;)p=h(p),f--;for(;0<g-f;)m=h(m),g--;for(;f--;){if(p===m||null!==m&&p===m.alternate){h=p;break e}p=h(p),m=h(m)}h=null}else h=null;null!==c&&ih(o,l,c,h,!1),null!==u&&null!==d&&ih(o,d,u,h,!0)}if("select"===(c=(l=i?Ke(i):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var y=zn;else if(Dn(l))if(Bn)y=Yn;else{y=qn;var x=Xn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?i&&Et(i.elementType)&&(y=zn):y=$n;switch(y&&(y=y(e,i))?Nn(o,y,n,r):(x&&x(e,l,i),"focusout"===e&&i&&"number"===l.type&&null!=i.memoizedProps.value&&yt(l,"number",l.value)),x=i?Ke(i):window,e){case"focusin":(Dn(x)||"true"===x.contentEditable)&&(ri=x,si=i,ai=null);break;case"focusout":ai=si=ri=null;break;case"mousedown":oi=!0;break;case"contextmenu":case"mouseup":case"dragend":oi=!1,li(o,n,r);break;case"selectionchange":if(ii)break;case"keydown":case"keyup":li(o,n,r)}var b;if(Sn)e:{switch(e){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else In?Cn(e,n)&&(_="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(_="onCompositionStart");_&&(En&&"ko"!==n.locale&&(In||"onCompositionStart"!==_?"onCompositionEnd"===_&&In&&(b=jt()):(Ht="value"in(Gt=r)?Gt.value:Gt.textContent,In=!0)),0<(x=th(i,_)).length&&(_=new un(_,e,null,n,r),o.push({event:_,listeners:x}),(b||null!==(b=Pn(n)))&&(_.data=b))),(b=Tn?function(e,t){switch(e){case"compositionend":return Pn(t);case"keypress":return 32!==t.which?null:(Rn=!0,An);case"textInput":return(e=t.data)===An&&Rn?null:e;default:return null}}(e,n):function(e,t){if(In)return"compositionend"===e||!Sn&&Cn(e,t)?(e=jt(),Wt=Ht=Gt=null,In=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return En&&"ko"!==t.locale?null:t.data}}(e,n))&&0<(_=th(i,"onBeforeInput")).length&&(x=new un("onBeforeInput","beforeinput",null,n,r),o.push({event:x,listeners:_}),x.data=b),function(e,t,n,i,r){if("submit"===t&&n&&n.stateNode===r){var s=Vu((r[Be]||null).action),a=i.submitter;a&&null!==(t=(t=a[Be]||null)?Vu(t.formAction):a.getAttribute("formAction"))&&(s=t,a=null);var o=new en("action","action",null,i,r);e.push({event:o,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(0!==Lu){var e=a?Gu(r,a):new FormData(r);Ja(n,{pending:!0,data:e,method:r.method,action:s},null,e)}}else"function"==typeof s&&(o.preventDefault(),e=a?Gu(r,a):new FormData(r),Ja(n,{pending:!0,data:e,method:r.method,action:s},s,e))},currentTarget:r}]})}}(o,e,i,n,r)}qu(o,t)})}function eh(e,t,n){return{instance:e,listener:t,currentTarget:n}}function th(e,t){for(var n=t+"Capture",i=[];null!==e;){var r=e,s=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===s||(null!=(r=Ut(e,n))&&i.unshift(eh(e,r,s)),null!=(r=Ut(e,t))&&i.push(eh(e,r,s))),3===e.tag)return i;e=e.return}return[]}function nh(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function ih(e,t,n,i,r){for(var s=t._reactName,a=[];null!==n&&n!==i;){var o=n,l=o.alternate,c=o.stateNode;if(o=o.tag,null!==l&&l===i)break;5!==o&&26!==o&&27!==o||null===c||(l=c,r?null!=(c=Ut(n,s))&&a.unshift(eh(n,c,l)):r||null!=(c=Ut(n,s))&&a.push(eh(n,c,l))),n=n.return}0!==a.length&&e.push({event:t,listeners:a})}var rh=/\r\n?/g,sh=/\u0000|\uFFFD/g;function ah(e){return("string"==typeof e?e:""+e).replace(rh,"\n").replace(sh,"")}function oh(e,t){return t=ah(t),ah(e)===t}function lh(e,t,n,r,s,a){switch(n){case"children":"string"==typeof r?"body"===t||"textarea"===t&&""===r||wt(e,r):("number"==typeof r||"bigint"==typeof r)&&"body"!==t&&wt(e,""+r);break;case"className":ot(e,"class",r);break;case"tabIndex":ot(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":ot(e,n,r);break;case"style":Tt(e,r,a);break;case"data":if("object"!==t){ot(e,"data",r);break}case"src":case"href":if(""===r&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==r||"function"==typeof r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Ct(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if("function"==typeof r){e.setAttribute(n,"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}if("function"==typeof a&&("formAction"===n?("input"!==t&&lh(e,t,"name",s.name,s,null),lh(e,t,"formEncType",s.formEncType,s,null),lh(e,t,"formMethod",s.formMethod,s,null),lh(e,t,"formTarget",s.formTarget,s,null)):(lh(e,t,"encType",s.encType,s,null),lh(e,t,"method",s.method,s,null),lh(e,t,"target",s.target,s,null))),null==r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Ct(""+r),e.setAttribute(n,r);break;case"onClick":null!=r&&(e.onclick=Pt);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=s.children)throw Error(i(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"muted":e.muted=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==r||"function"==typeof r||"boolean"==typeof r||"symbol"==typeof r){e.removeAttribute("xlink:href");break}n=Ct(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""+r):e.removeAttribute(n);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":r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===r?e.setAttribute(n,""):!1!==r&&null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":null==r||"function"==typeof r||"symbol"==typeof r||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":$u("beforetoggle",e),$u("toggle",e),at(e,"popover",r);break;case"xlinkActuate":lt(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":lt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":lt(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":lt(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":lt(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":lt(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":lt(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":lt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":lt(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":at(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&at(e,n=At.get(n)||n,r)}}function ch(e,t,n,r,s,a){switch(n){case"style":Tt(e,r,a);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=s.children)throw Error(i(60));e.innerHTML=n}}break;case"children":"string"==typeof r?wt(e,r):("number"==typeof r||"bigint"==typeof r)&&wt(e,""+r);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"onClick":null!=r&&(e.onclick=Pt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:et.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(s=n.endsWith("Capture"),t=n.slice(2,s?n.length-7:void 0),"function"==typeof(a=null!=(a=e[Be]||null)?a[n]:null)&&e.removeEventListener(t,a,s),"function"!=typeof r)?n in e?e[n]=r:!0===r?e.setAttribute(n,""):at(e,n,r):("function"!=typeof a&&null!==a&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,s)))}}function uh(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$u("error",e),$u("load",e);var r,s=!1,a=!1;for(r in n)if(n.hasOwnProperty(r)){var o=n[r];if(null!=o)switch(r){case"src":s=!0;break;case"srcSet":a=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:lh(e,t,r,o,n,null)}}return a&&lh(e,t,"srcSet",n.srcSet,n,null),void(s&&lh(e,t,"src",n.src,n,null));case"input":$u("invalid",e);var l=r=o=a=null,c=null,u=null;for(s in n)if(n.hasOwnProperty(s)){var h=n[s];if(null!=h)switch(s){case"name":a=h;break;case"type":o=h;break;case"checked":c=h;break;case"defaultChecked":u=h;break;case"value":r=h;break;case"defaultValue":l=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(i(137,t));break;default:lh(e,t,s,h,n,null)}}return void vt(e,r,l,c,u,o,a,!1);case"select":for(a in $u("invalid",e),s=o=r=null,n)if(n.hasOwnProperty(a)&&null!=(l=n[a]))switch(a){case"value":r=l;break;case"defaultValue":o=l;break;case"multiple":s=l;default:lh(e,t,a,l,n,null)}return t=r,n=o,e.multiple=!!s,void(null!=t?xt(e,!!s,t,!1):null!=n&&xt(e,!!s,n,!0));case"textarea":for(o in $u("invalid",e),r=a=s=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":s=l;break;case"defaultValue":a=l;break;case"children":r=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(i(91));break;default:lh(e,t,o,l,n,null)}return void _t(e,s,a,r);case"option":for(c in n)n.hasOwnProperty(c)&&null!=(s=n[c])&&("selected"===c?e.selected=s&&"function"!=typeof s&&"symbol"!=typeof s:lh(e,t,c,s,n,null));return;case"dialog":$u("beforetoggle",e),$u("toggle",e),$u("cancel",e),$u("close",e);break;case"iframe":case"object":$u("load",e);break;case"video":case"audio":for(s=0;s<ju.length;s++)$u(ju[s],e);break;case"image":$u("error",e),$u("load",e);break;case"details":$u("toggle",e);break;case"embed":case"source":case"link":$u("error",e),$u("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(s=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:lh(e,t,u,s,n,null)}return;default:if(Et(t)){for(h in n)n.hasOwnProperty(h)&&void 0!==(s=n[h])&&ch(e,t,h,s,n,void 0);return}}for(l in n)n.hasOwnProperty(l)&&null!=(s=n[l])&&lh(e,t,l,s,n,null)}function hh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var dh=null,ph=null;function fh(e){return 9===e.nodeType?e:e.ownerDocument}function mh(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function gh(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function vh(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var yh=null,xh="function"==typeof setTimeout?setTimeout:void 0,bh="function"==typeof clearTimeout?clearTimeout:void 0,_h="function"==typeof Promise?Promise:void 0,wh="function"==typeof queueMicrotask?queueMicrotask:void 0!==_h?function(e){return _h.resolve(null).then(e).catch(Sh)}:xh;function Sh(e){setTimeout(function(){throw e})}function Mh(e){return"head"===e}function Th(e,t){var n=t,i=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)||"/&"===n){if(0===i)return e.removeChild(r),void Gd(t);i--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)i++;else if("html"===n)Fh(e.ownerDocument.documentElement);else if("head"===n){Fh(n=e.ownerDocument.head);for(var s=n.firstChild;s;){var a=s.nextSibling,o=s.nodeName;s[Xe]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===s.rel.toLowerCase()||n.removeChild(s),s=a}}else"body"===n&&Fh(e.ownerDocument.body);n=r}while(n);Gd(t)}function Eh(e,t){var n=e;e=0;do{var i=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=i}while(n)}function Ah(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Ah(n),qe(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Rh(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Ih(e.nextSibling)))return null}return e}function Ch(e){return"$?"===e.data||"$~"===e.data}function Ph(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Ih(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Lh=null;function Dh(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Ih(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Nh(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Oh(e,t,n){switch(t=fh(n),e){case"html":if(!(e=t.documentElement))throw Error(i(452));return e;case"head":if(!(e=t.head))throw Error(i(453));return e;case"body":if(!(e=t.body))throw Error(i(454));return e;default:throw Error(i(451))}}function Fh(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);qe(e)}var kh=new Map,Uh=new Set;function zh(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Bh=D.d;D.d={f:function(){var e=Bh.f(),t=Zc();return e||t},r:function(e){var t=Ye(e);null!==t&&5===t.tag&&"form"===t.type?eo(t):Bh.r(e)},D:function(e){Bh.D(e),Gh("dns-prefetch",e,null)},C:function(e,t){Bh.C(e,t),Gh("preconnect",e,t)},L:function(e,t,n){Bh.L(e,t,n);var i=Vh;if(i&&e&&t){var r='link[rel="preload"][as="'+mt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+mt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(r+='[imagesizes="'+mt(n.imageSizes)+'"]')):r+='[href="'+mt(e)+'"]';var s=r;switch(t){case"style":s=Wh(e);break;case"script":s=qh(e)}kh.has(s)||(e=h({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),kh.set(s,e),null!==i.querySelector(r)||"style"===t&&i.querySelector(jh(s))||"script"===t&&i.querySelector($h(s))||(uh(t=i.createElement("link"),"link",e),Je(t),i.head.appendChild(t)))}},m:function(e,t){Bh.m(e,t);var n=Vh;if(n&&e){var i=t&&"string"==typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+mt(i)+'"][href="'+mt(e)+'"]',s=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":s=qh(e)}if(!kh.has(s)&&(e=h({rel:"modulepreload",href:e},t),kh.set(s,e),null===n.querySelector(r))){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector($h(s)))return}uh(i=n.createElement("link"),"link",e),Je(i),n.head.appendChild(i)}}},X:function(e,t){Bh.X(e,t);var n=Vh;if(n&&e){var i=Ze(n).hoistableScripts,r=qh(e),s=i.get(r);s||((s=n.querySelector($h(r)))||(e=h({src:e,async:!0},t),(t=kh.get(r))&&Jh(e,t),Je(s=n.createElement("script")),uh(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},i.set(r,s))}},S:function(e,t,n){Bh.S(e,t,n);var i=Vh;if(i&&e){var r=Ze(i).hoistableStyles,s=Wh(e);t=t||"default";var a=r.get(s);if(!a){var o={loading:0,preload:null};if(a=i.querySelector(jh(s)))o.loading=5;else{e=h({rel:"stylesheet",href:e,"data-precedence":t},n),(n=kh.get(s))&&Zh(e,n);var l=a=i.createElement("link");Je(l),uh(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){o.loading|=1}),l.addEventListener("error",function(){o.loading|=2}),o.loading|=4,Kh(a,t,i)}a={type:"stylesheet",instance:a,count:1,state:o},r.set(s,a)}}},M:function(e,t){Bh.M(e,t);var n=Vh;if(n&&e){var i=Ze(n).hoistableScripts,r=qh(e),s=i.get(r);s||((s=n.querySelector($h(r)))||(e=h({src:e,async:!0,type:"module"},t),(t=kh.get(r))&&Jh(e,t),Je(s=n.createElement("script")),uh(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},i.set(r,s))}}};var Vh="undefined"==typeof document?null:document;function Gh(e,t,n){var i=Vh;if(i&&"string"==typeof t&&t){var r=mt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"==typeof n&&(r+='[crossorigin="'+n+'"]'),Uh.has(r)||(Uh.add(r),e={rel:e,crossOrigin:n,href:t},null===i.querySelector(r)&&(uh(t=i.createElement("link"),"link",e),Je(t),i.head.appendChild(t)))}}function Hh(e,t,n,r){var s,a,o,l,c=(c=W.current)?zh(c):null;if(!c)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=Wh(n.href),(r=(n=Ze(c).hoistableStyles).get(t))||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=Wh(n.href);var u=Ze(c).hoistableStyles,h=u.get(e);if(h||(c=c.ownerDocument||c,h={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,h),(u=c.querySelector(jh(e)))&&!u._p&&(h.instance=u,h.state.loading=5),kh.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},kh.set(e,n),u||(s=c,a=e,o=n,l=h.state,s.querySelector('link[rel="preload"][as="style"]['+a+"]")?l.loading=1:(a=s.createElement("link"),l.preload=a,a.addEventListener("load",function(){return l.loading|=1}),a.addEventListener("error",function(){return l.loading|=2}),uh(a,"link",o),Je(a),s.head.appendChild(a))))),t&&null===r)throw Error(i(528,""));return h}if(t&&null!==r)throw Error(i(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=qh(n),(r=(n=Ze(c).hoistableScripts).get(t))||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Wh(e){return'href="'+mt(e)+'"'}function jh(e){return'link[rel="stylesheet"]['+e+"]"}function Xh(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function qh(e){return'[src="'+mt(e)+'"]'}function $h(e){return"script[async]"+e}function Yh(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+mt(n.href)+'"]');if(r)return t.instance=r,Je(r),r;var s=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return Je(r=(e.ownerDocument||e).createElement("style")),uh(r,"style",s),Kh(r,n.precedence,e),t.instance=r;case"stylesheet":s=Wh(n.href);var a=e.querySelector(jh(s));if(a)return t.state.loading|=4,t.instance=a,Je(a),a;r=Xh(n),(s=kh.get(s))&&Zh(r,s),Je(a=(e.ownerDocument||e).createElement("link"));var o=a;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),uh(a,"link",r),t.state.loading|=4,Kh(a,n.precedence,e),t.instance=a;case"script":return a=qh(n.src),(s=e.querySelector($h(a)))?(t.instance=s,Je(s),s):(r=n,(s=kh.get(a))&&Jh(r=h({},n),s),Je(s=(e=e.ownerDocument||e).createElement("script")),uh(s,"link",r),e.head.appendChild(s),t.instance=s);case"void":return null;default:throw Error(i(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(r=t.instance,t.state.loading|=4,Kh(r,n.precedence,e));return t.instance}function Kh(e,t,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,s=r,a=0;a<i.length;a++){var o=i[a];if(o.dataset.precedence===t)s=o;else if(s!==r)break}s?s.parentNode.insertBefore(e,s.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Zh(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Jh(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var Qh=null;function ed(e,t,n){if(null===Qh){var i=new Map,r=Qh=new Map;r.set(n,i)}else(i=(r=Qh).get(n))||(i=new Map,r.set(n,i));if(i.has(e))return i;for(i.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var s=n[r];if(!(s[Xe]||s[ze]||"link"===e&&"stylesheet"===s.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==s.namespaceURI){var a=s.getAttribute(t)||"";a=e+a;var o=i.get(a);o?o.push(s):i.set(a,[s])}}return i}function td(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function nd(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var id=0;function rd(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var sd=null;function ad(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,sd=new Map,t.forEach(od,e),sd=null,rd.call(e))}function od(e,t){if(!(4&t.state.loading)){var n=sd.get(e);if(n)var i=n.get(null);else{n=new Map,sd.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),s=0;s<r.length;s++){var a=r[s];"LINK"!==a.nodeName&&"not all"===a.getAttribute("media")||(n.set(a.dataset.precedence,a),i=a)}i&&n.set(null,i)}a=(r=t.instance).getAttribute("data-precedence"),(s=n.get(a)||i)===i&&n.set(null,r),n.set(a,r),this.count++,i=rd.bind(this),r.addEventListener("load",i),r.addEventListener("error",i),s?s.parentNode.insertBefore(r,s.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var ld={$$typeof:x,Provider:null,Consumer:null,_currentValue:N,_currentValue2:N,_threadCount:0};function cd(e,t,n,i,r,s,a,o,l){this.tag=1,this.containerInfo=e,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=Ce(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ce(0),this.hiddenUpdates=Ce(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=s,this.onRecoverableError=a,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function ud(e,t,n,i,r,s,a,o,l,c,u,h){return e=new cd(e,t,n,a,l,c,u,h,o),t=1,!0===s&&(t|=24),s=Fi(3,null,null,t),e.current=s,s.stateNode=e,(t=kr()).refCount++,e.pooledCache=t,t.refCount++,s.memoizedState={element:i,isDehydrated:n,cache:t},fs(s),e}function hd(e){return e?e=Ni:Ni}function dd(e,t,n,i,r,s){r=hd(r),null===i.context?i.context=r:i.pendingContext=r,(i=gs(t)).payload={element:n},null!==(s=void 0===s?null:s)&&(i.callback=s),null!==(n=vs(e,i,t))&&(Xc(n,0,t),ys(n,e,t))}function pd(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function fd(e,t){pd(e,t),(e=e.alternate)&&pd(e,t)}function md(e){if(13===e.tag||31===e.tag){var t=Ii(e,67108864);null!==t&&Xc(t,0,67108864),fd(e,67108864)}}function gd(e){if(13===e.tag||31===e.tag){var t=Wc(),n=Ii(e,t=Ne(t));null!==n&&Xc(n,0,t),fd(e,t)}}var vd=!0;function yd(e,t,n,i){var r=L.T;L.T=null;var s=D.p;try{D.p=2,bd(e,t,n,i)}finally{D.p=s,L.T=r}}function xd(e,t,n,i){var r=L.T;L.T=null;var s=D.p;try{D.p=8,bd(e,t,n,i)}finally{D.p=s,L.T=r}}function bd(e,t,n,i){if(vd){var r=_d(i);if(null===r)Qu(e,t,i,wd,n),Dd(e,i);else if(function(e,t,n,i,r){switch(t){case"focusin":return Ed=Nd(Ed,e,t,n,i,r),!0;case"dragenter":return Ad=Nd(Ad,e,t,n,i,r),!0;case"mouseover":return Rd=Nd(Rd,e,t,n,i,r),!0;case"pointerover":var s=r.pointerId;return Cd.set(s,Nd(Cd.get(s)||null,e,t,n,i,r)),!0;case"gotpointercapture":return s=r.pointerId,Pd.set(s,Nd(Pd.get(s)||null,e,t,n,i,r)),!0}return!1}(r,e,t,n,i))i.stopPropagation();else if(Dd(e,i),4&t&&-1<Ld.indexOf(e)){for(;null!==r;){var s=Ye(r);if(null!==s)switch(s.tag){case 3:if((s=s.stateNode).current.memoizedState.isDehydrated){var a=Me(s.pendingLanes);if(0!==a){var o=s;for(o.pendingLanes|=2,o.entangledLanes|=2;a;){var l=1<<31-ye(a);o.entanglements[1]|=l,a&=~l}Du(s),!(6&hc)&&(Lc=ae()+500,Nu(0))}}break;case 31:case 13:null!==(o=Ii(s,2))&&Xc(o,0,2),Zc(),fd(s,2)}if(null===(s=_d(i))&&Qu(e,t,i,wd,n),s===r)break;r=s}null!==r&&i.stopPropagation()}else Qu(e,t,i,null,n)}}function _d(e){return Sd(e=Lt(e))}var wd=null;function Sd(e){if(wd=null,null!==(e=$e(e))){var t=s(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=a(t)))return e;e=null}else if(31===n){if(null!==(e=o(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return wd=e,null}function Md(e){switch(e){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(oe()){case le:return 2;case ce:return 8;case ue:case he:return 32;case de:return 268435456;default:return 32}default:return 32}}var Td=!1,Ed=null,Ad=null,Rd=null,Cd=new Map,Pd=new Map,Id=[],Ld="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 Dd(e,t){switch(e){case"focusin":case"focusout":Ed=null;break;case"dragenter":case"dragleave":Ad=null;break;case"mouseover":case"mouseout":Rd=null;break;case"pointerover":case"pointerout":Cd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Pd.delete(t.pointerId)}}function Nd(e,t,n,i,r,s){return null===e||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:i,nativeEvent:s,targetContainers:[r]},null!==t&&null!==(t=Ye(t))&&md(t),e):(e.eventSystemFlags|=i,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function Od(e){var t=$e(e.target);if(null!==t){var n=s(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=a(n)))return e.blockedOn=t,void ke(e.priority,function(){gd(n)})}else if(31===t){if(null!==(t=o(n)))return e.blockedOn=t,void ke(e.priority,function(){gd(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Fd(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=_d(e.nativeEvent);if(null!==n)return null!==(t=Ye(n))&&md(t),e.blockedOn=n,!1;var i=new(n=e.nativeEvent).constructor(n.type,n);It=i,n.target.dispatchEvent(i),It=null,t.shift()}return!0}function kd(e,t,n){Fd(e)&&n.delete(t)}function Ud(){Td=!1,null!==Ed&&Fd(Ed)&&(Ed=null),null!==Ad&&Fd(Ad)&&(Ad=null),null!==Rd&&Fd(Rd)&&(Rd=null),Cd.forEach(kd),Pd.forEach(kd)}function zd(t,n){t.blockedOn===n&&(t.blockedOn=null,Td||(Td=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Ud)))}var Bd=null;function Vd(t){Bd!==t&&(Bd=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Bd===t&&(Bd=null);for(var e=0;e<t.length;e+=3){var n=t[e],i=t[e+1],r=t[e+2];if("function"!=typeof i){if(null===Sd(i||n))continue;break}var s=Ye(n);null!==s&&(t.splice(e,3),e-=3,Ja(s,{pending:!0,data:r,method:n.method,action:i},i,r))}}))}function Gd(e){function t(t){return zd(t,e)}null!==Ed&&zd(Ed,e),null!==Ad&&zd(Ad,e),null!==Rd&&zd(Rd,e),Cd.forEach(t),Pd.forEach(t);for(var n=0;n<Id.length;n++){var i=Id[n];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Id.length&&null===(n=Id[0]).blockedOn;)Od(n),null===n.blockedOn&&Id.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(i=0;i<n.length;i+=3){var r=n[i],s=n[i+1],a=r[Be]||null;if("function"==typeof s)a||Vd(n);else if(a){var o=null;if(s&&s.hasAttribute("formAction")){if(r=s,a=s[Be]||null)o=a.formAction;else if(null!==Sd(r))continue}else o=a.action;"function"==typeof o?n[i+1]=o:(n.splice(i,3),i-=3),Vd(n)}}}function Hd(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return r=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==r&&(r(),r=null),i||setTimeout(n,20)}function n(){if(!i&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var i=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==r&&(r(),r=null)}}}function Wd(e){this._internalRoot=e}function jd(e){this._internalRoot=e}jd.prototype.render=Wd.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(i(409));dd(t.current,Wc(),e,t,null,null)},jd.prototype.unmount=Wd.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;dd(e.current,2,null,e,null,null),Zc(),t[Ve]=null}},jd.prototype.unstable_scheduleHydration=function(e){if(e){var t=Fe();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Id.length&&0!==t&&t<Id[n].priority;n++);Id.splice(n,0,e),0===n&&Od(e)}};var Xd=t.version;if("19.2.8"!==Xd)throw Error(i(527,Xd,"19.2.8"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(i(188));throw e=Object.keys(e).join(","),Error(i(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=s(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(null===a)break;var o=a.alternate;if(null===o){if(null!==(r=a.return)){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return c(a),e;if(o===r)return c(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var l=!1,u=a.child;u;){if(u===n){l=!0,n=a,r=o;break}if(u===r){l=!0,r=a,n=o;break}u=u.sibling}if(!l){for(u=o.child;u;){if(u===n){l=!0,n=o,r=a;break}if(u===r){l=!0,r=o,n=a;break}u=u.sibling}if(!l)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}(t),null===(e=null!==e?u(e):null)?null:e.stateNode};var qd={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.8"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var $d=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$d.isDisabled&&$d.supportsFiber)try{me=$d.inject(qd),ge=$d}catch(e){}}return SR.createRoot=function(e,t){if(!r(e))throw Error(i(299));var n=!1,s="",a=wo,o=So,l=Mo;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(s=t.identifierPrefix),void 0!==t.onUncaughtError&&(a=t.onUncaughtError),void 0!==t.onCaughtError&&(o=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError)),t=ud(e,1,!1,null,0,n,s,null,a,o,l,Hd),e[Ve]=t.current,Zu(e),new Wd(t)},SR.hydrateRoot=function(e,t,n){if(!r(e))throw Error(i(299));var s=!1,a="",o=wo,l=So,c=Mo,u=null;return null!=n&&(!0===n.unstable_strictMode&&(s=!0),void 0!==n.identifierPrefix&&(a=n.identifierPrefix),void 0!==n.onUncaughtError&&(o=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.formState&&(u=n.formState)),(t=ud(e,1,!0,t,0,s,a,u,o,l,c,Hd)).context=hd(null),n=t.current,(a=gs(s=Ne(s=Wc()))).callback=null,vs(n,a,s),n=s,t.current.lanes=n,Pe(t,n),Du(t),e[Ve]=t.current,Zu(e),new jd(t)},SR.version="19.2.8",SR}();var DR=wR.exports;class NR{constructor(e){this.version="2.6.0",e.ipd=0,Nr.getState().setInputMode(e.primaryInputMode),this.devUIContainer=document.createElement("div"),this.devUIContainer.style.position="fixed",this.devUIContainer.style.width="100vw",this.devUIContainer.style.height="100vh",this.devUIContainer.style.top="50vh",this.devUIContainer.style.left="50vw",this.devUIContainer.style.transform="translate(-50%, -50%)",this.devUIContainer.style.pointerEvents="none";const t=this.devUIContainer.attachShadow({mode:"open"});this.inputLayer=new xR(e),Hc.setState({mode:this.inputLayer.currentGazeMode,commitHand:this.inputLayer.currentGazeCommitHand}),this.unsubscribeControlMode=e.onControlModeChange(t=>{"programmatic"===t?(this.inputLayer.setProgrammaticMode(!0),this.inputLayer.syncFromDevice(),Nr.getState().setInputMode(e.primaryInputMode),Hc.getState().setMode(this.inputLayer.currentGazeMode),this.inputLayer.setInteractionsEnabled(!1)):(this.inputLayer.setProgrammaticMode(!1),this.inputLayer.setInteractionsEnabled(!0),Hc.getState().setMode(this.inputLayer.currentGazeMode))}),this.unsubscribeStateChange=e.onStateChange(()=>{this.inputLayer.isInProgrammaticMode&&(this.inputLayer.syncFromDevice(),Nr.getState().setInputMode(e.primaryInputMode),Hc.getState().setMode(this.inputLayer.currentGazeMode))});DR.createRoot(t).render(u.jsx(OR,{xrDevice:e,inputLayer:this.inputLayer,shadowRoot:t}));const n=()=>{const t=document.createElement("div");document.body.appendChild(t);const n=t.attachShadow({mode:"open"});DR.createRoot(n).render(u.jsx(FR,{xrDevice:e,shadowRoot:n}))};document.body?n():window.onload=n}render(e){this.inputLayer.renderScene(e)}applyDefaultPose(e){this.inputLayer.applyDefaultPose(e)}setGazeMode(e){this.inputLayer.setGazeMode(e),Hc.getState().setMode(this.inputLayer.currentGazeMode)}setGazeCommitHand(e){this.inputLayer.setGazeCommitHand(e),Hc.getState().setCommitHand(e)}onSessionEnd(){this.inputLayer.onSessionEnd()}dispose(){this.unsubscribeControlMode(),this.unsubscribeStateChange(),this.inputLayer.dispose()}get devUICanvas(){return this.inputLayer.domElement}}const OR=({xrDevice:e,inputLayer:t,shadowRoot:n})=>{const[i,r]=l.useState(!1),[s,a]=l.useState(e.controlMode);return l.useEffect(()=>{const t=()=>{const e=document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement;r(!!e)};document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1);const n=e.onControlModeChange(e=>{a(e)});return()=>{document.removeEventListener("pointerlockchange",t,!1),document.removeEventListener("mozpointerlockchange",t,!1),document.removeEventListener("webkitpointerlockchange",t,!1),n()}},[e]),u.jsx(Ht,{target:n,disableCSSOMInjection:!0,children:u.jsxs("div",{style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between",pointerEvents:"none"},children:["programmatic"===s&&u.jsxs(u.Fragment,{children:[u.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:999,boxShadow:"inset 0 0 20px 5px rgba(59, 130, 246, 0.5)"}}),u.jsxs("div",{style:{position:"absolute",bottom:"8px",left:"50%",transform:"translateX(-50%)",backgroundColor:"rgba(59, 130, 246, 0.9)",color:"white",padding:"6px 16px",borderRadius:"16px",fontSize:"12px",fontFamily:"system-ui, sans-serif",fontWeight:500,zIndex:1e3,display:"flex",alignItems:"center",gap:"6px",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"},children:[u.jsx("span",{style:{fontSize:"14px"},children:"●"}),"Remote Control Active"]})]}),"programmatic"!==s&&u.jsxs(u.Fragment,{children:[u.jsx(gu,{xrDevice:e,inputLayer:t}),u.jsx(Or,{xrDevice:e,inputLayer:t,pointerLocked:i})]})]})})},FR=({xrDevice:e,shadowRoot:t})=>{const[n,i]=c.useState(e.sessionOffered&&!e.activeSession);return c.useEffect(()=>{const t=setInterval(()=>{i(e.sessionOffered&&!e.activeSession)},1e3);return()=>{clearInterval(t)}},[]),u.jsx(Ht,{target:t,disableCSSOMInjection:!0,children:u.jsxs(Mn,{style:{zIndex:899,position:"fixed",top:"8px",display:"flex",flexDirection:"row",alignItems:"center",justifyItems:"space-between",left:"50vw",transform:n?"translateX(-50%)":"translateX(-50%) translateY(calc(-100% - 12px))",transition:"transform 0.2s ease-in-out",paddingLeft:"5px",gap:"3px"},children:[u.jsx(Fi,{name:"iwer",size:24}),u.jsx(Tn,{onClick:()=>{e.grantOfferedSession()},style:{fontSize:"16px"},children:"Enter XR"})]})})};function kR(){let e=0,t=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(e|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(t|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function UR(e,t,n){for(let i=0;i<28;i+=7){const r=e>>>i,s=!(r>>>7==0&&0==t),a=255&(s?128|r:r);if(n.push(a),!s)return}const i=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|i:i)),r){for(let e=3;e<31;e+=7){const i=t>>>e,r=!(i>>>7==0),s=255&(r?128|i:i);if(n.push(s),!r)return}n.push(t>>>31&1)}}const zR=4294967296;function BR(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let i=0,r=0;function s(t,s){const a=Number(e.slice(t,s));r*=n,i=i*n+a,i>=zR&&(r+=i/zR|0,i%=zR)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?HR(i,r):GR(i,r)}function VR(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(zR*t+e);const n=16777215&(e>>>24|t<<8),i=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*i,s=n+8147497*i,a=2*i;const o=1e7;return r>=o&&(s+=Math.floor(r/o),r%=o),s>=o&&(a+=Math.floor(s/o),s%=o),a.toString()+WR(s)+WR(r)}function GR(e,t){return{lo:0|e,hi:0|t}}function HR(e,t){return t=~t,e?e=1+~e:t+=1,GR(e,t)}const WR=e=>{const t=String(e);return"0000000".slice(t.length)+t};function jR(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function XR(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}const qR=$R();function $R(){const e=new DataView(new ArrayBuffer(8));if(!("function"!=typeof BigInt||"function"!=typeof e.getBigInt64||"function"!=typeof e.getBigUint64||"function"!=typeof e.setBigInt64||"function"!=typeof e.setBigUint64||!globalThis.Deno&&!globalThis.Bun&&"object"==typeof process&&"object"==typeof process.env&&"1"===process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const i="bigint"==typeof e?e:BigInt(e);if(i>n||i<t)throw new Error(`invalid int64: ${e}`);return i},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<i)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),YR(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),KR(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),YR(e),BR(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),KR(e),BR(e)),dec:(e,t)=>function(e,t){let n=GR(e,t);const i=2147483648&n.hi;i&&(n=HR(n.lo,n.hi));const r=VR(n.lo,n.hi);return i?"-"+r:r}(e,t),uDec:(e,t)=>VR(e,t)}}function YR(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function KR(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const ZR=Symbol.for("@bufbuild/protobuf/text-encoding");function JR(){if(null==globalThis[ZR]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;let n;globalThis[ZR]={encodeUtf8:t=>e.encode(t),decodeUtf8:(e,i)=>i?(void 0===n&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(e)):t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[ZR]}var QR;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(QR||(QR={}));const eC=34028234663852886e22,tC=-34028234663852886e22;class nC{constructor(e=JR().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(sC(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return rC(e),jR(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>eC||e<tC))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){sC(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){rC(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return rC(e),jR(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=qR.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=qR.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=qR.enc(e);return UR(t.lo,t.hi,this.buf),this}sint64(e){const t=qR.enc(e),n=t.hi>>31;return UR(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){const t=qR.uEnc(e);return UR(t.lo,t.hi,this.buf),this}}class iC{constructor(e,t=JR().decodeUtf8){this.decodeUtf8=t,this.varint64=kR,this.uint32=XR,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){const e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||5==n&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");const i=t>>>3,r=7&t;if(i<=0||r>5)throw new Error("illegal tag: field no "+i+" wire type "+r);return[i,r]}skip(e,t,n=100){let i=this.pos;switch(e){case QR.Varint:for(;128&this.buf[this.pos++];);break;case QR.Bit64:this.pos+=4;case QR.Bit32:this.pos+=4;break;case QR.LengthDelimited:let i=this.uint32();this.pos+=i;break;case QR.StartGroup:if(n<=0)throw new Error("maximum recursion depth reached");for(;;){const[e,i]=this.tag();if(i===QR.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(i,e,n-1)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return qR.dec(...this.varint64())}uint64(){return qR.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,qR.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return qR.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return qR.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){return this.decodeUtf8(this.bytes(),e)}}function rC(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function sC(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const aC={encode:(e,t=new nC)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:fC(e.x)?globalThis.Number(e.x):0,y:fC(e.y)?globalThis.Number(e.y):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),t},create:e=>aC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={x:0,y:0};return i.x=null!==(t=e.x)&&void 0!==t?t:0,i.y=null!==(n=e.y)&&void 0!==n?n:0,i}};const oC={encode:(e,t=new nC)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:fC(e.width)?globalThis.Number(e.width):0,height:fC(e.height)?globalThis.Number(e.height):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),t},create:e=>oC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={width:0,height:0};return i.width=null!==(t=e.width)&&void 0!==t?t:0,i.height=null!==(n=e.height)&&void 0!==n?n:0,i}};const lC={encode:(e,t=new nC)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:fC(e.x)?globalThis.Number(e.x):0,y:fC(e.y)?globalThis.Number(e.y):0,z:fC(e.z)?globalThis.Number(e.z):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),t},create:e=>lC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={x:0,y:0,z:0};return r.x=null!==(t=e.x)&&void 0!==t?t:0,r.y=null!==(n=e.y)&&void 0!==n?n:0,r.z=null!==(i=e.z)&&void 0!==i?i:0,r}};const cC={encode:(e,t=new nC)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),0!==e.depth&&t.uint32(29).float(e.depth),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0,depth:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue;case 3:if(29!==e)break;r.depth=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:fC(e.width)?globalThis.Number(e.width):0,height:fC(e.height)?globalThis.Number(e.height):0,depth:fC(e.depth)?globalThis.Number(e.depth):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),0!==e.depth&&(t.depth=e.depth),t},create:e=>cC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={width:0,height:0,depth:0};return r.width=null!==(t=e.width)&&void 0!==t?t:0,r.height=null!==(n=e.height)&&void 0!==n?n:0,r.depth=null!==(i=e.depth)&&void 0!==i?i:0,r}};const uC={encode:(e,t=new nC)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),0!==e.w&&t.uint32(37).float(e.w),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0,w:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue;case 4:if(37!==e)break;r.w=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:fC(e.x)?globalThis.Number(e.x):0,y:fC(e.y)?globalThis.Number(e.y):0,z:fC(e.z)?globalThis.Number(e.z):0,w:fC(e.w)?globalThis.Number(e.w):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),0!==e.w&&(t.w=e.w),t},create:e=>uC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i,r;const s={x:0,y:0,z:0,w:0};return s.x=null!==(t=e.x)&&void 0!==t?t:0,s.y=null!==(n=e.y)&&void 0!==n?n:0,s.z=null!==(i=e.z)&&void 0!==i?i:0,s.w=null!==(r=e.w)&&void 0!==r?r:0,s}};const hC={encode:(e,t=new nC)=>(void 0!==e.offset&&aC.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&oC.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=aC.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=oC.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:fC(e.offset)?aC.fromJSON(e.offset):void 0,extent:fC(e.extent)?oC.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=aC.toJSON(e.offset)),void 0!==e.extent&&(t.extent=oC.toJSON(e.extent)),t},create:e=>hC.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?aC.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?oC.fromPartial(e.extent):void 0,t}};const dC={encode:(e,t=new nC)=>(void 0!==e.offset&&lC.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&cC.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=lC.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=cC.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:fC(e.offset)?lC.fromJSON(e.offset):void 0,extent:fC(e.extent)?cC.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=lC.toJSON(e.offset)),void 0!==e.extent&&(t.extent=cC.toJSON(e.extent)),t},create:e=>dC.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?lC.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?cC.fromPartial(e.extent):void 0,t}};const pC={encode:(e,t=new nC)=>(void 0!==e.orientation&&uC.encode(e.orientation,t.uint32(10).fork()).join(),void 0!==e.position&&lC.encode(e.position,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={orientation:void 0,position:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.orientation=uC.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.position=lC.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({orientation:fC(e.orientation)?uC.fromJSON(e.orientation):void 0,position:fC(e.position)?lC.fromJSON(e.position):void 0}),toJSON(e){const t={};return void 0!==e.orientation&&(t.orientation=uC.toJSON(e.orientation)),void 0!==e.position&&(t.position=lC.toJSON(e.position)),t},create:e=>pC.fromPartial(null!=e?e:{}),fromPartial(e){const t={orientation:void 0,position:void 0};return t.orientation=void 0!==e.orientation&&null!==e.orientation?uC.fromPartial(e.orientation):void 0,t.position=void 0!==e.position&&null!==e.position?lC.fromPartial(e.position):void 0,t}};function fC(e){return null!=e}var mC,gC;function vC(e){switch(e){case 0:case"Keyboard":return mC.Keyboard;default:return mC.UNRECOGNIZED}}function yC(e){switch(e){case 0:case"UNKNOWN":return gC.UNKNOWN;case 1:case"FLOOR":return gC.FLOOR;case 2:case"CEILING":return gC.CEILING;case 3:case"WALL_FACE":return gC.WALL_FACE;case 4:case"TABLE":return gC.TABLE;case 5:case"COUCH":return gC.COUCH;case 6:case"DOOR_FRAME":return gC.DOOR_FRAME;case 7:case"WINDOW_FRAME":return gC.WINDOW_FRAME;case 8:case"OTHER":return gC.OTHER;case 9:case"STORAGE":return gC.STORAGE;case 10:case"BED":return gC.BED;case 11:case"SCREEN":return gC.SCREEN;case 12:case"LAMP":return gC.LAMP;case 13:case"PLANT":return gC.PLANT;case 14:case"WALL_ART":return gC.WALL_ART;case 15:case"GLOBAL_MESH":return gC.GLOBAL_MESH;case 16:case"INVISIBLE_WALL_FACE":return gC.INVISIBLE_WALL_FACE;case 17:case"CHAIR":return gC.CHAIR;case 18:case"INNER_WALL_FACE":return gC.INNER_WALL_FACE;case 19:case"OTHER_ROOM_FACE":return gC.OTHER_ROOM_FACE;case 20:case"OPENING":return gC.OPENING;default:return gC.UNRECOGNIZED}}function xC(e){switch(e){case gC.UNKNOWN:return"UNKNOWN";case gC.FLOOR:return"FLOOR";case gC.CEILING:return"CEILING";case gC.WALL_FACE:return"WALL_FACE";case gC.TABLE:return"TABLE";case gC.COUCH:return"COUCH";case gC.DOOR_FRAME:return"DOOR_FRAME";case gC.WINDOW_FRAME:return"WINDOW_FRAME";case gC.OTHER:return"OTHER";case gC.STORAGE:return"STORAGE";case gC.BED:return"BED";case gC.SCREEN:return"SCREEN";case gC.LAMP:return"LAMP";case gC.PLANT:return"PLANT";case gC.WALL_ART:return"WALL_ART";case gC.GLOBAL_MESH:return"GLOBAL_MESH";case gC.INVISIBLE_WALL_FACE:return"INVISIBLE_WALL_FACE";case gC.CHAIR:return"CHAIR";case gC.INNER_WALL_FACE:return"INNER_WALL_FACE";case gC.OTHER_ROOM_FACE:return"OTHER_ROOM_FACE";case gC.OPENING:return"OPENING";case gC.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.Keyboard=0]="Keyboard",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(mC||(mC={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.FLOOR=1]="FLOOR",e[e.CEILING=2]="CEILING",e[e.WALL_FACE=3]="WALL_FACE",e[e.TABLE=4]="TABLE",e[e.COUCH=5]="COUCH",e[e.DOOR_FRAME=6]="DOOR_FRAME",e[e.WINDOW_FRAME=7]="WINDOW_FRAME",e[e.OTHER=8]="OTHER",e[e.STORAGE=9]="STORAGE",e[e.BED=10]="BED",e[e.SCREEN=11]="SCREEN",e[e.LAMP=12]="LAMP",e[e.PLANT=13]="PLANT",e[e.WALL_ART=14]="WALL_ART",e[e.GLOBAL_MESH=15]="GLOBAL_MESH",e[e.INVISIBLE_WALL_FACE=16]="INVISIBLE_WALL_FACE",e[e.CHAIR=17]="CHAIR",e[e.INNER_WALL_FACE=18]="INNER_WALL_FACE",e[e.OTHER_ROOM_FACE=19]="OTHER_ROOM_FACE",e[e.OPENING=20]="OPENING",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(gC||(gC={}));const bC={encode(e,t=new nC){""!==e.floorUuid&&t.uint32(10).string(e.floorUuid),""!==e.ceilingUuid&&t.uint32(18).string(e.ceilingUuid);for(const n of e.wallUuids)t.uint32(26).string(n);return t},decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.floorUuid=n.string();continue;case 2:if(18!==e)break;r.ceilingUuid=n.string();continue;case 3:if(26!==e)break;r.wallUuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({floorUuid:PC(e.floorUuid)?globalThis.String(e.floorUuid):"",ceilingUuid:PC(e.ceilingUuid)?globalThis.String(e.ceilingUuid):"",wallUuids:globalThis.Array.isArray(null==e?void 0:e.wallUuids)?e.wallUuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return""!==e.floorUuid&&(n.floorUuid=e.floorUuid),""!==e.ceilingUuid&&(n.ceilingUuid=e.ceilingUuid),(null===(t=e.wallUuids)||void 0===t?void 0:t.length)&&(n.wallUuids=e.wallUuids),n},create:e=>bC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};return r.floorUuid=null!==(t=e.floorUuid)&&void 0!==t?t:"",r.ceilingUuid=null!==(n=e.ceilingUuid)&&void 0!==n?n:"",r.wallUuids=(null===(i=e.wallUuids)||void 0===i?void 0:i.map(e=>e))||[],r}};const _C={encode(e,t=new nC){for(const n of e.uuids)t.uint32(10).string(n);return t},decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={uuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuids:globalThis.Array.isArray(null==e?void 0:e.uuids)?e.uuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return(null===(t=e.uuids)||void 0===t?void 0:t.length)&&(n.uuids=e.uuids),n},create:e=>_C.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={uuids:[]};return n.uuids=(null===(t=e.uuids)||void 0===t?void 0:t.map(e=>e))||[],n}};function wC(){return{vertices:new Uint8Array(0)}}const SC={encode:(e,t=new nC)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r=wC();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:PC(e.vertices)?RC(e.vertices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=CC(e.vertices)),t},create:e=>SC.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n=wC();return n.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),n}};function MC(){return{vertices:new Uint8Array(0),indices:new Uint8Array(0)}}const TC={encode:(e,t=new nC)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),0!==e.indices.length&&t.uint32(18).bytes(e.indices),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r=MC();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue;case 2:if(18!==e)break;r.indices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:PC(e.vertices)?RC(e.vertices):new Uint8Array(0),indices:PC(e.indices)?RC(e.indices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=CC(e.vertices)),0!==e.indices.length&&(t.indices=CC(e.indices)),t},create:e=>TC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i=MC();return i.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),i.indices=null!==(n=e.indices)&&void 0!==n?n:new Uint8Array(0),i}};const EC={encode:(e,t=new nC)=>(0!==e.classType&&t.uint32(8).int32(e.classType),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={classType:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(8!==e)break;r.classType=n.int32();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({classType:PC(e.classType)?vC(e.classType):0}),toJSON(e){const t={};return 0!==e.classType&&(t.classType=function(e){switch(e){case mC.Keyboard:return"Keyboard";case mC.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.classType)),t},create:e=>EC.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={classType:0};return n.classType=null!==(t=e.classType)&&void 0!==t?t:0,n}};const AC={encode:(e,t=new nC)=>(""!==e.uuid&&t.uint32(10).string(e.uuid),void 0!==e.semanticLabel_META&&t.uint32(16).int32(e.semanticLabel_META),void 0!==e.locatable_META&&pC.encode(e.locatable_META,t.uint32(26).fork()).join(),void 0!==e.boundary2D_META&&SC.encode(e.boundary2D_META,t.uint32(34).fork()).join(),void 0!==e.bounded2D_META&&hC.encode(e.bounded2D_META,t.uint32(42).fork()).join(),void 0!==e.bounded3D_META&&dC.encode(e.bounded3D_META,t.uint32(50).fork()).join(),void 0!==e.roomLayout_META&&bC.encode(e.roomLayout_META,t.uint32(58).fork()).join(),void 0!==e.spaceContainer_META&&_C.encode(e.spaceContainer_META,t.uint32(66).fork()).join(),void 0!==e.triangleMesh_META&&TC.encode(e.triangleMesh_META,t.uint32(74).fork()).join(),void 0!==e.dynamicObject_META&&EC.encode(e.dynamicObject_META,t.uint32(82).fork()).join(),t),decode(e,t){const n=e instanceof iC?e:new iC(e);let i=void 0===t?n.len:n.pos+t;const r={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuid=n.string();continue;case 2:if(16!==e)break;r.semanticLabel_META=n.int32();continue;case 3:if(26!==e)break;r.locatable_META=pC.decode(n,n.uint32());continue;case 4:if(34!==e)break;r.boundary2D_META=SC.decode(n,n.uint32());continue;case 5:if(42!==e)break;r.bounded2D_META=hC.decode(n,n.uint32());continue;case 6:if(50!==e)break;r.bounded3D_META=dC.decode(n,n.uint32());continue;case 7:if(58!==e)break;r.roomLayout_META=bC.decode(n,n.uint32());continue;case 8:if(66!==e)break;r.spaceContainer_META=_C.decode(n,n.uint32());continue;case 9:if(74!==e)break;r.triangleMesh_META=TC.decode(n,n.uint32());continue;case 10:if(82!==e)break;r.dynamicObject_META=EC.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuid:PC(e.uuid)?globalThis.String(e.uuid):"",semanticLabel_META:PC(e.semanticLabel_META)?yC(e.semanticLabel_META):void 0,locatable_META:PC(e.locatable_META)?pC.fromJSON(e.locatable_META):void 0,boundary2D_META:PC(e.boundary2D_META)?SC.fromJSON(e.boundary2D_META):void 0,bounded2D_META:PC(e.bounded2D_META)?hC.fromJSON(e.bounded2D_META):void 0,bounded3D_META:PC(e.bounded3D_META)?dC.fromJSON(e.bounded3D_META):void 0,roomLayout_META:PC(e.roomLayout_META)?bC.fromJSON(e.roomLayout_META):void 0,spaceContainer_META:PC(e.spaceContainer_META)?_C.fromJSON(e.spaceContainer_META):void 0,triangleMesh_META:PC(e.triangleMesh_META)?TC.fromJSON(e.triangleMesh_META):void 0,dynamicObject_META:PC(e.dynamicObject_META)?EC.fromJSON(e.dynamicObject_META):void 0}),toJSON(e){const t={};return""!==e.uuid&&(t.uuid=e.uuid),void 0!==e.semanticLabel_META&&(t.semanticLabel_META=xC(e.semanticLabel_META)),void 0!==e.locatable_META&&(t.locatable_META=pC.toJSON(e.locatable_META)),void 0!==e.boundary2D_META&&(t.boundary2D_META=SC.toJSON(e.boundary2D_META)),void 0!==e.bounded2D_META&&(t.bounded2D_META=hC.toJSON(e.bounded2D_META)),void 0!==e.bounded3D_META&&(t.bounded3D_META=dC.toJSON(e.bounded3D_META)),void 0!==e.roomLayout_META&&(t.roomLayout_META=bC.toJSON(e.roomLayout_META)),void 0!==e.spaceContainer_META&&(t.spaceContainer_META=_C.toJSON(e.spaceContainer_META)),void 0!==e.triangleMesh_META&&(t.triangleMesh_META=TC.toJSON(e.triangleMesh_META)),void 0!==e.dynamicObject_META&&(t.dynamicObject_META=EC.toJSON(e.dynamicObject_META)),t},create:e=>AC.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};return i.uuid=null!==(t=e.uuid)&&void 0!==t?t:"",i.semanticLabel_META=null!==(n=e.semanticLabel_META)&&void 0!==n?n:void 0,i.locatable_META=void 0!==e.locatable_META&&null!==e.locatable_META?pC.fromPartial(e.locatable_META):void 0,i.boundary2D_META=void 0!==e.boundary2D_META&&null!==e.boundary2D_META?SC.fromPartial(e.boundary2D_META):void 0,i.bounded2D_META=void 0!==e.bounded2D_META&&null!==e.bounded2D_META?hC.fromPartial(e.bounded2D_META):void 0,i.bounded3D_META=void 0!==e.bounded3D_META&&null!==e.bounded3D_META?dC.fromPartial(e.bounded3D_META):void 0,i.roomLayout_META=void 0!==e.roomLayout_META&&null!==e.roomLayout_META?bC.fromPartial(e.roomLayout_META):void 0,i.spaceContainer_META=void 0!==e.spaceContainer_META&&null!==e.spaceContainer_META?_C.fromPartial(e.spaceContainer_META):void 0,i.triangleMesh_META=void 0!==e.triangleMesh_META&&null!==e.triangleMesh_META?TC.fromPartial(e.triangleMesh_META):void 0,i.dynamicObject_META=void 0!==e.dynamicObject_META&&null!==e.dynamicObject_META?EC.fromPartial(e.dynamicObject_META):void 0,i}};function RC(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}}function CC(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const t=[];return e.forEach(e=>{t.push(globalThis.String.fromCharCode(e))}),globalThis.btoa(t.join(""))}}function PC(e){return null!=e}var IC,LC;!function(e){e.Locatable="locatable",e.Bounded3D="bounded3D",e.Bounded2D="bounded2D",e.TriangleMesh="triangleMesh",e.SemanticLabel="semanticLabel"}(IC||(IC={}));class DC extends EventTarget{constructor(e){super(),this._spatialEntity=e}}class NC extends DC{constructor(e,t){super(e),this._offset=new Ep,this._extent=new Ep,this.type=IC.Bounded2D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y),this._extent.set(i.width,i.height),this.buildGeometry()}buildGeometry(){var e;const t=new yx(this._extent.x,this._extent.y);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,0),t.rotateX(Math.PI/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y},extent:{width:this._extent.x,height:this._extent.y}}}}class OC extends DC{constructor(e,t){super(e),this._offset=new Rp,this._extent=new Rp,this.type=IC.Bounded3D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y,n.z),this._extent.set(i.width,i.height,i.depth),this.buildGeometry()}buildGeometry(){var e;const t=new ty(this._extent.x,this._extent.y,this._extent.z);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,this._offset.z+this._extent.z/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y,z:this._offset.z},extent:{width:this._extent.x,height:this._extent.y,depth:this._extent.z}}}}class FC extends DC{constructor(e,t){super(e),this.type=IC.Locatable,t.position&&this.position.copy(t.position),t.orientation&&this.orientation.copy(t.orientation)}get position(){return this._spatialEntity.position}get rotation(){return this._spatialEntity.rotation}get orientation(){return this._spatialEntity.quaternion}get initData(){return{position:{x:this.position.x,y:this.position.y,z:this.position.z},orientation:{x:this.orientation.x,y:this.orientation.y,z:this.orientation.z,w:this.orientation.w}}}get pbData(){return{position:{x:this._spatialEntity.position.x,y:this._spatialEntity.position.y,z:this._spatialEntity.position.z},orientation:{x:this._spatialEntity.quaternion.x,y:this._spatialEntity.quaternion.y,z:this._spatialEntity.quaternion.z,w:this._spatialEntity.quaternion.w}}}}function kC(e){return e.toLowerCase().replace(/_/g," ").trim()}class UC extends DC{constructor(e,t){super(e),this._semanticLabel=t,this.type=IC.SemanticLabel,this._spatialEntity.name=kC(xC(t))}get semanticLabel(){return this._semanticLabel}set semanticLabel(e){Object.values(gC).includes(e)?this._semanticLabel=e:this._semanticLabel=gC.UNRECOGNIZED,this._spatialEntity.name=kC(xC(this._semanticLabel))}get initData(){return this._semanticLabel}get pbData(){return this._semanticLabel}}class zC extends DC{constructor(e,t){super(e),this._polygonCount=0,this._vertexCount=0,this._dimensions={x:0,y:0,z:0},this.type=IC.TriangleMesh;const{vertices:n,indices:i}=t,r=new Uint32Array(i.buffer);this._vertices=new Float32Array(n.buffer),this._indices=[...r],this.buildGeometry();const s=e.material;s.polygonOffset=!0,s.polygonOffsetFactor=1,s.polygonOffsetUnits=.005,s.color.setHex(13948116),e.renderOrder=999}buildGeometry(){var e;const t=new Fm;t.setAttribute("position",new _m(this._vertices,3));const n=this._indices.reduce((e,t)=>t>e?t:e,0),i=n<65536?new Uint16Array(this._indices):new Uint32Array(this._indices);t.setIndex(new _m(i,1)),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t,t.computeVertexNormals(),this._vertexCount=t.attributes.position.count,this._polygonCount=t.index?t.index.count/3:this._vertexCount/3,t.computeBoundingBox();const r=t.boundingBox;this._dimensions={x:r.max.x-r.min.x,y:r.max.y-r.min.y,z:r.max.z-r.min.z}}get vertexCount(){return this._vertexCount}get polygonCount(){return this._polygonCount}get dimensions(){return this._dimensions}get initData(){const e=[];for(let t=0;t<this._vertices.length/3;t++)e.push({x:this._vertices[3*t],y:this._vertices[3*t+1],z:this._vertices[3*t+2]});return{vertices:e,indices:this._indices}}get pbData(){const e=new Uint32Array(this._indices);return{vertices:new Uint8Array(this._vertices.buffer),indices:new Uint8Array(e.buffer)}}}!function(e){e.Plane="plane",e.Box="box",e.Mesh="mesh"}(LC||(LC={}));const BC=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return t>>>0&16777215},VC={[gC.OTHER]:Pa.Other,[gC.TABLE]:Pa.Table,[gC.COUCH]:Pa.Couch,[gC.FLOOR]:Pa.Floor,[gC.CEILING]:Pa.Ceiling,[gC.WALL_FACE]:Pa.Wall,[gC.INVISIBLE_WALL_FACE]:Pa.Window,[gC.INNER_WALL_FACE]:Pa.Wall,[gC.DOOR_FRAME]:Pa.Door,[gC.WINDOW_FRAME]:Pa.Window,[gC.WALL_ART]:Pa.WallArt,[gC.STORAGE]:Pa.Shelf,[gC.BED]:Pa.Bed,[gC.LAMP]:Pa.Lamp,[gC.SCREEN]:Pa.Screen,[gC.PLANT]:Pa.Plant,[gC.GLOBAL_MESH]:Pa.GlobalMesh,[gC.CHAIR]:Pa.Couch,[gC.UNKNOWN]:Pa.Other,[gC.OTHER_ROOM_FACE]:Pa.Other,[gC.OPENING]:Pa.Other,[gC.UNRECOGNIZED]:Pa.Other},GC=new Ap(1,0,0,0);class HC extends Ag{constructor(e=function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(hT[255&e]+hT[e>>8&255]+hT[e>>16&255]+hT[e>>24&255]+"-"+hT[255&t]+hT[t>>8&255]+"-"+hT[t>>16&15|64]+hT[t>>24&255]+"-"+hT[63&n|128]+hT[n>>8&255]+"-"+hT[n>>16&255]+hT[n>>24&255]+hT[255&i]+hT[i>>8&255]+hT[i>>16&255]+hT[i>>24&255]).toLowerCase()}()){super(void 0,new jx({color:BC(e),flatShading:!0})),this.name="generic spatial entity",this.isSpatialEntity=!0,this._componentMap=new Map,this._spatialUUID=e}get spatialUUID(){return this._spatialUUID}updateMatrixWorld(e){super.updateMatrixWorld(e)}addComponent(e,t){let n=null;switch(e){case IC.Locatable:n=new FC(this,t);break;case IC.Bounded3D:n=new OC(this,t);break;case IC.Bounded2D:n=new NC(this,t);break;case IC.TriangleMesh:n=new zC(this,t);break;case IC.SemanticLabel:n=new UC(this,t)}n&&this._componentMap.set(e,n)}getComponent(e){return this._componentMap.get(e)}duplicate(){const e=new HC;return this._componentMap.forEach((t,n,i)=>{e.addComponent(t.type,t.initData)}),e}get nativeEntity(){if(!this._nativeEntity){const e=new Wa({x:this.position.x,y:this.position.y,z:this.position.z,w:1},{x:this.quaternion.x,y:this.quaternion.y,z:this.quaternion.z,w:this.quaternion.w}),t=VC[this.getComponent(IC.SemanticLabel).semanticLabel];if(this.entityType===LC.Plane){const{offset:e,extent:n}=this.getComponent(IC.Bounded2D),i=this.quaternion.clone().multiply(GC),r=new Wa({x:this.position.x,y:this.position.y,z:this.position.z,w:1},{x:i.x,y:i.y,z:i.z,w:i.w}),[s,a]=[e.x,e.x+n.x],[o,l]=[-e.y,-(e.y+n.y)],c=[new DOMPointReadOnly(s,0,o),new DOMPointReadOnly(s,0,l),new DOMPointReadOnly(a,0,l),new DOMPointReadOnly(a,0,o),new DOMPointReadOnly(s,0,o)];this._nativeEntity=new Fa(r,c,t)}else if(this.entityType===LC.Box||this.entityType===LC.Mesh){const n=this.geometry.getAttribute("position").array,i=new Uint32Array(this.geometry.index.array),r=this.entityType===LC.Mesh?Pa.GlobalMesh:t;this._nativeEntity=new Ca(e,n,i,r)}}return this._nativeEntity}static fromPBJSON(e){const t=AC.fromJSON(e);if(t.locatable_META){const e=new HC(t.uuid);return e.addComponent(IC.Locatable,t.locatable_META),t.semanticLabel_META&&e.addComponent(IC.SemanticLabel,t.semanticLabel_META),t.bounded2D_META?(e.addComponent(IC.Bounded2D,t.bounded2D_META),e._entityType=LC.Plane):t.bounded3D_META?(e.addComponent(IC.Bounded3D,t.bounded3D_META),e._entityType=LC.Box):t.triangleMesh_META&&(e.addComponent(IC.TriangleMesh,t.triangleMesh_META),e._entityType=LC.Mesh),e}}get entityType(){return void 0!==this._entityType?this._entityType:this.getComponent(IC.Bounded2D)?LC.Plane:this.getComponent(IC.Bounded3D)?LC.Box:this.getComponent(IC.TriangleMesh)?LC.Mesh:void 0}static toPBJSON(e){var t,n,i,r,s;return{uuid:e.spatialUUID,locatable_META:null===(t=e.getComponent(IC.Locatable))||void 0===t?void 0:t.pbData,boundary2D_META:void 0,bounded2D_META:null===(n=e.getComponent(IC.Bounded2D))||void 0===n?void 0:n.pbData,bounded3D_META:null===(i=e.getComponent(IC.Bounded3D))||void 0===i?void 0:i.pbData,semanticLabel_META:null===(r=e.getComponent(IC.SemanticLabel))||void 0===r?void 0:r.pbData,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:null===(s=e.getComponent(IC.TriangleMesh))||void 0===s?void 0:s.pbData,dynamicObject_META:void 0}}}const WC=256**3;function jC(e,t,n,i){return e/256+t/65536+n/WC+i/4278190080}function XC(e,t,n){return e>=1||e<=0?n:t*n/(n-e*(n-t))}const qC=e=>new mg({color:e,transparent:!0,opacity:.35,side:2,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),$C=new Set(Object.values(Pa)),YC=(new Jp).makeRotationZ(-Math.PI/2),KC=(new Jp).makeRotationX(Math.PI/2),ZC=new Jp,JC=new Rp,QC=new Ap,eP=new Rp,tP=new Rp,nP=new Jp;class iP{constructor(e,t=()=>{var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)}){this.root=e,this.disposeRoot=t,this.planeOverlays=new Af,this.meshOverlays=new Af,this.planes=new Map,this.meshes=new Map,this.planeMaterial=qC("#2f9bff"),this.meshMaterial=qC("#ff9a2f")}dispose(){this.root.removeFromParent(),this.planeOverlays.removeFromParent(),this.meshOverlays.removeFromParent();try{this.root.traverse(e=>{e.isLight&&e.dispose()}),this.disposeRoot()}finally{for(const e of[...this.planes.values(),...this.meshes.values()])e.overlay.geometry.dispose();this.planeMaterial.dispose(),this.meshMaterial.dispose()}}nonSurfaces(){const e=[];return this.root.traverse(t=>{const n=t;n.isMesh&&!rP(n)&&n.visible&&e.push(n)}),e}update(e,t,n){var i,r;null===(r=(i=this.root).update)||void 0===r||r.call(i,e),this.root.updateMatrixWorld(),void 0===this.globalMesh&&(this.globalMesh=function(e){const t=[],n=[],i=new Rp,r=new Jp,s=new Jp,a=e=>{for(let t=e;t;t=t.parent)if(!1===t.userData.xrGlobalMesh)return!0;return!1};return e.traverse(o=>{const l=o;if(!sP(l,e)||a(l))return;const c=l.geometry.getAttribute("position");if(!c)return;const u=l.geometry.getIndex(),h=l.isInstancedMesh?l:null;for(let e=0;e<(h?h.count:1);e++){r.copy(l.matrixWorld),h&&r.multiply(h.getMatrixAt(e,s));const a=t.length/3;for(let e=0;e<c.count;e++)i.fromBufferAttribute(c,e).applyMatrix4(r),t.push(i.x,i.y,i.z);const o=u?u.count:c.count;for(let e=0;e<o;e++)n.push(a+(u?u.getX(e):e))}}),n.length?new Ca(new Wa,new Float32Array(t),new Uint32Array(n),Pa.GlobalMesh):null}(this.root)),this.globalMesh&&n.add(this.globalMesh);const s=new Set,a=new Set;this.root.traverse(e=>{const i=e;if(!i.isMesh)return;const{xrPlane:r,xrMesh:o}=i.userData;if(r){s.add(i);let e=this.planes.get(i);e||(e=function(e,t,n){e.geometry.computeBoundingBox();const i=e.geometry.boundingBox,r=i.getSize(new Rp),s=i.getCenter(new Rp),a=(new Jp).makeTranslation(s.x,s.y,s.z);r.x<=r.y&&r.x<=r.z?a.multiply(YC):r.z<r.y&&a.multiply(KC);const o=cP(e,a,new Jp),{min:l,max:c}=i.clone().applyMatrix4(o.clone().invert().multiply(e.matrixWorld)),u=[new DOMPointReadOnly(l.x,0,l.z),new DOMPointReadOnly(c.x,0,l.z),new DOMPointReadOnly(c.x,0,c.z),new DOMPointReadOnly(l.x,0,c.z),new DOMPointReadOnly(l.x,0,l.z)],h=new Fy(u.slice(0,-1).map(e=>new Ep(e.x,-e.z))),d=new bx(h).rotateX(-Math.PI/2);return{native:new Fa(uP(o),u,t),frame:a,pose:o,overlay:oP(d,n,o)}}(i,lP(r),this.planeMaterial),this.planes.set(i,e),this.planeOverlays.add(e.overlay)),hP(i,e),t.add(e.native)}if(o){a.add(i);let e=this.meshes.get(i);e||(e=function(e,t,n){const i=new Jp,r=cP(e,i,new Jp),s=r.clone().invert().multiply(e.matrixWorld),a=e.geometry.getAttribute("position"),o=new Float32Array(3*a.count);for(let e=0;e<a.count;e++)tP.fromBufferAttribute(a,e).applyMatrix4(s),tP.toArray(o,3*e);const l=e.geometry.getIndex(),c=l?Uint32Array.from(l.array):Uint32Array.from({length:a.count},(e,t)=>t),u=new Fm;return u.setAttribute("position",new _m(o,3)),u.setIndex(new _m(c,1)),{native:new Ca(uP(r),o,c,t),frame:i,pose:r,overlay:oP(u,n,r)}}(i,lP(o),this.meshMaterial),this.meshes.set(i,e),this.meshOverlays.add(e.overlay)),hP(i,e),n.add(e.native)}});for(const[e,n]of this.planes)s.has(e)||(this.planes.delete(e),t.delete(n.native),aP(n));for(const[e,t]of this.meshes)a.has(e)||(this.meshes.delete(e),n.delete(t.native),aP(t))}}function rP(e,t){return(Array.isArray(e.material)?void 0===t?e.material:[e.material[t]]:[e.material]).some(e=>e&&e.visible&&e.colorWrite)}function sP(e,t,n){const i=e;if(!i.isMesh||!rP(i,n))return!1;for(let n=e;n;n=n.parent){if(!n.visible)return!1;if(n===t)return!0}return!1}function aP(e){e.overlay.removeFromParent(),e.overlay.geometry.dispose()}function oP(e,t,n){const i=new Ag(e,t);return i.raycast=()=>{},i.matrixAutoUpdate=!1,i.matrix.copy(n),i}function lP(e){return"string"==typeof e&&$C.has(e)?e:(!0!==e&&console.warn(`Unknown semantic label ${String(e)}, using 'other'`),Pa.Other)}function cP(e,t,n){return ZC.multiplyMatrices(e.matrixWorld,t),ZC.decompose(JC,QC,eP),n.compose(JC,QC,eP.set(1,1,1))}function uP(e){return e.decompose(JC,QC,eP),new Wa({x:JC.x,y:JC.y,z:JC.z,w:1},{x:QC.x,y:QC.y,z:QC.z,w:QC.w})}function hP(e,t){const n=cP(e,t.frame,nP);n.equals(t.pose)||(t.pose.copy(n),t.overlay.matrix.copy(n),t.native.transform=uP(n))}const dP={living_room:()=>import("./_iwsdk-legacy-capture-B-A3EajS.js"),meeting_room:()=>import("./_iwsdk-legacy-capture-B-A3EajS.js"),music_room:()=>import("./_iwsdk-legacy-capture-B-A3EajS.js"),office_large:()=>import("./_iwsdk-legacy-capture-B-A3EajS.js"),office_small:()=>import("./_iwsdk-legacy-capture-B-A3EajS.js")},pP=["living_room","meeting_room","music_room","office_large","office_small"],fP={bedroom:()=>import("./bedroom-DETf9sEz.js"),conference_room:()=>import("./conference_room-CqY6mchI.js"),home_office:()=>import("./home_office-BxWjiBZF.js"),kitchen:()=>import("./kitchen-X_P3Lfoy.js"),music_studio:()=>import("./music_studio-glBmJOMe.js"),open_office:()=>import("./open_office-BEqVZ5xR.js"),open_studio:()=>import("./open_studio-CVCR0jsb.js"),sunlit_living_room:()=>import("./sunlit_living_room-1m7CU_6o.js")},mP=["bedroom","conference_room","home_office","kitchen","music_studio","open_office","open_studio","sunlit_living_room"];async function gP(e){return(await fP[e]()).default}const vP=new Rp(0,0,-1),yP=new Nf(4079166),xP=new Nf;class bP extends EventTarget{constructor(e){super(),this.xrDevice=e,this.trackedPlanes=new Set,this.trackedMeshes=new Set,this.version="2.6.0",this.objectMap=new Map,this.planes=new Af,this.boxes=new Af,this.meshes=new Af,this.grid=new iw(50,50),this.sceneEnvironment=null,this.environmentFailed=!1,this.depthHidden=[],this.instanceMatrix=new Jp,this.lastRenderTime=null,this.addedEnvironments=new Map,this.loadId=0,this.tempPosition=new Rp,this.tempQuaternion=new Ap,this.tempDirection=new Rp,this.tempScale=new Rp,this.tempMatrix=new Jp,this.raycaster=new F_,this.hitTestTarget=new Af,this.hitTestMarker=new Ef,this.worldNormal=new Rp,this.normalMatrix=new Ip,this.depthRenderTarget=null,this.depthMaterial=new Hx({depthPacking:3201,side:2}),this._tempMatrix=new Jp,this.depthReadBuffer=null,this.scene=new Uf,this.scene.background=yP,this.camera=new Ob(50,window.innerWidth/window.innerHeight,.1,40),this.camera.position.set(0,1.6,5),this.scene.add(this.grid),this.scene.add(this.planes,this.boxes,this.meshes),this.planes.renderOrder=1,this.boxes.renderOrder=2,this.meshes.renderOrder=3,this.planes.visible=!1,this.boxes.visible=!1,this.renderer=new cT({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.hitTestTarget.add(this.hitTestMarker),this.hitTestMarker.rotateX(Math.PI/2),this.depthCamera=new Ib,this.raycaster.camera=this.camera}get environmentCanvas(){return this.renderer.domElement}get planesVisible(){return this.planes.visible}set planesVisible(e){this.planes.visible=e}get boundingBoxesVisible(){return this.boxes.visible}set boundingBoxesVisible(e){this.boxes.visible=e}get meshesVisible(){return this.meshes.visible}set meshesVisible(e){this.meshes.visible=e}render(e){var t,n,i,r;const s=this.sceneEnvironment;if(s){const a=Tp.clamp((e-(null!==(t=this.lastRenderTime)&&void 0!==t?t:e))/1e3,0,.1);if(!this.environmentFailed)try{s.update(a,this.trackedPlanes,this.trackedMeshes)}catch(e){this.environmentFailed=!0,console.error("Environment update failed; it stops updating",e)}const o=s.root;this.scene.background=null!==(n=o.background)&&void 0!==n?n:yP,this.scene.environment=null!==(i=o.environment)&&void 0!==i?i:null,this.scene.fog=null!==(r=o.fog)&&void 0!==r?r:null,this.applyRendering(o.rendering)}this.lastRenderTime=e,this.camera.position.copy(this.xrDevice.position),this.camera.quaternion.copy(this.xrDevice.quaternion);const a=this.xrDevice.fovy/Math.PI*180;let o=!1;this.camera.fov!==a&&(this.camera.fov=a,o=!0);const l=this.xrDevice.canvasDimensions;if(l){const e=this.renderer.domElement;(e.width!==l.width||e.height!==l.height)&&(this.camera.aspect=l.width/l.height,this.renderer.setSize(l.width,l.height),o=!0)}o&&this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)}deleteAll(){this.loadId++,[...this.objectMap.values()].forEach(e=>{e.removeFromParent()}),this.objectMap.clear(),this.trackedMeshes.clear(),this.trackedPlanes.clear();const e=this.sceneEnvironment;this.sceneEnvironment=null,this.depthHidden=[],this.environmentFailed=!1,this.grid.visible=!0,this.scene.background=yP,this.scene.environment=null,this.scene.fog=null,this.applyRendering(void 0);try{null==e||e.dispose()}catch(e){console.error("Disposing the environment failed",e)}}applyRendering(e){var t,n,i;this.renderer.shadowMap.enabled=null!==(t=null==e?void 0:e.shadows)&&void 0!==t&&t,this.renderer.toneMapping=null!==(n=null==e?void 0:e.toneMapping)&&void 0!==n?n:0,this.renderer.toneMappingExposure=null!==(i=null==e?void 0:e.toneMappingExposure)&&void 0!==i?i:1}get environments(){const e=[...this.addedEnvironments.keys()];return[...mP,...e,...pP]}environmentInfo(e){return this.addedEnvironments.has(e)?{kind:"added"}:pP.includes(e)?{kind:"legacy-scan"}:mP.includes(e)?{kind:"room"}:void 0}addEnvironment(e,t){if("none"===e)throw new Error(`Environment id ${e} is reserved`);if(pP.includes(e)||mP.includes(e))throw new Error(`Environment ${e} is a built-in environment`);this.addedEnvironments.set(e,t)}loadSceneEnvironment(e,t){this.deleteAll();const n=new iP(e,t);this.sceneEnvironment=n,this.depthHidden=n.nonSurfaces(),this.grid.visible=!1,this.meshes.add(e),this.planes.add(n.planeOverlays),this.boxes.add(n.meshOverlays);try{n.update(0,this.trackedPlanes,this.trackedMeshes)}catch(e){throw this.deleteAll(),e}this.dispatchEvent(new CustomEvent("environmentchange",{detail:{entityCount:this.trackedPlanes.size+this.trackedMeshes.size}}))}loadEnvironment(e){this.deleteAll(),e.spatialEntities.forEach(e=>{const t=HC.fromPBJSON(e);if(t){const n=this.objectMap.get(e.uuid);switch(n&&(n.removeFromParent(),this.trackedMeshes.delete(n.nativeEntity),this.trackedPlanes.delete(n.nativeEntity)),t.entityType){case LC.Box:this.boxes.add(t),this.trackedMeshes.add(t.nativeEntity);break;case LC.Plane:this.planes.add(t),this.trackedPlanes.add(t.nativeEntity);break;case LC.Mesh:this.meshes.add(t),this.trackedMeshes.add(t.nativeEntity)}this.objectMap.set(e.uuid,t)}}),this.dispatchEvent(new CustomEvent("environmentchange",{detail:{entityCount:this.objectMap.size}}))}async loadDefaultEnvironment(e){const t=++this.loadId;try{const n=this.addedEnvironments.get(e);if(n||mP.includes(e)){const{root:i,dispose:r}=n?await _P(n):await async function(e){const t=URL.createObjectURL(new Blob([await gP(e)],{type:"text/plain"}));try{return await _P(t)}finally{URL.revokeObjectURL(t)}}(e);return void(t===this.loadId?this.loadSceneEnvironment(i,r):r())}const i=await async function(e){if(!pP.includes(e))throw new Error(`Requested environment ${e} does not exist`);return async function(e){return(await dP[e]()).default}(e)}(e);t===this.loadId&&this.loadEnvironment(i)}catch(t){throw console.error(`Error loading environment ${e}`,t),t}}computeHitTestResults(e,t){var n;this.tempMatrix.fromArray(e),this.tempMatrix.decompose(this.tempPosition,this.tempQuaternion,this.tempScale),this.tempDirection.copy(vP).applyQuaternion(this.tempQuaternion).normalize(),this.raycaster.set(this.tempPosition,this.tempDirection);const i=[];t&&!t.includes("mesh")||i.push(this.meshes,this.boxes),t&&!t.includes("plane")||i.push(this.planes);const r=null===(n=this.sceneEnvironment)||void 0===n?void 0:n.root,s=this.raycaster.intersectObjects(i,!0).filter(e=>{var t;const n=e.object;if(!n.isMesh)return!1;if(r&&this.meshes.children.includes(r)){let i=n;for(;i&&i!==r;)i=i.parent;if(i===r)return sP(n,r,null===(t=e.face)||void 0===t?void 0:t.materialIndex)}const i=n.material;return Array.isArray(i)?i.some(e=>e.visible):i.visible}),a=s.map(e=>{var t;const n=e.point;if(this.hitTestTarget.position.copy(n),null===(t=e.face)||void 0===t?void 0:t.normal){this.worldNormal.copy(e.face.normal);const t=e.object;this.tempMatrix.copy(t.matrixWorld),t.isInstancedMesh&&void 0!==e.instanceId&&(t.getMatrixAt(e.instanceId,this.instanceMatrix),this.tempMatrix.multiply(this.instanceMatrix)),this.worldNormal.applyMatrix3(this.normalMatrix.getNormalMatrix(this.tempMatrix)).normalize(),this.worldNormal.dot(this.raycaster.ray.direction)>0&&this.worldNormal.negate(),this.hitTestTarget.lookAt(this.tempPosition.addVectors(n,this.worldNormal))}else this.hitTestTarget.quaternion.set(0,0,0,1);return this.hitTestTarget.updateMatrixWorld(!0),this.hitTestMarker.matrixWorld.toArray()});return a}computeDepthBuffer(e,t,n,i,r,s){var a;if(0===this.trackedMeshes.size&&!this.sceneEnvironment)return null;this.depthRenderTarget&&this.depthRenderTarget.width===n&&this.depthRenderTarget.height===i||(null===(a=this.depthRenderTarget)||void 0===a||a.dispose(),this.depthRenderTarget=new Yp(n,i),this.depthReadBuffer=new Uint8Array(n*i*4)),this._tempMatrix.fromArray(e),this._tempMatrix.invert(),this._tempMatrix.decompose(this.depthCamera.position,this.depthCamera.quaternion,this.depthCamera.scale),this.depthCamera.projectionMatrix.fromArray(t),this.depthCamera.projectionMatrixInverse.copy(this.depthCamera.projectionMatrix).invert();const o=this.meshes.visible,l=this.boxes.visible,c=this.planes.visible;this.meshes.visible=!0,this.boxes.visible=!this.sceneEnvironment,this.planes.visible=!1;const u=this.depthHidden.map(e=>e.visible);for(const e of this.depthHidden)e.visible=!1;const h=this.renderer.shadowMap.autoUpdate;this.renderer.shadowMap.autoUpdate=!1;const d=this.scene.overrideMaterial,p=this.scene.background;this.scene.overrideMaterial=this.depthMaterial,this.scene.background=null,this.renderer.setRenderTarget(this.depthRenderTarget);const f=this.renderer.getClearColor(xP),m=this.renderer.getClearAlpha();this.renderer.setClearColor(0,0),this.renderer.clear(),this.renderer.setClearColor(f,m),this.renderer.render(this.scene,this.depthCamera),this.renderer.setRenderTarget(null),this.scene.overrideMaterial=d,this.scene.background=p,this.meshes.visible=o,this.boxes.visible=l,this.planes.visible=c,this.depthHidden.forEach((e,t)=>e.visible=u[t]),this.renderer.shadowMap.autoUpdate=h,this.renderer.readRenderTargetPixels(this.depthRenderTarget,0,0,n,i,this.depthReadBuffer);const g=new ArrayBuffer(n*i*4),v=new Float32Array(g),y=this.depthReadBuffer;for(let e=0;e<i;e++){const t=i-1-e;for(let i=0;i<n;i++){const a=t*n+i,o=e*n+i,l=jC(y[4*a],y[4*a+1],y[4*a+2],y[4*a+3]);v[o]=XC(l,r,s)}}return{data:g,width:n,height:i,rawValueToMeters:1}}}async function _P(e){{const{GLTSLoader:t}=await import("./index-C3rlN7Lf.js"),n=new t(new fb);try{const t=await n.loadAsync(e);return{root:t,dispose:()=>{var e;try{null===(e=t.dispose)||void 0===e||e.call(t)}finally{n.dispose()}}}}catch(e){throw n.dispose(),e}}}const wP=["code","details","issues","lifecycle","recoverable","retryAction"];class SP{constructor(e,t={}){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=Number.POSITIVE_INFINITY,this.reconnectDelay=1e3,this.maxReconnectDelay=5e3,this.reconnectTimer=null,this.connectTimer=null,this.connectTimeoutMs=1e4,this.intentionalDisconnect=!1,this.runtimeReadyListener=()=>this.announceCommandReady(),this.device=e,this.verbose=t.verbose??!1,this.pageRole=this.detectPageRole(),this.deviceClass=t.deviceClass??"managed",this.sceneSessionId="undefined"!=typeof window?window.__IWSDK_SCENE_SESSION_ID:void 0;const n=`iwer-mcp-tab-id:${this.pageRole}`,i=`iwer-mcp-gen:${this.pageRole}`;let r="undefined"!=typeof sessionStorage?sessionStorage.getItem(n):null;r||(r=`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,"undefined"!=typeof sessionStorage&&sessionStorage.setItem(n,r)),this.tabId=r;const s="undefined"!=typeof sessionStorage?parseInt(sessionStorage.getItem(i)||"0",10)+1:1;if("undefined"!=typeof sessionStorage&&sessionStorage.setItem(i,String(s)),this.tabGeneration=s,"undefined"!=typeof window){try{const e=window.location.href,t=e.replace(/^[^#]*/u,e=>{const t=e.indexOf("?");return-1===t?e:e.slice(0,t)+e.slice(t).replace(/^\?__iwsdk_reload=[^&]*$|&__iwsdk_reload=[^&]*$/u,"")});t!==e&&window.history.replaceState(window.history.state,"",t)}catch{}window.__IWSDK_MCP_PAGE_ID=this.tabId,window.__IWSDK_MCP_PAGE_ROLE=this.pageRole,window.__IWSDK_MCP_TAB_GENERATION=this.tabGeneration,"function"==typeof window.addEventListener&&window.addEventListener("iwsdk:mcp-runtime-ready",this.runtimeReadyListener)}}get connected(){return this.ws?.readyState===WebSocket.OPEN}get connectionState(){return null==this.ws||this.ws.readyState===WebSocket.CLOSED?"disconnected":this.ws.readyState===WebSocket.OPEN?"connected":this.ws.readyState===WebSocket.CLOSING?"closing":"connecting"}isTraceEnabled(){return this.verbose||"undefined"!=typeof window&&!0===window.__IWSDK_MCP_TRACE}detectPageRole(){if("undefined"==typeof window)return"app";const e=window.__IWSDK_MCP_PAGE_ROLE;if("app"===e||"editor"===e||"preview"===e)return e;const t=window.location.pathname??"";return t.startsWith("/__iwsdk/editor")||t.startsWith("/__iwsdk/workspace")?"editor":"app"}trace(e,t={}){this.isTraceEnabled()&&console.log(`[IWSDK-MCP-TRACE] ${e} ${JSON.stringify({...t,tabId:this.tabId,tabGeneration:this.tabGeneration})}`)}connect(e){if(null!==this.ws)return;this.intentionalDisconnect=!1;const t=e??this.getVitePort(),n=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.hostname||"localhost"}:${t}/__iwer_mcp`;this.verbose&&console.log("[IWSDK-MCP] Connecting to:",n),this.trace("client_connect_start",{wsUrl:n,reconnectAttempts:this.reconnectAttempts});try{const e=new WebSocket(n);this.ws=e,this.setupEventHandlers(e),this.connectTimer=setTimeout(()=>{if(this.ws===e&&e.readyState===WebSocket.CONNECTING){this.trace("client_connect_timeout",{timeoutMs:this.connectTimeoutMs}),this.detachEventHandlers(e),this.ws=null;try{e.close()}catch{}this.clearConnectTimer(),this.intentionalDisconnect||this.scheduleReconnect()}},this.connectTimeoutMs)}catch(e){console.error("[IWSDK-MCP] Failed to create WebSocket:",e),this.ws=null,this.scheduleReconnect()}}disconnect(){if(this.intentionalDisconnect=!0,this.reconnectAttempts=0,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.clearConnectTimer(),this.ws){const e=this.ws;this.ws=null,this.detachEventHandlers(e);try{e.close()}catch{}}}getVitePort(){return parseInt(window.location.port,10)||5173}setupEventHandlers(e){e.onopen=()=>{this.ws===e&&(this.clearConnectTimer(),this.verbose&&console.log("[IWSDK-MCP] Connected"),this.trace("client_open"),this.reconnectAttempts=0,e.send(JSON.stringify({type:"iwsdk_browser_hello",...window.__IWSDK_RUNTIME_IDENTITY??{},headsetToken:(()=>{if("physical"!==this.deviceClass)return;let e=null;try{e=new URL(window.location.href).searchParams.get("__iwsdk_headset")}catch{}try{return e&&window.sessionStorage.setItem("iwsdk:headset-token",e),e??window.sessionStorage.getItem("iwsdk:headset-token")}catch{return e}})(),commandReady:null!=window.FRAMEWORK_MCP_RUNTIME,deviceClass:this.deviceClass,pageId:this.tabId,pageRole:this.pageRole,role:this.pageRole,sceneSessionId:this.sceneSessionId,tabId:this.tabId,tabGeneration:this.tabGeneration})),this.trace("client_hello_sent"))},e.onclose=t=>{this.ws===e&&(this.clearConnectTimer(),this.verbose&&console.log("[IWSDK-MCP] Disconnected:",t.reason||"Connection closed"),this.trace("client_close",{code:t.code,reason:t.reason||"Connection closed",intentional:this.intentionalDisconnect}),this.ws=null,this.detachEventHandlers(e),this.intentionalDisconnect||this.scheduleReconnect())},e.onerror=t=>{this.ws===e&&(this.trace("client_error",{message:t instanceof ErrorEvent&&t.message?t.message:"WebSocket error"}),console.error("[IWSDK-MCP] WebSocket error:",t))},e.onmessage=async t=>{this.ws===e&&await this.handleMessage(t.data)}}clearConnectTimer(){null!=this.connectTimer&&(clearTimeout(this.connectTimer),this.connectTimer=null)}detachEventHandlers(e){e.onopen=null,e.onclose=null,e.onerror=null,e.onmessage=null}announceCommandReady(){this.ws?.readyState===WebSocket.OPEN&&(this.ws.send(JSON.stringify({type:"iwsdk_browser_ready",pageId:this.tabId,pageRole:this.pageRole,tabGeneration:this.tabGeneration})),this.trace("client_command_ready_sent"))}async handleMessage(e){let t;try{t=JSON.parse(e)}catch{return void console.error("[IWSDK-MCP] Invalid JSON received:",e)}if("string"!=typeof t.id||"string"!=typeof t.method)return void console.error("[IWSDK-MCP] Malformed request (missing id or method):",t);this.verbose&&console.debug("[IWSDK-MCP] Received:",t.method,t.params),this.trace("client_request_received",{id:t.id,method:t.method});const n={id:t.id};try{n.result=await this.dispatch(t.method,t.params??{})}catch(e){n.error=function(e){const t="object"==typeof e&&null!==e?e:null,n={};for(const e of wP)null!=t&&void 0!==t[e]&&(n[e]=t[e]);const i=null!=t&&"string"==typeof t.cause?t.cause:void 0;return{code:null!=t&&"number"==typeof t.code&&Number.isInteger(t.code)?t.code:-32e3,message:e instanceof Error?e.message:String(e),...null==i?{}:{cause:i},...0===Object.keys(n).length?{}:{data:n}}}(e)}this.verbose&&(n.error?console.debug("[IWSDK-MCP] Error:",n.error.message):console.debug("[IWSDK-MCP] Result:",n.result)),this.send(n)}async dispatch(e,t){if("reload_page"===e){await(window.FRAMEWORK_MCP_RUNTIME?.prepareForReload?.());const e=`${Date.now()}-${Math.random().toString(36).slice(2)}`,t=window.location.href.replace(/^[^#]*/u,t=>`${t}${t.includes("?")?"&":"?"}__iwsdk_reload=${e}`);return setTimeout(()=>window.location.replace(t),50),{success:!0,message:"Page reload initiated"}}if(window.FRAMEWORK_MCP_RUNTIME?.handles(e))return window.FRAMEWORK_MCP_RUNTIME.dispatch(e,t);if(null==this.device)throw new Error(`Method "${e}" requires IWER device emulation and is unavailable in this workspace-only page`);return this.device.remote.dispatch(e,t)}send(e){if(this.ws&&this.ws.readyState===WebSocket.OPEN){const t={...e,_tabId:this.tabId,_tabGeneration:this.tabGeneration};this.trace("client_response_sent",{id:e.id,hasError:Boolean(e.error)}),this.ws.send(JSON.stringify(t))}}scheduleReconnect(){if(this.intentionalDisconnect||null!=this.reconnectTimer)return;if(this.reconnectAttempts>=this.maxReconnectAttempts)return void(this.verbose&&console.debug("[IWSDK-MCP] Max reconnect attempts reached"));this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*this.reconnectAttempts,this.maxReconnectDelay);this.verbose&&console.debug(`[IWSDK-MCP] Reconnecting in ${e}ms (attempt ${this.reconnectAttempts})`),this.trace("client_reconnect_scheduled",{delay:e,attempt:this.reconnectAttempts}),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}}function MP(e={}){const t=new SP(null,{verbose:e.verbose,deviceClass:e.deviceClass});return t.connect(e.port),t}const TP={...dc,supportedFeatures:[...dc.supportedFeatures,"gaze-tracking","eye-tracking"]},EP={metaQuest2:cc,metaQuest3:hc,metaQuestPro:uc,metaVRGlasses:TP,oculusQuest1:lc};class AP extends bP{get environments(){return super.environments.filter(e=>"legacy-scan"!==this.environmentInfo(e)?.kind)}}function RP(e){console.log("[IWSDK Dev] Configuration:",e);const t=window.__IWSDK_HOST_BROWSER_ENVIRONMENT??{platform:navigator.userAgentData?.platform||navigator.platform||null,userAgent:navigator.userAgent};window.__IWSDK_HOST_BROWSER_ENVIRONMENT=t,window.__IWSDK_EMULATION_PROFILE={active:!1,device:null,runtime:null},window.__IWSDK_TARGET_DEVICE_PREVIEW__={active:!1,gazeSimulation:!1};const n=!0===window.__IWER_MCP_MANAGED,i=/OculusBrowser/i.test(navigator.userAgent||""),r=e.nativeXRControl,s=!r&&i&&"head"===e.targetDevicePreview?.gazeSimulation,a=new URL(location.href).searchParams.has("__iwsdk_headset")||null!=sessionStorage.getItem("iwsdk:headset-token");if(r&&!i)return void console.error("[IWSDK Dev] Native XR control requires Meta Quest Browser; refusing to replace this browser's native navigator.xr with desktop emulation.");if(e.workspace&&i&&a&&!r&&!s)return void(window.IWER_MCP=MP({deviceClass:"physical",verbose:e.verbose}));e.workspace&&!1===e.iwer&&n&&(window.IWER_MCP=MP({verbose:e.verbose}));if(r||s?!1!==e.iwer:function(e,t,n){if(!1===n)return!1;if(t){const e=navigator.userAgent||"";if(t instanceof RegExp){if(t.test(e))return!1}else if("string"==typeof t&&t.startsWith("/")&&t.endsWith("/")){const n=t.slice(1,-1);try{if(new RegExp(n).test(e))return!1}catch{}}}if("always"===e)return!0;if("localhost"===e)return"localhost"===location.hostname||"127.0.0.1"===location.hostname;if(e instanceof RegExp)return e.test(location.hostname);if("string"==typeof e&&e.startsWith("/")&&e.endsWith("/")){const t=e.slice(1,-1);return new RegExp(t).test(location.hostname)}return!1}(e.activation,e.userAgentException,e.iwer)){e.verbose&&console.log("[IWSDK Dev] 🎯 Activating IWER runtime...");try{const t=EP[e.device];if(!t){const t=Object.keys(EP).join(", ");console.error(`[IWSDK Dev] ❌ Invalid device configuration: "${e.device}"\nAvailable devices: ${t}\nFalling back to default device: metaQuest3`)}const i=new Ql(s?TP:t||hc);if(e.verbose&&console.log("[IWSDK Dev] 📱 Using device configuration:",s?"metaVRGlasses (gaze preview)":t?e.device:"metaQuest3 (fallback)"),r||s){const e=s?"Gaze preview":"Native XR control",t=Vc();if(!t.supported)return void console.error(`[IWSDK Dev] ${e} is unavailable:`,t.notes.join(" "));const n=function(e,t){const n=new Gc(e,t);return n.install(),n}(i,{mode:s?"gaze-only":"full",onUnsupported:"warn"});if(!n.installed)return void console.error(`[IWSDK Dev] ${e} could not patch this browser:`,n.capabilities.notes.join(" "));s&&(window.__IWSDK_TARGET_DEVICE_PREVIEW__={active:!0,gazeSimulation:"head"}),window.IWER_NATIVE_OVERRIDE=n}else i.installRuntime({forceInstall:!0});if(window.__IWSDK_EMULATION_PROFILE={active:!0,device:s?"metaVRGlasses":e.device,runtime:r?"IWER-native-override":s?"IWER-native-gaze":"IWER"},r||s||e.ai&&n&&!e.ai.devUI||i.installDevUI(NR),e.sem&&!r&&!s){e.verbose&&console.log("[IWSDK Dev] 🌐 Installing SEM with scene:",e.sem.defaultScene),i.installSEM(AP),e.verbose&&console.log("[IWSDK Dev] 📍 Loading environment:",e.sem.defaultScene);const t=e.sem.defaultScene;i.sem?.loadDefaultEnvironment(t).catch(e=>console.error(`[IWSDK Dev] ❌ Failed to load environment ${t}:`,e))}const o=s&&a;if(e.workspace&&(n||r||o)){e.verbose&&console.log("[IWSDK Dev] 🔌 Initializing MCP client...");const t=function(e,t={}){const n=new SP(e,{deviceClass:t.deviceClass,verbose:t.verbose});return n.connect(t.port),n}(i,{deviceClass:r||o?"physical":"managed",verbose:e.verbose});window.IWER_MCP=t,e.verbose&&console.log("[IWSDK Dev] ✅ MCP client initialized")}e.verbose&&console.log("[IWSDK Dev] ✅ Runtime activated successfully!"),window.IWER_DEVICE=i}catch(e){console.error("[IWSDK Dev] ❌ Failed to activate runtime:",e)}}else if(e.verbose){const t=!1===e.iwer?"IWER disabled (iwer: false)":"activation conditions not met (localhost / user-agent)";console.log(`[IWSDK Dev] Skipping activation - ${t}`)}}function CP(e){RP(e)}export{Av as B,Ib as C,Jg as I,wb as L,Jp as M,Ju as N,qv as P,vu as R,Uf as S,uT as T,Ag as a,Fv as b,e as c,ag as d,Ug as e,ng as f,t as g,fb as h,gb as i,CP as s};
|