(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var V0={exports:{}},bf={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var yM;function i5(){if(yM)return bf;yM=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(i,a,o){var l=null;if(o!==void 0&&(l=""+o),a.key!==void 0&&(l=""+a.key),"key"in a){o={};for(var u in a)u!=="key"&&(o[u]=a[u])}else o=a;return a=o.ref,{$$typeof:e,type:i,key:l,ref:a!==void 0?a:null,props:o}}return bf.Fragment=t,bf.jsx=n,bf.jsxs=n,bf}var xM;function s5(){return xM||(xM=1,V0.exports=i5()),V0.exports}var rt=s5(),G0={exports:{}},_e={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var SM;function a5(){if(SM)return _e;SM=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),b=Symbol.iterator;function _(B){return B===null||typeof B!="object"?null:(B=b&&B[b]||B["@@iterator"],typeof B=="function"?B:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},M=Object.assign,S={};function y(B,et,Et){this.props=B,this.context=et,this.refs=S,this.updater=Et||x}y.prototype.isReactComponent={},y.prototype.setState=function(B,et){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,et,"setState")},y.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function E(){}E.prototype=y.prototype;function w(B,et,Et){this.props=B,this.context=et,this.refs=S,this.updater=Et||x}var A=w.prototype=new E;A.constructor=w,M(A,y.prototype),A.isPureReactComponent=!0;var U=Array.isArray;function O(){}var P={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function C(B,et,Et){var $=Et.ref;return{$$typeof:e,type:B,key:et,ref:$!==void 0?$:null,props:Et}}function R(B,et){return C(B.type,et,B.props)}function I(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function Z(B){var et={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(Et){return et[Et]})}var nt=/\/+/g;function ct(B,et){return typeof B=="object"&&B!==null&&B.key!=null?Z(""+B.key):et.toString(36)}function ft(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(O,O):(B.status="pending",B.then(function(et){B.status==="pending"&&(B.status="fulfilled",B.value=et)},function(et){B.status==="pending"&&(B.status="rejected",B.reason=et)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function z(B,et,Et,$,mt){var Dt=typeof B;(Dt==="undefined"||Dt==="boolean")&&(B=null);var _t=!1;if(B===null)_t=!0;else switch(Dt){case"bigint":case"string":case"number":_t=!0;break;case"object":switch(B.$$typeof){case e:case t:_t=!0;break;case p:return _t=B._init,z(_t(B._payload),et,Et,$,mt)}}if(_t)return mt=mt(B),_t=$===""?"."+ct(B,0):$,U(mt)?(Et="",_t!=null&&(Et=_t.replace(nt,"$&/")+"/"),z(mt,et,Et,"",function(re){return re})):mt!=null&&(I(mt)&&(mt=R(mt,Et+(mt.key==null||B&&B.key===mt.key?"":(""+mt.key).replace(nt,"$&/")+"/")+_t)),et.push(mt)),1;_t=0;var Wt=$===""?".":$+":";if(U(B))for(var ee=0;ee>>1,At=z[yt];if(0>>1;yta(Et,q))$a(mt,Et)?(z[yt]=mt,z[$]=q,yt=$):(z[yt]=Et,z[et]=q,yt=et);else if($a(mt,q))z[yt]=mt,z[$]=q,yt=$;else break t}}return J}function a(z,J){var q=z.sortIndex-J.sortIndex;return q!==0?q:z.id-J.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var h=[],d=[],p=1,m=null,b=3,_=!1,x=!1,M=!1,S=!1,y=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(z){for(var J=n(d);J!==null;){if(J.callback===null)i(d);else if(J.startTime<=z)i(d),J.sortIndex=J.expirationTime,t(h,J);else break;J=n(d)}}function U(z){if(M=!1,A(z),!x)if(n(h)!==null)x=!0,O||(O=!0,Z());else{var J=n(d);J!==null&&ft(U,J.startTime-z)}}var O=!1,P=-1,F=5,C=-1;function R(){return S?!0:!(e.unstable_now()-Cz&&R());){var yt=m.callback;if(typeof yt=="function"){m.callback=null,b=m.priorityLevel;var At=yt(m.expirationTime<=z);if(z=e.unstable_now(),typeof At=="function"){m.callback=At,A(z),J=!0;break e}m===n(h)&&i(h),A(z)}else i(h);m=n(h)}if(m!==null)J=!0;else{var B=n(d);B!==null&&ft(U,B.startTime-z),J=!1}}break t}finally{m=null,b=q,_=!1}J=void 0}}finally{J?Z():O=!1}}}var Z;if(typeof w=="function")Z=function(){w(I)};else if(typeof MessageChannel<"u"){var nt=new MessageChannel,ct=nt.port2;nt.port1.onmessage=I,Z=function(){ct.postMessage(null)}}else Z=function(){y(I,0)};function ft(z,J){P=y(function(){z(e.unstable_now())},J)}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(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125yt?(z.sortIndex=q,t(d,z),n(h)===null&&z===n(d)&&(M?(E(P),P=-1):M=!0,ft(U,q-yt))):(z.sortIndex=At,t(h,z),x||_||(x=!0,O||(O=!0,Z()))),z},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(z){var J=b;return function(){var q=b;b=J;try{return z.apply(this,arguments)}finally{b=q}}}})(W0)),W0}var AM;function o5(){return AM||(AM=1,j0.exports=r5()),j0.exports}var X0={exports:{}},Di={};/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var EM;function l5(){if(EM)return Di;EM=1;var e=H1();function t(h){var d="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),X0.exports=l5(),X0.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var RM;function u5(){if(RM)return vf;RM=1;var e=o5(),t=H1(),n=c5();function i(s){var r="https://react.dev/errors/"+s;if(1At||(s.current=yt[At],yt[At]=null,At--)}function Et(s,r){At++,yt[At]=s.current,s.current=r}var $=B(null),mt=B(null),Dt=B(null),_t=B(null);function Wt(s,r){switch(Et(Dt,r),Et(mt,s),Et($,null),r.nodeType){case 9:case 11:s=(s=r.documentElement)&&(s=s.namespaceURI)?HS(s):0;break;default:if(s=r.tagName,r=r.namespaceURI)r=HS(r),s=jS(r,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}et($),Et($,s)}function ee(){et($),et(mt),et(Dt)}function re(s){s.memoizedState!==null&&Et(_t,s);var r=$.current,c=jS(r,s.type);r!==c&&(Et(mt,s),Et($,c))}function Qe(s){mt.current===s&&(et($),et(mt)),_t.current===s&&(et(_t),df._currentValue=q)}var qe,De;function j(s){if(qe===void 0)try{throw Error()}catch(c){var r=c.stack.trim().match(/\n( *(at )?)/);qe=r&&r[1]||"",De=-1)":-1g||V[f]!==at[g]){var pt=` `+V[f].replace(" at new "," at ");return s.displayName&&pt.includes("")&&(pt=pt.replace("",s.displayName)),pt}while(1<=f&&0<=g);break}}}finally{jn=!1,Error.prepareStackTrace=c}return(c=s?s.displayName||s.name:"")?j(c):""}function Re(s,r){switch(s.tag){case 26:case 27:case 5:return j(s.type);case 16:return j("Lazy");case 13:return s.child!==r&&r!==null?j("Suspense Fallback"):j("Suspense");case 19:return j("SuspenseList");case 0:case 15:return we(s.type,!1);case 11:return we(s.type.render,!1);case 1:return we(s.type,!0);case 31:return j("Activity");default:return""}}function te(s){try{var r="",c=null;do r+=Re(s,c),c=s,s=s.return;while(s);return r}catch(f){return` Error generating stack: `+f.message+` `+f.stack}}var We=Object.prototype.hasOwnProperty,Kt=e.unstable_scheduleCallback,k=e.unstable_cancelCallback,L=e.unstable_shouldYield,it=e.unstable_requestPaint,gt=e.unstable_now,wt=e.unstable_getCurrentPriorityLevel,xt=e.unstable_ImmediatePriority,Qt=e.unstable_UserBlockingPriority,kt=e.unstable_NormalPriority,jt=e.unstable_LowPriority,Le=e.unstable_IdlePriority,Lt=e.log,Ht=e.unstable_setDisableYieldValue,ae=null,Gt=null;function Bt(s){if(typeof Lt=="function"&&Ht(s),Gt&&typeof Gt.setStrictMode=="function")try{Gt.setStrictMode(ae,s)}catch{}}var fe=Math.clz32?Math.clz32:K,me=Math.log,Ge=Math.LN2;function K(s){return s>>>=0,s===0?32:31-(me(s)/Ge|0)|0}var Ut=256,ht=262144,Mt=4194304;function Ot(s){var r=s&42;if(r!==0)return r;switch(s&-s){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 s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ft(s,r,c){var f=s.pendingLanes;if(f===0)return 0;var g=0,v=s.suspendedLanes,T=s.pingedLanes;s=s.warmLanes;var N=f&134217727;return N!==0?(f=N&~v,f!==0?g=Ot(f):(T&=N,T!==0?g=Ot(T):c||(c=N&~s,c!==0&&(g=Ot(c))))):(N=f&~v,N!==0?g=Ot(N):T!==0?g=Ot(T):c||(c=f&~s,c!==0&&(g=Ot(c)))),g===0?0:r!==0&&r!==g&&(r&v)===0&&(v=g&-g,c=r&-r,v>=c||v===32&&(c&4194048)!==0)?r:g}function pe(s,r){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&r)===0}function gn(s,r){switch(s){case 1:case 2:case 4:case 8:case 64:return r+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 r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Pn(){var s=Mt;return Mt<<=1,(Mt&62914560)===0&&(Mt=4194304),s}function ze(s){for(var r=[],c=0;31>c;c++)r.push(s);return r}function bn(s,r){s.pendingLanes|=r,r!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function fs(s,r,c,f,g,v){var T=s.pendingLanes;s.pendingLanes=c,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=c,s.entangledLanes&=c,s.errorRecoveryDisabledLanes&=c,s.shellSuspendCounter=0;var N=s.entanglements,V=s.expirationTimes,at=s.hiddenUpdates;for(c=T&~c;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var ai=/[\n"\\]/g;function Wn(s){return s.replace(ai,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function rn(s,r,c,f,g,v,T,N){s.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?s.type=T:s.removeAttribute("type"),r!=null?T==="number"?(r===0&&s.value===""||s.value!=r)&&(s.value=""+le(r)):s.value!==""+le(r)&&(s.value=""+le(r)):T!=="submit"&&T!=="reset"||s.removeAttribute("value"),r!=null?Ci(s,T,le(r)):c!=null?Ci(s,T,le(c)):f!=null&&s.removeAttribute("value"),g==null&&v!=null&&(s.defaultChecked=!!v),g!=null&&(s.checked=g&&typeof g!="function"&&typeof g!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?s.name=""+le(N):s.removeAttribute("name")}function Bi(s,r,c,f,g,v,T,N){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(s.type=v),r!=null||c!=null){if(!(v!=="submit"&&v!=="reset"||r!=null)){Se(s);return}c=c!=null?""+le(c):"",r=r!=null?""+le(r):c,N||r===s.value||(s.value=r),s.defaultValue=r}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,s.checked=N?s.checked:!!f,s.defaultChecked=!!f,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(s.name=T),Se(s)}function Ci(s,r,c){r==="number"&&Os(s.ownerDocument)===s||s.defaultValue===""+c||(s.defaultValue=""+c)}function Un(s,r,c,f){if(s=s.options,r){r={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Vm=!1;if(Ya)try{var Du={};Object.defineProperty(Du,"passive",{get:function(){Vm=!0}}),window.addEventListener("test",Du,Du),window.removeEventListener("test",Du,Du)}catch{Vm=!1}var Cr=null,Gm=null,Eh=null;function jy(){if(Eh)return Eh;var s,r=Gm,c=r.length,f,g="value"in Cr?Cr.value:Cr.textContent,v=g.length;for(s=0;s=Pu),Zy=" ",Qy=!1;function Jy(s,r){switch(s){case"keyup":return AD.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $y(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Nl=!1;function wD(s,r){switch(s){case"compositionend":return $y(r);case"keypress":return r.which!==32?null:(Qy=!0,Zy);case"textInput":return s=r.data,s===Zy&&Qy?null:s;default:return null}}function RD(s,r){if(Nl)return s==="compositionend"||!qm&&Jy(s,r)?(s=jy(),Eh=Gm=Cr=null,Nl=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:c,offset:r-s};s=f}t:{for(;c;){if(c.nextSibling){c=c.nextSibling;break t}c=c.parentNode}c=void 0}c=ox(c)}}function cx(s,r){return s&&r?s===r?!0:s&&s.nodeType===3?!1:r&&r.nodeType===3?cx(s,r.parentNode):"contains"in s?s.contains(r):s.compareDocumentPosition?!!(s.compareDocumentPosition(r)&16):!1:!1}function ux(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var r=Os(s.document);r instanceof s.HTMLIFrameElement;){try{var c=typeof r.contentWindow.location.href=="string"}catch{c=!1}if(c)s=r.contentWindow;else break;r=Os(s.document)}return r}function Zm(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r&&(r==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||r==="textarea"||s.contentEditable==="true")}var FD=Ya&&"documentMode"in document&&11>=document.documentMode,Pl=null,Qm=null,Iu=null,Jm=!1;function fx(s,r,c){var f=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Jm||Pl==null||Pl!==Os(f)||(f=Pl,"selectionStart"in f&&Zm(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Iu&&Fu(Iu,f)||(Iu=f,f=_d(Qm,"onSelect"),0>=T,g-=T,xa=1<<32-fe(r)+g|c<Me?(Be=$t,$t=null):Be=$t.sibling;var Ke=lt(Q,$t,st[Me],vt);if(Ke===null){$t===null&&($t=Be);break}s&&$t&&Ke.alternate===null&&r(Q,$t),X=v(Ke,X,Me),Ye===null?ce=Ke:Ye.sibling=Ke,Ye=Ke,$t=Be}if(Me===st.length)return c(Q,$t),Ve&&Za(Q,Me),ce;if($t===null){for(;MeMe?(Be=$t,$t=null):Be=$t.sibling;var Qr=lt(Q,$t,Ke.value,vt);if(Qr===null){$t===null&&($t=Be);break}s&&$t&&Qr.alternate===null&&r(Q,$t),X=v(Qr,X,Me),Ye===null?ce=Qr:Ye.sibling=Qr,Ye=Qr,$t=Be}if(Ke.done)return c(Q,$t),Ve&&Za(Q,Me),ce;if($t===null){for(;!Ke.done;Me++,Ke=st.next())Ke=St(Q,Ke.value,vt),Ke!==null&&(X=v(Ke,X,Me),Ye===null?ce=Ke:Ye.sibling=Ke,Ye=Ke);return Ve&&Za(Q,Me),ce}for($t=f($t);!Ke.done;Me++,Ke=st.next())Ke=ut($t,Q,Me,Ke.value,vt),Ke!==null&&(s&&Ke.alternate!==null&&$t.delete(Ke.key===null?Me:Ke.key),X=v(Ke,X,Me),Ye===null?ce=Ke:Ye.sibling=Ke,Ye=Ke);return s&&$t.forEach(function(n5){return r(Q,n5)}),Ve&&Za(Q,Me),ce}function cn(Q,X,st,vt){if(typeof st=="object"&&st!==null&&st.type===M&&st.key===null&&(st=st.props.children),typeof st=="object"&&st!==null){switch(st.$$typeof){case _:t:{for(var ce=st.key;X!==null;){if(X.key===ce){if(ce=st.type,ce===M){if(X.tag===7){c(Q,X.sibling),vt=g(X,st.props.children),vt.return=Q,Q=vt;break t}}else if(X.elementType===ce||typeof ce=="object"&&ce!==null&&ce.$$typeof===F&&Bo(ce)===X.type){c(Q,X.sibling),vt=g(X,st.props),Hu(vt,st),vt.return=Q,Q=vt;break t}c(Q,X);break}else r(Q,X);X=X.sibling}st.type===M?(vt=Uo(st.props.children,Q.mode,vt,st.key),vt.return=Q,Q=vt):(vt=Fh(st.type,st.key,st.props,null,Q.mode,vt),Hu(vt,st),vt.return=Q,Q=vt)}return T(Q);case x:t:{for(ce=st.key;X!==null;){if(X.key===ce)if(X.tag===4&&X.stateNode.containerInfo===st.containerInfo&&X.stateNode.implementation===st.implementation){c(Q,X.sibling),vt=g(X,st.children||[]),vt.return=Q,Q=vt;break t}else{c(Q,X);break}else r(Q,X);X=X.sibling}vt=ag(st,Q.mode,vt),vt.return=Q,Q=vt}return T(Q);case F:return st=Bo(st),cn(Q,X,st,vt)}if(ft(st))return Xt(Q,X,st,vt);if(Z(st)){if(ce=Z(st),typeof ce!="function")throw Error(i(150));return st=ce.call(st),he(Q,X,st,vt)}if(typeof st.then=="function")return cn(Q,X,Hh(st),vt);if(st.$$typeof===w)return cn(Q,X,Bh(Q,st),vt);jh(Q,st)}return typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint"?(st=""+st,X!==null&&X.tag===6?(c(Q,X.sibling),vt=g(X,st),vt.return=Q,Q=vt):(c(Q,X),vt=sg(st,Q.mode,vt),vt.return=Q,Q=vt),T(Q)):c(Q,X)}return function(Q,X,st,vt){try{Gu=0;var ce=cn(Q,X,st,vt);return jl=null,ce}catch($t){if($t===Hl||$t===Vh)throw $t;var Ye=ps(29,$t,null,Q.mode);return Ye.lanes=vt,Ye.return=Q,Ye}finally{}}}var Vo=Ux(!0),Ox=Ux(!1),Ur=!1;function bg(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function vg(s,r){s=s.updateQueue,r.updateQueue===s&&(r.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function Or(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Fr(s,r,c){var f=s.updateQueue;if(f===null)return null;if(f=f.shared,(Je&2)!==0){var g=f.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),f.pending=r,r=Oh(s),vx(s,null,c),r}return Uh(s,f,r,c),Oh(s)}function ju(s,r,c){if(r=r.updateQueue,r!==null&&(r=r.shared,(c&4194048)!==0)){var f=r.lanes;f&=s.pendingLanes,c|=f,r.lanes=c,Co(s,c)}}function _g(s,r){var c=s.updateQueue,f=s.alternate;if(f!==null&&(f=f.updateQueue,c===f)){var g=null,v=null;if(c=c.firstBaseUpdate,c!==null){do{var T={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};v===null?g=v=T:v=v.next=T,c=c.next}while(c!==null);v===null?g=v=r:v=v.next=r}else g=v=r;c={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},s.updateQueue=c;return}s=c.lastBaseUpdate,s===null?c.firstBaseUpdate=r:s.next=r,c.lastBaseUpdate=r}var yg=!1;function Wu(){if(yg){var s=Gl;if(s!==null)throw s}}function Xu(s,r,c,f){yg=!1;var g=s.updateQueue;Ur=!1;var v=g.firstBaseUpdate,T=g.lastBaseUpdate,N=g.shared.pending;if(N!==null){g.shared.pending=null;var V=N,at=V.next;V.next=null,T===null?v=at:T.next=at,T=V;var pt=s.alternate;pt!==null&&(pt=pt.updateQueue,N=pt.lastBaseUpdate,N!==T&&(N===null?pt.firstBaseUpdate=at:N.next=at,pt.lastBaseUpdate=V))}if(v!==null){var St=g.baseState;T=0,pt=at=V=null,N=v;do{var lt=N.lane&-536870913,ut=lt!==N.lane;if(ut?(ke<)===lt:(f<)===lt){lt!==0&<===Vl&&(yg=!0),pt!==null&&(pt=pt.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});t:{var Xt=s,he=N;lt=r;var cn=c;switch(he.tag){case 1:if(Xt=he.payload,typeof Xt=="function"){St=Xt.call(cn,St,lt);break t}St=Xt;break t;case 3:Xt.flags=Xt.flags&-65537|128;case 0:if(Xt=he.payload,lt=typeof Xt=="function"?Xt.call(cn,St,lt):Xt,lt==null)break t;St=m({},St,lt);break t;case 2:Ur=!0}}lt=N.callback,lt!==null&&(s.flags|=64,ut&&(s.flags|=8192),ut=g.callbacks,ut===null?g.callbacks=[lt]:ut.push(lt))}else ut={lane:lt,tag:N.tag,payload:N.payload,callback:N.callback,next:null},pt===null?(at=pt=ut,V=St):pt=pt.next=ut,T|=lt;if(N=N.next,N===null){if(N=g.shared.pending,N===null)break;ut=N,N=ut.next,ut.next=null,g.lastBaseUpdate=ut,g.shared.pending=null}}while(!0);pt===null&&(V=St),g.baseState=V,g.firstBaseUpdate=at,g.lastBaseUpdate=pt,v===null&&(g.shared.lanes=0),Vr|=T,s.lanes=T,s.memoizedState=St}}function Fx(s,r){if(typeof s!="function")throw Error(i(191,s));s.call(r)}function Ix(s,r){var c=s.callbacks;if(c!==null)for(s.callbacks=null,s=0;sv?v:8;var T=z.T,N={};z.T=N,Bg(s,!1,r,c);try{var V=g(),at=z.S;if(at!==null&&at(N,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var pt=WD(V,f);Ku(s,r,pt,_s(s))}else Ku(s,r,f,_s(s))}catch(St){Ku(s,r,{then:function(){},status:"rejected",reason:St},_s())}finally{J.p=v,T!==null&&N.types!==null&&(T.types=N.types),z.T=T}}function QD(){}function Ig(s,r,c,f){if(s.tag!==5)throw Error(i(476));var g=m2(s).queue;p2(s,g,r,q,c===null?QD:function(){return g2(s),c(f)})}function m2(s){var r=s.memoizedState;if(r!==null)return r;r={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tr,lastRenderedState:q},next:null};var c={};return r.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tr,lastRenderedState:c},next:null},s.memoizedState=r,s=s.alternate,s!==null&&(s.memoizedState=r),r}function g2(s){var r=m2(s);r.next===null&&(r=s.alternate.memoizedState),Ku(s,r.next.queue,{},_s())}function kg(){return Mi(df)}function b2(){return Vn().memoizedState}function v2(){return Vn().memoizedState}function JD(s){for(var r=s.return;r!==null;){switch(r.tag){case 24:case 3:var c=_s();s=Or(c);var f=Fr(r,s,c);f!==null&&(ss(f,r,c),ju(f,r,c)),r={cache:dg()},s.payload=r;return}r=r.return}}function $D(s,r,c){var f=_s();c={lane:f,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},td(s)?y2(r,c):(c=ng(s,r,c,f),c!==null&&(ss(c,s,f),x2(c,r,f)))}function _2(s,r,c){var f=_s();Ku(s,r,c,f)}function Ku(s,r,c,f){var g={lane:f,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(td(s))y2(r,g);else{var v=s.alternate;if(s.lanes===0&&(v===null||v.lanes===0)&&(v=r.lastRenderedReducer,v!==null))try{var T=r.lastRenderedState,N=v(T,c);if(g.hasEagerState=!0,g.eagerState=N,ds(N,T))return Uh(s,r,g,0),dn===null&&Ph(),!1}catch{}finally{}if(c=ng(s,r,g,f),c!==null)return ss(c,s,f),x2(c,r,f),!0}return!1}function Bg(s,r,c,f){if(f={lane:2,revertLane:b0(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},td(s)){if(r)throw Error(i(479))}else r=ng(s,c,f,2),r!==null&&ss(r,s,2)}function td(s){var r=s.alternate;return s===ye||r!==null&&r===ye}function y2(s,r){Xl=qh=!0;var c=s.pending;c===null?r.next=r:(r.next=c.next,c.next=r),s.pending=r}function x2(s,r,c){if((c&4194048)!==0){var f=r.lanes;f&=s.pendingLanes,c|=f,r.lanes=c,Co(s,c)}}var Zu={readContext:Mi,use:Zh,useCallback:On,useContext:On,useEffect:On,useImperativeHandle:On,useLayoutEffect:On,useInsertionEffect:On,useMemo:On,useReducer:On,useRef:On,useState:On,useDebugValue:On,useDeferredValue:On,useTransition:On,useSyncExternalStore:On,useId:On,useHostTransitionStatus:On,useFormState:On,useActionState:On,useOptimistic:On,useMemoCache:On,useCacheRefresh:On};Zu.useEffectEvent=On;var S2={readContext:Mi,use:Zh,useCallback:function(s,r){return zi().memoizedState=[s,r===void 0?null:r],s},useContext:Mi,useEffect:a2,useImperativeHandle:function(s,r,c){c=c!=null?c.concat([s]):null,Jh(4194308,4,c2.bind(null,r,s),c)},useLayoutEffect:function(s,r){return Jh(4194308,4,s,r)},useInsertionEffect:function(s,r){Jh(4,2,s,r)},useMemo:function(s,r){var c=zi();r=r===void 0?null:r;var f=s();if(Go){Bt(!0);try{s()}finally{Bt(!1)}}return c.memoizedState=[f,r],f},useReducer:function(s,r,c){var f=zi();if(c!==void 0){var g=c(r);if(Go){Bt(!0);try{c(r)}finally{Bt(!1)}}}else g=r;return f.memoizedState=f.baseState=g,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:g},f.queue=s,s=s.dispatch=$D.bind(null,ye,s),[f.memoizedState,s]},useRef:function(s){var r=zi();return s={current:s},r.memoizedState=s},useState:function(s){s=Ng(s);var r=s.queue,c=_2.bind(null,ye,r);return r.dispatch=c,[s.memoizedState,c]},useDebugValue:Og,useDeferredValue:function(s,r){var c=zi();return Fg(c,s,r)},useTransition:function(){var s=Ng(!1);return s=p2.bind(null,ye,s.queue,!0,!1),zi().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,r,c){var f=ye,g=zi();if(Ve){if(c===void 0)throw Error(i(407));c=c()}else{if(c=r(),dn===null)throw Error(i(349));(ke&127)!==0||Hx(f,r,c)}g.memoizedState=c;var v={value:c,getSnapshot:r};return g.queue=v,a2(Wx.bind(null,f,v,s),[s]),f.flags|=2048,Yl(9,{destroy:void 0},jx.bind(null,f,v,c,r),null),c},useId:function(){var s=zi(),r=dn.identifierPrefix;if(Ve){var c=Sa,f=xa;c=(f&~(1<<32-fe(f)-1)).toString(32)+c,r="_"+r+"R_"+c,c=Yh++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?T.createElement("select",{is:f.is}):T.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?T.createElement(g,{is:f.is}):T.createElement(g)}}v[Sn]=r,v[ii]=f;t:for(T=r.child;T!==null;){if(T.tag===5||T.tag===6)v.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===r)break t;for(;T.sibling===null;){if(T.return===null||T.return===r)break t;T=T.return}T.sibling.return=T.return,T=T.sibling}r.stateNode=v;t:switch(Ai(v,g,f),g){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break t;case"img":f=!0;break t;default:f=!1}f&&nr(r)}}return yn(r),$g(r,r.type,s===null?null:s.memoizedProps,r.pendingProps,c),null;case 6:if(s&&r.stateNode!=null)s.memoizedProps!==f&&nr(r);else{if(typeof f!="string"&&r.stateNode===null)throw Error(i(166));if(s=Dt.current,Bl(r)){if(s=r.stateNode,c=r.memoizedProps,f=null,g=Si,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}s[Sn]=r,s=!!(s.nodeValue===c||f!==null&&f.suppressHydrationWarning===!0||VS(s.nodeValue,c)),s||Nr(r,!0)}else s=yd(s).createTextNode(f),s[Sn]=r,r.stateNode=s}return yn(r),null;case 31:if(c=r.memoizedState,s===null||s.memoizedState!==null){if(f=Bl(r),c!==null){if(s===null){if(!f)throw Error(i(318));if(s=r.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(i(557));s[Sn]=r}else Oo(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;yn(r),s=!1}else c=cg(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=c),s=!0;if(!s)return r.flags&256?(gs(r),r):(gs(r),null);if((r.flags&128)!==0)throw Error(i(558))}return yn(r),null;case 13:if(f=r.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(g=Bl(r),f!==null&&f.dehydrated!==null){if(s===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[Sn]=r}else Oo(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;yn(r),g=!1}else g=cg(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=g),g=!0;if(!g)return r.flags&256?(gs(r),r):(gs(r),null)}return gs(r),(r.flags&128)!==0?(r.lanes=c,r):(c=f!==null,s=s!==null&&s.memoizedState!==null,c&&(f=r.child,g=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(g=f.alternate.memoizedState.cachePool.pool),v=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(v=f.memoizedState.cachePool.pool),v!==g&&(f.flags|=2048)),c!==s&&c&&(r.child.flags|=8192),ad(r,r.updateQueue),yn(r),null);case 4:return ee(),s===null&&x0(r.stateNode.containerInfo),yn(r),null;case 10:return Ja(r.type),yn(r),null;case 19:if(et(zn),f=r.memoizedState,f===null)return yn(r),null;if(g=(r.flags&128)!==0,v=f.rendering,v===null)if(g)Ju(f,!1);else{if(Fn!==0||s!==null&&(s.flags&128)!==0)for(s=r.child;s!==null;){if(v=Xh(s),v!==null){for(r.flags|=128,Ju(f,!1),s=v.updateQueue,r.updateQueue=s,ad(r,s),r.subtreeFlags=0,s=c,c=r.child;c!==null;)_x(c,s),c=c.sibling;return Et(zn,zn.current&1|2),Ve&&Za(r,f.treeForkCount),r.child}s=s.sibling}f.tail!==null&>()>ud&&(r.flags|=128,g=!0,Ju(f,!1),r.lanes=4194304)}else{if(!g)if(s=Xh(v),s!==null){if(r.flags|=128,g=!0,s=s.updateQueue,r.updateQueue=s,ad(r,s),Ju(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!Ve)return yn(r),null}else 2*gt()-f.renderingStartTime>ud&&c!==536870912&&(r.flags|=128,g=!0,Ju(f,!1),r.lanes=4194304);f.isBackwards?(v.sibling=r.child,r.child=v):(s=f.last,s!==null?s.sibling=v:r.child=v,f.last=v)}return f.tail!==null?(s=f.tail,f.rendering=s,f.tail=s.sibling,f.renderingStartTime=gt(),s.sibling=null,c=zn.current,Et(zn,g?c&1|2:c&1),Ve&&Za(r,f.treeForkCount),s):(yn(r),null);case 22:case 23:return gs(r),Sg(),f=r.memoizedState!==null,s!==null?s.memoizedState!==null!==f&&(r.flags|=8192):f&&(r.flags|=8192),f?(c&536870912)!==0&&(r.flags&128)===0&&(yn(r),r.subtreeFlags&6&&(r.flags|=8192)):yn(r),c=r.updateQueue,c!==null&&ad(r,c.retryQueue),c=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(c=s.memoizedState.cachePool.pool),f=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(f=r.memoizedState.cachePool.pool),f!==c&&(r.flags|=2048),s!==null&&et(ko),null;case 24:return c=null,s!==null&&(c=s.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),Ja(Xn),yn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function sL(s,r){switch(og(r),r.tag){case 1:return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 3:return Ja(Xn),ee(),s=r.flags,(s&65536)!==0&&(s&128)===0?(r.flags=s&-65537|128,r):null;case 26:case 27:case 5:return Qe(r),null;case 31:if(r.memoizedState!==null){if(gs(r),r.alternate===null)throw Error(i(340));Oo()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 13:if(gs(r),s=r.memoizedState,s!==null&&s.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Oo()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 19:return et(zn),null;case 4:return ee(),null;case 10:return Ja(r.type),null;case 22:case 23:return gs(r),Sg(),s!==null&&et(ko),s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 24:return Ja(Xn),null;case 25:return null;default:return null}}function X2(s,r){switch(og(r),r.tag){case 3:Ja(Xn),ee();break;case 26:case 27:case 5:Qe(r);break;case 4:ee();break;case 31:r.memoizedState!==null&&gs(r);break;case 13:gs(r);break;case 19:et(zn);break;case 10:Ja(r.type);break;case 22:case 23:gs(r),Sg(),s!==null&&et(ko);break;case 24:Ja(Xn)}}function $u(s,r){try{var c=r.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var g=f.next;c=g;do{if((c.tag&s)===s){f=void 0;var v=c.create,T=c.inst;f=v(),T.destroy=f}c=c.next}while(c!==g)}}catch(N){sn(r,r.return,N)}}function Br(s,r,c){try{var f=r.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&s)===s){var T=f.inst,N=T.destroy;if(N!==void 0){T.destroy=void 0,g=r;var V=c,at=N;try{at()}catch(pt){sn(g,V,pt)}}}f=f.next}while(f!==v)}}catch(pt){sn(r,r.return,pt)}}function q2(s){var r=s.updateQueue;if(r!==null){var c=s.stateNode;try{Ix(r,c)}catch(f){sn(s,s.return,f)}}}function Y2(s,r,c){c.props=Ho(s.type,s.memoizedProps),c.state=s.memoizedState;try{c.componentWillUnmount()}catch(f){sn(s,r,f)}}function tf(s,r){try{var c=s.ref;if(c!==null){switch(s.tag){case 26:case 27:case 5:var f=s.stateNode;break;case 30:f=s.stateNode;break;default:f=s.stateNode}typeof c=="function"?s.refCleanup=c(f):c.current=f}}catch(g){sn(s,r,g)}}function Ma(s,r){var c=s.ref,f=s.refCleanup;if(c!==null)if(typeof f=="function")try{f()}catch(g){sn(s,r,g)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(g){sn(s,r,g)}else c.current=null}function K2(s){var r=s.type,c=s.memoizedProps,f=s.stateNode;try{t:switch(r){case"button":case"input":case"select":case"textarea":c.autoFocus&&f.focus();break t;case"img":c.src?f.src=c.src:c.srcSet&&(f.srcset=c.srcSet)}}catch(g){sn(s,s.return,g)}}function t0(s,r,c){try{var f=s.stateNode;EL(f,s.type,c,r),f[ii]=r}catch(g){sn(s,s.return,g)}}function Z2(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Xr(s.type)||s.tag===4}function e0(s){t:for(;;){for(;s.sibling===null;){if(s.return===null||Z2(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Xr(s.type)||s.flags&2||s.child===null||s.tag===4)continue t;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function n0(s,r,c){var f=s.tag;if(f===5||f===6)s=s.stateNode,r?(c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c).insertBefore(s,r):(r=c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c,r.appendChild(s),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=qa));else if(f!==4&&(f===27&&Xr(s.type)&&(c=s.stateNode,r=null),s=s.child,s!==null))for(n0(s,r,c),s=s.sibling;s!==null;)n0(s,r,c),s=s.sibling}function rd(s,r,c){var f=s.tag;if(f===5||f===6)s=s.stateNode,r?c.insertBefore(s,r):c.appendChild(s);else if(f!==4&&(f===27&&Xr(s.type)&&(c=s.stateNode),s=s.child,s!==null))for(rd(s,r,c),s=s.sibling;s!==null;)rd(s,r,c),s=s.sibling}function Q2(s){var r=s.stateNode,c=s.memoizedProps;try{for(var f=s.type,g=r.attributes;g.length;)r.removeAttributeNode(g[0]);Ai(r,f,c),r[Sn]=s,r[ii]=c}catch(v){sn(s,s.return,v)}}var ir=!1,Kn=!1,i0=!1,J2=typeof WeakSet=="function"?WeakSet:Set,gi=null;function aL(s,r){if(s=s.containerInfo,T0=wd,s=ux(s),Zm(s)){if("selectionStart"in s)var c={start:s.selectionStart,end:s.selectionEnd};else t:{c=(c=s.ownerDocument)&&c.defaultView||window;var f=c.getSelection&&c.getSelection();if(f&&f.rangeCount!==0){c=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{c.nodeType,v.nodeType}catch{c=null;break t}var T=0,N=-1,V=-1,at=0,pt=0,St=s,lt=null;e:for(;;){for(var ut;St!==c||g!==0&&St.nodeType!==3||(N=T+g),St!==v||f!==0&&St.nodeType!==3||(V=T+f),St.nodeType===3&&(T+=St.nodeValue.length),(ut=St.firstChild)!==null;)lt=St,St=ut;for(;;){if(St===s)break e;if(lt===c&&++at===g&&(N=T),lt===v&&++pt===f&&(V=T),(ut=St.nextSibling)!==null)break;St=lt,lt=St.parentNode}St=ut}c=N===-1||V===-1?null:{start:N,end:V}}else c=null}c=c||{start:0,end:0}}else c=null;for(A0={focusedElem:s,selectionRange:c},wd=!1,gi=r;gi!==null;)if(r=gi,s=r.child,(r.subtreeFlags&1028)!==0&&s!==null)s.return=r,gi=s;else for(;gi!==null;){switch(r=gi,v=r.alternate,s=r.flags,r.tag){case 0:if((s&4)!==0&&(s=r.updateQueue,s=s!==null?s.events:null,s!==null))for(c=0;c title"))),Ai(v,f,c),v[Sn]=s,H(v),f=v;break t;case"link":var T=sM("link","href",g).get(f+(c.href||""));if(T){for(var N=0;Ncn&&(T=cn,cn=he,he=T);var Q=lx(N,he),X=lx(N,cn);if(Q&&X&&(ut.rangeCount!==1||ut.anchorNode!==Q.node||ut.anchorOffset!==Q.offset||ut.focusNode!==X.node||ut.focusOffset!==X.offset)){var st=St.createRange();st.setStart(Q.node,Q.offset),ut.removeAllRanges(),he>cn?(ut.addRange(st),ut.extend(X.node,X.offset)):(st.setEnd(X.node,X.offset),ut.addRange(st))}}}}for(St=[],ut=N;ut=ut.parentNode;)ut.nodeType===1&&St.push({element:ut,left:ut.scrollLeft,top:ut.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Nc?32:c,z.T=null,c=u0,u0=null;var v=Hr,T=lr;if(ri=0,$l=Hr=null,lr=0,(Je&6)!==0)throw Error(i(331));var N=Je;if(Je|=4,cS(v.current),rS(v,v.current,T,c),Je=N,of(0,!1),Gt&&typeof Gt.onPostCommitFiberRoot=="function")try{Gt.onPostCommitFiberRoot(ae,v)}catch{}return!0}finally{J.p=g,z.T=f,wS(s,r)}}function CS(s,r,c){r=Is(c,r),r=Hg(s.stateNode,r,2),s=Fr(s,r,2),s!==null&&(bn(s,2),Ta(s))}function sn(s,r,c){if(s.tag===3)CS(s,s,c);else for(;r!==null;){if(r.tag===3){CS(r,s,c);break}else if(r.tag===1){var f=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(Gr===null||!Gr.has(f))){s=Is(c,s),c=D2(2),f=Fr(r,c,2),f!==null&&(L2(c,f,r,s),bn(f,2),Ta(f));break}}r=r.return}}function p0(s,r,c){var f=s.pingCache;if(f===null){f=s.pingCache=new lL;var g=new Set;f.set(r,g)}else g=f.get(r),g===void 0&&(g=new Set,f.set(r,g));g.has(c)||(r0=!0,g.add(c),s=dL.bind(null,s,r,c),r.then(s,s))}function dL(s,r,c){var f=s.pingCache;f!==null&&f.delete(r),s.pingedLanes|=s.suspendedLanes&c,s.warmLanes&=~c,dn===s&&(ke&c)===c&&(Fn===4||Fn===3&&(ke&62914560)===ke&&300>gt()-cd?(Je&2)===0&&tc(s,0):o0|=c,Jl===ke&&(Jl=0)),Ta(s)}function DS(s,r){r===0&&(r=Pn()),s=Po(s,r),s!==null&&(bn(s,r),Ta(s))}function pL(s){var r=s.memoizedState,c=0;r!==null&&(c=r.retryLane),DS(s,c)}function mL(s,r){var c=0;switch(s.tag){case 31:case 13:var f=s.stateNode,g=s.memoizedState;g!==null&&(c=g.retryLane);break;case 19:f=s.stateNode;break;case 22:f=s.stateNode._retryCache;break;default:throw Error(i(314))}f!==null&&f.delete(r),DS(s,c)}function gL(s,r){return Kt(s,r)}var gd=null,nc=null,m0=!1,bd=!1,g0=!1,Wr=0;function Ta(s){s!==nc&&s.next===null&&(nc===null?gd=nc=s:nc=nc.next=s),bd=!0,m0||(m0=!0,vL())}function of(s,r){if(!g0&&bd){g0=!0;do for(var c=!1,f=gd;f!==null;){if(s!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var T=f.suspendedLanes,N=f.pingedLanes;v=(1<<31-fe(42|s)+1)-1,v&=g&~(T&~N),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(c=!0,US(f,v))}else v=ke,v=Ft(f,f===dn?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||pe(f,v)||(c=!0,US(f,v));f=f.next}while(c);g0=!1}}function bL(){LS()}function LS(){bd=m0=!1;var s=0;Wr!==0&&RL()&&(s=Wr);for(var r=gt(),c=null,f=gd;f!==null;){var g=f.next,v=NS(f,r);v===0?(f.next=null,c===null?gd=g:c.next=g,g===null&&(nc=c)):(c=f,(s!==0||(v&3)!==0)&&(bd=!0)),f=g}ri!==0&&ri!==5||of(s),Wr!==0&&(Wr=0)}function NS(s,r){for(var c=s.suspendedLanes,f=s.pingedLanes,g=s.expirationTimes,v=s.pendingLanes&-62914561;0N)break;var pt=V.transferSize,St=V.initiatorType;pt&&GS(St)&&(V=V.responseEnd,T+=pt*(V"u"?null:document;function tM(s,r,c){var f=ic;if(f&&typeof r=="string"&&r){var g=Wn(r);g='link[rel="'+s+'"][href="'+g+'"]',typeof c=="string"&&(g+='[crossorigin="'+c+'"]'),$S.has(g)||($S.add(g),s={rel:s,crossOrigin:c,href:r},f.querySelector(g)===null&&(r=f.createElement("link"),Ai(r,"link",s),H(r),f.head.appendChild(r)))}}function IL(s){cr.D(s),tM("dns-prefetch",s,null)}function kL(s,r){cr.C(s,r),tM("preconnect",s,r)}function BL(s,r,c){cr.L(s,r,c);var f=ic;if(f&&s&&r){var g='link[rel="preload"][as="'+Wn(r)+'"]';r==="image"&&c&&c.imageSrcSet?(g+='[imagesrcset="'+Wn(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(g+='[imagesizes="'+Wn(c.imageSizes)+'"]')):g+='[href="'+Wn(s)+'"]';var v=g;switch(r){case"style":v=sc(s);break;case"script":v=ac(s)}Hs.has(v)||(s=m({rel:"preload",href:r==="image"&&c&&c.imageSrcSet?void 0:s,as:r},c),Hs.set(v,s),f.querySelector(g)!==null||r==="style"&&f.querySelector(ff(v))||r==="script"&&f.querySelector(hf(v))||(r=f.createElement("link"),Ai(r,"link",s),H(r),f.head.appendChild(r)))}}function zL(s,r){cr.m(s,r);var c=ic;if(c&&s){var f=r&&typeof r.as=="string"?r.as:"script",g='link[rel="modulepreload"][as="'+Wn(f)+'"][href="'+Wn(s)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=ac(s)}if(!Hs.has(v)&&(s=m({rel:"modulepreload",href:s},r),Hs.set(v,s),c.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(hf(v)))return}f=c.createElement("link"),Ai(f,"link",s),H(f),c.head.appendChild(f)}}}function VL(s,r,c){cr.S(s,r,c);var f=ic;if(f&&s){var g=Y(f).hoistableStyles,v=sc(s);r=r||"default";var T=g.get(v);if(!T){var N={loading:0,preload:null};if(T=f.querySelector(ff(v)))N.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":r},c),(c=Hs.get(v))&&N0(s,c);var V=T=f.createElement("link");H(V),Ai(V,"link",s),V._p=new Promise(function(at,pt){V.onload=at,V.onerror=pt}),V.addEventListener("load",function(){N.loading|=1}),V.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Sd(T,r,f)}T={type:"stylesheet",instance:T,count:1,state:N},g.set(v,T)}}}function GL(s,r){cr.X(s,r);var c=ic;if(c&&s){var f=Y(c).hoistableScripts,g=ac(s),v=f.get(g);v||(v=c.querySelector(hf(g)),v||(s=m({src:s,async:!0},r),(r=Hs.get(g))&&P0(s,r),v=c.createElement("script"),H(v),Ai(v,"link",s),c.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function HL(s,r){cr.M(s,r);var c=ic;if(c&&s){var f=Y(c).hoistableScripts,g=ac(s),v=f.get(g);v||(v=c.querySelector(hf(g)),v||(s=m({src:s,async:!0,type:"module"},r),(r=Hs.get(g))&&P0(s,r),v=c.createElement("script"),H(v),Ai(v,"link",s),c.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function eM(s,r,c,f){var g=(g=Dt.current)?xd(g):null;if(!g)throw Error(i(446));switch(s){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(r=sc(c.href),c=Y(g).hoistableStyles,f=c.get(r),f||(f={type:"style",instance:null,count:0,state:null},c.set(r,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){s=sc(c.href);var v=Y(g).hoistableStyles,T=v.get(s);if(T||(g=g.ownerDocument||g,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(s,T),(v=g.querySelector(ff(s)))&&!v._p&&(T.instance=v,T.state.loading=5),Hs.has(s)||(c={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},Hs.set(s,c),v||jL(g,s,c,T.state))),r&&f===null)throw Error(i(528,""));return T}if(r&&f!==null)throw Error(i(529,""));return null;case"script":return r=c.async,c=c.src,typeof c=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=ac(c),c=Y(g).hoistableScripts,f=c.get(r),f||(f={type:"script",instance:null,count:0,state:null},c.set(r,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,s))}}function sc(s){return'href="'+Wn(s)+'"'}function ff(s){return'link[rel="stylesheet"]['+s+"]"}function nM(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function jL(s,r,c,f){s.querySelector('link[rel="preload"][as="style"]['+r+"]")?f.loading=1:(r=s.createElement("link"),f.preload=r,r.addEventListener("load",function(){return f.loading|=1}),r.addEventListener("error",function(){return f.loading|=2}),Ai(r,"link",c),H(r),s.head.appendChild(r))}function ac(s){return'[src="'+Wn(s)+'"]'}function hf(s){return"script[async]"+s}function iM(s,r,c){if(r.count++,r.instance===null)switch(r.type){case"style":var f=s.querySelector('style[data-href~="'+Wn(c.href)+'"]');if(f)return r.instance=f,H(f),f;var g=m({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return f=(s.ownerDocument||s).createElement("style"),H(f),Ai(f,"style",g),Sd(f,c.precedence,s),r.instance=f;case"stylesheet":g=sc(c.href);var v=s.querySelector(ff(g));if(v)return r.state.loading|=4,r.instance=v,H(v),v;f=nM(c),(g=Hs.get(g))&&N0(f,g),v=(s.ownerDocument||s).createElement("link"),H(v);var T=v;return T._p=new Promise(function(N,V){T.onload=N,T.onerror=V}),Ai(v,"link",f),r.state.loading|=4,Sd(v,c.precedence,s),r.instance=v;case"script":return v=ac(c.src),(g=s.querySelector(hf(v)))?(r.instance=g,H(g),g):(f=c,(g=Hs.get(v))&&(f=m({},c),P0(f,g)),s=s.ownerDocument||s,g=s.createElement("script"),H(g),Ai(g,"link",f),s.head.appendChild(g),r.instance=g);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(f=r.instance,r.state.loading|=4,Sd(f,c.precedence,s));return r.instance}function Sd(s,r,c){for(var f=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,T=0;T title"):null)}function WL(s,r,c){if(c===1||r.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return s=r.disabled,typeof r.precedence=="string"&&s==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function rM(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function XL(s,r,c,f){if(c.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var g=sc(f.href),v=r.querySelector(ff(g));if(v){r=v._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(s.count++,s=Td.bind(s),r.then(s,s)),c.state.loading|=4,c.instance=v,H(v);return}v=r.ownerDocument||r,f=nM(f),(g=Hs.get(g))&&N0(f,g),v=v.createElement("link"),H(v);var T=v;T._p=new Promise(function(N,V){T.onload=N,T.onerror=V}),Ai(v,"link",f),c.instance=v}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(c,r),(r=c.state.preload)&&(c.state.loading&3)===0&&(s.count++,c=Td.bind(s),r.addEventListener("load",c),r.addEventListener("error",c))}}var U0=0;function qL(s,r){return s.stylesheets&&s.count===0&&Ed(s,s.stylesheets),0U0?50:800)+r);return s.unsuspend=c,function(){s.unsuspend=null,clearTimeout(f),clearTimeout(g)}}:null}function Td(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ed(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var Ad=null;function Ed(s,r){s.stylesheets=null,s.unsuspend!==null&&(s.count++,Ad=new Map,r.forEach(YL,s),Ad=null,Td.call(s))}function YL(s,r){if(!(r.state.loading&4)){var c=Ad.get(s);if(c)var f=c.get(null);else{c=new Map,Ad.set(s,c);for(var g=s.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),H0.exports=u5(),H0.exports}var h5=f5();/** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */const j1="174",d5=0,DM=1,p5=2,S3=1,m5=2,gr=3,Mr=0,Oi=1,os=2,vo=0,Uc=1,zf=2,LM=3,NM=4,g5=5,rl=100,b5=101,v5=102,_5=103,y5=104,x5=200,S5=201,M5=202,T5=203,ov=204,lv=205,A5=206,E5=207,w5=208,R5=209,C5=210,D5=211,L5=212,N5=213,P5=214,cv=0,uv=1,fv=2,zc=3,hv=4,dv=5,pv=6,mv=7,M3=0,U5=1,O5=2,_o=0,F5=1,I5=2,k5=3,B5=4,z5=5,V5=6,G5=7,PM="attached",H5="detached",T3=300,Vc=301,Gc=302,gv=303,bv=304,rm=306,Da=1e3,mo=1001,kp=1002,Ki=1003,A3=1004,Pf=1005,As=1006,_p=1007,yr=1008,Tr=1009,E3=1010,w3=1011,Qf=1012,W1=1013,_l=1014,fa=1015,uh=1016,X1=1017,q1=1018,Hc=1020,R3=35902,C3=1021,D3=1022,Ks=1023,L3=1024,N3=1025,Oc=1026,jc=1027,Y1=1028,K1=1029,P3=1030,Z1=1031,Q1=1033,yp=33776,xp=33777,Sp=33778,Mp=33779,vv=35840,_v=35841,yv=35842,xv=35843,Sv=36196,Mv=37492,Tv=37496,Av=37808,Ev=37809,wv=37810,Rv=37811,Cv=37812,Dv=37813,Lv=37814,Nv=37815,Pv=37816,Uv=37817,Ov=37818,Fv=37819,Iv=37820,kv=37821,Tp=36492,Bv=36494,zv=36495,U3=36283,Vv=36284,Gv=36285,Hv=36286,Uf=2200,j5=2201,W5=2202,Jf=2300,$f=2301,q0=2302,wc=2400,Rc=2401,Bp=2402,J1=2500,X5=2501,q5=0,O3=1,jv=2,Y5=3200,K5=3201,F3=0,Z5=1,uo="",Jn="srgb",Qi="srgb-linear",zp="linear",un="srgb",oc=7680,UM=519,Q5=512,J5=513,$5=514,I3=515,tN=516,eN=517,nN=518,iN=519,Wv=35044,OM="300 es",xr=2e3,Vp=2001;class Al{addEventListener(t,n){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(n)===-1&&i[t].push(n)}hasEventListener(t,n){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(n)!==-1}removeEventListener(t,n){const i=this._listeners;if(i===void 0)return;const a=i[t];if(a!==void 0){const o=a.indexOf(n);o!==-1&&a.splice(o,1)}}dispatchEvent(t){const n=this._listeners;if(n===void 0)return;const i=n[t.type];if(i!==void 0){t.target=this;const a=i.slice(0);for(let o=0,l=a.length;o>8&255]+Li[e>>16&255]+Li[e>>24&255]+"-"+Li[t&255]+Li[t>>8&255]+"-"+Li[t>>16&15|64]+Li[t>>24&255]+"-"+Li[n&63|128]+Li[n>>8&255]+"-"+Li[n>>16&255]+Li[n>>24&255]+Li[i&255]+Li[i>>8&255]+Li[i>>16&255]+Li[i>>24&255]).toLowerCase()}function Fe(e,t,n){return Math.max(t,Math.min(n,e))}function $1(e,t){return(e%t+t)%t}function sN(e,t,n,i,a){return i+(e-t)*(a-i)/(n-t)}function aN(e,t,n){return e!==t?(n-e)/(t-e):0}function Gf(e,t,n){return(1-n)*e+n*t}function rN(e,t,n,i){return Gf(e,t,1-Math.exp(-n*i))}function oN(e,t=1){return t-Math.abs($1(e,t*2)-t)}function lN(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function cN(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function uN(e,t){return e+Math.floor(Math.random()*(t-e+1))}function fN(e,t){return e+Math.random()*(t-e)}function hN(e){return e*(.5-Math.random())}function dN(e){e!==void 0&&(FM=e);let t=FM+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function pN(e){return e*Vf}function mN(e){return e*Wc}function gN(e){return(e&e-1)===0&&e!==0}function bN(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function vN(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function _N(e,t,n,i,a){const o=Math.cos,l=Math.sin,u=o(n/2),h=l(n/2),d=o((t+i)/2),p=l((t+i)/2),m=o((t-i)/2),b=l((t-i)/2),_=o((i-t)/2),x=l((i-t)/2);switch(a){case"XYX":e.set(u*p,h*m,h*b,u*d);break;case"YZY":e.set(h*b,u*p,h*m,u*d);break;case"ZXZ":e.set(h*m,h*b,u*p,u*d);break;case"XZX":e.set(u*p,h*x,h*_,u*d);break;case"YXY":e.set(h*_,u*p,h*x,u*d);break;case"ZYZ":e.set(h*x,h*_,u*p,u*d);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}}function ca(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("Invalid component type.")}}function an(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw new Error("Invalid component type.")}}const Rn={DEG2RAD:Vf,RAD2DEG:Wc,generateUUID:ha,clamp:Fe,euclideanModulo:$1,mapLinear:sN,inverseLerp:aN,lerp:Gf,damp:rN,pingpong:oN,smoothstep:lN,smootherstep:cN,randInt:uN,randFloat:fN,randFloatSpread:hN,seededRandom:dN,degToRad:pN,radToDeg:mN,isPowerOfTwo:gN,ceilPowerOfTwo:bN,floorPowerOfTwo:vN,setQuaternionFromProperEuler:_N,normalize:an,denormalize:ca};class Ae{constructor(t=0,n=0){Ae.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,n){return this.x=t,this.y=n,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const n=this.x,i=this.y,a=t.elements;return this.x=a[0]*n+a[3]*i+a[6],this.y=a[1]*n+a[4]*i+a[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,n){return this.x=Fe(this.x,t.x,n.x),this.y=Fe(this.y,t.y,n.y),this}clampScalar(t,n){return this.x=Fe(this.x,t,n),this.y=Fe(this.y,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,t,n))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(t)/n;return Math.acos(Fe(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,i=this.y-t.y;return n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this}lerpVectors(t,n,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this}rotateAround(t,n){const i=Math.cos(n),a=Math.sin(n),o=this.x-t.x,l=this.y-t.y;return this.x=o*i-l*a+t.x,this.y=o*a+l*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Te{constructor(t,n,i,a,o,l,u,h,d){Te.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,i,a,o,l,u,h,d)}set(t,n,i,a,o,l,u,h,d){const p=this.elements;return p[0]=t,p[1]=a,p[2]=u,p[3]=n,p[4]=o,p[5]=h,p[6]=i,p[7]=l,p[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const n=this.elements,i=t.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(t,n,i){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const n=t.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const i=t.elements,a=n.elements,o=this.elements,l=i[0],u=i[3],h=i[6],d=i[1],p=i[4],m=i[7],b=i[2],_=i[5],x=i[8],M=a[0],S=a[3],y=a[6],E=a[1],w=a[4],A=a[7],U=a[2],O=a[5],P=a[8];return o[0]=l*M+u*E+h*U,o[3]=l*S+u*w+h*O,o[6]=l*y+u*A+h*P,o[1]=d*M+p*E+m*U,o[4]=d*S+p*w+m*O,o[7]=d*y+p*A+m*P,o[2]=b*M+_*E+x*U,o[5]=b*S+_*w+x*O,o[8]=b*y+_*A+x*P,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this}determinant(){const t=this.elements,n=t[0],i=t[1],a=t[2],o=t[3],l=t[4],u=t[5],h=t[6],d=t[7],p=t[8];return n*l*p-n*u*d-i*o*p+i*u*h+a*o*d-a*l*h}invert(){const t=this.elements,n=t[0],i=t[1],a=t[2],o=t[3],l=t[4],u=t[5],h=t[6],d=t[7],p=t[8],m=p*l-u*d,b=u*h-p*o,_=d*o-l*h,x=n*m+i*b+a*_;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const M=1/x;return t[0]=m*M,t[1]=(a*d-p*i)*M,t[2]=(u*i-a*l)*M,t[3]=b*M,t[4]=(p*n-a*h)*M,t[5]=(a*o-u*n)*M,t[6]=_*M,t[7]=(i*h-d*n)*M,t[8]=(l*n-i*o)*M,this}transpose(){let t;const n=this.elements;return t=n[1],n[1]=n[3],n[3]=t,t=n[2],n[2]=n[6],n[6]=t,t=n[5],n[5]=n[7],n[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const n=this.elements;return t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8],this}setUvTransform(t,n,i,a,o,l,u){const h=Math.cos(o),d=Math.sin(o);return this.set(i*h,i*d,-i*(h*l+d*u)+l+t,-a*d,a*h,-a*(-d*l+h*u)+u+n,0,0,1),this}scale(t,n){return this.premultiply(Y0.makeScale(t,n)),this}rotate(t){return this.premultiply(Y0.makeRotation(-t)),this}translate(t,n){return this.premultiply(Y0.makeTranslation(t,n)),this}makeTranslation(t,n){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,n,0,0,1),this}makeRotation(t){const n=Math.cos(t),i=Math.sin(t);return this.set(n,-i,0,i,n,0,0,0,1),this}makeScale(t,n){return this.set(t,0,0,0,n,0,0,0,1),this}equals(t){const n=this.elements,i=t.elements;for(let a=0;a<9;a++)if(n[a]!==i[a])return!1;return!0}fromArray(t,n=0){for(let i=0;i<9;i++)this.elements[i]=t[i+n];return this}toArray(t=[],n=0){const i=this.elements;return t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3],t[n+4]=i[4],t[n+5]=i[5],t[n+6]=i[6],t[n+7]=i[7],t[n+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Y0=new Te;function k3(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function th(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function yN(){const e=th("canvas");return e.style.display="block",e}const IM={};function nl(e){e in IM||(IM[e]=!0,console.warn(e))}function xN(e,t,n){return new Promise(function(i,a){function o(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:a();break;case e.TIMEOUT_EXPIRED:setTimeout(o,n);break;default:i()}}setTimeout(o,n)})}function SN(e){const t=e.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function MN(e){const t=e.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const kM=new Te().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),BM=new Te().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function TN(){const e={enabled:!0,workingColorSpace:Qi,spaces:{},convert:function(a,o,l){return this.enabled===!1||o===l||!o||!l||(this.spaces[o].transfer===un&&(a.r=Sr(a.r),a.g=Sr(a.g),a.b=Sr(a.b)),this.spaces[o].primaries!==this.spaces[l].primaries&&(a.applyMatrix3(this.spaces[o].toXYZ),a.applyMatrix3(this.spaces[l].fromXYZ)),this.spaces[l].transfer===un&&(a.r=Fc(a.r),a.g=Fc(a.g),a.b=Fc(a.b))),a},fromWorkingColorSpace:function(a,o){return this.convert(a,this.workingColorSpace,o)},toWorkingColorSpace:function(a,o){return this.convert(a,o,this.workingColorSpace)},getPrimaries:function(a){return this.spaces[a].primaries},getTransfer:function(a){return a===uo?zp:this.spaces[a].transfer},getLuminanceCoefficients:function(a,o=this.workingColorSpace){return a.fromArray(this.spaces[o].luminanceCoefficients)},define:function(a){Object.assign(this.spaces,a)},_getMatrix:function(a,o,l){return a.copy(this.spaces[o].toXYZ).multiply(this.spaces[l].fromXYZ)},_getDrawingBufferColorSpace:function(a){return this.spaces[a].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(a=this.workingColorSpace){return this.spaces[a].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return e.define({[Qi]:{primaries:t,whitePoint:i,transfer:zp,toXYZ:kM,fromXYZ:BM,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Jn},outputColorSpaceConfig:{drawingBufferColorSpace:Jn}},[Jn]:{primaries:t,whitePoint:i,transfer:un,toXYZ:kM,fromXYZ:BM,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Jn}}}),e}const He=TN();function Sr(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function Fc(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}let lc;class AN{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{lc===void 0&&(lc=th("canvas")),lc.width=t.width,lc.height=t.height;const i=lc.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=lc}return n.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const n=th("canvas");n.width=t.width,n.height=t.height;const i=n.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const a=i.getImageData(0,0,t.width,t.height),o=a.data;for(let l=0;l0&&(i.userData=this.userData),n||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==T3)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Da:t.x=t.x-Math.floor(t.x);break;case mo:t.x=t.x<0?0:1;break;case kp:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Da:t.y=t.y-Math.floor(t.y);break;case mo:t.y=t.y<0?0:1;break;case kp:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ci.DEFAULT_IMAGE=null;ci.DEFAULT_MAPPING=T3;ci.DEFAULT_ANISOTROPY=1;class tn{constructor(t=0,n=0,i=0,a=1){tn.prototype.isVector4=!0,this.x=t,this.y=n,this.z=i,this.w=a}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,n,i,a){return this.x=t,this.y=n,this.z=i,this.w=a,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this.w=t.w+n.w,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this.w+=t.w*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this.w=t.w-n.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const n=this.x,i=this.y,a=this.z,o=this.w,l=t.elements;return this.x=l[0]*n+l[4]*i+l[8]*a+l[12]*o,this.y=l[1]*n+l[5]*i+l[9]*a+l[13]*o,this.z=l[2]*n+l[6]*i+l[10]*a+l[14]*o,this.w=l[3]*n+l[7]*i+l[11]*a+l[15]*o,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const n=Math.sqrt(1-t.w*t.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/n,this.y=t.y/n,this.z=t.z/n),this}setAxisAngleFromRotationMatrix(t){let n,i,a,o;const h=t.elements,d=h[0],p=h[4],m=h[8],b=h[1],_=h[5],x=h[9],M=h[2],S=h[6],y=h[10];if(Math.abs(p-b)<.01&&Math.abs(m-M)<.01&&Math.abs(x-S)<.01){if(Math.abs(p+b)<.1&&Math.abs(m+M)<.1&&Math.abs(x+S)<.1&&Math.abs(d+_+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(d+1)/2,A=(_+1)/2,U=(y+1)/2,O=(p+b)/4,P=(m+M)/4,F=(x+S)/4;return w>A&&w>U?w<.01?(i=0,a=.707106781,o=.707106781):(i=Math.sqrt(w),a=O/i,o=P/i):A>U?A<.01?(i=.707106781,a=0,o=.707106781):(a=Math.sqrt(A),i=O/a,o=F/a):U<.01?(i=.707106781,a=.707106781,o=0):(o=Math.sqrt(U),i=P/o,a=F/o),this.set(i,a,o,n),this}let E=Math.sqrt((S-x)*(S-x)+(m-M)*(m-M)+(b-p)*(b-p));return Math.abs(E)<.001&&(E=1),this.x=(S-x)/E,this.y=(m-M)/E,this.z=(b-p)/E,this.w=Math.acos((d+_+y-1)/2),this}setFromMatrixPosition(t){const n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,n){return this.x=Fe(this.x,t.x,n.x),this.y=Fe(this.y,t.y,n.y),this.z=Fe(this.z,t.z,n.z),this.w=Fe(this.w,t.w,n.w),this}clampScalar(t,n){return this.x=Fe(this.x,t,n),this.y=Fe(this.y,t,n),this.z=Fe(this.z,t,n),this.w=Fe(this.w,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,t,n))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this.w+=(t.w-this.w)*n,this}lerpVectors(t,n,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this.z=t.z+(n.z-t.z)*i,this.w=t.w+(n.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this.w=t[n+3],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t[n+3]=this.w,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this.w=t.getW(n),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 RN extends Al{constructor(t=1,n=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=n,this.depth=1,this.scissor=new tn(0,0,t,n),this.scissorTest=!1,this.viewport=new tn(0,0,t,n);const a={width:t,height:n,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:As,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const o=new ci(a,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);o.flipY=!1,o.generateMipmaps=i.generateMipmaps,o.internalFormat=i.internalFormat,this.textures=[];const l=i.count;for(let u=0;u=0?1:-1,w=1-y*y;if(w>Number.EPSILON){const U=Math.sqrt(w),O=Math.atan2(U,y*E);S=Math.sin(S*O)/U,u=Math.sin(u*O)/U}const A=u*E;if(h=h*S+b*A,d=d*S+_*A,p=p*S+x*A,m=m*S+M*A,S===1-u){const U=1/Math.sqrt(h*h+d*d+p*p+m*m);h*=U,d*=U,p*=U,m*=U}}t[n]=h,t[n+1]=d,t[n+2]=p,t[n+3]=m}static multiplyQuaternionsFlat(t,n,i,a,o,l){const u=i[a],h=i[a+1],d=i[a+2],p=i[a+3],m=o[l],b=o[l+1],_=o[l+2],x=o[l+3];return t[n]=u*x+p*m+h*_-d*b,t[n+1]=h*x+p*b+d*m-u*_,t[n+2]=d*x+p*_+u*b-h*m,t[n+3]=p*x-u*m-h*b-d*_,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,n,i,a){return this._x=t,this._y=n,this._z=i,this._w=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,n=!0){const i=t._x,a=t._y,o=t._z,l=t._order,u=Math.cos,h=Math.sin,d=u(i/2),p=u(a/2),m=u(o/2),b=h(i/2),_=h(a/2),x=h(o/2);switch(l){case"XYZ":this._x=b*p*m+d*_*x,this._y=d*_*m-b*p*x,this._z=d*p*x+b*_*m,this._w=d*p*m-b*_*x;break;case"YXZ":this._x=b*p*m+d*_*x,this._y=d*_*m-b*p*x,this._z=d*p*x-b*_*m,this._w=d*p*m+b*_*x;break;case"ZXY":this._x=b*p*m-d*_*x,this._y=d*_*m+b*p*x,this._z=d*p*x+b*_*m,this._w=d*p*m-b*_*x;break;case"ZYX":this._x=b*p*m-d*_*x,this._y=d*_*m+b*p*x,this._z=d*p*x-b*_*m,this._w=d*p*m+b*_*x;break;case"YZX":this._x=b*p*m+d*_*x,this._y=d*_*m+b*p*x,this._z=d*p*x-b*_*m,this._w=d*p*m-b*_*x;break;case"XZY":this._x=b*p*m-d*_*x,this._y=d*_*m-b*p*x,this._z=d*p*x+b*_*m,this._w=d*p*m+b*_*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+l)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const i=n/2,a=Math.sin(i);return this._x=t.x*a,this._y=t.y*a,this._z=t.z*a,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,i=n[0],a=n[4],o=n[8],l=n[1],u=n[5],h=n[9],d=n[2],p=n[6],m=n[10],b=i+u+m;if(b>0){const _=.5/Math.sqrt(b+1);this._w=.25/_,this._x=(p-h)*_,this._y=(o-d)*_,this._z=(l-a)*_}else if(i>u&&i>m){const _=2*Math.sqrt(1+i-u-m);this._w=(p-h)/_,this._x=.25*_,this._y=(a+l)/_,this._z=(o+d)/_}else if(u>m){const _=2*Math.sqrt(1+u-i-m);this._w=(o-d)/_,this._x=(a+l)/_,this._y=.25*_,this._z=(h+p)/_}else{const _=2*Math.sqrt(1+m-i-u);this._w=(l-a)/_,this._x=(o+d)/_,this._y=(h+p)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(t,n){let i=t.dot(n)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Fe(this.dot(t),-1,1)))}rotateTowards(t,n){const i=this.angleTo(t);if(i===0)return this;const a=Math.min(1,n/i);return this.slerp(t,a),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,n){const i=t._x,a=t._y,o=t._z,l=t._w,u=n._x,h=n._y,d=n._z,p=n._w;return this._x=i*p+l*u+a*d-o*h,this._y=a*p+l*h+o*u-i*d,this._z=o*p+l*d+i*h-a*u,this._w=l*p-i*u-a*h-o*d,this._onChangeCallback(),this}slerp(t,n){if(n===0)return this;if(n===1)return this.copy(t);const i=this._x,a=this._y,o=this._z,l=this._w;let u=l*t._w+i*t._x+a*t._y+o*t._z;if(u<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,u=-u):this.copy(t),u>=1)return this._w=l,this._x=i,this._y=a,this._z=o,this;const h=1-u*u;if(h<=Number.EPSILON){const _=1-n;return this._w=_*l+n*this._w,this._x=_*i+n*this._x,this._y=_*a+n*this._y,this._z=_*o+n*this._z,this.normalize(),this}const d=Math.sqrt(h),p=Math.atan2(d,u),m=Math.sin((1-n)*p)/d,b=Math.sin(n*p)/d;return this._w=l*m+this._w*b,this._x=i*m+this._x*b,this._y=a*m+this._y*b,this._z=o*m+this._z*b,this._onChangeCallback(),this}slerpQuaternions(t,n,i){return this.copy(t).slerp(n,i)}random(){const t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),a=Math.sqrt(1-i),o=Math.sqrt(i);return this.set(a*Math.sin(t),a*Math.cos(t),o*Math.sin(n),o*Math.cos(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,n=0){return this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t}fromBufferAttribute(t,n){return this._x=t.getX(n),this._y=t.getY(n),this._z=t.getZ(n),this._w=t.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class G{constructor(t=0,n=0,i=0){G.prototype.isVector3=!0,this.x=t,this.y=n,this.z=i}set(t,n,i){return i===void 0&&(i=this.z),this.x=t,this.y=n,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this}applyEuler(t){return this.applyQuaternion(zM.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(zM.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,i=this.y,a=this.z,o=t.elements;return this.x=o[0]*n+o[3]*i+o[6]*a,this.y=o[1]*n+o[4]*i+o[7]*a,this.z=o[2]*n+o[5]*i+o[8]*a,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,i=this.y,a=this.z,o=t.elements,l=1/(o[3]*n+o[7]*i+o[11]*a+o[15]);return this.x=(o[0]*n+o[4]*i+o[8]*a+o[12])*l,this.y=(o[1]*n+o[5]*i+o[9]*a+o[13])*l,this.z=(o[2]*n+o[6]*i+o[10]*a+o[14])*l,this}applyQuaternion(t){const n=this.x,i=this.y,a=this.z,o=t.x,l=t.y,u=t.z,h=t.w,d=2*(l*a-u*i),p=2*(u*n-o*a),m=2*(o*i-l*n);return this.x=n+h*d+l*m-u*p,this.y=i+h*p+u*d-o*m,this.z=a+h*m+o*p-l*d,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const n=this.x,i=this.y,a=this.z,o=t.elements;return this.x=o[0]*n+o[4]*i+o[8]*a,this.y=o[1]*n+o[5]*i+o[9]*a,this.z=o[2]*n+o[6]*i+o[10]*a,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,n){return this.x=Fe(this.x,t.x,n.x),this.y=Fe(this.y,t.y,n.y),this.z=Fe(this.z,t.z,n.z),this}clampScalar(t,n){return this.x=Fe(this.x,t,n),this.y=Fe(this.y,t,n),this.z=Fe(this.z,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,t,n))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this}lerpVectors(t,n,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this.z=t.z+(n.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,n){const i=t.x,a=t.y,o=t.z,l=n.x,u=n.y,h=n.z;return this.x=a*h-o*u,this.y=o*l-i*h,this.z=i*u-a*l,this}projectOnVector(t){const n=t.lengthSq();if(n===0)return this.set(0,0,0);const i=t.dot(this)/n;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Z0.copy(this).projectOnVector(t),this.sub(Z0)}reflect(t){return this.sub(Z0.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(t)/n;return Math.acos(Fe(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,i=this.y-t.y,a=this.z-t.z;return n*n+i*i+a*a}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,n,i){const a=Math.sin(n)*t;return this.x=a*Math.sin(i),this.y=Math.cos(n)*t,this.z=a*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,n,i){return this.x=t*Math.sin(n),this.y=i,this.z=t*Math.cos(n),this}setFromMatrixPosition(t){const n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(t){const n=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),a=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=i,this.z=a,this}setFromMatrixColumn(t,n){return this.fromArray(t.elements,n*4)}setFromMatrix3Column(t,n){return this.fromArray(t.elements,n*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,n=Math.random()*2-1,i=Math.sqrt(1-n*n);return this.x=i*Math.cos(t),this.y=n,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Z0=new G,zM=new cs;class ls{constructor(t=new G(1/0,1/0,1/0),n=new G(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=n}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromArray(t){this.makeEmpty();for(let n=0,i=t.length;n=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,sa),sa.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let n,i;return t.normal.x>0?(n=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(n=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(n+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(n+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),n<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(_f),Od.subVectors(this.max,_f),cc.subVectors(t.a,_f),uc.subVectors(t.b,_f),fc.subVectors(t.c,_f),Jr.subVectors(uc,cc),$r.subVectors(fc,uc),Xo.subVectors(cc,fc);let n=[0,-Jr.z,Jr.y,0,-$r.z,$r.y,0,-Xo.z,Xo.y,Jr.z,0,-Jr.x,$r.z,0,-$r.x,Xo.z,0,-Xo.x,-Jr.y,Jr.x,0,-$r.y,$r.x,0,-Xo.y,Xo.x,0];return!Q0(n,cc,uc,fc,Od)||(n=[1,0,0,0,1,0,0,0,1],!Q0(n,cc,uc,fc,Od))?!1:(Fd.crossVectors(Jr,$r),n=[Fd.x,Fd.y,Fd.z],Q0(n,cc,uc,fc,Od))}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,sa).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(sa).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ur[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ur[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ur[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ur[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ur[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ur[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ur[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ur[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ur),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ur=[new G,new G,new G,new G,new G,new G,new G,new G],sa=new G,Ud=new ls,cc=new G,uc=new G,fc=new G,Jr=new G,$r=new G,Xo=new G,_f=new G,Od=new G,Fd=new G,qo=new G;function Q0(e,t,n,i,a){for(let o=0,l=e.length-3;o<=l;o+=3){qo.fromArray(e,o);const u=a.x*Math.abs(qo.x)+a.y*Math.abs(qo.y)+a.z*Math.abs(qo.z),h=t.dot(qo),d=n.dot(qo),p=i.dot(qo);if(Math.max(-Math.max(h,d,p),Math.min(h,d,p))>u)return!1}return!0}const DN=new ls,yf=new G,J0=new G;class ka{constructor(t=new G,n=-1){this.isSphere=!0,this.center=t,this.radius=n}set(t,n){return this.center.copy(t),this.radius=n,this}setFromPoints(t,n){const i=this.center;n!==void 0?i.copy(n):DN.setFromPoints(t).getCenter(i);let a=0;for(let o=0,l=t.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;yf.subVectors(t,this.center);const n=yf.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),a=(i-this.radius)*.5;this.center.addScaledVector(yf,a/i),this.radius+=a}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(J0.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(yf.copy(t.center).add(J0)),this.expandByPoint(yf.copy(t.center).sub(J0))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const fr=new G,$0=new G,Id=new G,to=new G,tb=new G,kd=new G,eb=new G;class om{constructor(t=new G,n=new G(0,0,-1)){this.origin=t,this.direction=n}set(t,n){return this.origin.copy(t),this.direction.copy(n),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,n){return n.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,fr)),this}closestPointToPoint(t,n){n.subVectors(t,this.origin);const i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const n=fr.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):(fr.copy(this.origin).addScaledVector(this.direction,n),fr.distanceToSquared(t))}distanceSqToSegment(t,n,i,a){$0.copy(t).add(n).multiplyScalar(.5),Id.copy(n).sub(t).normalize(),to.copy(this.origin).sub($0);const o=t.distanceTo(n)*.5,l=-this.direction.dot(Id),u=to.dot(this.direction),h=-to.dot(Id),d=to.lengthSq(),p=Math.abs(1-l*l);let m,b,_,x;if(p>0)if(m=l*h-u,b=l*u-h,x=o*p,m>=0)if(b>=-x)if(b<=x){const M=1/p;m*=M,b*=M,_=m*(m+l*b+2*u)+b*(l*m+b+2*h)+d}else b=o,m=Math.max(0,-(l*b+u)),_=-m*m+b*(b+2*h)+d;else b=-o,m=Math.max(0,-(l*b+u)),_=-m*m+b*(b+2*h)+d;else b<=-x?(m=Math.max(0,-(-l*o+u)),b=m>0?-o:Math.min(Math.max(-o,-h),o),_=-m*m+b*(b+2*h)+d):b<=x?(m=0,b=Math.min(Math.max(-o,-h),o),_=b*(b+2*h)+d):(m=Math.max(0,-(l*o+u)),b=m>0?o:Math.min(Math.max(-o,-h),o),_=-m*m+b*(b+2*h)+d);else b=l>0?-o:o,m=Math.max(0,-(l*b+u)),_=-m*m+b*(b+2*h)+d;return i&&i.copy(this.origin).addScaledVector(this.direction,m),a&&a.copy($0).addScaledVector(Id,b),_}intersectSphere(t,n){fr.subVectors(t.center,this.origin);const i=fr.dot(this.direction),a=fr.dot(fr)-i*i,o=t.radius*t.radius;if(a>o)return null;const l=Math.sqrt(o-a),u=i-l,h=i+l;return h<0?null:u<0?this.at(h,n):this.at(u,n)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const n=t.normal.dot(this.direction);if(n===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/n;return i>=0?i:null}intersectPlane(t,n){const i=this.distanceToPlane(t);return i===null?null:this.at(i,n)}intersectsPlane(t){const n=t.distanceToPoint(this.origin);return n===0||t.normal.dot(this.direction)*n<0}intersectBox(t,n){let i,a,o,l,u,h;const d=1/this.direction.x,p=1/this.direction.y,m=1/this.direction.z,b=this.origin;return d>=0?(i=(t.min.x-b.x)*d,a=(t.max.x-b.x)*d):(i=(t.max.x-b.x)*d,a=(t.min.x-b.x)*d),p>=0?(o=(t.min.y-b.y)*p,l=(t.max.y-b.y)*p):(o=(t.max.y-b.y)*p,l=(t.min.y-b.y)*p),i>l||o>a||((o>i||isNaN(i))&&(i=o),(l=0?(u=(t.min.z-b.z)*m,h=(t.max.z-b.z)*m):(u=(t.max.z-b.z)*m,h=(t.min.z-b.z)*m),i>h||u>a)||((u>i||i!==i)&&(i=u),(h=0?i:a,n)}intersectsBox(t){return this.intersectBox(t,fr)!==null}intersectTriangle(t,n,i,a,o){tb.subVectors(n,t),kd.subVectors(i,t),eb.crossVectors(tb,kd);let l=this.direction.dot(eb),u;if(l>0){if(a)return null;u=1}else if(l<0)u=-1,l=-l;else return null;to.subVectors(this.origin,t);const h=u*this.direction.dot(kd.crossVectors(to,kd));if(h<0)return null;const d=u*this.direction.dot(tb.cross(to));if(d<0||h+d>l)return null;const p=-u*to.dot(eb);return p<0?null:this.at(p/l,o)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ee{constructor(t,n,i,a,o,l,u,h,d,p,m,b,_,x,M,S){Ee.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,i,a,o,l,u,h,d,p,m,b,_,x,M,S)}set(t,n,i,a,o,l,u,h,d,p,m,b,_,x,M,S){const y=this.elements;return y[0]=t,y[4]=n,y[8]=i,y[12]=a,y[1]=o,y[5]=l,y[9]=u,y[13]=h,y[2]=d,y[6]=p,y[10]=m,y[14]=b,y[3]=_,y[7]=x,y[11]=M,y[15]=S,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ee().fromArray(this.elements)}copy(t){const n=this.elements,i=t.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(t){const n=this.elements,i=t.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this}setFromMatrix3(t){const n=t.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(t,n,i){return t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,n,i){return this.set(t.x,n.x,i.x,0,t.y,n.y,i.y,0,t.z,n.z,i.z,0,0,0,0,1),this}extractRotation(t){const n=this.elements,i=t.elements,a=1/hc.setFromMatrixColumn(t,0).length(),o=1/hc.setFromMatrixColumn(t,1).length(),l=1/hc.setFromMatrixColumn(t,2).length();return n[0]=i[0]*a,n[1]=i[1]*a,n[2]=i[2]*a,n[3]=0,n[4]=i[4]*o,n[5]=i[5]*o,n[6]=i[6]*o,n[7]=0,n[8]=i[8]*l,n[9]=i[9]*l,n[10]=i[10]*l,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(t){const n=this.elements,i=t.x,a=t.y,o=t.z,l=Math.cos(i),u=Math.sin(i),h=Math.cos(a),d=Math.sin(a),p=Math.cos(o),m=Math.sin(o);if(t.order==="XYZ"){const b=l*p,_=l*m,x=u*p,M=u*m;n[0]=h*p,n[4]=-h*m,n[8]=d,n[1]=_+x*d,n[5]=b-M*d,n[9]=-u*h,n[2]=M-b*d,n[6]=x+_*d,n[10]=l*h}else if(t.order==="YXZ"){const b=h*p,_=h*m,x=d*p,M=d*m;n[0]=b+M*u,n[4]=x*u-_,n[8]=l*d,n[1]=l*m,n[5]=l*p,n[9]=-u,n[2]=_*u-x,n[6]=M+b*u,n[10]=l*h}else if(t.order==="ZXY"){const b=h*p,_=h*m,x=d*p,M=d*m;n[0]=b-M*u,n[4]=-l*m,n[8]=x+_*u,n[1]=_+x*u,n[5]=l*p,n[9]=M-b*u,n[2]=-l*d,n[6]=u,n[10]=l*h}else if(t.order==="ZYX"){const b=l*p,_=l*m,x=u*p,M=u*m;n[0]=h*p,n[4]=x*d-_,n[8]=b*d+M,n[1]=h*m,n[5]=M*d+b,n[9]=_*d-x,n[2]=-d,n[6]=u*h,n[10]=l*h}else if(t.order==="YZX"){const b=l*h,_=l*d,x=u*h,M=u*d;n[0]=h*p,n[4]=M-b*m,n[8]=x*m+_,n[1]=m,n[5]=l*p,n[9]=-u*p,n[2]=-d*p,n[6]=_*m+x,n[10]=b-M*m}else if(t.order==="XZY"){const b=l*h,_=l*d,x=u*h,M=u*d;n[0]=h*p,n[4]=-m,n[8]=d*p,n[1]=b*m+M,n[5]=l*p,n[9]=_*m-x,n[2]=x*m-_,n[6]=u*p,n[10]=M*m+b}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(LN,t,NN)}lookAt(t,n,i){const a=this.elements;return ys.subVectors(t,n),ys.lengthSq()===0&&(ys.z=1),ys.normalize(),eo.crossVectors(i,ys),eo.lengthSq()===0&&(Math.abs(i.z)===1?ys.x+=1e-4:ys.z+=1e-4,ys.normalize(),eo.crossVectors(i,ys)),eo.normalize(),Bd.crossVectors(ys,eo),a[0]=eo.x,a[4]=Bd.x,a[8]=ys.x,a[1]=eo.y,a[5]=Bd.y,a[9]=ys.y,a[2]=eo.z,a[6]=Bd.z,a[10]=ys.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const i=t.elements,a=n.elements,o=this.elements,l=i[0],u=i[4],h=i[8],d=i[12],p=i[1],m=i[5],b=i[9],_=i[13],x=i[2],M=i[6],S=i[10],y=i[14],E=i[3],w=i[7],A=i[11],U=i[15],O=a[0],P=a[4],F=a[8],C=a[12],R=a[1],I=a[5],Z=a[9],nt=a[13],ct=a[2],ft=a[6],z=a[10],J=a[14],q=a[3],yt=a[7],At=a[11],B=a[15];return o[0]=l*O+u*R+h*ct+d*q,o[4]=l*P+u*I+h*ft+d*yt,o[8]=l*F+u*Z+h*z+d*At,o[12]=l*C+u*nt+h*J+d*B,o[1]=p*O+m*R+b*ct+_*q,o[5]=p*P+m*I+b*ft+_*yt,o[9]=p*F+m*Z+b*z+_*At,o[13]=p*C+m*nt+b*J+_*B,o[2]=x*O+M*R+S*ct+y*q,o[6]=x*P+M*I+S*ft+y*yt,o[10]=x*F+M*Z+S*z+y*At,o[14]=x*C+M*nt+S*J+y*B,o[3]=E*O+w*R+A*ct+U*q,o[7]=E*P+w*I+A*ft+U*yt,o[11]=E*F+w*Z+A*z+U*At,o[15]=E*C+w*nt+A*J+U*B,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this}determinant(){const t=this.elements,n=t[0],i=t[4],a=t[8],o=t[12],l=t[1],u=t[5],h=t[9],d=t[13],p=t[2],m=t[6],b=t[10],_=t[14],x=t[3],M=t[7],S=t[11],y=t[15];return x*(+o*h*m-a*d*m-o*u*b+i*d*b+a*u*_-i*h*_)+M*(+n*h*_-n*d*b+o*l*b-a*l*_+a*d*p-o*h*p)+S*(+n*d*m-n*u*_-o*l*m+i*l*_+o*u*p-i*d*p)+y*(-a*u*p-n*h*m+n*u*b+a*l*m-i*l*b+i*h*p)}transpose(){const t=this.elements;let n;return n=t[1],t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this}setPosition(t,n,i){const a=this.elements;return t.isVector3?(a[12]=t.x,a[13]=t.y,a[14]=t.z):(a[12]=t,a[13]=n,a[14]=i),this}invert(){const t=this.elements,n=t[0],i=t[1],a=t[2],o=t[3],l=t[4],u=t[5],h=t[6],d=t[7],p=t[8],m=t[9],b=t[10],_=t[11],x=t[12],M=t[13],S=t[14],y=t[15],E=m*S*d-M*b*d+M*h*_-u*S*_-m*h*y+u*b*y,w=x*b*d-p*S*d-x*h*_+l*S*_+p*h*y-l*b*y,A=p*M*d-x*m*d+x*u*_-l*M*_-p*u*y+l*m*y,U=x*m*h-p*M*h-x*u*b+l*M*b+p*u*S-l*m*S,O=n*E+i*w+a*A+o*U;if(O===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/O;return t[0]=E*P,t[1]=(M*b*o-m*S*o-M*a*_+i*S*_+m*a*y-i*b*y)*P,t[2]=(u*S*o-M*h*o+M*a*d-i*S*d-u*a*y+i*h*y)*P,t[3]=(m*h*o-u*b*o-m*a*d+i*b*d+u*a*_-i*h*_)*P,t[4]=w*P,t[5]=(p*S*o-x*b*o+x*a*_-n*S*_-p*a*y+n*b*y)*P,t[6]=(x*h*o-l*S*o-x*a*d+n*S*d+l*a*y-n*h*y)*P,t[7]=(l*b*o-p*h*o+p*a*d-n*b*d-l*a*_+n*h*_)*P,t[8]=A*P,t[9]=(x*m*o-p*M*o-x*i*_+n*M*_+p*i*y-n*m*y)*P,t[10]=(l*M*o-x*u*o+x*i*d-n*M*d-l*i*y+n*u*y)*P,t[11]=(p*u*o-l*m*o-p*i*d+n*m*d+l*i*_-n*u*_)*P,t[12]=U*P,t[13]=(p*M*a-x*m*a+x*i*b-n*M*b-p*i*S+n*m*S)*P,t[14]=(x*u*a-l*M*a-x*i*h+n*M*h+l*i*S-n*u*S)*P,t[15]=(l*m*a-p*u*a+p*i*h-n*m*h-l*i*b+n*u*b)*P,this}scale(t){const n=this.elements,i=t.x,a=t.y,o=t.z;return n[0]*=i,n[4]*=a,n[8]*=o,n[1]*=i,n[5]*=a,n[9]*=o,n[2]*=i,n[6]*=a,n[10]*=o,n[3]*=i,n[7]*=a,n[11]*=o,this}getMaxScaleOnAxis(){const t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],a=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,i,a))}makeTranslation(t,n,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,n,0,0,1,i,0,0,0,1),this}makeRotationX(t){const n=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(t){const n=Math.cos(t),i=Math.sin(t);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(t){const n=Math.cos(t),i=Math.sin(t);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,n){const i=Math.cos(n),a=Math.sin(n),o=1-i,l=t.x,u=t.y,h=t.z,d=o*l,p=o*u;return this.set(d*l+i,d*u-a*h,d*h+a*u,0,d*u+a*h,p*u+i,p*h-a*l,0,d*h-a*u,p*h+a*l,o*h*h+i,0,0,0,0,1),this}makeScale(t,n,i){return this.set(t,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,n,i,a,o,l){return this.set(1,i,o,0,t,1,l,0,n,a,1,0,0,0,0,1),this}compose(t,n,i){const a=this.elements,o=n._x,l=n._y,u=n._z,h=n._w,d=o+o,p=l+l,m=u+u,b=o*d,_=o*p,x=o*m,M=l*p,S=l*m,y=u*m,E=h*d,w=h*p,A=h*m,U=i.x,O=i.y,P=i.z;return a[0]=(1-(M+y))*U,a[1]=(_+A)*U,a[2]=(x-w)*U,a[3]=0,a[4]=(_-A)*O,a[5]=(1-(b+y))*O,a[6]=(S+E)*O,a[7]=0,a[8]=(x+w)*P,a[9]=(S-E)*P,a[10]=(1-(b+M))*P,a[11]=0,a[12]=t.x,a[13]=t.y,a[14]=t.z,a[15]=1,this}decompose(t,n,i){const a=this.elements;let o=hc.set(a[0],a[1],a[2]).length();const l=hc.set(a[4],a[5],a[6]).length(),u=hc.set(a[8],a[9],a[10]).length();this.determinant()<0&&(o=-o),t.x=a[12],t.y=a[13],t.z=a[14],aa.copy(this);const d=1/o,p=1/l,m=1/u;return aa.elements[0]*=d,aa.elements[1]*=d,aa.elements[2]*=d,aa.elements[4]*=p,aa.elements[5]*=p,aa.elements[6]*=p,aa.elements[8]*=m,aa.elements[9]*=m,aa.elements[10]*=m,n.setFromRotationMatrix(aa),i.x=o,i.y=l,i.z=u,this}makePerspective(t,n,i,a,o,l,u=xr){const h=this.elements,d=2*o/(n-t),p=2*o/(i-a),m=(n+t)/(n-t),b=(i+a)/(i-a);let _,x;if(u===xr)_=-(l+o)/(l-o),x=-2*l*o/(l-o);else if(u===Vp)_=-l/(l-o),x=-l*o/(l-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+u);return h[0]=d,h[4]=0,h[8]=m,h[12]=0,h[1]=0,h[5]=p,h[9]=b,h[13]=0,h[2]=0,h[6]=0,h[10]=_,h[14]=x,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(t,n,i,a,o,l,u=xr){const h=this.elements,d=1/(n-t),p=1/(i-a),m=1/(l-o),b=(n+t)*d,_=(i+a)*p;let x,M;if(u===xr)x=(l+o)*m,M=-2*m;else if(u===Vp)x=o*m,M=-1*m;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+u);return h[0]=2*d,h[4]=0,h[8]=0,h[12]=-b,h[1]=0,h[5]=2*p,h[9]=0,h[13]=-_,h[2]=0,h[6]=0,h[10]=M,h[14]=-x,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(t){const n=this.elements,i=t.elements;for(let a=0;a<16;a++)if(n[a]!==i[a])return!1;return!0}fromArray(t,n=0){for(let i=0;i<16;i++)this.elements[i]=t[i+n];return this}toArray(t=[],n=0){const i=this.elements;return t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3],t[n+4]=i[4],t[n+5]=i[5],t[n+6]=i[6],t[n+7]=i[7],t[n+8]=i[8],t[n+9]=i[9],t[n+10]=i[10],t[n+11]=i[11],t[n+12]=i[12],t[n+13]=i[13],t[n+14]=i[14],t[n+15]=i[15],t}}const hc=new G,aa=new Ee,LN=new G(0,0,0),NN=new G(1,1,1),eo=new G,Bd=new G,ys=new G,VM=new Ee,GM=new cs;class Oa{constructor(t=0,n=0,i=0,a=Oa.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=i,this._order=a}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,n,i,a=this._order){return this._x=t,this._y=n,this._z=i,this._order=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,n=this._order,i=!0){const a=t.elements,o=a[0],l=a[4],u=a[8],h=a[1],d=a[5],p=a[9],m=a[2],b=a[6],_=a[10];switch(n){case"XYZ":this._y=Math.asin(Fe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-p,_),this._z=Math.atan2(-l,o)):(this._x=Math.atan2(b,d),this._z=0);break;case"YXZ":this._x=Math.asin(-Fe(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(u,_),this._z=Math.atan2(h,d)):(this._y=Math.atan2(-m,o),this._z=0);break;case"ZXY":this._x=Math.asin(Fe(b,-1,1)),Math.abs(b)<.9999999?(this._y=Math.atan2(-m,_),this._z=Math.atan2(-l,d)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-Fe(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(b,_),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-l,d));break;case"YZX":this._z=Math.asin(Fe(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-p,d),this._y=Math.atan2(-m,o)):(this._x=0,this._y=Math.atan2(u,_));break;case"XZY":this._z=Math.asin(-Fe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(b,d),this._y=Math.atan2(u,o)):(this._x=Math.atan2(-p,_),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,i){return VM.makeRotationFromQuaternion(t),this.setFromRotationMatrix(VM,n,i)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return GM.setFromEuler(this),this.setFromQuaternion(GM,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Oa.DEFAULT_ORDER="XYZ";class z3{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let n=0;n1){for(let i=0;i0&&(a.userData=this.userData),a.layers=this.layers.mask,a.matrix=this.matrix.toArray(),a.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(a.matrixAutoUpdate=!1),this.isInstancedMesh&&(a.type="InstancedMesh",a.count=this.count,a.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(a.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(a.type="BatchedMesh",a.perObjectFrustumCulled=this.perObjectFrustumCulled,a.sortObjects=this.sortObjects,a.drawRanges=this._drawRanges,a.reservedRanges=this._reservedRanges,a.visibility=this._visibility,a.active=this._active,a.bounds=this._bounds.map(u=>({boxInitialized:u.boxInitialized,boxMin:u.box.min.toArray(),boxMax:u.box.max.toArray(),sphereInitialized:u.sphereInitialized,sphereRadius:u.sphere.radius,sphereCenter:u.sphere.center.toArray()})),a.maxInstanceCount=this._maxInstanceCount,a.maxVertexCount=this._maxVertexCount,a.maxIndexCount=this._maxIndexCount,a.geometryInitialized=this._geometryInitialized,a.geometryCount=this._geometryCount,a.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(a.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(a.boundingSphere={center:a.boundingSphere.center.toArray(),radius:a.boundingSphere.radius}),this.boundingBox!==null&&(a.boundingBox={min:a.boundingBox.min.toArray(),max:a.boundingBox.max.toArray()}));function o(u,h){return u[h.uuid]===void 0&&(u[h.uuid]=h.toJSON(t)),h.uuid}if(this.isScene)this.background&&(this.background.isColor?a.background=this.background.toJSON():this.background.isTexture&&(a.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(a.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){a.geometry=o(t.geometries,this.geometry);const u=this.geometry.parameters;if(u!==void 0&&u.shapes!==void 0){const h=u.shapes;if(Array.isArray(h))for(let d=0,p=h.length;d0){a.children=[];for(let u=0;u0){a.animations=[];for(let u=0;u0&&(i.geometries=u),h.length>0&&(i.materials=h),d.length>0&&(i.textures=d),p.length>0&&(i.images=p),m.length>0&&(i.shapes=m),b.length>0&&(i.skeletons=b),_.length>0&&(i.animations=_),x.length>0&&(i.nodes=x)}return i.object=a,i;function l(u){const h=[];for(const d in u){const p=u[d];delete p.metadata,h.push(p)}return h}}clone(t){return new this.constructor().copy(this,t)}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i0?a.multiplyScalar(1/Math.sqrt(o)):a.set(0,0,0)}static getBarycoord(t,n,i,a,o){ra.subVectors(a,n),dr.subVectors(i,n),ib.subVectors(t,n);const l=ra.dot(ra),u=ra.dot(dr),h=ra.dot(ib),d=dr.dot(dr),p=dr.dot(ib),m=l*d-u*u;if(m===0)return o.set(0,0,0),null;const b=1/m,_=(d*h-u*p)*b,x=(l*p-u*h)*b;return o.set(1-_-x,x,_)}static containsPoint(t,n,i,a){return this.getBarycoord(t,n,i,a,pr)===null?!1:pr.x>=0&&pr.y>=0&&pr.x+pr.y<=1}static getInterpolation(t,n,i,a,o,l,u,h){return this.getBarycoord(t,n,i,a,pr)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(o,pr.x),h.addScaledVector(l,pr.y),h.addScaledVector(u,pr.z),h)}static getInterpolatedAttribute(t,n,i,a,o,l){return ob.setScalar(0),lb.setScalar(0),cb.setScalar(0),ob.fromBufferAttribute(t,n),lb.fromBufferAttribute(t,i),cb.fromBufferAttribute(t,a),l.setScalar(0),l.addScaledVector(ob,o.x),l.addScaledVector(lb,o.y),l.addScaledVector(cb,o.z),l}static isFrontFacing(t,n,i,a){return ra.subVectors(i,n),dr.subVectors(t,n),ra.cross(dr).dot(a)<0}set(t,n,i){return this.a.copy(t),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(t,n,i,a){return this.a.copy(t[n]),this.b.copy(t[i]),this.c.copy(t[a]),this}setFromAttributeAndIndices(t,n,i,a){return this.a.fromBufferAttribute(t,n),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,a),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ra.subVectors(this.c,this.b),dr.subVectors(this.a,this.b),ra.cross(dr).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ua.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return ua.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,i,a,o){return ua.getInterpolation(t,this.a,this.b,this.c,n,i,a,o)}containsPoint(t){return ua.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ua.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,n){const i=this.a,a=this.b,o=this.c;let l,u;mc.subVectors(a,i),gc.subVectors(o,i),sb.subVectors(t,i);const h=mc.dot(sb),d=gc.dot(sb);if(h<=0&&d<=0)return n.copy(i);ab.subVectors(t,a);const p=mc.dot(ab),m=gc.dot(ab);if(p>=0&&m<=p)return n.copy(a);const b=h*m-p*d;if(b<=0&&h>=0&&p<=0)return l=h/(h-p),n.copy(i).addScaledVector(mc,l);rb.subVectors(t,o);const _=mc.dot(rb),x=gc.dot(rb);if(x>=0&&_<=x)return n.copy(o);const M=_*d-h*x;if(M<=0&&d>=0&&x<=0)return u=d/(d-x),n.copy(i).addScaledVector(gc,u);const S=p*x-_*m;if(S<=0&&m-p>=0&&_-x>=0)return YM.subVectors(o,a),u=(m-p)/(m-p+(_-x)),n.copy(a).addScaledVector(YM,u);const y=1/(S+M+b);return l=M*y,u=b*y,n.copy(i).addScaledVector(mc,l).addScaledVector(gc,u)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const V3={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},no={h:0,s:0,l:0},Vd={h:0,s:0,l:0};function ub(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}class be{constructor(t,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,n,i)}set(t,n,i){if(n===void 0&&i===void 0){const a=t;a&&a.isColor?this.copy(a):typeof a=="number"?this.setHex(a):typeof a=="string"&&this.setStyle(a)}else this.setRGB(t,n,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,n=Jn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,He.toWorkingColorSpace(this,n),this}setRGB(t,n,i,a=He.workingColorSpace){return this.r=t,this.g=n,this.b=i,He.toWorkingColorSpace(this,a),this}setHSL(t,n,i,a=He.workingColorSpace){if(t=$1(t,1),n=Fe(n,0,1),i=Fe(i,0,1),n===0)this.r=this.g=this.b=i;else{const o=i<=.5?i*(1+n):i+n-i*n,l=2*i-o;this.r=ub(l,o,t+1/3),this.g=ub(l,o,t),this.b=ub(l,o,t-1/3)}return He.toWorkingColorSpace(this,a),this}setStyle(t,n=Jn){function i(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let a;if(a=/^(\w+)\(([^\)]*)\)/.exec(t)){let o;const l=a[1],u=a[2];switch(l){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,n);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,n);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(a=/^\#([A-Fa-f\d]+)$/.exec(t)){const o=a[1],l=o.length;if(l===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,n);if(l===6)return this.setHex(parseInt(o,16),n);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,n);return this}setColorName(t,n=Jn){const i=V3[t.toLowerCase()];return i!==void 0?this.setHex(i,n):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Sr(t.r),this.g=Sr(t.g),this.b=Sr(t.b),this}copyLinearToSRGB(t){return this.r=Fc(t.r),this.g=Fc(t.g),this.b=Fc(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Jn){return He.fromWorkingColorSpace(Ni.copy(this),t),Math.round(Fe(Ni.r*255,0,255))*65536+Math.round(Fe(Ni.g*255,0,255))*256+Math.round(Fe(Ni.b*255,0,255))}getHexString(t=Jn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,n=He.workingColorSpace){He.fromWorkingColorSpace(Ni.copy(this),n);const i=Ni.r,a=Ni.g,o=Ni.b,l=Math.max(i,a,o),u=Math.min(i,a,o);let h,d;const p=(u+l)/2;if(u===l)h=0,d=0;else{const m=l-u;switch(d=p<=.5?m/(l+u):m/(2-l-u),l){case i:h=(a-o)/m+(a0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const n in t){const i=t[n];if(i===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const a=this[n];if(a===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}a&&a.isColor?a.set(i):a&&a.isVector3&&i&&i.isVector3?a.copy(i):this[n]=i}}toJSON(t){const n=t===void 0||typeof t=="string";n&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Uc&&(i.blending=this.blending),this.side!==Mr&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==ov&&(i.blendSrc=this.blendSrc),this.blendDst!==lv&&(i.blendDst=this.blendDst),this.blendEquation!==rl&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==zc&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==UM&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==oc&&(i.stencilFail=this.stencilFail),this.stencilZFail!==oc&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==oc&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function a(o){const l=[];for(const u in o){const h=o[u];delete h.metadata,l.push(h)}return l}if(n){const o=a(t.textures),l=a(t.images);o.length>0&&(i.textures=o),l.length>0&&(i.images=l)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const n=t.clippingPlanes;let i=null;if(n!==null){const a=n.length;i=new Array(a);for(let o=0;o!==a;++o)i[o]=n[o].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class _i extends Na{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new be(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 Oa,this.combine=M3,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Zn=new G,Gd=new Ae;let kN=0;class Zi{constructor(t,n,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:kN++}),this.name="",this.array=t,this.itemSize=n,this.count=t!==void 0?t.length/n:0,this.normalized=i,this.usage=Wv,this.updateRanges=[],this.gpuType=fa,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,n){this.updateRanges.push({start:t,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,n,i){t*=this.itemSize,i*=n.itemSize;for(let a=0,o=this.itemSize;an.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ls);const t=this.attributes.position,n=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new G(-1/0,-1/0,-1/0),new G(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),n)for(let i=0,a=n.length;i0&&(t.userData=this.userData),this.parameters!==void 0){const h=this.parameters;for(const d in h)h[d]!==void 0&&(t[d]=h[d]);return t}t.data={attributes:{}};const n=this.index;n!==null&&(t.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const i=this.attributes;for(const h in i){const d=i[h];t.data.attributes[h]=d.toJSON(t.data)}const a={};let o=!1;for(const h in this.morphAttributes){const d=this.morphAttributes[h],p=[];for(let m=0,b=d.length;m0&&(a[h]=p,o=!0)}o&&(t.data.morphAttributes=a,t.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(t.data.groups=JSON.parse(JSON.stringify(l)));const u=this.boundingSphere;return u!==null&&(t.data.boundingSphere={center:u.center.toArray(),radius:u.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(n));const a=t.attributes;for(const d in a){const p=a[d];this.setAttribute(d,p.clone(n))}const o=t.morphAttributes;for(const d in o){const p=[],m=o[d];for(let b=0,_=m.length;b<_;b++)p.push(m[b].clone(n));this.morphAttributes[d]=p}this.morphTargetsRelative=t.morphTargetsRelative;const l=t.groups;for(let d=0,p=l.length;d0){const a=n[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,l=a.length;o(t.far-t.near)**2))&&(KM.copy(o).invert(),Yo.copy(t.ray).applyMatrix4(KM),!(i.boundingBox!==null&&Yo.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,n,Yo)))}_computeIntersections(t,n,i){let a;const o=this.geometry,l=this.material,u=o.index,h=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,m=o.attributes.normal,b=o.groups,_=o.drawRange;if(u!==null)if(Array.isArray(l))for(let x=0,M=b.length;xn.far?null:{distance:d,point:Yd.clone(),object:e}}function Kd(e,t,n,i,a,o,l,u,h,d){e.getVertexPosition(u,jd),e.getVertexPosition(h,Wd),e.getVertexPosition(d,Xd);const p=zN(e,t,n,i,jd,Wd,Xd,QM);if(p){const m=new G;ua.getBarycoord(QM,jd,Wd,Xd,m),a&&(p.uv=ua.getInterpolatedAttribute(a,u,h,d,m,new Ae)),o&&(p.uv1=ua.getInterpolatedAttribute(o,u,h,d,m,new Ae)),l&&(p.normal=ua.getInterpolatedAttribute(l,u,h,d,m,new G),p.normal.dot(i.direction)>0&&p.normal.multiplyScalar(-1));const b={a:u,b:h,c:d,normal:new G,materialIndex:0};ua.getNormal(jd,Wd,Xd,b.normal),p.face=b,p.barycoord=m}return p}class xl extends Fi{constructor(t=1,n=1,i=1,a=1,o=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:n,depth:i,widthSegments:a,heightSegments:o,depthSegments:l};const u=this;a=Math.floor(a),o=Math.floor(o),l=Math.floor(l);const h=[],d=[],p=[],m=[];let b=0,_=0;x("z","y","x",-1,-1,i,n,t,l,o,0),x("z","y","x",1,-1,i,n,-t,l,o,1),x("x","z","y",1,1,t,i,n,a,l,2),x("x","z","y",1,-1,t,i,-n,a,l,3),x("x","y","z",1,-1,t,n,i,a,o,4),x("x","y","z",-1,-1,t,n,-i,a,o,5),this.setIndex(h),this.setAttribute("position",new Hn(d,3)),this.setAttribute("normal",new Hn(p,3)),this.setAttribute("uv",new Hn(m,2));function x(M,S,y,E,w,A,U,O,P,F,C){const R=A/P,I=U/F,Z=A/2,nt=U/2,ct=O/2,ft=P+1,z=F+1;let J=0,q=0;const yt=new G;for(let At=0;At0?1:-1,p.push(yt.x,yt.y,yt.z),m.push(et/P),m.push(1-At/F),J+=1}}for(let At=0;At0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const i={};for(const a in this.extensions)this.extensions[a]===!0&&(i[a]=!0);return Object.keys(i).length>0&&(n.extensions=i),n}}class W3 extends En{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ee,this.projectionMatrix=new Ee,this.projectionMatrixInverse=new Ee,this.coordinateSystem=xr}copy(t,n){return super.copy(t,n),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const io=new G,JM=new Ae,$M=new Ae;class Xi extends W3{constructor(t=50,n=1,i=.1,a=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=a,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,n){return super.copy(t,n),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const n=.5*this.getFilmHeight()/t;this.fov=Wc*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Vf*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Wc*2*Math.atan(Math.tan(Vf*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,n,i){io.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(io.x,io.y).multiplyScalar(-t/io.z),io.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(io.x,io.y).multiplyScalar(-t/io.z)}getViewSize(t,n){return this.getViewBounds(t,JM,$M),n.subVectors($M,JM)}setViewOffset(t,n,i,a,o,l){this.aspect=t/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=a,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let n=t*Math.tan(Vf*.5*this.fov)/this.zoom,i=2*n,a=this.aspect*i,o=-.5*a;const l=this.view;if(this.view!==null&&this.view.enabled){const h=l.fullWidth,d=l.fullHeight;o+=l.offsetX*a/h,n-=l.offsetY*i/d,a*=l.width/h,i*=l.height/d}const u=this.filmOffset;u!==0&&(o+=t*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+a,n,n-i,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const n=super.toJSON(t);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const vc=-90,_c=1;class WN extends En{constructor(t,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const a=new Xi(vc,_c,t,n);a.layers=this.layers,this.add(a);const o=new Xi(vc,_c,t,n);o.layers=this.layers,this.add(o);const l=new Xi(vc,_c,t,n);l.layers=this.layers,this.add(l);const u=new Xi(vc,_c,t,n);u.layers=this.layers,this.add(u);const h=new Xi(vc,_c,t,n);h.layers=this.layers,this.add(h);const d=new Xi(vc,_c,t,n);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const t=this.coordinateSystem,n=this.children.concat(),[i,a,o,l,u,h]=n;for(const d of n)this.remove(d);if(t===xr)i.up.set(0,1,0),i.lookAt(1,0,0),a.up.set(0,1,0),a.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),l.up.set(0,0,1),l.lookAt(0,-1,0),u.up.set(0,1,0),u.lookAt(0,0,1),h.up.set(0,1,0),h.lookAt(0,0,-1);else if(t===Vp)i.up.set(0,-1,0),i.lookAt(-1,0,0),a.up.set(0,-1,0),a.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),l.up.set(0,0,-1),l.lookAt(0,-1,0),u.up.set(0,-1,0),u.lookAt(0,0,1),h.up.set(0,-1,0),h.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const d of n)this.add(d),d.updateMatrixWorld()}update(t,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:a}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[o,l,u,h,d,p]=this.children,m=t.getRenderTarget(),b=t.getActiveCubeFace(),_=t.getActiveMipmapLevel(),x=t.xr.enabled;t.xr.enabled=!1;const M=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,a),t.render(n,o),t.setRenderTarget(i,1,a),t.render(n,l),t.setRenderTarget(i,2,a),t.render(n,u),t.setRenderTarget(i,3,a),t.render(n,h),t.setRenderTarget(i,4,a),t.render(n,d),i.texture.generateMipmaps=M,t.setRenderTarget(i,5,a),t.render(n,p),t.setRenderTarget(m,b,_),t.xr.enabled=x,i.texture.needsPMREMUpdate=!0}}class X3 extends ci{constructor(t,n,i,a,o,l,u,h,d,p){t=t!==void 0?t:[],n=n!==void 0?n:Vc,super(t,n,i,a,o,l,u,h,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class XN extends yl{constructor(t=1,n={}){super(t,t,n),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},a=[i,i,i,i,i,i];this.texture=new X3(a,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:As}fromEquirectangularTexture(t,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},a=new xl(5,5,5),o=new xo({name:"CubemapFromEquirect",uniforms:Xc(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Oi,blending:vo});o.uniforms.tEquirect.value=n;const l=new Oe(a,o),u=n.minFilter;return n.minFilter===yr&&(n.minFilter=As),new WN(1,10,this).update(t,l),n.minFilter=u,l.geometry.dispose(),l.material.dispose(),this}clear(t,n,i,a){const o=t.getRenderTarget();for(let l=0;l<6;l++)t.setRenderTarget(this,l),t.clear(n,i,a);t.setRenderTarget(o)}}class Wi extends En{constructor(){super(),this.isGroup=!0,this.type="Group"}}const qN={type:"move"};class db{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Wi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new G,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new G),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new G,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new G),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const n=this._hand;if(n)for(const i of t.hand.values())this._getHandJoint(n,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,n,i){let a=null,o=null,l=null;const u=this._targetRay,h=this._grip,d=this._hand;if(t&&n.session.visibilityState!=="visible-blurred"){if(d&&t.hand){l=!0;for(const M of t.hand.values()){const S=n.getJointPose(M,i),y=this._getHandJoint(d,M);S!==null&&(y.matrix.fromArray(S.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=S.radius),y.visible=S!==null}const p=d.joints["index-finger-tip"],m=d.joints["thumb-tip"],b=p.position.distanceTo(m.position),_=.02,x=.005;d.inputState.pinching&&b>_+x?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!d.inputState.pinching&&b<=_-x&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else h!==null&&t.gripSpace&&(o=n.getPose(t.gripSpace,i),o!==null&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));u!==null&&(a=n.getPose(t.targetRaySpace,i),a===null&&o!==null&&(a=o),a!==null&&(u.matrix.fromArray(a.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,a.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(a.linearVelocity)):u.hasLinearVelocity=!1,a.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(a.angularVelocity)):u.hasAngularVelocity=!1,this.dispatchEvent(qN)))}return u!==null&&(u.visible=a!==null),h!==null&&(h.visible=o!==null),d!==null&&(d.visible=l!==null),this}_getHandJoint(t,n){if(t.joints[n.jointName]===void 0){const i=new Wi;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[n.jointName]=i,t.add(i)}return t.joints[n.jointName]}}class e_{constructor(t,n=1,i=1e3){this.isFog=!0,this.name="",this.color=new be(t),this.near=n,this.far=i}clone(){return new e_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class YN extends En{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 Oa,this.environmentIntensity=1,this.environmentRotation=new Oa,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,n){return super.copy(t,n),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const n=super.toJSON(t);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}class KN{constructor(t,n){this.isInterleavedBuffer=!0,this.array=t,this.stride=n,this.count=t!==void 0?t.length/n:0,this.usage=Wv,this.updateRanges=[],this.version=0,this.uuid=ha()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,n){this.updateRanges.push({start:t,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,n,i){t*=this.stride,i*=n.stride;for(let a=0,o=this.stride;a1?null:n.copy(t.start).addScaledVector(i,o)}intersectsLine(t){const n=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return n<0&&i>0||i<0&&n>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,n){const i=n||eP.getNormalMatrix(t),a=this.coplanarPoint(gb).applyMatrix4(t),o=this.normal.applyMatrix3(i).normalize();return this.constant=-a.dot(o),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ko=new ka,Jd=new G;class s_{constructor(t=new il,n=new il,i=new il,a=new il,o=new il,l=new il){this.planes=[t,n,i,a,o,l]}set(t,n,i,a,o,l){const u=this.planes;return u[0].copy(t),u[1].copy(n),u[2].copy(i),u[3].copy(a),u[4].copy(o),u[5].copy(l),this}copy(t){const n=this.planes;for(let i=0;i<6;i++)n[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,n=xr){const i=this.planes,a=t.elements,o=a[0],l=a[1],u=a[2],h=a[3],d=a[4],p=a[5],m=a[6],b=a[7],_=a[8],x=a[9],M=a[10],S=a[11],y=a[12],E=a[13],w=a[14],A=a[15];if(i[0].setComponents(h-o,b-d,S-_,A-y).normalize(),i[1].setComponents(h+o,b+d,S+_,A+y).normalize(),i[2].setComponents(h+l,b+p,S+x,A+E).normalize(),i[3].setComponents(h-l,b-p,S-x,A-E).normalize(),i[4].setComponents(h-u,b-m,S-M,A-w).normalize(),n===xr)i[5].setComponents(h+u,b+m,S+M,A+w).normalize();else if(n===Vp)i[5].setComponents(u,m,M,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Ko.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const n=t.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Ko.copy(n.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Ko)}intersectsSprite(t){return Ko.center.set(0,0,0),Ko.radius=.7071067811865476,Ko.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ko)}intersectsSphere(t){const n=this.planes,i=t.center,a=-t.radius;for(let o=0;o<6;o++)if(n[o].distanceToPoint(i)0?t.max.x:t.min.x,Jd.y=a.normal.y>0?t.max.y:t.min.y,Jd.z=a.normal.z>0?t.max.z:t.min.z,a.distanceToPoint(Jd)<0)return!1}return!0}containsPoint(t){const n=this.planes;for(let i=0;i<6;i++)if(n[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class a_ extends Na{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new be(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Gp=new G,Hp=new G,lT=new Ee,Af=new om,$d=new ka,bb=new G,cT=new G;class eh extends En{constructor(t=new Fi,n=new a_){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,n){return super.copy(t,n),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const n=t.attributes.position,i=[0];for(let a=1,o=n.count;a0){const a=n[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,l=a.length;oi)return;bb.applyMatrix4(e.matrixWorld);const d=t.ray.origin.distanceTo(bb);if(!(dt.far))return{distance:d,point:cT.clone().applyMatrix4(e.matrixWorld),index:l,face:null,faceIndex:null,barycoord:null,object:e}}const uT=new G,fT=new G;class nP extends eh{constructor(t,n){super(t,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const n=t.attributes.position,i=[];for(let a=0,o=n.count;a0){const a=n[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,l=a.length;oa.far)return;o.push({distance:d,distanceToRay:Math.sqrt(u),point:h,index:t,face:null,faceIndex:null,barycoord:null,object:l})}}class ip extends ci{constructor(t,n,i,a,o,l,u,h,d){super(t,n,i,a,o,l,u,h,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Z3 extends ci{constructor(t,n,i,a,o,l,u,h,d,p=Oc){if(p!==Oc&&p!==jc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&p===Oc&&(i=_l),i===void 0&&p===jc&&(i=Hc),super(null,a,o,l,u,h,p,i,d),this.isDepthTexture=!0,this.image={width:t,height:n},this.magFilter=u!==void 0?u:Ki,this.minFilter=h!==void 0?h:Ki,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new t_(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const n=super.toJSON(t);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class fo extends Fi{constructor(t=1,n=1,i=1,a=32,o=1,l=!1,u=0,h=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:n,height:i,radialSegments:a,heightSegments:o,openEnded:l,thetaStart:u,thetaLength:h};const d=this;a=Math.floor(a),o=Math.floor(o);const p=[],m=[],b=[],_=[];let x=0;const M=[],S=i/2;let y=0;E(),l===!1&&(t>0&&w(!0),n>0&&w(!1)),this.setIndex(p),this.setAttribute("position",new Hn(m,3)),this.setAttribute("normal",new Hn(b,3)),this.setAttribute("uv",new Hn(_,2));function E(){const A=new G,U=new G;let O=0;const P=(n-t)/i;for(let F=0;F<=o;F++){const C=[],R=F/o,I=R*(n-t)+t;for(let Z=0;Z<=a;Z++){const nt=Z/a,ct=nt*h+u,ft=Math.sin(ct),z=Math.cos(ct);U.x=I*ft,U.y=-R*i+S,U.z=I*z,m.push(U.x,U.y,U.z),A.set(ft,P,z).normalize(),b.push(A.x,A.y,A.z),_.push(nt,1-R),C.push(x++)}M.push(C)}for(let F=0;F0||C!==0)&&(p.push(R,I,nt),O+=3),(n>0||C!==o-1)&&(p.push(I,Z,nt),O+=3)}d.addGroup(y,O,0),y+=O}function w(A){const U=x,O=new Ae,P=new G;let F=0;const C=A===!0?t:n,R=A===!0?1:-1;for(let Z=1;Z<=a;Z++)m.push(0,S*R,0),b.push(0,R,0),_.push(.5,.5),x++;const I=x;for(let Z=0;Z<=a;Z++){const ct=Z/a*h+u,ft=Math.cos(ct),z=Math.sin(ct);P.x=C*z,P.y=S*R,P.z=C*ft,m.push(P.x,P.y,P.z),b.push(0,R,0),O.x=ft*.5+.5,O.y=z*.5*R+.5,_.push(O.x,O.y),x++}for(let Z=0;Z.9&&P<.1&&(w<.2&&(l[E+0]+=1),A<.2&&(l[E+2]+=1),U<.2&&(l[E+4]+=1))}}function b(E){o.push(E.x,E.y,E.z)}function _(E,w){const A=E*3;w.x=t[A+0],w.y=t[A+1],w.z=t[A+2]}function x(){const E=new G,w=new G,A=new G,U=new G,O=new Ae,P=new Ae,F=new Ae;for(let C=0,R=0;C0)&&_.push(w,A,O),(y!==i-1||h0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class aP extends Na{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Y5,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class rP extends Na{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function sp(e,t,n){return!e||!n&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function oP(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function lP(e){function t(a,o){return e[a]-e[o]}const n=e.length,i=new Array(n);for(let a=0;a!==n;++a)i[a]=a;return i.sort(t),i}function pT(e,t,n){const i=e.length,a=new e.constructor(i);for(let o=0,l=0;l!==i;++o){const u=n[o]*t;for(let h=0;h!==t;++h)a[l++]=e[u+h]}return a}function Q3(e,t,n,i){let a=1,o=e[0];for(;o!==void 0&&o[i]===void 0;)o=e[a++];if(o===void 0)return;let l=o[i];if(l!==void 0)if(Array.isArray(l))do l=o[i],l!==void 0&&(t.push(o.time),n.push(...l)),o=e[a++];while(o!==void 0);else if(l.toArray!==void 0)do l=o[i],l!==void 0&&(t.push(o.time),l.toArray(n,n.length)),o=e[a++];while(o!==void 0);else do l=o[i],l!==void 0&&(t.push(o.time),n.push(l)),o=e[a++];while(o!==void 0)}class fh{constructor(t,n,i,a){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=a!==void 0?a:new n.constructor(i),this.sampleValues=n,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const n=this.parameterPositions;let i=this._cachedIndex,a=n[i],o=n[i-1];t:{e:{let l;n:{i:if(!(t=o)){const u=n[1];t=o)break e}l=i,i=0;break n}break t}for(;i>>1;tn;)--l;if(++l,o!==0||l!==a){o>=l&&(l=Math.max(l,1),o=l-1);const u=this.getValueSize();this.times=i.slice(o,l),this.values=this.values.slice(o*u,l*u)}return this}validate(){let t=!0;const n=this.getValueSize();n-Math.floor(n)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,a=this.values,o=i.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let l=null;for(let u=0;u!==o;u++){const h=i[u];if(typeof h=="number"&&isNaN(h)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,u,h),t=!1;break}if(l!==null&&l>h){console.error("THREE.KeyframeTrack: Out of order keys.",this,u,h,l),t=!1;break}l=h}if(a!==void 0&&oP(a))for(let u=0,h=a.length;u!==h;++u){const d=a[u];if(isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,u,d),t=!1;break}}return t}optimize(){const t=this.times.slice(),n=this.values.slice(),i=this.getValueSize(),a=this.getInterpolation()===q0,o=t.length-1;let l=1;for(let u=1;u0){t[l]=t[o];for(let u=o*i,h=l*i,d=0;d!==i;++d)n[h+d]=n[u+d];++l}return l!==t.length?(this.times=t.slice(0,l),this.values=n.slice(0,l*i)):(this.times=t,this.values=n),this}clone(){const t=this.times.slice(),n=this.values.slice(),i=this.constructor,a=new i(this.name,t,n);return a.createInterpolant=this.createInterpolant,a}}Ba.prototype.TimeBufferType=Float32Array;Ba.prototype.ValueBufferType=Float32Array;Ba.prototype.DefaultInterpolation=$f;class uu extends Ba{constructor(t,n,i){super(t,n,i)}}uu.prototype.ValueTypeName="bool";uu.prototype.ValueBufferType=Array;uu.prototype.DefaultInterpolation=Jf;uu.prototype.InterpolantFactoryMethodLinear=void 0;uu.prototype.InterpolantFactoryMethodSmooth=void 0;class $3 extends Ba{}$3.prototype.ValueTypeName="color";class Yc extends Ba{}Yc.prototype.ValueTypeName="number";class fP extends fh{constructor(t,n,i,a){super(t,n,i,a)}interpolate_(t,n,i,a){const o=this.resultBuffer,l=this.sampleValues,u=this.valueSize,h=(i-n)/(a-n);let d=t*u;for(let p=d+u;d!==p;d+=4)cs.slerpFlat(o,0,l,d-u,l,d,h);return o}}class Kc extends Ba{InterpolantFactoryMethodLinear(t){return new fP(this.times,this.values,this.getValueSize(),t)}}Kc.prototype.ValueTypeName="quaternion";Kc.prototype.InterpolantFactoryMethodSmooth=void 0;class fu extends Ba{constructor(t,n,i){super(t,n,i)}}fu.prototype.ValueTypeName="string";fu.prototype.ValueBufferType=Array;fu.prototype.DefaultInterpolation=Jf;fu.prototype.InterpolantFactoryMethodLinear=void 0;fu.prototype.InterpolantFactoryMethodSmooth=void 0;class Zc extends Ba{}Zc.prototype.ValueTypeName="vector";class Kv{constructor(t="",n=-1,i=[],a=J1){this.name=t,this.tracks=i,this.duration=n,this.blendMode=a,this.uuid=ha(),this.duration<0&&this.resetDuration()}static parse(t){const n=[],i=t.tracks,a=1/(t.fps||1);for(let l=0,u=i.length;l!==u;++l)n.push(dP(i[l]).scale(a));const o=new this(t.name,t.duration,n,t.blendMode);return o.uuid=t.uuid,o}static toJSON(t){const n=[],i=t.tracks,a={name:t.name,duration:t.duration,tracks:n,uuid:t.uuid,blendMode:t.blendMode};for(let o=0,l=i.length;o!==l;++o)n.push(Ba.toJSON(i[o]));return a}static CreateFromMorphTargetSequence(t,n,i,a){const o=n.length,l=[];for(let u=0;u1){const m=p[1];let b=a[m];b||(a[m]=b=[]),b.push(d)}}const l=[];for(const u in a)l.push(this.CreateFromMorphTargetSequence(u,a[u],n,i));return l}static parseAnimation(t,n){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(m,b,_,x,M){if(_.length!==0){const S=[],y=[];Q3(_,S,y,x),S.length!==0&&M.push(new m(b,S,y))}},a=[],o=t.name||"default",l=t.fps||30,u=t.blendMode;let h=t.length||-1;const d=t.hierarchy||[];for(let m=0;m{n&&n(o),this.manager.itemEnd(t)},0),o;if(mr[t]!==void 0){mr[t].push({onLoad:n,onProgress:i,onError:a});return}mr[t]=[],mr[t].push({onLoad:n,onProgress:i,onError:a});const l=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),u=this.mimeType,h=this.responseType;fetch(l).then(d=>{if(d.status===200||d.status===0){if(d.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||d.body===void 0||d.body.getReader===void 0)return d;const p=mr[t],m=d.body.getReader(),b=d.headers.get("X-File-Size")||d.headers.get("Content-Length"),_=b?parseInt(b):0,x=_!==0;let M=0;const S=new ReadableStream({start(y){E();function E(){m.read().then(({done:w,value:A})=>{if(w)y.close();else{M+=A.byteLength;const U=new ProgressEvent("progress",{lengthComputable:x,loaded:M,total:_});for(let O=0,P=p.length;O{y.error(w)})}}});return new Response(S)}else throw new gP(`fetch for "${d.url}" responded with ${d.status}: ${d.statusText}`,d)}).then(d=>{switch(h){case"arraybuffer":return d.arrayBuffer();case"blob":return d.blob();case"document":return d.text().then(p=>new DOMParser().parseFromString(p,u));case"json":return d.json();default:if(u===void 0)return d.text();{const m=/charset="?([^;"\s]*)"?/i.exec(u),b=m&&m[1]?m[1].toLowerCase():void 0,_=new TextDecoder(b);return d.arrayBuffer().then(x=>_.decode(x))}}}).then(d=>{go.add(t,d);const p=mr[t];delete mr[t];for(let m=0,b=p.length;m{const p=mr[t];if(p===void 0)throw this.manager.itemError(t),d;delete mr[t];for(let m=0,b=p.length;m{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class bP extends hu{constructor(t){super(t)}load(t,n,i,a){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const o=this,l=go.get(t);if(l!==void 0)return o.manager.itemStart(t),setTimeout(function(){n&&n(l),o.manager.itemEnd(t)},0),l;const u=th("img");function h(){p(),go.add(t,this),n&&n(this),o.manager.itemEnd(t)}function d(m){p(),a&&a(m),o.manager.itemError(t),o.manager.itemEnd(t)}function p(){u.removeEventListener("load",h,!1),u.removeEventListener("error",d,!1)}return u.addEventListener("load",h,!1),u.addEventListener("error",d,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(u.crossOrigin=this.crossOrigin),o.manager.itemStart(t),u.src=t,u}}class vP extends hu{constructor(t){super(t)}load(t,n,i,a){const o=new ci,l=new bP(this.manager);return l.setCrossOrigin(this.crossOrigin),l.setPath(this.path),l.load(t,function(u){o.image=u,o.needsUpdate=!0,n!==void 0&&n(o)},i,a),o}}class hh extends En{constructor(t,n=1){super(),this.isLight=!0,this.type="Light",this.color=new be(t),this.intensity=n}dispose(){}copy(t,n){return super.copy(t,n),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const n=super.toJSON(t);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}}class _P extends hh{constructor(t,n,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(En.DEFAULT_UP),this.updateMatrix(),this.groundColor=new be(n)}copy(t,n){return super.copy(t,n),this.groundColor.copy(t.groundColor),this}}const vb=new Ee,mT=new G,gT=new G;class u_{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ae(512,512),this.map=null,this.mapPass=null,this.matrix=new Ee,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new s_,this._frameExtents=new Ae(1,1),this._viewportCount=1,this._viewports=[new tn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const n=this.camera,i=this.matrix;mT.setFromMatrixPosition(t.matrixWorld),n.position.copy(mT),gT.setFromMatrixPosition(t.target.matrixWorld),n.lookAt(gT),n.updateMatrixWorld(),vb.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vb),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(vb)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class yP extends u_{constructor(){super(new Xi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const n=this.camera,i=Wc*2*t.angle*this.focus,a=this.mapSize.width/this.mapSize.height,o=t.distance||n.far;(i!==n.fov||a!==n.aspect||o!==n.far)&&(n.fov=i,n.aspect=a,n.far=o,n.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class xP extends hh{constructor(t,n,i=0,a=Math.PI/3,o=0,l=2){super(t,n),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(En.DEFAULT_UP),this.updateMatrix(),this.target=new En,this.distance=i,this.angle=a,this.penumbra=o,this.decay=l,this.map=null,this.shadow=new yP}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,n){return super.copy(t,n),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const bT=new Ee,Ef=new G,_b=new G;class SP extends u_{constructor(){super(new Xi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ae(4,2),this._viewportCount=6,this._viewports=[new tn(2,1,1,1),new tn(0,1,1,1),new tn(3,1,1,1),new tn(1,1,1,1),new tn(3,0,1,1),new tn(1,0,1,1)],this._cubeDirections=[new G(1,0,0),new G(-1,0,0),new G(0,0,1),new G(0,0,-1),new G(0,1,0),new G(0,-1,0)],this._cubeUps=[new G(0,1,0),new G(0,1,0),new G(0,1,0),new G(0,1,0),new G(0,0,1),new G(0,0,-1)]}updateMatrices(t,n=0){const i=this.camera,a=this.matrix,o=t.distance||i.far;o!==i.far&&(i.far=o,i.updateProjectionMatrix()),Ef.setFromMatrixPosition(t.matrixWorld),i.position.copy(Ef),_b.copy(i.position),_b.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(_b),i.updateMatrixWorld(),a.makeTranslation(-Ef.x,-Ef.y,-Ef.z),bT.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bT)}}class MP extends hh{constructor(t,n,i=0,a=2){super(t,n),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=a,this.shadow=new SP}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,n){return super.copy(t,n),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class f_ extends W3{constructor(t=-1,n=1,i=1,a=-1,o=.1,l=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=n,this.top=i,this.bottom=a,this.near=o,this.far=l,this.updateProjectionMatrix()}copy(t,n){return super.copy(t,n),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,n,i,a,o,l){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=a,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,a=(this.top+this.bottom)/2;let o=i-t,l=i+t,u=a+n,h=a-n;if(this.view!==null&&this.view.enabled){const d=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=d*this.view.offsetX,l=o+d*this.view.width,u-=p*this.view.offsetY,h=u-p*this.view.height}this.projectionMatrix.makeOrthographic(o,l,u,h,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const n=super.toJSON(t);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}class TP extends u_{constructor(){super(new f_(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Zv extends hh{constructor(t,n){super(t,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(En.DEFAULT_UP),this.updateMatrix(),this.target=new En,this.shadow=new TP}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class AP extends hh{constructor(t,n){super(t,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class Hf{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let n="";for(let i=0,a=t.length;i"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,n,i,a){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const o=this,l=go.get(t);if(l!==void 0){if(o.manager.itemStart(t),l.then){l.then(d=>{n&&n(d),o.manager.itemEnd(t)}).catch(d=>{a&&a(d)});return}return setTimeout(function(){n&&n(l),o.manager.itemEnd(t)},0),l}const u={};u.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",u.headers=this.requestHeader;const h=fetch(t,u).then(function(d){return d.blob()}).then(function(d){return createImageBitmap(d,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(d){return go.add(t,d),n&&n(d),o.manager.itemEnd(t),d}).catch(function(d){a&&a(d),go.remove(t),o.manager.itemError(t),o.manager.itemEnd(t)});go.add(t,h),o.manager.itemStart(t)}}class wP extends Xi{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t,this.index=0}}class RP{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vT(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const n=vT();t=(n-this.oldTime)/1e3,this.oldTime=n,this.elapsedTime+=t}return t}}function vT(){return performance.now()}class CP{constructor(t,n,i){this.binding=t,this.valueSize=i;let a,o,l;switch(n){case"quaternion":a=this._slerp,o=this._slerpAdditive,l=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":a=this._select,o=this._select,l=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:a=this._lerp,o=this._lerpAdditive,l=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=a,this._mixBufferRegionAdditive=o,this._setIdentity=l,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,n){const i=this.buffer,a=this.valueSize,o=t*a+a;let l=this.cumulativeWeight;if(l===0){for(let u=0;u!==a;++u)i[o+u]=i[u];l=n}else{l+=n;const u=n/l;this._mixBufferRegion(i,o,0,u,a)}this.cumulativeWeight=l}accumulateAdditive(t){const n=this.buffer,i=this.valueSize,a=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(n,a,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const n=this.valueSize,i=this.buffer,a=t*n+n,o=this.cumulativeWeight,l=this.cumulativeWeightAdditive,u=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const h=n*this._origIndex;this._mixBufferRegion(i,a,h,1-o,n)}l>0&&this._mixBufferRegionAdditive(i,a,this._addIndex*n,1,n);for(let h=n,d=n+n;h!==d;++h)if(i[h]!==i[h+n]){u.setValue(i,a);break}}saveOriginalState(){const t=this.binding,n=this.buffer,i=this.valueSize,a=i*this._origIndex;t.getValue(n,a);for(let o=i,l=a;o!==l;++o)n[o]=n[a+o%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,n=t+this.valueSize;for(let i=t;i=.5)for(let l=0;l!==o;++l)t[n+l]=t[i+l]}_slerp(t,n,i,a){cs.slerpFlat(t,n,t,n,t,i,a)}_slerpAdditive(t,n,i,a,o){const l=this._workIndex*o;cs.multiplyQuaternionsFlat(t,l,t,n,t,i),cs.slerpFlat(t,n,t,n,t,l,a)}_lerp(t,n,i,a,o){const l=1-a;for(let u=0;u!==o;++u){const h=n+u;t[h]=t[h]*l+t[i+u]*a}}_lerpAdditive(t,n,i,a,o){for(let l=0;l!==o;++l){const u=n+l;t[u]=t[u]+t[i+l]*a}}}const h_="\\[\\]\\.:\\/",DP=new RegExp("["+h_+"]","g"),d_="[^"+h_+"]",LP="[^"+h_.replace("\\.","")+"]",NP=/((?:WC+[\/:])*)/.source.replace("WC",d_),PP=/(WCOD+)?/.source.replace("WCOD",LP),UP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",d_),OP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",d_),FP=new RegExp("^"+NP+PP+UP+OP+"$"),IP=["material","materials","bones","map"];class kP{constructor(t,n,i){const a=i||en.parseTrackName(n);this._targetGroup=t,this._bindings=t.subscribe_(n,a)}getValue(t,n){this.bind();const i=this._targetGroup.nCachedObjects_,a=this._bindings[i];a!==void 0&&a.getValue(t,n)}setValue(t,n){const i=this._bindings;for(let a=this._targetGroup.nCachedObjects_,o=i.length;a!==o;++a)i[a].setValue(t,n)}bind(){const t=this._bindings;for(let n=this._targetGroup.nCachedObjects_,i=t.length;n!==i;++n)t[n].bind()}unbind(){const t=this._bindings;for(let n=this._targetGroup.nCachedObjects_,i=t.length;n!==i;++n)t[n].unbind()}}class en{constructor(t,n,i){this.path=n,this.parsedPath=i||en.parseTrackName(n),this.node=en.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,i){return t&&t.isAnimationObjectGroup?new en.Composite(t,n,i):new en(t,n,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(DP,"")}static parseTrackName(t){const n=FP.exec(t);if(n===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},a=i.nodeName&&i.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){const o=i.nodeName.substring(a+1);IP.indexOf(o)!==-1&&(i.nodeName=i.nodeName.substring(0,a),i.objectName=o)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,n){if(n===void 0||n===""||n==="."||n===-1||n===t.name||n===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(n);if(i!==void 0)return i}if(t.children){const i=function(o){for(let l=0;l0){const h=this._interpolants,d=this._propertyBindings;switch(this.blendMode){case X5:for(let p=0,m=h.length;p!==m;++p)h[p].evaluate(l),d[p].accumulateAdditive(u);break;case J1:default:for(let p=0,m=h.length;p!==m;++p)h[p].evaluate(l),d[p].accumulate(a,u)}}}_updateWeight(t){let n=0;if(this.enabled){n=this.weight;const i=this._weightInterpolant;if(i!==null){const a=i.evaluate(t)[0];n*=a,t>i.parameterPositions[1]&&(this.stopFading(),a===0&&(this.enabled=!1))}}return this._effectiveWeight=n,n}_updateTimeScale(t){let n=0;if(!this.paused){n=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const a=i.evaluate(t)[0];n*=a,t>i.parameterPositions[1]&&(this.stopWarping(),n===0?this.paused=!0:this.timeScale=n)}}return this._effectiveTimeScale=n,n}_updateTime(t){const n=this._clip.duration,i=this.loop;let a=this.time+t,o=this._loopCount;const l=i===W5;if(t===0)return o===-1?a:l&&(o&1)===1?n-a:a;if(i===Uf){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(a>=n)a=n;else if(a<0)a=0;else{this.time=a;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(o===-1&&(t>=0?(o=0,this._setEndings(!0,this.repetitions===0,l)):this._setEndings(this.repetitions===0,!0,l)),a>=n||a<0){const u=Math.floor(a/n);a-=n*u,o+=Math.abs(u);const h=this.repetitions-o;if(h<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a=t>0?n:0,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(h===1){const d=t<0;this._setEndings(d,!d,l)}else this._setEndings(!1,!1,l);this._loopCount=o,this.time=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:u})}}else this.time=a;if(l&&(o&1)===1)return n-a}return a}_setEndings(t,n,i){const a=this._interpolantSettings;i?(a.endingStart=Rc,a.endingEnd=Rc):(t?a.endingStart=this.zeroSlopeAtStart?Rc:wc:a.endingStart=Bp,n?a.endingEnd=this.zeroSlopeAtEnd?Rc:wc:a.endingEnd=Bp)}_scheduleFading(t,n,i){const a=this._mixer,o=a.time;let l=this._weightInterpolant;l===null&&(l=a._lendControlInterpolant(),this._weightInterpolant=l);const u=l.parameterPositions,h=l.sampleValues;return u[0]=o,h[0]=n,u[1]=o+t,h[1]=i,this}}const zP=new Float32Array(1);class VP extends Al{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,n){const i=t._localRoot||this._root,a=t._clip.tracks,o=a.length,l=t._propertyBindings,u=t._interpolants,h=i.uuid,d=this._bindingsByRootAndName;let p=d[h];p===void 0&&(p={},d[h]=p);for(let m=0;m!==o;++m){const b=a[m],_=b.name;let x=p[_];if(x!==void 0)++x.referenceCount,l[m]=x;else{if(x=l[m],x!==void 0){x._cacheIndex===null&&(++x.referenceCount,this._addInactiveBinding(x,h,_));continue}const M=n&&n._propertyBindings[m].binding.parsedPath;x=new CP(en.create(i,_,M),b.ValueTypeName,b.getValueSize()),++x.referenceCount,this._addInactiveBinding(x,h,_),l[m]=x}u[m].resultBuffer=x.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,a=t._clip.uuid,o=this._actionsByClip[a];this._bindAction(t,o&&o.knownActions[0]),this._addInactiveAction(t,a,i)}const n=t._propertyBindings;for(let i=0,a=n.length;i!==a;++i){const o=n[i];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const n=t._propertyBindings;for(let i=0,a=n.length;i!==a;++i){const o=n[i];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const n=t._cacheIndex;return n!==null&&n=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const n=this._actions,i=this._nActiveActions,a=this.time+=t,o=Math.sign(t),l=this._accuIndex^=1;for(let d=0;d!==i;++d)n[d]._update(a,t,o,l);const u=this._bindings,h=this._nActiveBindings;for(let d=0;d!==h;++d)u[d].apply(l);return this}setTime(t){this.time=0;for(let n=0;n_.start-x.start);let b=0;for(let _=1;_ 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif #endif`,rU=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,oU=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,lU=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,cU=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,uU=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,fU=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,hU=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,dU=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,pU=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,mU=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,gU=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,bU=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,vU=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,_U=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,yU="gl_FragColor = linearToOutputTexel( gl_FragColor );",xU=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,SU=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,MU=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,TU=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,AU=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,EU=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,wU=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,RU=`#ifdef USE_FOG varying float vFogDepth; #endif`,CU=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,DU=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,LU=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,NU=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,PU=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,UU=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,OU=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,FU=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,IU=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,kU=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,BU=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,zU=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,VU=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,GU=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,HU=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,jU=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,WU=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,XU=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,qU=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,YU=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,KU=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,ZU=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,QU=`#ifdef USE_MAP uniform sampler2D map; #endif`,JU=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,$U=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,tO=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,eO=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,nO=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`,iO=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,sO=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`,aO=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #endif`,rO=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`,oO=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,lO=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,cO=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,uO=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,fO=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,hO=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,dO=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,pO=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,mO=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,gO=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,bO=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,vO=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,_O=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,yO=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,xO=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,SO=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,MO=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,TO=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,AO=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,EO=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,wO=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,RO=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,CO=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,DO=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`,LO=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,NO=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,PO=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,UO=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,OO=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,FO=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 CineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,IO=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,kO=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,BO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,zO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,VO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,GO=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const HO=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,jO=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,WO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,XO=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,qO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,YO=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,KO=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,ZO=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,QO=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,JO=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,$O=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,t9=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,e9=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,n9=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,i9=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,s9=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,a9=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,r9=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,o9=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,l9=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,c9=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,u9=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,f9=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,h9=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,d9=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,p9=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,m9=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,g9=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,b9=`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,v9=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,_9=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,y9=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,x9=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,S9=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,Ce={alphahash_fragment:jP,alphahash_pars_fragment:WP,alphamap_fragment:XP,alphamap_pars_fragment:qP,alphatest_fragment:YP,alphatest_pars_fragment:KP,aomap_fragment:ZP,aomap_pars_fragment:QP,batching_pars_vertex:JP,batching_vertex:$P,begin_vertex:tU,beginnormal_vertex:eU,bsdfs:nU,iridescence_fragment:iU,bumpmap_pars_fragment:sU,clipping_planes_fragment:aU,clipping_planes_pars_fragment:rU,clipping_planes_pars_vertex:oU,clipping_planes_vertex:lU,color_fragment:cU,color_pars_fragment:uU,color_pars_vertex:fU,color_vertex:hU,common:dU,cube_uv_reflection_fragment:pU,defaultnormal_vertex:mU,displacementmap_pars_vertex:gU,displacementmap_vertex:bU,emissivemap_fragment:vU,emissivemap_pars_fragment:_U,colorspace_fragment:yU,colorspace_pars_fragment:xU,envmap_fragment:SU,envmap_common_pars_fragment:MU,envmap_pars_fragment:TU,envmap_pars_vertex:AU,envmap_physical_pars_fragment:FU,envmap_vertex:EU,fog_vertex:wU,fog_pars_vertex:RU,fog_fragment:CU,fog_pars_fragment:DU,gradientmap_pars_fragment:LU,lightmap_pars_fragment:NU,lights_lambert_fragment:PU,lights_lambert_pars_fragment:UU,lights_pars_begin:OU,lights_toon_fragment:IU,lights_toon_pars_fragment:kU,lights_phong_fragment:BU,lights_phong_pars_fragment:zU,lights_physical_fragment:VU,lights_physical_pars_fragment:GU,lights_fragment_begin:HU,lights_fragment_maps:jU,lights_fragment_end:WU,logdepthbuf_fragment:XU,logdepthbuf_pars_fragment:qU,logdepthbuf_pars_vertex:YU,logdepthbuf_vertex:KU,map_fragment:ZU,map_pars_fragment:QU,map_particle_fragment:JU,map_particle_pars_fragment:$U,metalnessmap_fragment:tO,metalnessmap_pars_fragment:eO,morphinstance_vertex:nO,morphcolor_vertex:iO,morphnormal_vertex:sO,morphtarget_pars_vertex:aO,morphtarget_vertex:rO,normal_fragment_begin:oO,normal_fragment_maps:lO,normal_pars_fragment:cO,normal_pars_vertex:uO,normal_vertex:fO,normalmap_pars_fragment:hO,clearcoat_normal_fragment_begin:dO,clearcoat_normal_fragment_maps:pO,clearcoat_pars_fragment:mO,iridescence_pars_fragment:gO,opaque_fragment:bO,packing:vO,premultiplied_alpha_fragment:_O,project_vertex:yO,dithering_fragment:xO,dithering_pars_fragment:SO,roughnessmap_fragment:MO,roughnessmap_pars_fragment:TO,shadowmap_pars_fragment:AO,shadowmap_pars_vertex:EO,shadowmap_vertex:wO,shadowmask_pars_fragment:RO,skinbase_vertex:CO,skinning_pars_vertex:DO,skinning_vertex:LO,skinnormal_vertex:NO,specularmap_fragment:PO,specularmap_pars_fragment:UO,tonemapping_fragment:OO,tonemapping_pars_fragment:FO,transmission_fragment:IO,transmission_pars_fragment:kO,uv_pars_fragment:BO,uv_pars_vertex:zO,uv_vertex:VO,worldpos_vertex:GO,background_vert:HO,background_frag:jO,backgroundCube_vert:WO,backgroundCube_frag:XO,cube_vert:qO,cube_frag:YO,depth_vert:KO,depth_frag:ZO,distanceRGBA_vert:QO,distanceRGBA_frag:JO,equirect_vert:$O,equirect_frag:t9,linedashed_vert:e9,linedashed_frag:n9,meshbasic_vert:i9,meshbasic_frag:s9,meshlambert_vert:a9,meshlambert_frag:r9,meshmatcap_vert:o9,meshmatcap_frag:l9,meshnormal_vert:c9,meshnormal_frag:u9,meshphong_vert:f9,meshphong_frag:h9,meshphysical_vert:d9,meshphysical_frag:p9,meshtoon_vert:m9,meshtoon_frag:g9,points_vert:b9,points_frag:v9,shadow_vert:_9,shadow_frag:y9,sprite_vert:x9,sprite_frag:S9},zt={common:{diffuse:{value:new be(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Te},alphaMap:{value:null},alphaMapTransform:{value:new Te},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Te}},envmap:{envMap:{value:null},envMapRotation:{value:new Te},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Te}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Te}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Te},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Te},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Te},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Te}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Te}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Te}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new be(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new be(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Te},alphaTest:{value:0},uvTransform:{value:new Te}},sprite:{diffuse:{value:new be(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Te},alphaMap:{value:null},alphaMapTransform:{value:new Te},alphaTest:{value:0}}},Ra={basic:{uniforms:Hi([zt.common,zt.specularmap,zt.envmap,zt.aomap,zt.lightmap,zt.fog]),vertexShader:Ce.meshbasic_vert,fragmentShader:Ce.meshbasic_frag},lambert:{uniforms:Hi([zt.common,zt.specularmap,zt.envmap,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.fog,zt.lights,{emissive:{value:new be(0)}}]),vertexShader:Ce.meshlambert_vert,fragmentShader:Ce.meshlambert_frag},phong:{uniforms:Hi([zt.common,zt.specularmap,zt.envmap,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.fog,zt.lights,{emissive:{value:new be(0)},specular:{value:new be(1118481)},shininess:{value:30}}]),vertexShader:Ce.meshphong_vert,fragmentShader:Ce.meshphong_frag},standard:{uniforms:Hi([zt.common,zt.envmap,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.roughnessmap,zt.metalnessmap,zt.fog,zt.lights,{emissive:{value:new be(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ce.meshphysical_vert,fragmentShader:Ce.meshphysical_frag},toon:{uniforms:Hi([zt.common,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.gradientmap,zt.fog,zt.lights,{emissive:{value:new be(0)}}]),vertexShader:Ce.meshtoon_vert,fragmentShader:Ce.meshtoon_frag},matcap:{uniforms:Hi([zt.common,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.fog,{matcap:{value:null}}]),vertexShader:Ce.meshmatcap_vert,fragmentShader:Ce.meshmatcap_frag},points:{uniforms:Hi([zt.points,zt.fog]),vertexShader:Ce.points_vert,fragmentShader:Ce.points_frag},dashed:{uniforms:Hi([zt.common,zt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ce.linedashed_vert,fragmentShader:Ce.linedashed_frag},depth:{uniforms:Hi([zt.common,zt.displacementmap]),vertexShader:Ce.depth_vert,fragmentShader:Ce.depth_frag},normal:{uniforms:Hi([zt.common,zt.bumpmap,zt.normalmap,zt.displacementmap,{opacity:{value:1}}]),vertexShader:Ce.meshnormal_vert,fragmentShader:Ce.meshnormal_frag},sprite:{uniforms:Hi([zt.sprite,zt.fog]),vertexShader:Ce.sprite_vert,fragmentShader:Ce.sprite_frag},background:{uniforms:{uvTransform:{value:new Te},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ce.background_vert,fragmentShader:Ce.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Te}},vertexShader:Ce.backgroundCube_vert,fragmentShader:Ce.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ce.cube_vert,fragmentShader:Ce.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ce.equirect_vert,fragmentShader:Ce.equirect_frag},distanceRGBA:{uniforms:Hi([zt.common,zt.displacementmap,{referencePosition:{value:new G},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ce.distanceRGBA_vert,fragmentShader:Ce.distanceRGBA_frag},shadow:{uniforms:Hi([zt.lights,zt.fog,{color:{value:new be(0)},opacity:{value:1}}]),vertexShader:Ce.shadow_vert,fragmentShader:Ce.shadow_frag}};Ra.physical={uniforms:Hi([Ra.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Te},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Te},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Te},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Te},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Te},sheen:{value:0},sheenColor:{value:new be(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Te},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Te},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Te},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Te},attenuationDistance:{value:0},attenuationColor:{value:new be(0)},specularColor:{value:new be(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Te},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Te},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Te}}]),vertexShader:Ce.meshphysical_vert,fragmentShader:Ce.meshphysical_frag};const ap={r:0,b:0,g:0},Zo=new Oa,M9=new Ee;function T9(e,t,n,i,a,o,l){const u=new be(0);let h=o===!0?0:1,d,p,m=null,b=0,_=null;function x(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:t).get(A)),A}function M(w){let A=!1;const U=x(w);U===null?y(u,h):U&&U.isColor&&(y(U,1),A=!0);const O=e.xr.getEnvironmentBlendMode();O==="additive"?i.buffers.color.setClear(0,0,0,1,l):O==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,l),(e.autoClear||A)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function S(w,A){const U=x(A);U&&(U.isCubeTexture||U.mapping===rm)?(p===void 0&&(p=new Oe(new xl(1,1,1),new xo({name:"BackgroundCubeMaterial",uniforms:Xc(Ra.backgroundCube.uniforms),vertexShader:Ra.backgroundCube.vertexShader,fragmentShader:Ra.backgroundCube.fragmentShader,side:Oi,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(O,P,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(p)),Zo.copy(A.backgroundRotation),Zo.x*=-1,Zo.y*=-1,Zo.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(Zo.y*=-1,Zo.z*=-1),p.material.uniforms.envMap.value=U,p.material.uniforms.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(M9.makeRotationFromEuler(Zo)),p.material.toneMapped=He.getTransfer(U.colorSpace)!==un,(m!==U||b!==U.version||_!==e.toneMapping)&&(p.material.needsUpdate=!0,m=U,b=U.version,_=e.toneMapping),p.layers.enableAll(),w.unshift(p,p.geometry,p.material,0,0,null)):U&&U.isTexture&&(d===void 0&&(d=new Oe(new qc(2,2),new xo({name:"BackgroundMaterial",uniforms:Xc(Ra.background.uniforms),vertexShader:Ra.background.vertexShader,fragmentShader:Ra.background.fragmentShader,side:Mr,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(d)),d.material.uniforms.t2D.value=U,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.toneMapped=He.getTransfer(U.colorSpace)!==un,U.matrixAutoUpdate===!0&&U.updateMatrix(),d.material.uniforms.uvTransform.value.copy(U.matrix),(m!==U||b!==U.version||_!==e.toneMapping)&&(d.material.needsUpdate=!0,m=U,b=U.version,_=e.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null))}function y(w,A){w.getRGB(ap,j3(e)),i.buffers.color.setClear(ap.r,ap.g,ap.b,A,l)}function E(){p!==void 0&&(p.geometry.dispose(),p.material.dispose(),p=void 0),d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0)}return{getClearColor:function(){return u},setClearColor:function(w,A=1){u.set(w),h=A,y(u,h)},getClearAlpha:function(){return h},setClearAlpha:function(w){h=w,y(u,h)},render:M,addToRenderList:S,dispose:E}}function A9(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},a=b(null);let o=a,l=!1;function u(R,I,Z,nt,ct){let ft=!1;const z=m(nt,Z,I);o!==z&&(o=z,d(o.object)),ft=_(R,nt,Z,ct),ft&&x(R,nt,Z,ct),ct!==null&&t.update(ct,e.ELEMENT_ARRAY_BUFFER),(ft||l)&&(l=!1,A(R,I,Z,nt),ct!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(ct).buffer))}function h(){return e.createVertexArray()}function d(R){return e.bindVertexArray(R)}function p(R){return e.deleteVertexArray(R)}function m(R,I,Z){const nt=Z.wireframe===!0;let ct=i[R.id];ct===void 0&&(ct={},i[R.id]=ct);let ft=ct[I.id];ft===void 0&&(ft={},ct[I.id]=ft);let z=ft[nt];return z===void 0&&(z=b(h()),ft[nt]=z),z}function b(R){const I=[],Z=[],nt=[];for(let ct=0;ct=0){const At=ct[q];let B=ft[q];if(B===void 0&&(q==="instanceMatrix"&&R.instanceMatrix&&(B=R.instanceMatrix),q==="instanceColor"&&R.instanceColor&&(B=R.instanceColor)),At===void 0||At.attribute!==B||B&&At.data!==B.data)return!0;z++}return o.attributesNum!==z||o.index!==nt}function x(R,I,Z,nt){const ct={},ft=I.attributes;let z=0;const J=Z.getAttributes();for(const q in J)if(J[q].location>=0){let At=ft[q];At===void 0&&(q==="instanceMatrix"&&R.instanceMatrix&&(At=R.instanceMatrix),q==="instanceColor"&&R.instanceColor&&(At=R.instanceColor));const B={};B.attribute=At,At&&At.data&&(B.data=At.data),ct[q]=B,z++}o.attributes=ct,o.attributesNum=z,o.index=nt}function M(){const R=o.newAttributes;for(let I=0,Z=R.length;I=0){let yt=ct[J];if(yt===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(yt=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(yt=R.instanceColor)),yt!==void 0){const At=yt.normalized,B=yt.itemSize,et=t.get(yt);if(et===void 0)continue;const Et=et.buffer,$=et.type,mt=et.bytesPerElement,Dt=$===e.INT||$===e.UNSIGNED_INT||yt.gpuType===W1;if(yt.isInterleavedBufferAttribute){const _t=yt.data,Wt=_t.stride,ee=yt.offset;if(_t.isInstancedInterleavedBuffer){for(let re=0;re0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";P="mediump"}return P==="mediump"&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let d=n.precision!==void 0?n.precision:"highp";const p=h(d);p!==d&&(console.warn("THREE.WebGLRenderer:",d,"not supported, using",p,"instead."),d=p);const m=n.logarithmicDepthBuffer===!0,b=n.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),_=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),M=e.getParameter(e.MAX_TEXTURE_SIZE),S=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),y=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),w=e.getParameter(e.MAX_VARYING_VECTORS),A=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),U=x>0,O=e.getParameter(e.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:h,textureFormatReadable:l,textureTypeReadable:u,precision:d,logarithmicDepthBuffer:m,reverseDepthBuffer:b,maxTextures:_,maxVertexTextures:x,maxTextureSize:M,maxCubemapSize:S,maxAttributes:y,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:U,maxSamples:O}}function R9(e){const t=this;let n=null,i=0,a=!1,o=!1;const l=new il,u=new Te,h={value:null,needsUpdate:!1};this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(m,b){const _=m.length!==0||b||i!==0||a;return a=b,i=m.length,_},this.beginShadows=function(){o=!0,p(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(m,b){n=p(m,b,0)},this.setState=function(m,b,_){const x=m.clippingPlanes,M=m.clipIntersection,S=m.clipShadows,y=e.get(m);if(!a||x===null||x.length===0||o&&!S)o?p(null):d();else{const E=o?0:i,w=E*4;let A=y.clippingState||null;h.value=A,A=p(x,b,w,_);for(let U=0;U!==w;++U)A[U]=n[U];y.clippingState=A,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=E}};function d(){h.value!==n&&(h.value=n,h.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function p(m,b,_,x){const M=m!==null?m.length:0;let S=null;if(M!==0){if(S=h.value,x!==!0||S===null){const y=_+M*4,E=b.matrixWorldInverse;u.getNormalMatrix(E),(S===null||S.length0){const d=new XN(h.height);return d.fromEquirectangularTexture(e,l),t.set(l,d),l.addEventListener("dispose",a),n(d.texture,l.mapping)}else return null}}return l}function a(l){const u=l.target;u.removeEventListener("dispose",a);const h=t.get(u);h!==void 0&&(t.delete(u),h.dispose())}function o(){t=new WeakMap}return{get:i,dispose:o}}const Cc=4,yT=[.125,.215,.35,.446,.526,.582],ol=20,yb=new f_,xT=new be;let xb=null,Sb=0,Mb=0,Tb=!1;const sl=(1+Math.sqrt(5))/2,xc=1/sl,ST=[new G(-sl,xc,0),new G(sl,xc,0),new G(-xc,0,sl),new G(xc,0,sl),new G(0,sl,-xc),new G(0,sl,xc),new G(-1,1,-1),new G(1,1,-1),new G(-1,1,1),new G(1,1,1)],D9=new G;class MT{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,n=0,i=.1,a=100,o={}){const{size:l=256,position:u=D9}=o;xb=this._renderer.getRenderTarget(),Sb=this._renderer.getActiveCubeFace(),Mb=this._renderer.getActiveMipmapLevel(),Tb=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(l);const h=this._allocateTargets();return h.depthBuffer=!0,this._sceneToCubeUV(t,i,a,h,u),n>0&&this._blur(h,0,0,n),this._applyPMREM(h),this._cleanup(h),h}fromEquirectangular(t,n=null){return this._fromTexture(t,n)}fromCubemap(t,n=null){return this._fromTexture(t,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ET(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=AT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?A:0,A,A),m.setRenderTarget(a),S&&m.render(M,h),m.render(t,h)}M.geometry.dispose(),M.material.dispose(),m.toneMapping=_,m.autoClear=b,t.background=y}_textureToCubeUV(t,n){const i=this._renderer,a=t.mapping===Vc||t.mapping===Gc;a?(this._cubemapMaterial===null&&(this._cubemapMaterial=ET()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=AT());const o=a?this._cubemapMaterial:this._equirectMaterial,l=new Oe(this._lodPlanes[0],o),u=o.uniforms;u.envMap.value=t;const h=this._cubeSize;rp(n,0,0,3*h,2*h),i.setRenderTarget(n),i.render(l,yb)}_applyPMREM(t){const n=this._renderer,i=n.autoClear;n.autoClear=!1;const a=this._lodPlanes.length;for(let o=1;ool&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${ol}`);const y=[];let E=0;for(let P=0;Pw-Cc?a-w+Cc:0),O=4*(this._cubeSize-A);rp(n,U,O,3*A,2*A),h.setRenderTarget(n),h.render(m,yb)}}function L9(e){const t=[],n=[],i=[];let a=e;const o=e-Cc+1+yT.length;for(let l=0;le-Cc?h=yT[l-e+Cc-1]:l===0&&(h=0),i.push(h);const d=1/(u-2),p=-d,m=1+d,b=[p,p,m,p,m,m,p,p,m,m,p,m],_=6,x=6,M=3,S=2,y=1,E=new Float32Array(M*x*_),w=new Float32Array(S*x*_),A=new Float32Array(y*x*_);for(let O=0;O<_;O++){const P=O%3*2/3-1,F=O>2?0:-1,C=[P,F,0,P+2/3,F,0,P+2/3,F+1,0,P,F,0,P+2/3,F+1,0,P,F+1,0];E.set(C,M*x*O),w.set(b,S*x*O);const R=[O,O,O,O,O,O];A.set(R,y*x*O)}const U=new Fi;U.setAttribute("position",new Zi(E,M)),U.setAttribute("uv",new Zi(w,S)),U.setAttribute("faceIndex",new Zi(A,y)),t.push(U),a>Cc&&a--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function TT(e,t,n){const i=new yl(e,t,n);return i.texture.mapping=rm,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function rp(e,t,n,i,a){e.viewport.set(t,n,i,a),e.scissor.set(t,n,i,a)}function N9(e,t,n){const i=new Float32Array(ol),a=new G(0,1,0);return new xo({name:"SphericalGaussianBlur",defines:{n:ol,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:a}},vertexShader:p_(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:vo,depthTest:!1,depthWrite:!1})}function AT(){return new xo({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:p_(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:vo,depthTest:!1,depthWrite:!1})}function ET(){return new xo({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:p_(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:vo,depthTest:!1,depthWrite:!1})}function p_(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function P9(e){let t=new WeakMap,n=null;function i(u){if(u&&u.isTexture){const h=u.mapping,d=h===gv||h===bv,p=h===Vc||h===Gc;if(d||p){let m=t.get(u);const b=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==b)return n===null&&(n=new MT(e)),m=d?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),m.texture;if(m!==void 0)return m.texture;{const _=u.image;return d&&_&&_.height>0||p&&_&&a(_)?(n===null&&(n=new MT(e)),m=d?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),u.addEventListener("dispose",o),m.texture):null}}}return u}function a(u){let h=0;const d=6;for(let p=0;pt.maxTextureSize&&(O=Math.ceil(U/t.maxTextureSize),U=t.maxTextureSize);const P=new Float32Array(U*O*4*m),F=new B3(P,U,O,m);F.type=fa,F.needsUpdate=!0;const C=A*4;for(let I=0;I0)return e;const a=t*n;let o=RT[a];if(o===void 0&&(o=new Float32Array(a),RT[a]=o),t!==0){i.toArray(o,0);for(let l=1,u=0;l!==t;++l)u+=n,e[l].toArray(o,u)}return o}function hi(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${u}: ${n[l]}`)}return i.join(` `)}const OT=new Te;function P6(e){He._getMatrix(OT,He.workingColorSpace,e);const t=`mat3( ${OT.elements.map(n=>n.toFixed(4))} )`;switch(He.getTransfer(e)){case zp:return[t,"LinearTransferOETF"];case un:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function FT(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),a=e.getShaderInfoLog(t).trim();if(i&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+` `+a+` `+N6(e.getShaderSource(t),l)}else return a}function U6(e,t){const n=P6(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(` `)}function O6(e,t){let n;switch(t){case F5:n="Linear";break;case I5:n="Reinhard";break;case k5:n="Cineon";break;case B5:n="ACESFilmic";break;case V5:n="AgX";break;case G5:n="Neutral";break;case z5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const op=new G;function F6(){He.getLuminanceCoefficients(op);const e=op.x.toFixed(4),t=op.y.toFixed(4),n=op.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`," return dot( weights, rgb );","}"].join(` `)}function I6(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Of).join(` `)}function k6(e){const t=[];for(const n in e){const i=e[n];i!==!1&&t.push("#define "+n+" "+i)}return t.join(` `)}function B6(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let a=0;a/gm;function Qv(e){return e.replace(z6,G6)}const V6=new Map;function G6(e,t){let n=Ce[t];if(n===void 0){const i=V6.get(t);if(i!==void 0)n=Ce[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw new Error("Can not resolve #include <"+t+">")}return Qv(n)}const H6=/#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 BT(e){return e.replace(H6,j6)}function j6(e,t,n,i){let a="";for(let o=parseInt(t);o0&&(S+=` `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Of).join(` `),y.length>0&&(y+=` `)):(S=[zT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,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 "+p:"",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&&n.flatShading===!1?"#define USE_TANGENT":"",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&&n.flatShading===!1?"#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 "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Of).join(` `),y=[zT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,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 "+d:"",n.envMap?"#define "+p:"",n.envMap?"#define "+m:"",b?"#define CUBEUV_TEXEL_WIDTH "+b.texelWidth:"",b?"#define CUBEUV_TEXEL_HEIGHT "+b.texelHeight:"",b?"#define CUBEUV_MAX_MIP "+b.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.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&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#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.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 "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==_o?"#define TONE_MAPPING":"",n.toneMapping!==_o?Ce.tonemapping_pars_fragment:"",n.toneMapping!==_o?O6("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ce.colorspace_pars_fragment,U6("linearToOutputTexel",n.outputColorSpace),F6(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",` `].filter(Of).join(` `)),l=Qv(l),l=IT(l,n),l=kT(l,n),u=Qv(u),u=IT(u,n),u=kT(u,n),l=BT(l),u=BT(u),n.isRawShaderMaterial!==!0&&(E=`#version 300 es `,S=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+S,y=["#define varying in",n.glslVersion===OM?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===OM?"":"#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(` `)+` `+y);const w=E+S+l,A=E+y+u,U=UT(a,a.VERTEX_SHADER,w),O=UT(a,a.FRAGMENT_SHADER,A);a.attachShader(M,U),a.attachShader(M,O),n.index0AttributeName!==void 0?a.bindAttribLocation(M,0,n.index0AttributeName):n.morphTargets===!0&&a.bindAttribLocation(M,0,"position"),a.linkProgram(M);function P(I){if(e.debug.checkShaderErrors){const Z=a.getProgramInfoLog(M).trim(),nt=a.getShaderInfoLog(U).trim(),ct=a.getShaderInfoLog(O).trim();let ft=!0,z=!0;if(a.getProgramParameter(M,a.LINK_STATUS)===!1)if(ft=!1,typeof e.debug.onShaderError=="function")e.debug.onShaderError(a,M,U,O);else{const J=FT(a,U,"vertex"),q=FT(a,O,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(M,a.VALIDATE_STATUS)+` Material Name: `+I.name+` Material Type: `+I.type+` Program Info Log: `+Z+` `+J+` `+q)}else Z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Z):(nt===""||ct==="")&&(z=!1);z&&(I.diagnostics={runnable:ft,programLog:Z,vertexShader:{log:nt,prefix:S},fragmentShader:{log:ct,prefix:y}})}a.deleteShader(U),a.deleteShader(O),F=new Ap(a,M),C=B6(a,M)}let F;this.getUniforms=function(){return F===void 0&&P(this),F};let C;this.getAttributes=function(){return C===void 0&&P(this),C};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=a.getProgramParameter(M,D6)),R},this.destroy=function(){i.releaseStatesOfProgram(this),a.deleteProgram(M),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=L6++,this.cacheKey=t,this.usedTimes=1,this.program=M,this.vertexShader=U,this.fragmentShader=O,this}let Q6=0;class J6{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const n=t.vertexShader,i=t.fragmentShader,a=this._getShaderStage(n),o=this._getShaderStage(i),l=this._getShaderCacheForMaterial(t);return l.has(a)===!1&&(l.add(a),a.usedTimes++),l.has(o)===!1&&(l.add(o),o.usedTimes++),this}remove(t){const n=this.materialCache.get(t);for(const i of n)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const n=this.materialCache;let i=n.get(t);return i===void 0&&(i=new Set,n.set(t,i)),i}_getShaderStage(t){const n=this.shaderCache;let i=n.get(t);return i===void 0&&(i=new $6(t),n.set(t,i)),i}}class $6{constructor(t){this.id=Q6++,this.code=t,this.usedTimes=0}}function t8(e,t,n,i,a,o,l){const u=new z3,h=new J6,d=new Set,p=[],m=a.logarithmicDepthBuffer,b=a.vertexTextures;let _=a.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function M(C){return d.add(C),C===0?"uv":`uv${C}`}function S(C,R,I,Z,nt){const ct=Z.fog,ft=nt.geometry,z=C.isMeshStandardMaterial?Z.environment:null,J=(C.isMeshStandardMaterial?n:t).get(C.envMap||z),q=J&&J.mapping===rm?J.image.height:null,yt=x[C.type];C.precision!==null&&(_=a.getMaxPrecision(C.precision),_!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",_,"instead."));const At=ft.morphAttributes.position||ft.morphAttributes.normal||ft.morphAttributes.color,B=At!==void 0?At.length:0;let et=0;ft.morphAttributes.position!==void 0&&(et=1),ft.morphAttributes.normal!==void 0&&(et=2),ft.morphAttributes.color!==void 0&&(et=3);let Et,$,mt,Dt;if(yt){const ze=Ra[yt];Et=ze.vertexShader,$=ze.fragmentShader}else Et=C.vertexShader,$=C.fragmentShader,h.update(C),mt=h.getVertexShaderID(C),Dt=h.getFragmentShaderID(C);const _t=e.getRenderTarget(),Wt=e.state.buffers.depth.getReversed(),ee=nt.isInstancedMesh===!0,re=nt.isBatchedMesh===!0,Qe=!!C.map,qe=!!C.matcap,De=!!J,j=!!C.aoMap,jn=!!C.lightMap,we=!!C.bumpMap,Re=!!C.normalMap,te=!!C.displacementMap,We=!!C.emissiveMap,Kt=!!C.metalnessMap,k=!!C.roughnessMap,L=C.anisotropy>0,it=C.clearcoat>0,gt=C.dispersion>0,wt=C.iridescence>0,xt=C.sheen>0,Qt=C.transmission>0,kt=L&&!!C.anisotropyMap,jt=it&&!!C.clearcoatMap,Le=it&&!!C.clearcoatNormalMap,Lt=it&&!!C.clearcoatRoughnessMap,Ht=wt&&!!C.iridescenceMap,ae=wt&&!!C.iridescenceThicknessMap,Gt=xt&&!!C.sheenColorMap,Bt=xt&&!!C.sheenRoughnessMap,fe=!!C.specularMap,me=!!C.specularColorMap,Ge=!!C.specularIntensityMap,K=Qt&&!!C.transmissionMap,Ut=Qt&&!!C.thicknessMap,ht=!!C.gradientMap,Mt=!!C.alphaMap,Ot=C.alphaTest>0,Ft=!!C.alphaHash,pe=!!C.extensions;let gn=_o;C.toneMapped&&(_t===null||_t.isXRRenderTarget===!0)&&(gn=e.toneMapping);const Pn={shaderID:yt,shaderType:C.type,shaderName:C.name,vertexShader:Et,fragmentShader:$,defines:C.defines,customVertexShaderID:mt,customFragmentShaderID:Dt,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:_,batching:re,batchingColor:re&&nt._colorsTexture!==null,instancing:ee,instancingColor:ee&&nt.instanceColor!==null,instancingMorph:ee&&nt.morphTexture!==null,supportsVertexTextures:b,outputColorSpace:_t===null?e.outputColorSpace:_t.isXRRenderTarget===!0?_t.texture.colorSpace:Qi,alphaToCoverage:!!C.alphaToCoverage,map:Qe,matcap:qe,envMap:De,envMapMode:De&&J.mapping,envMapCubeUVHeight:q,aoMap:j,lightMap:jn,bumpMap:we,normalMap:Re,displacementMap:b&&te,emissiveMap:We,normalMapObjectSpace:Re&&C.normalMapType===Z5,normalMapTangentSpace:Re&&C.normalMapType===F3,metalnessMap:Kt,roughnessMap:k,anisotropy:L,anisotropyMap:kt,clearcoat:it,clearcoatMap:jt,clearcoatNormalMap:Le,clearcoatRoughnessMap:Lt,dispersion:gt,iridescence:wt,iridescenceMap:Ht,iridescenceThicknessMap:ae,sheen:xt,sheenColorMap:Gt,sheenRoughnessMap:Bt,specularMap:fe,specularColorMap:me,specularIntensityMap:Ge,transmission:Qt,transmissionMap:K,thicknessMap:Ut,gradientMap:ht,opaque:C.transparent===!1&&C.blending===Uc&&C.alphaToCoverage===!1,alphaMap:Mt,alphaTest:Ot,alphaHash:Ft,combine:C.combine,mapUv:Qe&&M(C.map.channel),aoMapUv:j&&M(C.aoMap.channel),lightMapUv:jn&&M(C.lightMap.channel),bumpMapUv:we&&M(C.bumpMap.channel),normalMapUv:Re&&M(C.normalMap.channel),displacementMapUv:te&&M(C.displacementMap.channel),emissiveMapUv:We&&M(C.emissiveMap.channel),metalnessMapUv:Kt&&M(C.metalnessMap.channel),roughnessMapUv:k&&M(C.roughnessMap.channel),anisotropyMapUv:kt&&M(C.anisotropyMap.channel),clearcoatMapUv:jt&&M(C.clearcoatMap.channel),clearcoatNormalMapUv:Le&&M(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Lt&&M(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ht&&M(C.iridescenceMap.channel),iridescenceThicknessMapUv:ae&&M(C.iridescenceThicknessMap.channel),sheenColorMapUv:Gt&&M(C.sheenColorMap.channel),sheenRoughnessMapUv:Bt&&M(C.sheenRoughnessMap.channel),specularMapUv:fe&&M(C.specularMap.channel),specularColorMapUv:me&&M(C.specularColorMap.channel),specularIntensityMapUv:Ge&&M(C.specularIntensityMap.channel),transmissionMapUv:K&&M(C.transmissionMap.channel),thicknessMapUv:Ut&&M(C.thicknessMap.channel),alphaMapUv:Mt&&M(C.alphaMap.channel),vertexTangents:!!ft.attributes.tangent&&(Re||L),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!ft.attributes.color&&ft.attributes.color.itemSize===4,pointsUvs:nt.isPoints===!0&&!!ft.attributes.uv&&(Qe||Mt),fog:!!ct,useFog:C.fog===!0,fogExp2:!!ct&&ct.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:m,reverseDepthBuffer:Wt,skinning:nt.isSkinnedMesh===!0,morphTargets:ft.morphAttributes.position!==void 0,morphNormals:ft.morphAttributes.normal!==void 0,morphColors:ft.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:et,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:l.numPlanes,numClipIntersection:l.numIntersection,dithering:C.dithering,shadowMapEnabled:e.shadowMap.enabled&&I.length>0,shadowMapType:e.shadowMap.type,toneMapping:gn,decodeVideoTexture:Qe&&C.map.isVideoTexture===!0&&He.getTransfer(C.map.colorSpace)===un,decodeVideoTextureEmissive:We&&C.emissiveMap.isVideoTexture===!0&&He.getTransfer(C.emissiveMap.colorSpace)===un,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===os,flipSided:C.side===Oi,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:pe&&C.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pe&&C.extensions.multiDraw===!0||re)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return Pn.vertexUv1s=d.has(1),Pn.vertexUv2s=d.has(2),Pn.vertexUv3s=d.has(3),d.clear(),Pn}function y(C){const R=[];if(C.shaderID?R.push(C.shaderID):(R.push(C.customVertexShaderID),R.push(C.customFragmentShaderID)),C.defines!==void 0)for(const I in C.defines)R.push(I),R.push(C.defines[I]);return C.isRawShaderMaterial===!1&&(E(R,C),w(R,C),R.push(e.outputColorSpace)),R.push(C.customProgramCacheKey),R.join()}function E(C,R){C.push(R.precision),C.push(R.outputColorSpace),C.push(R.envMapMode),C.push(R.envMapCubeUVHeight),C.push(R.mapUv),C.push(R.alphaMapUv),C.push(R.lightMapUv),C.push(R.aoMapUv),C.push(R.bumpMapUv),C.push(R.normalMapUv),C.push(R.displacementMapUv),C.push(R.emissiveMapUv),C.push(R.metalnessMapUv),C.push(R.roughnessMapUv),C.push(R.anisotropyMapUv),C.push(R.clearcoatMapUv),C.push(R.clearcoatNormalMapUv),C.push(R.clearcoatRoughnessMapUv),C.push(R.iridescenceMapUv),C.push(R.iridescenceThicknessMapUv),C.push(R.sheenColorMapUv),C.push(R.sheenRoughnessMapUv),C.push(R.specularMapUv),C.push(R.specularColorMapUv),C.push(R.specularIntensityMapUv),C.push(R.transmissionMapUv),C.push(R.thicknessMapUv),C.push(R.combine),C.push(R.fogExp2),C.push(R.sizeAttenuation),C.push(R.morphTargetsCount),C.push(R.morphAttributeCount),C.push(R.numDirLights),C.push(R.numPointLights),C.push(R.numSpotLights),C.push(R.numSpotLightMaps),C.push(R.numHemiLights),C.push(R.numRectAreaLights),C.push(R.numDirLightShadows),C.push(R.numPointLightShadows),C.push(R.numSpotLightShadows),C.push(R.numSpotLightShadowsWithMaps),C.push(R.numLightProbes),C.push(R.shadowMapType),C.push(R.toneMapping),C.push(R.numClippingPlanes),C.push(R.numClipIntersection),C.push(R.depthPacking)}function w(C,R){u.disableAll(),R.supportsVertexTextures&&u.enable(0),R.instancing&&u.enable(1),R.instancingColor&&u.enable(2),R.instancingMorph&&u.enable(3),R.matcap&&u.enable(4),R.envMap&&u.enable(5),R.normalMapObjectSpace&&u.enable(6),R.normalMapTangentSpace&&u.enable(7),R.clearcoat&&u.enable(8),R.iridescence&&u.enable(9),R.alphaTest&&u.enable(10),R.vertexColors&&u.enable(11),R.vertexAlphas&&u.enable(12),R.vertexUv1s&&u.enable(13),R.vertexUv2s&&u.enable(14),R.vertexUv3s&&u.enable(15),R.vertexTangents&&u.enable(16),R.anisotropy&&u.enable(17),R.alphaHash&&u.enable(18),R.batching&&u.enable(19),R.dispersion&&u.enable(20),R.batchingColor&&u.enable(21),C.push(u.mask),u.disableAll(),R.fog&&u.enable(0),R.useFog&&u.enable(1),R.flatShading&&u.enable(2),R.logarithmicDepthBuffer&&u.enable(3),R.reverseDepthBuffer&&u.enable(4),R.skinning&&u.enable(5),R.morphTargets&&u.enable(6),R.morphNormals&&u.enable(7),R.morphColors&&u.enable(8),R.premultipliedAlpha&&u.enable(9),R.shadowMapEnabled&&u.enable(10),R.doubleSided&&u.enable(11),R.flipSided&&u.enable(12),R.useDepthPacking&&u.enable(13),R.dithering&&u.enable(14),R.transmission&&u.enable(15),R.sheen&&u.enable(16),R.opaque&&u.enable(17),R.pointsUvs&&u.enable(18),R.decodeVideoTexture&&u.enable(19),R.decodeVideoTextureEmissive&&u.enable(20),R.alphaToCoverage&&u.enable(21),C.push(u.mask)}function A(C){const R=x[C.type];let I;if(R){const Z=Ra[R];I=GN.clone(Z.uniforms)}else I=C.uniforms;return I}function U(C,R){let I;for(let Z=0,nt=p.length;Z0?i.push(y):_.transparent===!0?a.push(y):n.push(y)}function h(m,b,_,x,M,S){const y=l(m,b,_,x,M,S);_.transmission>0?i.unshift(y):_.transparent===!0?a.unshift(y):n.unshift(y)}function d(m,b){n.length>1&&n.sort(m||n8),i.length>1&&i.sort(b||VT),a.length>1&&a.sort(b||VT)}function p(){for(let m=t,b=e.length;m=o.length?(l=new GT,o.push(l)):l=o[a],l}function n(){e=new WeakMap}return{get:t,dispose:n}}function s8(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new G,color:new be};break;case"SpotLight":n={position:new G,direction:new G,color:new be,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new G,color:new be,distance:0,decay:0};break;case"HemisphereLight":n={direction:new G,skyColor:new be,groundColor:new be};break;case"RectAreaLight":n={color:new be,position:new G,halfWidth:new G,halfHeight:new G};break}return e[t.id]=n,n}}}function a8(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}let r8=0;function o8(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function l8(e){const t=new s8,n=a8(),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 d=0;d<9;d++)i.probe.push(new G);const a=new G,o=new Ee,l=new Ee;function u(d){let p=0,m=0,b=0;for(let C=0;C<9;C++)i.probe[C].set(0,0,0);let _=0,x=0,M=0,S=0,y=0,E=0,w=0,A=0,U=0,O=0,P=0;d.sort(o8);for(let C=0,R=d.length;C0&&(e.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=zt.LTC_FLOAT_1,i.rectAreaLTC2=zt.LTC_FLOAT_2):(i.rectAreaLTC1=zt.LTC_HALF_1,i.rectAreaLTC2=zt.LTC_HALF_2)),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=b;const F=i.hash;(F.directionalLength!==_||F.pointLength!==x||F.spotLength!==M||F.rectAreaLength!==S||F.hemiLength!==y||F.numDirectionalShadows!==E||F.numPointShadows!==w||F.numSpotShadows!==A||F.numSpotMaps!==U||F.numLightProbes!==P)&&(i.directional.length=_,i.spot.length=M,i.rectArea.length=S,i.point.length=x,i.hemi.length=y,i.directionalShadow.length=E,i.directionalShadowMap.length=E,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=E,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=A+U-O,i.spotLightMap.length=U,i.numSpotLightShadowsWithMaps=O,i.numLightProbes=P,F.directionalLength=_,F.pointLength=x,F.spotLength=M,F.rectAreaLength=S,F.hemiLength=y,F.numDirectionalShadows=E,F.numPointShadows=w,F.numSpotShadows=A,F.numSpotMaps=U,F.numLightProbes=P,i.version=r8++)}function h(d,p){let m=0,b=0,_=0,x=0,M=0;const S=p.matrixWorldInverse;for(let y=0,E=d.length;y=l.length?(u=new HT(e),l.push(u)):u=l[o],u}function i(){t=new WeakMap}return{get:n,dispose:i}}const u8=`void main() { gl_Position = vec4( position, 1.0 ); }`,f8=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function h8(e,t,n){let i=new s_;const a=new Ae,o=new Ae,l=new tn,u=new aP({depthPacking:K5}),h=new rP,d={},p=n.maxTextureSize,m={[Mr]:Oi,[Oi]:Mr,[os]:os},b=new xo({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:u8,fragmentShader:f8}),_=b.clone();_.defines.HORIZONTAL_PASS=1;const x=new Fi;x.setAttribute("position",new Zi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const M=new Oe(x,b),S=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=S3;let y=this.type;this.render=function(O,P,F){if(S.enabled===!1||S.autoUpdate===!1&&S.needsUpdate===!1||O.length===0)return;const C=e.getRenderTarget(),R=e.getActiveCubeFace(),I=e.getActiveMipmapLevel(),Z=e.state;Z.setBlending(vo),Z.buffers.color.setClear(1,1,1,1),Z.buffers.depth.setTest(!0),Z.setScissorTest(!1);const nt=y!==gr&&this.type===gr,ct=y===gr&&this.type!==gr;for(let ft=0,z=O.length;ftp||a.y>p)&&(a.x>p&&(o.x=Math.floor(p/yt.x),a.x=o.x*yt.x,q.mapSize.x=o.x),a.y>p&&(o.y=Math.floor(p/yt.y),a.y=o.y*yt.y,q.mapSize.y=o.y)),q.map===null||nt===!0||ct===!0){const B=this.type!==gr?{minFilter:Ki,magFilter:Ki}:{};q.map!==null&&q.map.dispose(),q.map=new yl(a.x,a.y,B),q.map.texture.name=J.name+".shadowMap",q.camera.updateProjectionMatrix()}e.setRenderTarget(q.map),e.clear();const At=q.getViewportCount();for(let B=0;B0||P.map&&P.alphaTest>0){const Z=R.uuid,nt=P.uuid;let ct=d[Z];ct===void 0&&(ct={},d[Z]=ct);let ft=ct[nt];ft===void 0&&(ft=R.clone(),ct[nt]=ft,P.addEventListener("dispose",U)),R=ft}if(R.visible=P.visible,R.wireframe=P.wireframe,C===gr?R.side=P.shadowSide!==null?P.shadowSide:P.side:R.side=P.shadowSide!==null?P.shadowSide:m[P.side],R.alphaMap=P.alphaMap,R.alphaTest=P.alphaTest,R.map=P.map,R.clipShadows=P.clipShadows,R.clippingPlanes=P.clippingPlanes,R.clipIntersection=P.clipIntersection,R.displacementMap=P.displacementMap,R.displacementScale=P.displacementScale,R.displacementBias=P.displacementBias,R.wireframeLinewidth=P.wireframeLinewidth,R.linewidth=P.linewidth,F.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const Z=e.properties.get(R);Z.light=F}return R}function A(O,P,F,C,R){if(O.visible===!1)return;if(O.layers.test(P.layers)&&(O.isMesh||O.isLine||O.isPoints)&&(O.castShadow||O.receiveShadow&&R===gr)&&(!O.frustumCulled||i.intersectsObject(O))){O.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,O.matrixWorld);const nt=t.update(O),ct=O.material;if(Array.isArray(ct)){const ft=nt.groups;for(let z=0,J=ft.length;z=1):q.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),z=J>=2);let yt=null,At={};const B=e.getParameter(e.SCISSOR_BOX),et=e.getParameter(e.VIEWPORT),Et=new tn().fromArray(B),$=new tn().fromArray(et);function mt(K,Ut,ht,Mt){const Ot=new Uint8Array(4),Ft=e.createTexture();e.bindTexture(K,Ft),e.texParameteri(K,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(K,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),d=new Ae,p=new WeakMap;let m;const b=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(k,L){return _?new OffscreenCanvas(k,L):th("canvas")}function M(k,L,it){let gt=1;const wt=Kt(k);if((wt.width>it||wt.height>it)&&(gt=it/Math.max(wt.width,wt.height)),gt<1)if(typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&k instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&k instanceof ImageBitmap||typeof VideoFrame<"u"&&k instanceof VideoFrame){const xt=Math.floor(gt*wt.width),Qt=Math.floor(gt*wt.height);m===void 0&&(m=x(xt,Qt));const kt=L?x(xt,Qt):m;return kt.width=xt,kt.height=Qt,kt.getContext("2d").drawImage(k,0,0,xt,Qt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+wt.width+"x"+wt.height+") to ("+xt+"x"+Qt+")."),kt}else return"data"in k&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+wt.width+"x"+wt.height+")."),k;return k}function S(k){return k.generateMipmaps}function y(k){e.generateMipmap(k)}function E(k){return k.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:k.isWebGL3DRenderTarget?e.TEXTURE_3D:k.isWebGLArrayRenderTarget||k.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function w(k,L,it,gt,wt=!1){if(k!==null){if(e[k]!==void 0)return e[k];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+k+"'")}let xt=L;if(L===e.RED&&(it===e.FLOAT&&(xt=e.R32F),it===e.HALF_FLOAT&&(xt=e.R16F),it===e.UNSIGNED_BYTE&&(xt=e.R8)),L===e.RED_INTEGER&&(it===e.UNSIGNED_BYTE&&(xt=e.R8UI),it===e.UNSIGNED_SHORT&&(xt=e.R16UI),it===e.UNSIGNED_INT&&(xt=e.R32UI),it===e.BYTE&&(xt=e.R8I),it===e.SHORT&&(xt=e.R16I),it===e.INT&&(xt=e.R32I)),L===e.RG&&(it===e.FLOAT&&(xt=e.RG32F),it===e.HALF_FLOAT&&(xt=e.RG16F),it===e.UNSIGNED_BYTE&&(xt=e.RG8)),L===e.RG_INTEGER&&(it===e.UNSIGNED_BYTE&&(xt=e.RG8UI),it===e.UNSIGNED_SHORT&&(xt=e.RG16UI),it===e.UNSIGNED_INT&&(xt=e.RG32UI),it===e.BYTE&&(xt=e.RG8I),it===e.SHORT&&(xt=e.RG16I),it===e.INT&&(xt=e.RG32I)),L===e.RGB_INTEGER&&(it===e.UNSIGNED_BYTE&&(xt=e.RGB8UI),it===e.UNSIGNED_SHORT&&(xt=e.RGB16UI),it===e.UNSIGNED_INT&&(xt=e.RGB32UI),it===e.BYTE&&(xt=e.RGB8I),it===e.SHORT&&(xt=e.RGB16I),it===e.INT&&(xt=e.RGB32I)),L===e.RGBA_INTEGER&&(it===e.UNSIGNED_BYTE&&(xt=e.RGBA8UI),it===e.UNSIGNED_SHORT&&(xt=e.RGBA16UI),it===e.UNSIGNED_INT&&(xt=e.RGBA32UI),it===e.BYTE&&(xt=e.RGBA8I),it===e.SHORT&&(xt=e.RGBA16I),it===e.INT&&(xt=e.RGBA32I)),L===e.RGB&&it===e.UNSIGNED_INT_5_9_9_9_REV&&(xt=e.RGB9_E5),L===e.RGBA){const Qt=wt?zp:He.getTransfer(gt);it===e.FLOAT&&(xt=e.RGBA32F),it===e.HALF_FLOAT&&(xt=e.RGBA16F),it===e.UNSIGNED_BYTE&&(xt=Qt===un?e.SRGB8_ALPHA8:e.RGBA8),it===e.UNSIGNED_SHORT_4_4_4_4&&(xt=e.RGBA4),it===e.UNSIGNED_SHORT_5_5_5_1&&(xt=e.RGB5_A1)}return(xt===e.R16F||xt===e.R32F||xt===e.RG16F||xt===e.RG32F||xt===e.RGBA16F||xt===e.RGBA32F)&&t.get("EXT_color_buffer_float"),xt}function A(k,L){let it;return k?L===null||L===_l||L===Hc?it=e.DEPTH24_STENCIL8:L===fa?it=e.DEPTH32F_STENCIL8:L===Qf&&(it=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===_l||L===Hc?it=e.DEPTH_COMPONENT24:L===fa?it=e.DEPTH_COMPONENT32F:L===Qf&&(it=e.DEPTH_COMPONENT16),it}function U(k,L){return S(k)===!0||k.isFramebufferTexture&&k.minFilter!==Ki&&k.minFilter!==As?Math.log2(Math.max(L.width,L.height))+1:k.mipmaps!==void 0&&k.mipmaps.length>0?k.mipmaps.length:k.isCompressedTexture&&Array.isArray(k.image)?L.mipmaps.length:1}function O(k){const L=k.target;L.removeEventListener("dispose",O),F(L),L.isVideoTexture&&p.delete(L)}function P(k){const L=k.target;L.removeEventListener("dispose",P),R(L)}function F(k){const L=i.get(k);if(L.__webglInit===void 0)return;const it=k.source,gt=b.get(it);if(gt){const wt=gt[L.__cacheKey];wt.usedTimes--,wt.usedTimes===0&&C(k),Object.keys(gt).length===0&&b.delete(it)}i.remove(k)}function C(k){const L=i.get(k);e.deleteTexture(L.__webglTexture);const it=k.source,gt=b.get(it);delete gt[L.__cacheKey],l.memory.textures--}function R(k){const L=i.get(k);if(k.depthTexture&&(k.depthTexture.dispose(),i.remove(k.depthTexture)),k.isWebGLCubeRenderTarget)for(let gt=0;gt<6;gt++){if(Array.isArray(L.__webglFramebuffer[gt]))for(let wt=0;wt=a.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+k+" texture units while this GPU supports only "+a.maxTextures),I+=1,k}function ct(k){const L=[];return L.push(k.wrapS),L.push(k.wrapT),L.push(k.wrapR||0),L.push(k.magFilter),L.push(k.minFilter),L.push(k.anisotropy),L.push(k.internalFormat),L.push(k.format),L.push(k.type),L.push(k.generateMipmaps),L.push(k.premultiplyAlpha),L.push(k.flipY),L.push(k.unpackAlignment),L.push(k.colorSpace),L.join()}function ft(k,L){const it=i.get(k);if(k.isVideoTexture&&te(k),k.isRenderTargetTexture===!1&&k.version>0&&it.__version!==k.version){const gt=k.image;if(gt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(gt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{$(it,k,L);return}}n.bindTexture(e.TEXTURE_2D,it.__webglTexture,e.TEXTURE0+L)}function z(k,L){const it=i.get(k);if(k.version>0&&it.__version!==k.version){$(it,k,L);return}n.bindTexture(e.TEXTURE_2D_ARRAY,it.__webglTexture,e.TEXTURE0+L)}function J(k,L){const it=i.get(k);if(k.version>0&&it.__version!==k.version){$(it,k,L);return}n.bindTexture(e.TEXTURE_3D,it.__webglTexture,e.TEXTURE0+L)}function q(k,L){const it=i.get(k);if(k.version>0&&it.__version!==k.version){mt(it,k,L);return}n.bindTexture(e.TEXTURE_CUBE_MAP,it.__webglTexture,e.TEXTURE0+L)}const yt={[Da]:e.REPEAT,[mo]:e.CLAMP_TO_EDGE,[kp]:e.MIRRORED_REPEAT},At={[Ki]:e.NEAREST,[A3]:e.NEAREST_MIPMAP_NEAREST,[Pf]:e.NEAREST_MIPMAP_LINEAR,[As]:e.LINEAR,[_p]:e.LINEAR_MIPMAP_NEAREST,[yr]:e.LINEAR_MIPMAP_LINEAR},B={[Q5]:e.NEVER,[iN]:e.ALWAYS,[J5]:e.LESS,[I3]:e.LEQUAL,[$5]:e.EQUAL,[nN]:e.GEQUAL,[tN]:e.GREATER,[eN]:e.NOTEQUAL};function et(k,L){if(L.type===fa&&t.has("OES_texture_float_linear")===!1&&(L.magFilter===As||L.magFilter===_p||L.magFilter===Pf||L.magFilter===yr||L.minFilter===As||L.minFilter===_p||L.minFilter===Pf||L.minFilter===yr)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(k,e.TEXTURE_WRAP_S,yt[L.wrapS]),e.texParameteri(k,e.TEXTURE_WRAP_T,yt[L.wrapT]),(k===e.TEXTURE_3D||k===e.TEXTURE_2D_ARRAY)&&e.texParameteri(k,e.TEXTURE_WRAP_R,yt[L.wrapR]),e.texParameteri(k,e.TEXTURE_MAG_FILTER,At[L.magFilter]),e.texParameteri(k,e.TEXTURE_MIN_FILTER,At[L.minFilter]),L.compareFunction&&(e.texParameteri(k,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(k,e.TEXTURE_COMPARE_FUNC,B[L.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===Ki||L.minFilter!==Pf&&L.minFilter!==yr||L.type===fa&&t.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||i.get(L).__currentAnisotropy){const it=t.get("EXT_texture_filter_anisotropic");e.texParameterf(k,it.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,a.getMaxAnisotropy())),i.get(L).__currentAnisotropy=L.anisotropy}}}function Et(k,L){let it=!1;k.__webglInit===void 0&&(k.__webglInit=!0,L.addEventListener("dispose",O));const gt=L.source;let wt=b.get(gt);wt===void 0&&(wt={},b.set(gt,wt));const xt=ct(L);if(xt!==k.__cacheKey){wt[xt]===void 0&&(wt[xt]={texture:e.createTexture(),usedTimes:0},l.memory.textures++,it=!0),wt[xt].usedTimes++;const Qt=wt[k.__cacheKey];Qt!==void 0&&(wt[k.__cacheKey].usedTimes--,Qt.usedTimes===0&&C(L)),k.__cacheKey=xt,k.__webglTexture=wt[xt].texture}return it}function $(k,L,it){let gt=e.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(gt=e.TEXTURE_2D_ARRAY),L.isData3DTexture&&(gt=e.TEXTURE_3D);const wt=Et(k,L),xt=L.source;n.bindTexture(gt,k.__webglTexture,e.TEXTURE0+it);const Qt=i.get(xt);if(xt.version!==Qt.__version||wt===!0){n.activeTexture(e.TEXTURE0+it);const kt=He.getPrimaries(He.workingColorSpace),jt=L.colorSpace===uo?null:He.getPrimaries(L.colorSpace),Le=L.colorSpace===uo||kt===jt?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,L.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,L.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Le);let Lt=M(L.image,!1,a.maxTextureSize);Lt=We(L,Lt);const Ht=o.convert(L.format,L.colorSpace),ae=o.convert(L.type);let Gt=w(L.internalFormat,Ht,ae,L.colorSpace,L.isVideoTexture);et(gt,L);let Bt;const fe=L.mipmaps,me=L.isVideoTexture!==!0,Ge=Qt.__version===void 0||wt===!0,K=xt.dataReady,Ut=U(L,Lt);if(L.isDepthTexture)Gt=A(L.format===jc,L.type),Ge&&(me?n.texStorage2D(e.TEXTURE_2D,1,Gt,Lt.width,Lt.height):n.texImage2D(e.TEXTURE_2D,0,Gt,Lt.width,Lt.height,0,Ht,ae,null));else if(L.isDataTexture)if(fe.length>0){me&&Ge&&n.texStorage2D(e.TEXTURE_2D,Ut,Gt,fe[0].width,fe[0].height);for(let ht=0,Mt=fe.length;ht0){const Ot=_T(Bt.width,Bt.height,L.format,L.type);for(const Ft of L.layerUpdates){const pe=Bt.data.subarray(Ft*Ot/Bt.data.BYTES_PER_ELEMENT,(Ft+1)*Ot/Bt.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ht,0,0,Ft,Bt.width,Bt.height,1,Ht,pe)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ht,0,0,0,Bt.width,Bt.height,Lt.depth,Ht,Bt.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ht,Gt,Bt.width,Bt.height,Lt.depth,0,Bt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else me?K&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,ht,0,0,0,Bt.width,Bt.height,Lt.depth,Ht,ae,Bt.data):n.texImage3D(e.TEXTURE_2D_ARRAY,ht,Gt,Bt.width,Bt.height,Lt.depth,0,Ht,ae,Bt.data)}else{me&&Ge&&n.texStorage2D(e.TEXTURE_2D,Ut,Gt,fe[0].width,fe[0].height);for(let ht=0,Mt=fe.length;ht0){const ht=_T(Lt.width,Lt.height,L.format,L.type);for(const Mt of L.layerUpdates){const Ot=Lt.data.subarray(Mt*ht/Lt.data.BYTES_PER_ELEMENT,(Mt+1)*ht/Lt.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,Mt,Lt.width,Lt.height,1,Ht,ae,Ot)}L.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,Lt.width,Lt.height,Lt.depth,Ht,ae,Lt.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,Gt,Lt.width,Lt.height,Lt.depth,0,Ht,ae,Lt.data);else if(L.isData3DTexture)me?(Ge&&n.texStorage3D(e.TEXTURE_3D,Ut,Gt,Lt.width,Lt.height,Lt.depth),K&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,Lt.width,Lt.height,Lt.depth,Ht,ae,Lt.data)):n.texImage3D(e.TEXTURE_3D,0,Gt,Lt.width,Lt.height,Lt.depth,0,Ht,ae,Lt.data);else if(L.isFramebufferTexture){if(Ge)if(me)n.texStorage2D(e.TEXTURE_2D,Ut,Gt,Lt.width,Lt.height);else{let ht=Lt.width,Mt=Lt.height;for(let Ot=0;Ot>=1,Mt>>=1}}else if(fe.length>0){if(me&&Ge){const ht=Kt(fe[0]);n.texStorage2D(e.TEXTURE_2D,Ut,Gt,ht.width,ht.height)}for(let ht=0,Mt=fe.length;ht0&&Ut++;const Mt=Kt(Ht[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,Ut,fe,Mt.width,Mt.height)}for(let Mt=0;Mt<6;Mt++)if(Lt){me?K&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+Mt,0,0,0,Ht[Mt].width,Ht[Mt].height,Gt,Bt,Ht[Mt].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+Mt,0,fe,Ht[Mt].width,Ht[Mt].height,0,Gt,Bt,Ht[Mt].data);for(let Ot=0;Ot>xt),ae=Math.max(1,L.height>>xt);wt===e.TEXTURE_3D||wt===e.TEXTURE_2D_ARRAY?n.texImage3D(wt,xt,jt,Ht,ae,L.depth,0,Qt,kt,null):n.texImage2D(wt,xt,jt,Ht,ae,0,Qt,kt,null)}n.bindFramebuffer(e.FRAMEBUFFER,k),Re(L)?u.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,gt,wt,Lt.__webglTexture,0,we(L)):(wt===e.TEXTURE_2D||wt>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&wt<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,gt,wt,Lt.__webglTexture,xt),n.bindFramebuffer(e.FRAMEBUFFER,null)}function _t(k,L,it){if(e.bindRenderbuffer(e.RENDERBUFFER,k),L.depthBuffer){const gt=L.depthTexture,wt=gt&>.isDepthTexture?gt.type:null,xt=A(L.stencilBuffer,wt),Qt=L.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,kt=we(L);Re(L)?u.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,kt,xt,L.width,L.height):it?e.renderbufferStorageMultisample(e.RENDERBUFFER,kt,xt,L.width,L.height):e.renderbufferStorage(e.RENDERBUFFER,xt,L.width,L.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,Qt,e.RENDERBUFFER,k)}else{const gt=L.textures;for(let wt=0;wt{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,gt.removeEventListener("dispose",wt)};gt.addEventListener("dispose",wt),L.__depthDisposeCallback=wt}L.__boundDepthTexture=gt}if(k.depthTexture&&!L.__autoAllocateDepthBuffer){if(it)throw new Error("target.depthTexture not supported in Cube render targets");Wt(L.__webglFramebuffer,k)}else if(it){L.__webglDepthbuffer=[];for(let gt=0;gt<6;gt++)if(n.bindFramebuffer(e.FRAMEBUFFER,L.__webglFramebuffer[gt]),L.__webglDepthbuffer[gt]===void 0)L.__webglDepthbuffer[gt]=e.createRenderbuffer(),_t(L.__webglDepthbuffer[gt],k,!1);else{const wt=k.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,xt=L.__webglDepthbuffer[gt];e.bindRenderbuffer(e.RENDERBUFFER,xt),e.framebufferRenderbuffer(e.FRAMEBUFFER,wt,e.RENDERBUFFER,xt)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=e.createRenderbuffer(),_t(L.__webglDepthbuffer,k,!1);else{const gt=k.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,wt=L.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,wt),e.framebufferRenderbuffer(e.FRAMEBUFFER,gt,e.RENDERBUFFER,wt)}n.bindFramebuffer(e.FRAMEBUFFER,null)}function re(k,L,it){const gt=i.get(k);L!==void 0&&Dt(gt.__webglFramebuffer,k,k.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),it!==void 0&&ee(k)}function Qe(k){const L=k.texture,it=i.get(k),gt=i.get(L);k.addEventListener("dispose",P);const wt=k.textures,xt=k.isWebGLCubeRenderTarget===!0,Qt=wt.length>1;if(Qt||(gt.__webglTexture===void 0&&(gt.__webglTexture=e.createTexture()),gt.__version=L.version,l.memory.textures++),xt){it.__webglFramebuffer=[];for(let kt=0;kt<6;kt++)if(L.mipmaps&&L.mipmaps.length>0){it.__webglFramebuffer[kt]=[];for(let jt=0;jt0){it.__webglFramebuffer=[];for(let kt=0;kt0&&Re(k)===!1){it.__webglMultisampledFramebuffer=e.createFramebuffer(),it.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,it.__webglMultisampledFramebuffer);for(let kt=0;kt0)for(let jt=0;jt0)for(let jt=0;jt0){if(Re(k)===!1){const L=k.textures,it=k.width,gt=k.height;let wt=e.COLOR_BUFFER_BIT;const xt=k.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,Qt=i.get(k),kt=L.length>1;if(kt)for(let jt=0;jt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function te(k){const L=l.render.frame;p.get(k)!==L&&(p.set(k,L),k.update())}function We(k,L){const it=k.colorSpace,gt=k.format,wt=k.type;return k.isCompressedTexture===!0||k.isVideoTexture===!0||it!==Qi&&it!==uo&&(He.getTransfer(it)===un?(gt!==Ks||wt!==Tr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",it)),L}function Kt(k){return typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement?(d.width=k.naturalWidth||k.width,d.height=k.naturalHeight||k.height):typeof VideoFrame<"u"&&k instanceof VideoFrame?(d.width=k.displayWidth,d.height=k.displayHeight):(d.width=k.width,d.height=k.height),d}this.allocateTextureUnit=nt,this.resetTextureUnits=Z,this.setTexture2D=ft,this.setTexture2DArray=z,this.setTexture3D=J,this.setTextureCube=q,this.rebindTextures=re,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=qe,this.updateMultisampleRenderTarget=jn,this.setupDepthRenderbuffer=ee,this.setupFrameBufferTexture=Dt,this.useMultisampledRTT=Re}function g8(e,t){function n(i,a=uo){let o;const l=He.getTransfer(a);if(i===Tr)return e.UNSIGNED_BYTE;if(i===X1)return e.UNSIGNED_SHORT_4_4_4_4;if(i===q1)return e.UNSIGNED_SHORT_5_5_5_1;if(i===R3)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===E3)return e.BYTE;if(i===w3)return e.SHORT;if(i===Qf)return e.UNSIGNED_SHORT;if(i===W1)return e.INT;if(i===_l)return e.UNSIGNED_INT;if(i===fa)return e.FLOAT;if(i===uh)return e.HALF_FLOAT;if(i===C3)return e.ALPHA;if(i===D3)return e.RGB;if(i===Ks)return e.RGBA;if(i===L3)return e.LUMINANCE;if(i===N3)return e.LUMINANCE_ALPHA;if(i===Oc)return e.DEPTH_COMPONENT;if(i===jc)return e.DEPTH_STENCIL;if(i===Y1)return e.RED;if(i===K1)return e.RED_INTEGER;if(i===P3)return e.RG;if(i===Z1)return e.RG_INTEGER;if(i===Q1)return e.RGBA_INTEGER;if(i===yp||i===xp||i===Sp||i===Mp)if(l===un)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(i===yp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===xp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Sp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Mp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(i===yp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===xp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Sp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Mp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===vv||i===_v||i===yv||i===xv)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(i===vv)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===_v)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===yv)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===xv)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Sv||i===Mv||i===Tv)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(i===Sv||i===Mv)return l===un?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(i===Tv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Av||i===Ev||i===wv||i===Rv||i===Cv||i===Dv||i===Lv||i===Nv||i===Pv||i===Uv||i===Ov||i===Fv||i===Iv||i===kv)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(i===Av)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ev)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===wv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Rv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Cv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Dv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Lv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Nv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Pv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Uv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ov)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Fv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Iv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===kv)return l===un?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Tp||i===Bv||i===zv)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(i===Tp)return l===un?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Bv)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===zv)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===U3||i===Vv||i===Gv||i===Hv)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(i===Tp)return o.COMPRESSED_RED_RGTC1_EXT;if(i===Vv)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Gv)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Hv)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Hc?e.UNSIGNED_INT_24_8:e[i]!==void 0?e[i]:null}return{convert:n}}const b8=` void main() { gl_Position = vec4( position, 1.0 ); }`,v8=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`;class _8{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,n,i){if(this.texture===null){const a=new ci,o=t.properties.get(a);o.__webglTexture=n.texture,(n.depthNear!==i.depthNear||n.depthFar!==i.depthFar)&&(this.depthNear=n.depthNear,this.depthFar=n.depthFar),this.texture=a}}getMesh(t){if(this.texture!==null&&this.mesh===null){const n=t.cameras[0].viewport,i=new xo({vertexShader:b8,fragmentShader:v8,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Oe(new qc(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class y8 extends Al{constructor(t,n){super();const i=this;let a=null,o=1,l=null,u="local-floor",h=1,d=null,p=null,m=null,b=null,_=null,x=null;const M=new _8,S=n.getContextAttributes();let y=null,E=null;const w=[],A=[],U=new Ae;let O=null;const P=new Xi;P.viewport=new tn;const F=new Xi;F.viewport=new tn;const C=[P,F],R=new wP;let I=null,Z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let mt=w[$];return mt===void 0&&(mt=new db,w[$]=mt),mt.getTargetRaySpace()},this.getControllerGrip=function($){let mt=w[$];return mt===void 0&&(mt=new db,w[$]=mt),mt.getGripSpace()},this.getHand=function($){let mt=w[$];return mt===void 0&&(mt=new db,w[$]=mt),mt.getHandSpace()};function nt($){const mt=A.indexOf($.inputSource);if(mt===-1)return;const Dt=w[mt];Dt!==void 0&&(Dt.update($.inputSource,$.frame,d||l),Dt.dispatchEvent({type:$.type,data:$.inputSource}))}function ct(){a.removeEventListener("select",nt),a.removeEventListener("selectstart",nt),a.removeEventListener("selectend",nt),a.removeEventListener("squeeze",nt),a.removeEventListener("squeezestart",nt),a.removeEventListener("squeezeend",nt),a.removeEventListener("end",ct),a.removeEventListener("inputsourceschange",ft);for(let $=0;$=0&&(A[_t]=null,w[_t].disconnect(Dt))}for(let mt=0;mt<$.added.length;mt++){const Dt=$.added[mt];let _t=A.indexOf(Dt);if(_t===-1){for(let ee=0;ee=A.length){A.push(Dt),_t=ee;break}else if(A[ee]===null){A[ee]=Dt,_t=ee;break}if(_t===-1)break}const Wt=w[_t];Wt&&Wt.connect(Dt)}}const z=new G,J=new G;function q($,mt,Dt){z.setFromMatrixPosition(mt.matrixWorld),J.setFromMatrixPosition(Dt.matrixWorld);const _t=z.distanceTo(J),Wt=mt.projectionMatrix.elements,ee=Dt.projectionMatrix.elements,re=Wt[14]/(Wt[10]-1),Qe=Wt[14]/(Wt[10]+1),qe=(Wt[9]+1)/Wt[5],De=(Wt[9]-1)/Wt[5],j=(Wt[8]-1)/Wt[0],jn=(ee[8]+1)/ee[0],we=re*j,Re=re*jn,te=_t/(-j+jn),We=te*-j;if(mt.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(We),$.translateZ(te),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Wt[10]===-1)$.projectionMatrix.copy(mt.projectionMatrix),$.projectionMatrixInverse.copy(mt.projectionMatrixInverse);else{const Kt=re+te,k=Qe+te,L=we-We,it=Re+(_t-We),gt=qe*Qe/k*Kt,wt=De*Qe/k*Kt;$.projectionMatrix.makePerspective(L,it,gt,wt,Kt,k),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function yt($,mt){mt===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(mt.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(a===null)return;let mt=$.near,Dt=$.far;M.texture!==null&&(M.depthNear>0&&(mt=M.depthNear),M.depthFar>0&&(Dt=M.depthFar)),R.near=F.near=P.near=mt,R.far=F.far=P.far=Dt,(I!==R.near||Z!==R.far)&&(a.updateRenderState({depthNear:R.near,depthFar:R.far}),I=R.near,Z=R.far),P.layers.mask=$.layers.mask|2,F.layers.mask=$.layers.mask|4,R.layers.mask=P.layers.mask|F.layers.mask;const _t=$.parent,Wt=R.cameras;yt(R,_t);for(let ee=0;ee0&&(S.alphaTest.value=y.alphaTest);const E=t.get(y),w=E.envMap,A=E.envMapRotation;w&&(S.envMap.value=w,Qo.copy(A),Qo.x*=-1,Qo.y*=-1,Qo.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Qo.y*=-1,Qo.z*=-1),S.envMapRotation.value.setFromMatrix4(x8.makeRotationFromEuler(Qo)),S.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=y.reflectivity,S.ior.value=y.ior,S.refractionRatio.value=y.refractionRatio),y.lightMap&&(S.lightMap.value=y.lightMap,S.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,S.lightMapTransform)),y.aoMap&&(S.aoMap.value=y.aoMap,S.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,S.aoMapTransform))}function l(S,y){S.diffuse.value.copy(y.color),S.opacity.value=y.opacity,y.map&&(S.map.value=y.map,n(y.map,S.mapTransform))}function u(S,y){S.dashSize.value=y.dashSize,S.totalSize.value=y.dashSize+y.gapSize,S.scale.value=y.scale}function h(S,y,E,w){S.diffuse.value.copy(y.color),S.opacity.value=y.opacity,S.size.value=y.size*E,S.scale.value=w*.5,y.map&&(S.map.value=y.map,n(y.map,S.uvTransform)),y.alphaMap&&(S.alphaMap.value=y.alphaMap,n(y.alphaMap,S.alphaMapTransform)),y.alphaTest>0&&(S.alphaTest.value=y.alphaTest)}function d(S,y){S.diffuse.value.copy(y.color),S.opacity.value=y.opacity,S.rotation.value=y.rotation,y.map&&(S.map.value=y.map,n(y.map,S.mapTransform)),y.alphaMap&&(S.alphaMap.value=y.alphaMap,n(y.alphaMap,S.alphaMapTransform)),y.alphaTest>0&&(S.alphaTest.value=y.alphaTest)}function p(S,y){S.specular.value.copy(y.specular),S.shininess.value=Math.max(y.shininess,1e-4)}function m(S,y){y.gradientMap&&(S.gradientMap.value=y.gradientMap)}function b(S,y){S.metalness.value=y.metalness,y.metalnessMap&&(S.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,S.metalnessMapTransform)),S.roughness.value=y.roughness,y.roughnessMap&&(S.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,S.roughnessMapTransform)),y.envMap&&(S.envMapIntensity.value=y.envMapIntensity)}function _(S,y,E){S.ior.value=y.ior,y.sheen>0&&(S.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),S.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(S.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,S.sheenColorMapTransform)),y.sheenRoughnessMap&&(S.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,S.sheenRoughnessMapTransform))),y.clearcoat>0&&(S.clearcoat.value=y.clearcoat,S.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(S.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,S.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(S.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===Oi&&S.clearcoatNormalScale.value.negate())),y.dispersion>0&&(S.dispersion.value=y.dispersion),y.iridescence>0&&(S.iridescence.value=y.iridescence,S.iridescenceIOR.value=y.iridescenceIOR,S.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(S.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,S.iridescenceMapTransform)),y.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),y.transmission>0&&(S.transmission.value=y.transmission,S.transmissionSamplerMap.value=E.texture,S.transmissionSamplerSize.value.set(E.width,E.height),y.transmissionMap&&(S.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,S.transmissionMapTransform)),S.thickness.value=y.thickness,y.thicknessMap&&(S.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=y.attenuationDistance,S.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(S.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(S.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,S.anisotropyMapTransform))),S.specularIntensity.value=y.specularIntensity,S.specularColor.value.copy(y.specularColor),y.specularColorMap&&(S.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,S.specularColorMapTransform)),y.specularIntensityMap&&(S.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,S.specularIntensityMapTransform))}function x(S,y){y.matcap&&(S.matcap.value=y.matcap)}function M(S,y){const E=t.get(y).light;S.referencePosition.value.setFromMatrixPosition(E.matrixWorld),S.nearDistance.value=E.shadow.camera.near,S.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:a}}function M8(e,t,n,i){let a={},o={},l=[];const u=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function h(E,w){const A=w.program;i.uniformBlockBinding(E,A)}function d(E,w){let A=a[E.id];A===void 0&&(x(E),A=p(E),a[E.id]=A,E.addEventListener("dispose",S));const U=w.program;i.updateUBOMapping(E,U);const O=t.render.frame;o[E.id]!==O&&(b(E),o[E.id]=O)}function p(E){const w=m();E.__bindingPointIndex=w;const A=e.createBuffer(),U=E.__size,O=E.usage;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,U,O),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function m(){for(let E=0;E0&&(A+=U-O),E.__size=A,E.__cache={},this}function M(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function S(E){const w=E.target;w.removeEventListener("dispose",S);const A=l.indexOf(w.__bindingPointIndex);l.splice(A,1),e.deleteBuffer(a[w.id]),delete a[w.id],delete o[w.id]}function y(){for(const E in a)e.deleteBuffer(a[E]);l=[],a={},o={}}return{bind:h,update:d,dispose:y}}class T8{constructor(t={}){const{canvas:n=yN(),context:i=null,depth:a=!0,stencil:o=!1,alpha:l=!1,antialias:u=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:d=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:m=!1,reverseDepthBuffer:b=!1}=t;this.isWebGLRenderer=!0;let _;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=i.getContextAttributes().alpha}else _=l;const x=new Uint32Array(4),M=new Int32Array(4);let S=null,y=null;const E=[],w=[];this.domElement=n,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._outputColorSpace=Jn,this.toneMapping=_o,this.toneMappingExposure=1;const A=this;let U=!1,O=0,P=0,F=null,C=-1,R=null;const I=new tn,Z=new tn;let nt=null;const ct=new be(0);let ft=0,z=n.width,J=n.height,q=1,yt=null,At=null;const B=new tn(0,0,z,J),et=new tn(0,0,z,J);let Et=!1;const $=new s_;let mt=!1,Dt=!1;this.transmissionResolutionScale=1;const _t=new Ee,Wt=new Ee,ee=new G,re=new tn,Qe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let qe=!1;function De(){return F===null?q:1}let j=i;function jn(D,W){return n.getContext(D,W)}try{const D={alpha:!0,depth:a,stencil:o,antialias:u,premultipliedAlpha:h,preserveDrawingBuffer:d,powerPreference:p,failIfMajorPerformanceCaveat:m};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${j1}`),n.addEventListener("webglcontextlost",Mt,!1),n.addEventListener("webglcontextrestored",Ot,!1),n.addEventListener("webglcontextcreationerror",Ft,!1),j===null){const W="webgl2";if(j=jn(W,D),j===null)throw jn(W)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(D){throw console.error("THREE.WebGLRenderer: "+D.message),D}let we,Re,te,We,Kt,k,L,it,gt,wt,xt,Qt,kt,jt,Le,Lt,Ht,ae,Gt,Bt,fe,me,Ge,K;function Ut(){we=new U9(j),we.init(),me=new g8(j,we),Re=new w9(j,we,t,me),te=new p8(j,we),Re.reverseDepthBuffer&&b&&te.buffers.depth.setReversed(!0),We=new I9(j),Kt=new e8,k=new m8(j,we,te,Kt,Re,me,We),L=new C9(A),it=new P9(A),gt=new HP(j),Ge=new A9(j,gt),wt=new O9(j,gt,We,Ge),xt=new B9(j,wt,gt,We),Gt=new k9(j,Re,k),Lt=new R9(Kt),Qt=new t8(A,L,it,we,Re,Ge,Lt),kt=new S8(A,Kt),jt=new i8,Le=new c8(we),ae=new T9(A,L,it,te,xt,_,h),Ht=new h8(A,xt,Re),K=new M8(j,We,Re,te),Bt=new E9(j,we,We),fe=new F9(j,we,We),We.programs=Qt.programs,A.capabilities=Re,A.extensions=we,A.properties=Kt,A.renderLists=jt,A.shadowMap=Ht,A.state=te,A.info=We}Ut();const ht=new y8(A,j);this.xr=ht,this.getContext=function(){return j},this.getContextAttributes=function(){return j.getContextAttributes()},this.forceContextLoss=function(){const D=we.get("WEBGL_lose_context");D&&D.loseContext()},this.forceContextRestore=function(){const D=we.get("WEBGL_lose_context");D&&D.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(D){D!==void 0&&(q=D,this.setSize(z,J,!1))},this.getSize=function(D){return D.set(z,J)},this.setSize=function(D,W,tt=!0){if(ht.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}z=D,J=W,n.width=Math.floor(D*q),n.height=Math.floor(W*q),tt===!0&&(n.style.width=D+"px",n.style.height=W+"px"),this.setViewport(0,0,D,W)},this.getDrawingBufferSize=function(D){return D.set(z*q,J*q).floor()},this.setDrawingBufferSize=function(D,W,tt){z=D,J=W,q=tt,n.width=Math.floor(D*tt),n.height=Math.floor(W*tt),this.setViewport(0,0,D,W)},this.getCurrentViewport=function(D){return D.copy(I)},this.getViewport=function(D){return D.copy(B)},this.setViewport=function(D,W,tt,Y){D.isVector4?B.set(D.x,D.y,D.z,D.w):B.set(D,W,tt,Y),te.viewport(I.copy(B).multiplyScalar(q).round())},this.getScissor=function(D){return D.copy(et)},this.setScissor=function(D,W,tt,Y){D.isVector4?et.set(D.x,D.y,D.z,D.w):et.set(D,W,tt,Y),te.scissor(Z.copy(et).multiplyScalar(q).round())},this.getScissorTest=function(){return Et},this.setScissorTest=function(D){te.setScissorTest(Et=D)},this.setOpaqueSort=function(D){yt=D},this.setTransparentSort=function(D){At=D},this.getClearColor=function(D){return D.copy(ae.getClearColor())},this.setClearColor=function(){ae.setClearColor(...arguments)},this.getClearAlpha=function(){return ae.getClearAlpha()},this.setClearAlpha=function(){ae.setClearAlpha(...arguments)},this.clear=function(D=!0,W=!0,tt=!0){let Y=0;if(D){let H=!1;if(F!==null){const bt=F.texture.format;H=bt===Q1||bt===Z1||bt===K1}if(H){const bt=F.texture.type,Ct=bt===Tr||bt===_l||bt===Qf||bt===Hc||bt===X1||bt===q1,Rt=ae.getClearColor(),Tt=ae.getClearAlpha(),Pt=Rt.r,Vt=Rt.g,It=Rt.b;Ct?(x[0]=Pt,x[1]=Vt,x[2]=It,x[3]=Tt,j.clearBufferuiv(j.COLOR,0,x)):(M[0]=Pt,M[1]=Vt,M[2]=It,M[3]=Tt,j.clearBufferiv(j.COLOR,0,M))}else Y|=j.COLOR_BUFFER_BIT}W&&(Y|=j.DEPTH_BUFFER_BIT),tt&&(Y|=j.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),j.clear(Y)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Mt,!1),n.removeEventListener("webglcontextrestored",Ot,!1),n.removeEventListener("webglcontextcreationerror",Ft,!1),ae.dispose(),jt.dispose(),Le.dispose(),Kt.dispose(),L.dispose(),it.dispose(),xt.dispose(),Ge.dispose(),K.dispose(),Qt.dispose(),ht.dispose(),ht.removeEventListener("sessionstart",Ro),ht.removeEventListener("sessionend",Co),Us.stop()};function Mt(D){D.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),U=!0}function Ot(){console.log("THREE.WebGLRenderer: Context Restored."),U=!1;const D=We.autoReset,W=Ht.enabled,tt=Ht.autoUpdate,Y=Ht.needsUpdate,H=Ht.type;Ut(),We.autoReset=D,Ht.enabled=W,Ht.autoUpdate=tt,Ht.needsUpdate=Y,Ht.type=H}function Ft(D){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",D.statusMessage)}function pe(D){const W=D.target;W.removeEventListener("dispose",pe),gn(W)}function gn(D){Pn(D),Kt.remove(D)}function Pn(D){const W=Kt.get(D).programs;W!==void 0&&(W.forEach(function(tt){Qt.releaseProgram(tt)}),D.isShaderMaterial&&Qt.releaseShaderCache(D))}this.renderBufferDirect=function(D,W,tt,Y,H,bt){W===null&&(W=Qe);const Ct=H.isMesh&&H.matrixWorld.determinant()<0,Rt=Zt(D,W,tt,Y,H);te.setMaterial(Y,Ct);let Tt=tt.index,Pt=1;if(Y.wireframe===!0){if(Tt=wt.getWireframeAttribute(tt),Tt===void 0)return;Pt=2}const Vt=tt.drawRange,It=tt.attributes.position;let oe=Vt.start*Pt,ve=(Vt.start+Vt.count)*Pt;bt!==null&&(oe=Math.max(oe,bt.start*Pt),ve=Math.min(ve,(bt.start+bt.count)*Pt)),Tt!==null?(oe=Math.max(oe,0),ve=Math.min(ve,Tt.count)):It!=null&&(oe=Math.max(oe,0),ve=Math.min(ve,It.count));const Ne=ve-oe;if(Ne<0||Ne===1/0)return;Ge.setup(H,Y,Rt,tt,Tt);let xe,le=Bt;if(Tt!==null&&(xe=gt.get(Tt),le=fe,le.setIndex(xe)),H.isMesh)Y.wireframe===!0?(te.setLineWidth(Y.wireframeLinewidth*De()),le.setMode(j.LINES)):le.setMode(j.TRIANGLES);else if(H.isLine){let Jt=Y.linewidth;Jt===void 0&&(Jt=1),te.setLineWidth(Jt*De()),H.isLineSegments?le.setMode(j.LINES):H.isLineLoop?le.setMode(j.LINE_LOOP):le.setMode(j.LINE_STRIP)}else H.isPoints?le.setMode(j.POINTS):H.isSprite&&le.setMode(j.TRIANGLES);if(H.isBatchedMesh)if(H._multiDrawInstances!==null)nl("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),le.renderMultiDrawInstances(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount,H._multiDrawInstances);else if(we.get("WEBGL_multi_draw"))le.renderMultiDraw(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount);else{const Jt=H._multiDrawStarts,hn=H._multiDrawCounts,Se=H._multiDrawCount,mi=Tt?gt.get(Tt).bytesPerElement:1,Os=Kt.get(Y).currentProgram.getUniforms();for(let ai=0;ai{function bt(){if(Y.forEach(function(Ct){Kt.get(Ct).currentProgram.isReady()&&Y.delete(Ct)}),Y.size===0){H(D);return}setTimeout(bt,10)}we.get("KHR_parallel_shader_compile")!==null?bt():setTimeout(bt,10)})};let bn=null;function fs(D){bn&&bn(D)}function Ro(){Us.stop()}function Co(){Us.start()}const Us=new ew;Us.setAnimationLoop(fs),typeof self<"u"&&Us.setContext(self),this.setAnimationLoop=function(D){bn=D,ht.setAnimationLoop(D),D===null?Us.stop():Us.start()},ht.addEventListener("sessionstart",Ro),ht.addEventListener("sessionend",Co),this.render=function(D,W){if(W!==void 0&&W.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;if(D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),W.parent===null&&W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),ht.enabled===!0&&ht.isPresenting===!0&&(ht.cameraAutoUpdate===!0&&ht.updateCamera(W),W=ht.getCamera()),D.isScene===!0&&D.onBeforeRender(A,D,W,F),y=Le.get(D,w.length),y.init(W),w.push(y),Wt.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),$.setFromProjectionMatrix(Wt),Dt=this.localClippingEnabled,mt=Lt.init(this.clippingPlanes,Dt),S=jt.get(D,E.length),S.init(),E.push(S),ht.enabled===!0&&ht.isPresenting===!0){const bt=A.xr.getDepthSensingMesh();bt!==null&&_a(bt,W,-1/0,A.sortObjects)}_a(D,W,0,A.sortObjects),S.finish(),A.sortObjects===!0&&S.sort(yt,At),qe=ht.enabled===!1||ht.isPresenting===!1||ht.hasDepthSensing()===!1,qe&&ae.addToRenderList(S,D),this.info.render.frame++,mt===!0&&Lt.beginShadows();const tt=y.state.shadowsArray;Ht.render(tt,D,W),mt===!0&&Lt.endShadows(),this.info.autoReset===!0&&this.info.reset();const Y=S.opaque,H=S.transmissive;if(y.setupLights(),W.isArrayCamera){const bt=W.cameras;if(H.length>0)for(let Ct=0,Rt=bt.length;Ct0&&ni(Y,H,D,W),qe&&ae.render(D),Wa(S,D,W);F!==null&&P===0&&(k.updateMultisampleRenderTarget(F),k.updateRenderTargetMipmap(F)),D.isScene===!0&&D.onAfterRender(A,D,W),Ge.resetDefaultState(),C=-1,R=null,w.pop(),w.length>0?(y=w[w.length-1],mt===!0&&Lt.setGlobalState(A.clippingPlanes,y.state.camera)):y=null,E.pop(),E.length>0?S=E[E.length-1]:S=null};function _a(D,W,tt,Y){if(D.visible===!1)return;if(D.layers.test(W.layers)){if(D.isGroup)tt=D.renderOrder;else if(D.isLOD)D.autoUpdate===!0&&D.update(W);else if(D.isLight)y.pushLight(D),D.castShadow&&y.pushShadow(D);else if(D.isSprite){if(!D.frustumCulled||$.intersectsSprite(D)){Y&&re.setFromMatrixPosition(D.matrixWorld).applyMatrix4(Wt);const Ct=xt.update(D),Rt=D.material;Rt.visible&&S.push(D,Ct,Rt,tt,re.z,null)}}else if((D.isMesh||D.isLine||D.isPoints)&&(!D.frustumCulled||$.intersectsObject(D))){const Ct=xt.update(D),Rt=D.material;if(Y&&(D.boundingSphere!==void 0?(D.boundingSphere===null&&D.computeBoundingSphere(),re.copy(D.boundingSphere.center)):(Ct.boundingSphere===null&&Ct.computeBoundingSphere(),re.copy(Ct.boundingSphere.center)),re.applyMatrix4(D.matrixWorld).applyMatrix4(Wt)),Array.isArray(Rt)){const Tt=Ct.groups;for(let Pt=0,Vt=Tt.length;Pt0&&Xa(H,W,tt),bt.length>0&&Xa(bt,W,tt),Ct.length>0&&Xa(Ct,W,tt),te.buffers.depth.setTest(!0),te.buffers.depth.setMask(!0),te.buffers.color.setMask(!0),te.setPolygonOffset(!1)}function ni(D,W,tt,Y){if((tt.isScene===!0?tt.overrideMaterial:null)!==null)return;y.state.transmissionRenderTarget[Y.id]===void 0&&(y.state.transmissionRenderTarget[Y.id]=new yl(1,1,{generateMipmaps:!0,type:we.has("EXT_color_buffer_half_float")||we.has("EXT_color_buffer_float")?uh:Tr,minFilter:yr,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:He.workingColorSpace}));const bt=y.state.transmissionRenderTarget[Y.id],Ct=Y.viewport||I;bt.setSize(Ct.z*A.transmissionResolutionScale,Ct.w*A.transmissionResolutionScale);const Rt=A.getRenderTarget();A.setRenderTarget(bt),A.getClearColor(ct),ft=A.getClearAlpha(),ft<1&&A.setClearColor(16777215,.5),A.clear(),qe&&ae.render(tt);const Tt=A.toneMapping;A.toneMapping=_o;const Pt=Y.viewport;if(Y.viewport!==void 0&&(Y.viewport=void 0),y.setupLightsView(Y),mt===!0&&Lt.setGlobalState(A.clippingPlanes,Y),Xa(D,tt,Y),k.updateMultisampleRenderTarget(bt),k.updateRenderTargetMipmap(bt),we.has("WEBGL_multisampled_render_to_texture")===!1){let Vt=!1;for(let It=0,oe=W.length;It0),It=!!tt.morphAttributes.position,oe=!!tt.morphAttributes.normal,ve=!!tt.morphAttributes.color;let Ne=_o;Y.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(Ne=A.toneMapping);const xe=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,le=xe!==void 0?xe.length:0,Jt=Kt.get(Y),hn=y.state.lights;if(mt===!0&&(Dt===!0||D!==R)){const Un=D===R&&Y.id===C;Lt.setState(Y,D,Un)}let Se=!1;Y.version===Jt.__version?(Jt.needsLights&&Jt.lightsStateVersion!==hn.state.version||Jt.outputColorSpace!==Rt||H.isBatchedMesh&&Jt.batching===!1||!H.isBatchedMesh&&Jt.batching===!0||H.isBatchedMesh&&Jt.batchingColor===!0&&H.colorTexture===null||H.isBatchedMesh&&Jt.batchingColor===!1&&H.colorTexture!==null||H.isInstancedMesh&&Jt.instancing===!1||!H.isInstancedMesh&&Jt.instancing===!0||H.isSkinnedMesh&&Jt.skinning===!1||!H.isSkinnedMesh&&Jt.skinning===!0||H.isInstancedMesh&&Jt.instancingColor===!0&&H.instanceColor===null||H.isInstancedMesh&&Jt.instancingColor===!1&&H.instanceColor!==null||H.isInstancedMesh&&Jt.instancingMorph===!0&&H.morphTexture===null||H.isInstancedMesh&&Jt.instancingMorph===!1&&H.morphTexture!==null||Jt.envMap!==Tt||Y.fog===!0&&Jt.fog!==bt||Jt.numClippingPlanes!==void 0&&(Jt.numClippingPlanes!==Lt.numPlanes||Jt.numIntersection!==Lt.numIntersection)||Jt.vertexAlphas!==Pt||Jt.vertexTangents!==Vt||Jt.morphTargets!==It||Jt.morphNormals!==oe||Jt.morphColors!==ve||Jt.toneMapping!==Ne||Jt.morphTargetsCount!==le)&&(Se=!0):(Se=!0,Jt.__version=Y.version);let mi=Jt.currentProgram;Se===!0&&(mi=Sn(Y,W,H));let Os=!1,ai=!1,Wn=!1;const rn=mi.getUniforms(),Bi=Jt.uniforms;if(te.useProgram(mi.program)&&(Os=!0,ai=!0,Wn=!0),Y.id!==C&&(C=Y.id,ai=!0),Os||R!==D){te.buffers.depth.getReversed()?(_t.copy(D.projectionMatrix),SN(_t),MN(_t),rn.setValue(j,"projectionMatrix",_t)):rn.setValue(j,"projectionMatrix",D.projectionMatrix),rn.setValue(j,"viewMatrix",D.matrixWorldInverse);const xi=rn.map.cameraPosition;xi!==void 0&&xi.setValue(j,ee.setFromMatrixPosition(D.matrixWorld)),Re.logarithmicDepthBuffer&&rn.setValue(j,"logDepthBufFC",2/(Math.log(D.far+1)/Math.LN2)),(Y.isMeshPhongMaterial||Y.isMeshToonMaterial||Y.isMeshLambertMaterial||Y.isMeshBasicMaterial||Y.isMeshStandardMaterial||Y.isShaderMaterial)&&rn.setValue(j,"isOrthographic",D.isOrthographicCamera===!0),R!==D&&(R=D,ai=!0,Wn=!0)}if(H.isSkinnedMesh){rn.setOptional(j,H,"bindMatrix"),rn.setOptional(j,H,"bindMatrixInverse");const Un=H.skeleton;Un&&(Un.boneTexture===null&&Un.computeBoneTexture(),rn.setValue(j,"boneTexture",Un.boneTexture,k))}H.isBatchedMesh&&(rn.setOptional(j,H,"batchingTexture"),rn.setValue(j,"batchingTexture",H._matricesTexture,k),rn.setOptional(j,H,"batchingIdTexture"),rn.setValue(j,"batchingIdTexture",H._indirectTexture,k),rn.setOptional(j,H,"batchingColorTexture"),H._colorsTexture!==null&&rn.setValue(j,"batchingColorTexture",H._colorsTexture,k));const Ci=tt.morphAttributes;if((Ci.position!==void 0||Ci.normal!==void 0||Ci.color!==void 0)&&Gt.update(H,tt,mi),(ai||Jt.receiveShadow!==H.receiveShadow)&&(Jt.receiveShadow=H.receiveShadow,rn.setValue(j,"receiveShadow",H.receiveShadow)),Y.isMeshGouraudMaterial&&Y.envMap!==null&&(Bi.envMap.value=Tt,Bi.flipEnvMap.value=Tt.isCubeTexture&&Tt.isRenderTargetTexture===!1?-1:1),Y.isMeshStandardMaterial&&Y.envMap===null&&W.environment!==null&&(Bi.envMapIntensity.value=W.environmentIntensity),ai&&(rn.setValue(j,"toneMappingExposure",A.toneMappingExposure),Jt.needsLights&&ge(Bi,Wn),bt&&Y.fog===!0&&kt.refreshFogUniforms(Bi,bt),kt.refreshMaterialUniforms(Bi,Y,q,J,y.state.transmissionRenderTarget[D.id]),Ap.upload(j,ii(Jt),Bi,k)),Y.isShaderMaterial&&Y.uniformsNeedUpdate===!0&&(Ap.upload(j,ii(Jt),Bi,k),Y.uniformsNeedUpdate=!1),Y.isSpriteMaterial&&rn.setValue(j,"center",H.center),rn.setValue(j,"modelViewMatrix",H.modelViewMatrix),rn.setValue(j,"normalMatrix",H.normalMatrix),rn.setValue(j,"modelMatrix",H.matrixWorld),Y.isShaderMaterial||Y.isRawShaderMaterial){const Un=Y.uniformsGroups;for(let xi=0,Cl=Un.length;xi0&&k.useMultisampledRTT(D)===!1?H=Kt.get(D).__webglMultisampledFramebuffer:Array.isArray(Vt)?H=Vt[tt]:H=Vt,I.copy(D.viewport),Z.copy(D.scissor),nt=D.scissorTest}else I.copy(B).multiplyScalar(q).floor(),Z.copy(et).multiplyScalar(q).floor(),nt=Et;if(tt!==0&&(H=vn),te.bindFramebuffer(j.FRAMEBUFFER,H)&&Y&&te.drawBuffers(D,H),te.viewport(I),te.scissor(Z),te.setScissorTest(nt),bt){const Tt=Kt.get(D.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_CUBE_MAP_POSITIVE_X+W,Tt.__webglTexture,tt)}else if(Ct){const Tt=Kt.get(D.texture),Pt=W;j.framebufferTextureLayer(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,Tt.__webglTexture,tt,Pt)}else if(D!==null&&tt!==0){const Tt=Kt.get(D.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Tt.__webglTexture,tt)}C=-1},this.readRenderTargetPixels=function(D,W,tt,Y,H,bt,Ct){if(!(D&&D.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Rt=Kt.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&Ct!==void 0&&(Rt=Rt[Ct]),Rt){te.bindFramebuffer(j.FRAMEBUFFER,Rt);try{const Tt=D.texture,Pt=Tt.format,Vt=Tt.type;if(!Re.textureFormatReadable(Pt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Re.textureTypeReadable(Vt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}W>=0&&W<=D.width-Y&&tt>=0&&tt<=D.height-H&&j.readPixels(W,tt,Y,H,me.convert(Pt),me.convert(Vt),bt)}finally{const Tt=F!==null?Kt.get(F).__webglFramebuffer:null;te.bindFramebuffer(j.FRAMEBUFFER,Tt)}}},this.readRenderTargetPixelsAsync=async function(D,W,tt,Y,H,bt,Ct){if(!(D&&D.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Rt=Kt.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&Ct!==void 0&&(Rt=Rt[Ct]),Rt){const Tt=D.texture,Pt=Tt.format,Vt=Tt.type;if(!Re.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Re.textureTypeReadable(Vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(W>=0&&W<=D.width-Y&&tt>=0&&tt<=D.height-H){te.bindFramebuffer(j.FRAMEBUFFER,Rt);const It=j.createBuffer();j.bindBuffer(j.PIXEL_PACK_BUFFER,It),j.bufferData(j.PIXEL_PACK_BUFFER,bt.byteLength,j.STREAM_READ),j.readPixels(W,tt,Y,H,me.convert(Pt),me.convert(Vt),0);const oe=F!==null?Kt.get(F).__webglFramebuffer:null;te.bindFramebuffer(j.FRAMEBUFFER,oe);const ve=j.fenceSync(j.SYNC_GPU_COMMANDS_COMPLETE,0);return j.flush(),await xN(j,ve,4),j.bindBuffer(j.PIXEL_PACK_BUFFER,It),j.getBufferSubData(j.PIXEL_PACK_BUFFER,0,bt),j.deleteBuffer(It),j.deleteSync(ve),bt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(D,W=null,tt=0){D.isTexture!==!0&&(nl("WebGLRenderer: copyFramebufferToTexture function signature has changed."),W=arguments[0]||null,D=arguments[1]);const Y=Math.pow(2,-tt),H=Math.floor(D.image.width*Y),bt=Math.floor(D.image.height*Y),Ct=W!==null?W.x:0,Rt=W!==null?W.y:0;k.setTexture2D(D,0),j.copyTexSubImage2D(j.TEXTURE_2D,tt,0,0,Ct,Rt,H,bt),te.unbindTexture()};const si=j.createFramebuffer(),ya=j.createFramebuffer();this.copyTextureToTexture=function(D,W,tt=null,Y=null,H=0,bt=null){D.isTexture!==!0&&(nl("WebGLRenderer: copyTextureToTexture function signature has changed."),Y=arguments[0]||null,D=arguments[1],W=arguments[2],bt=arguments[3]||0,tt=null),bt===null&&(H!==0?(nl("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),bt=H,H=0):bt=0);let Ct,Rt,Tt,Pt,Vt,It,oe,ve,Ne;const xe=D.isCompressedTexture?D.mipmaps[bt]:D.image;if(tt!==null)Ct=tt.max.x-tt.min.x,Rt=tt.max.y-tt.min.y,Tt=tt.isBox3?tt.max.z-tt.min.z:1,Pt=tt.min.x,Vt=tt.min.y,It=tt.isBox3?tt.min.z:0;else{const Ci=Math.pow(2,-H);Ct=Math.floor(xe.width*Ci),Rt=Math.floor(xe.height*Ci),D.isDataArrayTexture?Tt=xe.depth:D.isData3DTexture?Tt=Math.floor(xe.depth*Ci):Tt=1,Pt=0,Vt=0,It=0}Y!==null?(oe=Y.x,ve=Y.y,Ne=Y.z):(oe=0,ve=0,Ne=0);const le=me.convert(W.format),Jt=me.convert(W.type);let hn;W.isData3DTexture?(k.setTexture3D(W,0),hn=j.TEXTURE_3D):W.isDataArrayTexture||W.isCompressedArrayTexture?(k.setTexture2DArray(W,0),hn=j.TEXTURE_2D_ARRAY):(k.setTexture2D(W,0),hn=j.TEXTURE_2D),j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,W.flipY),j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,W.premultiplyAlpha),j.pixelStorei(j.UNPACK_ALIGNMENT,W.unpackAlignment);const Se=j.getParameter(j.UNPACK_ROW_LENGTH),mi=j.getParameter(j.UNPACK_IMAGE_HEIGHT),Os=j.getParameter(j.UNPACK_SKIP_PIXELS),ai=j.getParameter(j.UNPACK_SKIP_ROWS),Wn=j.getParameter(j.UNPACK_SKIP_IMAGES);j.pixelStorei(j.UNPACK_ROW_LENGTH,xe.width),j.pixelStorei(j.UNPACK_IMAGE_HEIGHT,xe.height),j.pixelStorei(j.UNPACK_SKIP_PIXELS,Pt),j.pixelStorei(j.UNPACK_SKIP_ROWS,Vt),j.pixelStorei(j.UNPACK_SKIP_IMAGES,It);const rn=D.isDataArrayTexture||D.isData3DTexture,Bi=W.isDataArrayTexture||W.isData3DTexture;if(D.isDepthTexture){const Ci=Kt.get(D),Un=Kt.get(W),xi=Kt.get(Ci.__renderTarget),Cl=Kt.get(Un.__renderTarget);te.bindFramebuffer(j.READ_FRAMEBUFFER,xi.__webglFramebuffer),te.bindFramebuffer(j.DRAW_FRAMEBUFFER,Cl.__webglFramebuffer);for(let Ji=0;Ji=2.0 are supported."));return}const d=new sF(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p=0&&u[m]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}d.setExtensions(l),d.setPlugins(u),d.parse(i,a)}parseAsync(t,n){const i=this;return new Promise(function(a,o){i.parse(t,n,a,o)})}}function E8(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Ie={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class w8{constructor(t){this.parser=t,this.name=Ie.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,n=this.parser.json.nodes||[];for(let i=0,a=n.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(t,o.source,l)}}class V8{constructor(t){this.parser=t,this.name=Ie.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,a=i.json,o=a.textures[t];if(!o.extensions||!o.extensions[n])return null;const l=o.extensions[n],u=a.images[l.source];let h=i.textureLoader;if(u.uri){const d=i.options.manager.getHandler(u.uri);d!==null&&(h=d)}return this.detectSupport().then(function(d){if(d)return i.loadTextureImage(t,l.source,h);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){t(n.height===1)}})),this.isSupported}}class G8{constructor(t){this.parser=t,this.name=Ie.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,a=i.json,o=a.textures[t];if(!o.extensions||!o.extensions[n])return null;const l=o.extensions[n],u=a.images[l.source];let h=i.textureLoader;if(u.uri){const d=i.options.manager.getHandler(u.uri);d!==null&&(h=d)}return this.detectSupport().then(function(d){if(d)return i.loadTextureImage(t,l.source,h);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){t(n.height===1)}})),this.isSupported}}class H8{constructor(t){this.name=Ie.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const n=this.parser.json,i=n.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const a=i.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),l=this.parser.options.meshoptDecoder;if(!l||!l.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(u){const h=a.byteOffset||0,d=a.byteLength||0,p=a.count,m=a.byteStride,b=new Uint8Array(u,h,d);return l.decodeGltfBufferAsync?l.decodeGltfBufferAsync(p,m,b,a.mode,a.filter).then(function(_){return _.buffer}):l.ready.then(function(){const _=new ArrayBuffer(p*m);return l.decodeGltfBuffer(new Uint8Array(_),p,m,b,a.mode,a.filter),_})})}else return null}}class j8{constructor(t){this.name=Ie.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const n=this.parser.json,i=n.nodes[t];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const a=n.meshes[i.mesh];for(const d of a.primitives)if(d.mode!==Ys.TRIANGLES&&d.mode!==Ys.TRIANGLE_STRIP&&d.mode!==Ys.TRIANGLE_FAN&&d.mode!==void 0)return null;const l=i.extensions[this.name].attributes,u=[],h={};for(const d in l)u.push(this.parser.getDependency("accessor",l[d]).then(p=>(h[d]=p,h[d])));return u.length<1?null:(u.push(this.parser.createNodeMesh(t)),Promise.all(u).then(d=>{const p=d.pop(),m=p.isGroup?p.children:[p],b=d[0].count,_=[];for(const x of m){const M=new Ee,S=new G,y=new cs,E=new G(1,1,1),w=new $N(x.geometry,x.material,b);for(let A=0;A0||e.search(/^data\:image\/jpeg/)===0?"image/jpeg":e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?"image/webp":e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const iF=new Ee;class sF{constructor(t={},n={}){this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new E8,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,a=-1,o=!1,l=-1;if(typeof navigator<"u"){const u=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(u)===!0;const h=u.match(/Version\/(\d+)/);a=i&&h?parseInt(h[1],10):-1,o=u.indexOf("Firefox")>-1,l=o?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&a<17||o&&l<98?this.textureLoader=new vP(this.options.manager):this.textureLoader=new EP(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new tw(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,n){const i=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(l){return l._markDefs&&l._markDefs()}),Promise.all(this._invokeAll(function(l){return l.beforeRoot&&l.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(l){const u={scene:l[0][a.scene||0],scenes:l[0],animations:l[1],cameras:l[2],asset:a.asset,parser:i,userData:{}};return Jo(o,u,a),vr(u,a),Promise.all(i._invokeAll(function(h){return h.afterRoot&&h.afterRoot(u)})).then(function(){for(const h of u.scenes)h.updateMatrixWorld();t(u)})}).catch(n)}_markDefs(){const t=this.json.nodes||[],n=this.json.skins||[],i=this.json.meshes||[];for(let a=0,o=n.length;a{const h=this.associations.get(l);h!=null&&this.associations.set(u,h);for(const[d,p]of l.children.entries())o(p,u.children[d])};return o(i,a),a.name+="_instance_"+t.uses[n]++,a}_invokeOne(t){const n=Object.values(this.plugins);n.push(this);for(let i=0;i=2&&S.setY(C,O[P*h+1]),h>=3&&S.setZ(C,O[P*h+2]),h>=4&&S.setW(C,O[P*h+3]),h>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}S.normalized=x}return S})}loadTexture(t){const n=this.json,i=this.options,o=n.textures[t].source,l=n.images[o];let u=this.textureLoader;if(l.uri){const h=i.manager.getHandler(l.uri);h!==null&&(u=h)}return this.loadTextureImage(t,o,u)}loadTextureImage(t,n,i){const a=this,o=this.json,l=o.textures[t],u=o.images[n],h=(u.uri||u.bufferView)+":"+l.sampler;if(this.textureCache[h])return this.textureCache[h];const d=this.loadImageSource(n,i).then(function(p){p.flipY=!1,p.name=l.name||u.name||"",p.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(p.name=u.uri);const b=(o.samplers||{})[l.sampler]||{};return p.magFilter=XT[b.magFilter]||As,p.minFilter=XT[b.minFilter]||yr,p.wrapS=qT[b.wrapS]||Da,p.wrapT=qT[b.wrapT]||Da,p.generateMipmaps=!p.isCompressedTexture&&p.minFilter!==Ki&&p.minFilter!==As,a.associations.set(p,{textures:t}),p}).catch(function(){return null});return this.textureCache[h]=d,d}loadImageSource(t,n){const i=this,a=this.json,o=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(m=>m.clone());const l=a.images[t],u=self.URL||self.webkitURL;let h=l.uri||"",d=!1;if(l.bufferView!==void 0)h=i.getDependency("bufferView",l.bufferView).then(function(m){d=!0;const b=new Blob([m],{type:l.mimeType});return h=u.createObjectURL(b),h});else if(l.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const p=Promise.resolve(h).then(function(m){return new Promise(function(b,_){let x=b;n.isImageBitmapLoader===!0&&(x=function(M){const S=new ci(M);S.needsUpdate=!0,b(S)}),n.load(Hf.resolveURL(m,o.path),x,void 0,_)})}).then(function(m){return d===!0&&u.revokeObjectURL(h),vr(m,l),m.userData.mimeType=l.mimeType||nF(l.uri),m}).catch(function(m){throw console.error("THREE.GLTFLoader: Couldn't load texture",h),m});return this.sourceCache[t]=p,p}assignTexture(t,n,i,a){const o=this;return this.getDependency("texture",i.index).then(function(l){if(!l)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(l=l.clone(),l.channel=i.texCoord),o.extensions[Ie.KHR_TEXTURE_TRANSFORM]){const u=i.extensions!==void 0?i.extensions[Ie.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const h=o.associations.get(l);l=o.extensions[Ie.KHR_TEXTURE_TRANSFORM].extendTexture(l,u),o.associations.set(l,h)}}return a!==void 0&&(l.colorSpace=a),t[n]=l,l})}assignFinalMaterial(t){const n=t.geometry;let i=t.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,l=n.attributes.normal===void 0;if(t.isPoints){const u="PointsMaterial:"+i.uuid;let h=this.cache.get(u);h||(h=new K3,Na.prototype.copy.call(h,i),h.color.copy(i.color),h.map=i.map,h.sizeAttenuation=!1,this.cache.add(u,h)),i=h}else if(t.isLine){const u="LineBasicMaterial:"+i.uuid;let h=this.cache.get(u);h||(h=new a_,Na.prototype.copy.call(h,i),h.color.copy(i.color),h.map=i.map,this.cache.add(u,h)),i=h}if(a||o||l){let u="ClonedMaterial:"+i.uuid+":";a&&(u+="derivative-tangents:"),o&&(u+="vertex-colors:"),l&&(u+="flat-shading:");let h=this.cache.get(u);h||(h=i.clone(),o&&(h.vertexColors=!0),l&&(h.flatShading=!0),a&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),this.cache.add(u,h),this.associations.set(h,this.associations.get(i))),i=h}t.material=i}getMaterialType(){return ho}loadMaterial(t){const n=this,i=this.json,a=this.extensions,o=i.materials[t];let l;const u={},h=o.extensions||{},d=[];if(h[Ie.KHR_MATERIALS_UNLIT]){const m=a[Ie.KHR_MATERIALS_UNLIT];l=m.getMaterialType(),d.push(m.extendParams(u,o,n))}else{const m=o.pbrMetallicRoughness||{};if(u.color=new be(1,1,1),u.opacity=1,Array.isArray(m.baseColorFactor)){const b=m.baseColorFactor;u.color.setRGB(b[0],b[1],b[2],Qi),u.opacity=b[3]}m.baseColorTexture!==void 0&&d.push(n.assignTexture(u,"map",m.baseColorTexture,Jn)),u.metalness=m.metallicFactor!==void 0?m.metallicFactor:1,u.roughness=m.roughnessFactor!==void 0?m.roughnessFactor:1,m.metallicRoughnessTexture!==void 0&&(d.push(n.assignTexture(u,"metalnessMap",m.metallicRoughnessTexture)),d.push(n.assignTexture(u,"roughnessMap",m.metallicRoughnessTexture))),l=this._invokeOne(function(b){return b.getMaterialType&&b.getMaterialType(t)}),d.push(Promise.all(this._invokeAll(function(b){return b.extendMaterialParams&&b.extendMaterialParams(t,u)})))}o.doubleSided===!0&&(u.side=os);const p=o.alphaMode||wb.OPAQUE;if(p===wb.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,p===wb.MASK&&(u.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&l!==_i&&(d.push(n.assignTexture(u,"normalMap",o.normalTexture)),u.normalScale=new Ae(1,1),o.normalTexture.scale!==void 0)){const m=o.normalTexture.scale;u.normalScale.set(m,m)}if(o.occlusionTexture!==void 0&&l!==_i&&(d.push(n.assignTexture(u,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&l!==_i){const m=o.emissiveFactor;u.emissive=new be().setRGB(m[0],m[1],m[2],Qi)}return o.emissiveTexture!==void 0&&l!==_i&&d.push(n.assignTexture(u,"emissiveMap",o.emissiveTexture,Jn)),Promise.all(d).then(function(){const m=new l(u);return o.name&&(m.name=o.name),vr(m,o),n.associations.set(m,{materials:t}),o.extensions&&Jo(a,m,o),m})}createUniqueName(t){const n=en.sanitizeNodeName(t||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(t){const n=this,i=this.extensions,a=this.primitiveCache;function o(u){return i[Ie.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,n).then(function(h){return YT(h,u,n)})}const l=[];for(let u=0,h=t.length;u0&&tF(y,o),y.name=n.createUniqueName(o.name||"mesh_"+t),vr(y,o),S.extensions&&Jo(a,y,S),n.assignFinalMaterial(y),m.push(y)}for(let _=0,x=m.length;_1?p=new Wi:d.length===1?p=d[0]:p=new En,p!==d[0])for(let m=0,b=d.length;m{const m=new Map;for(const[b,_]of a.associations)(b instanceof Na||b instanceof ci)&&m.set(b,_);return p.traverse(b=>{const _=a.associations.get(b);_!=null&&m.set(b,_)}),m};return a.associations=d(o),o})}_createAnimationTracks(t,n,i,a,o){const l=[],u=t.name?t.name:t.uuid,h=[];so[o.path]===so.weights?t.traverse(function(b){b.morphTargetInfluences&&h.push(b.name?b.name:b.uuid)}):h.push(u);let d;switch(so[o.path]){case so.weights:d=Yc;break;case so.rotation:d=Kc;break;case so.position:case so.scale:d=Zc;break;default:switch(i.itemSize){case 1:d=Yc;break;case 2:case 3:default:d=Zc;break}break}const p=a.interpolation!==void 0?Q8[a.interpolation]:$f,m=this._getArrayFromAccessor(i);for(let b=0,_=h.length;b<_;b++){const x=new d(h[b]+"."+so[o.path],n.array,m,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),l.push(x)}return l}_getArrayFromAccessor(t){let n=t.array;if(t.normalized){const i=$v(n.constructor),a=new Float32Array(n.length);for(let o=0,l=n.length;o96?A-97:A>64?A-39:A+4}for(var U=0,w=0;w0?M(y,E,w,p[A],d[U]):l.then(function(){var O=new Uint8Array(y*E);return h(o.exports[p[A]],O,y,E,w,o.exports[d[U]]),O})}}})();const ZT=.85,oF=-.52,lF=.75,cF=-.9,uF=-.28,Rf=5,Gi={left:{scale:.43,forwardMul:.018,sideMul:-.012,offsetX:-.008,offsetY:-.012,offsetZ:.006,rotationFine:Rn.degToRad(-2)},right:{scale:.43,forwardMul:.018,sideMul:.012,offsetX:.008,offsetY:-.012,offsetZ:.006,rotationFine:Rn.degToRad(2)}},Cb=[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16],[17,18,19,20]],Sc=.38;class fF{constructor(t,n,i){this.gltfLoader=new A8,this.hasBallModel=!1,this.playerMixer=null,this.playerKickAction=null,this.playerRunAction=null,this.strikerKickBone=null,this.strikerKickRig=null,this.gloveFollowState=new Map,this.gloveLostFrames={left:0,right:0},this.lastGloveLandmarks=null,this.detailedHandLandmarks={left:null,right:null},this.gloveFingerRig={left:null,right:null},this.followGloveFingerBones=!1,this.gloveStaticWrap=!0,this.swapGloveHands=!1,this.gloveTrackingMode="both",this.gloveCalibration={left:{scale:Gi.left.scale,forwardMul:Gi.left.forwardMul,sideMul:Gi.left.sideMul,rotationOffset:Math.PI/2,offsetX:Gi.left.offsetX,offsetY:Gi.left.offsetY,offsetZ:Gi.left.offsetZ,rotationFine:Gi.left.rotationFine},right:{scale:Gi.right.scale,forwardMul:Gi.right.forwardMul,sideMul:Gi.right.sideMul,rotationOffset:-Math.PI/2,offsetX:Gi.right.offsetX,offsetY:Gi.right.offsetY,offsetZ:Gi.right.offsetZ,rotationFine:Gi.right.rotationFine}},this.trailMeshes=[],this.trailCount=20,this.particles=[],this.ballVelocity=new G,this.ballSpin=new G,this.isBallActive=!1,this.isSuperBall=!1,this.ballStartZ=-15,this.catchPlaneZ=-2,this.goalLineZ=-1,this.timeScale=1,this.timeScaleTimer=0,this.animationId=0,this.clock=new RP,this.kickAnimFrame=0,this.kickContactTimer=null,this.difficultyMultiplier=1,this.pendingBallLaunch=!1,this.playerAnimState="idle",this.kickContactRatio=.42,this.onPlayerActionFinished=a=>{const o=a==null?void 0:a.action;if(o){if(this.playerRunAction&&o===this.playerRunAction&&this.playerAnimState==="runup"){this.playKickClip();return}this.playerKickAction&&o===this.playerKickAction&&this.playerAnimState==="kick"&&(this.playerAnimState="idle",this.clearKickContactTimer(),this.pendingBallLaunch=!1)}},this.onWindowResize=()=>{this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight)},this.container=t,this.onSave=n,this.onGoal=i,this.gltfLoader.setMeshoptDecoder(rF),this.scene=new YN,this.camera=new Xi(60,window.innerWidth/window.innerHeight,.1,100),this.camera.position.set(0,1.5,0),this.renderer=new T8({alpha:!0,antialias:!0}),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(this.renderer.domElement),this.setupLights(),this.setupScene(),window.addEventListener("resize",this.onWindowResize),this.animate=this.animate.bind(this),this.animationId=requestAnimationFrame(this.animate)}setupLights(){const t=new AP(16777215,.95);this.scene.add(t);const n=new _P(14676991,9157491,.72);n.position.set(0,16,-4),this.scene.add(n);const i=new Zv(16773846,1.25);i.position.set(-7,12,8),this.scene.add(i);const a=new Zv(11983103,.35);a.position.set(6,7,-6),this.scene.add(a)}setupScene(){this.setupEnvironment();const t=this.createBallTexture(),n=new br(.2,64,64),i=new ma({map:t.diff,bumpMap:t.bump,bumpScale:.005,roughness:.5,metalness:.1,clearcoat:.4,clearcoatRoughness:.2});this.ballFallbackMaterial=i,this.ball=new Oe(n,i);const a=new br(.205,32,32),o=new _i({color:65382,wireframe:!0,transparent:!0,opacity:0});this.ballWire=new Oe(a,o),this.ball.add(this.ballWire),this.ball.position.set(0,.2,this.ballStartZ),this.scene.add(this.ball),this.trailGroup=new Wi;const l=new br(.18,16,16);for(let nt=0;nt{const n=t.scene;this.fitModel(n,.42),n.traverse(i=>{i instanceof Oe&&(i.castShadow=!1,i.receiveShadow=!1)}),this.ball.add(n),this.ballFallbackMaterial.transparent=!0,this.ballFallbackMaterial.opacity=0,this.ballFallbackMaterial.depthWrite=!1,this.hasBallModel=!0},void 0,t=>console.warn("ball.glb failed to load, using fallback ball mesh.",t))}loadPlayerModel(){this.gltfLoader.load("/models/player.glb",t=>{const n=t.scene;n.traverse(a=>{if(!(a instanceof Oe))return;a.frustumCulled=!1,a.castShadow=!1,a.receiveShadow=!1;const o=Array.isArray(a.material)?a.material:[a.material];for(const l of o)l&&("transparent"in l&&(l.transparent=!1),"opacity"in l&&(l.opacity=1),"alphaTest"in l&&(l.alphaTest=0),"depthWrite"in l&&(l.depthWrite=!0),"depthTest"in l&&(l.depthTest=!0),"side"in l&&(l.side=os),l.needsUpdate=!0)}),this.fitModel(n,2,!0),this.striker.add(n),this.strikerBodyFallback.visible=!1,this.strikerKickBone=this.findKickBone(n),this.strikerKickRig=this.findKickRigBones(n),this.playerMixer&&this.playerMixer.removeEventListener("finished",this.onPlayerActionFinished),this.playerMixer=null,this.playerKickAction=null,this.playerRunAction=null,this.playerAnimState="idle";const i=t.animations.filter(a=>a.duration>.05);if(i.length>0){const a=i.find(u=>{const h=u.name.toLowerCase();return h.includes("kick")||h.includes("soccer")||h.includes("shoot")})||i[0],o=i.find(u=>u.name.toLowerCase().includes("run"))||null;this.playerMixer=new VP(n),this.playerMixer.addEventListener("finished",this.onPlayerActionFinished);const l=this.playerMixer.clipAction(a);if(l.clampWhenFinished=!0,l.loop=Uf,l.enabled=!0,this.playerKickAction=l,o){const u=this.playerMixer.clipAction(o);u.loop=Uf,u.clampWhenFinished=!0,u.enabled=!0,this.playerRunAction=u}console.info(`Using player animations: kick=${a.name} (${a.duration.toFixed(2)}s)`+(o?`, run=${o.name} (${o.duration.toFixed(2)}s)`:""))}else console.warn("player.glb has no playable animation clip (duration > 0). Using procedural kick fallback.")},void 0,t=>console.warn("player.glb failed to load, using fallback striker.",t))}loadGloveModel(){this.gltfLoader.load("/models/glove.glb",t=>{const n=KT(t.scene),i=KT(t.scene);this.prepareGloveModel(n,!0),this.prepareGloveModel(i,!1),this.gloveFingerRig.left=this.buildGloveFingerRig(n,!0),this.gloveFingerRig.right=this.buildGloveFingerRig(i,!1),this.leftGlove.clear(),this.rightGlove.clear(),this.leftGlove.add(n),this.rightGlove.add(i)},void 0,t=>console.warn("glove.glb failed to load, using fallback glove meshes.",t))}prepareGloveModel(t,n){t.traverse(d=>{if(!(d instanceof Oe))return;d.castShadow=!1,d.receiveShadow=!1;const p=Array.isArray(d.material)?d.material:[d.material];for(const m of p)m&&("transparent"in m&&(m.transparent=!0),"opacity"in m&&(m.opacity=ZT),"depthWrite"in m&&(m.depthWrite=!0),"depthTest"in m&&(m.depthTest=!0),"side"in m&&(m.side=os),m.needsUpdate=!0);d.renderOrder=30});const a=new ls().setFromObject(t).getSize(new G),l=1/Math.max(a.y,1e-4);t.scale.setScalar(l),n&&(t.scale.x*=-1),t.updateMatrixWorld(!0);const u=new G;let h=!1;if(t.traverse(d=>{if(h||!(d instanceof Xv))return;const p=d.skeleton;if(!p||p.bones.length===0)return;(p.bones.find(b=>!b.parent||b.parent.type!=="Bone")||p.bones[0]).getWorldPosition(u),t.worldToLocal(u),h=!0}),!h){const d=new ls().setFromObject(t);u.set((d.min.x+d.max.x)*.5,d.min.y,(d.min.z+d.max.z)*.5)}t.position.sub(u)}buildGloveFingerRig(t,n){let i=null;if(t.traverse(M=>{i||!(M instanceof Xv)||M.skeleton&&M.skeleton.bones.length>0&&(i=M.skeleton)}),!i)return null;const a=i.bones;if(a.length<5)return null;const o=a.find(M=>!M.parent||M.parent.type!=="Bone")||a[0],l=M=>M.children.filter(S=>S.type==="Bone"),u=a.filter(M=>l(M).length===0);if(u.length===0)return null;const h=[];for(const M of u){const S=[];let y=M;for(;y&&y.type==="Bone"&&(S.push(y),y!==o);)y=y.parent;S[S.length-1]===o&&h.push(S.reverse())}if(h.length===0)return null;let d=0;for(;;){const M=h[0][d];if(!M||!h.every(y=>y[d]===M))break;d+=1}const p=h.map(M=>M.slice(Math.max(1,d-1))).filter(M=>M.length>=2);if(p.length===0)return null;t.updateMatrixWorld(!0);const m=new G,b=p.map(M=>{M[M.length-1].getWorldPosition(m),t.worldToLocal(m);const y=n?-m.x:m.x;return{chain:M,signedX:y,length:M.length}});b.sort((M,S)=>M.signedX-S.signedX||S.length-M.length);const _=b.slice(0,5).map(M=>M.chain);for(;_.length{const S=[];for(let y=0;y{if(i.type!=="Bone")return;const a=i.name.toLowerCase();(!n&&a.includes("right")&&(a.includes("upleg")||a.includes("thigh")||a.includes("leg"))||!n&&(a.includes("leg")||a.includes("thigh")))&&(n=i)}),n}findBoneByAliases(t,n){let i=null;return t.traverse(a=>{if(i||a.type!=="Bone")return;const o=a.name.toLowerCase();n.some(l=>o.includes(l))&&(i=a)}),i}findKickRigBones(t){const n=this.findBoneByAliases(t,["rightupleg","right_thigh","rthigh","mixamorigrightupleg"]),i=this.findBoneByAliases(t,["rightleg","right_calf","rcalf","mixamorigrightleg"]),a=this.findBoneByAliases(t,["rightfoot","rfoot","mixamorigrightfoot"]),o=this.findBoneByAliases(t,["leftupleg","left_thigh","lthigh","mixamorigleftupleg"]),l=this.findBoneByAliases(t,["hips","pelvis","mixamorighips"]),u=this.findBoneByAliases(t,["spine02","spine2"])||this.findBoneByAliases(t,["spine01","spine1"])||this.findBoneByAliases(t,["spine"]);return{hips:l,spine:u,rightUpLeg:n,rightLeg:i,rightFoot:a,leftUpLeg:o}}screenToWorld(t,n,i){const a=Math.abs(this.camera.position.z-i),o=Rn.degToRad(this.camera.fov),l=2*Math.tan(o/2)*a,u=l*this.camera.aspect,h=this.camera.position.x+(t-.5)*u,d=this.camera.position.y-(n-.5)*l;return new G(h,d,i)}handLandmarkToWorld(t){const n=typeof t.z=="number"&&Number.isFinite(t.z)?t.z:0,i=Rn.clamp(oF-n*lF,cF,uF);return this.screenToWorld(1-t.x,t.y,i)}updateGloveLandmarks(t){this.lastGloveLandmarks=t;const n=this.swapGloveHands?this.detailedHandLandmarks.right:this.detailedHandLandmarks.left,i=this.swapGloveHands?this.detailedHandLandmarks.left:this.detailedHandLandmarks.right,a=this.getGlovePoseFromDetailedHand(n,!0),o=this.getGlovePoseFromDetailedHand(i,!1);let l=null,u=null;if(t){const p=this.getGlovePose(t,!0),m=this.getGlovePose(t,!1);l=this.swapGloveHands?m:p,u=this.swapGloveHands?p:m}const h=a??l,d=o??u;if(!h&&!d){this.gloveLostFrames.left+=1,this.gloveLostFrames.right+=1,this.gloveLostFrames.left>Rf&&(this.leftGlove.visible=!1),this.gloveLostFrames.right>Rf&&(this.rightGlove.visible=!1),this.applyGloveFingerRig("left",null),this.applyGloveFingerRig("right",null);return}this.gloveTrackingMode==="both"?h?(this.gloveLostFrames.left=0,this.applyGlovePose(this.leftGlove,h,!0)):(this.gloveLostFrames.left+=1,this.gloveLostFrames.left>Rf&&(this.leftGlove.visible=!1)):(this.gloveLostFrames.left=Rf+1,this.leftGlove.visible=!1),d?(this.gloveLostFrames.right=0,this.applyGlovePose(this.rightGlove,d,!1)):(this.gloveLostFrames.right+=1,this.gloveLostFrames.right>Rf&&(this.rightGlove.visible=!1)),this.applyGloveFingerRig("left",this.followGloveFingerBones?h:null),this.applyGloveFingerRig("right",this.followGloveFingerBones?d:null)}setGloveStaticWrap(t){this.gloveStaticWrap=t}setSwapGloveHands(t){this.swapGloveHands=t}getSwapGloveHands(){return this.swapGloveHands}setGloveTrackingMode(t){this.gloveTrackingMode=t,t==="right-only"&&(this.leftGlove.visible=!1)}getGloveTrackingMode(){return this.gloveTrackingMode}getHandDetectionStatus(t=this.lastGloveLandmarks){if(!t)return{leftDetected:!1,rightDetected:!1};const n=this.pickBestLandmark(t,[15]),i=this.pickBestLandmark(t,[16]),a=!!n&&(n.visibility??1)>=.12,o=!!i&&(i.visibility??1)>=.12;return{leftDetected:a,rightDetected:o}}autoDetectHandMapping(t=this.lastGloveLandmarks){if(!t)return{resolved:!1,swapped:this.swapGloveHands};const n=this.pickBestLandmark(t,[15]),i=this.pickBestLandmark(t,[16]);if(!n||!i)return{resolved:!1,swapped:this.swapGloveHands};if((n.visibility??1)<.15||(i.visibility??1)<.15)return{resolved:!1,swapped:this.swapGloveHands};const a=1-n.x,o=1-i.x;if(Math.abs(o-a)<.06)return{resolved:!1,swapped:this.swapGloveHands};const u=o{if(!m)return;const b=this.gloveCalibration[p];b.scale=Rn.clamp(m.handLength*3.6,.3,.62),h=!0};return d("left",l),d("right",u),h}pickBestLandmark(t,n){let i=null,a=-1;for(const o of n){const l=t[o];if(!l)continue;const u=l.visibility??1;u>a&&(i=l,a=u)}return i}getGlovePoseFromDetailedHand(t,n){if(!t||t.length<21)return null;const i=t[0];if(!i)return null;const a=[t[5],t[9],t[13],t[17]].filter(x=>!!x).filter(x=>(x.visibility??1)>=.04);if(a.length===0)return null;const o=x=>this.handLandmarkToWorld(x),l=o(i),u=a.map(o),h=new G;for(const x of u)h.add(x);h.multiplyScalar(1/u.length);let d=new G().subVectors(h,l);d.lengthSq()<1e-8&&d.set(n?-1:1,0,0),d.normalize();const p=[t[5],t[17]].filter(x=>!!x).filter(x=>(x.visibility??1)>=.04);let m=l.distanceTo(h);if(p.length===2){const x=o(p[0]).distanceTo(o(p[1]));m=Math.max(m,x*.65)}m=Rn.clamp(m,.045,.2);const b=l.clone().multiplyScalar(.34).add(h.clone().multiplyScalar(.66)),_=Math.atan2(d.y,d.x);return{palm:b,dir:d,handLength:m,angle:_}}getGlovePose(t,n){const i=this.pickBestLandmark(t,n?[15]:[16]);if(!i||(i.visibility??1)<.08)return null;const a=this.pickBestLandmark(t,n?[19,17,21]:[20,18,22]),o=this.pickBestLandmark(t,n?[19]:[20]),l=this.pickBestLandmark(t,n?[17]:[18]),u=this.pickBestLandmark(t,n?[21]:[22]),h=this.pickBestLandmark(t,n?[13]:[14]),d=this.pickBestLandmark(t,n?[11]:[12]),p=-.52,m=R=>this.screenToWorld(1-R.x,R.y,p),b=(R,I=.08)=>R&&(R.visibility??1)>=I?m(R):null,_=m(i),x=b(o),M=b(l),S=b(u),y=b(a,.05),E=b(h,.05),w=b(d,.05);let A=new G(n?-1:1,0,0),U=.08,O=!1;const P=[x,M,S].filter(R=>!!R).filter(R=>{const I=R.distanceTo(_);return I>.02&&I<.55});if(P.length>0){const R=new G;for(const nt of P)R.add(nt);R.multiplyScalar(1/P.length);const I=new G().subVectors(R,_),Z=I.length();Z>1e-4&&(A=I.multiplyScalar(1/Z),U=Rn.clamp(Z,.045,.18),O=!0)}if(!O&&E){const R=new G().subVectors(_,E),I=R.length();I>1e-4&&(A=R.multiplyScalar(1/I),U=Rn.clamp(I*.45,.045,.16),O=!0)}if(!O&&w){const R=new G().subVectors(_,w),I=R.length();I>1e-4&&(A=R.multiplyScalar(1/I),U=Rn.clamp(I*.3,.045,.16))}let F=_.clone().addScaledVector(A,U*.18);if(P.length>=2){const R=new G;for(const I of P)R.add(I);R.multiplyScalar(1/P.length),F=_.clone().multiplyScalar(.42).add(R.multiplyScalar(.58))}else y&&F.lerp(y,.2);const C=Math.atan2(A.y,A.x);return{palm:F,dir:A,handLength:U,angle:C}}applyGlovePose(t,n,i){const a=i?"left":"right",o=i?"left":"right",l=this.gloveCalibration[o],u=new G;let h=l.rotationOffset;if(!n)u.set(i?-.18:.18,1.02,-.55);else{u.copy(n.palm).addScaledVector(n.dir,n.handLength*l.forwardMul);const p=new G(-n.dir.y,n.dir.x,0).normalize();u.addScaledVector(p,n.handLength*l.sideMul),h=this.gloveStaticWrap?l.rotationOffset:n.angle+l.rotationOffset}u.x+=l.offsetX,u.y+=l.offsetY,u.z+=l.offsetZ,h+=l.rotationFine;let d=this.gloveFollowState.get(a);if(!d)d={pos:u.clone(),angle:h},this.gloveFollowState.set(a,d);else{const p=d.pos.distanceTo(u),m=p>.12?.5:p>.05?.36:.22;p>8e-4&&d.pos.lerp(u,m);let b=h-d.angle;for(;b>Math.PI;)b-=Math.PI*2;for(;b<-Math.PI;)b+=Math.PI*2;const _=Math.abs(b),x=_>.9?.5:_>.28?.34:.18;_>.0025&&(d.angle+=b*x)}t.visible=!0,t.position.copy(d.pos),t.rotation.set(0,0,d.angle),t.scale.set(l.scale,l.scale,l.scale)}applyGloveFingerRig(t,n){const i=this.gloveFingerRig[t];if(!i||i.length===0)return;const a=this.swapGloveHands?t==="left"?"right":"left":t,o=this.detailedHandLandmarks[a],l=t==="left"?this.leftGlove:this.rightGlove;if(!l.visible||!o||o.length<21||!n){for(const x of i)for(const M of x)M.bone.quaternion.slerp(M.restQuat,Sc);return}l.updateMatrixWorld(!0);const u=new G,h=new G,d=new G,p=new cs,m=new G,b=new cs,_=new cs;for(let x=0;xo[E]).filter(E=>!!E);if(y.length<2){for(const E of M)E.bone.quaternion.slerp(E.restQuat,Sc);continue}for(let E=0;E{this.kickContactTimer=null,this.startBallFlight()},Math.max(0,t))}playKickClip(){if(!this.playerKickAction)return;this.playerAnimState="kick";const t=this.playerKickAction.getClip().duration,n=Math.round(t*this.kickContactRatio*1e3);this.scheduleBallLaunch(n),this.playerKickAction.enabled=!0,this.playerKickAction.clampWhenFinished=!0,this.playerKickAction.reset(),this.playerKickAction.setLoop(Uf,1),this.playerKickAction.fadeIn(.06),this.playerKickAction.play()}shootBall(t,n){this.difficultyMultiplier=t,this.clearKickContactTimer(),this.pendingBallLaunch=!1,this.playerAnimState="idle",this.ball.position.set((Math.random()-.5)*2,.2,this.ballStartZ),this.isBallActive=!1,this.isSuperBall=!1,this.timeScale=1,this.timeScaleTimer=0;const i=this.ballFallbackMaterial,a=this.ballWire.material;this.isSuperBall?(i.color.setHex(16777215),i.emissive.setHex(16711765),i.emissiveIntensity=.8,a.color.setHex(65535),a.opacity=1,this.strikerAura.material.opacity=.5):(i.color.setHex(16777215),i.emissive.setHex(0),i.emissiveIntensity=0,a.opacity=0,this.strikerAura.material.opacity=0);let o=0,l=1.5;const u=Math.abs(this.camera.position.z-this.catchPlaneZ),h=Rn.degToRad(this.camera.fov),d=2*Math.tan(h/2)*u,p=d*this.camera.aspect;if(n!==void 0){let E,w;n===0?(E=.1,w=.35):n===1?(E=.375,w=.625):(E=.65,w=.9);const A=.3,U=.6,O=E+Math.random()*(w-E),P=A+Math.random()*(U-A);o=this.camera.position.x+(O-.5)*p,l=this.camera.position.y-(P-.5)*d}else o=this.camera.position.x+(Math.random()-.5)*p*.8,l=this.camera.position.y+(Math.random()-.5)*d*.6;const m=this.isSuperBall?1.2/t:2/t,b=o-this.ball.position.x,_=l-this.ball.position.y,x=this.catchPlaneZ-this.ball.position.z;this.ballVelocity.set(b/m,_/m,x/m);const M=9.8*.2;this.ballVelocity.y+=M*m/2;const S=15+t*5;this.ballSpin.set((Math.random()-.2)*S,(Math.random()-.5)*S*1.5,(Math.random()-.5)*S*.2);const y=new G().crossVectors(this.ballSpin,this.ballVelocity).multiplyScalar(.015);this.ballVelocity.sub(y.multiplyScalar(m*.5)),this.pendingBallLaunch=!0,this.striker.position.x=this.ball.position.x,this.triggerKickAnimation()}triggerKickAnimation(){var m;if(this.playerMixer&&this.playerKickAction){(m=this.playerRunAction)==null||m.stop(),this.playerKickAction.stop(),this.playerRunAction?(this.playerAnimState="runup",this.playerRunAction.enabled=!0,this.playerRunAction.clampWhenFinished=!0,this.playerRunAction.reset(),this.playerRunAction.setLoop(Uf,1),this.playerRunAction.fadeIn(.05),this.playerRunAction.play()):this.playKickClip();return}this.startBallFlight(),this.kickAnimFrame&&cancelAnimationFrame(this.kickAnimFrame);const t=performance.now(),n=480,i=this.striker.rotation.x,a=this.striker.position.y,o=this.strikerKickBone,l=o?o.rotation.x:0,u=this.strikerKickRig,h=["hips","spine","rightUpLeg","rightLeg","rightFoot","leftUpLeg"],d=new Map;if(u)for(const b of h){const _=u[b];_&&d.set(b,_.rotation.clone())}const p=b=>{const _=Math.min(1,(b-t)/n),x=Rn.clamp(_/.32,0,1),M=Rn.clamp((_-.32)/.34,0,1),S=Rn.clamp((_-.66)/.34,0,1),y=x*x,E=M<.5?2*M*M:1-Math.pow(-2*M+2,2)/2,w=S<.5?2*S*S:1-Math.pow(-2*S+2,2)/2,A=y*(1-w)+E*(1-w);if(this.striker.position.y=a+Math.sin(_*Math.PI)*.4,u&&d.size>0){const U=u.hips,O=u.spine,P=u.rightUpLeg,F=u.rightLeg,C=u.rightFoot,R=u.leftUpLeg,I=d.get("hips");U&&I&&(U.rotation.x=I.x-.2*y+.14*E-.06*w,U.rotation.y=I.y+.06*E);const Z=d.get("spine");O&&Z&&(O.rotation.x=Z.x+.18*y-.12*E+.05*w);const nt=d.get("rightUpLeg");P&&nt&&(P.rotation.x=nt.x+.75*y-1.25*E+.35*w,P.rotation.y=nt.y-.08*E);const ct=d.get("rightLeg");F&&ct&&(F.rotation.x=ct.x-.95*y+1.05*E-.15*w);const ft=d.get("rightFoot");C&&ft&&(C.rotation.x=ft.x+.35*E-.08*w);const z=d.get("leftUpLeg");R&&z&&(R.rotation.x=z.x+.2*A)}else this.striker.rotation.x=i+Math.sin(_*Math.PI*2)*.2,o&&(o.rotation.x=l-Math.sin(_*Math.PI)*1);if(_<1)this.kickAnimFrame=requestAnimationFrame(p);else if(this.striker.position.y=a,this.striker.rotation.x=i,u&&d.size>0)for(const[U,O]of d.entries()){const P=u[U];P&&P.rotation.copy(O)}else o&&(o.rotation.x=l)};this.kickAnimFrame=requestAnimationFrame(p)}animate(){this.animationId=requestAnimationFrame(this.animate);const t=this.clock.getDelta();this.playerMixer&&this.playerMixer.update(t),this.timeScaleTimer>0&&(this.timeScaleTimer-=t,this.timeScaleTimer<=0?this.timeScale=1:this.timeScale=Math.min(1,.25+(4-this.timeScaleTimer)*.25));const n=t*this.timeScale;if(this.isBallActive){const i=1.9600000000000002;this.ballVelocity.y-=i*n;const a=new G().crossVectors(this.ballSpin,this.ballVelocity).multiplyScalar(.015);if(this.ballVelocity.addScaledVector(a,n),this.ball.position.addScaledVector(this.ballVelocity,n),this.ball.rotateX(this.ballSpin.x*n),this.ball.rotateY(this.ballSpin.y*n),this.ball.rotateZ(this.ballSpin.z*n),this.isSuperBall){this.ball.scale.set(1+Math.random()*.3,1+Math.random()*.3,1+Math.random()*.3);for(let o=this.trailCount-1;o>0;o--)this.trailMeshes[o].position.copy(this.trailMeshes[o-1].position),this.trailMeshes[o].position.x+=(Math.random()-.5)*.4,this.trailMeshes[o].position.y+=(Math.random()-.5)*.4,this.trailMeshes[o].visible=this.trailMeshes[o-1].visible,this.trailMeshes[o].material.opacity=1-o/this.trailCount,this.trailMeshes[o].material.color.setHSL(Math.random(),1,.5);this.trailMeshes[0].position.copy(this.ball.position),this.trailMeshes[0].visible=!0,this.trailMeshes[0].material.opacity=1,this.trailMeshes[0].material.color.setHex(65535)}else{this.ball.scale.set(1,1,1);for(let o=0;othis.catchPlaneZ+.5){this.isBallActive=!1,this.strikerAura.material.opacity=0,this.ball.scale.set(1,1,1);for(let o=0;o-2.9&&this.ball.position.x<2.9&&this.ball.position.y>0&&this.ball.position.y<2.9?(this.onGoal(),this.triggerExplosion(this.ball.position,this.isSuperBall)):this.onSave()}}for(let i=this.particles.length-1;i>=0;i--){const a=this.particles[i];if(a.life-=n*1.5,a.life<=0){this.particleGroup.remove(a.mesh),this.particles.splice(i,1);continue}a.mesh.position.addScaledVector(a.velocity,n),a.mesh.rotation.x+=n*5,a.mesh.rotation.y+=n*5,a.velocity.y-=9.8*n,a.isSuper&&a.mesh.scale.multiplyScalar(1+n),a.mesh.material.opacity=a.life}this.renderer.render(this.scene,this.camera)}hideTrails(){for(let t=0;t{n.beginPath();for(let m=0;m<5;m++){const b=m/5*Math.PI*2-Math.PI/2,_=d+Math.cos(b)*55,x=p+Math.sin(b)*55;m===0?n.moveTo(_,x):n.lineTo(_,x)}n.closePath(),n.fill()});const a=new ip(t);a.colorSpace=Jn;const o=document.createElement("canvas");o.width=512,o.height=512;const l=o.getContext("2d");l.fillStyle="#808080",l.fillRect(0,0,512,512);const u=l.getImageData(0,0,512,512);for(let d=0;d{l.beginPath();for(let m=0;m<5;m++){const b=m/5*Math.PI*2-Math.PI/2,_=d+Math.cos(b)*57,x=p+Math.sin(b)*57;m===0?l.moveTo(_,x):l.lineTo(_,x)}l.closePath(),l.stroke();for(let m=0;m<5;m++){const b=m/5*Math.PI*2-Math.PI/2,_=d+Math.cos(b)*57,x=p+Math.sin(b)*57,M=d+Math.cos(b)*110,S=p+Math.sin(b)*110;l.beginPath(),l.moveTo(_,x),l.lineTo(M,S),l.stroke()}});const h=new ip(o);return{diff:a,bump:h}}createGrassTexture(){const t=document.createElement("canvas");t.width=1024,t.height=1024;const n=t.getContext("2d"),i=n.createLinearGradient(0,0,0,t.height);i.addColorStop(0,"#3c8e3a"),i.addColorStop(1,"#2c6d2f"),n.fillStyle=i,n.fillRect(0,0,t.width,t.height);const a=14;for(let l=0;l.45?"rgba(210,255,190,0.10)":"rgba(20,50,20,0.12)",n.fillRect(u,h,d,d)}const o=new ip(t);return o.colorSpace=Jn,o}createStadiumSeatTexture(){const t=document.createElement("canvas");t.width=1024,t.height=512;const n=t.getContext("2d"),i=n.createLinearGradient(0,0,0,t.height);i.addColorStop(0,"#6f8aa8"),i.addColorStop(1,"#4d627b"),n.fillStyle=i,n.fillRect(0,0,t.width,t.height);const a=28;for(let l=12;l.74;n.fillStyle=h?"rgba(255, 240, 198, 0.78)":"rgba(80, 108, 138, 0.85)",n.fillRect(u,l+3,10,a-12)}}const o=new ip(t);return o.colorSpace=Jn,o}getBallScreenPosition(){if(!this.isBallActive||this.ball.position.zthis.catchPlaneZ+1)return null;const t=this.ball.position.clone();return t.project(this.camera),{x:(t.x+1)/2,y:(-t.y+1)/2,zDepth:this.ball.position.z}}getGloveScreenPosition(t){const n=t==="left"?this.leftGlove:this.rightGlove;if(!n.visible)return null;const i=n.position.clone().project(this.camera);return{x:(i.x+1)/2,y:(-i.y+1)/2}}getActiveDefensePoints(){const t=this.getGloveScreenPosition("right"),n=this.getGloveScreenPosition("left");if(this.gloveTrackingMode==="right-only")return t?[t]:[];const i=[];return n&&i.push(n),t&&i.push(t),i}triggerParticleSave(){this.triggerExplosion(this.ball.position,this.isSuperBall),this.ball.visible=!1,setTimeout(()=>this.ball.visible=!0,500)}triggerExplosion(t,n){const i=n?100:30,a=n?65535:16776960;for(let o=0;o>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&a=56320&&o<=57343){t=1024*(t-55296)+o-56320+65536,i[n++]=t>>18|240,i[n++]=t>>12&63|128,i[n++]=t>>6&63|128,i[n++]=63&t|128;continue}a--}t=65533}i[n++]=t>>12|224,i[n++]=t>>6&63|128}i[n++]=63&t|128}}e=n===i.length?i:i.subarray(0,n)}return e}function fw(e){Qc.setTimeout((()=>{throw e}),0)}var t1,mF=cw(610401301,!1),JT=cw(748402147,!0);function $T(){var e=Qc.navigator;return e&&(e=e.userAgent)?e:""}const tA=Qc.navigator;function cm(e){return cm[" "](e),e}t1=tA&&tA.userAgentData||null,cm[" "]=function(){};const hw={};let Ff=null;function gF(e){const t=e.length;let n=3*t/4;n%3?n=Math.floor(n):"=.".indexOf(e[t-1])!=-1&&(n="=.".indexOf(e[t-2])!=-1?n-2:n-1);const i=new Uint8Array(n);let a=0;return(function(o,l){function u(d){for(;h>4),m!=64&&(l(p<<4&240|m>>2),b!=64&&l(m<<6&192|b))}})(e,(function(o){i[a++]=o})),a!==n?i.subarray(0,a):i}function dw(){if(!Ff){Ff={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let n=0;n<5;n++){const i=e.concat(t[n].split(""));hw[n]=i;for(let a=0;a0)&&($T().indexOf("Trident")!=-1||$T().indexOf("MSIE")!=-1))&&typeof btoa=="function";const eA=/[-_.]/g,vF={"-":"+",_:"/",".":"="};function _F(e){return vF[e]||""}function mw(e){if(!pw)return gF(e);e=eA.test(e)?e.replace(eA,_F):e,e=atob(e);const t=new Uint8Array(e.length);for(let n=0;n=t||(n[e]=i+1,bw(e=Error(),"incident"),fw(e))}}function pu(){return typeof BigInt=="function"}var mu=typeof Symbol=="function"&&typeof Symbol()=="symbol";function za(e,t,n=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?n&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t}var SF=za("jas",void 0,!0),nA=za(void 0,"0di"),Cf=za(void 0,"1oa"),Es=za(void 0,Symbol()),MF=za(void 0,"0ub"),TF=za(void 0,"0ubs"),n1=za(void 0,"0ubsb"),AF=za(void 0,"0actk"),tu=za("m_m","Pa",!0),iA=za();const vw={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},_w=Object.defineProperties,ne=mu?SF:"Ga";var El;const sA=[];function dh(e,t){mu||ne in e||_w(e,vw),e[ne]|=t}function pi(e,t){mu||ne in e||_w(e,vw),e[ne]=t}function ph(e){return dh(e,34),e}function nh(e){return dh(e,8192),e}pi(sA,7),El=Object.freeze(sA);var eu={};function Cs(e,t){return t===void 0?e.h!==Ml&&!!(2&(0|e.v[ne])):!!(2&t)&&e.h!==Ml}const Ml={};function b_(e,t){if(e!=null){if(typeof e=="string")e=e?new Pa(e,Jc):Sl();else if(e.constructor!==Pa)if(m_(e))e=e.length?new Pa(new Uint8Array(e),Jc):Sl();else{if(!t)throw Error();e=void 0}}return e}class aA{constructor(t,n,i){this.g=t,this.h=n,this.l=i}next(){const t=this.g.next();return t.done||(t.value=this.h.call(this.l,t.value)),t}[Symbol.iterator](){return this}}var EF=Object.freeze({});function yw(e,t,n){const i=128&t?0:-1,a=e.length;var o;(o=!!a)&&(o=(o=e[a-1])!=null&&typeof o=="object"&&o.constructor===Object);const l=a+(o?-1:0);for(t=128&t?1:0;ttypeof e=="number")),rA=um((e=>typeof e=="string")),RF=um((e=>typeof e=="boolean")),fm=typeof Qc.BigInt=="function"&&typeof Qc.BigInt(0)=="bigint";function ws(e){var t=e;if(rA(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(wF(t)&&!Number.isSafeInteger(t))throw Error(String(t));return fm?BigInt(e):e=RF(e)?e?"1":"0":rA(e)?e.trim()||"0":String(e)}var i1=um((e=>fm?e>=DF&&e<=NF:e[0]==="-"?oA(e,CF):oA(e,LF)));const CF=Number.MIN_SAFE_INTEGER.toString(),DF=fm?BigInt(Number.MIN_SAFE_INTEGER):void 0,LF=Number.MAX_SAFE_INTEGER.toString(),NF=fm?BigInt(Number.MAX_SAFE_INTEGER):void 0;function oA(e,t){if(e.length>t.length)return!1;if(e.lengtha)return!1;if(i>>0;Cn=t,$n=(e-t)/4294967296>>>0}function nu(e){if(e<0){lA(-e);const[t,n]=y_(Cn,$n);Cn=t>>>0,$n=n>>>0}else lA(e)}function v_(e){const t=UF||(UF=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),$n=0,Cn=t.getUint32(0,!0)}function Sw(e,t){const n=4294967296*t+(e>>>0);return Number.isSafeInteger(n)?n:ih(e,t)}function OF(e,t){return ws(pu()?BigInt.asUintN(64,(BigInt(t>>>0)<>>0)):ih(e,t))}function Mw(e,t){return pu()?ws(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(t))<>>=0,(t>>>=0)<=2097151)var n=""+(4294967296*t+e);else pu()?n=""+(BigInt(t)<>>24|t<<8))+6710656*(t=t>>16&65535),n+=8147497*t,t*=2,e>=1e7&&(n+=e/1e7>>>0,e%=1e7),n>=1e7&&(t+=n/1e7>>>0,n%=1e7),n=t+cA(n)+cA(e));return n}function cA(e){return e=String(e),"0000000".slice(e.length)+e}function __(e,t){if(2147483648&t)if(pu())e=""+(BigInt(0|t)<>>0));else{const[n,i]=y_(e,t);e="-"+ih(n,i)}else e=ih(e,t);return e}function hm(e){if(e.length<16)nu(Number(e));else if(pu())e=BigInt(e),Cn=Number(e&BigInt(4294967295))>>>0,$n=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+(e[0]==="-");$n=Cn=0;const n=e.length;for(let i=t,a=(n-t)%6+t;a<=n;i=a,a+=6){const o=Number(e.slice(i,a));$n*=1e6,Cn=1e6*Cn+o,Cn>=4294967296&&($n+=Math.trunc(Cn/4294967296),$n>>>=0,Cn>>>=0)}if(t){const[i,a]=y_(Cn,$n);Cn=i,$n=a}}}function y_(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function da(e){return Array.prototype.slice.call(e)}const mh=typeof BigInt=="function"?BigInt.asIntN:void 0,FF=typeof BigInt=="function"?BigInt.asUintN:void 0,Tl=Number.isSafeInteger,dm=Number.isFinite,iu=Math.trunc,IF=ws(0);function If(e){if(e!=null&&typeof e!="number")throw Error(`Value of float/double field must be a number, found ${typeof e}: ${e}`);return e}function La(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function sh(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}function Tw(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}const kF=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function gh(e){switch(typeof e){case"bigint":return!0;case"number":return dm(e);case"string":return kF.test(e);default:return!1}}function bu(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return dm(e)?0|e:void 0}function Aw(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return dm(e)?e>>>0:void 0}function Ew(e){const t=e.length;return(e[0]==="-"?t<20||t===20&&e<="-9223372036854775808":t<19||t===19&&e<="9223372036854775807")?e:(hm(e),__(Cn,$n))}function x_(e){if(e=iu(e),!Tl(e)){nu(e);var t=Cn,n=$n;(e=2147483648&n)&&(n=~n>>>0,(t=1+~t>>>0)==0&&(n=n+1>>>0)),e=typeof(t=Sw(t,n))=="number"?e?-t:t:e?"-"+t:t}return e}function ww(e){var t=iu(Number(e));return Tl(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Ew(e))}function Rw(e){var t=iu(Number(e));return Tl(t)?ws(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),pu()?ws(mh(64,BigInt(e))):ws(Ew(e)))}function Cw(e){return Tl(e)?e=ws(x_(e)):(e=iu(e),Tl(e)?e=String(e):(nu(e),e=__(Cn,$n)),e=ws(e)),e}function jp(e){const t=typeof e;return e==null?e:t==="bigint"?ws(mh(64,e)):gh(e)?t==="string"?Rw(e):Cw(e):void 0}function Dw(e){if(typeof e!="string")throw Error();return e}function bh(e){if(e!=null&&typeof e!="string")throw Error();return e}function Ri(e){return e==null||typeof e=="string"?e:void 0}function S_(e,t,n,i){return e!=null&&e[tu]===eu?e:Array.isArray(e)?((i=(n=0|e[ne])|32&i|2&i)!==n&&pi(e,i),new t(e)):(n?2&i?((e=t[nA])||(ph((e=new t).v),e=t[nA]=e),t=e):t=new t:t=void 0,t)}function BF(e,t,n){if(t)t:{if(!gh(t=e))throw e1("int64");switch(typeof t){case"string":t=Rw(t);break t;case"bigint":t=ws(mh(64,t));break t;default:t=Cw(t)}}else t=jp(e);return(e=t)==null?n?IF:void 0:e}const zF={};let VF=(function(){try{return cm(new class extends Map{constructor(){super()}}),!1}catch{return!0}})();class Lb{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,n){return this.g.set(t,n),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,n){return this.g.forEach(t,n)}[Symbol.iterator](){return this.entries()}}const GF=VF?(Object.setPrototypeOf(Lb.prototype,Map.prototype),Object.defineProperties(Lb.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Lb):class extends Map{constructor(){super()}};function uA(e){return e}function Nb(e){if(2&e.J)throw Error("Cannot mutate an immutable Map")}var Ar=class extends GF{constructor(e,t,n=uA,i=uA){super(),this.J=0|e[ne],this.K=t,this.S=n,this.fa=this.K?HF:i;for(let a=0;a{e.call(t,a.get(i),i,a)})):super.forEach(e,t)}set(e,t){return Nb(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.fa(t,!0,!0,this.K,!1,this.J))}Ma(e){const t=this.S(e[0],!1,!0);e=e[1],e=this.K?e===void 0?null:e:this.fa(e,!1,!0,void 0,!1,this.J),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);const t=super.get(e);if(t!==void 0){var n=this.K;return n?((n=this.fa(t,!1,!0,n,this.ra,this.J))!==t&&super.set(e,n),n):t}}[Symbol.iterator](){return this.entries()}};function HF(e,t,n,i,a,o){return e=S_(e,i,n,o),a&&(e=T_(e)),e}function jF(e){return[e,this.get(e)]}let WF;function fA(){return WF||(WF=new Ar(ph([]),void 0,void 0,void 0,zF))}function pm(e){return Es?e[Es]:void 0}function Wp(e,t){for(const n in e)!isNaN(n)&&t(e,+n,e[n])}Ar.prototype.toJSON=void 0;var s1=class{};const XF={Ka:!0};function qF(e,t){t<100||$c(TF,1)}function mm(e,t,n,i){const a=i!==void 0;i=!!i;var o,l=Es;!a&&mu&&l&&(o=e[l])&&Wp(o,qF),l=[];var u=e.length;let h;o=4294967295;let d=!1;const p=!!(64&t),m=p?128&t?0:-1:void 0;1&t||(h=u&&e[u-1],h!=null&&typeof h=="object"&&h.constructor===Object?o=--u:h=void 0,!p||128&t||a||(d=!0,o=o-m+m)),t=void 0;for(var b=0;b=o){const x=b-m;(t??(t={}))[x]=_}else l[b]=_}if(h)for(let _ in h){if((u=h[_])==null||(u=n(u,i))==null)continue;let x;b=+_,p&&!Number.isNaN(b)&&(x=b+m){x[S]=da(y)})),x.da=_.da,x})(e)),l}function YF(e){return e[0]=ah(e[0]),e[1]=ah(e[1]),e}function ah(e){switch(typeof e){case"number":return Number.isFinite(e)?e:""+e;case"bigint":return i1(e)?Number(e):""+e;case"boolean":return e?1:0;case"object":if(Array.isArray(e)){var t=0|e[ne];return e.length===0&&1&t?void 0:mm(e,t,ah)}if(e!=null&&e[tu]===eu)return Lw(e);if(e instanceof Pa){if((t=e.g)==null)e="";else if(typeof t=="string")e=t;else{if(pw){for(var n="",i=0,a=t.length-10240;i>2];o=n[(3&o)<<4|l>>4],l=n[(15&l)<<2|u>>6],u=n[63&u],i[p++]=h+o+l+u}switch(h=0,u=a,t.length-d){case 2:u=n[(15&(h=t[d+1]))<<2]||a;case 1:t=t[d],i[p]=n[t>>2]+n[(3&t)<<4|h>>4]+u+a}t=i.join("")}e=e.g=t}return e}return e instanceof Ar?e=e.size!==0?e.V(YF):void 0:void 0}return e}let KF,ZF;function Lw(e){return mm(e=e.v,0|e[ne],ah)}function hl(e,t){return Nw(e,t[0],t[1])}function Nw(e,t,n,i=0){if(e==null){var a=32;n?(e=[n],a|=128):e=[],t&&(a=-16760833&a|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error("narr");if(a=0|e[ne],JT&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&(function(){if(JT)throw Error("carr");$c(AF,5)})(),256&a)throw Error("farr");if(64&a)return(a|i)!==a&&pi(e,a|i),e;if(n&&(a|=128,n!==e[0]))throw Error("mid");t:{a|=64;var o=(n=e).length;if(o){var l=o-1;const h=n[l];if(h!=null&&typeof h=="object"&&h.constructor===Object){if((l-=t=128&a?0:-1)>=1024)throw Error("pvtlmt");for(var u in h)(o=+u)1024)throw Error("spvt");a=-16760833&a|(1023&u)<<14}}}return pi(e,64|a|i),e}function QF(e,t){if(typeof e!="object")return e;if(Array.isArray(e)){var n=0|e[ne];return e.length===0&&1&n?void 0:hA(e,n,t)}if(e!=null&&e[tu]===eu)return dA(e);if(e instanceof Ar){if(2&(t=e.J))return e;if(!e.size)return;if(n=ph(e.V()),e.K)for(e=0;e=o)if(l=e[o],l!=null&&typeof l=="object"&&l.constructor===Object)n=l[t],u=!0;else{if(a!==o)return;n=l}else n=e[a];if(i&&n!=null){if((i=i(n))==null)return i;if(!Object.is(i,n))return u?l[t]=i:e[a]=i,i}return n}}function fn(e,t,n,i){yu(e),ui(e=e.v,0|e[ne],t,n,i)}function ui(e,t,n,i,a){const o=n+(a?0:-1);var l=e.length-1;if(l>=1+(a?0:-1)&&o>=l){const u=e[l];if(u!=null&&typeof u=="object"&&u.constructor===Object)return u[n]=i,t}return o<=l?(e[o]=i,t):(i!==void 0&&(n>=(l=(t??(t=0|e[ne]))>>14&1023||536870912)?i!=null&&(e[l+(a?0:-1)]={[n]:i}):e[o]=i),t)}function ll(){return EF===void 0?2:4}function cl(e,t,n,i,a){let o=e.v,l=0|o[ne];i=Cs(e,l)?1:i,a=!!a||i===3,i===2&&_u(e)&&(o=e.v,l=0|o[ne]);let u=(e=E_(o,t))===El?7:0|e[ne],h=w_(u,l);var d=!(4&h);if(d){4&h&&(e=da(e),u=0,h=pl(h,l),l=ui(o,l,t,e));let p=0,m=0;for(;p{const u=S_(l,n,!1,t);return o=u!==l&&u!=null,u})))!=null)return o&&!Cs(i)&&wl(e,t),i}function Ze(e,t,n,i){let a=e.v,o=0|a[ne];if((t=kw(a,o,t,n,i))==null)return t;if(o=0|a[ne],!Cs(e,o)){const l=T_(t);l!==t&&(_u(e)&&(a=e.v,o=0|a[ne]),o=ui(a,o,n,t=l,i),wl(a,o))}return t}function Bw(e,t,n,i,a,o,l,u){var h=Cs(e,n);o=h?1:o,l=!!l||o===3,h=u&&!h,(o===2||h)&&_u(e)&&(n=0|(t=e.v)[ne]);var d=(e=E_(t,a))===El?7:0|e[ne],p=w_(d,n);if(u=!(4&p)){var m=e,b=n;const _=!!(2&p);_&&(b|=2);let x=!_,M=!0,S=0,y=0;for(;S32)for(a|=(127&n)>>4,o=3;o<32&&128&n;o+=7)n=l[u++],a|=(127&n)<>>0,a>>>0);throw Error()}function U_(e){let t=0,n=e.g;const i=n+10,a=e.h;for(;n>>0}function qp(e){var t=e.h;const n=e.g;var i=t[n],a=t[n+1];const o=t[n+2];return t=t[n+3],ml(e,e.g+4),e=2*((a=(i<<0|a<<8|o<<16|t<<24)>>>0)>>31)+1,i=a>>>23&255,a&=8388607,i==255?a?NaN:e*(1/0):i==0?1401298464324817e-60*e*a:e*Math.pow(2,i-150)*(a+8388608)}function JF(e){return So(e)}function ml(e,t){if(e.g=t,t>e.l)throw Error()}function Vw(e,t){if(t<0)throw Error();const n=e.g;if((t=n+t)>e.l)throw Error();return e.g=t,n}function Gw(e,t){if(t==0)return Sl();var n=Vw(e,t);return e.Y&&e.j?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?new Uint8Array(0):PF?e.slice(n,t):new Uint8Array(e.subarray(n,t))),n.length==0?Sl():new Pa(n,Jc)}var pA=[];function Hw(e,t,n,i){if(Yp.length){const a=Yp.pop();return a.o(i),a.g.init(e,t,n,i),a}return new $F(e,t,n,i)}function jw(e){e.g.clear(),e.l=-1,e.h=-1,Yp.length<100&&Yp.push(e)}function Ww(e){var t=e.g;if(t.g==t.l)return!1;e.m=e.g.g;var n=Fa(e.g);if(t=n>>>3,!((n&=7)>=0&&n<=5)||t<1)throw Error();return e.l=t,e.h=n,!0}function Ep(e){switch(e.h){case 0:e.h!=0?Ep(e):U_(e.g);break;case 1:ml(e=e.g,e.g+8);break;case 2:if(e.h!=2)Ep(e);else{var t=Fa(e.g);ml(e=e.g,e.g+t)}break;case 5:ml(e=e.g,e.g+4);break;case 3:for(t=e.l;;){if(!Ww(e))throw Error();if(e.h==4){if(e.l!=t)throw Error();break}Ep(e)}break;default:throw Error()}}function vh(e,t,n){const i=e.g.l;var a=Fa(e.g);let o=(a=e.g.g+a)-i;if(o<=0&&(e.g.l=a,n(t,e,void 0,void 0,void 0),o=a-e.g.g),o)throw Error();return e.g.g=a,e.g.l=i,t}function O_(e){var t=Fa(e.g),n=Vw(e=e.g,t);if(e=e.h,hF){var i,a=e;(i=Db)||(i=Db=new TextDecoder("utf-8",{fatal:!0})),t=n+t,a=n===0&&t===a.length?a:a.subarray(n,t);try{var o=i.decode(a)}catch(u){if(lp===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),lp=!0}catch{lp=!1}}throw!lp&&(Db=void 0),u}}else{t=(o=n)+t,n=[];let u,h=null;for(;o=t?$o():(u=e[o++],l<194||(192&u)!=128?(o--,$o()):n.push((31&l)<<6|63&u)):l<240?o>=t-1?$o():(u=e[o++],(192&u)!=128||l===224&&u<160||l===237&&u>=160||(192&(i=e[o++]))!=128?(o--,$o()):n.push((15&l)<<12|(63&u)<<6|63&i)):l<=244?o>=t-2?$o():(u=e[o++],(192&u)!=128||u-144+(l<<28)>>30!=0||(192&(i=e[o++]))!=128||(192&(a=e[o++]))!=128?(o--,$o()):(l=(7&l)<<18|(63&u)<<12|(63&i)<<6|63&a,l-=65536,n.push(55296+(l>>10&1023),56320+(1023&l)))):$o(),n.length>=8192&&(h=QT(h,n),n.length=0)}o=QT(h,n)}return o}function Xw(e){const t=Fa(e.g);return Gw(e.g,t)}function bm(e,t,n){var i=Fa(e.g);for(i=e.g.g+i;e.g.g>>0,this.g=t>>>0}};let tI;function gA(e){return e?/^-?\d+$/.test(e)?(hm(e),new r1(Cn,$n)):null:eI||(eI=new r1(0,0))}var r1=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let eI;function kc(e,t,n){for(;n>0||t>127;)e.g.push(127&t|128),t=(t>>>7|n<<25)>>>0,n>>>=7;e.g.push(t)}function Su(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function vm(e,t){if(t>=0)Su(e,t);else{for(let n=0;n<9;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function F_(e){var t=Cn;e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function su(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function $s(e,t,n){Su(e.g,8*t+n)}function I_(e,t){return $s(e,t,2),t=e.g.end(),su(e,t),t.push(e.h),t}function k_(e,t){var n=t.pop();for(n=e.h+e.g.length()-n;n>127;)t.push(127&n|128),n>>>=7,e.h++;t.push(n),e.h++}function _m(e,t,n){$s(e,t,2),Su(e.g,n.length),su(e,e.g.end()),su(e,n)}function Kp(e,t,n,i){n!=null&&(t=I_(e,t),i(n,e),k_(e,t))}function Va(){const e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var B_=Va(),qw=Va(),z_=Va(),V_=Va(),G_=Va(),Yw=Va(),nI=Va(),ym=Va(),Kw=Va(),Zw=Va();function Ga(e,t,n){var i=e.v;Es&&Es in i&&(i=i[Es])&&delete i[t.g],t.h?t.j(e,t.h,t.g,n,t.l):t.j(e,t.g,n,t.l)}var ie=class{constructor(e,t){this.v=Nw(e,t,void 0,2048)}toJSON(){return Lw(this)}j(){var a;var e=II,t=this.v,n=e.g,i=Es;if(mu&&i&&((a=t[i])==null?void 0:a[n])!=null&&$c(MF,3),t=e.g,iA&&Es&&iA===void 0&&(i=(n=this.v)[Es])&&(i=i.da))try{i(n,t,XF)}catch(o){fw(o)}return e.h?e.m(this,e.h,e.g,e.l):e.m(this,e.g,e.defaultValue,e.l)}clone(){const e=this.v,t=0|e[ne];return A_(this,e,t)?M_(this,e,!0):new this.constructor(vu(e,t,!1))}};ie.prototype[tu]=eu,ie.prototype.toString=function(){return this.v.toString()};var Mu=class{constructor(e,t,n){this.g=e,this.h=t,e=B_,this.l=!!e&&n===e||!1}};function xm(e,t){return new Mu(e,t,B_)}function Qw(e,t,n,i,a){Kp(e,n,eR(t,i),a)}const iI=xm((function(e,t,n,i,a){return e.h===2&&(vh(e,D_(t,i,n),a),!0)}),Qw),sI=xm((function(e,t,n,i,a){return e.h===2&&(vh(e,D_(t,i,n),a),!0)}),Qw);var Sm=Symbol(),Mm=Symbol(),o1=Symbol(),bA=Symbol(),vA=Symbol();let Jw,$w;function Rl(e,t,n,i){var a=i[e];if(a)return a;(a={}).qa=i,a.T=(function(m){switch(typeof m){case"boolean":return KF||(KF=[0,void 0,!0]);case"number":return m>0?void 0:m===0?ZF||(ZF=[0,void 0]):[-m,void 0];case"string":return[0,m];case"object":return m}})(i[0]);var o=i[1];let l=1;o&&o.constructor===Object&&(a.ba=o,typeof(o=i[++l])=="function"&&(a.ma=!0,Jw??(Jw=o),$w??($w=i[l+1]),o=i[l+=2]));const u={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var h=0;ha(o,l,u,i):a}function j_(e,t,n,i,a){const o=n.g;let l,u;e[t]=(h,d,p)=>o(h,d,p,u||(u=Rl(Mm,H_,j_,i).T),l||(l=W_(i)),a)}function W_(e){let t=e[o1];if(t!=null)return t;const n=Rl(Mm,H_,j_,e);return t=n.ma?(i,a)=>Jw(i,a,n):(i,a)=>{for(;Ww(a)&&a.h!=4;){var o=a.l,l=n[o];if(l==null){var u=n.ba;u&&(u=u[o])&&(u=rI(u))!=null&&(l=n[o]=u)}if(l==null||!l(a,i,o)){if(l=(u=a).m,Ep(u),u.ha)var h=void 0;else h=u.g.g-l,u.g.g=l,h=Gw(u.g,h);l=void 0,u=i,h&&((l=u[Es]??(u[Es]=new s1))[o]??(l[o]=[])).push(h)}}return(i=pm(i))&&(i.da=n.qa[vA]),!0},e[o1]=t,e[vA]=aI.bind(e),t}function aI(e,t,n,i){var a=this[Mm];const o=this[o1],l=hl(void 0,a.T),u=pm(e);if(u){var h=!1,d=a.ba;if(d){if(a=(p,m,b)=>{if(b.length!==0)if(d[m])for(const _ of b){p=Hw(_);try{h=!0,o(l,p)}finally{jw(p)}}else i==null||i(e,m,b)},t==null)Wp(u,a);else if(u!=null){const p=u[t];p&&a(u,t,p)}if(h){let p=0|e[ne];if(2&p&&2048&p&&!(n!=null&&n.Ka))throw Error();const m=gu(p),b=(_,x)=>{if(Er(e,_,m)!=null){if((n==null?void 0:n.Qa)===1)return;throw Error()}x!=null&&(p=ui(e,p,_,x,m)),delete u[_]};t==null?yw(l,0|l[ne],((_,x)=>{b(_,x)})):b(t,Er(l,t,m))}}}}function rI(e){const t=(e=tR(e))[0].g;if(e=e[1]){const n=W_(e),i=Rl(Mm,H_,j_,e).T;return(a,o,l)=>t(a,o,l,i,n)}return t}function Tm(e,t,n){e[t]=n.h}function Am(e,t,n,i){let a,o;const l=n.h;e[t]=(u,h,d)=>l(u,h,d,o||(o=Rl(Sm,Tm,Am,i).T),a||(a=nR(i)))}function nR(e){let t=e[bA];if(!t){const n=Rl(Sm,Tm,Am,e);t=(i,a)=>iR(i,a,n),e[bA]=t}return t}function iR(e,t,n){yw(e,0|e[ne],((i,a)=>{if(a!=null){var o=(function(l,u){var h=l[u];if(h)return h;if((h=l.ba)&&(h=h[u])){var d=(h=tR(h))[0].h;if(h=h[1]){const p=nR(h),m=Rl(Sm,Tm,Am,h).T;h=l.ma?$w(m,p):(b,_,x)=>d(b,_,x,m,p)}else h=d;return l[u]=h}})(n,i);o?o(t,a,i):i<500||$c(n1,3)}})),(e=pm(e))&&Wp(e,((i,a,o)=>{for(su(t,t.g.end()),i=0;i{Kp(e,n,hl([l,o],i),a)}));else if(Array.isArray(t)){for(let o=0;o>BigInt(32))),kc(e.g,n.h,n.g);break;default:n=gA(t),kc(e.g,n.h,n.g)}}function rR(e,t,n){(t=bu(t))!=null&&t!=null&&($s(e,n,0),vm(e.g,t))}function oR(e,t,n){(t=Tw(t))!=null&&($s(e,n,0),e.g.g.push(t?1:0))}function lR(e,t,n){(t=Ri(t))!=null&&_m(e,n,uw(t))}function cR(e,t,n,i,a){Kp(e,n,eR(t,i),a)}function uR(e,t,n){(t=t==null||typeof t=="string"||t instanceof Pa?t:void 0)!=null&&_m(e,n,N_(t,!0).buffer)}function fR(e,t,n){(t=Aw(t))!=null&&t!=null&&($s(e,n,0),Su(e.g,t))}function hR(e,t,n){return(e.h===5||e.h===2)&&(t=xu(t,0|t[ne],n),e.h==2?bm(e,qp,t):t.push(qp(e.g)),!0)}var ti=Ii((function(e,t,n){return e.h===5&&(ki(t,n,qp(e.g)),!0)}),sR,ym),cI=Au(hR,(function(e,t,n){if((t=Tu(La,t))!=null)for(let l=0;l=0?i=String(a):((a=i.indexOf("."))!==-1&&(i=i.substring(0,a)),(a=i[0]!=="-"&&((a=i.length)<20||a===20&&i<="18446744073709551615"))||(hm(i),i=ih(Cn,$n))),i;if(a==="number")return(i=iu(i))>=0&&Tl(i)||(nu(i),i=Sw(Cn,$n)),i}})(t),t!=null&&(typeof t=="string"&&mA(t),t!=null))switch($s(e,n,0),typeof t){case"number":e=e.g,nu(t),kc(e,Cn,$n);break;case"bigint":n=BigInt.asUintN(64,t),n=new a1(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),kc(e.g,n.h,n.g);break;default:n=mA(t),kc(e.g,n.h,n.g)}}),nI),li=Ii((function(e,t,n){return e.h===0&&(ki(t,n,So(e.g)),!0)}),rR,V_),_h=Au((function(e,t,n){return(e.h===0||e.h===2)&&(t=xu(t,0|t[ne],n),e.h==2?bm(e,So,t):t.push(So(e.g)),!0)}),(function(e,t,n){if((t=Tu(bu,t))!=null&&t.length){n=I_(e,n);for(let i=0;i{{const o={ea:!0};i&&Object.assign(o,i),n=Hw(n,void 0,void 0,o);try{const l=new e,u=l.v;W_(t)(u,n);var a=l}finally{jw(n)}}return a}}function Em(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const l=this.g;return this.g=[],l}}}};iR(this.v,t,Rl(Sm,Tm,Am,e)),su(t,t.g.end());const n=new Uint8Array(t.h),i=t.l,a=i.length;let o=0;for(let l=0;la;n=xA.createPolicy("goog#html",{createHTML:i,createScript:i,createScriptURL:i})}catch{}return n})()),e=(t=Ob)?t.createScriptURL(e):e,new class{constructor(n){this.g=n}toString(){return this.g+""}}(e)}function cp(e,...t){if(t.length===0)return SA(e[0]);let n=e[0];for(let i=0;i({index:Zs(i,1)??0??-1,score:Gn(i,2)??0,categoryName:Ri(Dn(i,3))??""??"",displayName:Ri(Dn(i,4))??""??""}))),headIndex:t,headName:n}}function VI(e){const t={classifications:wr(e,SI,1).map((n=>{var i;return ty(((i=Ze(n,xR,4))==null?void 0:i.g())??[],Zs(n,2)??0,Ri(Dn(n,3))??"")}))};return(function(n){return n==null?n:typeof n=="bigint"?(i1(n)?n=Number(n):(n=mh(64,n),n=i1(n)?Number(n):String(n)),n):gh(n)?typeof n=="number"?x_(n):ww(n):void 0})(Dn(e,2,void 0,void 0,jp))!=null&&(t.timestampMs=YR(Dn(e,2,void 0,void 0,jp)??Pw)),t}function KR(e){var l,u;var t=cl(e,3,La,ll()),n=cl(e,2,bu,ll()),i=cl(e,1,Ri,ll()),a=cl(e,9,Ri,ll());const o={categories:[],keypoints:[]};for(let h=0;ht>127?t-256:t))}function UA(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let n=0,i=0,a=0;for(let o=0;o=1&&Number(e[1])>=17))}async function OA(e){if(typeof importScripts!="function"){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((n,i)=>{t.addEventListener("load",(()=>{n()}),!1),t.addEventListener("error",(a=>{i(a)}),!1),document.body.appendChild(t)}))}try{importScripts(e.toString())}catch(t){if(!(t instanceof TypeError))throw t;{const n=self.import;n?await n(e.toString()):await import(e.toString())}}}function JR(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function se(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function FA(e,t,n){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(n?e.i._bindTextureToStream(n):e.i._bindTextureToCanvas(),!(n=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1);const[i,a]=JR(t);return!e.l||i===e.i.canvas.width&&a===e.i.canvas.height||(e.i.canvas.width=i,e.i.canvas.height=a),[i,a]}function IA(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const i=new Uint32Array(t.length);for(let a=0;a>2),n(t);for(const a of i)e.i._free(a);e.i._free(t)}function Aa(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function ro(e,t,n){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(a,o,l)=>{o?(n(i,l),i=[]):i.push(a)}}Ac.forVisionTasks=function(e,t=!1){return fp("vision",e??cp``,t)},Ac.forTextTasks=function(e,t=!1){return fp("text",e??cp``,t)},Ac.forGenAiTasks=function(e,t=!1){return fp("genai",e??cp``,t)},Ac.forAudioTasks=function(e,t=!1){return fp("audio",e??cp``,t)},Ac.isSimdSupported=function(e=!1){return ZR(e)};async function HI(e,t,n,i){return e=await(async(a,o,l,u,h)=>{if(o&&await OA(o),!self.ModuleFactory||l&&(await OA(l),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&h&&((o=self.Module).locateFile=h.locateFile,h.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=h.mainScriptUrlOrBlob)),h=await self.ModuleFactory(self.Module||h),self.ModuleFactory=self.Module=void 0,new a(h,u)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile:a=>a.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&a.endsWith(".data")?n.assetBinaryPath.toString():a}),await e.o(i),e}function kb(e,t){const n=Ze(e.baseOptions,Zp,1)||new Zp;typeof t=="string"?(fn(n,2,bh(t)),fn(n,1)):t instanceof Uint8Array&&(fn(n,1,b_(t,!1)),fn(n,2)),de(e.baseOptions,0,1,n)}function kA(e){try{const t=e.H.length;if(t===1)throw Error(e.H[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.H.map((n=>n.message)).join(", "))}finally{e.H=[]}}function Yt(e,t){e.C=Math.max(e.C,t)}function Dm(e,t){e.B=new us,Ds(e.B,2,"PassThroughCalculator"),wn(e.B,"free_memory"),je(e.B,"free_memory_unused_out"),Nn(t,"free_memory"),ta(t,e.B)}function au(e,t){wn(e.B,t),je(e.B,t+"_unused_out")}function Lm(e){e.g.addBoolToStream(!0,"free_memory",e.C)}var h1=class{constructor(e){this.g=e,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){var n,i,a,o,l,u;if(t){const h=e.baseOptions||{};if((n=e.baseOptions)!=null&&n.modelAssetBuffer&&((i=e.baseOptions)!=null&&i.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((a=Ze(this.baseOptions,Zp,1))!=null&&a.g()||(o=Ze(this.baseOptions,Zp,1))!=null&&o.l()||(l=e.baseOptions)!=null&&l.modelAssetBuffer||(u=e.baseOptions)!=null&&u.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if((function(d,p){let m=Ze(d.baseOptions,CA,3);if(!m){var b=m=new CA,_=new MA;jf(b,4,wp,_)}"delegate"in p&&(p.delegate==="GPU"?(p=m,b=new mI,jf(p,2,wp,b)):(p=m,b=new MA,jf(p,4,wp,b))),de(d.baseOptions,0,3,m)})(this,h),h.modelAssetPath)return fetch(h.modelAssetPath.toString()).then((d=>{if(d.ok)return d.arrayBuffer();throw Error(`Failed to fetch model: ${h.modelAssetPath} (${d.status})`)})).then((d=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(d),!0,!1,!1),kb(this,"/model.dat"),this.m(),this.L()}));if(h.modelAssetBuffer instanceof Uint8Array)kb(this,h.modelAssetBuffer);else if(h.modelAssetBuffer)return(async function(d){const p=[];for(var m=0;;){const{done:b,value:_}=await d.read();if(b)break;p.push(_),m+=_.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];d=new Uint8Array(m),m=0;for(const b of p)d.set(b,m),m+=b.length;return d})(h.modelAssetBuffer).then((d=>{kb(this,d),this.m(),this.L()}))}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let e;if(this.g.ca((t=>{e=gI(t)})),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener(((n,i)=>{this.H.push(Error(i))})),this.g.Ja(),this.g.setGraph(e,t),this.B=void 0,kA(this)}finishProcessing(){this.g.finishProcessing(),kA(this)}close(){this.B=void 0,this.g.closeGraph()}};function yo(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}h1.prototype.close=h1.prototype.close;class jI{constructor(t,n,i,a){this.g=t,this.h=n,this.m=i,this.l=a}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function BA(e,t,n){const i=e.g;if(n=yo(i.createShader(n),"Failed to create WebGL shader"),i.shaderSource(n,t),i.compileShader(n),!i.getShaderParameter(n,i.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${i.getShaderInfoLog(n)}`);return i.attachShader(e.h,n),n}function zA(e,t){const n=e.g,i=yo(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(i);const a=yo(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,a),n.enableVertexAttribArray(e.O),n.vertexAttribPointer(e.O,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const o=yo(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,o),n.enableVertexAttribArray(e.L),n.vertexAttribPointer(e.L,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new jI(n,i,a,o)}function ey(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function WI(e,t,n,i){return ey(e,t),e.h||(e.m(),e.D()),n?(e.u||(e.u=zA(e,!0)),n=e.u):(e.A||(e.A=zA(e,!1)),n=e.A),t.useProgram(e.h),n.bind(),e.l(),e=i(),n.g.bindVertexArray(null),e}function $R(e,t,n){return ey(e,t),e=yo(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),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,n??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function t4(e,t,n){ey(e,t),e.B||(e.B=yo(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.B),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}function XI(e){var t;(t=e.g)==null||t.bindFramebuffer(e.g.FRAMEBUFFER,null)}var e4=class{H(){return` precision mediump float; varying vec2 vTex; uniform sampler2D inputTexture; void main() { gl_FragColor = texture2D(inputTexture, vTex); } `}m(){const e=this.g;if(this.h=yo(e.createProgram(),"Failed to create WebGL program"),this.X=BA(this,` attribute vec2 aVertex; attribute vec2 aTex; varying vec2 vTex; void main(void) { gl_Position = vec4(aVertex, 0.0, 1.0); vTex = aTex; }`,e.VERTEX_SHADER),this.W=BA(this,this.H(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.O=e.getAttribLocation(this.h,"aVertex"),this.L=e.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.X),e.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function _r(e,t){switch(t){case 0:return e.g.find((n=>n instanceof Uint8Array));case 1:return e.g.find((n=>n instanceof Float32Array));case 2:return e.g.find((n=>typeof WebGLTexture<"u"&&n instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function d1(e){var t=_r(e,1);if(!t){if(t=_r(e,0))t=new Float32Array(t).map((i=>i/255));else{t=new Float32Array(e.width*e.height);const i=ru(e);var n=ny(e);if(t4(n,i,n4(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){n=new Float32Array(e.width*e.height*4),i.readPixels(0,0,e.width,e.height,i.RGBA,i.FLOAT,n);for(let a=0,o=0;aMath.round(255*n)))),e.g.push(t)),t;var e,t}ia(){return d1(this)}N(){return n4(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof Uint8Array)n=new Uint8Array(t);else if(t instanceof Float32Array)n=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const i=ru(this),a=ny(this);i.activeTexture(i.TEXTURE1),n=$R(a,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,n);const o=i4(this);i.texImage2D(i.TEXTURE_2D,0,o,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),t4(a,i,n),WI(a,i,!1,(()=>{s4(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),p1(this)})),XI(a),p1(this)}}e.push(n)}return new vi(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&ru(this).deleteTexture(_r(this,2)),VA=-1}};vi.prototype.close=vi.prototype.close,vi.prototype.clone=vi.prototype.clone,vi.prototype.getAsWebGLTexture=vi.prototype.N,vi.prototype.getAsFloat32Array=vi.prototype.ia,vi.prototype.getAsUint8Array=vi.prototype.ja,vi.prototype.hasWebGLTexture=vi.prototype.R,vi.prototype.hasFloat32Array=vi.prototype.ka,vi.prototype.hasUint8Array=vi.prototype.Fa;var VA=250;function ga(...e){return e.map((([t,n])=>({start:t,end:n})))}const qI=(function(e){return class extends e{Ja(){this.i._registerModelResourcesGraphService()}}})((GA=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:QR()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){const n=e.length,i=this.i._malloc(n);this.i.HEAPU8.set(e,i),t?this.i._changeBinaryGraph(n,i):this.i._changeTextGraph(n,i),this.i._free(i)}configureAudio(e,t,n,i,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),se(this,i||"input_audio",(o=>{se(this,a=a||"audio_header",(l=>{this.i._configureAudio(o,l,e,t??0,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ca(e){Aa(this,"__graph_config__",(t=>{e(t)})),se(this,"__graph_config__",(t=>{this.i._getGraphConfig(t,void 0)})),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,n){this.addAudioToStreamWithShape(e,0,0,t,n)}addAudioToStreamWithShape(e,t,n,i,a){const o=4*e.length;this.h!==o&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(o),this.h=o),this.i.HEAPF32.set(e,this.g/4),se(this,i,(l=>{this.i._addAudioToInputStream(this.g,t,n,l,a)}))}addGpuBufferToStream(e,t,n){se(this,t,(i=>{const[a,o]=FA(this,e,i);this.i._addBoundTextureToStream(i,a,o,n)}))}addBoolToStream(e,t,n){se(this,t,(i=>{this.i._addBoolToInputStream(e,i,n)}))}addDoubleToStream(e,t,n){se(this,t,(i=>{this.i._addDoubleToInputStream(e,i,n)}))}addFloatToStream(e,t,n){se(this,t,(i=>{this.i._addFloatToInputStream(e,i,n)}))}addIntToStream(e,t,n){se(this,t,(i=>{this.i._addIntToInputStream(e,i,n)}))}addUintToStream(e,t,n){se(this,t,(i=>{this.i._addUintToInputStream(e,i,n)}))}addStringToStream(e,t,n){se(this,t,(i=>{se(this,e,(a=>{this.i._addStringToInputStream(a,i,n)}))}))}addStringRecordToStream(e,t,n){se(this,t,(i=>{IA(this,Object.keys(e),(a=>{IA(this,Object.values(e),(o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(e).length,i,n)}))}))}))}addProtoToStream(e,t,n,i){se(this,n,(a=>{se(this,t,(o=>{const l=this.i._malloc(e.length);this.i.HEAPU8.set(e,l),this.i._addProtoToInputStream(l,e.length,o,a,i),this.i._free(l)}))}))}addEmptyPacketToStream(e,t){se(this,e,(n=>{this.i._addEmptyPacketToInputStream(n,t)}))}addBoolVectorToStream(e,t,n){se(this,t,(i=>{const a=this.i._allocateBoolVector(e.length);if(!a)throw Error("Unable to allocate new bool vector on heap.");for(const o of e)this.i._addBoolVectorEntry(a,o);this.i._addBoolVectorToInputStream(a,i,n)}))}addDoubleVectorToStream(e,t,n){se(this,t,(i=>{const a=this.i._allocateDoubleVector(e.length);if(!a)throw Error("Unable to allocate new double vector on heap.");for(const o of e)this.i._addDoubleVectorEntry(a,o);this.i._addDoubleVectorToInputStream(a,i,n)}))}addFloatVectorToStream(e,t,n){se(this,t,(i=>{const a=this.i._allocateFloatVector(e.length);if(!a)throw Error("Unable to allocate new float vector on heap.");for(const o of e)this.i._addFloatVectorEntry(a,o);this.i._addFloatVectorToInputStream(a,i,n)}))}addIntVectorToStream(e,t,n){se(this,t,(i=>{const a=this.i._allocateIntVector(e.length);if(!a)throw Error("Unable to allocate new int vector on heap.");for(const o of e)this.i._addIntVectorEntry(a,o);this.i._addIntVectorToInputStream(a,i,n)}))}addUintVectorToStream(e,t,n){se(this,t,(i=>{const a=this.i._allocateUintVector(e.length);if(!a)throw Error("Unable to allocate new unsigned int vector on heap.");for(const o of e)this.i._addUintVectorEntry(a,o);this.i._addUintVectorToInputStream(a,i,n)}))}addStringVectorToStream(e,t,n){se(this,t,(i=>{const a=this.i._allocateStringVector(e.length);if(!a)throw Error("Unable to allocate new string vector on heap.");for(const o of e)se(this,o,(l=>{this.i._addStringVectorEntry(a,l)}));this.i._addStringVectorToInputStream(a,i,n)}))}addBoolToInputSidePacket(e,t){se(this,t,(n=>{this.i._addBoolToInputSidePacket(e,n)}))}addDoubleToInputSidePacket(e,t){se(this,t,(n=>{this.i._addDoubleToInputSidePacket(e,n)}))}addFloatToInputSidePacket(e,t){se(this,t,(n=>{this.i._addFloatToInputSidePacket(e,n)}))}addIntToInputSidePacket(e,t){se(this,t,(n=>{this.i._addIntToInputSidePacket(e,n)}))}addUintToInputSidePacket(e,t){se(this,t,(n=>{this.i._addUintToInputSidePacket(e,n)}))}addStringToInputSidePacket(e,t){se(this,t,(n=>{se(this,e,(i=>{this.i._addStringToInputSidePacket(i,n)}))}))}addProtoToInputSidePacket(e,t,n){se(this,n,(i=>{se(this,t,(a=>{const o=this.i._malloc(e.length);this.i.HEAPU8.set(e,o),this.i._addProtoToInputSidePacket(o,e.length,a,i),this.i._free(o)}))}))}addBoolVectorToInputSidePacket(e,t){se(this,t,(n=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const a of e)this.i._addBoolVectorEntry(i,a);this.i._addBoolVectorToInputSidePacket(i,n)}))}addDoubleVectorToInputSidePacket(e,t){se(this,t,(n=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const a of e)this.i._addDoubleVectorEntry(i,a);this.i._addDoubleVectorToInputSidePacket(i,n)}))}addFloatVectorToInputSidePacket(e,t){se(this,t,(n=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const a of e)this.i._addFloatVectorEntry(i,a);this.i._addFloatVectorToInputSidePacket(i,n)}))}addIntVectorToInputSidePacket(e,t){se(this,t,(n=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const a of e)this.i._addIntVectorEntry(i,a);this.i._addIntVectorToInputSidePacket(i,n)}))}addUintVectorToInputSidePacket(e,t){se(this,t,(n=>{const i=this.i._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(const a of e)this.i._addUintVectorEntry(i,a);this.i._addUintVectorToInputSidePacket(i,n)}))}addStringVectorToInputSidePacket(e,t){se(this,t,(n=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const a of e)se(this,a,(o=>{this.i._addStringVectorEntry(i,o)}));this.i._addStringVectorToInputSidePacket(i,n)}))}attachBoolListener(e,t){Aa(this,e,t),se(this,e,(n=>{this.i._attachBoolListener(n)}))}attachBoolVectorListener(e,t){ro(this,e,t),se(this,e,(n=>{this.i._attachBoolVectorListener(n)}))}attachIntListener(e,t){Aa(this,e,t),se(this,e,(n=>{this.i._attachIntListener(n)}))}attachIntVectorListener(e,t){ro(this,e,t),se(this,e,(n=>{this.i._attachIntVectorListener(n)}))}attachUintListener(e,t){Aa(this,e,t),se(this,e,(n=>{this.i._attachUintListener(n)}))}attachUintVectorListener(e,t){ro(this,e,t),se(this,e,(n=>{this.i._attachUintVectorListener(n)}))}attachDoubleListener(e,t){Aa(this,e,t),se(this,e,(n=>{this.i._attachDoubleListener(n)}))}attachDoubleVectorListener(e,t){ro(this,e,t),se(this,e,(n=>{this.i._attachDoubleVectorListener(n)}))}attachFloatListener(e,t){Aa(this,e,t),se(this,e,(n=>{this.i._attachFloatListener(n)}))}attachFloatVectorListener(e,t){ro(this,e,t),se(this,e,(n=>{this.i._attachFloatVectorListener(n)}))}attachStringListener(e,t){Aa(this,e,t),se(this,e,(n=>{this.i._attachStringListener(n)}))}attachStringVectorListener(e,t){ro(this,e,t),se(this,e,(n=>{this.i._attachStringVectorListener(n)}))}attachProtoListener(e,t,n){Aa(this,e,t),se(this,e,(i=>{this.i._attachProtoListener(i,n||!1)}))}attachProtoVectorListener(e,t,n){ro(this,e,t),se(this,e,(i=>{this.i._attachProtoVectorListener(i,n||!1)}))}attachAudioListener(e,t,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Aa(this,e,((i,a)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,a)})),se(this,e,(i=>{this.i._attachAudioListener(i,n||!1)}))}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends GA{get ga(){return this.i}pa(e,t,n){se(this,t,(i=>{const[a,o]=FA(this,e,i);this.ga._addBoundTextureAsImageToStream(i,a,o,n)}))}Z(e,t){Aa(this,e,t),se(this,e,(n=>{this.ga._attachImageListener(n)}))}aa(e,t){ro(this,e,t),se(this,e,(n=>{this.ga._attachImageVectorListener(n)}))}}));var GA,ba=class extends qI{};async function Xe(e,t,n){return(async function(i,a,o,l){return HI(i,a,o,l)})(e,n.canvas??(QR()?void 0:document.createElement("canvas")),t,n)}function a4(e,t,n,i){if(e.U){const o=new ER;if(n!=null&&n.regionOfInterest){if(!e.oa)throw Error("This task doesn't support region-of-interest.");var a=n.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(a.left<0||a.top<0||a.right>1||a.bottom>1)throw Error("Expected RectF values to be in [0,1].");ue(o,1,(a.left+a.right)/2),ue(o,2,(a.top+a.bottom)/2),ue(o,4,a.right-a.left),ue(o,3,a.bottom-a.top)}else ue(o,1,.5),ue(o,2,.5),ue(o,4,1),ue(o,3,1);if(n!=null&&n.rotationDegrees){if((n==null?void 0:n.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90ยฐ.");if(ue(o,5,-Math.PI*n.rotationDegrees/180),(n==null?void 0:n.rotationDegrees)%180!=0){const[l,u]=JR(t);n=Gn(o,3)*u/l,a=Gn(o,4)*l/u,ue(o,4,n),ue(o,3,a)}}e.g.addProtoToStream(o.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.pa(t,e.X,i??performance.now()),e.finishProcessing()}function va(e,t,n){var i;if((i=e.baseOptions)!=null&&i.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");a4(e,t,n,e.C+1)}function ja(e,t,n,i){var a;if(!((a=e.baseOptions)!=null&&a.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");a4(e,t,n,i)}function ou(e,t,n,i){var a=t.data;const o=t.width,l=o*(t=t.height);if((a instanceof Uint8Array||a instanceof Float32Array)&&a.length!==l)throw Error("Unsupported channel count: "+a.length/l);return e=new vi([a],n,!1,e.g.i.canvas,e.P,o,t),i?e.clone():e}var Ls=class extends h1{constructor(e,t,n,i){super(e),this.g=e,this.X=t,this.U=n,this.oa=i,this.P=new e4}l(e,t=!0){if("runningMode"in e&&fn(this.baseOptions,2,sh(!!e.runningMode&&e.runningMode!=="IMAGE")),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Ls.prototype.close=Ls.prototype.close;var Ws=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},de(e=this.h=new Rm,0,1,t=new Bn),ue(this.h,2,.5),ue(this.h,3,.3)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&ue(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&ue(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},va(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},ja(this,e,n,t),this.j}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"norm_rect_in"),$e(e,"detections");const t=new Ns;Ga(t,RI,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),wn(n,"IMAGE:image_in"),wn(n,"NORM_RECT:norm_rect_in"),je(n,"DETECTIONS:detections"),n.o(t),ta(e,n),this.g.attachProtoVectorListener("detections",((i,a)=>{for(const o of i)i=MR(o),this.j.detections.push(KR(i));Yt(this,a)})),this.g.attachEmptyPacketListener("detections",(i=>{Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ws.prototype.detectForVideo=Ws.prototype.G,Ws.prototype.detect=Ws.prototype.F,Ws.prototype.setOptions=Ws.prototype.o,Ws.createFromModelPath=async function(e,t){return Xe(Ws,e,{baseOptions:{modelAssetPath:t}})},Ws.createFromModelBuffer=function(e,t){return Xe(Ws,e,{baseOptions:{modelAssetBuffer:t}})},Ws.createFromOptions=function(e,t){return Xe(Ws,e,t)};var iy=ga([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),sy=ga([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),ay=ga([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),r4=ga([474,475],[475,476],[476,477],[477,474]),ry=ga([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),oy=ga([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),o4=ga([469,470],[470,471],[471,472],[472,469]),ly=ga([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),l4=[...iy,...sy,...ay,...ry,...oy,...ly],c4=ga([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function HA(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var In=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,de(e=this.h=new LR,0,1,t=new Bn),this.A=new DR,de(this.h,0,3,this.A),this.u=new Rm,de(this.h,0,2,this.u),Rr(this.u,4,1),ue(this.u,2,.5),ue(this.A,2,.5),ue(this.h,4,.5)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return"numFaces"in e&&Rr(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&ue(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&ue(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&ue(this.A,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return HA(this),va(this,e,t),this.j}G(e,t,n){return HA(this),ja(this,e,n,t),this.j}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"norm_rect"),$e(e,"face_landmarks");const t=new Ns;Ga(t,DI,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),wn(n,"IMAGE:image_in"),wn(n,"NORM_RECT:norm_rect"),je(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),ta(e,n),this.g.attachProtoVectorListener("face_landmarks",((i,a)=>{for(const o of i)i=yh(o),this.j.faceLandmarks.push(Cm(i));Yt(this,a)})),this.g.attachEmptyPacketListener("face_landmarks",(i=>{Yt(this,i)})),this.outputFaceBlendshapes&&($e(e,"blendshapes"),je(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((i,a)=>{if(this.outputFaceBlendshapes)for(const o of i)i=wm(o),this.j.faceBlendshapes.push(ty(i.g()??[]));Yt(this,a)})),this.g.attachEmptyPacketListener("blendshapes",(i=>{Yt(this,i)}))),this.outputFacialTransformationMatrixes&&($e(e,"face_geometry"),je(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((i,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of i)(i=Ze(i=CI(o),yI,2))&&this.j.facialTransformationMatrixes.push({rows:Zs(i,1)??0??0,columns:Zs(i,2)??0??0,data:cl(i,3,La,ll()).slice()??[]});Yt(this,a)})),this.g.attachEmptyPacketListener("face_geometry",(i=>{Yt(this,i)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};In.prototype.detectForVideo=In.prototype.G,In.prototype.detect=In.prototype.F,In.prototype.setOptions=In.prototype.o,In.createFromModelPath=function(e,t){return Xe(In,e,{baseOptions:{modelAssetPath:t}})},In.createFromModelBuffer=function(e,t){return Xe(In,e,{baseOptions:{modelAssetBuffer:t}})},In.createFromOptions=function(e,t){return Xe(In,e,t)},In.FACE_LANDMARKS_LIPS=iy,In.FACE_LANDMARKS_LEFT_EYE=sy,In.FACE_LANDMARKS_LEFT_EYEBROW=ay,In.FACE_LANDMARKS_LEFT_IRIS=r4,In.FACE_LANDMARKS_RIGHT_EYE=ry,In.FACE_LANDMARKS_RIGHT_EYEBROW=oy,In.FACE_LANDMARKS_RIGHT_IRIS=o4,In.FACE_LANDMARKS_FACE_OVAL=ly,In.FACE_LANDMARKS_CONTOURS=l4,In.FACE_LANDMARKS_TESSELATION=c4;var cy=ga([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function jA(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function WA(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function XA(e,t=!0){const n=[];for(const a of e){var i=wm(a);e=[];for(const o of i.g())i=t&&Zs(o,1)!=null?Zs(o,1)??0:-1,e.push({score:Gn(o,2)??0,index:i,categoryName:Ri(Dn(o,3))??""??"",displayName:Ri(Dn(o,4))??""??""});n.push(e)}return n}var Ss=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],de(e=this.j=new UR,0,1,t=new Bn),this.u=new Z_,de(this.j,0,2,this.u),this.D=new K_,de(this.u,0,3,this.D),this.A=new PR,de(this.u,0,2,this.A),this.h=new LI,de(this.j,0,3,this.h),ue(this.A,2,.5),ue(this.u,4,.5),ue(this.D,2,.5)}get baseOptions(){return Ze(this.j,Bn,1)}set baseOptions(e){de(this.j,0,1,e)}o(e){var a,o,l,u;if(Rr(this.A,3,e.numHands??1),"minHandDetectionConfidence"in e&&ue(this.A,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&ue(this.u,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&ue(this.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Tc,n=t,i=f1(e.cannedGesturesClassifierOptions,(a=Ze(this.h,Tc,3))==null?void 0:a.l());de(n,0,2,i),de(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((o=Ze(this.h,Tc,3))==null||o.g());return e.customGesturesClassifierOptions?(de(n=t=new Tc,0,2,i=f1(e.customGesturesClassifierOptions,(l=Ze(this.h,Tc,4))==null?void 0:l.l())),de(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((u=Ze(this.h,Tc,4))==null||u.g()),this.l(e)}Ha(e,t){return jA(this),va(this,e,t),WA(this)}Ia(e,t,n){return jA(this),ja(this,e,n,t),WA(this)}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"norm_rect"),$e(e,"hand_gestures"),$e(e,"hand_landmarks"),$e(e,"world_hand_landmarks"),$e(e,"handedness");const t=new Ns;Ga(t,NI,this.j);const n=new us;Ds(n,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),wn(n,"IMAGE:image_in"),wn(n,"NORM_RECT:norm_rect"),je(n,"HAND_GESTURES:hand_gestures"),je(n,"LANDMARKS:hand_landmarks"),je(n,"WORLD_LANDMARKS:world_hand_landmarks"),je(n,"HANDEDNESS:handedness"),n.o(t),ta(e,n),this.g.attachProtoVectorListener("hand_landmarks",((i,a)=>{for(const o of i){i=yh(o);const l=[];for(const u of wr(i,AR,1))l.push({x:Gn(u,1)??0,y:Gn(u,2)??0,z:Gn(u,3)??0,visibility:Gn(u,4)??0});this.landmarks.push(l)}Yt(this,a)})),this.g.attachEmptyPacketListener("hand_landmarks",(i=>{Yt(this,i)})),this.g.attachProtoVectorListener("world_hand_landmarks",((i,a)=>{for(const o of i){i=Bc(o);const l=[];for(const u of wr(i,TR,1))l.push({x:Gn(u,1)??0,y:Gn(u,2)??0,z:Gn(u,3)??0,visibility:Gn(u,4)??0});this.worldLandmarks.push(l)}Yt(this,a)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(i=>{Yt(this,i)})),this.g.attachProtoVectorListener("hand_gestures",((i,a)=>{this.gestures.push(...XA(i,!1)),Yt(this,a)})),this.g.attachEmptyPacketListener("hand_gestures",(i=>{Yt(this,i)})),this.g.attachProtoVectorListener("handedness",((i,a)=>{this.handedness.push(...XA(i)),Yt(this,a)})),this.g.attachEmptyPacketListener("handedness",(i=>{Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function qA(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Ss.prototype.recognizeForVideo=Ss.prototype.Ia,Ss.prototype.recognize=Ss.prototype.Ha,Ss.prototype.setOptions=Ss.prototype.o,Ss.createFromModelPath=function(e,t){return Xe(Ss,e,{baseOptions:{modelAssetPath:t}})},Ss.createFromModelBuffer=function(e,t){return Xe(Ss,e,{baseOptions:{modelAssetBuffer:t}})},Ss.createFromOptions=function(e,t){return Xe(Ss,e,t)},Ss.HAND_CONNECTIONS=cy;var ji=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],de(e=this.h=new Z_,0,1,t=new Bn),this.u=new K_,de(this.h,0,3,this.u),this.j=new PR,de(this.h,0,2,this.j),Rr(this.j,3,1),ue(this.j,2,.5),ue(this.u,2,.5),ue(this.h,4,.5)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return"numHands"in e&&Rr(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&ue(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&ue(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&ue(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],va(this,e,t),qA(this)}G(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ja(this,e,n,t),qA(this)}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"norm_rect"),$e(e,"hand_landmarks"),$e(e,"world_hand_landmarks"),$e(e,"handedness");const t=new Ns;Ga(t,PI,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),wn(n,"IMAGE:image_in"),wn(n,"NORM_RECT:norm_rect"),je(n,"LANDMARKS:hand_landmarks"),je(n,"WORLD_LANDMARKS:world_hand_landmarks"),je(n,"HANDEDNESS:handedness"),n.o(t),ta(e,n),this.g.attachProtoVectorListener("hand_landmarks",((i,a)=>{for(const o of i)i=yh(o),this.landmarks.push(Cm(i));Yt(this,a)})),this.g.attachEmptyPacketListener("hand_landmarks",(i=>{Yt(this,i)})),this.g.attachProtoVectorListener("world_hand_landmarks",((i,a)=>{for(const o of i)i=Bc(o),this.worldLandmarks.push(Xf(i));Yt(this,a)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(i=>{Yt(this,i)})),this.g.attachProtoVectorListener("handedness",((i,a)=>{var o=this.handedness,l=o.push;const u=[];for(const h of i){i=wm(h);const d=[];for(const p of i.g())d.push({score:Gn(p,2)??0,index:Zs(p,1)??0??-1,categoryName:Ri(Dn(p,3))??""??"",displayName:Ri(Dn(p,4))??""??""});u.push(d)}l.call(o,...u),Yt(this,a)})),this.g.attachEmptyPacketListener("handedness",(i=>{Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ji.prototype.detectForVideo=ji.prototype.G,ji.prototype.detect=ji.prototype.F,ji.prototype.setOptions=ji.prototype.o,ji.createFromModelPath=function(e,t){return Xe(ji,e,{baseOptions:{modelAssetPath:t}})},ji.createFromModelBuffer=function(e,t){return Xe(ji,e,{baseOptions:{modelAssetBuffer:t}})},ji.createFromOptions=function(e,t){return Xe(ji,e,t)},ji.HAND_CONNECTIONS=cy;var u4=ga([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function YA(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function KA(e){try{if(!e.D)return e.h;e.D(e.h)}finally{Lm(e)}}function dp(e,t){e=yh(e),t.push(Cm(e))}var Tn=class extends Ls{constructor(e,t){super(new ba(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,de(e=this.j=new BR,0,1,t=new Bn),this.I=new K_,de(this.j,0,2,this.I),this.W=new UI,de(this.j,0,3,this.W),this.u=new Rm,de(this.j,0,4,this.u),this.O=new DR,de(this.j,0,5,this.O),this.A=new IR,de(this.j,0,6,this.A),this.M=new kR,de(this.j,0,7,this.M),ue(this.u,2,.5),ue(this.u,3,.3),ue(this.O,2,.5),ue(this.A,2,.5),ue(this.A,3,.3),ue(this.M,2,.5),ue(this.I,2,.5)}get baseOptions(){return Ze(this.j,Bn,1)}set baseOptions(e){de(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&ue(this.u,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&ue(this.u,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&ue(this.O,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&ue(this.A,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&ue(this.A,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&ue(this.M,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&ue(this.I,2,e.minHandLandmarksConfidence??.5),this.l(e)}F(e,t,n){const i=typeof t!="function"?t:{};return this.D=typeof t=="function"?t:n,YA(this),va(this,e,i),KA(this)}G(e,t,n,i){const a=typeof n!="function"?n:{};return this.D=typeof n=="function"?n:i,YA(this),ja(this,e,a,t),KA(this)}m(){var e=new Ps;Nn(e,"input_frames_image"),$e(e,"pose_landmarks"),$e(e,"pose_world_landmarks"),$e(e,"face_landmarks"),$e(e,"left_hand_landmarks"),$e(e,"left_hand_world_landmarks"),$e(e,"right_hand_landmarks"),$e(e,"right_hand_world_landmarks");const t=new Ns,n=new _A;Ds(n,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),(function(a,o){if(o!=null)if(Array.isArray(o))fn(a,2,mm(o,0,ah));else{if(!(typeof o=="string"||o instanceof Pa||m_(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");co(a,2,b_(o,!1),Sl())}})(n,this.j.g());const i=new us;Ds(i,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),L_(i,8,_A,n),wn(i,"IMAGE:input_frames_image"),je(i,"POSE_LANDMARKS:pose_landmarks"),je(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),je(i,"FACE_LANDMARKS:face_landmarks"),je(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),je(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),je(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),je(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),ta(e,i),Dm(this,e),this.g.attachProtoListener("pose_landmarks",((a,o)=>{dp(a,this.h.poseLandmarks),Yt(this,o)})),this.g.attachEmptyPacketListener("pose_landmarks",(a=>{Yt(this,a)})),this.g.attachProtoListener("pose_world_landmarks",((a,o)=>{var l=this.h.poseWorldLandmarks;a=Bc(a),l.push(Xf(a)),Yt(this,o)})),this.g.attachEmptyPacketListener("pose_world_landmarks",(a=>{Yt(this,a)})),this.outputPoseSegmentationMasks&&(je(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),au(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",((a,o)=>{this.h.poseSegmentationMasks=[ou(this,a,!0,!this.D)],Yt(this,o)})),this.g.attachEmptyPacketListener("pose_segmentation_mask",(a=>{this.h.poseSegmentationMasks=[],Yt(this,a)}))),this.g.attachProtoListener("face_landmarks",((a,o)=>{dp(a,this.h.faceLandmarks),Yt(this,o)})),this.g.attachEmptyPacketListener("face_landmarks",(a=>{Yt(this,a)})),this.outputFaceBlendshapes&&($e(e,"extra_blendshapes"),je(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",((a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=wm(a),l.push(ty(a.g()??[]))),Yt(this,o)})),this.g.attachEmptyPacketListener("extra_blendshapes",(a=>{Yt(this,a)}))),this.g.attachProtoListener("left_hand_landmarks",((a,o)=>{dp(a,this.h.leftHandLandmarks),Yt(this,o)})),this.g.attachEmptyPacketListener("left_hand_landmarks",(a=>{Yt(this,a)})),this.g.attachProtoListener("left_hand_world_landmarks",((a,o)=>{var l=this.h.leftHandWorldLandmarks;a=Bc(a),l.push(Xf(a)),Yt(this,o)})),this.g.attachEmptyPacketListener("left_hand_world_landmarks",(a=>{Yt(this,a)})),this.g.attachProtoListener("right_hand_landmarks",((a,o)=>{dp(a,this.h.rightHandLandmarks),Yt(this,o)})),this.g.attachEmptyPacketListener("right_hand_landmarks",(a=>{Yt(this,a)})),this.g.attachProtoListener("right_hand_world_landmarks",((a,o)=>{var l=this.h.rightHandWorldLandmarks;a=Bc(a),l.push(Xf(a)),Yt(this,o)})),this.g.attachEmptyPacketListener("right_hand_world_landmarks",(a=>{Yt(this,a)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Tn.prototype.detectForVideo=Tn.prototype.G,Tn.prototype.detect=Tn.prototype.F,Tn.prototype.setOptions=Tn.prototype.o,Tn.createFromModelPath=function(e,t){return Xe(Tn,e,{baseOptions:{modelAssetPath:t}})},Tn.createFromModelBuffer=function(e,t){return Xe(Tn,e,{baseOptions:{modelAssetBuffer:t}})},Tn.createFromOptions=function(e,t){return Xe(Tn,e,t)},Tn.HAND_CONNECTIONS=cy,Tn.POSE_CONNECTIONS=u4,Tn.FACE_LANDMARKS_LIPS=iy,Tn.FACE_LANDMARKS_LEFT_EYE=sy,Tn.FACE_LANDMARKS_LEFT_EYEBROW=ay,Tn.FACE_LANDMARKS_LEFT_IRIS=r4,Tn.FACE_LANDMARKS_RIGHT_EYE=ry,Tn.FACE_LANDMARKS_RIGHT_EYEBROW=oy,Tn.FACE_LANDMARKS_RIGHT_IRIS=o4,Tn.FACE_LANDMARKS_FACE_OVAL=ly,Tn.FACE_LANDMARKS_CONTOURS=l4,Tn.FACE_LANDMARKS_TESSELATION=c4;var Xs=class extends Ls{constructor(e,t){super(new ba(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},de(e=this.h=new zR,0,1,t=new Bn)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return de(this.h,0,2,f1(e,Ze(this.h,q_,2))),this.l(e)}sa(e,t){return this.j={classifications:[]},va(this,e,t),this.j}ta(e,t,n){return this.j={classifications:[]},ja(this,e,n,t),this.j}m(){var e=new Ps;Nn(e,"input_image"),Nn(e,"norm_rect"),$e(e,"classifications");const t=new Ns;Ga(t,OI,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),wn(n,"IMAGE:input_image"),wn(n,"NORM_RECT:norm_rect"),je(n,"CLASSIFICATIONS:classifications"),n.o(t),ta(e,n),this.g.attachProtoListener("classifications",((i,a)=>{this.j=VI(MI(i)),Yt(this,a)})),this.g.attachEmptyPacketListener("classifications",(i=>{Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Xs.prototype.classifyForVideo=Xs.prototype.ta,Xs.prototype.classify=Xs.prototype.sa,Xs.prototype.setOptions=Xs.prototype.o,Xs.createFromModelPath=function(e,t){return Xe(Xs,e,{baseOptions:{modelAssetPath:t}})},Xs.createFromModelBuffer=function(e,t){return Xe(Xs,e,{baseOptions:{modelAssetBuffer:t}})},Xs.createFromOptions=function(e,t){return Xe(Xs,e,t)};var Ms=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect",!0),this.h=new VR,this.embeddings={embeddings:[]},de(e=this.h,0,1,t=new Bn)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){var t=this.h,n=Ze(this.h,RA,2);return n=n?n.clone():new RA,e.l2Normalize!==void 0?fn(n,1,sh(e.l2Normalize)):"l2Normalize"in e&&fn(n,1),e.quantize!==void 0?fn(n,2,sh(e.quantize)):"quantize"in e&&fn(n,2),de(t,0,2,n),this.l(e)}za(e,t){return va(this,e,t),this.embeddings}Aa(e,t,n){return ja(this,e,n,t),this.embeddings}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"norm_rect"),$e(e,"embeddings_out");const t=new Ns;Ga(t,FI,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),wn(n,"IMAGE:image_in"),wn(n,"NORM_RECT:norm_rect"),je(n,"EMBEDDINGS:embeddings_out"),n.o(t),ta(e,n),this.g.attachProtoListener("embeddings_out",((i,a)=>{i=EI(i),this.embeddings=(function(o){return{embeddings:wr(o,AI,1).map((l=>{var d,p;const u={headIndex:Zs(l,3)??0??-1,headName:Ri(Dn(l,4))??""??""};var h=l.v;return kw(h,0|h[ne],wA,Pb(l,1))!==void 0?(l=cl(l=Ze(l,wA,Pb(l,1),void 0),1,La,ll()),u.floatEmbedding=l.slice()):(h=new Uint8Array(0),u.quantizedEmbedding=((p=(d=Ze(l,TI,Pb(l,2),void 0))==null?void 0:d.na())==null?void 0:p.h())??h),u})),timestampMs:YR(Dn(o,2,void 0,void 0,jp)??Pw)}})(i),Yt(this,a)})),this.g.attachEmptyPacketListener("embeddings_out",(i=>{Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ms.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=UA(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=UA(PA(e.quantizedEmbedding),PA(t.quantizedEmbedding))}return e},Ms.prototype.embedForVideo=Ms.prototype.Aa,Ms.prototype.embed=Ms.prototype.za,Ms.prototype.setOptions=Ms.prototype.o,Ms.createFromModelPath=function(e,t){return Xe(Ms,e,{baseOptions:{modelAssetPath:t}})},Ms.createFromModelBuffer=function(e,t){return Xe(Ms,e,{baseOptions:{modelAssetBuffer:t}})},Ms.createFromOptions=function(e,t){return Xe(Ms,e,t)};var m1=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach((n=>{n.close()})),(t=this.categoryMask)==null||t.close()}};function YI(e){var n,i;const t=(function(a){return wr(a,us,1)})(e.ca()).filter((a=>(Ri(Dn(a,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator")));if(e.u=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(n=Ze(t[0],Ns,7))==null?void 0:n.j())==null?void 0:i.g())??new Map).forEach(((a,o)=>{e.u[Number(o)]=Ri(Dn(a,1))??""}))}function ZA(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function QA(e){try{const t=new m1(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{Lm(e)}}m1.prototype.close=m1.prototype.close;var as=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new $_,this.A=new GR,de(this.h,0,3,this.A),de(e=this.h,0,1,t=new Bn)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?fn(this.h,2,bh(e.displayNamesLocale)):"displayNamesLocale"in e&&fn(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}L(){YI(this)}segment(e,t,n){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:n,ZA(this),va(this,e,i),QA(this)}La(e,t,n,i){const a=typeof n!="function"?n:{};return this.j=typeof n=="function"?n:i,ZA(this),ja(this,e,a,t),QA(this)}Da(){return this.u}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"norm_rect");const t=new Ns;Ga(t,jR,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),wn(n,"IMAGE:image_in"),wn(n,"NORM_RECT:norm_rect"),n.o(t),ta(e,n),Dm(this,e),this.outputConfidenceMasks&&($e(e,"confidence_masks"),je(n,"CONFIDENCE_MASKS:confidence_masks"),au(this,"confidence_masks"),this.g.aa("confidence_masks",((i,a)=>{this.confidenceMasks=i.map((o=>ou(this,o,!0,!this.j))),Yt(this,a)})),this.g.attachEmptyPacketListener("confidence_masks",(i=>{this.confidenceMasks=[],Yt(this,i)}))),this.outputCategoryMask&&($e(e,"category_mask"),je(n,"CATEGORY_MASK:category_mask"),au(this,"category_mask"),this.g.Z("category_mask",((i,a)=>{this.categoryMask=ou(this,i,!1,!this.j),Yt(this,a)})),this.g.attachEmptyPacketListener("category_mask",(i=>{this.categoryMask=void 0,Yt(this,i)}))),$e(e,"quality_scores"),je(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((i,a)=>{this.qualityScores=i,Yt(this,a)})),this.g.attachEmptyPacketListener("quality_scores",(i=>{this.categoryMask=void 0,Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};as.prototype.getLabels=as.prototype.Da,as.prototype.segmentForVideo=as.prototype.La,as.prototype.segment=as.prototype.segment,as.prototype.setOptions=as.prototype.o,as.createFromModelPath=function(e,t){return Xe(as,e,{baseOptions:{modelAssetPath:t}})},as.createFromModelBuffer=function(e,t){return Xe(as,e,{baseOptions:{modelAssetBuffer:t}})},as.createFromOptions=function(e,t){return Xe(as,e,t)};var g1=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach((n=>{n.close()})),(t=this.categoryMask)==null||t.close()}};g1.prototype.close=g1.prototype.close;var Ea=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new $_,this.u=new GR,de(this.h,0,3,this.u),de(e=this.h,0,1,t=new Bn)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,n,i){const a=typeof n!="function"?n:{};if(this.j=typeof n=="function"?n:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.C+1,i=new WR,t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var o=new Ib;co(o,3,sh(!0),!1),co(o,1,If(t.keypoint.x),0),co(o,2,If(t.keypoint.y),0),jf(i,1,u1,o)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");{const u=new kI;for(o of t.scribble)co(t=new Ib,3,sh(!0),!1),co(t,1,If(o.x),0),co(t,2,If(o.y),0),L_(u,1,Ib,t);jf(i,2,u1,u)}}this.g.addProtoToStream(i.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",n),va(this,e,a);t:{try{const u=new g1(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=u;break t}this.j(u)}finally{Lm(this)}l=void 0}return l}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"roi_in"),Nn(e,"norm_rect_in");const t=new Ns;Ga(t,jR,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),wn(n,"IMAGE:image_in"),wn(n,"ROI:roi_in"),wn(n,"NORM_RECT:norm_rect_in"),n.o(t),ta(e,n),Dm(this,e),this.outputConfidenceMasks&&($e(e,"confidence_masks"),je(n,"CONFIDENCE_MASKS:confidence_masks"),au(this,"confidence_masks"),this.g.aa("confidence_masks",((i,a)=>{this.confidenceMasks=i.map((o=>ou(this,o,!0,!this.j))),Yt(this,a)})),this.g.attachEmptyPacketListener("confidence_masks",(i=>{this.confidenceMasks=[],Yt(this,i)}))),this.outputCategoryMask&&($e(e,"category_mask"),je(n,"CATEGORY_MASK:category_mask"),au(this,"category_mask"),this.g.Z("category_mask",((i,a)=>{this.categoryMask=ou(this,i,!1,!this.j),Yt(this,a)})),this.g.attachEmptyPacketListener("category_mask",(i=>{this.categoryMask=void 0,Yt(this,i)}))),$e(e,"quality_scores"),je(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((i,a)=>{this.qualityScores=i,Yt(this,a)})),this.g.attachEmptyPacketListener("quality_scores",(i=>{this.categoryMask=void 0,Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ea.prototype.segment=Ea.prototype.segment,Ea.prototype.setOptions=Ea.prototype.o,Ea.createFromModelPath=function(e,t){return Xe(Ea,e,{baseOptions:{modelAssetPath:t}})},Ea.createFromModelBuffer=function(e,t){return Xe(Ea,e,{baseOptions:{modelAssetBuffer:t}})},Ea.createFromOptions=function(e,t){return Xe(Ea,e,t)};var qs=class extends Ls{constructor(e,t){super(new ba(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},de(e=this.h=new XR,0,1,t=new Bn)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?fn(this.h,2,bh(e.displayNamesLocale)):"displayNamesLocale"in e&&fn(this.h,2),e.maxResults!==void 0?Rr(this.h,3,e.maxResults):"maxResults"in e&&fn(this.h,3),e.scoreThreshold!==void 0?ue(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&fn(this.h,4),e.categoryAllowlist!==void 0?Xp(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&fn(this.h,5),e.categoryDenylist!==void 0?Xp(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&fn(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},va(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},ja(this,e,n,t),this.j}m(){var e=new Ps;Nn(e,"input_frame_gpu"),Nn(e,"norm_rect"),$e(e,"detections");const t=new Ns;Ga(t,BI,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),wn(n,"IMAGE:input_frame_gpu"),wn(n,"NORM_RECT:norm_rect"),je(n,"DETECTIONS:detections"),n.o(t),ta(e,n),this.g.attachProtoVectorListener("detections",((i,a)=>{for(const o of i)i=MR(o),this.j.detections.push(KR(i));Yt(this,a)})),this.g.attachEmptyPacketListener("detections",(i=>{Yt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};qs.prototype.detectForVideo=qs.prototype.G,qs.prototype.detect=qs.prototype.F,qs.prototype.setOptions=qs.prototype.o,qs.createFromModelPath=async function(e,t){return Xe(qs,e,{baseOptions:{modelAssetPath:t}})},qs.createFromModelBuffer=function(e,t){return Xe(qs,e,{baseOptions:{modelAssetBuffer:t}})},qs.createFromOptions=function(e,t){return Xe(qs,e,t)};var b1=class{constructor(e,t,n){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=n}close(){var e;(e=this.segmentationMasks)==null||e.forEach((t=>{t.close()}))}};function JA(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function $A(e){try{const t=new b1(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.u)return t;e.u(t)}finally{Lm(e)}}b1.prototype.close=b1.prototype.close;var rs=class extends Ls{constructor(e,t){super(new ba(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,de(e=this.h=new qR,0,1,t=new Bn),this.A=new kR,de(this.h,0,3,this.A),this.j=new IR,de(this.h,0,2,this.j),Rr(this.j,4,1),ue(this.j,2,.5),ue(this.A,2,.5),ue(this.h,4,.5)}get baseOptions(){return Ze(this.h,Bn,1)}set baseOptions(e){de(this.h,0,1,e)}o(e){return"numPoses"in e&&Rr(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&ue(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&ue(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&ue(this.A,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,n){const i=typeof t!="function"?t:{};return this.u=typeof t=="function"?t:n,JA(this),va(this,e,i),$A(this)}G(e,t,n,i){const a=typeof n!="function"?n:{};return this.u=typeof n=="function"?n:i,JA(this),ja(this,e,a,t),$A(this)}m(){var e=new Ps;Nn(e,"image_in"),Nn(e,"norm_rect"),$e(e,"normalized_landmarks"),$e(e,"world_landmarks"),$e(e,"segmentation_masks");const t=new Ns;Ga(t,zI,this.h);const n=new us;Ds(n,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),wn(n,"IMAGE:image_in"),wn(n,"NORM_RECT:norm_rect"),je(n,"NORM_LANDMARKS:normalized_landmarks"),je(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),ta(e,n),Dm(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((i,a)=>{this.landmarks=[];for(const o of i)i=yh(o),this.landmarks.push(Cm(i));Yt(this,a)})),this.g.attachEmptyPacketListener("normalized_landmarks",(i=>{this.landmarks=[],Yt(this,i)})),this.g.attachProtoVectorListener("world_landmarks",((i,a)=>{this.worldLandmarks=[];for(const o of i)i=Bc(o),this.worldLandmarks.push(Xf(i));Yt(this,a)})),this.g.attachEmptyPacketListener("world_landmarks",(i=>{this.worldLandmarks=[],Yt(this,i)})),this.outputSegmentationMasks&&(je(n,"SEGMENTATION_MASK:segmentation_masks"),au(this,"segmentation_masks"),this.g.aa("segmentation_masks",((i,a)=>{this.segmentationMasks=i.map((o=>ou(this,o,!0,!this.u))),Yt(this,a)})),this.g.attachEmptyPacketListener("segmentation_masks",(i=>{this.segmentationMasks=[],Yt(this,i)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};rs.prototype.detectForVideo=rs.prototype.G,rs.prototype.detect=rs.prototype.F,rs.prototype.setOptions=rs.prototype.o,rs.createFromModelPath=function(e,t){return Xe(rs,e,{baseOptions:{modelAssetPath:t}})},rs.createFromModelBuffer=function(e,t){return Xe(rs,e,{baseOptions:{modelAssetBuffer:t}})},rs.createFromOptions=function(e,t){return Xe(rs,e,t)},rs.POSE_CONNECTIONS=u4;const uy=dt.createContext({});function fy(e){const t=dt.useRef(null);return t.current===null&&(t.current=e()),t.current}const KI=typeof window<"u",f4=KI?dt.useLayoutEffect:dt.useEffect,Nm=dt.createContext(null);function hy(e,t){e.indexOf(t)===-1&&e.push(t)}function Qp(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Ia=(e,t,n)=>n>t?t:n{};const To={},h4=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function d4(e){return typeof e=="object"&&e!==null}const p4=e=>/^0[^.\s]+$/u.test(e);function m4(e){let t;return()=>(t===void 0&&(t=e()),t)}const Js=e=>e,ZI=(e,t)=>n=>t(e(n)),xh=(...e)=>e.reduce(ZI),rh=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i};class py{constructor(){this.subscriptions=[]}add(t){return hy(this.subscriptions,t),()=>Qp(this.subscriptions,t)}notify(t,n,i){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](t,n,i);else for(let o=0;oe*1e3,Qs=e=>e/1e3;function g4(e,t){return t?e*(1e3/t):0}const b4=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,QI=1e-7,JI=12;function $I(e,t,n,i,a){let o,l,u=0;do l=t+(n-t)/2,o=b4(l,i,a)-e,o>0?n=l:t=l;while(Math.abs(o)>QI&&++u$I(o,0,1,e,n);return o=>o===0||o===1?o:b4(a(o),t,i)}const v4=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,_4=e=>t=>1-e(1-t),y4=Sh(.33,1.53,.69,.99),my=_4(y4),x4=v4(my),S4=e=>e>=1?1:(e*=2)<1?.5*my(e):.5*(2-Math.pow(2,-10*(e-1))),gy=e=>1-Math.sin(Math.acos(e)),M4=_4(gy),T4=v4(gy),tk=Sh(.42,0,1,1),ek=Sh(0,0,.58,1),A4=Sh(.42,0,.58,1),nk=e=>Array.isArray(e)&&typeof e[0]!="number",E4=e=>Array.isArray(e)&&typeof e[0]=="number",ik={linear:Js,easeIn:tk,easeInOut:A4,easeOut:ek,circIn:gy,circInOut:T4,circOut:M4,backIn:my,backInOut:x4,backOut:y4,anticipate:S4},sk=e=>typeof e=="string",tE=e=>{if(E4(e)){dy(e.length===4);const[t,n,i,a]=e;return Sh(t,n,i,a)}else if(sk(e))return ik[e];return e},pp=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function ak(e,t){let n=new Set,i=new Set,a=!1,o=!1;const l=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function h(p){l.has(p)&&(d.schedule(p),e()),p(u)}const d={schedule:(p,m=!1,b=!1)=>{const x=b&&a?n:i;return m&&l.add(p),x.add(p),p},cancel:p=>{i.delete(p),l.delete(p)},process:p=>{if(u=p,a){o=!0;return}a=!0;const m=n;n=i,i=m,n.forEach(h),n.clear(),a=!1,o&&(o=!1,d.process(p))}};return d}const rk=40;function w4(e,t){let n=!1,i=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=pp.reduce((w,A)=>(w[A]=ak(o),w),{}),{setup:u,read:h,resolveKeyframes:d,preUpdate:p,update:m,preRender:b,render:_,postRender:x}=l,M=()=>{const w=To.useManualTiming,A=w?a.timestamp:performance.now();n=!1,w||(a.delta=i?1e3/60:Math.max(Math.min(A-a.timestamp,rk),1)),a.timestamp=A,a.isProcessing=!0,u.process(a),h.process(a),d.process(a),p.process(a),m.process(a),b.process(a),_.process(a),x.process(a),a.isProcessing=!1,n&&t&&(i=!1,e(M))},S=()=>{n=!0,i=!0,a.isProcessing||e(M)};return{schedule:pp.reduce((w,A)=>{const U=l[A];return w[A]=(O,P=!1,F=!1)=>(n||S(),U.schedule(O,P,F)),w},{}),cancel:w=>{for(let A=0;A(Rp===void 0&&qi.set(Ei.isProcessing||To.useManualTiming?Ei.timestamp:performance.now()),Rp),set:e=>{Rp=e,queueMicrotask(ok)}},R4=e=>t=>typeof t=="string"&&t.startsWith(e),C4=R4("--"),lk=R4("var(--"),by=e=>lk(e)?ck.test(e.split("/*")[0].trim()):!1,ck=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function eE(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Eu={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},oh={...Eu,transform:e=>Ia(0,1,e)},mp={...Eu,default:1},qf=e=>Math.round(e*1e5)/1e5,vy=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function uk(e){return e==null}const fk=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,_y=(e,t)=>n=>!!(typeof n=="string"&&fk.test(n)&&n.startsWith(e)||t&&!uk(n)&&Object.prototype.hasOwnProperty.call(n,t)),D4=(e,t,n)=>i=>{if(typeof i!="string")return i;const[a,o,l,u]=i.match(vy);return{[e]:parseFloat(a),[t]:parseFloat(o),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},hk=e=>Ia(0,255,e),zb={...Eu,transform:e=>Math.round(hk(e))},ul={test:_y("rgb","red"),parse:D4("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+zb.transform(e)+", "+zb.transform(t)+", "+zb.transform(n)+", "+qf(oh.transform(i))+")"};function dk(e){let t="",n="",i="",a="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),a=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),a=e.substring(4,5),t+=t,n+=n,i+=i,a+=a),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:a?parseInt(a,16)/255:1}}const v1={test:_y("#"),parse:dk,transform:ul.transform},Mh=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),oo=Mh("deg"),Ua=Mh("%"),qt=Mh("px"),pk=Mh("vh"),mk=Mh("vw"),nE={...Ua,parse:e=>Ua.parse(e)/100,transform:e=>Ua.transform(e*100)},Lc={test:_y("hsl","hue"),parse:D4("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+Ua.transform(qf(t))+", "+Ua.transform(qf(n))+", "+qf(oh.transform(i))+")"},Qn={test:e=>ul.test(e)||v1.test(e)||Lc.test(e),parse:e=>ul.test(e)?ul.parse(e):Lc.test(e)?Lc.parse(e):v1.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?ul.transform(e):Lc.transform(e),getAnimatableNone:e=>{const t=Qn.parse(e);return t.alpha=0,Qn.transform(t)}},gk=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function bk(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(vy))==null?void 0:t.length)||0)+(((n=e.match(gk))==null?void 0:n.length)||0)>0}const L4="number",N4="color",vk="var",_k="var(",iE="${}",yk=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function lu(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},a=[];let o=0;const u=t.replace(yk,h=>(Qn.test(h)?(i.color.push(o),a.push(N4),n.push(Qn.parse(h))):h.startsWith(_k)?(i.var.push(o),a.push(vk),n.push(h)):(i.number.push(o),a.push(L4),n.push(parseFloat(h))),++o,iE)).split(iE);return{values:n,split:u,indexes:i,types:a}}function xk(e){return lu(e).values}function P4({split:e,types:t}){const n=e.length;return i=>{let a="";for(let o=0;otypeof e=="number"?0:Qn.test(e)?Qn.getAnimatableNone(e):e,Tk=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:Mk(e);function Ak(e){const t=lu(e);return P4(t)(t.values.map((i,a)=>Tk(i,t.split[a])))}const pa={test:bk,parse:xk,createTransformer:Sk,getAnimatableNone:Ak};function Vb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ek({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let a=0,o=0,l=0;if(!t)a=o=l=n;else{const u=n<.5?n*(1+t):n+t-n*t,h=2*n-u;a=Vb(h,u,e+1/3),o=Vb(h,u,e),l=Vb(h,u,e-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:i}}function Jp(e,t){return n=>n>0?t:e}const xn=(e,t,n)=>e+(t-e)*n,Gb=(e,t,n)=>{const i=e*e,a=n*(t*t-i)+i;return a<0?0:Math.sqrt(a)},wk=[v1,ul,Lc],Rk=e=>wk.find(t=>t.test(e));function sE(e){const t=Rk(e);if(!t)return!1;let n=t.parse(e);return t===Lc&&(n=Ek(n)),n}const aE=(e,t)=>{const n=sE(e),i=sE(t);if(!n||!i)return Jp(e,t);const a={...n};return o=>(a.red=Gb(n.red,i.red,o),a.green=Gb(n.green,i.green,o),a.blue=Gb(n.blue,i.blue,o),a.alpha=xn(n.alpha,i.alpha,o),ul.transform(a))},_1=new Set(["none","hidden"]);function Ck(e,t){return _1.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Dk(e,t){return n=>xn(e,t,n)}function yy(e){return typeof e=="number"?Dk:typeof e=="string"?by(e)?Jp:Qn.test(e)?aE:Pk:Array.isArray(e)?U4:typeof e=="object"?Qn.test(e)?aE:Lk:Jp}function U4(e,t){const n=[...e],i=n.length,a=e.map((o,l)=>yy(o)(o,t[l]));return o=>{for(let l=0;l{for(const o in i)n[o]=i[o](a);return n}}function Nk(e,t){const n=[],i={color:0,var:0,number:0};for(let a=0;a{const n=pa.createTransformer(t),i=lu(e),a=lu(t);return i.indexes.var.length===a.indexes.var.length&&i.indexes.color.length===a.indexes.color.length&&i.indexes.number.length>=a.indexes.number.length?_1.has(e)&&!a.values.length||_1.has(t)&&!i.values.length?Ck(e,t):xh(U4(Nk(i,a),a.values),n):Jp(e,t)};function O4(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?xn(e,t,n):yy(e)(e,t)}const Uk=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>mn.update(t,n),stop:()=>Ao(t),now:()=>Ei.isProcessing?Ei.timestamp:qi.now()}},F4=(e,t,n=10)=>{let i="";const a=Math.max(Math.round(t/n),2);for(let o=0;o=$p?1/0:t}function Ok(e,t=100,n){const i=n({...e,keyframes:[0,t]}),a=Math.min(xy(i),$p);return{type:"keyframes",ease:o=>i.next(a*o).value/t,duration:Qs(a)}}const kn={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function y1(e,t){return e*Math.sqrt(1-t*t)}const Fk=12;function Ik(e,t,n){let i=n;for(let a=1;a{const p=d*l,m=p*e,b=p-n,_=y1(d,l),x=Math.exp(-m);return Hb-b/_*x},o=d=>{const m=d*l*e,b=m*n+n,_=Math.pow(l,2)*Math.pow(d,2)*e,x=Math.exp(-m),M=y1(Math.pow(d,2),l);return(-a(d)+Hb>0?-1:1)*((b-_)*x)/M}):(a=d=>{const p=Math.exp(-d*e),m=(d-n)*e+1;return-Hb+p*m},o=d=>{const p=Math.exp(-d*e),m=(n-d)*(e*e);return p*m});const u=5/e,h=Ik(a,o,u);if(e=Rs(e),isNaN(h))return{stiffness:kn.stiffness,damping:kn.damping,duration:e};{const d=Math.pow(h,2)*i;return{stiffness:d,damping:l*2*Math.sqrt(i*d),duration:e}}}const Bk=["duration","bounce"],zk=["stiffness","damping","mass"];function rE(e,t){return t.some(n=>e[n]!==void 0)}function Vk(e){let t={velocity:kn.velocity,stiffness:kn.stiffness,damping:kn.damping,mass:kn.mass,isResolvedFromDuration:!1,...e};if(!rE(e,zk)&&rE(e,Bk))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),a=i*i,o=2*Ia(.05,1,1-(e.bounce||0))*Math.sqrt(a);t={...t,mass:kn.mass,stiffness:a,damping:o}}else{const n=kk({...e,velocity:0});t={...t,...n,mass:kn.mass},t.isResolvedFromDuration=!0}return t}function tm(e=kn.visualDuration,t=kn.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:a}=n;const o=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:h,damping:d,mass:p,duration:m,velocity:b,isResolvedFromDuration:_}=Vk({...n,velocity:-Qs(n.velocity||0)}),x=b||0,M=d/(2*Math.sqrt(h*p)),S=l-o,y=Qs(Math.sqrt(h/p)),E=Math.abs(S)<5;i||(i=E?kn.restSpeed.granular:kn.restSpeed.default),a||(a=E?kn.restDelta.granular:kn.restDelta.default);let w,A,U,O,P,F;if(M<1)U=y1(y,M),O=(x+M*y*S)/U,w=R=>{const I=Math.exp(-M*y*R);return l-I*(O*Math.sin(U*R)+S*Math.cos(U*R))},P=M*y*O+S*U,F=M*y*S-O*U,A=R=>Math.exp(-M*y*R)*(P*Math.sin(U*R)+F*Math.cos(U*R));else if(M===1){w=I=>l-Math.exp(-y*I)*(S+(x+y*S)*I);const R=x+y*S;A=I=>Math.exp(-y*I)*(y*R*I-x)}else{const R=y*Math.sqrt(M*M-1);w=ct=>{const ft=Math.exp(-M*y*ct),z=Math.min(R*ct,300);return l-ft*((x+M*y*S)*Math.sinh(z)+R*S*Math.cosh(z))/R};const I=(x+M*y*S)/R,Z=M*y*I-S*R,nt=M*y*S-I*R;A=ct=>{const ft=Math.exp(-M*y*ct),z=Math.min(R*ct,300);return ft*(Z*Math.sinh(z)+nt*Math.cosh(z))}}const C={calculatedDuration:_&&m||null,velocity:R=>Rs(A(R)),next:R=>{if(!_&&M<1){const Z=Math.exp(-M*y*R),nt=Math.sin(U*R),ct=Math.cos(U*R),ft=l-Z*(O*nt+S*ct),z=Rs(Z*(P*nt+F*ct));return u.done=Math.abs(z)<=i&&Math.abs(l-ft)<=a,u.value=u.done?l:ft,u}const I=w(R);if(_)u.done=R>=m;else{const Z=Rs(A(R));u.done=Math.abs(Z)<=i&&Math.abs(l-I)<=a}return u.value=u.done?l:I,u},toString:()=>{const R=Math.min(xy(C),$p),I=F4(Z=>C.next(R*Z).value,R,30);return R+"ms "+I},toTransition:()=>{}};return C}tm.applyToOptions=e=>{const t=Ok(e,100,tm);return e.ease=t.ease,e.duration=Rs(t.duration),e.type="keyframes",e};const Gk=5;function I4(e,t,n){const i=Math.max(t-Gk,0);return g4(n-e(i),t-i)}function x1({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:u,max:h,restDelta:d=.5,restSpeed:p}){const m=e[0],b={done:!1,value:m},_=F=>u!==void 0&&Fh,x=F=>u===void 0?h:h===void 0||Math.abs(u-F)-M*Math.exp(-F/i),w=F=>y+E(F),A=F=>{const C=E(F),R=w(F);b.done=Math.abs(C)<=d,b.value=b.done?y:R};let U,O;const P=F=>{_(b.value)&&(U=F,O=tm({keyframes:[b.value,x(b.value)],velocity:I4(w,F,b.value),damping:a,stiffness:o,restDelta:d,restSpeed:p}))};return P(0),{calculatedDuration:null,next:F=>{let C=!1;return!O&&U===void 0&&(C=!0,A(F),P(F)),U!==void 0&&F>=U?O.next(F-U):(!C&&A(F),b)}}}function Hk(e,t,n){const i=[],a=n||To.mix||O4,o=e.length-1;for(let l=0;lt[0];if(o===2&&t[0]===t[1])return()=>t[1];const l=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const u=Hk(t,i,a),h=u.length,d=p=>{if(l&&p1)for(;md(Ia(e[0],e[o-1],p)):d}function Wk(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const a=rh(0,t,i);e.push(xn(n,1,a))}}function Xk(e){const t=[0];return Wk(t,e.length-1),t}function qk(e,t){return e.map(n=>n*t)}function Yk(e,t){return e.map(()=>t||A4).splice(0,e.length-1)}function Yf({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const a=nk(i)?i.map(tE):tE(i),o={done:!1,value:t[0]},l=qk(n&&n.length===t.length?n:Xk(t),e),u=jk(l,t,{ease:Array.isArray(a)?a:Yk(t,a)});return{calculatedDuration:e,next:h=>(o.value=u(h),o.done=h>=e,o)}}const Kk=e=>e!==null;function Pm(e,{repeat:t,repeatType:n="loop"},i,a=1){const o=e.filter(Kk),u=a<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!u||i===void 0?o[u]:i}const Zk={decay:x1,inertia:x1,tween:Yf,keyframes:Yf,spring:tm};function k4(e){typeof e.type=="string"&&(e.type=Zk[e.type])}class Sy{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Qk=e=>e/100;class em extends Sy{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var i,a;const{motionValue:n}=this.options;n&&n.updatedAt!==qi.now()&&this.tick(qi.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(a=(i=this.options).onStop)==null||a.call(i))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;k4(t);const{type:n=Yf,repeat:i=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=t;let{keyframes:u}=t;const h=n||Yf;h!==Yf&&typeof u[0]!="number"&&(this.mixKeyframes=xh(Qk,O4(u[0],u[1])),u=[0,100]);const d=h({...t,keyframes:u});o==="mirror"&&(this.mirroredGenerator=h({...t,keyframes:[...u].reverse(),velocity:-l})),d.calculatedDuration===null&&(d.calculatedDuration=xy(d));const{calculatedDuration:p}=d;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(i+1)-a,this.generator=d}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:i,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:u,calculatedDuration:h}=this;if(this.startTime===null)return i.next(0);const{delay:d=0,keyframes:p,repeat:m,repeatType:b,repeatDelay:_,type:x,onUpdate:M,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const y=this.currentTime-d*(this.playbackSpeed>=0?1:-1),E=this.playbackSpeed>=0?y<0:y>a;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let w=this.currentTime,A=i;if(m){const F=Math.min(this.currentTime,a)/u;let C=Math.floor(F),R=F%1;!R&&F>=1&&(R=1),R===1&&C--,C=Math.min(C,m+1),!!(C%2)&&(b==="reverse"?(R=1-R,_&&(R-=_/u)):b==="mirror"&&(A=l)),w=Ia(0,1,R)*u}let U;E?(this.delayState.value=p[0],U=this.delayState):U=A.next(w),o&&!E&&(U.value=o(U.value));let{done:O}=U;!E&&h!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const P=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return P&&x!==x1&&(U.value=Pm(p,this.options,S,this.speed)),M&&M(U.value),P&&this.finish(),U}then(t,n){return this.finished.then(t,n)}get duration(){return Qs(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Qs(t)}get time(){return Qs(this.currentTime)}set time(t){t=Rs(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return I4(i=>this.generator.next(i).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(qi.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=Qs(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:t=Uk,startTime:n}=this.options;this.driver||(this.driver=t(l=>this.tick(l))),(o=(a=this.options).onPlay)==null||o.call(a);const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(qi.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function Jk(e){for(let t=1;te*180/Math.PI,S1=e=>{const t=fl(Math.atan2(e[1],e[0]));return M1(t)},$k={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:S1,rotateZ:S1,skewX:e=>fl(Math.atan(e[1])),skewY:e=>fl(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},M1=e=>(e=e%360,e<0&&(e+=360),e),oE=S1,lE=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),cE=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),tB={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:lE,scaleY:cE,scale:e=>(lE(e)+cE(e))/2,rotateX:e=>M1(fl(Math.atan2(e[6],e[5]))),rotateY:e=>M1(fl(Math.atan2(-e[2],e[0]))),rotateZ:oE,rotate:oE,skewX:e=>fl(Math.atan(e[4])),skewY:e=>fl(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function T1(e){return e.includes("scale")?1:0}function A1(e,t){if(!e||e==="none")return T1(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,a;if(n)i=tB,a=n;else{const u=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=$k,a=u}if(!a)return T1(t);const o=i[t],l=a[1].split(",").map(nB);return typeof o=="function"?o(l):l[o]}const eB=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return A1(n,t)};function nB(e){return parseFloat(e.trim())}const wu=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ru=new Set(wu),uE=e=>e===Eu||e===qt,iB=new Set(["x","y","z"]),sB=wu.filter(e=>!iB.has(e));function aB(e){const t=[];return sB.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const bo={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:i})=>{const a=e.max-e.min;return i==="border-box"?a:a-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:i})=>{const a=e.max-e.min;return i==="border-box"?a:a-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>A1(t,"x"),y:(e,{transform:t})=>A1(t,"y")};bo.translateX=bo.x;bo.translateY=bo.y;const bl=new Set;let E1=!1,w1=!1,R1=!1;function B4(){if(w1){const e=Array.from(bl).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const a=aB(i);a.length&&(n.set(i,a),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const a=n.get(i);a&&a.forEach(([o,l])=>{var u;(u=i.getValue(o))==null||u.set(l)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}w1=!1,E1=!1,bl.forEach(e=>e.complete(R1)),bl.clear()}function z4(){bl.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(w1=!0)})}function rB(){R1=!0,z4(),B4(),R1=!1}class My{constructor(t,n,i,a,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=a,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(bl.add(this),E1||(E1=!0,mn.read(z4),mn.resolveKeyframes(B4))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:a}=this;if(t[0]===null){const o=a==null?void 0:a.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(i&&n){const u=i.readValue(n,l);u!=null&&(t[0]=u)}t[0]===void 0&&(t[0]=l),a&&o===void 0&&a.set(t[0])}Jk(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),bl.delete(this)}cancel(){this.state==="scheduled"&&(bl.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const oB=e=>e.startsWith("--");function V4(e,t,n){oB(t)?e.style.setProperty(t,n):e.style[t]=n}const lB={};function G4(e,t){const n=m4(e);return()=>lB[t]??n()}const cB=G4(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),H4=G4(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),kf=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,fE={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:kf([0,.65,.55,1]),circOut:kf([.55,0,1,.45]),backIn:kf([.31,.01,.66,-.59]),backOut:kf([.33,1.53,.69,.99])};function j4(e,t){if(e)return typeof e=="function"?H4()?F4(e,t):"ease-out":E4(e)?kf(e):Array.isArray(e)?e.map(n=>j4(n,t)||fE.easeOut):fE[e]}function uB(e,t,n,{delay:i=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:u="easeOut",times:h}={},d=void 0){const p={[t]:n};h&&(p.offset=h);const m=j4(u,a);Array.isArray(m)&&(p.easing=m);const b={delay:i,duration:a,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return d&&(b.pseudoElement=d),e.animate(p,b)}function W4(e){return typeof e=="function"&&"applyToOptions"in e}function fB({type:e,...t}){return W4(e)&&H4()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class X4 extends Sy{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:i,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:u,onComplete:h}=t;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=t,dy(typeof t.type!="string");const d=fB(t);this.animation=uB(n,i,a,d,o),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Pm(a,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(p),V4(n,i,p),this.animation.cancel()}h==null||h(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,i,a;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((a=(i=this.animation).commitStyles)==null||a.call(i))}get duration(){var n,i;const t=((i=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:i.call(n).duration)||0;return Qs(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Qs(t)}get time(){return Qs(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Rs(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:i,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&cB()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),i&&(this.animation.rangeEnd=i),Js):a(this)}}const q4={anticipate:S4,backInOut:x4,circInOut:T4};function hB(e){return e in q4}function dB(e){typeof e.ease=="string"&&hB(e.ease)&&(e.ease=q4[e.ease])}const jb=10;class pB extends X4{constructor(t){dB(t),k4(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:i,onComplete:a,element:o,...l}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const u=new em({...l,autoplay:!1}),h=Math.max(jb,qi.now()-this.startTime),d=Ia(0,jb,h-jb),p=u.sample(h).value,{name:m}=this.options;o&&m&&V4(o,m,p),n.setWithVelocity(u.sample(Math.max(0,h-d)).value,p,d),u.stop()}}const hE=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(pa.test(e)||e==="0")&&!e.startsWith("url("));function mB(e){const t=e[0];if(e.length===1)return!0;for(let n=0;nObject.hasOwnProperty.call(Element.prototype,"animate"));function xB(e){var m;const{motionValue:t,name:n,repeatDelay:i,repeatType:a,damping:o,type:l,keyframes:u}=e;if(!(((m=t==null?void 0:t.owner)==null?void 0:m.current)instanceof HTMLElement))return!1;const{onUpdate:d,transformTemplate:p}=t.owner.getProps();return yB()&&n&&(Y4.has(n)||_B.has(n)&&vB(u))&&(n!=="transform"||!p)&&!d&&!i&&a!=="mirror"&&o!==0&&l!=="inertia"}const SB=40;class MB extends Sy{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:u,name:h,motionValue:d,element:p,...m}){var x;super(),this.stop=()=>{var M,S;this._animation&&(this._animation.stop(),(M=this.stopTimeline)==null||M.call(this)),(S=this.keyframeResolver)==null||S.cancel()},this.createdAt=qi.now();const b={autoplay:t,delay:n,type:i,repeat:a,repeatDelay:o,repeatType:l,name:h,motionValue:d,element:p,...m},_=(p==null?void 0:p.KeyframeResolver)||My;this.keyframeResolver=new _(u,(M,S,y)=>this.onKeyframesResolved(M,S,b,!y),h,d,p),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,n,i,a){var y,E;this.keyframeResolver=void 0;const{name:o,type:l,velocity:u,delay:h,isHandoff:d,onUpdate:p}=i;this.resolvedAt=qi.now();let m=!0;gB(t,o,l,u)||(m=!1,(To.instantAnimations||!h)&&(p==null||p(Pm(t,i,n))),t[0]=t[t.length-1],C1(i),i.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>SB?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},x=m&&!d&&xB(_),M=(E=(y=_.motionValue)==null?void 0:y.owner)==null?void 0:E.current;let S;if(x)try{S=new pB({..._,element:M})}catch{S=new em(_)}else S=new em(_);S.finished.then(()=>{this.notifyFinished()}).catch(Js),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),rB()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function K4(e,t,n,i=0,a=1){const o=Array.from(e).sort((d,p)=>d.sortNodePosition(p)).indexOf(t),l=e.size,u=(l-1)*i;return typeof n=="function"?n(o,l):a===1?o*i:u-o*i}const TB=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function AB(e){const t=TB.exec(e);if(!t)return[,];const[,n,i,a]=t;return[`--${n??i}`,a]}function Z4(e,t,n=1){const[i,a]=AB(e);if(!i)return;const o=window.getComputedStyle(t).getPropertyValue(i);if(o){const l=o.trim();return h4(l)?parseFloat(l):l}return by(a)?Z4(a,t,n+1):a}const EB={type:"spring",stiffness:500,damping:25,restSpeed:10},wB=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),RB={type:"keyframes",duration:.8},CB={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},DB=(e,{keyframes:t})=>t.length>2?RB:Ru.has(e)?e.startsWith("scale")?wB(t[1]):EB:CB;function Q4(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...i}=e;return{...t,...i}}return e}function Ty(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?Q4(n,e):n}const LB=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function NB(e){for(const t in e)if(!LB.has(t))return!0;return!1}const Ay=(e,t,n,i={},a,o)=>l=>{const u=Ty(i,e)||{},h=u.delay||i.delay||0;let{elapsed:d=0}=i;d=d-Rs(h);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...u,delay:-d,onUpdate:b=>{t.set(b),u.onUpdate&&u.onUpdate(b)},onComplete:()=>{l(),u.onComplete&&u.onComplete()},name:e,motionValue:t,element:o?void 0:a};NB(u)||Object.assign(p,DB(e,p)),p.duration&&(p.duration=Rs(p.duration)),p.repeatDelay&&(p.repeatDelay=Rs(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let m=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(C1(p),p.delay===0&&(m=!0)),(To.instantAnimations||To.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(m=!0,C1(p),p.delay=0),p.allowFlatten=!u.type&&!u.ease,m&&!o&&t.get()!==void 0){const b=Pm(p.keyframes,u);if(b!==void 0){mn.update(()=>{p.onUpdate(b),p.onComplete()});return}}return u.isSync?new em(p):new MB(p)};function dE(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function Ey(e,t,n,i){if(typeof t=="function"){const[a,o]=dE(i);t=t(n!==void 0?n:e.custom,a,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,o]=dE(i);t=t(n!==void 0?n:e.custom,a,o)}return t}function vl(e,t,n){const i=e.getProps();return Ey(i,t,n!==void 0?n:i.custom,e)}const J4=new Set(["width","height","top","left","right","bottom",...wu]),pE=30,PB=e=>!isNaN(parseFloat(e));class UB{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var o;const a=qi.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=qi.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=PB(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new py);const i=this.events[t].add(n);return t==="change"?()=>{i(),mn.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=qi.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>pE)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,pE);return g4(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function cu(e,t){return new UB(e,t)}const D1=e=>Array.isArray(e);function OB(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,cu(n))}function FB(e){return D1(e)?e[e.length-1]||0:e}function IB(e,t){const n=vl(e,t);let{transitionEnd:i={},transition:a={},...o}=n||{};o={...o,...i};for(const l in o){const u=FB(o[l]);OB(e,l,u)}}const wi=e=>!!(e&&e.getVelocity);function kB(e){return!!(wi(e)&&e.add)}function L1(e,t){const n=e.getValue("willChange");if(kB(n))return n.add(t);if(!n&&To.WillChange){const i=new To.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function wy(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const BB="framerAppearId",$4="data-"+wy(BB);function tC(e){return e.props[$4]}function zB({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function eC(e,t,{delay:n=0,transitionOverride:i,type:a}={}){let{transition:o,transitionEnd:l,...u}=t;const h=e.getDefaultTransition();o=o?Q4(o,h):h;const d=o==null?void 0:o.reduceMotion;i&&(o=i);const p=[],m=a&&e.animationState&&e.animationState.getState()[a];for(const b in u){const _=e.getValue(b,e.latestValues[b]??null),x=u[b];if(x===void 0||m&&zB(m,b))continue;const M={delay:n,...Ty(o||{},b)},S=_.get();if(S!==void 0&&!_.isAnimating()&&!Array.isArray(x)&&x===S&&!M.velocity){mn.update(()=>_.set(x));continue}let y=!1;if(window.MotionHandoffAnimation){const A=tC(e);if(A){const U=window.MotionHandoffAnimation(A,b,mn);U!==null&&(M.startTime=U,y=!0)}}L1(e,b);const E=d??e.shouldReduceMotion;_.start(Ay(b,_,x,E&&J4.has(b)?{type:!1}:M,e,y));const w=_.animation;w&&p.push(w)}if(l){const b=()=>mn.update(()=>{l&&IB(e,l)});p.length?Promise.all(p).then(b):b()}return p}function N1(e,t,n={}){var h;const i=vl(e,t,n.type==="exit"?(h=e.presenceContext)==null?void 0:h.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(a=n.transitionOverride);const o=i?()=>Promise.all(eC(e,i,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:b}=a;return VB(e,t,d,p,m,b,n)}:()=>Promise.resolve(),{when:u}=a;if(u){const[d,p]=u==="beforeChildren"?[o,l]:[l,o];return d().then(()=>p())}else return Promise.all([o(),l(n.delay)])}function VB(e,t,n=0,i=0,a=0,o=1,l){const u=[];for(const h of e.variantChildren)h.notify("AnimationStart",t),u.push(N1(h,t,{...l,delay:n+(typeof i=="function"?0:i)+K4(e.variantChildren,h,i,a,o)}).then(()=>h.notify("AnimationComplete",t)));return Promise.all(u)}function GB(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const a=t.map(o=>N1(e,o,n));i=Promise.all(a)}else if(typeof t=="string")i=N1(e,t,n);else{const a=typeof t=="function"?vl(e,t,n.custom):t;i=Promise.all(eC(e,a,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const HB={test:e=>e==="auto",parse:e=>e},nC=e=>t=>t.test(e),iC=[Eu,qt,Ua,oo,mk,pk,HB],mE=e=>iC.find(nC(e));function jB(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||p4(e):!0}const WB=new Set(["brightness","contrast","saturate","opacity"]);function XB(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(vy)||[];if(!i)return e;const a=n.replace(i,"");let o=WB.has(t)?1:0;return i!==n&&(o*=100),t+"("+o+a+")"}const qB=/\b([a-z-]*)\(.*?\)/gu,P1={...pa,getAnimatableNone:e=>{const t=e.match(qB);return t?t.map(XB).join(" "):e}},U1={...pa,getAnimatableNone:e=>{const t=pa.parse(e);return pa.createTransformer(e)(t.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},gE={...Eu,transform:Math.round},YB={rotate:oo,rotateX:oo,rotateY:oo,rotateZ:oo,scale:mp,scaleX:mp,scaleY:mp,scaleZ:mp,skew:oo,skewX:oo,skewY:oo,distance:qt,translateX:qt,translateY:qt,translateZ:qt,x:qt,y:qt,z:qt,perspective:qt,transformPerspective:qt,opacity:oh,originX:nE,originY:nE,originZ:qt},Ry={borderWidth:qt,borderTopWidth:qt,borderRightWidth:qt,borderBottomWidth:qt,borderLeftWidth:qt,borderRadius:qt,borderTopLeftRadius:qt,borderTopRightRadius:qt,borderBottomRightRadius:qt,borderBottomLeftRadius:qt,width:qt,maxWidth:qt,height:qt,maxHeight:qt,top:qt,right:qt,bottom:qt,left:qt,inset:qt,insetBlock:qt,insetBlockStart:qt,insetBlockEnd:qt,insetInline:qt,insetInlineStart:qt,insetInlineEnd:qt,padding:qt,paddingTop:qt,paddingRight:qt,paddingBottom:qt,paddingLeft:qt,paddingBlock:qt,paddingBlockStart:qt,paddingBlockEnd:qt,paddingInline:qt,paddingInlineStart:qt,paddingInlineEnd:qt,margin:qt,marginTop:qt,marginRight:qt,marginBottom:qt,marginLeft:qt,marginBlock:qt,marginBlockStart:qt,marginBlockEnd:qt,marginInline:qt,marginInlineStart:qt,marginInlineEnd:qt,fontSize:qt,backgroundPositionX:qt,backgroundPositionY:qt,...YB,zIndex:gE,fillOpacity:oh,strokeOpacity:oh,numOctaves:gE},KB={...Ry,color:Qn,backgroundColor:Qn,outlineColor:Qn,fill:Qn,stroke:Qn,borderColor:Qn,borderTopColor:Qn,borderRightColor:Qn,borderBottomColor:Qn,borderLeftColor:Qn,filter:P1,WebkitFilter:P1,mask:U1,WebkitMask:U1},sC=e=>KB[e],ZB=new Set([P1,U1]);function aC(e,t){let n=sC(e);return ZB.has(n)||(n=pa),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const QB=new Set(["auto","none","0"]);function JB(e,t,n){let i=0,a;for(;i{t.getValue(h).set(d)}),this.resolveNoneKeyframes()}}function rC(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let i=document;const a=(n==null?void 0:n[e])??i.querySelectorAll(e);return a?Array.from(a):[]}return Array.from(e).filter(i=>i!=null)}const oC=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Cp(e){return d4(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:Cy}=w4(queueMicrotask,!1),la={x:!1,y:!1};function lC(){return la.x||la.y}function tz(e){return e==="x"||e==="y"?la[e]?null:(la[e]=!0,()=>{la[e]=!1}):la.x||la.y?null:(la.x=la.y=!0,()=>{la.x=la.y=!1})}function cC(e,t){const n=rC(e),i=new AbortController,a={passive:!0,...t,signal:i.signal};return[n,a,()=>i.abort()]}function ez(e){return!(e.pointerType==="touch"||lC())}function nz(e,t,n={}){const[i,a,o]=cC(e,n);return i.forEach(l=>{let u=!1,h=!1,d;const p=()=>{l.removeEventListener("pointerleave",x)},m=S=>{d&&(d(S),d=void 0),p()},b=S=>{u=!1,window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b),h&&(h=!1,m(S))},_=()=>{u=!0,window.addEventListener("pointerup",b,a),window.addEventListener("pointercancel",b,a)},x=S=>{if(S.pointerType!=="touch"){if(u){h=!0;return}m(S)}},M=S=>{if(!ez(S))return;h=!1;const y=t(l,S);typeof y=="function"&&(d=y,l.addEventListener("pointerleave",x,a))};l.addEventListener("pointerenter",M,a),l.addEventListener("pointerdown",_,a)}),o}const uC=(e,t)=>t?e===t?!0:uC(e,t.parentElement):!1,Dy=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,iz=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function sz(e){return iz.has(e.tagName)||e.isContentEditable===!0}const az=new Set(["INPUT","SELECT","TEXTAREA"]);function rz(e){return az.has(e.tagName)||e.isContentEditable===!0}const Dp=new WeakSet;function bE(e){return t=>{t.key==="Enter"&&e(t)}}function Wb(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const oz=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=bE(()=>{if(Dp.has(n))return;Wb(n,"down");const a=bE(()=>{Wb(n,"up")}),o=()=>Wb(n,"cancel");n.addEventListener("keyup",a,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function vE(e){return Dy(e)&&!lC()}const _E=new WeakSet;function lz(e,t,n={}){const[i,a,o]=cC(e,n),l=u=>{const h=u.currentTarget;if(!vE(u)||_E.has(u))return;Dp.add(h),n.stopPropagation&&_E.add(u);const d=t(h,u),p=(_,x)=>{window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",b),Dp.has(h)&&Dp.delete(h),vE(_)&&typeof d=="function"&&d(_,{success:x})},m=_=>{p(_,h===window||h===document||n.useGlobalTarget||uC(h,_.target))},b=_=>{p(_,!1)};window.addEventListener("pointerup",m,a),window.addEventListener("pointercancel",b,a)};return i.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",l,a),Cp(u)&&(u.addEventListener("focus",d=>oz(d,a)),!sz(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function Ly(e){return d4(e)&&"ownerSVGElement"in e}const Lp=new WeakMap;let lo;const fC=(e,t,n)=>(i,a)=>a&&a[0]?a[0][e+"Size"]:Ly(i)&&"getBBox"in i?i.getBBox()[t]:i[n],cz=fC("inline","width","offsetWidth"),uz=fC("block","height","offsetHeight");function fz({target:e,borderBoxSize:t}){var n;(n=Lp.get(e))==null||n.forEach(i=>{i(e,{get width(){return cz(e,t)},get height(){return uz(e,t)}})})}function hz(e){e.forEach(fz)}function dz(){typeof ResizeObserver>"u"||(lo=new ResizeObserver(hz))}function pz(e,t){lo||dz();const n=rC(e);return n.forEach(i=>{let a=Lp.get(i);a||(a=new Set,Lp.set(i,a)),a.add(t),lo==null||lo.observe(i)}),()=>{n.forEach(i=>{const a=Lp.get(i);a==null||a.delete(t),a!=null&&a.size||lo==null||lo.unobserve(i)})}}const Np=new Set;let Nc;function mz(){Nc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Np.forEach(t=>t(e))},window.addEventListener("resize",Nc)}function gz(e){return Np.add(e),Nc||mz(),()=>{Np.delete(e),!Np.size&&typeof Nc=="function"&&(window.removeEventListener("resize",Nc),Nc=void 0)}}function yE(e,t){return typeof e=="function"?gz(e):pz(e,t)}function bz(e){return Ly(e)&&e.tagName==="svg"}const vz=[...iC,Qn,pa],_z=e=>vz.find(nC(e)),xE=()=>({translate:0,scale:1,origin:0,originPoint:0}),Pc=()=>({x:xE(),y:xE()}),SE=()=>({min:0,max:0}),oi=()=>({x:SE(),y:SE()}),yz=new WeakMap;function Um(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function lh(e){return typeof e=="string"||Array.isArray(e)}const Ny=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Py=["initial",...Ny];function Om(e){return Um(e.animate)||Py.some(t=>lh(e[t]))}function hC(e){return!!(Om(e)||e.variants)}function xz(e,t,n){for(const i in t){const a=t[i],o=n[i];if(wi(a))e.addValue(i,a);else if(wi(o))e.addValue(i,cu(a,{owner:e}));else if(o!==a)if(e.hasValue(i)){const l=e.getValue(i);l.liveStyle===!0?l.jump(a):l.hasAnimated||l.set(a)}else{const l=e.getStaticValue(i);e.addValue(i,cu(l!==void 0?l:a,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const O1={current:null},dC={current:!1},Sz=typeof window<"u";function Mz(){if(dC.current=!0,!!Sz)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>O1.current=e.matches;e.addEventListener("change",t),t()}else O1.current=!1}const ME=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let nm={};function pC(e){nm=e}function Tz(){return nm}class Az{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:u},h={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=My,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const _=qi.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,mn.render(this.render,!1,!0))};const{latestValues:d,renderState:p}=u;this.latestValues=d,this.baseTarget={...d},this.initialValues=n.initial?{...d}:{},this.renderState=p,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=h,this.blockInitialAnimation=!!l,this.isControllingVariants=Om(n),this.isVariantNode=hC(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:m,...b}=this.scrapeMotionValuesFromProps(n,{},this);for(const _ in b){const x=b[_];d[_]!==void 0&&wi(x)&&x.set(d[_])}}mount(t){var n,i;if(this.hasBeenMounted)for(const a in this.initialValues)(n=this.values.get(a))==null||n.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=t,yz.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,o)=>this.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(dC.current||Mz(),this.shouldReduceMotion=O1.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(i=this.parent)==null||i.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),Ao(this.notifyUpdate),Ao(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const i=this.features[n];i&&(i.unmount(),i.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&Y4.has(t)&&this.current instanceof HTMLElement){const{factory:l,keyframes:u,times:h,ease:d,duration:p}=n.accelerate,m=new X4({element:this.current,name:t,keyframes:u,times:h,ease:d,duration:Rs(p)}),b=l(m);this.valueSubscriptions.set(t,()=>{b(),m.cancel()});return}const i=Ru.has(t);i&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&mn.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in nm){const n=nm[t];if(!n)continue;const{isEnabled:i,Feature:a}=n;if(!this.features[t]&&a&&i(this.props)&&(this.features[t]=new a(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):oi()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;in.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=cu(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(h4(i)||p4(i))?i=parseFloat(i):!_z(i)&&pa.test(n)&&(i=aC(t,n)),this.setBaseTarget(t,wi(i)?i.get():i)),wi(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var o;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const l=Ey(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);l&&(i=l[t])}if(n&&i!==void 0)return i;const a=this.getBaseTargetFromProps(this.props,t);return a!==void 0&&!wi(a)?a:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new py),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Cy.render(this.render)}}class mC extends Az{constructor(){super(...arguments),this.KeyframeResolver=$B}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const i=t.style;return i?i[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;wi(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class wo{constructor(t){this.isMounted=!1,this.node=t}update(){}}function gC({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function Ez({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function wz(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function Xb(e){return e===void 0||e===1}function F1({scale:e,scaleX:t,scaleY:n}){return!Xb(e)||!Xb(t)||!Xb(n)}function al(e){return F1(e)||bC(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function bC(e){return TE(e.x)||TE(e.y)}function TE(e){return e&&e!=="0%"}function im(e,t,n){const i=e-n,a=t*i;return n+a}function AE(e,t,n,i,a){return a!==void 0&&(e=im(e,a,i)),im(e,n,i)+t}function I1(e,t=0,n=1,i,a){e.min=AE(e.min,t,n,i,a),e.max=AE(e.max,t,n,i,a)}function vC(e,{x:t,y:n}){I1(e.x,t.translate,t.scale,t.originPoint),I1(e.y,n.translate,n.scale,n.originPoint)}const EE=.999999999999,wE=1.0000000000001;function Rz(e,t,n,i=!1){var u;const a=n.length;if(!a)return;t.x=t.y=1;let o,l;for(let h=0;hEE&&(t.x=1),t.yEE&&(t.y=1)}function Ca(e,t){e.min+=t,e.max+=t}function RE(e,t,n,i,a=.5){const o=xn(e.min,e.max,a);I1(e,t,n,o,i)}function CE(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Pp(e,t,n){const i=n??e;RE(e.x,CE(t.x,i.x),t.scaleX,t.scale,t.originX),RE(e.y,CE(t.y,i.y),t.scaleY,t.scale,t.originY)}function _C(e,t){return gC(wz(e.getBoundingClientRect(),t))}function Cz(e,t,n){const i=_C(e,n),{scroll:a}=t;return a&&(Ca(i.x,a.offset.x),Ca(i.y,a.offset.y)),i}const Dz={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Lz=wu.length;function Nz(e,t,n){let i="",a=!0;for(let o=0;o{if(!t.target)return e;if(typeof e=="string")if(qt.test(e))e=parseFloat(e);else return e;const n=DE(e,t.target.x),i=DE(e,t.target.y);return`${n}% ${i}%`}},Pz={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,a=pa.parse(e);if(a.length>5)return i;const o=pa.createTransformer(e),l=typeof a[0]!="number"?1:0,u=n.x.scale*t.x,h=n.y.scale*t.y;a[0+l]/=u,a[1+l]/=h;const d=xn(u,h,.5);return typeof a[2+l]=="number"&&(a[2+l]/=d),typeof a[3+l]=="number"&&(a[3+l]/=d),o(a)}},k1={borderRadius:{...Df,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Df,borderTopRightRadius:Df,borderBottomLeftRadius:Df,borderBottomRightRadius:Df,boxShadow:Pz};function xC(e,{layout:t,layoutId:n}){return Ru.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!k1[e]||e==="opacity")}function Oy(e,t,n){var l;const i=e.style,a=t==null?void 0:t.style,o={};if(!i)return o;for(const u in i)(wi(i[u])||a&&wi(a[u])||xC(u,e)||((l=n==null?void 0:n.getValue(u))==null?void 0:l.liveStyle)!==void 0)&&(o[u]=i[u]);return o}function Uz(e){return window.getComputedStyle(e)}class Oz extends mC{constructor(){super(...arguments),this.type="html",this.renderInstance=yC}readValueFromInstance(t,n){var i;if(Ru.has(n))return(i=this.projection)!=null&&i.isProjecting?T1(n):eB(t,n);{const a=Uz(t),o=(C4(n)?a.getPropertyValue(n):a[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return _C(t,n)}build(t,n,i){Uy(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return Oy(t,n,i)}}const Fz={offset:"stroke-dashoffset",array:"stroke-dasharray"},Iz={offset:"strokeDashoffset",array:"strokeDasharray"};function kz(e,t,n=1,i=0,a=!0){e.pathLength=1;const o=a?Fz:Iz;e[o.offset]=`${-i}`,e[o.array]=`${t} ${n}`}const Bz=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function SC(e,{attrX:t,attrY:n,attrScale:i,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...u},h,d,p){if(Uy(e,u,d),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:m,style:b}=e;m.transform&&(b.transform=m.transform,delete m.transform),(b.transform||m.transformOrigin)&&(b.transformOrigin=m.transformOrigin??"50% 50%",delete m.transformOrigin),b.transform&&(b.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete m.transformBox);for(const _ of Bz)m[_]!==void 0&&(b[_]=m[_],delete m[_]);t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),i!==void 0&&(m.scale=i),a!==void 0&&kz(m,a,o,l,!1)}const MC=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),TC=e=>typeof e=="string"&&e.toLowerCase()==="svg";function zz(e,t,n,i){yC(e,t,void 0,i);for(const a in t.attrs)e.setAttribute(MC.has(a)?a:wy(a),t.attrs[a])}function AC(e,t,n){const i=Oy(e,t,n);for(const a in e)if(wi(e[a])||wi(t[a])){const o=wu.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;i[o]=e[a]}return i}class Vz extends mC{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=oi}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Ru.has(n)){const i=sC(n);return i&&i.default||0}return n=MC.has(n)?n:wy(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return AC(t,n,i)}build(t,n,i){SC(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,a){zz(t,n,i,a)}mount(t){this.isSVGTag=TC(t.tagName),super.mount(t)}}const Gz=Py.length;function EC(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?EC(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;nPromise.all(t.map(({animation:n,options:i})=>GB(e,n,i)))}function Xz(e){let t=Wz(e),n=LE(),i=!0,a=!1;const o=d=>(p,m)=>{var _;const b=vl(e,m,d==="exit"?(_=e.presenceContext)==null?void 0:_.custom:void 0);if(b){const{transition:x,transitionEnd:M,...S}=b;p={...p,...S,...M}}return p};function l(d){t=d(e)}function u(d){const{props:p}=e,m=EC(e.parent)||{},b=[],_=new Set;let x={},M=1/0;for(let y=0;yM&&U,R=!1;const I=Array.isArray(A)?A:[A];let Z=I.reduce(o(E),{});O===!1&&(Z={});const{prevResolvedValues:nt={}}=w,ct={...nt,...Z},ft=q=>{C=!0,_.has(q)&&(R=!0,_.delete(q)),w.needsAnimating[q]=!0;const yt=e.getValue(q);yt&&(yt.liveStyle=!1)};for(const q in ct){const yt=Z[q],At=nt[q];if(x.hasOwnProperty(q))continue;let B=!1;D1(yt)&&D1(At)?B=!wC(yt,At):B=yt!==At,B?yt!=null?ft(q):_.add(q):yt!==void 0&&_.has(q)?ft(q):w.protectedKeys[q]=!0}w.prevProp=A,w.prevResolvedValues=Z,w.isActive&&(x={...x,...Z}),(i||a)&&e.blockInitialAnimation&&(C=!1);const z=P&&F;C&&(!z||R)&&b.push(...I.map(q=>{const yt={type:E};if(typeof q=="string"&&(i||a)&&!z&&e.manuallyAnimateOnMount&&e.parent){const{parent:At}=e,B=vl(At,q);if(At.enteringChildren&&B){const{delayChildren:et}=B.transition||{};yt.delay=K4(At.enteringChildren,e,et)}}return{animation:q,options:yt}}))}if(_.size){const y={};if(typeof p.initial!="boolean"){const E=vl(e,Array.isArray(p.initial)?p.initial[0]:p.initial);E&&E.transition&&(y.transition=E.transition)}_.forEach(E=>{const w=e.getBaseTarget(E),A=e.getValue(E);A&&(A.liveStyle=!0),y[E]=w??null}),b.push({animation:y})}let S=!!b.length;return i&&(p.initial===!1||p.initial===p.animate)&&!e.manuallyAnimateOnMount&&(S=!1),i=!1,a=!1,S?t(b):Promise.resolve()}function h(d,p){var b;if(n[d].isActive===p)return Promise.resolve();(b=e.variantChildren)==null||b.forEach(_=>{var x;return(x=_.animationState)==null?void 0:x.setActive(d,p)}),n[d].isActive=p;const m=u(d);for(const _ in n)n[_].protectedKeys={};return m}return{animateChanges:u,setActive:h,setAnimateFunction:l,getState:()=>n,reset:()=>{n=LE(),a=!0}}}function qz(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!wC(t,e):!1}function tl(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function LE(){return{animate:tl(!0),whileInView:tl(),whileHover:tl(),whileTap:tl(),whileDrag:tl(),whileFocus:tl(),exit:tl()}}function B1(e,t){e.min=t.min,e.max=t.max}function oa(e,t){B1(e.x,t.x),B1(e.y,t.y)}function NE(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const RC=1e-4,Yz=1-RC,Kz=1+RC,CC=.01,Zz=0-CC,Qz=0+CC;function Yi(e){return e.max-e.min}function Jz(e,t,n){return Math.abs(e-t)<=n}function PE(e,t,n,i=.5){e.origin=i,e.originPoint=xn(t.min,t.max,e.origin),e.scale=Yi(n)/Yi(t),e.translate=xn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Yz&&e.scale<=Kz||isNaN(e.scale))&&(e.scale=1),(e.translate>=Zz&&e.translate<=Qz||isNaN(e.translate))&&(e.translate=0)}function Kf(e,t,n,i){PE(e.x,t.x,n.x,i?i.originX:void 0),PE(e.y,t.y,n.y,i?i.originY:void 0)}function UE(e,t,n,i=0){const a=i?xn(n.min,n.max,i):n.min;e.min=a+t.min,e.max=e.min+Yi(t)}function $z(e,t,n,i){UE(e.x,t.x,n.x,i==null?void 0:i.x),UE(e.y,t.y,n.y,i==null?void 0:i.y)}function OE(e,t,n,i=0){const a=i?xn(n.min,n.max,i):n.min;e.min=t.min-a,e.max=e.min+Yi(t)}function sm(e,t,n,i){OE(e.x,t.x,n.x,i==null?void 0:i.x),OE(e.y,t.y,n.y,i==null?void 0:i.y)}function FE(e,t,n,i,a){return e-=t,e=im(e,1/n,i),a!==void 0&&(e=im(e,1/a,i)),e}function t7(e,t=0,n=1,i=.5,a,o=e,l=e){if(Ua.test(t)&&(t=parseFloat(t),t=xn(l.min,l.max,t/100)-l.min),typeof t!="number")return;let u=xn(o.min,o.max,i);e===o&&(u-=t),e.min=FE(e.min,t,n,u,a),e.max=FE(e.max,t,n,u,a)}function IE(e,t,[n,i,a],o,l){t7(e,t[n],t[i],t[a],t.scale,o,l)}const e7=["x","scaleX","originX"],n7=["y","scaleY","originY"];function kE(e,t,n,i){IE(e.x,t,e7,n?n.x:void 0,i?i.x:void 0),IE(e.y,t,n7,n?n.y:void 0,i?i.y:void 0)}function BE(e){return e.translate===0&&e.scale===1}function DC(e){return BE(e.x)&&BE(e.y)}function zE(e,t){return e.min===t.min&&e.max===t.max}function i7(e,t){return zE(e.x,t.x)&&zE(e.y,t.y)}function VE(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function LC(e,t){return VE(e.x,t.x)&&VE(e.y,t.y)}function GE(e){return Yi(e.x)/Yi(e.y)}function HE(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function wa(e){return[e("x"),e("y")]}function s7(e,t,n){let i="";const a=e.x.translate/t.x,o=e.y.translate/t.y,l=(n==null?void 0:n.z)||0;if((a||o||l)&&(i=`translate3d(${a}px, ${o}px, ${l}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:p,rotateX:m,rotateY:b,skewX:_,skewY:x}=n;d&&(i=`perspective(${d}px) ${i}`),p&&(i+=`rotate(${p}deg) `),m&&(i+=`rotateX(${m}deg) `),b&&(i+=`rotateY(${b}deg) `),_&&(i+=`skewX(${_}deg) `),x&&(i+=`skewY(${x}deg) `)}const u=e.x.scale*t.x,h=e.y.scale*t.y;return(u!==1||h!==1)&&(i+=`scale(${u}, ${h})`),i||"none"}const NC=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],a7=NC.length,jE=e=>typeof e=="string"?parseFloat(e):e,WE=e=>typeof e=="number"||qt.test(e);function r7(e,t,n,i,a,o){a?(e.opacity=xn(0,n.opacity??1,o7(i)),e.opacityExit=xn(t.opacity??1,0,l7(i))):o&&(e.opacity=xn(t.opacity??1,n.opacity??1,i));for(let l=0;lit?1:n(rh(e,t,i))}function c7(e,t,n){const i=wi(e)?e:cu(e);return i.start(Ay("",i,t,n)),i.animation}function ch(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}const u7=(e,t)=>e.depth-t.depth;class f7{constructor(){this.children=[],this.isDirty=!1}add(t){hy(this.children,t),this.isDirty=!0}remove(t){Qp(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(u7),this.isDirty=!1,this.children.forEach(t)}}function h7(e,t){const n=qi.now(),i=({timestamp:a})=>{const o=a-n;o>=t&&(Ao(i),e(o-t))};return mn.setup(i,!0),()=>Ao(i)}function Up(e){return wi(e)?e.get():e}class d7{constructor(){this.members=[]}add(t){hy(this.members,t);for(let n=this.members.length-1;n>=0;n--){const i=this.members[n];if(i===t||i===this.lead||i===this.prevLead)continue;const a=i.instance;(!a||a.isConnected===!1)&&!i.snapshot&&(Qp(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(Qp(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let i=this.members.indexOf(t)-1;i>=0;i--){const a=this.members[i];if(a.isPresent!==!1&&((n=a.instance)==null?void 0:n.isConnected)!==!1)return this.promote(a),!0}return!1}promote(t,n){var a;const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.updateSnapshot(),t.scheduleRender();const{layoutDependency:o}=i.options,{layoutDependency:l}=t.options;(o===void 0||o!==l)&&(t.resumeFrom=i,n&&(i.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),(a=t.root)!=null&&a.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,i,a,o,l;(i=(n=t.options).onExitComplete)==null||i.call(n),(l=(a=t.resumingFrom)==null?void 0:(o=a.options).onExitComplete)==null||l.call(o)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const Op={hasAnimatedSinceResize:!0,hasEverUpdated:!1},qb=["","X","Y","Z"],p7=1e3;let m7=0;function Yb(e,t,n,i){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),i&&(i[e]=0))}function UC(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=tC(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",mn,!(a||o))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&UC(i)}function OC({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:a}){return class{constructor(l={},u=t==null?void 0:t()){this.id=m7++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(v7),this.nodes.forEach(T7),this.nodes.forEach(A7),this.nodes.forEach(_7)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let h=0;hthis.root.updateBlockedByResize=!1;mn.read(()=>{m=window.innerWidth}),e(l,()=>{const _=window.innerWidth;_!==m&&(m=_,this.root.updateBlockedByResize=!0,p&&p(),p=h7(b,250),Op.hasAnimatedSinceResize&&(Op.hasAnimatedSinceResize=!1,this.nodes.forEach(KE)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&d&&(u||h)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:m,hasRelativeLayoutChanged:b,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||d.getDefaultTransition()||D7,{onLayoutAnimationStart:M,onLayoutAnimationComplete:S}=d.getProps(),y=!this.targetLayout||!LC(this.targetLayout,_),E=!m&&b;if(this.options.layoutRoot||this.resumeFrom||E||m&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...Ty(x,"layout"),onPlay:M,onComplete:S};(d.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(p,E)}else m||KE(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=_})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ao(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(E7),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&UC(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Yi(this.snapshot.measuredBox.x)&&!Yi(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h{const U=A/1e3;ZE(m.x,l.x,U),ZE(m.y,l.y,U),this.setTargetDelta(m),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(sm(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),R7(this.relativeTarget,this.relativeTargetOrigin,b,U),w&&i7(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=oi()),oa(w,this.relativeTarget)),M&&(this.animationValues=p,r7(p,d,this.latestValues,U,E,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=U},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var u,h,d;this.notifyListeners("animationStart"),(u=this.currentAnimation)==null||u.stop(),(d=(h=this.resumingFrom)==null?void 0:h.currentAnimation)==null||d.stop(),this.pendingAnimation&&(Ao(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=mn.update(()=>{Op.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=cu(0)),this.motionValue.jump(0,!1),this.currentAnimation=c7(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(p7),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:u,target:h,layout:d,latestValues:p}=l;if(!(!u||!h||!d)){if(this!==l&&this.layout&&d&&FC(this.options.animationType,this.layout.layoutBox,d.layoutBox)){h=this.target||oi();const m=Yi(this.layout.layoutBox.x);h.x.min=l.target.x.min,h.x.max=h.x.min+m;const b=Yi(this.layout.layoutBox.y);h.y.min=l.target.y.min,h.y.max=h.y.min+b}oa(u,h),Pp(u,p),Kf(this.projectionDeltaWithTransform,this.layoutCorrected,u,p)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new d7),this.sharedNodes.get(l).add(u);const d=u.options.initialPromotionConfig;u.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(u):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var u;const{layoutId:l}=this.options;return l?((u=this.getStack())==null?void 0:u.lead)||this:this}getPrevLead(){var u;const{layoutId:l}=this.options;return l?(u=this.getStack())==null?void 0:u.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:u,preserveFollowOpacity:h}={}){const d=this.getStack();d&&d.promote(this,h),l&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let u=!1;const{latestValues:h}=l;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(u=!0),!u)return;const d={};h.z&&Yb("z",l,d,this.animationValues);for(let p=0;p{var u;return(u=l.currentAnimation)==null?void 0:u.stop()}),this.root.nodes.forEach(qE),this.root.sharedNodes.clear()}}}function g7(e){e.updateLayout()}function b7(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:a}=e.layout,{animationType:o}=e.options,l=t.source!==e.layout.source;if(o==="size")wa(m=>{const b=l?t.measuredBox[m]:t.layoutBox[m],_=Yi(b);b.min=i[m].min,b.max=b.min+_});else if(o==="x"||o==="y"){const m=o==="x"?"y":"x";B1(l?t.measuredBox[m]:t.layoutBox[m],i[m])}else FC(o,t.layoutBox,i)&&wa(m=>{const b=l?t.measuredBox[m]:t.layoutBox[m],_=Yi(i[m]);b.max=b.min+_,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+_)});const u=Pc();Kf(u,i,t.layoutBox);const h=Pc();l?Kf(h,e.applyTransform(a,!0),t.measuredBox):Kf(h,i,t.layoutBox);const d=!DC(u);let p=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:b,layout:_}=m;if(b&&_){const x=e.options.layoutAnchor||void 0,M=oi();sm(M,t.layoutBox,b.layoutBox,x);const S=oi();sm(S,i,_.layoutBox,x),LC(M,S)||(p=!0),m.options.layoutRoot&&(e.relativeTarget=S,e.relativeTargetOrigin=M,e.relativeParent=m)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:h,layoutDelta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:p})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function v7(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function _7(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function y7(e){e.clearSnapshot()}function qE(e){e.clearMeasurements()}function x7(e){e.isLayoutDirty=!0,e.updateLayout()}function YE(e){e.isLayoutDirty=!1}function S7(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function M7(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function KE(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function T7(e){e.resolveTargetDelta()}function A7(e){e.calcProjection()}function E7(e){e.resetSkewAndRotation()}function w7(e){e.removeLeadSnapshot()}function ZE(e,t,n){e.translate=xn(t.translate,0,n),e.scale=xn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function QE(e,t,n,i){e.min=xn(t.min,n.min,i),e.max=xn(t.max,n.max,i)}function R7(e,t,n,i){QE(e.x,t.x,n.x,i),QE(e.y,t.y,n.y,i)}function C7(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const D7={duration:.45,ease:[.4,0,.1,1]},JE=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),$E=JE("applewebkit/")&&!JE("chrome/")?Math.round:Js;function t3(e){e.min=$E(e.min),e.max=$E(e.max)}function L7(e){t3(e.x),t3(e.y)}function FC(e,t,n){return e==="position"||e==="preserve-aspect"&&!Jz(GE(t),GE(n),.2)}function N7(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const P7=OC({attachResizeListener:(e,t)=>ch(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),Kb={current:void 0},IC=OC({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Kb.current){const e=new P7({});e.mount(window),e.setOptions({layoutScroll:!0}),Kb.current=e}return Kb.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Fy=dt.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function e3(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function U7(...e){return t=>{let n=!1;const i=e.map(a=>{const o=e3(a,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a{const{width:_,height:x,top:M,left:S,right:y,bottom:E}=h.current;if(t||o===!1||!u.current||!_||!x)return;const w=n==="left"?`left: ${S}`:`right: ${y}`,A=i==="bottom"?`bottom: ${E}`:`top: ${M}`;u.current.dataset.motionPopId=l;const U=document.createElement("style");d&&(U.nonce=d);const O=a??document.head;return O.appendChild(U),U.sheet&&U.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${x}px !important; ${w}px !important; ${A}px !important; } `),()=>{var P;(P=u.current)==null||P.removeAttribute("data-motion-pop-id"),O.contains(U)&&O.removeChild(U)}},[t]),rt.jsx(F7,{isPresent:t,childRef:u,sizeRef:h,pop:o,children:o===!1?e:dt.cloneElement(e,{ref:m})})}const k7=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:a,presenceAffectsLayout:o,mode:l,anchorX:u,anchorY:h,root:d})=>{const p=fy(B7),m=dt.useId();let b=!0,_=dt.useMemo(()=>(b=!1,{id:m,initial:t,isPresent:n,custom:a,onExitComplete:x=>{p.set(x,!0);for(const M of p.values())if(!M)return;i&&i()},register:x=>(p.set(x,!1),()=>p.delete(x))}),[n,p,i]);return o&&b&&(_={..._}),dt.useMemo(()=>{p.forEach((x,M)=>p.set(M,!1))},[n]),dt.useEffect(()=>{!n&&!p.size&&i&&i()},[n]),e=rt.jsx(I7,{pop:l==="popLayout",isPresent:n,anchorX:u,anchorY:h,root:d,children:e}),rt.jsx(Nm.Provider,{value:_,children:e})};function B7(){return new Map}function kC(e=!0){const t=dt.useContext(Nm);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:a}=t,o=dt.useId();dt.useEffect(()=>{if(e)return a(o)},[e]);const l=dt.useCallback(()=>e&&i&&i(o),[o,i,e]);return!n&&i?[!1,l]:[!0]}const gp=e=>e.key||"";function n3(e){const t=[];return dt.Children.forEach(e,n=>{dt.isValidElement(n)&&t.push(n)}),t}const Zb=({children:e,custom:t,initial:n=!0,onExitComplete:i,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:u="left",anchorY:h="top",root:d})=>{const[p,m]=kC(l),b=dt.useMemo(()=>n3(e),[e]),_=l&&!p?[]:b.map(gp),x=dt.useRef(!0),M=dt.useRef(b),S=fy(()=>new Map),y=dt.useRef(new Set),[E,w]=dt.useState(b),[A,U]=dt.useState(b);f4(()=>{x.current=!1,M.current=b;for(let F=0;F{const C=gp(F),R=l&&!p?!1:b===A||_.includes(C),I=()=>{if(y.current.has(C))return;if(S.has(C))y.current.add(C),S.set(C,!0);else return;let Z=!0;S.forEach(nt=>{nt||(Z=!1)}),Z&&(P==null||P(),U(M.current),l&&(m==null||m()),i&&i())};return rt.jsx(k7,{isPresent:R,initial:!x.current||n?void 0:!1,custom:t,presenceAffectsLayout:a,mode:o,root:d,onExitComplete:R?void 0:I,anchorX:u,anchorY:h,children:F},C)})})},BC=dt.createContext({strict:!1}),i3={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let s3=!1;function z7(){if(s3)return;const e={};for(const t in i3)e[t]={isEnabled:n=>i3[t].some(i=>!!n[i])};pC(e),s3=!0}function zC(){return z7(),Tz()}function V7(e){const t=zC();for(const n in e)t[n]={...t[n],...e[n]};pC(t)}const G7=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function am(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||G7.has(e)}let VC=e=>!am(e);function H7(e){typeof e=="function"&&(VC=t=>t.startsWith("on")?!am(t):e(t))}try{H7(require("@emotion/is-prop-valid").default)}catch{}function j7(e,t,n){const i={};for(const a in e)a==="values"&&typeof e.values=="object"||wi(e[a])||(VC(a)||n===!0&&am(a)||!t&&!am(a)||e.draggable&&a.startsWith("onDrag"))&&(i[a]=e[a]);return i}const Fm=dt.createContext({});function W7(e,t){if(Om(e)){const{initial:n,animate:i}=e;return{initial:n===!1||lh(n)?n:void 0,animate:lh(i)?i:void 0}}return e.inherit!==!1?t:{}}function X7(e){const{initial:t,animate:n}=W7(e,dt.useContext(Fm));return dt.useMemo(()=>({initial:t,animate:n}),[a3(t),a3(n)])}function a3(e){return Array.isArray(e)?e.join(" "):e}const Iy=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function GC(e,t,n){for(const i in t)!wi(t[i])&&!xC(i,n)&&(e[i]=t[i])}function q7({transformTemplate:e},t){return dt.useMemo(()=>{const n=Iy();return Uy(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Y7(e,t){const n=e.style||{},i={};return GC(i,n,e),Object.assign(i,q7(e,t)),i}function K7(e,t){const n={},i=Y7(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}const HC=()=>({...Iy(),attrs:{}});function Z7(e,t,n,i){const a=dt.useMemo(()=>{const o=HC();return SC(o,t,TC(i),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};GC(o,e.style,e),a.style={...o,...a.style}}return a}const Q7=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ky(e){return typeof e!="string"||e.includes("-")?!1:!!(Q7.indexOf(e)>-1||/[A-Z]/u.test(e))}function J7(e,t,n,{latestValues:i},a,o=!1,l){const h=(l??ky(e)?Z7:K7)(t,i,a,e),d=j7(t,typeof e=="string",o),p=e!==dt.Fragment?{...d,...h,ref:n}:{},{children:m}=t,b=dt.useMemo(()=>wi(m)?m.get():m,[m]);return dt.createElement(e,{...p,children:b})}function $7({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,a){return{latestValues:tV(n,i,a,e),renderState:t()}}function tV(e,t,n,i){const a={},o=i(e,{});for(const b in o)a[b]=Up(o[b]);let{initial:l,animate:u}=e;const h=Om(e),d=hC(e);t&&d&&!h&&e.inherit!==!1&&(l===void 0&&(l=t.initial),u===void 0&&(u=t.animate));let p=n?n.initial===!1:!1;p=p||l===!1;const m=p?u:l;if(m&&typeof m!="boolean"&&!Um(m)){const b=Array.isArray(m)?m:[m];for(let _=0;_(t,n)=>{const i=dt.useContext(Fm),a=dt.useContext(Nm),o=()=>$7(e,t,i,a);return n?o():fy(o)},eV=jC({scrapeMotionValuesFromProps:Oy,createRenderState:Iy}),nV=jC({scrapeMotionValuesFromProps:AC,createRenderState:HC}),iV=Symbol.for("motionComponentSymbol");function sV(e,t,n){const i=dt.useRef(n);dt.useInsertionEffect(()=>{i.current=n});const a=dt.useRef(null);return dt.useCallback(o=>{var u;o&&((u=e.onMount)==null||u.call(e,o));const l=i.current;if(typeof l=="function")if(o){const h=l(o);typeof h=="function"&&(a.current=h)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);t&&(o?t.mount(o):t.unmount())},[t])}const WC=dt.createContext({});function Ec(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function aV(e,t,n,i,a,o){var w,A;const{visualElement:l}=dt.useContext(Fm),u=dt.useContext(BC),h=dt.useContext(Nm),d=dt.useContext(Fy),p=d.reducedMotion,m=d.skipAnimations,b=dt.useRef(null),_=dt.useRef(!1);i=i||u.renderer,!b.current&&i&&(b.current=i(e,{visualState:t,parent:l,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:p,skipAnimations:m,isSVG:o}),_.current&&b.current&&(b.current.manuallyAnimateOnMount=!0));const x=b.current,M=dt.useContext(WC);x&&!x.projection&&a&&(x.type==="html"||x.type==="svg")&&rV(b.current,n,a,M);const S=dt.useRef(!1);dt.useInsertionEffect(()=>{x&&S.current&&x.update(n,h)});const y=n[$4],E=dt.useRef(!!y&&typeof window<"u"&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,y))&&((A=window.MotionHasOptimisedAnimation)==null?void 0:A.call(window,y)));return f4(()=>{_.current=!0,x&&(S.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),E.current&&x.animationState&&x.animationState.animateChanges())}),dt.useEffect(()=>{x&&(!E.current&&x.animationState&&x.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{var U;(U=window.MotionHandoffMarkAsComplete)==null||U.call(window,y)}),E.current=!1),x.enteringChildren=void 0)}),x}function rV(e,t,n,i){const{layoutId:a,layout:o,drag:l,dragConstraints:u,layoutScroll:h,layoutRoot:d,layoutAnchor:p,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:XC(e.parent)),e.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||u&&Ec(u),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,crossfade:m,layoutScroll:h,layoutRoot:d,layoutAnchor:p})}function XC(e){if(e)return e.options.allowProjection!==!1?e.projection:XC(e.parent)}function Qb(e,{forwardMotionProps:t=!1,type:n}={},i,a){i&&V7(i);const o=n?n==="svg":ky(e),l=o?nV:eV;function u(d,p){let m;const b={...dt.useContext(Fy),...d,layoutId:oV(d)},{isStatic:_}=b,x=X7(d),M=l(d,_);if(!_&&typeof window<"u"){lV();const S=cV(b);m=S.MeasureLayout,x.visualElement=aV(e,M,b,a,S.ProjectionNode,o)}return rt.jsxs(Fm.Provider,{value:x,children:[m&&x.visualElement?rt.jsx(m,{visualElement:x.visualElement,...b}):null,J7(e,d,sV(M,x.visualElement,p),M,_,t,o)]})}u.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=dt.forwardRef(u);return h[iV]=e,h}function oV({layoutId:e}){const t=dt.useContext(uy).id;return t&&e!==void 0?t+"-"+e:e}function lV(e,t){dt.useContext(BC).strict}function cV(e){const t=zC(),{drag:n,layout:i}=t;if(!n&&!i)return{};const a={...n,...i};return{MeasureLayout:n!=null&&n.isEnabled(e)||i!=null&&i.isEnabled(e)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function uV(e,t){if(typeof Proxy>"u")return Qb;const n=new Map,i=(o,l)=>Qb(o,l,e,t),a=(o,l)=>i(o,l);return new Proxy(a,{get:(o,l)=>l==="create"?i:(n.has(l)||n.set(l,Qb(l,void 0,e,t)),n.get(l))})}const fV=(e,t)=>t.isSVG??ky(e)?new Vz(t):new Oz(t,{allowProjection:e!==dt.Fragment});class hV extends wo{constructor(t){super(t),t.animationState||(t.animationState=Xz(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Um(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let dV=0;class pV extends wo{constructor(){super(...arguments),this.id=dV++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;if(t&&i===!1){if(this.isExitComplete){const{initial:l,custom:u}=this.node.getProps();if(typeof l=="string"){const h=vl(this.node,l,u);if(h){const{transition:d,transitionEnd:p,...m}=h;for(const b in m)(o=this.node.getValue(b))==null||o.jump(m[b])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const mV={animation:{Feature:hV},exit:{Feature:pV}};function Th(e){return{point:{x:e.pageX,y:e.pageY}}}const gV=e=>t=>Dy(t)&&e(t,Th(t));function Zf(e,t,n,i){return ch(e,t,gV(n),i)}const qC=({current:e})=>e?e.ownerDocument.defaultView:null,r3=(e,t)=>Math.abs(e-t);function bV(e,t){const n=r3(e.x,t.x),i=r3(e.y,t.y);return Math.sqrt(n**2+i**2)}const o3=new Set(["auto","scroll"]);class YC{constructor(t,n,{transformPagePoint:i,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:u}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=bp(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Jb(this.lastMoveEventInfo,this.history),x=this.startEvent!==null,M=bV(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!x&&!M)return;const{point:S}=_,{timestamp:y}=Ei;this.history.push({...S,timestamp:y});const{onStart:E,onMove:w}=this.handlers;x||(E&&E(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,_)},this.handlePointerMove=(_,x)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=x,this.lastMoveEventInfo=bp(x,this.transformPagePoint),mn.update(this.updatePoint,!0)},this.handlePointerUp=(_,x)=>{this.end();const{onEnd:M,onSessionEnd:S,resumeAnimation:y}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=Jb(_.type==="pointercancel"?this.lastMoveEventInfo:bp(x,this.transformPagePoint),this.history);this.startEvent&&M&&M(_,E),S&&S(_,E)},!Dy(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=l,this.contextWindow=a||window;const h=Th(t),d=bp(h,this.transformPagePoint),{point:p}=d,{timestamp:m}=Ei;this.history=[{...p,timestamp:m}];const{onSessionStart:b}=n;b&&b(t,Jb(d,this.history)),this.removeListeners=xh(Zf(this.contextWindow,"pointermove",this.handlePointerMove),Zf(this.contextWindow,"pointerup",this.handlePointerUp),Zf(this.contextWindow,"pointercancel",this.handlePointerUp)),u&&this.startScrollTracking(u)}startScrollTracking(t){let n=t.parentElement;for(;n;){const i=getComputedStyle(n);(o3.has(i.overflowX)||o3.has(i.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const i=t===window,a=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:a.x-n.x,y:a.y-n.y};o.x===0&&o.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,a),mn.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ao(this.updatePoint)}}function bp(e,t){return t?{point:t(e.point)}:e}function l3(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Jb({point:e},t){return{point:e,delta:l3(e,KC(t)),offset:l3(e,vV(t)),velocity:_V(t,.1)}}function vV(e){return e[0]}function KC(e){return e[e.length-1]}function _V(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const a=KC(e);for(;n>=0&&(i=e[n],!(a.timestamp-i.timestamp>Rs(t)));)n--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&a.timestamp-i.timestamp>Rs(t)*2&&(i=e[1]);const o=Qs(a.timestamp-i.timestamp);if(o===0)return{x:0,y:0};const l={x:(a.x-i.x)/o,y:(a.y-i.y)/o};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function yV(e,{min:t,max:n},i){return t!==void 0&&en&&(e=i?xn(n,e,i.max):Math.min(e,n)),e}function c3(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function xV(e,{top:t,left:n,bottom:i,right:a}){return{x:c3(e.x,n,a),y:c3(e.y,t,i)}}function u3(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.mini?n=rh(t.min,t.max-i,e.min):i>a&&(n=rh(e.min,e.max-a,t.min)),Ia(0,1,n)}function TV(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const z1=.35;function AV(e=z1){return e===!1?e=0:e===!0&&(e=z1),{x:f3(e,"left","right"),y:f3(e,"top","bottom")}}function f3(e,t,n){return{min:h3(e,t),max:h3(e,n)}}function h3(e,t){return typeof e=="number"?e:e[t]||0}const EV=new WeakMap;class wV{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=oi(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=m=>{n&&this.snapToCursor(Th(m).point),this.stopAnimation()},l=(m,b)=>{const{drag:_,dragPropagation:x,onDragStart:M}=this.getProps();if(_&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=tz(_),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=b,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),wa(y=>{let E=this.getAxisMotionValue(y).get()||0;if(Ua.test(E)){const{projection:w}=this.visualElement;if(w&&w.layout){const A=w.layout.layoutBox[y];A&&(E=Yi(A)*(parseFloat(E)/100))}}this.originPoint[y]=E}),M&&mn.update(()=>M(m,b),!1,!0),L1(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},u=(m,b)=>{this.latestPointerEvent=m,this.latestPanInfo=b;const{dragPropagation:_,dragDirectionLock:x,onDirectionLock:M,onDrag:S}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:y}=b;if(x&&this.currentDirection===null){this.currentDirection=CV(y),this.currentDirection!==null&&M&&M(this.currentDirection);return}this.updateAxis("x",b.point,y),this.updateAxis("y",b.point,y),this.visualElement.render(),S&&mn.update(()=>S(m,b),!1,!0)},h=(m,b)=>{this.latestPointerEvent=m,this.latestPanInfo=b,this.stop(m,b),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>{const{dragSnapToOrigin:m}=this.getProps();(m||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new YC(t,{onSessionStart:o,onStart:l,onMove:u,onSessionEnd:h,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:i,contextWindow:qC(this.visualElement),element:this.visualElement.current})}stop(t,n){const i=t||this.latestPointerEvent,a=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!a||!i)return;const{velocity:l}=a;this.startAnimation(l);const{onDragEnd:u}=this.getProps();u&&mn.postRender(()=>u(i,a))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,i){const{drag:a}=this.getProps();if(!i||!vp(t,a,this.currentDirection))return;const o=this.getAxisMotionValue(t);let l=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(l=yV(l,this.constraints[t],this.elastic[t])),o.set(l)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,a=this.constraints;t&&Ec(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=xV(i.layoutBox,t):this.constraints=!1,this.elastic=AV(n),a!==this.constraints&&!Ec(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&wa(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=TV(i.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ec(t))return!1;const i=t.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=Cz(i,a.root,this.visualElement.getTransformPagePoint());let l=SV(a.layout.layoutBox,o);if(n){const u=n(Ez(l));this.hasMutatedConstraints=!!u,u&&(l=gC(u))}return l}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:u}=this.getProps(),h=this.constraints||{},d=wa(p=>{if(!vp(p,n,this.currentDirection))return;let m=h&&h[p]||{};(l===!0||l===p)&&(m={min:0,max:0});const b=a?200:1e6,_=a?40:1e7,x={type:"inertia",velocity:i?t[p]:0,bounceStiffness:b,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...m};return this.startAxisValueAnimation(p,x)});return Promise.all(d).then(u)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return L1(this.visualElement,t),i.start(Ay(t,i,0,n,this.visualElement,!1))}stopAnimation(){wa(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),a=i[n];return a||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){wa(n=>{const{drag:i}=this.getProps();if(!vp(n,i,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(n);if(a&&a.layout){const{min:l,max:u}=a.layout.layoutBox[n],h=o.get()||0;o.set(t[n]-xn(l,u,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!Ec(n)||!i||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};wa(l=>{const u=this.getAxisMotionValue(l);if(u&&this.constraints!==!1){const h=u.get();a[l]=MV({min:h,max:h},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),wa(l=>{if(!vp(l,t,null))return;const u=this.getAxisMotionValue(l),{min:h,max:d}=this.constraints[l];u.set(xn(h,d,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;EV.set(this.visualElement,this);const t=this.visualElement.current,n=Zf(t,"pointerdown",d=>{const{drag:p,dragListener:m=!0}=this.getProps(),b=d.target,_=b!==t&&rz(b);p&&m&&!_&&this.start(d)});let i;const a=()=>{const{dragConstraints:d}=this.getProps();Ec(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),i||(i=RV(t,d.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),mn.read(a);const u=ch(window,"resize",()=>this.scalePositionWithinConstraints()),h=o.addEventListener("didUpdate",(({delta:d,hasLayoutChanged:p})=>{this.isDragging&&p&&(wa(m=>{const b=this.getAxisMotionValue(m);b&&(this.originPoint[m]+=d[m].translate,b.set(b.get()+d[m].translate))}),this.visualElement.render())}));return()=>{u(),n(),l(),h&&h(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=z1,dragMomentum:u=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:u}}}function d3(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function RV(e,t,n){const i=yE(e,d3(n)),a=yE(t,d3(n));return()=>{i(),a()}}function vp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function CV(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class DV extends wo{constructor(t){super(t),this.removeGroupControls=Js,this.removeListeners=Js,this.controls=new wV(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Js}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const $b=e=>(t,n)=>{e&&mn.update(()=>e(t,n),!1,!0)};class LV extends wo{constructor(){super(...arguments),this.removePointerDownListener=Js}onPointerDown(t){this.session=new YC(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:qC(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:a}=this.node.getProps();return{onSessionStart:$b(t),onStart:$b(n),onMove:$b(i),onEnd:(o,l)=>{delete this.session,a&&mn.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=Zf(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let tv=!1;class NV extends dt.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:a}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),i&&i.register&&a&&i.register(o),tv&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Op.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:a,isPresent:o}=this.props,{projection:l}=i;return l&&(l.isPresent=o,t.layoutDependency!==n&&l.setOptions({...l.options,layoutDependency:n}),tv=!0,a||t.layoutDependency!==n||n===void 0||t.isPresent!==o?l.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?l.promote():l.relegate()||mn.postRender(()=>{const u=l.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:i}=t;i&&(i.options.layoutAnchor=n,i.root.didUpdate(),Cy.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:a}=t;tv=!0,a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),i&&i.deregister&&i.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function ZC(e){const[t,n]=kC(),i=dt.useContext(uy);return rt.jsx(NV,{...e,layoutGroup:i,switchLayoutGroup:dt.useContext(WC),isPresent:t,safeToRemove:n})}const PV={pan:{Feature:LV},drag:{Feature:DV,ProjectionNode:IC,MeasureLayout:ZC}};function p3(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,o=i[a];o&&mn.postRender(()=>o(t,Th(t)))}class UV extends wo{mount(){const{current:t}=this.node;t&&(this.unmount=nz(t,(n,i)=>(p3(this.node,i,"Start"),a=>p3(this.node,a,"End"))))}unmount(){}}class OV extends wo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=xh(ch(this.node.current,"focus",()=>this.onFocus()),ch(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function m3(e,t,n){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),o=i[a];o&&mn.postRender(()=>o(t,Th(t)))}class FV extends wo{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=lz(t,(a,o)=>(m3(this.node,o,"Start"),(l,{success:u})=>m3(this.node,l,u?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const V1=new WeakMap,ev=new WeakMap,IV=e=>{const t=V1.get(e.target);t&&t(e)},kV=e=>{e.forEach(IV)};function BV({root:e,...t}){const n=e||document;ev.has(n)||ev.set(n,{});const i=ev.get(n),a=JSON.stringify(t);return i[a]||(i[a]=new IntersectionObserver(kV,{root:e,...t})),i[a]}function zV(e,t,n){const i=BV(t);return V1.set(e,n),i.observe(e),()=>{V1.delete(e),i.unobserve(e)}}const VV={some:0,all:1};class GV extends wo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var h;(h=this.stopObserver)==null||h.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:a="some",once:o}=t,l={root:n?n.current:void 0,rootMargin:i,threshold:typeof a=="number"?a:VV[a]},u=d=>{const{isIntersecting:p}=d;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:m,onViewportLeave:b}=this.node.getProps(),_=p?m:b;_&&_(d)};this.stopObserver=zV(this.node.current,l,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(HV(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function HV({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const jV={inView:{Feature:GV},tap:{Feature:FV},focus:{Feature:OV},hover:{Feature:UV}},WV={layout:{ProjectionNode:IC,MeasureLayout:ZC}},XV={...mV,...jV,...PV,...WV},nv=uV(XV,fV);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qV=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),YV=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,i)=>i?i.toUpperCase():n.toLowerCase()),g3=e=>{const t=YV(e);return t.charAt(0).toUpperCase()+t.slice(1)},QC=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim(),KV=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var ZV={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"};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=dt.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:a="",children:o,iconNode:l,...u},h)=>dt.createElement("svg",{ref:h,...ZV,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:QC("lucide",a),...!o&&!KV(u)&&{"aria-hidden":"true"},...u},[...l.map(([d,p])=>dt.createElement(d,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const By=(e,t)=>{const n=dt.forwardRef(({className:i,...a},o)=>dt.createElement(QV,{ref:o,iconNode:t,className:QC(`lucide-${qV(g3(e))}`,`lucide-${e}`,i),...a}));return n.displayName=g3(e),n};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],$V=By("play",JV);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tG=[["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"}]],eG=By("rotate-ccw",tG);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nG=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],iG=By("shield",nG);function sG(e){const t=[...e];for(let i=t.length-1;i>0;i--){const a=Math.floor(Math.random()*(i+1));[t[i],t[a]]=[t[a],t[i]]}const n=t.indexOf(e[0]);return{options:t,correctZone:n}}function aG(e){let t="",n=0,i=0,a=0;if(e===1)if(Math.random()>.5){const p=Math.floor(Math.random()*10)+1,m=Math.floor(Math.random()*10)+1;t=`${p} + ${m} = ?`,n=p+m}else{let p=Math.floor(Math.random()*10)+5,m=Math.floor(Math.random()*p)+1;t=`${p} - ${m} = ?`,n=p-m}else if(e===1.5){const d=Math.floor(Math.random()*3);if(d===0){const p=Math.floor(Math.random()*40)+10,m=Math.floor(Math.random()*40)+10;t=`${p} + ${m} = ?`,n=p+m}else if(d===1){const p=Math.floor(Math.random()*50)+20,m=Math.floor(Math.random()*20)+5;t=`${p} - ${m} = ?`,n=p-m}else{const p=Math.floor(Math.random()*9)+2,m=Math.floor(Math.random()*9)+2;t=`${p} ร— ${m} = ?`,n=p*m}}else{const d=Math.floor(Math.random()*3);if(d===0){const p=Math.floor(Math.random()*10)+5,m=Math.floor(Math.random()*15)+5;t=`${p} ร— ${m} = ?`,n=p*m}else if(d===1){const p=Math.floor(Math.random()*10)+3,m=Math.floor(Math.random()*10)+3;t=`${p*m} รท ${p} = ?`,n=m}else{const p=Math.floor(Math.random()*10)+2,m=Math.floor(Math.random()*10)+2,b=p*m;t=`${p}x = ${b}, x = ?`,n=m}}let o=Math.floor(Math.random()*3)+1,l=Math.floor(Math.random()*3)+1;Math.random()>.5&&(o*=-1),Math.random()>.5&&(l*=-1),i=n+o,a=n+l*2,i===a&&(a+=1),i===n&&(i+=1),a===n&&(a-=1);const{options:u,correctZone:h}=sG([n,i,a]);return{question:t,correctAnswer:n,options:u,correctZone:h}}const Ts=new(window.AudioContext||window.webkitAudioContext);let Lf=null;function Nf(e){if(Ts.state==="suspended"&&Ts.resume(),e==="BGM_START"){if(Lf)return;const a=[220,261.63,329.63,440,392,329.63,261.63,196];let o=0;Lf=setInterval(()=>{const l=Ts.currentTime,u=Ts.createOscillator(),h=Ts.createGain();u.type="sawtooth",u.frequency.setValueAtTime(a[o%a.length]/2,l),h.gain.setValueAtTime(.04,l),h.gain.exponentialRampToValueAtTime(.001,l+.2);const d=Ts.createBiquadFilter();d.type="lowpass",d.frequency.setValueAtTime(600,l),d.frequency.exponentialRampToValueAtTime(100,l+.2),u.connect(d),d.connect(h),h.connect(Ts.destination),u.start(l),u.stop(l+.2),o++},280);return}if(e==="BGM_STOP"){Lf&&(clearInterval(Lf),Lf=null);return}const t=Ts.createOscillator(),n=Ts.createGain();t.connect(n),n.connect(Ts.destination);const i=Ts.currentTime;if(e==="SAVE")t.type="sine",t.frequency.setValueAtTime(400,i),t.frequency.exponentialRampToValueAtTime(800,i+.1),n.gain.setValueAtTime(.5,i),n.gain.exponentialRampToValueAtTime(.01,i+.1),t.start(i),t.stop(i+.1);else if(e==="SUPER_SAVE"){t.type="sawtooth",t.frequency.setValueAtTime(150,i),t.frequency.exponentialRampToValueAtTime(800,i+.3);const a=Ts.createOscillator();a.type="square",a.frequency.setValueAtTime(200,i),a.frequency.exponentialRampToValueAtTime(1e3,i+.3),a.connect(n),a.start(i),a.stop(i+.3),n.gain.setValueAtTime(.8,i),n.gain.exponentialRampToValueAtTime(.01,i+.3),t.start(i),t.stop(i+.3)}else if(e==="GOAL")t.type="square",t.frequency.setValueAtTime(200,i),t.frequency.exponentialRampToValueAtTime(50,i+.4),n.gain.setValueAtTime(.5,i),n.gain.exponentialRampToValueAtTime(.01,i+.4),t.start(i),t.stop(i+.4);else if(e==="KICK")t.type="triangle",t.frequency.setValueAtTime(150,i),t.frequency.exponentialRampToValueAtTime(10,i+.3),n.gain.setValueAtTime(1,i),n.gain.exponentialRampToValueAtTime(.01,i+.3),t.start(i),t.stop(i+.3);else if(e==="WHOOSH"){const a=Ts.createOscillator();t.type="sine",a.type="square",t.frequency.setValueAtTime(800,i),t.frequency.exponentialRampToValueAtTime(100,i+.3),a.frequency.setValueAtTime(1200,i),a.frequency.exponentialRampToValueAtTime(200,i+.3),a.connect(n),n.gain.setValueAtTime(.2,i),n.gain.exponentialRampToValueAtTime(.01,i+.3),t.start(i),t.stop(i+.3),a.start(i),a.stop(i+.3)}}const b3=[{id:"1",name:"WAKABAYASHI",score:25500},{id:"2",name:"MULLER",score:21e3},{id:"3",name:"WAKASHIMAZU",score:18500},{id:"4",name:"HERNANDEZ",score:15e3},{id:"5",name:"MORISAKI",score:12500}],v3={left:{scale:.3,forwardMul:.018,sideMul:-.012,offsetX:0,offsetY:0,offsetZ:.006,rotationDeg:-118},right:{scale:.3,forwardMul:.018,sideMul:.012,offsetX:0,offsetY:0,offsetZ:.006,rotationDeg:108}},Fp=(e,t,n)=>Math.min(n,Math.max(t,e)),Ip="ar-goalkeeper-glove-calibration-v3",rG=["ar-goalkeeper-glove-calibration-v2","ar-goalkeeper-glove-calibration-v1"],Bf=6,iv=[15,17,19,21],sv=[16,18,20,22],av=[{xMin:.1,xMax:.35,yMin:.25,yMax:.65},{xMin:.375,xMax:.625,yMin:.25,yMax:.65},{xMin:.65,xMax:.9,yMin:.25,yMax:.65}],oG=.012,lG=.04,_3=.008,y3=.035,cG=.2,uG=.08,fG=2,hG=4,dG=[4,8,12,16,20],rv=(e,t,n,i=0,a=0)=>e>=n.xMin-i&&e<=n.xMax+i&&t>=n.yMin-a&&t<=n.yMax+a,x3=(e,t,n=.06)=>e?t.reduce((i,a)=>{const o=e[a];if(!o)return i;const l=o.visibility??1;return l({left:{...v3.left},right:{...v3.right}}),el=(e,t,n,i)=>{const a=Number(e);return Number.isFinite(a)?Fp(a,n,i):t},pG=e=>{const t=G1(),n=e&&typeof e=="object"?e:{},i=a=>{const o=n[a]&&typeof n[a]=="object"?n[a]:{},l=t[a];return{scale:el(o.scale,l.scale,.2,.9),forwardMul:el(o.forwardMul,l.forwardMul,-.2,.2),sideMul:el(o.sideMul,l.sideMul,-.2,.2),offsetX:el(o.offsetX,l.offsetX,-.2,.2),offsetY:el(o.offsetY,l.offsetY,-.2,.2),offsetZ:el(o.offsetZ,l.offsetZ,-.2,.2),rotationDeg:el(o.rotationDeg,l.rotationDeg,-180,180)}};return{left:i("left"),right:i("right")}},mG=()=>{const e={calibrationSaved:!0,profileRevision:Bf,gloveStaticWrap:!0,swapGloveHands:!1,gloveTrackingMode:"both",manualCalibration:G1()};if(typeof window>"u")return e;const t=n=>{const i=JSON.parse(n),a=i.gloveTrackingMode==="right-only"?"right-only":"both",o=Number(i.profileRevision),l=Number.isFinite(o)?o:0,u=pG(i.manualCalibration),h=l{async function ot(){const Zt=await Ac.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.21/wasm");u.current=await rs.createFromOptions(Zt,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task",delegate:"GPU"},runningMode:"VIDEO",numPoses:1});try{h.current=await ji.createFromOptions(Zt,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task",delegate:"GPU"},runningMode:"VIDEO",numHands:2})}catch(Nt){console.warn("Hand landmarker failed to load. Falling back to basic hand overlay.",Nt)}let ge=null;if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)try{ge=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:640,height:480}}),t.current&&(t.current.srcObject=ge,t.current.play().catch(Nt=>{Nt.name!=="AbortError"&&console.error("Error playing video:",Nt)})),n.current&&(n.current.srcObject=ge,n.current.play().catch(Nt=>{Nt.name!=="AbortError"&&console.error("Error playing preview:",Nt)}))}catch(Nt){console.error("Camera access denied:",Nt),Lt("Camera access denied. Please allow camera permissions in your browser or open the app in a new tab.")}if(a.current&&!l.current){l.current=new fF(a.current,()=>{var vn;return Ft((vn=l.current)!=null&&vn.isSuperBall?"SUPER_SAVE":"SAVE")},()=>Ft("GOAL"));const Nt=e.current;l.current.setGloveStaticWrap(Nt.gloveStaticWrap),l.current.setSwapGloveHands(Nt.swapGloveHands),l.current.setGloveTrackingMode(Nt.gloveTrackingMode),l.current.setGloveCalibration("left",{scale:Nt.manualCalibration.left.scale,forwardMul:Nt.manualCalibration.left.forwardMul,sideMul:Nt.manualCalibration.left.sideMul,offsetX:Nt.manualCalibration.left.offsetX,offsetY:Nt.manualCalibration.left.offsetY,offsetZ:Nt.manualCalibration.left.offsetZ,rotationFine:Rn.degToRad(Nt.manualCalibration.left.rotationDeg)}),l.current.setGloveCalibration("right",{scale:Nt.manualCalibration.right.scale,forwardMul:Nt.manualCalibration.right.forwardMul,sideMul:Nt.manualCalibration.right.sideMul,offsetX:Nt.manualCalibration.right.offsetX,offsetY:Nt.manualCalibration.right.offsetY,offsetZ:Nt.manualCalibration.right.offsetZ,rotationFine:Rn.degToRad(Nt.manualCalibration.right.rotationDeg)}),q(Nt.gloveStaticWrap),At(Nt.swapGloveHands),re(Nt.gloveTrackingMode),We({left:{...Nt.manualCalibration.left},right:{...Nt.manualCalibration.right}}),L.current=Nt.swapGloveHands,Qe.current=Nt.gloveTrackingMode,it.current=Nt.swapGloveHands?"left":"right"}b(!0)}return ot(),()=>{var Zt,ge,Nt;(Zt=l.current)==null||Zt.cleanup(),(ge=h.current)==null||ge.close(),h.current=null,(Nt=u.current)==null||Nt.close(),Bt.current=[],t.current&&t.current.srcObject&&(t.current.srcObject.getTracks().forEach(si=>si.stop()),t.current.srcObject=null)}},[]),dt.useEffect(()=>{var ge;if(_!=="PLAYING")return;const ot=n.current,Zt=(ge=t.current)==null?void 0:ge.srcObject;!ot||!Zt||(ot.srcObject!==Zt&&(ot.srcObject=Zt),ot.play().catch(Nt=>{(Nt==null?void 0:Nt.name)!=="AbortError"&&console.error("Error syncing preview stream:",Nt)}))},[_,m]);const Mt=ot=>{window.localStorage.setItem(Ip,JSON.stringify(ot)),e.current=ot},Ot=()=>{if(M.current!=="PLAYING"||!l.current||C.current>=10)return;const ot=aG(E.current);nt(ot),ct.current=ot,Ge.current=!0,l.current.shootBall(E.current,ot.correctZone);const Zt=l.current.isSuperBall;K.current=Zt,Qt(Zt),Zt&&(jt(!0),setTimeout(()=>jt(!1),500))},Ft=ot=>{Nf(ot),l.current&&l.current.hideTrails();let Zt="";if(ct.current){const ge=ct.current.options[ct.current.correctZone];Zt=ot==="GOAL"?`Miss... = ${ge}`:`Correct! = ${ge}`}else Zt=ot==="SAVE"?"SAVE!":ot==="SUPER_SAVE"?"SUPER SAVE!!":"GOAL!";if(ot==="SAVE"||ot==="SUPER_SAVE"){const ge=ot==="SAVE"?100:300;A(Nt=>Nt+ge*E.current)}else O(ge=>ge+1);F(ge=>{const Nt=ge+1;return C.current=Nt,Nt}),I({text:Zt,type:ot}),setTimeout(()=>I(null),1e3),setTimeout(Ot,2e3)};dt.useEffect(()=>{const ot=()=>{o.current&&(o.current.width=window.innerWidth,o.current.height=window.innerHeight)};window.addEventListener("resize",ot),ot();let Zt;const ge=()=>{var vn,si,ya;if(l.current){const D=l.current.isBallActive;!me.current&&D&&Ge.current&&(Nf("KICK"),K.current&&Nf("WHOOSH"),Ge.current=!1,K.current=!1),me.current=D}if(t.current&&u.current&&t.current.readyState>=2){const D=performance.now();if(fe.current!==t.current.currentTime){fe.current=t.current.currentTime;const W=u.current.detectForVideo(t.current,D);if(W.landmarks&&W.landmarks[0]?Gt.current=W.landmarks[0]:Gt.current=null,h.current)try{const tt=h.current.detectForVideo(t.current,D),Y=(tt.landmarks??[]).map((H,bt)=>{var Tt,Pt,Vt,It;const Ct=((It=(Vt=(Pt=(Tt=tt.handedness)==null?void 0:Tt[bt])==null?void 0:Pt[0])==null?void 0:Vt.categoryName)==null?void 0:It.toLowerCase())||"",Rt=Ct.includes("left")?"left":Ct.includes("right")?"right":"unknown";return{landmarks:H,side:Rt}});Bt.current=Y,(vn=l.current)==null||vn.updateDetailedHandLandmarks(Y.map(H=>({landmarks:H.landmarks,label:H.side})))}catch{Bt.current=[],(si=l.current)==null||si.updateDetailedHandLandmarks([])}else Bt.current=[],(ya=l.current)==null||ya.updateDetailedHandLandmarks([]);if(l.current){if(l.current.updateGloveLandmarks(Gt.current),Ut.current&&Gt.current){ht.current+=1;const Tt=l.current.autoDetectHandMapping(Gt.current);Tt.resolved?(At(Tt.swapped),L.current=Tt.swapped,it.current=Tt.swapped?"left":"right",Ut.current=!1):ht.current>240&&(Ut.current=!1)}const tt=x3(Gt.current,iv),Y=x3(Gt.current,sv),H=k.current,bt=Kt.current,Ct=(Tt,Pt,Vt)=>{let It=Tt==="left"?H.leftSeen:H.rightSeen,oe=Tt==="left"?H.leftLost:H.rightLost;return Pt>=cG?(It+=1,oe=0):Pt<=uG?(oe+=1,It=0):Vt?oe=0:It=0,Tt==="left"?(H.leftSeen=It,H.leftLost=oe):(H.rightSeen=It,H.rightLost=oe),!Vt&&It>=fG?!0:Vt&&oe>=hG?!1:Vt},Rt={leftDetected:Ct("left",tt,bt.leftDetected),rightDetected:Ct("right",Y,bt.rightDetected)};(Rt.leftDetected!==Kt.current.leftDetected||Rt.rightDetected!==Kt.current.rightDetected)&&(Kt.current=Rt,De(Rt))}}}if(l.current&&M.current==="PLAYING"){const D=l.current.getBallScreenPosition();if(D){const W=D.x,tt=D.y;let Y=!1;const H=ct.current?av[ct.current.correctZone]:null,bt=!!H&&rv(W,tt,H,oG,lG),Ct=Gt.current;if(Ct){const Rt=[...iv],Tt=[...sv],Pt=(Ne,xe=0)=>Ne.reduce((le,Jt)=>{const hn=Ct[Jt];if(!hn)return le;const Se=hn.visibility??1;return Se.18)it.current=Ne;else{const ai=it.current==="right"?Pt(Tt,.06):Pt(Rt,.06),Wn=it.current==="right"?Pt(Rt,.06):Pt(Tt,.06);ai<.06&&Wn>.22?it.current=it.current==="right"?"left":"right":Se>hn+.28&&(it.current=le)}const mi=it.current==="right"?Tt:Rt;if(Pt(mi,.06)>.04)Vt=mi;else{const ai=it.current==="right"?Rt:Tt;Vt=[...mi,...ai]}oe=.08}const ve=It==="right-only"?.27:.17;for(const Ne of Vt){const xe=Ct[Ne];if(!xe||(xe.visibility??1){const Rt=Tt=>Tt==="left"?0:Tt==="right"?1:2;return Rt(bt.side)-Rt(Ct.side)});if(H.length>0){const bt={left:"#00E5FF",right:"#FF4DA6",unknown:"#FFFFFF"};for(let Ct=0;Ct{const Vt=bt[Pt];return!Vt||(Vt.visibility??1)<.08?null:{x:(1-Vt.x)*W,y:Vt.y*tt}});Y.strokeStyle=Rt.color,Y.lineWidth=Math.max(1.25,W*.012),Y.lineCap="round",Y.lineJoin="round",Y.shadowBlur=5,Y.shadowColor=Rt.color;for(let Pt=1;Pt({id:Ct,...bt}));D.strokeStyle="#00FF00",D.lineWidth=4;for(const bt of Y)D.strokeRect(bt.xMin*W,bt.yMin*tt,(bt.xMax-bt.xMin)*W,(bt.yMax-bt.yMin)*tt);const H=[15,17,19,21,16,18,20,22];D.fillStyle="#FF0055";for(const bt of H){const Ct=Gt.current[bt];Ct&&(D.beginPath(),D.arc((1-Ct.x)*W,Ct.y*tt,15,0,Math.PI*2),D.fill())}if(l.current){const bt=new G(-3,1.5,l.current.catchPlaneZ).project(l.current.camera),Ct=new G(3,1.5,l.current.catchPlaneZ).project(l.current.camera),Rt=new G(0,3,l.current.catchPlaneZ).project(l.current.camera),Tt=new G(0,0,l.current.catchPlaneZ).project(l.current.camera),Pt=(bt.x+1)/2*W,Vt=(Ct.x+1)/2*W,It=(-Rt.y+1)/2*tt,oe=(-Tt.y+1)/2*tt;D.strokeStyle="#FFFF00",D.lineWidth=4,D.strokeRect(Pt,It,Vt-Pt,oe-It)}}}Zt=requestAnimationFrame(ge)};return ge(),()=>{cancelAnimationFrame(Zt),window.removeEventListener("resize",ot)}},[S]);const pe=ot=>{try{const Zt=JSON.parse(localStorage.getItem("ar-goalkeeper-scores")||"[]");ot&&ot>0&&(Zt.push({id:Date.now().toString(),name:"YOU",score:ot,isYou:!0}),Zt.sort((Nt,vn)=>vn.score-Nt.score),localStorage.setItem("ar-goalkeeper-scores",JSON.stringify(Zt.slice(0,10))));const ge=[...b3,...Zt];ge.sort((Nt,vn)=>vn.score-Nt.score),p(ge.slice(0,5))}catch(Zt){console.error(Zt),p(b3)}};dt.useEffect(()=>{pe()},[]),dt.useEffect(()=>{P>=10&&_==="PLAYING"&&(x("GAMEOVER"),M.current="GAMEOVER",Nf("BGM_STOP"),l.current&&(l.current.isBallActive=!1),me.current=!1,Ge.current=!1,K.current=!1,pe(w))},[P,w,_]);const gn=ot=>{y(ot),E.current=ot},Pn=()=>{A(0),O(0),F(0),C.current=0,me.current=!1,Ge.current=!1,K.current=!1,Ut.current=!e.current.calibrationSaved,ht.current=0,x("PLAYING"),M.current="PLAYING",Nf("BGM_START"),Qt(!1),setTimeout(()=>{M.current==="PLAYING"&&Ot()},1e3)},ze=()=>{if(!l.current)return;if(l.current.calibrateGloves(Gt.current)){const Zt=l.current.getSwapGloveHands();At(Zt),L.current=Zt,it.current=Zt?"left":"right";const ge=l.current.getGloveCalibration("left"),Nt=l.current.getGloveCalibration("right");We(vn=>({left:{...vn.left,scale:ge.scale},right:{...vn.right,scale:Nt.scale}})),et("Gloves recalibrated (scale only, not saved)")}else et("Calibration failed: show both hands to camera");setTimeout(()=>et(""),2e3)},bn=(ot,Zt)=>{We(ge=>{var si;const Nt={...ge[ot],...Zt},vn={...ge,[ot]:Nt};return(si=l.current)==null||si.setGloveCalibration(ot,{scale:Nt.scale,forwardMul:Nt.forwardMul,sideMul:Nt.sideMul,offsetX:Nt.offsetX,offsetY:Nt.offsetY,offsetZ:Nt.offsetZ,rotationFine:Rn.degToRad(Nt.rotationDeg)}),vn})},fs=()=>{if(!l.current)return;l.current.resetGloveCalibrationAdjustments(_t);const ot=l.current.getGloveCalibration(_t);bn(_t,{scale:ot.scale,forwardMul:ot.forwardMul,sideMul:ot.sideMul,offsetX:ot.offsetX,offsetY:ot.offsetY,offsetZ:ot.offsetZ,rotationDeg:Rn.radToDeg(ot.rotationFine)}),et(`${_t.toUpperCase()} glove reset`),setTimeout(()=>et(""),1400)},Ro=()=>{if(!l.current)return;const ot=l.current.autoDetectHandMapping(Gt.current);if(!ot.resolved){et("Right hand not clear: keep both hands visible"),setTimeout(()=>et(""),1800);return}At(ot.swapped),L.current=ot.swapped,it.current=ot.swapped?"left":"right",et(ot.swapped?"Mapping detected: swapped":"Mapping detected: normal"),setTimeout(()=>et(""),1800)},Co=ot=>{var Zt;re(ot),Qe.current=ot,ot==="right-only"&&(it.current=L.current?"left":"right"),(Zt=l.current)==null||Zt.setGloveTrackingMode(ot),et(ot==="right-only"?"Tracking right hand only":"Tracking both hands"),setTimeout(()=>et(""),1600)},Us=()=>{try{const ot={calibrationSaved:!0,profileRevision:Bf,gloveStaticWrap:J,swapGloveHands:yt,gloveTrackingMode:ee,manualCalibration:{left:{...te.left},right:{...te.right}}};Mt(ot),et("Calibration saved"),setTimeout(()=>et(""),1600)}catch(ot){console.warn("Manual glove calibration save failed.",ot),et("Save failed"),setTimeout(()=>et(""),1600)}},_a=(ot,Zt)=>{const ge=gt.current;if(!ge)return;const Nt=ge.getBoundingClientRect(),vn=Fp((ot-Nt.left)/Nt.width,0,1),si=Fp((Zt-Nt.top)/Nt.height,0,1);bn(_t,{offsetX:Rn.lerp(-.2,.2,vn),offsetY:Rn.lerp(.2,-.2,si)})},Wa=(ot,Zt)=>{const ge=wt.current;if(!ge)return;const Nt=ge.getBoundingClientRect(),vn=Nt.left+Nt.width/2,si=Nt.top+Nt.height/2,ya=Math.atan2(Zt-si,ot-vn);let D=Rn.radToDeg(ya);D>180&&(D-=360),D<-180&&(D+=360),bn(_t,{rotationDeg:Fp(D,-180,180)})},ni=te[_t],Xa={left:`${Rn.mapLinear(ni.offsetX,-.2,.2,0,100)}%`,top:`${Rn.mapLinear(ni.offsetY,.2,-.2,0,100)}%`},hs={transform:`translate(-50%, -50%) rotate(${ni.rotationDeg}deg)`},Sn=()=>{var Zt;const ot=!J;q(ot),(Zt=l.current)==null||Zt.setGloveStaticWrap(ot),et(ot?"Glove mode: static wrap":"Glove mode: dynamic angle"),setTimeout(()=>et(""),1400)},ii=()=>{var Zt;const ot=!yt;At(ot),L.current=ot,it.current=ot?"left":"right",(Zt=l.current)==null||Zt.setSwapGloveHands(ot),et(ot?"Hand mapping swapped":"Hand mapping normal"),setTimeout(()=>et(""),1400)};return rt.jsxs("div",{className:`relative w-screen h-screen overflow-hidden text-white font-anime tracking-wide ${kt?"camera-shake":""}`,style:{background:"radial-gradient(circle at center, #1a2a1a 0%, #050505 100%)"},children:[xt&&_==="PLAYING"&&rt.jsx("div",{className:"speed-lines pointer-events-none"}),rt.jsx("video",{ref:t,playsInline:!0,muted:!0,className:"absolute inset-0 w-full h-full object-cover -scale-x-100 opacity-0"}),rt.jsx("div",{className:"absolute inset-0 pointer-events-none opacity-0",style:{backgroundImage:"repeating-linear-gradient(0deg, rgba(0,0,0,0.1) 0px, rgba(0,0,0,0.1) 1px, transparent 1px, transparent 2px)"}}),rt.jsx("div",{ref:a,className:"absolute inset-0 w-full h-full pointer-events-none"}),rt.jsx("canvas",{ref:o,className:"absolute inset-0 w-full h-full pointer-events-none opacity-50 z-10"}),rt.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col pointer-events-none",children:[_==="PLAYING"&&Z&&rt.jsx("div",{className:"absolute inset-0 z-30 pointer-events-none",children:Z.options.map((ot,Zt)=>{const ge=av[Zt],Nt=`${(ge.xMin+ge.xMax)/2*100}%`,vn=`${(ge.yMin+ge.yMax)/2*100}%`;return rt.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2 flex items-center justify-center w-32 h-32 md:w-48 md:h-48 transition-all duration-300 border-2 border-white/20 bg-black/28 rounded-[2rem] shadow-[0_0_10px_rgba(255,255,255,0.05)]",style:{left:Nt,top:vn},children:rt.jsx("div",{className:"font-mono font-bold tracking-tighter text-4xl md:text-6xl tabular-nums transition-colors duration-300 text-white/80 drop-shadow-[0_0_8px_rgba(255,255,255,0.3)]",children:ot})},Zt)})}),_==="PLAYING"&&rt.jsxs("header",{className:"absolute top-8 left-8 right-8 flex justify-between items-start z-50 pointer-events-auto",children:[rt.jsxs("div",{className:"flex gap-4",children:[rt.jsx("div",{className:"bg-white border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#FFE600] transition-transform",children:rt.jsxs("div",{className:"skew-x-[15deg]",children:[rt.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-[#FF0055] mb-[-4px]",children:"SCORE"}),rt.jsx("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-black tracking-widest",children:String(w).padStart(5,"0")})]})}),rt.jsx("div",{className:"bg-black border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#FF0055]",children:rt.jsxs("div",{className:"skew-x-[15deg]",children:[rt.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-[#FF0055] mb-[-4px]",children:"GOALS"}),rt.jsx("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-white tracking-widest",children:String(U).padStart(2,"0")})]})})]}),rt.jsx("div",{className:"flex flex-col items-end gap-2",children:rt.jsx("div",{className:"bg-white border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#00E5FF]",children:rt.jsxs("div",{className:"skew-x-[15deg]",children:[rt.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-black mb-[-4px]",children:"KICKS"}),rt.jsxs("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-black tracking-widest",children:[String(P).padStart(2,"0")," ",rt.jsx("span",{className:"text-black/50 text-[20px] font-black tracking-wide",children:"/ 10"})]})]})})})]}),_==="PLAYING"&&Z&&rt.jsx("div",{className:"absolute bottom-20 left-1/2 -translate-x-1/2 z-50 flex flex-col items-center pointer-events-none",children:rt.jsx("div",{className:"bg-[#FF0055] border-black px-8 sm:px-12 py-3 skew-x-[-10deg] shadow-[8px_8px_0_#00E5FF] border-4",children:rt.jsxs("div",{className:"skew-x-[10deg] text-white flex flex-col items-center",children:[rt.jsx("div",{className:"text-[15px] sm:text-[18px] font-anime font-bold uppercase tracking-widest text-[#FFE600] mb-[-6px] drop-shadow-md",children:"MATH QUESTION"}),rt.jsx("div",{className:"text-[52px] sm:text-[64px] font-comic font-black tracking-widest drop-shadow-xl leading-none",children:Z.question})]})})}),rt.jsx(Zb,{children:_==="IDLE"&&rt.jsx(nv.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.05},className:"absolute inset-0 bg-white p-4 sm:p-10 border-[16px] border-[#FF0055] flex flex-col items-center justify-center text-center pointer-events-auto z-40 bg-[radial-gradient(#e5e7eb_1px,transparent_1px)] [background-size:16px_16px] overflow-y-auto",children:rt.jsxs("div",{className:"max-w-3xl w-full py-8",children:[rt.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 bg-[#00E5FF] border-[6px] border-black flex items-center justify-center mx-auto mb-4 sm:mb-6 shadow-[8px_8px_0_#000] rotate-12",children:rt.jsx(iG,{className:"w-10 h-10 sm:w-12 sm:h-12 text-white -rotate-12"})}),rt.jsx("h1",{className:"text-5xl sm:text-7xl md:text-8xl font-comic mb-4 tracking-widest text-[#FFE600] drop-shadow-[4px_4px_0_#000] sm:drop-shadow-[8px_8px_0_#000]",style:{WebkitTextStroke:"3px black"},children:"AR GOALKEEPER"}),rt.jsx("p",{className:"text-black text-lg sm:text-[24px] md:text-[28px] font-anime font-black mb-4 sm:mb-6 leading-relaxed tracking-wider bg-white inline-block px-4 border-4 border-black",children:"STAND IN FRONT OF THE CAMERA. BLOCK THE EPIC SHOTS!"}),rt.jsxs("div",{className:"bg-[#FFE600] border-4 border-black text-black px-4 sm:px-6 py-2 sm:py-3 text-sm sm:text-lg font-anime font-black flex items-center justify-center gap-2 sm:gap-3 mb-6 sm:mb-10 mx-auto w-fit tracking-widest shadow-[4px_4px_0_#00E5FF] sm:shadow-[6px_6px_0_#00E5FF]",children:[rt.jsx("span",{className:"animate-pulse",children:"โ–ถ"})," LIVE TRACKING ACTIVE"]}),Le?rt.jsx("div",{className:"flex flex-col items-center gap-4 py-4 sm:py-8",children:rt.jsx("p",{className:"text-[#FF0055] font-anime font-black text-xl sm:text-2xl tracking-widest mt-4 max-w-md text-center",children:Le})}):m?rt.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[rt.jsxs("div",{children:[rt.jsx("p",{className:"text-[18px] sm:text-[24px] font-anime font-black text-black mb-4 tracking-widest bg-[#00E5FF] inline-block px-4 border-4 border-black",children:"SELECT RANK"}),rt.jsx("div",{className:"flex flex-wrap justify-center gap-3 sm:gap-4",children:[1,1.5,2].map((ot,Zt)=>{const ge=["GENIN","CHUNIN","JONIN"];return rt.jsx("button",{onClick:()=>gn(ot),className:`px-6 sm:px-8 py-2 sm:py-3 skew-x-[-15deg] font-anime font-black text-lg sm:text-xl tracking-widest transition-transform border-4 border-black active:translate-y-1 active:shadow-none ${S===ot?"bg-[#FF0055] text-white shadow-[6px_6px_0_#000] sm:shadow-[8px_8px_0_#000] -translate-y-1":"bg-white text-black hover:bg-[#FFE600] shadow-[3px_3px_0_#000] sm:shadow-[4px_4px_0_#000]"}`,children:rt.jsx("div",{className:"skew-x-[15deg]",children:ge[Zt]})},ot)})})]}),rt.jsx("button",{onClick:Pn,className:"w-full max-w-sm sm:max-w-lg mx-auto py-4 sm:py-6 skew-x-[-10deg] font-anime font-black text-[28px] sm:text-[40px] tracking-widest text-black bg-[#00E5FF] border-4 border-black hover:bg-[#FF0055] hover:text-white transition-colors flex items-center justify-center gap-3 sm:gap-4 active:translate-y-2 active:translate-x-2 shadow-[8px_8px_0_#000] sm:shadow-[12px_12px_0_#000] active:shadow-[0_0_0_#000] mb-6",children:rt.jsxs("div",{className:"skew-x-[10deg] flex items-center justify-center gap-3 sm:gap-4",children:[rt.jsx($V,{className:"fill-current w-8 h-8 sm:w-10 sm:h-10"})," ",rt.jsx("span",{className:"mt-1",children:"START GAME!"})]})}),rt.jsx("button",{onClick:()=>ae(!Ht),className:"w-full max-w-xs sm:max-w-sm mx-auto py-2 sm:py-3 skew-x-[-10deg] font-anime font-bold text-lg sm:text-xl tracking-widest text-white bg-black border-4 border-white hover:bg-white hover:text-black transition-colors flex items-center justify-center shadow-[4px_4px_0_#FF0055]",children:rt.jsx("div",{className:"skew-x-[10deg]",children:Ht?"HIDE RANKING":"SHOW RANKING"})}),Ht&&rt.jsx("div",{className:"w-full max-w-sm sm:max-w-lg mx-auto mt-8 bg-black border-4 border-black p-4 sm:p-6 shadow-[8px_8px_0_#FFE600] skew-x-[-5deg]",children:rt.jsxs("div",{className:"skew-x-[5deg]",children:[rt.jsx("h3",{className:"text-[#00E5FF] font-anime font-black text-xl sm:text-2xl tracking-widest mb-4 sm:mb-6 uppercase text-center",children:"๐Ÿ† Global Top 5 ๐Ÿ†"}),rt.jsx("div",{className:"flex flex-col gap-2 sm:gap-3",children:d.map((ot,Zt)=>rt.jsxs("div",{className:`flex justify-between items-center px-3 sm:px-4 py-2 border-2 ${ot.isYou?"bg-[#FF0055] border-black text-white shadow-[4px_4px_0_#000]":"bg-white/10 border-white/20 text-white"}`,children:[rt.jsxs("span",{className:"font-anime font-bold text-base sm:text-lg tracking-widest truncate",children:[Zt+1,". ",ot.name]}),rt.jsx("span",{className:"font-comic font-black text-xl sm:text-2xl tabular-nums ml-4",children:String(ot.score).padStart(5,"0")})]},ot.id+Zt))})]})})]}):rt.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 sm:py-8",children:[rt.jsx("div",{className:"w-12 h-12 sm:w-16 sm:h-16 border-[8px] sm:border-[12px] border-black border-r-[#00E5FF] animate-spin"}),rt.jsx("p",{className:"text-black font-anime font-black text-xl sm:text-3xl tracking-widest mt-4",children:"LOADING KI..."})]})]})})}),rt.jsx(Zb,{children:_==="GAMEOVER"&&rt.jsx(nv.div,{initial:{opacity:0,scale:.9,y:50},animate:{opacity:1,scale:1,y:0},className:"absolute inset-0 bg-[#FFE600] p-4 sm:p-10 border-[16px] border-[#00E5FF] flex flex-col items-center justify-center text-center pointer-events-auto z-40 bg-[radial-gradient(#000_1px,transparent_1px)] [background-size:24px_24px] overflow-y-auto",children:rt.jsxs("div",{className:"max-w-3xl w-full py-8",children:[rt.jsx("h2",{className:"text-6xl sm:text-7xl md:text-9xl font-comic tracking-widest mb-4 sm:mb-6 text-[#FF0055] drop-shadow-[4px_4px_0_#000] sm:drop-shadow-[8px_8px_0_#000]",style:{WebkitTextStroke:"4px black"},children:"FULL TIME"}),rt.jsx("p",{className:"text-black font-anime font-black tracking-widest text-xl sm:text-3xl mb-10 sm:mb-16 bg-white border-4 border-black inline-block px-4 sm:px-6 py-2 shadow-[4px_4px_0_#00E5FF] sm:shadow-[6px_6px_0_#00E5FF]",children:"MATCH FINISHED"}),rt.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6 sm:gap-8 mb-10 sm:mb-16",children:[rt.jsx("div",{className:"bg-white border-4 border-black py-8 sm:py-10 skew-x-[-10deg] shadow-[8px_8px_0_#000] sm:shadow-[12px_12px_0_#000]",children:rt.jsxs("div",{className:"skew-x-[10deg]",children:[rt.jsx("div",{className:"text-[14px] sm:text-[18px] font-anime font-black uppercase tracking-widest text-[#FF0055] mb-[4px]",children:"FINAL SCORE"}),rt.jsx("div",{className:"text-5xl sm:text-7xl font-comic font-[900] text-black tabular-nums leading-none tracking-widest",children:String(w).padStart(5,"0")})]})}),rt.jsx("div",{className:"bg-black border-4 border-black py-8 sm:py-10 skew-x-[-10deg] shadow-[8px_8px_0_#FF0055] sm:shadow-[12px_12px_0_#FF0055]",children:rt.jsxs("div",{className:"skew-x-[10deg]",children:[rt.jsx("div",{className:"text-[14px] sm:text-[18px] font-anime font-black uppercase tracking-widest text-[#00E5FF] mb-[4px]",children:"CONCEDED"}),rt.jsx("div",{className:"text-5xl sm:text-7xl font-comic font-[900] text-white tabular-nums leading-none tracking-widest",children:String(U).padStart(2,"0")})]})})]}),rt.jsx("button",{onClick:Pn,className:"w-full max-w-sm sm:max-w-lg mx-auto py-4 sm:py-6 skew-x-[-10deg] font-anime font-black text-[24px] sm:text-[36px] tracking-widest text-white bg-black border-4 border-white hover:bg-[#00E5FF] hover:border-black hover:text-black transition-colors flex items-center justify-center gap-3 sm:gap-4 active:translate-y-2 active:translate-x-2 shadow-[8px_8px_0_#FF0055] sm:shadow-[12px_12px_0_#FF0055] active:shadow-transparent mb-6",children:rt.jsxs("div",{className:"skew-x-[10deg] flex items-center justify-center gap-3 sm:gap-4",children:[rt.jsx(eG,{className:"w-6 h-6 sm:w-8 sm:h-8 stroke-[4]"})," PLAY AGAIN!"]})}),rt.jsx("button",{onClick:()=>ae(!Ht),className:"w-full max-w-xs sm:max-w-sm mx-auto py-2 sm:py-3 skew-x-[-10deg] font-anime font-bold text-lg sm:text-xl tracking-widest text-[#00E5FF] bg-black border-4 border-[#00E5FF] hover:bg-[#00E5FF] hover:text-black transition-colors flex items-center justify-center shadow-[4px_4px_0_#FF0055]",children:rt.jsx("div",{className:"skew-x-[10deg]",children:Ht?"HIDE RANKING":"SHOW RANKING"})}),Ht&&rt.jsx("div",{className:"w-full max-w-sm sm:max-w-lg mx-auto mt-10 mb-16 bg-white border-4 border-black p-4 sm:p-6 shadow-[8px_8px_0_#000] skew-x-[5deg]",children:rt.jsxs("div",{className:"skew-x-[-5deg]",children:[rt.jsx("h3",{className:"text-black font-anime font-black text-xl sm:text-2xl tracking-widest mb-4 sm:mb-6 uppercase text-center bg-[#FFE600] border-2 border-black inline-block px-4 py-1",children:"๐Ÿ† GLOBAL RANKING ๐Ÿ†"}),rt.jsx("div",{className:"flex flex-col gap-2 sm:gap-3",children:d.map((ot,Zt)=>rt.jsxs("div",{className:`flex justify-between items-center px-3 sm:px-4 py-2 border-2 ${ot.isYou?"bg-[#FF0055] border-black text-white shadow-[4px_4px_0_#000]":"bg-black/5 border-black/20 text-black shadow-[2px_2px_0_rgba(0,0,0,0.1)]"}`,children:[rt.jsxs("span",{className:"font-anime font-bold text-base sm:text-lg tracking-widest truncate",children:[Zt+1,". ",ot.name]}),rt.jsx("span",{className:"font-comic font-black text-xl sm:text-2xl tabular-nums ml-4",children:String(ot.score).padStart(5,"0")})]},ot.id+Zt))})]})})]})})}),rt.jsx(Zb,{children:R&&rt.jsx(nv.div,{initial:{opacity:0,scale:.5,y:"100%",rotate:-5},animate:{opacity:1,scale:1,y:0,rotate:0},exit:{opacity:0,scale:1.5,y:"-100%",rotate:5},transition:{type:"spring",damping:15,stiffness:300,duration:.4},className:"absolute inset-0 flex items-center justify-center pointer-events-none z-50 overflow-hidden",children:rt.jsx("div",{className:`w-full flex items-center justify-center py-8 ${R.type==="SUPER_SAVE"?"cut-in-banner":""}`,children:rt.jsx("div",{className:`uppercase whitespace-nowrap text-center font-comic px-10 cut-in-text ${R.type==="SAVE"?"text-[#ffcc00] text-[120px] opacity-90 drop-shadow-[0_10px_0_#997300]":R.type==="SUPER_SAVE"?"text-[#00ffff] text-[150px] scale-110 drop-shadow-[0px_10px_0_#008080] super-aura":"text-[#ff4444] text-[150px] opacity-90 drop-shadow-[0_10px_0_#800000]"}`,style:{WebkitTextStroke:R.type==="SUPER_SAVE"?"4px #fff":"3px #000"},children:R.text})})})}),rt.jsxs("div",{className:"absolute bottom-8 left-8 text-[10px] opacity-40 uppercase font-mono tracking-widest z-50 pointer-events-none",children:["v1.0.4-beta // latency: ",(1e3/60).toFixed(0),"ms"]}),_==="PLAYING"&&rt.jsx("div",{className:"absolute bottom-4 right-4 w-28 h-20 sm:w-32 sm:h-24 bg-black border-2 border-white/80 box-content overflow-hidden shadow-[4px_4px_0_#00E5FF] skew-x-[-8deg] z-50 pointer-events-none fade-in",children:rt.jsxs("div",{className:"skew-x-[10deg] w-full h-full transform scale-110",children:[rt.jsx("video",{ref:n,playsInline:!0,muted:!0,className:"w-full h-full object-cover -scale-x-100"}),rt.jsx("canvas",{ref:i,className:"absolute inset-0 w-full h-full pointer-events-none"}),rt.jsxs("div",{className:"absolute top-1 left-1 text-[8px] font-anime font-black tracking-widest uppercase bg-[#FF0055] px-1.5 py-0.5 text-white flex items-center gap-1 border border-black",children:[rt.jsx("div",{className:"w-1 h-1 bg-white animate-[pulse_1s_ease-in-out_infinite]"}),"REC"]})]})}),rt.jsx("div",{className:"absolute top-4 right-4 z-50 pointer-events-auto",children:rt.jsx("button",{onClick:()=>$(ot=>!ot),className:"bg-white/90 hover:bg-white text-black px-3 py-2 border-2 border-black rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:Et?"CLOSE SETTINGS":"SETTINGS"})}),Et&&rt.jsxs("div",{className:"absolute top-16 right-4 z-50 pointer-events-auto flex flex-col items-end gap-2",children:[B&&rt.jsx("div",{className:"bg-black/70 text-[#00E5FF] px-3 py-1 border border-[#00E5FF]/60 rounded font-anime text-[11px] tracking-widest uppercase backdrop-blur-sm",children:B}),rt.jsx("div",{className:"bg-black/70 text-white px-3 py-2 border border-white/30 rounded font-anime text-[10px] tracking-widest uppercase backdrop-blur-sm",children:ee==="right-only"?`TRACKED ${it.current.toUpperCase()}: ${(it.current==="left"?qe.leftDetected:qe.rightDetected)?"OK":"MISS"}`:`LEFT: ${qe.leftDetected?"OK":"MISS"} | RIGHT: ${qe.rightDetected?"OK":"MISS"}`}),rt.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[rt.jsx("button",{onClick:ze,className:"bg-[#00E5FF]/90 hover:bg-[#00E5FF] text-black px-3 py-2 border-2 border-black rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:"CALIBRATE GLOVES"}),rt.jsx("button",{onClick:Us,className:"bg-[#22c55e]/90 hover:bg-[#22c55e] text-black px-3 py-2 border-2 border-black rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:"SAVE CALIBRATION"}),rt.jsx("button",{onClick:Ro,className:"bg-[#FFE600]/90 hover:bg-[#FFE600] text-black px-3 py-2 border-2 border-black rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:"DETECT RIGHT HAND"}),rt.jsxs("button",{onClick:()=>Co(ee==="both"?"right-only":"both"),className:"bg-[#FF0055]/90 hover:bg-[#FF0055] text-white px-3 py-2 border-2 border-black rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:["TRACK: ",ee==="both"?"BOTH":"RIGHT ONLY"]}),rt.jsxs("button",{onClick:Sn,className:"bg-black/60 hover:bg-black text-white px-3 py-2 border-2 border-white/60 rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:["WRAP: ",J?"STATIC":"DYNAMIC"]}),rt.jsxs("button",{onClick:ii,className:"bg-black/60 hover:bg-black text-white px-3 py-2 border-2 border-white/60 rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:["MAP: ",yt?"SWAPPED":"NORMAL"]}),rt.jsxs("button",{onClick:()=>z(!ft),className:"bg-black/50 hover:bg-black text-white px-3 py-2 border-2 border-white/50 rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:["DEBUG: ",ft?"ON":"OFF"]}),rt.jsxs("button",{onClick:()=>Dt(ot=>!ot),className:"bg-white/90 hover:bg-white text-black px-3 py-2 border-2 border-black rounded font-anime text-xs tracking-widest backdrop-blur-sm transition-colors",children:[mt?"HIDE":"OPEN"," GLOVE CAL"]})]}),mt&&rt.jsxs("div",{className:"w-[320px] max-w-[92vw] bg-black/80 border-2 border-[#00E5FF] rounded-lg p-3 backdrop-blur-md text-white shadow-[0_0_20px_rgba(0,229,255,0.3)]",children:[rt.jsxs("div",{className:"flex items-center justify-between gap-2 mb-3",children:[rt.jsx("div",{className:"font-anime text-[11px] tracking-widest uppercase text-[#00E5FF]",children:"Drag, Rotate, Tune"}),rt.jsxs("div",{className:"flex gap-1",children:[rt.jsx("button",{onClick:()=>Wt("left"),className:`px-2 py-1 border rounded text-[10px] font-anime tracking-widest ${_t==="left"?"bg-[#00E5FF] text-black border-black":"bg-black/40 border-white/40"}`,children:"LEFT"}),rt.jsx("button",{onClick:()=>Wt("right"),className:`px-2 py-1 border rounded text-[10px] font-anime tracking-widest ${_t==="right"?"bg-[#00E5FF] text-black border-black":"bg-black/40 border-white/40"}`,children:"RIGHT"})]})]}),rt.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[rt.jsxs("div",{children:[rt.jsx("div",{className:"text-[10px] uppercase tracking-widest mb-1 text-white/80",children:"Drag Position (X/Y)"}),rt.jsxs("div",{ref:gt,onPointerDown:ot=>{jn(!0),ot.currentTarget.setPointerCapture(ot.pointerId),_a(ot.clientX,ot.clientY)},onPointerMove:ot=>{j&&_a(ot.clientX,ot.clientY)},onPointerUp:ot=>{jn(!1),ot.currentTarget.hasPointerCapture(ot.pointerId)&&ot.currentTarget.releasePointerCapture(ot.pointerId)},onPointerCancel:ot=>{jn(!1),ot.currentTarget.hasPointerCapture(ot.pointerId)&&ot.currentTarget.releasePointerCapture(ot.pointerId)},className:"relative h-28 rounded border border-white/40 bg-[linear-gradient(90deg,rgba(255,255,255,0.06)_1px,transparent_1px),linear-gradient(rgba(255,255,255,0.06)_1px,transparent_1px)] [background-size:14px_14px] touch-none",children:[rt.jsx("div",{className:"absolute left-1/2 top-1/2 w-px h-full bg-white/20 -translate-x-1/2"}),rt.jsx("div",{className:"absolute top-1/2 left-0 h-px w-full bg-white/20 -translate-y-1/2"}),rt.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-[#00E5FF] border border-black -translate-x-1/2 -translate-y-1/2 shadow-[0_0_8px_rgba(0,229,255,0.8)]",style:Xa})]})]}),rt.jsxs("div",{children:[rt.jsx("div",{className:"text-[10px] uppercase tracking-widest mb-1 text-white/80",children:"Rotate Glove"}),rt.jsxs("div",{ref:wt,onPointerDown:ot=>{Re(!0),ot.currentTarget.setPointerCapture(ot.pointerId),Wa(ot.clientX,ot.clientY)},onPointerMove:ot=>{we&&Wa(ot.clientX,ot.clientY)},onPointerUp:ot=>{Re(!1),ot.currentTarget.hasPointerCapture(ot.pointerId)&&ot.currentTarget.releasePointerCapture(ot.pointerId)},onPointerCancel:ot=>{Re(!1),ot.currentTarget.hasPointerCapture(ot.pointerId)&&ot.currentTarget.releasePointerCapture(ot.pointerId)},className:"relative h-28 rounded-full border border-white/40 bg-black/40 touch-none",children:[rt.jsx("div",{className:"absolute left-1/2 top-1/2 w-[40%] h-[2px] bg-[#FFE600] origin-left",style:hs}),rt.jsx("div",{className:"absolute left-1/2 top-1/2 w-3 h-3 bg-[#FFE600] rounded-full -translate-x-1/2 -translate-y-1/2 border border-black"})]})]})]}),rt.jsxs("div",{className:"space-y-2",children:[rt.jsxs("label",{className:"block text-[10px] uppercase tracking-widest",children:["Scale ",ni.scale.toFixed(2),rt.jsx("input",{type:"range",min:.2,max:.9,step:.01,value:ni.scale,onChange:ot=>bn(_t,{scale:Number(ot.target.value)}),className:"w-full"})]}),rt.jsxs("label",{className:"block text-[10px] uppercase tracking-widest",children:["Depth Z ",ni.offsetZ.toFixed(3),rt.jsx("input",{type:"range",min:-.2,max:.2,step:.005,value:ni.offsetZ,onChange:ot=>bn(_t,{offsetZ:Number(ot.target.value)}),className:"w-full"})]}),rt.jsxs("label",{className:"block text-[10px] uppercase tracking-widest",children:["Forward ",ni.forwardMul.toFixed(3),rt.jsx("input",{type:"range",min:-.2,max:.2,step:.005,value:ni.forwardMul,onChange:ot=>bn(_t,{forwardMul:Number(ot.target.value)}),className:"w-full"})]}),rt.jsxs("label",{className:"block text-[10px] uppercase tracking-widest",children:["Side ",ni.sideMul.toFixed(3),rt.jsx("input",{type:"range",min:-.2,max:.2,step:.005,value:ni.sideMul,onChange:ot=>bn(_t,{sideMul:Number(ot.target.value)}),className:"w-full"})]}),rt.jsxs("label",{className:"block text-[10px] uppercase tracking-widest",children:["Rotation ",Math.round(ni.rotationDeg),"deg",rt.jsx("input",{type:"range",min:-180,max:180,step:1,value:ni.rotationDeg,onChange:ot=>bn(_t,{rotationDeg:Number(ot.target.value)}),className:"w-full"})]})]}),rt.jsxs("button",{onClick:fs,className:"mt-3 w-full bg-white text-black border border-black py-2 rounded font-anime text-[10px] tracking-widest uppercase",children:["Reset ",_t," Glove"]})]})]})]})]})}h5.createRoot(document.getElementById("root")).render(rt.jsx(dt.StrictMode,{children:rt.jsx(gG,{})}));