(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();var N0={exports:{}},cf={};/** * @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 nb;function FL(){if(nb)return cf;nb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(i,r,o){var c=null;if(o!==void 0&&(c=""+o),r.key!==void 0&&(c=""+r.key),"key"in r){o={};for(var u in r)u!=="key"&&(o[u]=r[u])}else o=r;return r=o.ref,{$$typeof:e,type:i,key:c,ref:r!==void 0?r:null,props:o}}return cf.Fragment=t,cf.jsx=n,cf.jsxs=n,cf}var ib;function kL(){return ib||(ib=1,N0.exports=FL()),N0.exports}var _t=kL(),U0={exports:{}},de={};/** * @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 sb;function zL(){if(sb)return de;sb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=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"),_=Symbol.iterator;function y(z){return z===null||typeof z!="object"?null:(z=_&&z[_]||z["@@iterator"],typeof z=="function"?z:null)}var M={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,S={};function x(z,it,Tt){this.props=z,this.context=it,this.refs=S,this.updater=Tt||M}x.prototype.isReactComponent={},x.prototype.setState=function(z,it){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,it,"setState")},x.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function R(){}R.prototype=x.prototype;function w(z,it,Tt){this.props=z,this.context=it,this.refs=S,this.updater=Tt||M}var E=w.prototype=new R;E.constructor=w,T(E,x.prototype),E.isPureReactComponent=!0;var P=Array.isArray;function I(){}var U={H:null,A:null,T:null,S:null},B=Object.prototype.hasOwnProperty;function D(z,it,Tt){var J=Tt.ref;return{$$typeof:e,type:z,key:it,ref:J!==void 0?J:null,props:Tt}}function A(z,it){return D(z.type,it,z.props)}function F(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function q(z){var it={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(Tt){return it[Tt]})}var tt=/\/+/g;function ot(z,it){return typeof z=="object"&&z!==null&&z.key!=null?q(""+z.key):it.toString(36)}function ct(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(I,I):(z.status="pending",z.then(function(it){z.status==="pending"&&(z.status="fulfilled",z.value=it)},function(it){z.status==="pending"&&(z.status="rejected",z.reason=it)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function k(z,it,Tt,J,dt){var At=typeof z;(At==="undefined"||At==="boolean")&&(z=null);var xt=!1;if(z===null)xt=!0;else switch(At){case"bigint":case"string":case"number":xt=!0;break;case"object":switch(z.$$typeof){case e:case t:xt=!0;break;case p:return xt=z._init,k(xt(z._payload),it,Tt,J,dt)}}if(xt)return dt=dt(z),xt=J===""?"."+ot(z,0):J,P(dt)?(Tt="",xt!=null&&(Tt=xt.replace(tt,"$&/")+"/"),k(dt,it,Tt,"",function($t){return $t})):dt!=null&&(F(dt)&&(dt=A(dt,Tt+(dt.key==null||z&&z.key===dt.key?"":(""+dt.key).replace(tt,"$&/")+"/")+xt)),it.push(dt)),1;xt=0;var Vt=J===""?".":J+":";if(P(z))for(var Gt=0;Gt>>1,bt=k[pt];if(0>>1;ptr(Tt,j))Jr(dt,Tt)?(k[pt]=dt,k[J]=j,pt=J):(k[pt]=Tt,k[it]=j,pt=it);else if(Jr(dt,j))k[pt]=dt,k[J]=j,pt=J;else break t}}return Q}function r(k,Q){var j=k.sortIndex-Q.sortIndex;return j!==0?j:k.id-Q.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 c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var h=[],d=[],p=1,m=null,_=3,y=!1,M=!1,T=!1,S=!1,x=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function E(k){for(var Q=n(d);Q!==null;){if(Q.callback===null)i(d);else if(Q.startTime<=k)i(d),Q.sortIndex=Q.expirationTime,t(h,Q);else break;Q=n(d)}}function P(k){if(T=!1,E(k),!M)if(n(h)!==null)M=!0,I||(I=!0,q());else{var Q=n(d);Q!==null&&ct(P,Q.startTime-k)}}var I=!1,U=-1,B=5,D=-1;function A(){return S?!0:!(e.unstable_now()-Dk&&A());){var pt=m.callback;if(typeof pt=="function"){m.callback=null,_=m.priorityLevel;var bt=pt(m.expirationTime<=k);if(k=e.unstable_now(),typeof bt=="function"){m.callback=bt,E(k),Q=!0;break e}m===n(h)&&i(h),E(k)}else i(h);m=n(h)}if(m!==null)Q=!0;else{var z=n(d);z!==null&&ct(P,z.startTime-k),Q=!1}}break t}finally{m=null,_=j,y=!1}Q=void 0}}finally{Q?q():I=!1}}}var q;if(typeof w=="function")q=function(){w(F)};else if(typeof MessageChannel<"u"){var tt=new MessageChannel,ot=tt.port2;tt.port1.onmessage=F,q=function(){ot.postMessage(null)}}else q=function(){x(F,0)};function ct(k,Q){U=x(function(){k(e.unstable_now())},Q)}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(k){k.callback=null},e.unstable_forceFrameRate=function(k){0>k||125pt?(k.sortIndex=j,t(d,k),n(h)===null&&k===n(d)&&(T?(R(U),U=-1):T=!0,ct(P,j-pt))):(k.sortIndex=bt,t(h,k),M||y||(M=!0,I||(I=!0,q()))),k},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(k){var Q=_;return function(){var j=_;_=Q;try{return k.apply(this,arguments)}finally{_=j}}}})(I0)),I0}var ob;function HL(){return ob||(ob=1,O0.exports=VL()),O0.exports}var B0={exports:{}},yi={};/** * @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 lb;function GL(){if(lb)return yi;lb=1;var e=A1();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(),B0.exports=GL(),B0.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 ub;function jL(){if(ub)return uf;ub=1;var e=HL(),t=A1(),n=WL();function i(s){var a="https://react.dev/errors/"+s;if(1bt||(s.current=pt[bt],pt[bt]=null,bt--)}function Tt(s,a){bt++,pt[bt]=s.current,s.current=a}var J=z(null),dt=z(null),At=z(null),xt=z(null);function Vt(s,a){switch(Tt(At,a),Tt(dt,s),Tt(J,null),a.nodeType){case 9:case 11:s=(s=a.documentElement)&&(s=s.namespaceURI)?EM(s):0;break;default:if(s=a.tagName,a=a.namespaceURI)a=EM(a),s=AM(a,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}it(J),Tt(J,s)}function Gt(){it(J),it(dt),it(At)}function $t(s){s.memoizedState!==null&&Tt(xt,s);var a=J.current,l=AM(a,s.type);a!==l&&(Tt(dt,s),Tt(J,l))}function Ke(s){dt.current===s&&(it(J),it(dt)),xt.current===s&&(it(xt),rf._currentValue=j)}var Ge,ye;function H(s){if(Ge===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);Ge=a&&a[1]||"",ye=-1)":-1g||V[f]!==nt[g]){var ht=` `+V[f].replace(" at new "," at ");return s.displayName&&ht.includes("")&&(ht=ht.replace("",s.displayName)),ht}while(1<=f&&0<=g);break}}}finally{Wn=!1,Error.prepareStackTrace=l}return(l=s?s.displayName||s.name:"")?H(l):""}function be(s,a){switch(s.tag){case 26:case 27:case 5:return H(s.type);case 16:return H("Lazy");case 13:return s.child!==a&&a!==null?H("Suspense Fallback"):H("Suspense");case 19:return H("SuspenseList");case 0:case 15:return xe(s.type,!1);case 11:return xe(s.type.render,!1);case 1:return xe(s.type,!0);case 31:return H("Activity");default:return""}}function Kt(s){try{var a="",l=null;do a+=be(s,l),l=s,s=s.return;while(s);return a}catch(f){return` Error generating stack: `+f.message+` `+f.stack}}var Dt=Object.prototype.hasOwnProperty,Et=e.unstable_scheduleCallback,O=e.unstable_cancelCallback,C=e.unstable_shouldYield,$=e.unstable_requestPaint,ut=e.unstable_now,St=e.unstable_getCurrentPriorityLevel,mt=e.unstable_ImmediatePriority,Xt=e.unstable_UserBlockingPriority,Ct=e.unstable_NormalPriority,Lt=e.unstable_LowPriority,Se=e.unstable_IdlePriority,Rt=e.log,zt=e.unstable_setDisableYieldValue,te=null,qt=null;function Bt(s){if(typeof Rt=="function"&&zt(s),qt&&typeof qt.setStrictMode=="function")try{qt.setStrictMode(te,s)}catch{}}var oe=Math.clz32?Math.clz32:Y,pe=Math.log,$e=Math.LN2;function Y(s){return s>>>=0,s===0?32:31-(pe(s)/$e|0)|0}var Nt=256,ft=262144,yt=4194304;function Ut(s){var a=s&42;if(a!==0)return a;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 Pt(s,a,l){var f=s.pendingLanes;if(f===0)return 0;var g=0,v=s.suspendedLanes,b=s.pingedLanes;s=s.warmLanes;var L=f&134217727;return L!==0?(f=L&~v,f!==0?g=Ut(f):(b&=L,b!==0?g=Ut(b):l||(l=L&~s,l!==0&&(g=Ut(l))))):(L=f&~v,L!==0?g=Ut(L):b!==0?g=Ut(b):l||(l=f&~s,l!==0&&(g=Ut(l)))),g===0?0:a!==0&&a!==g&&(a&v)===0&&(v=g&-g,l=a&-a,v>=l||v===32&&(l&4194048)!==0)?a:g}function le(s,a){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&a)===0}function pn(s,a){switch(s){case 1:case 2:case 4:case 8:case 64:return a+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 a+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 jn(){var s=yt;return yt<<=1,(yt&62914560)===0&&(yt=4194304),s}function Be(s){for(var a=[],l=0;31>l;l++)a.push(s);return a}function li(s,a){s.pendingLanes|=a,a!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Vs(s,a,l,f,g,v){var b=s.pendingLanes;s.pendingLanes=l,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=l,s.entangledLanes&=l,s.errorRecoveryDisabledLanes&=l,s.shellSuspendCounter=0;var L=s.entanglements,V=s.expirationTimes,nt=s.hiddenUpdates;for(l=b&~l;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var Ai=/[\n"\\]/g;function ni(s){return s.replace(Ai,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function tn(s,a,l,f,g,v,b,L){s.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?s.type=b:s.removeAttribute("type"),a!=null?b==="number"?(a===0&&s.value===""||s.value!=a)&&(s.value=""+fe(a)):s.value!==""+fe(a)&&(s.value=""+fe(a)):b!=="submit"&&b!=="reset"||s.removeAttribute("value"),a!=null?vi(s,b,fe(a)):l!=null?vi(s,b,fe(l)):f!=null&&s.removeAttribute("value"),g==null&&v!=null&&(s.defaultChecked=!!v),g!=null&&(s.checked=g&&typeof g!="function"&&typeof g!="symbol"),L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"?s.name=""+fe(L):s.removeAttribute("name")}function wi(s,a,l,f,g,v,b,L){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(s.type=v),a!=null||l!=null){if(!(v!=="submit"&&v!=="reset"||a!=null)){Pe(s);return}l=l!=null?""+fe(l):"",a=a!=null?""+fe(a):l,L||a===s.value||(s.value=a),s.defaultValue=a}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,s.checked=L?s.checked:!!f,s.defaultChecked=!!f,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(s.name=b),Pe(s)}function vi(s,a,l){a==="number"&&Gs(s.ownerDocument)===s||s.defaultValue===""+l||(s.defaultValue=""+l)}function En(s,a,l,f){if(s=s.options,a){a={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Nm=!1;if(Ir)try{var Mu={};Object.defineProperty(Mu,"passive",{get:function(){Nm=!0}}),window.addEventListener("test",Mu,Mu),window.removeEventListener("test",Mu,Mu)}catch{Nm=!1}var ga=null,Um=null,gh=null;function Ax(){if(gh)return gh;var s,a=Um,l=a.length,f,g="value"in ga?ga.value:ga.textContent,v=g.length;for(s=0;s=Eu),Nx=" ",Ux=!1;function Px(s,a){switch(s){case"keyup":return aD.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ox(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var xl=!1;function lD(s,a){switch(s){case"compositionend":return Ox(a);case"keypress":return a.which!==32?null:(Ux=!0,Nx);case"textInput":return s=a.data,s===Nx&&Ux?null:s;default:return null}}function cD(s,a){if(xl)return s==="compositionend"||!Fm&&Px(s,a)?(s=Ax(),gh=Um=ga=null,xl=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:l,offset:a-s};s=f}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=Gx(l)}}function jx(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?jx(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function Xx(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var a=Gs(s.document);a instanceof s.HTMLIFrameElement;){try{var l=typeof a.contentWindow.location.href=="string"}catch{l=!1}if(l)s=a.contentWindow;else break;a=Gs(s.document)}return a}function Vm(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a&&(a==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||a==="textarea"||s.contentEditable==="true")}var _D=Ir&&"documentMode"in document&&11>=document.documentMode,Sl=null,Hm=null,Cu=null,Gm=!1;function qx(s,a,l){var f=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Gm||Sl==null||Sl!==Gs(f)||(f=Sl,"selectionStart"in f&&Vm(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}),Cu&&Ru(Cu,f)||(Cu=f,f=cd(Hm,"onSelect"),0>=b,g-=b,ur=1<<32-oe(a)+g|l<ge?(De=Yt,Yt=null):De=Yt.sibling;var Ve=st(Z,Yt,et[ge],gt);if(Ve===null){Yt===null&&(Yt=De);break}s&&Yt&&Ve.alternate===null&&a(Z,Yt),W=v(Ve,W,ge),ze===null?ne=Ve:ze.sibling=Ve,ze=Ve,Yt=De}if(ge===et.length)return l(Z,Yt),Ue&&Fr(Z,ge),ne;if(Yt===null){for(;gege?(De=Yt,Yt=null):De=Yt.sibling;var Fa=st(Z,Yt,Ve.value,gt);if(Fa===null){Yt===null&&(Yt=De);break}s&&Yt&&Fa.alternate===null&&a(Z,Yt),W=v(Fa,W,ge),ze===null?ne=Fa:ze.sibling=Fa,ze=Fa,Yt=De}if(Ve.done)return l(Z,Yt),Ue&&Fr(Z,ge),ne;if(Yt===null){for(;!Ve.done;ge++,Ve=et.next())Ve=vt(Z,Ve.value,gt),Ve!==null&&(W=v(Ve,W,ge),ze===null?ne=Ve:ze.sibling=Ve,ze=Ve);return Ue&&Fr(Z,ge),ne}for(Yt=f(Yt);!Ve.done;ge++,Ve=et.next())Ve=lt(Yt,Z,ge,Ve.value,gt),Ve!==null&&(s&&Ve.alternate!==null&&Yt.delete(Ve.key===null?ge:Ve.key),W=v(Ve,W,ge),ze===null?ne=Ve:ze.sibling=Ve,ze=Ve);return s&&Yt.forEach(function(BL){return a(Z,BL)}),Ue&&Fr(Z,ge),ne}function sn(Z,W,et,gt){if(typeof et=="object"&&et!==null&&et.type===T&&et.key===null&&(et=et.props.children),typeof et=="object"&&et!==null){switch(et.$$typeof){case y:t:{for(var ne=et.key;W!==null;){if(W.key===ne){if(ne=et.type,ne===T){if(W.tag===7){l(Z,W.sibling),gt=g(W,et.props.children),gt.return=Z,Z=gt;break t}}else if(W.elementType===ne||typeof ne=="object"&&ne!==null&&ne.$$typeof===B&&Eo(ne)===W.type){l(Z,W.sibling),gt=g(W,et.props),Ou(gt,et),gt.return=Z,Z=gt;break t}l(Z,W);break}else a(Z,W);W=W.sibling}et.type===T?(gt=xo(et.props.children,Z.mode,gt,et.key),gt.return=Z,Z=gt):(gt=Ah(et.type,et.key,et.props,null,Z.mode,gt),Ou(gt,et),gt.return=Z,Z=gt)}return b(Z);case M:t:{for(ne=et.key;W!==null;){if(W.key===ne)if(W.tag===4&&W.stateNode.containerInfo===et.containerInfo&&W.stateNode.implementation===et.implementation){l(Z,W.sibling),gt=g(W,et.children||[]),gt.return=Z,Z=gt;break t}else{l(Z,W);break}else a(Z,W);W=W.sibling}gt=Zm(et,Z.mode,gt),gt.return=Z,Z=gt}return b(Z);case B:return et=Eo(et),sn(Z,W,et,gt)}if(ct(et))return Ht(Z,W,et,gt);if(q(et)){if(ne=q(et),typeof ne!="function")throw Error(i(150));return et=ne.call(et),re(Z,W,et,gt)}if(typeof et.then=="function")return sn(Z,W,Uh(et),gt);if(et.$$typeof===w)return sn(Z,W,Ch(Z,et),gt);Ph(Z,et)}return typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint"?(et=""+et,W!==null&&W.tag===6?(l(Z,W.sibling),gt=g(W,et),gt.return=Z,Z=gt):(l(Z,W),gt=Km(et,Z.mode,gt),gt.return=Z,Z=gt),b(Z)):l(Z,W)}return function(Z,W,et,gt){try{Pu=0;var ne=sn(Z,W,et,gt);return Nl=null,ne}catch(Yt){if(Yt===Ll||Yt===Lh)throw Yt;var ze=ts(29,Yt,null,Z.mode);return ze.lanes=gt,ze.return=Z,ze}finally{}}}var wo=g2(!0),_2=g2(!1),Sa=!1;function lg(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function cg(s,a){s=s.updateQueue,a.updateQueue===s&&(a.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function Ma(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function ba(s,a,l){var f=s.updateQueue;if(f===null)return null;if(f=f.shared,(We&2)!==0){var g=f.pending;return g===null?a.next=a:(a.next=g.next,g.next=a),f.pending=a,a=Eh(s),t2(s,null,l),a}return Th(s,f,a,l),Eh(s)}function Iu(s,a,l){if(a=a.updateQueue,a!==null&&(a=a.shared,(l&4194048)!==0)){var f=a.lanes;f&=s.pendingLanes,l|=f,a.lanes=l,_u(s,l)}}function ug(s,a){var l=s.updateQueue,f=s.alternate;if(f!==null&&(f=f.updateQueue,l===f)){var g=null,v=null;if(l=l.firstBaseUpdate,l!==null){do{var b={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};v===null?g=v=b:v=v.next=b,l=l.next}while(l!==null);v===null?g=v=a:v=v.next=a}else g=v=a;l={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},s.updateQueue=l;return}s=l.lastBaseUpdate,s===null?l.firstBaseUpdate=a:s.next=a,l.lastBaseUpdate=a}var fg=!1;function Bu(){if(fg){var s=Dl;if(s!==null)throw s}}function Fu(s,a,l,f){fg=!1;var g=s.updateQueue;Sa=!1;var v=g.firstBaseUpdate,b=g.lastBaseUpdate,L=g.shared.pending;if(L!==null){g.shared.pending=null;var V=L,nt=V.next;V.next=null,b===null?v=nt:b.next=nt,b=V;var ht=s.alternate;ht!==null&&(ht=ht.updateQueue,L=ht.lastBaseUpdate,L!==b&&(L===null?ht.firstBaseUpdate=nt:L.next=nt,ht.lastBaseUpdate=V))}if(v!==null){var vt=g.baseState;b=0,ht=nt=V=null,L=v;do{var st=L.lane&-536870913,lt=st!==L.lane;if(lt?(Ce&st)===st:(f&st)===st){st!==0&&st===Cl&&(fg=!0),ht!==null&&(ht=ht.next={lane:0,tag:L.tag,payload:L.payload,callback:null,next:null});t:{var Ht=s,re=L;st=a;var sn=l;switch(re.tag){case 1:if(Ht=re.payload,typeof Ht=="function"){vt=Ht.call(sn,vt,st);break t}vt=Ht;break t;case 3:Ht.flags=Ht.flags&-65537|128;case 0:if(Ht=re.payload,st=typeof Ht=="function"?Ht.call(sn,vt,st):Ht,st==null)break t;vt=m({},vt,st);break t;case 2:Sa=!0}}st=L.callback,st!==null&&(s.flags|=64,lt&&(s.flags|=8192),lt=g.callbacks,lt===null?g.callbacks=[st]:lt.push(st))}else lt={lane:st,tag:L.tag,payload:L.payload,callback:L.callback,next:null},ht===null?(nt=ht=lt,V=vt):ht=ht.next=lt,b|=st;if(L=L.next,L===null){if(L=g.shared.pending,L===null)break;lt=L,L=lt.next,lt.next=null,g.lastBaseUpdate=lt,g.shared.pending=null}}while(!0);ht===null&&(V=vt),g.baseState=V,g.firstBaseUpdate=nt,g.lastBaseUpdate=ht,v===null&&(g.shared.lanes=0),Ra|=b,s.lanes=b,s.memoizedState=vt}}function v2(s,a){if(typeof s!="function")throw Error(i(191,s));s.call(a)}function y2(s,a){var l=s.callbacks;if(l!==null)for(s.callbacks=null,s=0;sv?v:8;var b=k.T,L={};k.T=L,Dg(s,!1,a,l);try{var V=g(),nt=k.S;if(nt!==null&&nt(L,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var ht=AD(V,f);Vu(s,a,ht,rs(s))}else Vu(s,a,f,rs(s))}catch(vt){Vu(s,a,{then:function(){},status:"rejected",reason:vt},rs())}finally{Q.p=v,b!==null&&L.types!==null&&(b.types=L.types),k.T=b}}function ND(){}function Rg(s,a,l,f){if(s.tag!==5)throw Error(i(476));var g=Q2(s).queue;Z2(s,g,a,j,l===null?ND:function(){return J2(s),l(f)})}function Q2(s){var a=s.memoizedState;if(a!==null)return a;a={memoizedState:j,baseState:j,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hr,lastRenderedState:j},next:null};var l={};return a.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hr,lastRenderedState:l},next:null},s.memoizedState=a,s=s.alternate,s!==null&&(s.memoizedState=a),a}function J2(s){var a=Q2(s);a.next===null&&(a=s.alternate.memoizedState),Vu(s,a.next.queue,{},rs())}function Cg(){return hi(rf)}function $2(){return Nn().memoizedState}function tS(){return Nn().memoizedState}function UD(s){for(var a=s.return;a!==null;){switch(a.tag){case 24:case 3:var l=rs();s=Ma(l);var f=ba(a,s,l);f!==null&&(ji(f,a,l),Iu(f,a,l)),a={cache:sg()},s.payload=a;return}a=a.return}}function PD(s,a,l){var f=rs();l={lane:f,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Wh(s)?nS(a,l):(l=qm(s,a,l,f),l!==null&&(ji(l,s,f),iS(l,a,f)))}function eS(s,a,l){var f=rs();Vu(s,a,l,f)}function Vu(s,a,l,f){var g={lane:f,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Wh(s))nS(a,g);else{var v=s.alternate;if(s.lanes===0&&(v===null||v.lanes===0)&&(v=a.lastRenderedReducer,v!==null))try{var b=a.lastRenderedState,L=v(b,l);if(g.hasEagerState=!0,g.eagerState=L,$i(L,b))return Th(s,a,g,0),on===null&&bh(),!1}catch{}finally{}if(l=qm(s,a,g,f),l!==null)return ji(l,s,f),iS(l,a,f),!0}return!1}function Dg(s,a,l,f){if(f={lane:2,revertLane:l0(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Wh(s)){if(a)throw Error(i(479))}else a=qm(s,l,f,2),a!==null&&ji(a,s,2)}function Wh(s){var a=s.alternate;return s===me||a!==null&&a===me}function nS(s,a){Pl=Bh=!0;var l=s.pending;l===null?a.next=a:(a.next=l.next,l.next=a),s.pending=a}function iS(s,a,l){if((l&4194048)!==0){var f=a.lanes;f&=s.pendingLanes,l|=f,a.lanes=l,_u(s,l)}}var Hu={readContext:hi,use:zh,useCallback:An,useContext:An,useEffect:An,useImperativeHandle:An,useLayoutEffect:An,useInsertionEffect:An,useMemo:An,useReducer:An,useRef:An,useState:An,useDebugValue:An,useDeferredValue:An,useTransition:An,useSyncExternalStore:An,useId:An,useHostTransitionStatus:An,useFormState:An,useActionState:An,useOptimistic:An,useMemoCache:An,useCacheRefresh:An};Hu.useEffectEvent=An;var sS={readContext:hi,use:zh,useCallback:function(s,a){return Ri().memoizedState=[s,a===void 0?null:a],s},useContext:hi,useEffect:V2,useImperativeHandle:function(s,a,l){l=l!=null?l.concat([s]):null,Hh(4194308,4,j2.bind(null,a,s),l)},useLayoutEffect:function(s,a){return Hh(4194308,4,s,a)},useInsertionEffect:function(s,a){Hh(4,2,s,a)},useMemo:function(s,a){var l=Ri();a=a===void 0?null:a;var f=s();if(Ro){Bt(!0);try{s()}finally{Bt(!1)}}return l.memoizedState=[f,a],f},useReducer:function(s,a,l){var f=Ri();if(l!==void 0){var g=l(a);if(Ro){Bt(!0);try{l(a)}finally{Bt(!1)}}}else g=a;return f.memoizedState=f.baseState=g,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:g},f.queue=s,s=s.dispatch=PD.bind(null,me,s),[f.memoizedState,s]},useRef:function(s){var a=Ri();return s={current:s},a.memoizedState=s},useState:function(s){s=bg(s);var a=s.queue,l=eS.bind(null,me,a);return a.dispatch=l,[s.memoizedState,l]},useDebugValue:Ag,useDeferredValue:function(s,a){var l=Ri();return wg(l,s,a)},useTransition:function(){var s=bg(!1);return s=Z2.bind(null,me,s.queue,!0,!1),Ri().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,a,l){var f=me,g=Ri();if(Ue){if(l===void 0)throw Error(i(407));l=l()}else{if(l=a(),on===null)throw Error(i(349));(Ce&127)!==0||E2(f,a,l)}g.memoizedState=l;var v={value:l,getSnapshot:a};return g.queue=v,V2(w2.bind(null,f,v,s),[s]),f.flags|=2048,Il(9,{destroy:void 0},A2.bind(null,f,v,l,a),null),l},useId:function(){var s=Ri(),a=on.identifierPrefix;if(Ue){var l=fr,f=ur;l=(f&~(1<<32-oe(f)-1)).toString(32)+l,a="_"+a+"R_"+l,l=Fh++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?b.createElement("select",{is:f.is}):b.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?b.createElement(g,{is:f.is}):b.createElement(g)}}v[Tn]=a,v[ci]=f;t:for(b=a.child;b!==null;){if(b.tag===5||b.tag===6)v.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===a)break t;for(;b.sibling===null;){if(b.return===null||b.return===a)break t;b=b.return}b.sibling.return=b.return,b=b.sibling}a.stateNode=v;t:switch(pi(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&&Wr(a)}}return hn(a),Wg(a,a.type,s===null?null:s.memoizedProps,a.pendingProps,l),null;case 6:if(s&&a.stateNode!=null)s.memoizedProps!==f&&Wr(a);else{if(typeof f!="string"&&a.stateNode===null)throw Error(i(166));if(s=At.current,wl(a)){if(s=a.stateNode,l=a.memoizedProps,f=null,g=fi,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}s[Tn]=a,s=!!(s.nodeValue===l||f!==null&&f.suppressHydrationWarning===!0||bM(s.nodeValue,l)),s||ya(a,!0)}else s=ud(s).createTextNode(f),s[Tn]=a,a.stateNode=s}return hn(a),null;case 31:if(l=a.memoizedState,s===null||s.memoizedState!==null){if(f=wl(a),l!==null){if(s===null){if(!f)throw Error(i(318));if(s=a.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(i(557));s[Tn]=a}else So(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;hn(a),s=!1}else l=tg(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=l),s=!0;if(!s)return a.flags&256?(ns(a),a):(ns(a),null);if((a.flags&128)!==0)throw Error(i(558))}return hn(a),null;case 13:if(f=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(g=wl(a),f!==null&&f.dehydrated!==null){if(s===null){if(!g)throw Error(i(318));if(g=a.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[Tn]=a}else So(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;hn(a),g=!1}else g=tg(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=g),g=!0;if(!g)return a.flags&256?(ns(a),a):(ns(a),null)}return ns(a),(a.flags&128)!==0?(a.lanes=l,a):(l=f!==null,s=s!==null&&s.memoizedState!==null,l&&(f=a.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)),l!==s&&l&&(a.child.flags|=8192),Kh(a,a.updateQueue),hn(a),null);case 4:return Gt(),s===null&&h0(a.stateNode.containerInfo),hn(a),null;case 10:return zr(a.type),hn(a),null;case 19:if(it(Ln),f=a.memoizedState,f===null)return hn(a),null;if(g=(a.flags&128)!==0,v=f.rendering,v===null)if(g)Wu(f,!1);else{if(wn!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(v=Ih(s),v!==null){for(a.flags|=128,Wu(f,!1),s=v.updateQueue,a.updateQueue=s,Kh(a,s),a.subtreeFlags=0,s=l,l=a.child;l!==null;)e2(l,s),l=l.sibling;return Tt(Ln,Ln.current&1|2),Ue&&Fr(a,f.treeForkCount),a.child}s=s.sibling}f.tail!==null&&ut()>td&&(a.flags|=128,g=!0,Wu(f,!1),a.lanes=4194304)}else{if(!g)if(s=Ih(v),s!==null){if(a.flags|=128,g=!0,s=s.updateQueue,a.updateQueue=s,Kh(a,s),Wu(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!Ue)return hn(a),null}else 2*ut()-f.renderingStartTime>td&&l!==536870912&&(a.flags|=128,g=!0,Wu(f,!1),a.lanes=4194304);f.isBackwards?(v.sibling=a.child,a.child=v):(s=f.last,s!==null?s.sibling=v:a.child=v,f.last=v)}return f.tail!==null?(s=f.tail,f.rendering=s,f.tail=s.sibling,f.renderingStartTime=ut(),s.sibling=null,l=Ln.current,Tt(Ln,g?l&1|2:l&1),Ue&&Fr(a,f.treeForkCount),s):(hn(a),null);case 22:case 23:return ns(a),dg(),f=a.memoizedState!==null,s!==null?s.memoizedState!==null!==f&&(a.flags|=8192):f&&(a.flags|=8192),f?(l&536870912)!==0&&(a.flags&128)===0&&(hn(a),a.subtreeFlags&6&&(a.flags|=8192)):hn(a),l=a.updateQueue,l!==null&&Kh(a,l.retryQueue),l=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),f=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(f=a.memoizedState.cachePool.pool),f!==l&&(a.flags|=2048),s!==null&&it(To),null;case 24:return l=null,s!==null&&(l=s.memoizedState.cache),a.memoizedState.cache!==l&&(a.flags|=2048),zr(Pn),hn(a),null;case 25:return null;case 30:return null}throw Error(i(156,a.tag))}function kD(s,a){switch(Jm(a),a.tag){case 1:return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return zr(Pn),Gt(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 26:case 27:case 5:return Ke(a),null;case 31:if(a.memoizedState!==null){if(ns(a),a.alternate===null)throw Error(i(340));So()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 13:if(ns(a),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(i(340));So()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return it(Ln),null;case 4:return Gt(),null;case 10:return zr(a.type),null;case 22:case 23:return ns(a),dg(),s!==null&&it(To),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 24:return zr(Pn),null;case 25:return null;default:return null}}function RS(s,a){switch(Jm(a),a.tag){case 3:zr(Pn),Gt();break;case 26:case 27:case 5:Ke(a);break;case 4:Gt();break;case 31:a.memoizedState!==null&&ns(a);break;case 13:ns(a);break;case 19:it(Ln);break;case 10:zr(a.type);break;case 22:case 23:ns(a),dg(),s!==null&&it(To);break;case 24:zr(Pn)}}function ju(s,a){try{var l=a.updateQueue,f=l!==null?l.lastEffect:null;if(f!==null){var g=f.next;l=g;do{if((l.tag&s)===s){f=void 0;var v=l.create,b=l.inst;f=v(),b.destroy=f}l=l.next}while(l!==g)}}catch(L){Qe(a,a.return,L)}}function Aa(s,a,l){try{var f=a.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&s)===s){var b=f.inst,L=b.destroy;if(L!==void 0){b.destroy=void 0,g=a;var V=l,nt=L;try{nt()}catch(ht){Qe(g,V,ht)}}}f=f.next}while(f!==v)}}catch(ht){Qe(a,a.return,ht)}}function CS(s){var a=s.updateQueue;if(a!==null){var l=s.stateNode;try{y2(a,l)}catch(f){Qe(s,s.return,f)}}}function DS(s,a,l){l.props=Co(s.type,s.memoizedProps),l.state=s.memoizedState;try{l.componentWillUnmount()}catch(f){Qe(s,a,f)}}function Xu(s,a){try{var l=s.ref;if(l!==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 l=="function"?s.refCleanup=l(f):l.current=f}}catch(g){Qe(s,a,g)}}function hr(s,a){var l=s.ref,f=s.refCleanup;if(l!==null)if(typeof f=="function")try{f()}catch(g){Qe(s,a,g)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(g){Qe(s,a,g)}else l.current=null}function LS(s){var a=s.type,l=s.memoizedProps,f=s.stateNode;try{t:switch(a){case"button":case"input":case"select":case"textarea":l.autoFocus&&f.focus();break t;case"img":l.src?f.src=l.src:l.srcSet&&(f.srcset=l.srcSet)}}catch(g){Qe(s,s.return,g)}}function jg(s,a,l){try{var f=s.stateNode;oL(f,s.type,l,a),f[ci]=a}catch(g){Qe(s,s.return,g)}}function NS(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Ua(s.type)||s.tag===4}function Xg(s){t:for(;;){for(;s.sibling===null;){if(s.return===null||NS(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&&Ua(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 qg(s,a,l){var f=s.tag;if(f===5||f===6)s=s.stateNode,a?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(s,a):(a=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,a.appendChild(s),l=l._reactRootContainer,l!=null||a.onclick!==null||(a.onclick=Or));else if(f!==4&&(f===27&&Ua(s.type)&&(l=s.stateNode,a=null),s=s.child,s!==null))for(qg(s,a,l),s=s.sibling;s!==null;)qg(s,a,l),s=s.sibling}function Zh(s,a,l){var f=s.tag;if(f===5||f===6)s=s.stateNode,a?l.insertBefore(s,a):l.appendChild(s);else if(f!==4&&(f===27&&Ua(s.type)&&(l=s.stateNode),s=s.child,s!==null))for(Zh(s,a,l),s=s.sibling;s!==null;)Zh(s,a,l),s=s.sibling}function US(s){var a=s.stateNode,l=s.memoizedProps;try{for(var f=s.type,g=a.attributes;g.length;)a.removeAttributeNode(g[0]);pi(a,f,l),a[Tn]=s,a[ci]=l}catch(v){Qe(s,s.return,v)}}var jr=!1,Bn=!1,Yg=!1,PS=typeof WeakSet=="function"?WeakSet:Set,ii=null;function zD(s,a){if(s=s.containerInfo,m0=_d,s=Xx(s),Vm(s)){if("selectionStart"in s)var l={start:s.selectionStart,end:s.selectionEnd};else t:{l=(l=s.ownerDocument)&&l.defaultView||window;var f=l.getSelection&&l.getSelection();if(f&&f.rangeCount!==0){l=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break t}var b=0,L=-1,V=-1,nt=0,ht=0,vt=s,st=null;e:for(;;){for(var lt;vt!==l||g!==0&&vt.nodeType!==3||(L=b+g),vt!==v||f!==0&&vt.nodeType!==3||(V=b+f),vt.nodeType===3&&(b+=vt.nodeValue.length),(lt=vt.firstChild)!==null;)st=vt,vt=lt;for(;;){if(vt===s)break e;if(st===l&&++nt===g&&(L=b),st===v&&++ht===f&&(V=b),(lt=vt.nextSibling)!==null)break;vt=st,st=vt.parentNode}vt=lt}l=L===-1||V===-1?null:{start:L,end:V}}else l=null}l=l||{start:0,end:0}}else l=null;for(g0={focusedElem:s,selectionRange:l},_d=!1,ii=a;ii!==null;)if(a=ii,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,ii=s;else for(;ii!==null;){switch(a=ii,v=a.alternate,s=a.flags,a.tag){case 0:if((s&4)!==0&&(s=a.updateQueue,s=s!==null?s.events:null,s!==null))for(l=0;l title"))),pi(v,f,l),v[Tn]=s,X(v),f=v;break t;case"link":var b=zM("link","href",g).get(f+(l.href||""));if(b){for(var L=0;Lsn&&(b=sn,sn=re,re=b);var Z=Wx(L,re),W=Wx(L,sn);if(Z&&W&&(lt.rangeCount!==1||lt.anchorNode!==Z.node||lt.anchorOffset!==Z.offset||lt.focusNode!==W.node||lt.focusOffset!==W.offset)){var et=vt.createRange();et.setStart(Z.node,Z.offset),lt.removeAllRanges(),re>sn?(lt.addRange(et),lt.extend(W.node,W.offset)):(et.setEnd(W.node,W.offset),lt.addRange(et))}}}}for(vt=[],lt=L;lt=lt.parentNode;)lt.nodeType===1&&vt.push({element:lt,left:lt.scrollLeft,top:lt.scrollTop});for(typeof L.focus=="function"&&L.focus(),L=0;Ll?32:l,k.T=null,l=e0,e0=null;var v=Da,b=Zr;if(qn=0,Vl=Da=null,Zr=0,(We&6)!==0)throw Error(i(331));var L=We;if(We|=4,jS(v.current),HS(v,v.current,b,l),We=L,Ju(0,!1),qt&&typeof qt.onPostCommitFiberRoot=="function")try{qt.onPostCommitFiberRoot(te,v)}catch{}return!0}finally{Q.p=g,k.T=f,cM(s,a)}}function fM(s,a,l){a=Ms(l,a),a=Pg(s.stateNode,a,2),s=ba(s,a,2),s!==null&&(li(s,2),dr(s))}function Qe(s,a,l){if(s.tag===3)fM(s,s,l);else for(;a!==null;){if(a.tag===3){fM(a,s,l);break}else if(a.tag===1){var f=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(Ca===null||!Ca.has(f))){s=Ms(l,s),l=hS(2),f=ba(a,l,2),f!==null&&(dS(l,f,a,s),li(f,2),dr(f));break}}a=a.return}}function r0(s,a,l){var f=s.pingCache;if(f===null){f=s.pingCache=new GD;var g=new Set;f.set(a,g)}else g=f.get(a),g===void 0&&(g=new Set,f.set(a,g));g.has(l)||(Qg=!0,g.add(l),s=YD.bind(null,s,a,l),a.then(s,s))}function YD(s,a,l){var f=s.pingCache;f!==null&&f.delete(a),s.pingedLanes|=s.suspendedLanes&l,s.warmLanes&=~l,on===s&&(Ce&l)===l&&(wn===4||wn===3&&(Ce&62914560)===Ce&&300>ut()-$h?(We&2)===0&&Hl(s,0):Jg|=l,zl===Ce&&(zl=0)),dr(s)}function hM(s,a){a===0&&(a=jn()),s=yo(s,a),s!==null&&(li(s,a),dr(s))}function KD(s){var a=s.memoizedState,l=0;a!==null&&(l=a.retryLane),hM(s,l)}function ZD(s,a){var l=0;switch(s.tag){case 31:case 13:var f=s.stateNode,g=s.memoizedState;g!==null&&(l=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(a),hM(s,l)}function QD(s,a){return Et(s,a)}var ad=null,Wl=null,a0=!1,od=!1,o0=!1,Na=0;function dr(s){s!==Wl&&s.next===null&&(Wl===null?ad=Wl=s:Wl=Wl.next=s),od=!0,a0||(a0=!0,$D())}function Ju(s,a){if(!o0&&od){o0=!0;do for(var l=!1,f=ad;f!==null;){if(s!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var b=f.suspendedLanes,L=f.pingedLanes;v=(1<<31-oe(42|s)+1)-1,v&=g&~(b&~L),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(l=!0,gM(f,v))}else v=Ce,v=Pt(f,f===on?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||le(f,v)||(l=!0,gM(f,v));f=f.next}while(l);o0=!1}}function JD(){dM()}function dM(){od=a0=!1;var s=0;Na!==0&&cL()&&(s=Na);for(var a=ut(),l=null,f=ad;f!==null;){var g=f.next,v=pM(f,a);v===0?(f.next=null,l===null?ad=g:l.next=g,g===null&&(Wl=l)):(l=f,(s!==0||(v&3)!==0)&&(od=!0)),f=g}qn!==0&&qn!==5||Ju(s),Na!==0&&(Na=0)}function pM(s,a){for(var l=s.suspendedLanes,f=s.pingedLanes,g=s.expirationTimes,v=s.pendingLanes&-62914561;0L)break;var ht=V.transferSize,vt=V.initiatorType;ht&&TM(vt)&&(V=V.responseEnd,b+=ht*(V"u"?null:document;function IM(s,a,l){var f=jl;if(f&&typeof a=="string"&&a){var g=ni(a);g='link[rel="'+s+'"][href="'+g+'"]',typeof l=="string"&&(g+='[crossorigin="'+l+'"]'),OM.has(g)||(OM.add(g),s={rel:s,crossOrigin:l,href:a},f.querySelector(g)===null&&(a=f.createElement("link"),pi(a,"link",s),X(a),f.head.appendChild(a)))}}function vL(s){Qr.D(s),IM("dns-prefetch",s,null)}function yL(s,a){Qr.C(s,a),IM("preconnect",s,a)}function xL(s,a,l){Qr.L(s,a,l);var f=jl;if(f&&s&&a){var g='link[rel="preload"][as="'+ni(a)+'"]';a==="image"&&l&&l.imageSrcSet?(g+='[imagesrcset="'+ni(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(g+='[imagesizes="'+ni(l.imageSizes)+'"]')):g+='[href="'+ni(s)+'"]';var v=g;switch(a){case"style":v=Xl(s);break;case"script":v=ql(s)}Rs.has(v)||(s=m({rel:"preload",href:a==="image"&&l&&l.imageSrcSet?void 0:s,as:a},l),Rs.set(v,s),f.querySelector(g)!==null||a==="style"&&f.querySelector(nf(v))||a==="script"&&f.querySelector(sf(v))||(a=f.createElement("link"),pi(a,"link",s),X(a),f.head.appendChild(a)))}}function SL(s,a){Qr.m(s,a);var l=jl;if(l&&s){var f=a&&typeof a.as=="string"?a.as:"script",g='link[rel="modulepreload"][as="'+ni(f)+'"][href="'+ni(s)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=ql(s)}if(!Rs.has(v)&&(s=m({rel:"modulepreload",href:s},a),Rs.set(v,s),l.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(sf(v)))return}f=l.createElement("link"),pi(f,"link",s),X(f),l.head.appendChild(f)}}}function ML(s,a,l){Qr.S(s,a,l);var f=jl;if(f&&s){var g=at(f).hoistableStyles,v=Xl(s);a=a||"default";var b=g.get(v);if(!b){var L={loading:0,preload:null};if(b=f.querySelector(nf(v)))L.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":a},l),(l=Rs.get(v))&&b0(s,l);var V=b=f.createElement("link");X(V),pi(V,"link",s),V._p=new Promise(function(nt,ht){V.onload=nt,V.onerror=ht}),V.addEventListener("load",function(){L.loading|=1}),V.addEventListener("error",function(){L.loading|=2}),L.loading|=4,hd(b,a,f)}b={type:"stylesheet",instance:b,count:1,state:L},g.set(v,b)}}}function bL(s,a){Qr.X(s,a);var l=jl;if(l&&s){var f=at(l).hoistableScripts,g=ql(s),v=f.get(g);v||(v=l.querySelector(sf(g)),v||(s=m({src:s,async:!0},a),(a=Rs.get(g))&&T0(s,a),v=l.createElement("script"),X(v),pi(v,"link",s),l.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function TL(s,a){Qr.M(s,a);var l=jl;if(l&&s){var f=at(l).hoistableScripts,g=ql(s),v=f.get(g);v||(v=l.querySelector(sf(g)),v||(s=m({src:s,async:!0,type:"module"},a),(a=Rs.get(g))&&T0(s,a),v=l.createElement("script"),X(v),pi(v,"link",s),l.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function BM(s,a,l,f){var g=(g=At.current)?fd(g):null;if(!g)throw Error(i(446));switch(s){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(a=Xl(l.href),l=at(g).hoistableStyles,f=l.get(a),f||(f={type:"style",instance:null,count:0,state:null},l.set(a,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){s=Xl(l.href);var v=at(g).hoistableStyles,b=v.get(s);if(b||(g=g.ownerDocument||g,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(s,b),(v=g.querySelector(nf(s)))&&!v._p&&(b.instance=v,b.state.loading=5),Rs.has(s)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Rs.set(s,l),v||EL(g,s,l,b.state))),a&&f===null)throw Error(i(528,""));return b}if(a&&f!==null)throw Error(i(529,""));return null;case"script":return a=l.async,l=l.src,typeof l=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=ql(l),l=at(g).hoistableScripts,f=l.get(a),f||(f={type:"script",instance:null,count:0,state:null},l.set(a,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,s))}}function Xl(s){return'href="'+ni(s)+'"'}function nf(s){return'link[rel="stylesheet"]['+s+"]"}function FM(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function EL(s,a,l,f){s.querySelector('link[rel="preload"][as="style"]['+a+"]")?f.loading=1:(a=s.createElement("link"),f.preload=a,a.addEventListener("load",function(){return f.loading|=1}),a.addEventListener("error",function(){return f.loading|=2}),pi(a,"link",l),X(a),s.head.appendChild(a))}function ql(s){return'[src="'+ni(s)+'"]'}function sf(s){return"script[async]"+s}function kM(s,a,l){if(a.count++,a.instance===null)switch(a.type){case"style":var f=s.querySelector('style[data-href~="'+ni(l.href)+'"]');if(f)return a.instance=f,X(f),f;var g=m({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return f=(s.ownerDocument||s).createElement("style"),X(f),pi(f,"style",g),hd(f,l.precedence,s),a.instance=f;case"stylesheet":g=Xl(l.href);var v=s.querySelector(nf(g));if(v)return a.state.loading|=4,a.instance=v,X(v),v;f=FM(l),(g=Rs.get(g))&&b0(f,g),v=(s.ownerDocument||s).createElement("link"),X(v);var b=v;return b._p=new Promise(function(L,V){b.onload=L,b.onerror=V}),pi(v,"link",f),a.state.loading|=4,hd(v,l.precedence,s),a.instance=v;case"script":return v=ql(l.src),(g=s.querySelector(sf(v)))?(a.instance=g,X(g),g):(f=l,(g=Rs.get(v))&&(f=m({},l),T0(f,g)),s=s.ownerDocument||s,g=s.createElement("script"),X(g),pi(g,"link",f),s.head.appendChild(g),a.instance=g);case"void":return null;default:throw Error(i(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(f=a.instance,a.state.loading|=4,hd(f,l.precedence,s));return a.instance}function hd(s,a,l){for(var f=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,b=0;b title"):null)}function AL(s,a,l){if(l===1||a.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;switch(a.rel){case"stylesheet":return s=a.disabled,typeof a.precedence=="string"&&s==null;default:return!0}case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function HM(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function wL(s,a,l,f){if(l.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var g=Xl(f.href),v=a.querySelector(nf(g));if(v){a=v._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(s.count++,s=pd.bind(s),a.then(s,s)),l.state.loading|=4,l.instance=v,X(v);return}v=a.ownerDocument||a,f=FM(f),(g=Rs.get(g))&&b0(f,g),v=v.createElement("link"),X(v);var b=v;b._p=new Promise(function(L,V){b.onload=L,b.onerror=V}),pi(v,"link",f),l.instance=v}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(l,a),(a=l.state.preload)&&(l.state.loading&3)===0&&(s.count++,l=pd.bind(s),a.addEventListener("load",l),a.addEventListener("error",l))}}var E0=0;function RL(s,a){return s.stylesheets&&s.count===0&&gd(s,s.stylesheets),0E0?50:800)+a);return s.unsuspend=l,function(){s.unsuspend=null,clearTimeout(f),clearTimeout(g)}}:null}function pd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)gd(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var md=null;function gd(s,a){s.stylesheets=null,s.unsuspend!==null&&(s.count++,md=new Map,a.forEach(CL,s),md=null,pd.call(s))}function CL(s,a){if(!(a.state.loading&4)){var l=md.get(s);if(l)var f=l.get(null);else{l=new Map,md.set(s,l);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(),P0.exports=jL(),P0.exports}var qL=XL();/** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */const w1="174",YL=0,hb=1,KL=2,t3=1,ZL=2,sa=3,ua=0,Zi=1,Ps=2,no=0,Sc=1,Df=2,db=3,pb=4,QL=5,jo=100,JL=101,$L=102,t5=103,e5=104,n5=200,i5=201,s5=202,r5=203,q_=204,Y_=205,a5=206,o5=207,l5=208,c5=209,u5=210,f5=211,h5=212,d5=213,p5=214,K_=0,Z_=1,Q_=2,wc=3,J_=4,$_=5,tv=6,ev=7,e3=0,m5=1,g5=2,io=0,_5=1,v5=2,y5=3,x5=4,S5=5,M5=6,b5=7,mb="attached",T5="detached",n3=300,Rc=301,Cc=302,nv=303,iv=304,qp=306,Dc=1e3,$a=1001,Ep=1002,Oi=1003,i3=1004,Tf=1005,hs=1006,lp=1007,oa=1008,fa=1009,s3=1010,r3=1011,Vf=1012,R1=1013,al=1014,tr=1015,th=1016,C1=1017,D1=1018,Lc=1020,a3=35902,o3=1021,l3=1022,Os=1023,c3=1024,u3=1025,Mc=1026,Nc=1027,L1=1028,N1=1029,f3=1030,U1=1031,P1=1033,cp=33776,up=33777,fp=33778,hp=33779,sv=35840,rv=35841,av=35842,ov=35843,lv=36196,cv=37492,uv=37496,fv=37808,hv=37809,dv=37810,pv=37811,mv=37812,gv=37813,_v=37814,vv=37815,yv=37816,xv=37817,Sv=37818,Mv=37819,bv=37820,Tv=37821,dp=36492,Ev=36494,Av=36495,h3=36283,wv=36284,Rv=36285,Cv=36286,Ef=2200,E5=2201,A5=2202,Hf=2300,Gf=2301,F0=2302,pc=2400,mc=2401,Ap=2402,O1=2500,w5=2501,R5=0,d3=1,Dv=2,C5=3200,D5=3201,p3=0,L5=1,Qa="",oi="srgb",Bi="srgb-linear",wp="linear",rn="srgb",Kl=7680,gb=519,N5=512,U5=513,P5=514,m3=515,O5=516,I5=517,B5=518,F5=519,Lv=35044,_b="300 es",la=2e3,Rp=2001;class hl{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 r=i[t];if(r!==void 0){const o=r.indexOf(n);o!==-1&&r.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 r=i.slice(0);for(let o=0,c=r.length;o>8&255]+xi[e>>16&255]+xi[e>>24&255]+"-"+xi[t&255]+xi[t>>8&255]+"-"+xi[t>>16&15|64]+xi[t>>24&255]+"-"+xi[n&63|128]+xi[n>>8&255]+"-"+xi[n>>16&255]+xi[n>>24&255]+xi[i&255]+xi[i>>8&255]+xi[i>>16&255]+xi[i>>24&255]).toLowerCase()}function we(e,t,n){return Math.max(t,Math.min(n,e))}function I1(e,t){return(e%t+t)%t}function k5(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function z5(e,t,n){return e!==t?(n-e)/(t-e):0}function Nf(e,t,n){return(1-n)*e+n*t}function V5(e,t,n,i){return Nf(e,t,1-Math.exp(-n*i))}function H5(e,t=1){return t-Math.abs(I1(e,t*2)-t)}function G5(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function W5(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function j5(e,t){return e+Math.floor(Math.random()*(t-e+1))}function X5(e,t){return e+Math.random()*(t-e)}function q5(e){return e*(.5-Math.random())}function Y5(e){e!==void 0&&(vb=e);let t=vb+=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 K5(e){return e*Lf}function Z5(e){return e*Uc}function Q5(e){return(e&e-1)===0&&e!==0}function J5(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function $5(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function tN(e,t,n,i,r){const o=Math.cos,c=Math.sin,u=o(n/2),h=c(n/2),d=o((t+i)/2),p=c((t+i)/2),m=o((t-i)/2),_=c((t-i)/2),y=o((i-t)/2),M=c((i-t)/2);switch(r){case"XYX":e.set(u*p,h*m,h*_,u*d);break;case"YZY":e.set(h*_,u*p,h*m,u*d);break;case"ZXZ":e.set(h*m,h*_,u*p,u*d);break;case"XZX":e.set(u*p,h*M,h*y,u*d);break;case"YXY":e.set(h*y,u*p,h*M,u*d);break;case"ZYZ":e.set(h*M,h*y,u*p,u*d);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Js(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 Je(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 gr={DEG2RAD:Lf,RAD2DEG:Uc,generateUUID:er,clamp:we,euclideanModulo:I1,mapLinear:k5,inverseLerp:z5,lerp:Nf,damp:V5,pingpong:H5,smoothstep:G5,smootherstep:W5,randInt:j5,randFloat:X5,randFloatSpread:q5,seededRandom:Y5,degToRad:K5,radToDeg:Z5,isPowerOfTwo:Q5,ceilPowerOfTwo:J5,floorPowerOfTwo:$5,setQuaternionFromProperEuler:tN,normalize:Je,denormalize:Js};class Te{constructor(t=0,n=0){Te.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,r=t.elements;return this.x=r[0]*n+r[3]*i+r[6],this.y=r[1]*n+r[4]*i+r[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=we(this.x,t.x,n.x),this.y=we(this.y,t.y,n.y),this}clampScalar(t,n){return this.x=we(this.x,t,n),this.y=we(this.y,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(we(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(we(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),r=Math.sin(n),o=this.x-t.x,c=this.y-t.y;return this.x=o*i-c*r+t.x,this.y=o*r+c*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class _e{constructor(t,n,i,r,o,c,u,h,d){_e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,i,r,o,c,u,h,d)}set(t,n,i,r,o,c,u,h,d){const p=this.elements;return p[0]=t,p[1]=r,p[2]=u,p[3]=n,p[4]=o,p[5]=h,p[6]=i,p[7]=c,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,r=n.elements,o=this.elements,c=i[0],u=i[3],h=i[6],d=i[1],p=i[4],m=i[7],_=i[2],y=i[5],M=i[8],T=r[0],S=r[3],x=r[6],R=r[1],w=r[4],E=r[7],P=r[2],I=r[5],U=r[8];return o[0]=c*T+u*R+h*P,o[3]=c*S+u*w+h*I,o[6]=c*x+u*E+h*U,o[1]=d*T+p*R+m*P,o[4]=d*S+p*w+m*I,o[7]=d*x+p*E+m*U,o[2]=_*T+y*R+M*P,o[5]=_*S+y*w+M*I,o[8]=_*x+y*E+M*U,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],r=t[2],o=t[3],c=t[4],u=t[5],h=t[6],d=t[7],p=t[8];return n*c*p-n*u*d-i*o*p+i*u*h+r*o*d-r*c*h}invert(){const t=this.elements,n=t[0],i=t[1],r=t[2],o=t[3],c=t[4],u=t[5],h=t[6],d=t[7],p=t[8],m=p*c-u*d,_=u*h-p*o,y=d*o-c*h,M=n*m+i*_+r*y;if(M===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/M;return t[0]=m*T,t[1]=(r*d-p*i)*T,t[2]=(u*i-r*c)*T,t[3]=_*T,t[4]=(p*n-r*h)*T,t[5]=(r*o-u*n)*T,t[6]=y*T,t[7]=(i*h-d*n)*T,t[8]=(c*n-i*o)*T,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,r,o,c,u){const h=Math.cos(o),d=Math.sin(o);return this.set(i*h,i*d,-i*(h*c+d*u)+c+t,-r*d,r*h,-r*(-d*c+h*u)+u+n,0,0,1),this}scale(t,n){return this.premultiply(k0.makeScale(t,n)),this}rotate(t){return this.premultiply(k0.makeRotation(-t)),this}translate(t,n){return this.premultiply(k0.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 r=0;r<9;r++)if(n[r]!==i[r])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 k0=new _e;function g3(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Wf(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function eN(){const e=Wf("canvas");return e.style.display="block",e}const yb={};function Vo(e){e in yb||(yb[e]=!0,console.warn(e))}function nN(e,t,n){return new Promise(function(i,r){function o(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(o,n);break;default:i()}}setTimeout(o,n)})}function iN(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 sN(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 xb=new _e().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Sb=new _e().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rN(){const e={enabled:!0,workingColorSpace:Bi,spaces:{},convert:function(r,o,c){return this.enabled===!1||o===c||!o||!c||(this.spaces[o].transfer===rn&&(r.r=ca(r.r),r.g=ca(r.g),r.b=ca(r.b)),this.spaces[o].primaries!==this.spaces[c].primaries&&(r.applyMatrix3(this.spaces[o].toXYZ),r.applyMatrix3(this.spaces[c].fromXYZ)),this.spaces[c].transfer===rn&&(r.r=bc(r.r),r.g=bc(r.g),r.b=bc(r.b))),r},fromWorkingColorSpace:function(r,o){return this.convert(r,this.workingColorSpace,o)},toWorkingColorSpace:function(r,o){return this.convert(r,o,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Qa?wp:this.spaces[r].transfer},getLuminanceCoefficients:function(r,o=this.workingColorSpace){return r.fromArray(this.spaces[o].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,o,c){return r.copy(this.spaces[o].toXYZ).multiply(this.spaces[c].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return e.define({[Bi]:{primaries:t,whitePoint:i,transfer:wp,toXYZ:xb,fromXYZ:Sb,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:oi},outputColorSpaceConfig:{drawingBufferColorSpace:oi}},[oi]:{primaries:t,whitePoint:i,transfer:rn,toXYZ:xb,fromXYZ:Sb,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:oi}}}),e}const Oe=rN();function ca(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function bc(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}let Zl;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{Zl===void 0&&(Zl=Wf("canvas")),Zl.width=t.width,Zl.height=t.height;const i=Zl.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=Zl}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=Wf("canvas");n.width=t.width,n.height=t.height;const i=n.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const r=i.getImageData(0,0,t.width,t.height),o=r.data;for(let c=0;c0&&(i.userData=this.userData),n||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==n3)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Dc:t.x=t.x-Math.floor(t.x);break;case $a:t.x=t.x<0?0:1;break;case Ep: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 Dc:t.y=t.y-Math.floor(t.y);break;case $a:t.y=t.y<0?0:1;break;case Ep: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++}}Zn.DEFAULT_IMAGE=null;Zn.DEFAULT_MAPPING=n3;Zn.DEFAULT_ANISOTROPY=1;class Xe{constructor(t=0,n=0,i=0,r=1){Xe.prototype.isVector4=!0,this.x=t,this.y=n,this.z=i,this.w=r}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,r){return this.x=t,this.y=n,this.z=i,this.w=r,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,r=this.z,o=this.w,c=t.elements;return this.x=c[0]*n+c[4]*i+c[8]*r+c[12]*o,this.y=c[1]*n+c[5]*i+c[9]*r+c[13]*o,this.z=c[2]*n+c[6]*i+c[10]*r+c[14]*o,this.w=c[3]*n+c[7]*i+c[11]*r+c[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,r,o;const h=t.elements,d=h[0],p=h[4],m=h[8],_=h[1],y=h[5],M=h[9],T=h[2],S=h[6],x=h[10];if(Math.abs(p-_)<.01&&Math.abs(m-T)<.01&&Math.abs(M-S)<.01){if(Math.abs(p+_)<.1&&Math.abs(m+T)<.1&&Math.abs(M+S)<.1&&Math.abs(d+y+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(d+1)/2,E=(y+1)/2,P=(x+1)/2,I=(p+_)/4,U=(m+T)/4,B=(M+S)/4;return w>E&&w>P?w<.01?(i=0,r=.707106781,o=.707106781):(i=Math.sqrt(w),r=I/i,o=U/i):E>P?E<.01?(i=.707106781,r=0,o=.707106781):(r=Math.sqrt(E),i=I/r,o=B/r):P<.01?(i=.707106781,r=.707106781,o=0):(o=Math.sqrt(P),i=U/o,r=B/o),this.set(i,r,o,n),this}let R=Math.sqrt((S-M)*(S-M)+(m-T)*(m-T)+(_-p)*(_-p));return Math.abs(R)<.001&&(R=1),this.x=(S-M)/R,this.y=(m-T)/R,this.z=(_-p)/R,this.w=Math.acos((d+y+x-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=we(this.x,t.x,n.x),this.y=we(this.y,t.y,n.y),this.z=we(this.z,t.z,n.z),this.w=we(this.w,t.w,n.w),this}clampScalar(t,n){return this.x=we(this.x,t,n),this.y=we(this.y,t,n),this.z=we(this.z,t,n),this.w=we(this.w,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(we(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 cN extends hl{constructor(t=1,n=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=n,this.depth=1,this.scissor=new Xe(0,0,t,n),this.scissorTest=!1,this.viewport=new Xe(0,0,t,n);const r={width:t,height:n,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:hs,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const o=new Zn(r,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 c=i.count;for(let u=0;u=0?1:-1,w=1-x*x;if(w>Number.EPSILON){const P=Math.sqrt(w),I=Math.atan2(P,x*R);S=Math.sin(S*I)/P,u=Math.sin(u*I)/P}const E=u*R;if(h=h*S+_*E,d=d*S+y*E,p=p*S+M*E,m=m*S+T*E,S===1-u){const P=1/Math.sqrt(h*h+d*d+p*p+m*m);h*=P,d*=P,p*=P,m*=P}}t[n]=h,t[n+1]=d,t[n+2]=p,t[n+3]=m}static multiplyQuaternionsFlat(t,n,i,r,o,c){const u=i[r],h=i[r+1],d=i[r+2],p=i[r+3],m=o[c],_=o[c+1],y=o[c+2],M=o[c+3];return t[n]=u*M+p*m+h*y-d*_,t[n+1]=h*M+p*_+d*m-u*y,t[n+2]=d*M+p*y+u*_-h*m,t[n+3]=p*M-u*m-h*_-d*y,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,r){return this._x=t,this._y=n,this._z=i,this._w=r,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,r=t._y,o=t._z,c=t._order,u=Math.cos,h=Math.sin,d=u(i/2),p=u(r/2),m=u(o/2),_=h(i/2),y=h(r/2),M=h(o/2);switch(c){case"XYZ":this._x=_*p*m+d*y*M,this._y=d*y*m-_*p*M,this._z=d*p*M+_*y*m,this._w=d*p*m-_*y*M;break;case"YXZ":this._x=_*p*m+d*y*M,this._y=d*y*m-_*p*M,this._z=d*p*M-_*y*m,this._w=d*p*m+_*y*M;break;case"ZXY":this._x=_*p*m-d*y*M,this._y=d*y*m+_*p*M,this._z=d*p*M+_*y*m,this._w=d*p*m-_*y*M;break;case"ZYX":this._x=_*p*m-d*y*M,this._y=d*y*m+_*p*M,this._z=d*p*M-_*y*m,this._w=d*p*m+_*y*M;break;case"YZX":this._x=_*p*m+d*y*M,this._y=d*y*m+_*p*M,this._z=d*p*M-_*y*m,this._w=d*p*m-_*y*M;break;case"XZY":this._x=_*p*m-d*y*M,this._y=d*y*m-_*p*M,this._z=d*p*M+_*y*m,this._w=d*p*m+_*y*M;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const i=n/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,i=n[0],r=n[4],o=n[8],c=n[1],u=n[5],h=n[9],d=n[2],p=n[6],m=n[10],_=i+u+m;if(_>0){const y=.5/Math.sqrt(_+1);this._w=.25/y,this._x=(p-h)*y,this._y=(o-d)*y,this._z=(c-r)*y}else if(i>u&&i>m){const y=2*Math.sqrt(1+i-u-m);this._w=(p-h)/y,this._x=.25*y,this._y=(r+c)/y,this._z=(o+d)/y}else if(u>m){const y=2*Math.sqrt(1+u-i-m);this._w=(o-d)/y,this._x=(r+c)/y,this._y=.25*y,this._z=(h+p)/y}else{const y=2*Math.sqrt(1+m-i-u);this._w=(c-r)/y,this._x=(o+d)/y,this._y=(h+p)/y,this._z=.25*y}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(we(this.dot(t),-1,1)))}rotateTowards(t,n){const i=this.angleTo(t);if(i===0)return this;const r=Math.min(1,n/i);return this.slerp(t,r),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,r=t._y,o=t._z,c=t._w,u=n._x,h=n._y,d=n._z,p=n._w;return this._x=i*p+c*u+r*d-o*h,this._y=r*p+c*h+o*u-i*d,this._z=o*p+c*d+i*h-r*u,this._w=c*p-i*u-r*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,r=this._y,o=this._z,c=this._w;let u=c*t._w+i*t._x+r*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=c,this._x=i,this._y=r,this._z=o,this;const h=1-u*u;if(h<=Number.EPSILON){const y=1-n;return this._w=y*c+n*this._w,this._x=y*i+n*this._x,this._y=y*r+n*this._y,this._z=y*o+n*this._z,this.normalize(),this}const d=Math.sqrt(h),p=Math.atan2(d,u),m=Math.sin((1-n)*p)/d,_=Math.sin(n*p)/d;return this._w=c*m+this._w*_,this._x=i*m+this._x*_,this._y=r*m+this._y*_,this._z=o*m+this._z*_,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(),r=Math.sqrt(1-i),o=Math.sqrt(i);return this.set(r*Math.sin(t),r*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(Mb.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(Mb.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,i=this.y,r=this.z,o=t.elements;return this.x=o[0]*n+o[3]*i+o[6]*r,this.y=o[1]*n+o[4]*i+o[7]*r,this.z=o[2]*n+o[5]*i+o[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,i=this.y,r=this.z,o=t.elements,c=1/(o[3]*n+o[7]*i+o[11]*r+o[15]);return this.x=(o[0]*n+o[4]*i+o[8]*r+o[12])*c,this.y=(o[1]*n+o[5]*i+o[9]*r+o[13])*c,this.z=(o[2]*n+o[6]*i+o[10]*r+o[14])*c,this}applyQuaternion(t){const n=this.x,i=this.y,r=this.z,o=t.x,c=t.y,u=t.z,h=t.w,d=2*(c*r-u*i),p=2*(u*n-o*r),m=2*(o*i-c*n);return this.x=n+h*d+c*m-u*p,this.y=i+h*p+u*d-o*m,this.z=r+h*m+o*p-c*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,r=this.z,o=t.elements;return this.x=o[0]*n+o[4]*i+o[8]*r,this.y=o[1]*n+o[5]*i+o[9]*r,this.z=o[2]*n+o[6]*i+o[10]*r,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=we(this.x,t.x,n.x),this.y=we(this.y,t.y,n.y),this.z=we(this.z,t.z,n.z),this}clampScalar(t,n){return this.x=we(this.x,t,n),this.y=we(this.y,t,n),this.z=we(this.z,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(we(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,r=t.y,o=t.z,c=n.x,u=n.y,h=n.z;return this.x=r*h-o*u,this.y=o*c-i*h,this.z=i*u-r*c,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 V0.copy(this).projectOnVector(t),this.sub(V0)}reflect(t){return this.sub(V0.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(we(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return n*n+i*i+r*r}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 r=Math.sin(n)*t;return this.x=r*Math.sin(i),this.y=Math.cos(n)*t,this.z=r*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(),r=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=i,this.z=r,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 V0=new G,Mb=new nr;class Ki{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,qs),qs.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(ff),Ed.subVectors(this.max,ff),Ql.subVectors(t.a,ff),Jl.subVectors(t.b,ff),$l.subVectors(t.c,ff),ka.subVectors(Jl,Ql),za.subVectors($l,Jl),No.subVectors(Ql,$l);let n=[0,-ka.z,ka.y,0,-za.z,za.y,0,-No.z,No.y,ka.z,0,-ka.x,za.z,0,-za.x,No.z,0,-No.x,-ka.y,ka.x,0,-za.y,za.x,0,-No.y,No.x,0];return!H0(n,Ql,Jl,$l,Ed)||(n=[1,0,0,0,1,0,0,0,1],!H0(n,Ql,Jl,$l,Ed))?!1:(Ad.crossVectors(ka,za),n=[Ad.x,Ad.y,Ad.z],H0(n,Ql,Jl,$l,Ed))}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,qs).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(qs).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:(Jr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Jr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Jr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Jr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Jr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Jr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Jr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Jr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Jr),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 Jr=[new G,new G,new G,new G,new G,new G,new G,new G],qs=new G,Td=new Ki,Ql=new G,Jl=new G,$l=new G,ka=new G,za=new G,No=new G,ff=new G,Ed=new G,Ad=new G,Uo=new G;function H0(e,t,n,i,r){for(let o=0,c=e.length-3;o<=c;o+=3){Uo.fromArray(e,o);const u=r.x*Math.abs(Uo.x)+r.y*Math.abs(Uo.y)+r.z*Math.abs(Uo.z),h=t.dot(Uo),d=n.dot(Uo),p=i.dot(Uo);if(Math.max(-Math.max(h,d,p),Math.min(h,d,p))>u)return!1}return!0}const fN=new Ki,hf=new G,G0=new G;class wr{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):fN.setFromPoints(t).getCenter(i);let r=0;for(let o=0,c=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;hf.subVectors(t,this.center);const n=hf.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),r=(i-this.radius)*.5;this.center.addScaledVector(hf,r/i),this.radius+=r}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):(G0.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(hf.copy(t.center).add(G0)),this.expandByPoint(hf.copy(t.center).sub(G0))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const $r=new G,W0=new G,wd=new G,Va=new G,j0=new G,Rd=new G,X0=new G;class Yp{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,$r)),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=$r.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):($r.copy(this.origin).addScaledVector(this.direction,n),$r.distanceToSquared(t))}distanceSqToSegment(t,n,i,r){W0.copy(t).add(n).multiplyScalar(.5),wd.copy(n).sub(t).normalize(),Va.copy(this.origin).sub(W0);const o=t.distanceTo(n)*.5,c=-this.direction.dot(wd),u=Va.dot(this.direction),h=-Va.dot(wd),d=Va.lengthSq(),p=Math.abs(1-c*c);let m,_,y,M;if(p>0)if(m=c*h-u,_=c*u-h,M=o*p,m>=0)if(_>=-M)if(_<=M){const T=1/p;m*=T,_*=T,y=m*(m+c*_+2*u)+_*(c*m+_+2*h)+d}else _=o,m=Math.max(0,-(c*_+u)),y=-m*m+_*(_+2*h)+d;else _=-o,m=Math.max(0,-(c*_+u)),y=-m*m+_*(_+2*h)+d;else _<=-M?(m=Math.max(0,-(-c*o+u)),_=m>0?-o:Math.min(Math.max(-o,-h),o),y=-m*m+_*(_+2*h)+d):_<=M?(m=0,_=Math.min(Math.max(-o,-h),o),y=_*(_+2*h)+d):(m=Math.max(0,-(c*o+u)),_=m>0?o:Math.min(Math.max(-o,-h),o),y=-m*m+_*(_+2*h)+d);else _=c>0?-o:o,m=Math.max(0,-(c*_+u)),y=-m*m+_*(_+2*h)+d;return i&&i.copy(this.origin).addScaledVector(this.direction,m),r&&r.copy(W0).addScaledVector(wd,_),y}intersectSphere(t,n){$r.subVectors(t.center,this.origin);const i=$r.dot(this.direction),r=$r.dot($r)-i*i,o=t.radius*t.radius;if(r>o)return null;const c=Math.sqrt(o-r),u=i-c,h=i+c;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,r,o,c,u,h;const d=1/this.direction.x,p=1/this.direction.y,m=1/this.direction.z,_=this.origin;return d>=0?(i=(t.min.x-_.x)*d,r=(t.max.x-_.x)*d):(i=(t.max.x-_.x)*d,r=(t.min.x-_.x)*d),p>=0?(o=(t.min.y-_.y)*p,c=(t.max.y-_.y)*p):(o=(t.max.y-_.y)*p,c=(t.min.y-_.y)*p),i>c||o>r||((o>i||isNaN(i))&&(i=o),(c=0?(u=(t.min.z-_.z)*m,h=(t.max.z-_.z)*m):(u=(t.max.z-_.z)*m,h=(t.min.z-_.z)*m),i>h||u>r)||((u>i||i!==i)&&(i=u),(h=0?i:r,n)}intersectsBox(t){return this.intersectBox(t,$r)!==null}intersectTriangle(t,n,i,r,o){j0.subVectors(n,t),Rd.subVectors(i,t),X0.crossVectors(j0,Rd);let c=this.direction.dot(X0),u;if(c>0){if(r)return null;u=1}else if(c<0)u=-1,c=-c;else return null;Va.subVectors(this.origin,t);const h=u*this.direction.dot(Rd.crossVectors(Va,Rd));if(h<0)return null;const d=u*this.direction.dot(j0.cross(Va));if(d<0||h+d>c)return null;const p=-u*Va.dot(X0);return p<0?null:this.at(p/c,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 ve{constructor(t,n,i,r,o,c,u,h,d,p,m,_,y,M,T,S){ve.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,r,o,c,u,h,d,p,m,_,y,M,T,S)}set(t,n,i,r,o,c,u,h,d,p,m,_,y,M,T,S){const x=this.elements;return x[0]=t,x[4]=n,x[8]=i,x[12]=r,x[1]=o,x[5]=c,x[9]=u,x[13]=h,x[2]=d,x[6]=p,x[10]=m,x[14]=_,x[3]=y,x[7]=M,x[11]=T,x[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 ve().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,r=1/tc.setFromMatrixColumn(t,0).length(),o=1/tc.setFromMatrixColumn(t,1).length(),c=1/tc.setFromMatrixColumn(t,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,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]*c,n[9]=i[9]*c,n[10]=i[10]*c,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,r=t.y,o=t.z,c=Math.cos(i),u=Math.sin(i),h=Math.cos(r),d=Math.sin(r),p=Math.cos(o),m=Math.sin(o);if(t.order==="XYZ"){const _=c*p,y=c*m,M=u*p,T=u*m;n[0]=h*p,n[4]=-h*m,n[8]=d,n[1]=y+M*d,n[5]=_-T*d,n[9]=-u*h,n[2]=T-_*d,n[6]=M+y*d,n[10]=c*h}else if(t.order==="YXZ"){const _=h*p,y=h*m,M=d*p,T=d*m;n[0]=_+T*u,n[4]=M*u-y,n[8]=c*d,n[1]=c*m,n[5]=c*p,n[9]=-u,n[2]=y*u-M,n[6]=T+_*u,n[10]=c*h}else if(t.order==="ZXY"){const _=h*p,y=h*m,M=d*p,T=d*m;n[0]=_-T*u,n[4]=-c*m,n[8]=M+y*u,n[1]=y+M*u,n[5]=c*p,n[9]=T-_*u,n[2]=-c*d,n[6]=u,n[10]=c*h}else if(t.order==="ZYX"){const _=c*p,y=c*m,M=u*p,T=u*m;n[0]=h*p,n[4]=M*d-y,n[8]=_*d+T,n[1]=h*m,n[5]=T*d+_,n[9]=y*d-M,n[2]=-d,n[6]=u*h,n[10]=c*h}else if(t.order==="YZX"){const _=c*h,y=c*d,M=u*h,T=u*d;n[0]=h*p,n[4]=T-_*m,n[8]=M*m+y,n[1]=m,n[5]=c*p,n[9]=-u*p,n[2]=-d*p,n[6]=y*m+M,n[10]=_-T*m}else if(t.order==="XZY"){const _=c*h,y=c*d,M=u*h,T=u*d;n[0]=h*p,n[4]=-m,n[8]=d*p,n[1]=_*m+T,n[5]=c*p,n[9]=y*m-M,n[2]=M*m-y,n[6]=u*p,n[10]=T*m+_}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(hN,t,dN)}lookAt(t,n,i){const r=this.elements;return as.subVectors(t,n),as.lengthSq()===0&&(as.z=1),as.normalize(),Ha.crossVectors(i,as),Ha.lengthSq()===0&&(Math.abs(i.z)===1?as.x+=1e-4:as.z+=1e-4,as.normalize(),Ha.crossVectors(i,as)),Ha.normalize(),Cd.crossVectors(as,Ha),r[0]=Ha.x,r[4]=Cd.x,r[8]=as.x,r[1]=Ha.y,r[5]=Cd.y,r[9]=as.y,r[2]=Ha.z,r[6]=Cd.z,r[10]=as.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const i=t.elements,r=n.elements,o=this.elements,c=i[0],u=i[4],h=i[8],d=i[12],p=i[1],m=i[5],_=i[9],y=i[13],M=i[2],T=i[6],S=i[10],x=i[14],R=i[3],w=i[7],E=i[11],P=i[15],I=r[0],U=r[4],B=r[8],D=r[12],A=r[1],F=r[5],q=r[9],tt=r[13],ot=r[2],ct=r[6],k=r[10],Q=r[14],j=r[3],pt=r[7],bt=r[11],z=r[15];return o[0]=c*I+u*A+h*ot+d*j,o[4]=c*U+u*F+h*ct+d*pt,o[8]=c*B+u*q+h*k+d*bt,o[12]=c*D+u*tt+h*Q+d*z,o[1]=p*I+m*A+_*ot+y*j,o[5]=p*U+m*F+_*ct+y*pt,o[9]=p*B+m*q+_*k+y*bt,o[13]=p*D+m*tt+_*Q+y*z,o[2]=M*I+T*A+S*ot+x*j,o[6]=M*U+T*F+S*ct+x*pt,o[10]=M*B+T*q+S*k+x*bt,o[14]=M*D+T*tt+S*Q+x*z,o[3]=R*I+w*A+E*ot+P*j,o[7]=R*U+w*F+E*ct+P*pt,o[11]=R*B+w*q+E*k+P*bt,o[15]=R*D+w*tt+E*Q+P*z,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],r=t[8],o=t[12],c=t[1],u=t[5],h=t[9],d=t[13],p=t[2],m=t[6],_=t[10],y=t[14],M=t[3],T=t[7],S=t[11],x=t[15];return M*(+o*h*m-r*d*m-o*u*_+i*d*_+r*u*y-i*h*y)+T*(+n*h*y-n*d*_+o*c*_-r*c*y+r*d*p-o*h*p)+S*(+n*d*m-n*u*y-o*c*m+i*c*y+o*u*p-i*d*p)+x*(-r*u*p-n*h*m+n*u*_+r*c*m-i*c*_+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 r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=n,r[14]=i),this}invert(){const t=this.elements,n=t[0],i=t[1],r=t[2],o=t[3],c=t[4],u=t[5],h=t[6],d=t[7],p=t[8],m=t[9],_=t[10],y=t[11],M=t[12],T=t[13],S=t[14],x=t[15],R=m*S*d-T*_*d+T*h*y-u*S*y-m*h*x+u*_*x,w=M*_*d-p*S*d-M*h*y+c*S*y+p*h*x-c*_*x,E=p*T*d-M*m*d+M*u*y-c*T*y-p*u*x+c*m*x,P=M*m*h-p*T*h-M*u*_+c*T*_+p*u*S-c*m*S,I=n*R+i*w+r*E+o*P;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const U=1/I;return t[0]=R*U,t[1]=(T*_*o-m*S*o-T*r*y+i*S*y+m*r*x-i*_*x)*U,t[2]=(u*S*o-T*h*o+T*r*d-i*S*d-u*r*x+i*h*x)*U,t[3]=(m*h*o-u*_*o-m*r*d+i*_*d+u*r*y-i*h*y)*U,t[4]=w*U,t[5]=(p*S*o-M*_*o+M*r*y-n*S*y-p*r*x+n*_*x)*U,t[6]=(M*h*o-c*S*o-M*r*d+n*S*d+c*r*x-n*h*x)*U,t[7]=(c*_*o-p*h*o+p*r*d-n*_*d-c*r*y+n*h*y)*U,t[8]=E*U,t[9]=(M*m*o-p*T*o-M*i*y+n*T*y+p*i*x-n*m*x)*U,t[10]=(c*T*o-M*u*o+M*i*d-n*T*d-c*i*x+n*u*x)*U,t[11]=(p*u*o-c*m*o-p*i*d+n*m*d+c*i*y-n*u*y)*U,t[12]=P*U,t[13]=(p*T*r-M*m*r+M*i*_-n*T*_-p*i*S+n*m*S)*U,t[14]=(M*u*r-c*T*r-M*i*h+n*T*h+c*i*S-n*u*S)*U,t[15]=(c*m*r-p*u*r+p*i*h-n*m*h-c*i*_+n*u*_)*U,this}scale(t){const n=this.elements,i=t.x,r=t.y,o=t.z;return n[0]*=i,n[4]*=r,n[8]*=o,n[1]*=i,n[5]*=r,n[9]*=o,n[2]*=i,n[6]*=r,n[10]*=o,n[3]*=i,n[7]*=r,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],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,i,r))}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),r=Math.sin(n),o=1-i,c=t.x,u=t.y,h=t.z,d=o*c,p=o*u;return this.set(d*c+i,d*u-r*h,d*h+r*u,0,d*u+r*h,p*u+i,p*h-r*c,0,d*h-r*u,p*h+r*c,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,r,o,c){return this.set(1,i,o,0,t,1,c,0,n,r,1,0,0,0,0,1),this}compose(t,n,i){const r=this.elements,o=n._x,c=n._y,u=n._z,h=n._w,d=o+o,p=c+c,m=u+u,_=o*d,y=o*p,M=o*m,T=c*p,S=c*m,x=u*m,R=h*d,w=h*p,E=h*m,P=i.x,I=i.y,U=i.z;return r[0]=(1-(T+x))*P,r[1]=(y+E)*P,r[2]=(M-w)*P,r[3]=0,r[4]=(y-E)*I,r[5]=(1-(_+x))*I,r[6]=(S+R)*I,r[7]=0,r[8]=(M+w)*U,r[9]=(S-R)*U,r[10]=(1-(_+T))*U,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,n,i){const r=this.elements;let o=tc.set(r[0],r[1],r[2]).length();const c=tc.set(r[4],r[5],r[6]).length(),u=tc.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),t.x=r[12],t.y=r[13],t.z=r[14],Ys.copy(this);const d=1/o,p=1/c,m=1/u;return Ys.elements[0]*=d,Ys.elements[1]*=d,Ys.elements[2]*=d,Ys.elements[4]*=p,Ys.elements[5]*=p,Ys.elements[6]*=p,Ys.elements[8]*=m,Ys.elements[9]*=m,Ys.elements[10]*=m,n.setFromRotationMatrix(Ys),i.x=o,i.y=c,i.z=u,this}makePerspective(t,n,i,r,o,c,u=la){const h=this.elements,d=2*o/(n-t),p=2*o/(i-r),m=(n+t)/(n-t),_=(i+r)/(i-r);let y,M;if(u===la)y=-(c+o)/(c-o),M=-2*c*o/(c-o);else if(u===Rp)y=-c/(c-o),M=-c*o/(c-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]=_,h[13]=0,h[2]=0,h[6]=0,h[10]=y,h[14]=M,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(t,n,i,r,o,c,u=la){const h=this.elements,d=1/(n-t),p=1/(i-r),m=1/(c-o),_=(n+t)*d,y=(i+r)*p;let M,T;if(u===la)M=(c+o)*m,T=-2*m;else if(u===Rp)M=o*m,T=-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]=-_,h[1]=0,h[5]=2*p,h[9]=0,h[13]=-y,h[2]=0,h[6]=0,h[10]=T,h[14]=-M,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(t){const n=this.elements,i=t.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])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 tc=new G,Ys=new ve,hN=new G(0,0,0),dN=new G(1,1,1),Ha=new G,Cd=new G,as=new G,bb=new ve,Tb=new nr;class Tr{constructor(t=0,n=0,i=0,r=Tr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=i,this._order=r}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,r=this._order){return this._x=t,this._y=n,this._z=i,this._order=r,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 r=t.elements,o=r[0],c=r[4],u=r[8],h=r[1],d=r[5],p=r[9],m=r[2],_=r[6],y=r[10];switch(n){case"XYZ":this._y=Math.asin(we(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-p,y),this._z=Math.atan2(-c,o)):(this._x=Math.atan2(_,d),this._z=0);break;case"YXZ":this._x=Math.asin(-we(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(u,y),this._z=Math.atan2(h,d)):(this._y=Math.atan2(-m,o),this._z=0);break;case"ZXY":this._x=Math.asin(we(_,-1,1)),Math.abs(_)<.9999999?(this._y=Math.atan2(-m,y),this._z=Math.atan2(-c,d)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-we(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(_,y),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-c,d));break;case"YZX":this._z=Math.asin(we(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,y));break;case"XZY":this._z=Math.asin(-we(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(_,d),this._y=Math.atan2(u,o)):(this._x=Math.atan2(-p,y),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 bb.makeRotationFromQuaternion(t),this.setFromRotationMatrix(bb,n,i)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return Tb.setFromEuler(this),this.setFromQuaternion(Tb,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}}Tr.DEFAULT_ORDER="XYZ";class v3{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&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.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()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.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?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.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){r.children=[];for(let u=0;u0){r.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),_.length>0&&(i.skeletons=_),y.length>0&&(i.animations=y),M.length>0&&(i.nodes=M)}return i.object=r,i;function c(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?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(t,n,i,r,o){Ks.subVectors(r,n),ea.subVectors(i,n),Y0.subVectors(t,n);const c=Ks.dot(Ks),u=Ks.dot(ea),h=Ks.dot(Y0),d=ea.dot(ea),p=ea.dot(Y0),m=c*d-u*u;if(m===0)return o.set(0,0,0),null;const _=1/m,y=(d*h-u*p)*_,M=(c*p-u*h)*_;return o.set(1-y-M,M,y)}static containsPoint(t,n,i,r){return this.getBarycoord(t,n,i,r,na)===null?!1:na.x>=0&&na.y>=0&&na.x+na.y<=1}static getInterpolation(t,n,i,r,o,c,u,h){return this.getBarycoord(t,n,i,r,na)===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,na.x),h.addScaledVector(c,na.y),h.addScaledVector(u,na.z),h)}static getInterpolatedAttribute(t,n,i,r,o,c){return J0.setScalar(0),$0.setScalar(0),t_.setScalar(0),J0.fromBufferAttribute(t,n),$0.fromBufferAttribute(t,i),t_.fromBufferAttribute(t,r),c.setScalar(0),c.addScaledVector(J0,o.x),c.addScaledVector($0,o.y),c.addScaledVector(t_,o.z),c}static isFrontFacing(t,n,i,r){return Ks.subVectors(i,n),ea.subVectors(t,n),Ks.cross(ea).dot(r)<0}set(t,n,i){return this.a.copy(t),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(t,n,i,r){return this.a.copy(t[n]),this.b.copy(t[i]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,n,i,r){return this.a.fromBufferAttribute(t,n),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,r),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 Ks.subVectors(this.c,this.b),ea.subVectors(this.a,this.b),Ks.cross(ea).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return $s.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return $s.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,i,r,o){return $s.getInterpolation(t,this.a,this.b,this.c,n,i,r,o)}containsPoint(t){return $s.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return $s.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,n){const i=this.a,r=this.b,o=this.c;let c,u;ic.subVectors(r,i),sc.subVectors(o,i),K0.subVectors(t,i);const h=ic.dot(K0),d=sc.dot(K0);if(h<=0&&d<=0)return n.copy(i);Z0.subVectors(t,r);const p=ic.dot(Z0),m=sc.dot(Z0);if(p>=0&&m<=p)return n.copy(r);const _=h*m-p*d;if(_<=0&&h>=0&&p<=0)return c=h/(h-p),n.copy(i).addScaledVector(ic,c);Q0.subVectors(t,o);const y=ic.dot(Q0),M=sc.dot(Q0);if(M>=0&&y<=M)return n.copy(o);const T=y*d-h*M;if(T<=0&&d>=0&&M<=0)return u=d/(d-M),n.copy(i).addScaledVector(sc,u);const S=p*M-y*m;if(S<=0&&m-p>=0&&y-M>=0)return Db.subVectors(o,r),u=(m-p)/(m-p+(y-M)),n.copy(r).addScaledVector(Db,u);const x=1/(S+T+_);return c=T*x,u=_*x,n.copy(i).addScaledVector(ic,c).addScaledVector(sc,u)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const y3={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},Ga={h:0,s:0,l:0},Ld={h:0,s:0,l:0};function e_(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 he{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 r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(t,n,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,n=oi){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Oe.toWorkingColorSpace(this,n),this}setRGB(t,n,i,r=Oe.workingColorSpace){return this.r=t,this.g=n,this.b=i,Oe.toWorkingColorSpace(this,r),this}setHSL(t,n,i,r=Oe.workingColorSpace){if(t=I1(t,1),n=we(n,0,1),i=we(i,0,1),n===0)this.r=this.g=this.b=i;else{const o=i<=.5?i*(1+n):i+n-i*n,c=2*i-o;this.r=e_(c,o,t+1/3),this.g=e_(c,o,t),this.b=e_(c,o,t-1/3)}return Oe.toWorkingColorSpace(this,r),this}setStyle(t,n=oi){function i(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){let o;const c=r[1],u=r[2];switch(c){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(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const o=r[1],c=o.length;if(c===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,n);if(c===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=oi){const i=y3[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=ca(t.r),this.g=ca(t.g),this.b=ca(t.b),this}copyLinearToSRGB(t){return this.r=bc(t.r),this.g=bc(t.g),this.b=bc(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=oi){return Oe.fromWorkingColorSpace(Si.copy(this),t),Math.round(we(Si.r*255,0,255))*65536+Math.round(we(Si.g*255,0,255))*256+Math.round(we(Si.b*255,0,255))}getHexString(t=oi){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,n=Oe.workingColorSpace){Oe.fromWorkingColorSpace(Si.copy(this),n);const i=Si.r,r=Si.g,o=Si.b,c=Math.max(i,r,o),u=Math.min(i,r,o);let h,d;const p=(u+c)/2;if(u===c)h=0,d=0;else{const m=c-u;switch(d=p<=.5?m/(c+u):m/(2-c-u),c){case i:h=(r-o)/m+(r0!=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 r=this[n];if(r===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.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!==Sc&&(i.blending=this.blending),this.side!==ua&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==q_&&(i.blendSrc=this.blendSrc),this.blendDst!==Y_&&(i.blendDst=this.blendDst),this.blendEquation!==jo&&(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!==wc&&(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!==gb&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Kl&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Kl&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Kl&&(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 r(o){const c=[];for(const u in o){const h=o[u];delete h.metadata,c.push(h)}return c}if(n){const o=r(t.textures),c=r(t.images);o.length>0&&(i.textures=o),c.length>0&&(i.images=c)}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 r=n.length;i=new Array(r);for(let o=0;o!==r;++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 Li extends Sr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new he(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 Tr,this.combine=e3,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 Fn=new G,Nd=new Te;let yN=0;class Ii{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:yN++}),this.name="",this.array=t,this.itemSize=n,this.count=t!==void 0?t.length/n:0,this.normalized=i,this.usage=Lv,this.updateRanges=[],this.gpuType=tr,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 r=0,o=this.itemSize;rn.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 Ki);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,r=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 r={};let o=!1;for(const h in this.morphAttributes){const d=this.morphAttributes[h],p=[];for(let m=0,_=d.length;m<_;m++){const y=d[m];p.push(y.toJSON(t.data))}p.length>0&&(r[h]=p,o=!0)}o&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const c=this.groups;c.length>0&&(t.data.groups=JSON.parse(JSON.stringify(c)));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 r=t.attributes;for(const d in r){const p=r[d];this.setAttribute(d,p.clone(n))}const o=t.morphAttributes;for(const d in o){const p=[],m=o[d];for(let _=0,y=m.length;_0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,c=r.length;o(t.far-t.near)**2))&&(Lb.copy(o).invert(),Po.copy(t.ray).applyMatrix4(Lb),!(i.boundingBox!==null&&Po.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,n,Po)))}_computeIntersections(t,n,i){let r;const o=this.geometry,c=this.material,u=o.index,h=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,m=o.attributes.normal,_=o.groups,y=o.drawRange;if(u!==null)if(Array.isArray(c))for(let M=0,T=_.length;Mn.far?null:{distance:d,point:Fd.clone(),object:e}}function kd(e,t,n,i,r,o,c,u,h,d){e.getVertexPosition(u,Pd),e.getVertexPosition(h,Od),e.getVertexPosition(d,Id);const p=SN(e,t,n,i,Pd,Od,Id,Ub);if(p){const m=new G;$s.getBarycoord(Ub,Pd,Od,Id,m),r&&(p.uv=$s.getInterpolatedAttribute(r,u,h,d,m,new Te)),o&&(p.uv1=$s.getInterpolatedAttribute(o,u,h,d,m,new Te)),c&&(p.normal=$s.getInterpolatedAttribute(c,u,h,d,m,new G),p.normal.dot(i.direction)>0&&p.normal.multiplyScalar(-1));const _={a:u,b:h,c:d,normal:new G,materialIndex:0};$s.getNormal(Pd,Od,Id,_.normal),p.face=_,p.barycoord=m}return p}class ll extends Qi{constructor(t=1,n=1,i=1,r=1,o=1,c=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:n,depth:i,widthSegments:r,heightSegments:o,depthSegments:c};const u=this;r=Math.floor(r),o=Math.floor(o),c=Math.floor(c);const h=[],d=[],p=[],m=[];let _=0,y=0;M("z","y","x",-1,-1,i,n,t,c,o,0),M("z","y","x",1,-1,i,n,-t,c,o,1),M("x","z","y",1,1,t,i,n,r,c,2),M("x","z","y",1,-1,t,i,-n,r,c,3),M("x","y","z",1,-1,t,n,i,r,o,4),M("x","y","z",-1,-1,t,n,-i,r,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 M(T,S,x,R,w,E,P,I,U,B,D){const A=E/U,F=P/B,q=E/2,tt=P/2,ot=I/2,ct=U+1,k=B+1;let Q=0,j=0;const pt=new G;for(let bt=0;bt0?1:-1,p.push(pt.x,pt.y,pt.z),m.push(it/U),m.push(1-bt/B),Q+=1}}for(let bt=0;bt0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(n.extensions=i),n}}class b3 extends Mn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ve,this.projectionMatrix=new ve,this.projectionMatrixInverse=new ve,this.coordinateSystem=la}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 Wa=new G,Pb=new Te,Ob=new Te;class Ni extends b3{constructor(t=50,n=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=r,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=Uc*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Lf*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Uc*2*Math.atan(Math.tan(Lf*.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){Wa.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Wa.x,Wa.y).multiplyScalar(-t/Wa.z),Wa.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Wa.x,Wa.y).multiplyScalar(-t/Wa.z)}getViewSize(t,n){return this.getViewBounds(t,Pb,Ob),n.subVectors(Ob,Pb)}setViewOffset(t,n,i,r,o,c){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=r,this.view.width=o,this.view.height=c,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let n=t*Math.tan(Lf*.5*this.fov)/this.zoom,i=2*n,r=this.aspect*i,o=-.5*r;const c=this.view;if(this.view!==null&&this.view.enabled){const h=c.fullWidth,d=c.fullHeight;o+=c.offsetX*r/h,n-=c.offsetY*i/d,r*=c.width/h,i*=c.height/d}const u=this.filmOffset;u!==0&&(o+=t*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+r,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 ac=-90,oc=1;class AN extends Mn{constructor(t,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ni(ac,oc,t,n);r.layers=this.layers,this.add(r);const o=new Ni(ac,oc,t,n);o.layers=this.layers,this.add(o);const c=new Ni(ac,oc,t,n);c.layers=this.layers,this.add(c);const u=new Ni(ac,oc,t,n);u.layers=this.layers,this.add(u);const h=new Ni(ac,oc,t,n);h.layers=this.layers,this.add(h);const d=new Ni(ac,oc,t,n);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const t=this.coordinateSystem,n=this.children.concat(),[i,r,o,c,u,h]=n;for(const d of n)this.remove(d);if(t===la)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),c.up.set(0,0,1),c.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===Rp)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),c.up.set(0,0,-1),c.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:r}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[o,c,u,h,d,p]=this.children,m=t.getRenderTarget(),_=t.getActiveCubeFace(),y=t.getActiveMipmapLevel(),M=t.xr.enabled;t.xr.enabled=!1;const T=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,r),t.render(n,o),t.setRenderTarget(i,1,r),t.render(n,c),t.setRenderTarget(i,2,r),t.render(n,u),t.setRenderTarget(i,3,r),t.render(n,h),t.setRenderTarget(i,4,r),t.render(n,d),i.texture.generateMipmaps=T,t.setRenderTarget(i,5,r),t.render(n,p),t.setRenderTarget(m,_,y),t.xr.enabled=M,i.texture.needsPMREMUpdate=!0}}class T3 extends Zn{constructor(t,n,i,r,o,c,u,h,d,p){t=t!==void 0?t:[],n=n!==void 0?n:Rc,super(t,n,i,r,o,c,u,h,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class wN extends ol{constructor(t=1,n={}){super(t,t,n),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},r=[i,i,i,i,i,i];this.texture=new T3(r,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:hs}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 ); } `},r=new ll(5,5,5),o=new ro({name:"CubemapFromEquirect",uniforms:Pc(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Zi,blending:no});o.uniforms.tEquirect.value=n;const c=new qe(r,o),u=n.minFilter;return n.minFilter===oa&&(n.minFilter=hs),new AN(1,10,this).update(t,c),n.minFilter=u,c.geometry.dispose(),c.material.dispose(),this}clear(t,n,i,r){const o=t.getRenderTarget();for(let c=0;c<6;c++)t.setRenderTarget(this,c),t.clear(n,i,r);t.setRenderTarget(o)}}class Yi extends Mn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const RN={type:"move"};class s_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Yi,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 Yi,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 Yi,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 r=null,o=null,c=null;const u=this._targetRay,h=this._grip,d=this._hand;if(t&&n.session.visibilityState!=="visible-blurred"){if(d&&t.hand){c=!0;for(const T of t.hand.values()){const S=n.getJointPose(T,i),x=this._getHandJoint(d,T);S!==null&&(x.matrix.fromArray(S.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=S.radius),x.visible=S!==null}const p=d.joints["index-finger-tip"],m=d.joints["thumb-tip"],_=p.position.distanceTo(m.position),y=.02,M=.005;d.inputState.pinching&&_>y+M?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!d.inputState.pinching&&_<=y-M&&(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&&(r=n.getPose(t.targetRaySpace,i),r===null&&o!==null&&(r=o),r!==null&&(u.matrix.fromArray(r.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,r.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(r.linearVelocity)):u.hasLinearVelocity=!1,r.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(r.angularVelocity)):u.hasAngularVelocity=!1,this.dispatchEvent(RN)))}return u!==null&&(u.visible=r!==null),h!==null&&(h.visible=o!==null),d!==null&&(d.visible=c!==null),this}_getHandJoint(t,n){if(t.joints[n.jointName]===void 0){const i=new Yi;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[n.jointName]=i,t.add(i)}return t.joints[n.jointName]}}class CN extends Mn{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 Tr,this.environmentIntensity=1,this.environmentRotation=new Tr,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 DN{constructor(t,n){this.isInterleavedBuffer=!0,this.array=t,this.stride=n,this.count=t!==void 0?t.length/n:0,this.usage=Lv,this.updateRanges=[],this.version=0,this.uuid=er()}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 r=0,o=this.stride;r1?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||IN.getNormalMatrix(t),r=this.coplanarPoint(o_).applyMatrix4(t),o=this.normal.applyMatrix3(i).normalize();return this.constant=-r.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 Oo=new wr,Hd=new G;class z1{constructor(t=new Ho,n=new Ho,i=new Ho,r=new Ho,o=new Ho,c=new Ho){this.planes=[t,n,i,r,o,c]}set(t,n,i,r,o,c){const u=this.planes;return u[0].copy(t),u[1].copy(n),u[2].copy(i),u[3].copy(r),u[4].copy(o),u[5].copy(c),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=la){const i=this.planes,r=t.elements,o=r[0],c=r[1],u=r[2],h=r[3],d=r[4],p=r[5],m=r[6],_=r[7],y=r[8],M=r[9],T=r[10],S=r[11],x=r[12],R=r[13],w=r[14],E=r[15];if(i[0].setComponents(h-o,_-d,S-y,E-x).normalize(),i[1].setComponents(h+o,_+d,S+y,E+x).normalize(),i[2].setComponents(h+c,_+p,S+M,E+R).normalize(),i[3].setComponents(h-c,_-p,S-M,E-R).normalize(),i[4].setComponents(h-u,_-m,S-T,E-w).normalize(),n===la)i[5].setComponents(h+u,_+m,S+T,E+w).normalize();else if(n===Rp)i[5].setComponents(u,m,T,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(),Oo.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const n=t.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Oo.copy(n.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Oo)}intersectsSprite(t){return Oo.center.set(0,0,0),Oo.radius=.7071067811865476,Oo.applyMatrix4(t.matrixWorld),this.intersectsSphere(Oo)}intersectsSphere(t){const n=this.planes,i=t.center,r=-t.radius;for(let o=0;o<6;o++)if(n[o].distanceToPoint(i)0?t.max.x:t.min.x,Hd.y=r.normal.y>0?t.max.y:t.min.y,Hd.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(Hd)<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 V1 extends Sr{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new he(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 Cp=new G,Dp=new G,Wb=new ve,_f=new Yp,Gd=new wr,l_=new G,jb=new G;class H1 extends Mn{constructor(t=new Qi,n=new V1){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 r=1,o=n.count;r0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,c=r.length;oi)return;l_.applyMatrix4(e.matrixWorld);const d=t.ray.origin.distanceTo(l_);if(!(dt.far))return{distance:d,point:jb.clone().applyMatrix4(e.matrixWorld),index:c,face:null,faceIndex:null,barycoord:null,object:e}}const Xb=new G,qb=new G;class R3 extends H1{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 r=0,o=n.count;r0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,c=r.length;or.far)return;o.push({distance:d,distanceToRay:Math.sqrt(u),point:h,index:t,face:null,faceIndex:null,barycoord:null,object:c})}}class Zb extends Zn{constructor(t,n,i,r,o,c,u,h,d){super(t,n,i,r,o,c,u,h,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class D3 extends Zn{constructor(t,n,i,r,o,c,u,h,d,p=Mc){if(p!==Mc&&p!==Nc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&p===Mc&&(i=al),i===void 0&&p===Nc&&(i=Lc),super(null,r,o,c,u,h,p,i,d),this.isDepthTexture=!0,this.image={width:t,height:n},this.magFilter=u!==void 0?u:Oi,this.minFilter=h!==void 0?h:Oi,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new B1(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 Yo extends Qi{constructor(t=1,n=1,i=1,r=32,o=1,c=!1,u=0,h=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:n,height:i,radialSegments:r,heightSegments:o,openEnded:c,thetaStart:u,thetaLength:h};const d=this;r=Math.floor(r),o=Math.floor(o);const p=[],m=[],_=[],y=[];let M=0;const T=[],S=i/2;let x=0;R(),c===!1&&(t>0&&w(!0),n>0&&w(!1)),this.setIndex(p),this.setAttribute("position",new Hn(m,3)),this.setAttribute("normal",new Hn(_,3)),this.setAttribute("uv",new Hn(y,2));function R(){const E=new G,P=new G;let I=0;const U=(n-t)/i;for(let B=0;B<=o;B++){const D=[],A=B/o,F=A*(n-t)+t;for(let q=0;q<=r;q++){const tt=q/r,ot=tt*h+u,ct=Math.sin(ot),k=Math.cos(ot);P.x=F*ct,P.y=-A*i+S,P.z=F*k,m.push(P.x,P.y,P.z),E.set(ct,U,k).normalize(),_.push(E.x,E.y,E.z),y.push(tt,1-A),D.push(M++)}T.push(D)}for(let B=0;B0||D!==0)&&(p.push(A,F,tt),I+=3),(n>0||D!==o-1)&&(p.push(F,q,tt),I+=3)}d.addGroup(x,I,0),x+=I}function w(E){const P=M,I=new Te,U=new G;let B=0;const D=E===!0?t:n,A=E===!0?1:-1;for(let q=1;q<=r;q++)m.push(0,S*A,0),_.push(0,A,0),y.push(.5,.5),M++;const F=M;for(let q=0;q<=r;q++){const ot=q/r*h+u,ct=Math.cos(ot),k=Math.sin(ot);U.x=D*k,U.y=S*A,U.z=D*ct,m.push(U.x,U.y,U.z),_.push(0,A,0),I.x=ct*.5+.5,I.y=k*.5*A+.5,y.push(I.x,I.y),M++}for(let q=0;q.9&&U<.1&&(w<.2&&(c[R+0]+=1),E<.2&&(c[R+2]+=1),P<.2&&(c[R+4]+=1))}}function _(R){o.push(R.x,R.y,R.z)}function y(R,w){const E=R*3;w.x=t[E+0],w.y=t[E+1],w.z=t[E+2]}function M(){const R=new G,w=new G,E=new G,P=new G,I=new Te,U=new Te,B=new Te;for(let D=0,A=0;D0)&&y.push(w,E,I),(x!==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 kN extends Sr{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=C5,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 zN extends Sr{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 qd(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 VN(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function HN(e){function t(r,o){return e[r]-e[o]}const n=e.length,i=new Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function Qb(e,t,n){const i=e.length,r=new e.constructor(i);for(let o=0,c=0;c!==i;++o){const u=n[o]*t;for(let h=0;h!==t;++h)r[c++]=e[u+h]}return r}function L3(e,t,n,i){let r=1,o=e[0];for(;o!==void 0&&o[i]===void 0;)o=e[r++];if(o===void 0)return;let c=o[i];if(c!==void 0)if(Array.isArray(c))do c=o[i],c!==void 0&&(t.push(o.time),n.push(...c)),o=e[r++];while(o!==void 0);else if(c.toArray!==void 0)do c=o[i],c!==void 0&&(t.push(o.time),c.toArray(n,n.length)),o=e[r++];while(o!==void 0);else do c=o[i],c!==void 0&&(t.push(o.time),n.push(c)),o=e[r++];while(o!==void 0)}class eh{constructor(t,n,i,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r: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,r=n[i],o=n[i-1];t:{e:{let c;n:{i:if(!(t=o)){const u=n[1];t=o)break e}c=i,i=0;break n}break t}for(;i>>1;tn;)--c;if(++c,o!==0||c!==r){o>=c&&(c=Math.max(c,1),o=c-1);const u=this.getValueSize();this.times=i.slice(o,c),this.values=this.values.slice(o*u,c*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,r=this.values,o=i.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let c=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(c!==null&&c>h){console.error("THREE.KeyframeTrack: Out of order keys.",this,u,h,c),t=!1;break}c=h}if(r!==void 0&&VN(r))for(let u=0,h=r.length;u!==h;++u){const d=r[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(),r=this.getInterpolation()===F0,o=t.length-1;let c=1;for(let u=1;u0){t[c]=t[o];for(let u=o*i,h=c*i,d=0;d!==i;++d)n[h+d]=n[u+d];++c}return c!==t.length?(this.times=t.slice(0,c),this.values=n.slice(0,c*i)):(this.times=t,this.values=n),this}clone(){const t=this.times.slice(),n=this.values.slice(),i=this.constructor,r=new i(this.name,t,n);return r.createInterpolant=this.createInterpolant,r}}Rr.prototype.TimeBufferType=Float32Array;Rr.prototype.ValueBufferType=Float32Array;Rr.prototype.DefaultInterpolation=Gf;class Qc extends Rr{constructor(t,n,i){super(t,n,i)}}Qc.prototype.ValueTypeName="bool";Qc.prototype.ValueBufferType=Array;Qc.prototype.DefaultInterpolation=Hf;Qc.prototype.InterpolantFactoryMethodLinear=void 0;Qc.prototype.InterpolantFactoryMethodSmooth=void 0;class U3 extends Rr{}U3.prototype.ValueTypeName="color";class Oc extends Rr{}Oc.prototype.ValueTypeName="number";class jN extends eh{constructor(t,n,i,r){super(t,n,i,r)}interpolate_(t,n,i,r){const o=this.resultBuffer,c=this.sampleValues,u=this.valueSize,h=(i-n)/(r-n);let d=t*u;for(let p=d+u;d!==p;d+=4)nr.slerpFlat(o,0,c,d-u,c,d,h);return o}}class Ic extends Rr{InterpolantFactoryMethodLinear(t){return new jN(this.times,this.values,this.getValueSize(),t)}}Ic.prototype.ValueTypeName="quaternion";Ic.prototype.InterpolantFactoryMethodSmooth=void 0;class Jc extends Rr{constructor(t,n,i){super(t,n,i)}}Jc.prototype.ValueTypeName="string";Jc.prototype.ValueBufferType=Array;Jc.prototype.DefaultInterpolation=Hf;Jc.prototype.InterpolantFactoryMethodLinear=void 0;Jc.prototype.InterpolantFactoryMethodSmooth=void 0;class Bc extends Rr{}Bc.prototype.ValueTypeName="vector";class Pv{constructor(t="",n=-1,i=[],r=O1){this.name=t,this.tracks=i,this.duration=n,this.blendMode=r,this.uuid=er(),this.duration<0&&this.resetDuration()}static parse(t){const n=[],i=t.tracks,r=1/(t.fps||1);for(let c=0,u=i.length;c!==u;++c)n.push(qN(i[c]).scale(r));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,r={name:t.name,duration:t.duration,tracks:n,uuid:t.uuid,blendMode:t.blendMode};for(let o=0,c=i.length;o!==c;++o)n.push(Rr.toJSON(i[o]));return r}static CreateFromMorphTargetSequence(t,n,i,r){const o=n.length,c=[];for(let u=0;u1){const m=p[1];let _=r[m];_||(r[m]=_=[]),_.push(d)}}const c=[];for(const u in r)c.push(this.CreateFromMorphTargetSequence(u,r[u],n,i));return c}static parseAnimation(t,n){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(m,_,y,M,T){if(y.length!==0){const S=[],x=[];L3(y,S,x,M),S.length!==0&&T.push(new m(_,S,x))}},r=[],o=t.name||"default",c=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(ia[t]!==void 0){ia[t].push({onLoad:n,onProgress:i,onError:r});return}ia[t]=[],ia[t].push({onLoad:n,onProgress:i,onError:r});const c=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),u=this.mimeType,h=this.responseType;fetch(c).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=ia[t],m=d.body.getReader(),_=d.headers.get("X-File-Size")||d.headers.get("Content-Length"),y=_?parseInt(_):0,M=y!==0;let T=0;const S=new ReadableStream({start(x){R();function R(){m.read().then(({done:w,value:E})=>{if(w)x.close();else{T+=E.byteLength;const P=new ProgressEvent("progress",{lengthComputable:M,loaded:T,total:y});for(let I=0,U=p.length;I{x.error(w)})}}});return new Response(S)}else throw new ZN(`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),_=m&&m[1]?m[1].toLowerCase():void 0,y=new TextDecoder(_);return d.arrayBuffer().then(M=>y.decode(M))}}}).then(d=>{to.add(t,d);const p=ia[t];delete ia[t];for(let m=0,_=p.length;m<_;m++){const y=p[m];y.onLoad&&y.onLoad(d)}}).catch(d=>{const p=ia[t];if(p===void 0)throw this.manager.itemError(t),d;delete ia[t];for(let m=0,_=p.length;m<_;m++){const y=p[m];y.onError&&y.onError(d)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class QN extends $c{constructor(t){super(t)}load(t,n,i,r){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const o=this,c=to.get(t);if(c!==void 0)return o.manager.itemStart(t),setTimeout(function(){n&&n(c),o.manager.itemEnd(t)},0),c;const u=Wf("img");function h(){p(),to.add(t,this),n&&n(this),o.manager.itemEnd(t)}function d(m){p(),r&&r(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 JN extends $c{constructor(t){super(t)}load(t,n,i,r){const o=new Zn,c=new QN(this.manager);return c.setCrossOrigin(this.crossOrigin),c.setPath(this.path),c.load(t,function(u){o.image=u,o.needsUpdate=!0,n!==void 0&&n(o)},i,r),o}}class Zp extends Mn{constructor(t,n=1){super(),this.isLight=!0,this.type="Light",this.color=new he(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}}const c_=new ve,Jb=new G,$b=new G;class X1{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Te(512,512),this.map=null,this.mapPass=null,this.matrix=new ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new z1,this._frameExtents=new Te(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const n=this.camera,i=this.matrix;Jb.setFromMatrixPosition(t.matrixWorld),n.position.copy(Jb),$b.setFromMatrixPosition(t.target.matrixWorld),n.lookAt($b),n.updateMatrixWorld(),c_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(c_),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(c_)}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 $N extends X1{constructor(){super(new Ni(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const n=this.camera,i=Uc*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,o=t.distance||n.far;(i!==n.fov||r!==n.aspect||o!==n.far)&&(n.fov=i,n.aspect=r,n.far=o,n.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class tU extends Zp{constructor(t,n,i=0,r=Math.PI/3,o=0,c=2){super(t,n),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Mn.DEFAULT_UP),this.updateMatrix(),this.target=new Mn,this.distance=i,this.angle=r,this.penumbra=o,this.decay=c,this.map=null,this.shadow=new $N}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 tT=new ve,vf=new G,u_=new G;class eU extends X1{constructor(){super(new Ni(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Te(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(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,r=this.matrix,o=t.distance||i.far;o!==i.far&&(i.far=o,i.updateProjectionMatrix()),vf.setFromMatrixPosition(t.matrixWorld),i.position.copy(vf),u_.copy(i.position),u_.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(u_),i.updateMatrixWorld(),r.makeTranslation(-vf.x,-vf.y,-vf.z),tT.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tT)}}class nU extends Zp{constructor(t,n,i=0,r=2){super(t,n),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new eU}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 q1 extends b3{constructor(t=-1,n=1,i=1,r=-1,o=.1,c=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=r,this.near=o,this.far=c,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,r,o,c){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=r,this.view.width=o,this.view.height=c,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,r=(this.top+this.bottom)/2;let o=i-t,c=i+t,u=r+n,h=r-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,c=o+d*this.view.width,u-=p*this.view.offsetY,h=u-p*this.view.height}this.projectionMatrix.makeOrthographic(o,c,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 iU extends X1{constructor(){super(new q1(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class O3 extends Zp{constructor(t,n){super(t,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mn.DEFAULT_UP),this.updateMatrix(),this.target=new Mn,this.shadow=new iU}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class sU extends Zp{constructor(t,n){super(t,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class Uf{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,r=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,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const o=this,c=to.get(t);if(c!==void 0){if(o.manager.itemStart(t),c.then){c.then(d=>{n&&n(d),o.manager.itemEnd(t)}).catch(d=>{r&&r(d)});return}return setTimeout(function(){n&&n(c),o.manager.itemEnd(t)},0),c}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 to.add(t,d),n&&n(d),o.manager.itemEnd(t),d}).catch(function(d){r&&r(d),to.remove(t),o.manager.itemError(t),o.manager.itemEnd(t)});to.add(t,h),o.manager.itemStart(t)}}class aU extends Ni{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t,this.index=0}}class oU{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=eT(),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=eT();t=(n-this.oldTime)/1e3,this.oldTime=n,this.elapsedTime+=t}return t}}function eT(){return performance.now()}class lU{constructor(t,n,i){this.binding=t,this.valueSize=i;let r,o,c;switch(n){case"quaternion":r=this._slerp,o=this._slerpAdditive,c=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,o=this._select,c=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,o=this._lerpAdditive,c=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=o,this._setIdentity=c,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,r=this.valueSize,o=t*r+r;let c=this.cumulativeWeight;if(c===0){for(let u=0;u!==r;++u)i[o+u]=i[u];c=n}else{c+=n;const u=n/c;this._mixBufferRegion(i,o,0,u,r)}this.cumulativeWeight=c}accumulateAdditive(t){const n=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(n,r,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const n=this.valueSize,i=this.buffer,r=t*n+n,o=this.cumulativeWeight,c=this.cumulativeWeightAdditive,u=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const h=n*this._origIndex;this._mixBufferRegion(i,r,h,1-o,n)}c>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*n,1,n);for(let h=n,d=n+n;h!==d;++h)if(i[h]!==i[h+n]){u.setValue(i,r);break}}saveOriginalState(){const t=this.binding,n=this.buffer,i=this.valueSize,r=i*this._origIndex;t.getValue(n,r);for(let o=i,c=r;o!==c;++o)n[o]=n[r+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 c=0;c!==o;++c)t[n+c]=t[i+c]}_slerp(t,n,i,r){nr.slerpFlat(t,n,t,n,t,i,r)}_slerpAdditive(t,n,i,r,o){const c=this._workIndex*o;nr.multiplyQuaternionsFlat(t,c,t,n,t,i),nr.slerpFlat(t,n,t,n,t,c,r)}_lerp(t,n,i,r,o){const c=1-r;for(let u=0;u!==o;++u){const h=n+u;t[h]=t[h]*c+t[i+u]*r}}_lerpAdditive(t,n,i,r,o){for(let c=0;c!==o;++c){const u=n+c;t[u]=t[u]+t[i+c]*r}}}const Y1="\\[\\]\\.:\\/",cU=new RegExp("["+Y1+"]","g"),K1="[^"+Y1+"]",uU="[^"+Y1.replace("\\.","")+"]",fU=/((?:WC+[\/:])*)/.source.replace("WC",K1),hU=/(WCOD+)?/.source.replace("WCOD",uU),dU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",K1),pU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",K1),mU=new RegExp("^"+fU+hU+dU+pU+"$"),gU=["material","materials","bones","map"];class _U{constructor(t,n,i){const r=i||Ye.parseTrackName(n);this._targetGroup=t,this._bindings=t.subscribe_(n,r)}getValue(t,n){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(t,n)}setValue(t,n){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=i.length;r!==o;++r)i[r].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 Ye{constructor(t,n,i){this.path=n,this.parsedPath=i||Ye.parseTrackName(n),this.node=Ye.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 Ye.Composite(t,n,i):new Ye(t,n,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(cU,"")}static parseTrackName(t){const n=mU.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]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const o=i.nodeName.substring(r+1);gU.indexOf(o)!==-1&&(i.nodeName=i.nodeName.substring(0,r),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 c=0;c0){const h=this._interpolants,d=this._propertyBindings;switch(this.blendMode){case w5:for(let p=0,m=h.length;p!==m;++p)h[p].evaluate(c),d[p].accumulateAdditive(u);break;case O1:default:for(let p=0,m=h.length;p!==m;++p)h[p].evaluate(c),d[p].accumulate(r,u)}}}_updateWeight(t){let n=0;if(this.enabled){n=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(t)[0];n*=r,t>i.parameterPositions[1]&&(this.stopFading(),r===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 r=i.evaluate(t)[0];n*=r,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 r=this.time+t,o=this._loopCount;const c=i===A5;if(t===0)return o===-1?r:c&&(o&1)===1?n-r:r;if(i===Ef){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=n)r=n;else if(r<0)r=0;else{this.time=r;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,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,c)):this._setEndings(this.repetitions===0,!0,c)),r>=n||r<0){const u=Math.floor(r/n);r-=n*u,o+=Math.abs(u);const h=this.repetitions-o;if(h<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?n:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(h===1){const d=t<0;this._setEndings(d,!d,c)}else this._setEndings(!1,!1,c);this._loopCount=o,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:u})}}else this.time=r;if(c&&(o&1)===1)return n-r}return r}_setEndings(t,n,i){const r=this._interpolantSettings;i?(r.endingStart=mc,r.endingEnd=mc):(t?r.endingStart=this.zeroSlopeAtStart?mc:pc:r.endingStart=Ap,n?r.endingEnd=this.zeroSlopeAtEnd?mc:pc:r.endingEnd=Ap)}_scheduleFading(t,n,i){const r=this._mixer,o=r.time;let c=this._weightInterpolant;c===null&&(c=r._lendControlInterpolant(),this._weightInterpolant=c);const u=c.parameterPositions,h=c.sampleValues;return u[0]=o,h[0]=n,u[1]=o+t,h[1]=i,this}}const yU=new Float32Array(1);class xU extends hl{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,r=t._clip.tracks,o=r.length,c=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 _=r[m],y=_.name;let M=p[y];if(M!==void 0)++M.referenceCount,c[m]=M;else{if(M=c[m],M!==void 0){M._cacheIndex===null&&(++M.referenceCount,this._addInactiveBinding(M,h,y));continue}const T=n&&n._propertyBindings[m].binding.parsedPath;M=new lU(Ye.create(i,y,T),_.ValueTypeName,_.getValueSize()),++M.referenceCount,this._addInactiveBinding(M,h,y),c[m]=M}u[m].resultBuffer=M.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,r=t._clip.uuid,o=this._actionsByClip[r];this._bindAction(t,o&&o.knownActions[0]),this._addInactiveAction(t,r,i)}const n=t._propertyBindings;for(let i=0,r=n.length;i!==r;++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,r=n.length;i!==r;++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,r=this.time+=t,o=Math.sign(t),c=this._accuIndex^=1;for(let d=0;d!==i;++d)n[d]._update(r,t,o,c);const u=this._bindings,h=this._nActiveBindings;for(let d=0;d!==h;++d)u[d].apply(c);return this}setTime(t){this.time=0;for(let n=0;ny.start-M.start);let _=0;for(let y=1;y 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`,zU=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,VU=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,HU=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,GU=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,WU=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,jU=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,XU=`#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`,qU=`#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`,YU=`#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`,KU=`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`,ZU=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,QU=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,JU=`#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`,tP="gl_FragColor = linearToOutputTexel( gl_FragColor );",eP=`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 ); }`,nP=`#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`,iP=`#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`,sP=`#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`,rP=`#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`,aP=`#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`,oP=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,lP=`#ifdef USE_FOG varying float vFogDepth; #endif`,cP=`#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`,uP=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,fP=`#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 }`,hP=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,dP=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,pP=`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`,mP=`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`,gP=`#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`,_P=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,vP=`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`,yP=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,xP=`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`,SP=`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`,MP=`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 ); }`,bP=` 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`,TP=`#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`,EP=`#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`,AP=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,wP=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,RP=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,CP=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,DP=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,LP=`#ifdef USE_MAP uniform sampler2D map; #endif`,NP=`#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`,UP=`#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`,PP=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,OP=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,IP=`#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`,BP=`#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`,FP=`#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`,kP=`#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`,zP=`#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`,VP=`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;`,HP=`#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`,GP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,WP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,jP=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,XP=`#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`,qP=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,YP=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,KP=`#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`,ZP=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,QP=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JP=`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 ); }`,$P=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,tO=`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;`,eO=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,nO=`#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`,iO=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,sO=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,rO=`#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`,aO=`#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`,oO=`#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`,lO=`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`,uO=`#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`,fO=`#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`,hO=`#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`,dO=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,pO=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,mO=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,gO=`#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; }`,_O=`#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`,vO=`#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`,yO=`#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`,xO=`#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`,SO=`#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`,MO=`#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 bO=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,TO=`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 }`,EO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,AO=`#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 }`,wO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,RO=`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 }`,CO=`#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; }`,DO=`#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 }`,LO=`#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; }`,NO=`#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 ); }`,UO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,PO=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,OO=`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 }`,IO=`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 }`,BO=`#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 }`,FO=`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 }`,kO=`#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 }`,zO=`#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 }`,VO=`#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; }`,HO=`#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 }`,GO=`#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 }`,WO=`#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 }`,jO=`#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 }`,XO=`#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 }`,qO=`#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 }`,YO=`#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 }`,KO=`#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 }`,ZO=`#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 }`,QO=`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 }`,JO=`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 }`,$O=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,t6=`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 }`,e6=`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 }`,n6=`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 }`,Me={alphahash_fragment:TU,alphahash_pars_fragment:EU,alphamap_fragment:AU,alphamap_pars_fragment:wU,alphatest_fragment:RU,alphatest_pars_fragment:CU,aomap_fragment:DU,aomap_pars_fragment:LU,batching_pars_vertex:NU,batching_vertex:UU,begin_vertex:PU,beginnormal_vertex:OU,bsdfs:IU,iridescence_fragment:BU,bumpmap_pars_fragment:FU,clipping_planes_fragment:kU,clipping_planes_pars_fragment:zU,clipping_planes_pars_vertex:VU,clipping_planes_vertex:HU,color_fragment:GU,color_pars_fragment:WU,color_pars_vertex:jU,color_vertex:XU,common:qU,cube_uv_reflection_fragment:YU,defaultnormal_vertex:KU,displacementmap_pars_vertex:ZU,displacementmap_vertex:QU,emissivemap_fragment:JU,emissivemap_pars_fragment:$U,colorspace_fragment:tP,colorspace_pars_fragment:eP,envmap_fragment:nP,envmap_common_pars_fragment:iP,envmap_pars_fragment:sP,envmap_pars_vertex:rP,envmap_physical_pars_fragment:gP,envmap_vertex:aP,fog_vertex:oP,fog_pars_vertex:lP,fog_fragment:cP,fog_pars_fragment:uP,gradientmap_pars_fragment:fP,lightmap_pars_fragment:hP,lights_lambert_fragment:dP,lights_lambert_pars_fragment:pP,lights_pars_begin:mP,lights_toon_fragment:_P,lights_toon_pars_fragment:vP,lights_phong_fragment:yP,lights_phong_pars_fragment:xP,lights_physical_fragment:SP,lights_physical_pars_fragment:MP,lights_fragment_begin:bP,lights_fragment_maps:TP,lights_fragment_end:EP,logdepthbuf_fragment:AP,logdepthbuf_pars_fragment:wP,logdepthbuf_pars_vertex:RP,logdepthbuf_vertex:CP,map_fragment:DP,map_pars_fragment:LP,map_particle_fragment:NP,map_particle_pars_fragment:UP,metalnessmap_fragment:PP,metalnessmap_pars_fragment:OP,morphinstance_vertex:IP,morphcolor_vertex:BP,morphnormal_vertex:FP,morphtarget_pars_vertex:kP,morphtarget_vertex:zP,normal_fragment_begin:VP,normal_fragment_maps:HP,normal_pars_fragment:GP,normal_pars_vertex:WP,normal_vertex:jP,normalmap_pars_fragment:XP,clearcoat_normal_fragment_begin:qP,clearcoat_normal_fragment_maps:YP,clearcoat_pars_fragment:KP,iridescence_pars_fragment:ZP,opaque_fragment:QP,packing:JP,premultiplied_alpha_fragment:$P,project_vertex:tO,dithering_fragment:eO,dithering_pars_fragment:nO,roughnessmap_fragment:iO,roughnessmap_pars_fragment:sO,shadowmap_pars_fragment:rO,shadowmap_pars_vertex:aO,shadowmap_vertex:oO,shadowmask_pars_fragment:lO,skinbase_vertex:cO,skinning_pars_vertex:uO,skinning_vertex:fO,skinnormal_vertex:hO,specularmap_fragment:dO,specularmap_pars_fragment:pO,tonemapping_fragment:mO,tonemapping_pars_fragment:gO,transmission_fragment:_O,transmission_pars_fragment:vO,uv_pars_fragment:yO,uv_pars_vertex:xO,uv_vertex:SO,worldpos_vertex:MO,background_vert:bO,background_frag:TO,backgroundCube_vert:EO,backgroundCube_frag:AO,cube_vert:wO,cube_frag:RO,depth_vert:CO,depth_frag:DO,distanceRGBA_vert:LO,distanceRGBA_frag:NO,equirect_vert:UO,equirect_frag:PO,linedashed_vert:OO,linedashed_frag:IO,meshbasic_vert:BO,meshbasic_frag:FO,meshlambert_vert:kO,meshlambert_frag:zO,meshmatcap_vert:VO,meshmatcap_frag:HO,meshnormal_vert:GO,meshnormal_frag:WO,meshphong_vert:jO,meshphong_frag:XO,meshphysical_vert:qO,meshphysical_frag:YO,meshtoon_vert:KO,meshtoon_frag:ZO,points_vert:QO,points_frag:JO,shadow_vert:$O,shadow_frag:t6,sprite_vert:e6,sprite_frag:n6},It={common:{diffuse:{value:new he(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new _e},alphaMap:{value:null},alphaMapTransform:{value:new _e},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new _e}},envmap:{envMap:{value:null},envMapRotation:{value:new _e},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new _e}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new _e}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new _e},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new _e},normalScale:{value:new Te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new _e},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new _e}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new _e}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new _e}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new he(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 he(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new _e},alphaTest:{value:0},uvTransform:{value:new _e}},sprite:{diffuse:{value:new he(16777215)},opacity:{value:1},center:{value:new Te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new _e},alphaMap:{value:null},alphaMapTransform:{value:new _e},alphaTest:{value:0}}},vr={basic:{uniforms:Di([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.fog]),vertexShader:Me.meshbasic_vert,fragmentShader:Me.meshbasic_frag},lambert:{uniforms:Di([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new he(0)}}]),vertexShader:Me.meshlambert_vert,fragmentShader:Me.meshlambert_frag},phong:{uniforms:Di([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new he(0)},specular:{value:new he(1118481)},shininess:{value:30}}]),vertexShader:Me.meshphong_vert,fragmentShader:Me.meshphong_frag},standard:{uniforms:Di([It.common,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.roughnessmap,It.metalnessmap,It.fog,It.lights,{emissive:{value:new he(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Me.meshphysical_vert,fragmentShader:Me.meshphysical_frag},toon:{uniforms:Di([It.common,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.gradientmap,It.fog,It.lights,{emissive:{value:new he(0)}}]),vertexShader:Me.meshtoon_vert,fragmentShader:Me.meshtoon_frag},matcap:{uniforms:Di([It.common,It.bumpmap,It.normalmap,It.displacementmap,It.fog,{matcap:{value:null}}]),vertexShader:Me.meshmatcap_vert,fragmentShader:Me.meshmatcap_frag},points:{uniforms:Di([It.points,It.fog]),vertexShader:Me.points_vert,fragmentShader:Me.points_frag},dashed:{uniforms:Di([It.common,It.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Me.linedashed_vert,fragmentShader:Me.linedashed_frag},depth:{uniforms:Di([It.common,It.displacementmap]),vertexShader:Me.depth_vert,fragmentShader:Me.depth_frag},normal:{uniforms:Di([It.common,It.bumpmap,It.normalmap,It.displacementmap,{opacity:{value:1}}]),vertexShader:Me.meshnormal_vert,fragmentShader:Me.meshnormal_frag},sprite:{uniforms:Di([It.sprite,It.fog]),vertexShader:Me.sprite_vert,fragmentShader:Me.sprite_frag},background:{uniforms:{uvTransform:{value:new _e},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Me.background_vert,fragmentShader:Me.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new _e}},vertexShader:Me.backgroundCube_vert,fragmentShader:Me.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Me.cube_vert,fragmentShader:Me.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Me.equirect_vert,fragmentShader:Me.equirect_frag},distanceRGBA:{uniforms:Di([It.common,It.displacementmap,{referencePosition:{value:new G},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Me.distanceRGBA_vert,fragmentShader:Me.distanceRGBA_frag},shadow:{uniforms:Di([It.lights,It.fog,{color:{value:new he(0)},opacity:{value:1}}]),vertexShader:Me.shadow_vert,fragmentShader:Me.shadow_frag}};vr.physical={uniforms:Di([vr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new _e},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new _e},clearcoatNormalScale:{value:new Te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new _e},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new _e},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new _e},sheen:{value:0},sheenColor:{value:new he(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new _e},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new _e},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new _e},transmissionSamplerSize:{value:new Te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new _e},attenuationDistance:{value:0},attenuationColor:{value:new he(0)},specularColor:{value:new he(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new _e},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new _e},anisotropyVector:{value:new Te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new _e}}]),vertexShader:Me.meshphysical_vert,fragmentShader:Me.meshphysical_frag};const Yd={r:0,b:0,g:0},Io=new Tr,i6=new ve;function s6(e,t,n,i,r,o,c){const u=new he(0);let h=o===!0?0:1,d,p,m=null,_=0,y=null;function M(w){let E=w.isScene===!0?w.background:null;return E&&E.isTexture&&(E=(w.backgroundBlurriness>0?n:t).get(E)),E}function T(w){let E=!1;const P=M(w);P===null?x(u,h):P&&P.isColor&&(x(P,1),E=!0);const I=e.xr.getEnvironmentBlendMode();I==="additive"?i.buffers.color.setClear(0,0,0,1,c):I==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,c),(e.autoClear||E)&&(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,E){const P=M(E);P&&(P.isCubeTexture||P.mapping===qp)?(p===void 0&&(p=new qe(new ll(1,1,1),new ro({name:"BackgroundCubeMaterial",uniforms:Pc(vr.backgroundCube.uniforms),vertexShader:vr.backgroundCube.vertexShader,fragmentShader:vr.backgroundCube.fragmentShader,side:Zi,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(I,U,B){this.matrixWorld.copyPosition(B.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(p)),Io.copy(E.backgroundRotation),Io.x*=-1,Io.y*=-1,Io.z*=-1,P.isCubeTexture&&P.isRenderTargetTexture===!1&&(Io.y*=-1,Io.z*=-1),p.material.uniforms.envMap.value=P,p.material.uniforms.flipEnvMap.value=P.isCubeTexture&&P.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(i6.makeRotationFromEuler(Io)),p.material.toneMapped=Oe.getTransfer(P.colorSpace)!==rn,(m!==P||_!==P.version||y!==e.toneMapping)&&(p.material.needsUpdate=!0,m=P,_=P.version,y=e.toneMapping),p.layers.enableAll(),w.unshift(p,p.geometry,p.material,0,0,null)):P&&P.isTexture&&(d===void 0&&(d=new qe(new Kp(2,2),new ro({name:"BackgroundMaterial",uniforms:Pc(vr.background.uniforms),vertexShader:vr.background.vertexShader,fragmentShader:vr.background.fragmentShader,side:ua,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(d)),d.material.uniforms.t2D.value=P,d.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,d.material.toneMapped=Oe.getTransfer(P.colorSpace)!==rn,P.matrixAutoUpdate===!0&&P.updateMatrix(),d.material.uniforms.uvTransform.value.copy(P.matrix),(m!==P||_!==P.version||y!==e.toneMapping)&&(d.material.needsUpdate=!0,m=P,_=P.version,y=e.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null))}function x(w,E){w.getRGB(Yd,M3(e)),i.buffers.color.setClear(Yd.r,Yd.g,Yd.b,E,c)}function R(){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,E=1){u.set(w),h=E,x(u,h)},getClearAlpha:function(){return h},setClearAlpha:function(w){h=w,x(u,h)},render:T,addToRenderList:S,dispose:R}}function r6(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=_(null);let o=r,c=!1;function u(A,F,q,tt,ot){let ct=!1;const k=m(tt,q,F);o!==k&&(o=k,d(o.object)),ct=y(A,tt,q,ot),ct&&M(A,tt,q,ot),ot!==null&&t.update(ot,e.ELEMENT_ARRAY_BUFFER),(ct||c)&&(c=!1,E(A,F,q,tt),ot!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(ot).buffer))}function h(){return e.createVertexArray()}function d(A){return e.bindVertexArray(A)}function p(A){return e.deleteVertexArray(A)}function m(A,F,q){const tt=q.wireframe===!0;let ot=i[A.id];ot===void 0&&(ot={},i[A.id]=ot);let ct=ot[F.id];ct===void 0&&(ct={},ot[F.id]=ct);let k=ct[tt];return k===void 0&&(k=_(h()),ct[tt]=k),k}function _(A){const F=[],q=[],tt=[];for(let ot=0;ot=0){const bt=ot[j];let z=ct[j];if(z===void 0&&(j==="instanceMatrix"&&A.instanceMatrix&&(z=A.instanceMatrix),j==="instanceColor"&&A.instanceColor&&(z=A.instanceColor)),bt===void 0||bt.attribute!==z||z&&bt.data!==z.data)return!0;k++}return o.attributesNum!==k||o.index!==tt}function M(A,F,q,tt){const ot={},ct=F.attributes;let k=0;const Q=q.getAttributes();for(const j in Q)if(Q[j].location>=0){let bt=ct[j];bt===void 0&&(j==="instanceMatrix"&&A.instanceMatrix&&(bt=A.instanceMatrix),j==="instanceColor"&&A.instanceColor&&(bt=A.instanceColor));const z={};z.attribute=bt,bt&&bt.data&&(z.data=bt.data),ot[j]=z,k++}o.attributes=ot,o.attributesNum=k,o.index=tt}function T(){const A=o.newAttributes;for(let F=0,q=A.length;F=0){let pt=ot[Q];if(pt===void 0&&(Q==="instanceMatrix"&&A.instanceMatrix&&(pt=A.instanceMatrix),Q==="instanceColor"&&A.instanceColor&&(pt=A.instanceColor)),pt!==void 0){const bt=pt.normalized,z=pt.itemSize,it=t.get(pt);if(it===void 0)continue;const Tt=it.buffer,J=it.type,dt=it.bytesPerElement,At=J===e.INT||J===e.UNSIGNED_INT||pt.gpuType===R1;if(pt.isInterleavedBufferAttribute){const xt=pt.data,Vt=xt.stride,Gt=pt.offset;if(xt.isInstancedInterleavedBuffer){for(let $t=0;$t0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";U="mediump"}return U==="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,_=n.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),y=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),M=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=e.getParameter(e.MAX_TEXTURE_SIZE),S=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),x=e.getParameter(e.MAX_VERTEX_ATTRIBS),R=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),w=e.getParameter(e.MAX_VARYING_VECTORS),E=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),P=M>0,I=e.getParameter(e.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:h,textureFormatReadable:c,textureTypeReadable:u,precision:d,logarithmicDepthBuffer:m,reverseDepthBuffer:_,maxTextures:y,maxVertexTextures:M,maxTextureSize:T,maxCubemapSize:S,maxAttributes:x,maxVertexUniforms:R,maxVaryings:w,maxFragmentUniforms:E,vertexTextures:P,maxSamples:I}}function l6(e){const t=this;let n=null,i=0,r=!1,o=!1;const c=new Ho,u=new _e,h={value:null,needsUpdate:!1};this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(m,_){const y=m.length!==0||_||i!==0||r;return r=_,i=m.length,y},this.beginShadows=function(){o=!0,p(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(m,_){n=p(m,_,0)},this.setState=function(m,_,y){const M=m.clippingPlanes,T=m.clipIntersection,S=m.clipShadows,x=e.get(m);if(!r||M===null||M.length===0||o&&!S)o?p(null):d();else{const R=o?0:i,w=R*4;let E=x.clippingState||null;h.value=E,E=p(M,_,w,y);for(let P=0;P!==w;++P)E[P]=n[P];x.clippingState=E,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=R}};function d(){h.value!==n&&(h.value=n,h.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function p(m,_,y,M){const T=m!==null?m.length:0;let S=null;if(T!==0){if(S=h.value,M!==!0||S===null){const x=y+T*4,R=_.matrixWorldInverse;u.getNormalMatrix(R),(S===null||S.length0){const d=new wN(h.height);return d.fromEquirectangularTexture(e,c),t.set(c,d),c.addEventListener("dispose",r),n(d.texture,c.mapping)}else return null}}return c}function r(c){const u=c.target;u.removeEventListener("dispose",r);const h=t.get(u);h!==void 0&&(t.delete(u),h.dispose())}function o(){t=new WeakMap}return{get:i,dispose:o}}const gc=4,iT=[.125,.215,.35,.446,.526,.582],qo=20,f_=new q1,sT=new he;let h_=null,d_=0,p_=0,m_=!1;const Go=(1+Math.sqrt(5))/2,cc=1/Go,rT=[new G(-Go,cc,0),new G(Go,cc,0),new G(-cc,0,Go),new G(cc,0,Go),new G(0,Go,-cc),new G(0,Go,cc),new G(-1,1,-1),new G(1,1,-1),new G(-1,1,1),new G(1,1,1)],u6=new G;class aT{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,r=100,o={}){const{size:c=256,position:u=u6}=o;h_=this._renderer.getRenderTarget(),d_=this._renderer.getActiveCubeFace(),p_=this._renderer.getActiveMipmapLevel(),m_=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(c);const h=this._allocateTargets();return h.depthBuffer=!0,this._sceneToCubeUV(t,i,r,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=cT(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lT(),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?E:0,E,E),m.setRenderTarget(r),S&&m.render(T,h),m.render(t,h)}T.geometry.dispose(),T.material.dispose(),m.toneMapping=y,m.autoClear=_,t.background=x}_textureToCubeUV(t,n){const i=this._renderer,r=t.mapping===Rc||t.mapping===Cc;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=cT()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lT());const o=r?this._cubemapMaterial:this._equirectMaterial,c=new qe(this._lodPlanes[0],o),u=o.uniforms;u.envMap.value=t;const h=this._cubeSize;Kd(n,0,0,3*h,2*h),i.setRenderTarget(n),i.render(c,f_)}_applyPMREM(t){const n=this._renderer,i=n.autoClear;n.autoClear=!1;const r=this._lodPlanes.length;for(let o=1;oqo&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${qo}`);const x=[];let R=0;for(let U=0;Uw-gc?r-w+gc:0),I=4*(this._cubeSize-E);Kd(n,P,I,3*E,2*E),h.setRenderTarget(n),h.render(m,f_)}}function f6(e){const t=[],n=[],i=[];let r=e;const o=e-gc+1+iT.length;for(let c=0;ce-gc?h=iT[c-e+gc-1]:c===0&&(h=0),i.push(h);const d=1/(u-2),p=-d,m=1+d,_=[p,p,m,p,m,m,p,p,m,m,p,m],y=6,M=6,T=3,S=2,x=1,R=new Float32Array(T*M*y),w=new Float32Array(S*M*y),E=new Float32Array(x*M*y);for(let I=0;I2?0:-1,D=[U,B,0,U+2/3,B,0,U+2/3,B+1,0,U,B,0,U+2/3,B+1,0,U,B+1,0];R.set(D,T*M*I),w.set(_,S*M*I);const A=[I,I,I,I,I,I];E.set(A,x*M*I)}const P=new Qi;P.setAttribute("position",new Ii(R,T)),P.setAttribute("uv",new Ii(w,S)),P.setAttribute("faceIndex",new Ii(E,x)),t.push(P),r>gc&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function oT(e,t,n){const i=new ol(e,t,n);return i.texture.mapping=qp,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Kd(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function h6(e,t,n){const i=new Float32Array(qo),r=new G(0,1,0);return new ro({name:"SphericalGaussianBlur",defines:{n:qo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Z1(),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:no,depthTest:!1,depthWrite:!1})}function lT(){return new ro({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Z1(),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:no,depthTest:!1,depthWrite:!1})}function cT(){return new ro({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Z1(),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:no,depthTest:!1,depthWrite:!1})}function Z1(){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 d6(e){let t=new WeakMap,n=null;function i(u){if(u&&u.isTexture){const h=u.mapping,d=h===nv||h===iv,p=h===Rc||h===Cc;if(d||p){let m=t.get(u);const _=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==_)return n===null&&(n=new aT(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 y=u.image;return d&&y&&y.height>0||p&&y&&r(y)?(n===null&&(n=new aT(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 r(u){let h=0;const d=6;for(let p=0;pt.maxTextureSize&&(I=Math.ceil(P/t.maxTextureSize),P=t.maxTextureSize);const U=new Float32Array(P*I*4*m),B=new _3(U,P,I,m);B.type=tr,B.needsUpdate=!0;const D=E*4;for(let F=0;F0)return e;const r=t*n;let o=fT[r];if(o===void 0&&(o=new Float32Array(r),fT[r]=o),t!==0){i.toArray(o,0);for(let c=1,u=0;c!==t;++c)u+=n,e[c].toArray(o,u)}return o}function $n(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${u}: ${n[c]}`)}return i.join(` `)}const vT=new _e;function dI(e){Oe._getMatrix(vT,Oe.workingColorSpace,e);const t=`mat3( ${vT.elements.map(n=>n.toFixed(4))} )`;switch(Oe.getTransfer(e)){case wp:return[t,"LinearTransferOETF"];case rn:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function yT(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&r==="")return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const c=parseInt(o[1]);return n.toUpperCase()+` `+r+` `+hI(e.getShaderSource(t),c)}else return r}function pI(e,t){const n=dI(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(` `)}function mI(e,t){let n;switch(t){case _5:n="Linear";break;case v5:n="Reinhard";break;case y5:n="Cineon";break;case x5:n="ACESFilmic";break;case M5:n="AgX";break;case b5:n="Neutral";break;case S5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Zd=new G;function gI(){Oe.getLuminanceCoefficients(Zd);const e=Zd.x.toFixed(4),t=Zd.y.toFixed(4),n=Zd.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`," return dot( weights, rgb );","}"].join(` `)}function _I(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Af).join(` `)}function vI(e){const t=[];for(const n in e){const i=e[n];i!==!1&&t.push("#define "+n+" "+i)}return t.join(` `)}function yI(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function Ov(e){return e.replace(xI,MI)}const SI=new Map;function MI(e,t){let n=Me[t];if(n===void 0){const i=SI.get(t);if(i!==void 0)n=Me[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 Ov(n)}const bI=/#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 MT(e){return e.replace(bI,TI)}function TI(e,t,n,i){let r="";for(let o=parseInt(t);o0&&(S+=` `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,M].filter(Af).join(` `),x.length>0&&(x+=` `)):(S=[bT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,M,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(Af).join(` `),x=[bT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,M,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:"",_?"#define CUBEUV_TEXEL_WIDTH "+_.texelWidth:"",_?"#define CUBEUV_TEXEL_HEIGHT "+_.texelHeight:"",_?"#define CUBEUV_MAX_MIP "+_.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!==io?"#define TONE_MAPPING":"",n.toneMapping!==io?Me.tonemapping_pars_fragment:"",n.toneMapping!==io?mI("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Me.colorspace_pars_fragment,pI("linearToOutputTexel",n.outputColorSpace),gI(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",` `].filter(Af).join(` `)),c=Ov(c),c=xT(c,n),c=ST(c,n),u=Ov(u),u=xT(u,n),u=ST(u,n),c=MT(c),u=MT(u),n.isRawShaderMaterial!==!0&&(R=`#version 300 es `,S=[y,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+S,x=["#define varying in",n.glslVersion===_b?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===_b?"":"#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(` `)+` `+x);const w=R+S+c,E=R+x+u,P=_T(r,r.VERTEX_SHADER,w),I=_T(r,r.FRAGMENT_SHADER,E);r.attachShader(T,P),r.attachShader(T,I),n.index0AttributeName!==void 0?r.bindAttribLocation(T,0,n.index0AttributeName):n.morphTargets===!0&&r.bindAttribLocation(T,0,"position"),r.linkProgram(T);function U(F){if(e.debug.checkShaderErrors){const q=r.getProgramInfoLog(T).trim(),tt=r.getShaderInfoLog(P).trim(),ot=r.getShaderInfoLog(I).trim();let ct=!0,k=!0;if(r.getProgramParameter(T,r.LINK_STATUS)===!1)if(ct=!1,typeof e.debug.onShaderError=="function")e.debug.onShaderError(r,T,P,I);else{const Q=yT(r,P,"vertex"),j=yT(r,I,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(T,r.VALIDATE_STATUS)+` Material Name: `+F.name+` Material Type: `+F.type+` Program Info Log: `+q+` `+Q+` `+j)}else q!==""?console.warn("THREE.WebGLProgram: Program Info Log:",q):(tt===""||ot==="")&&(k=!1);k&&(F.diagnostics={runnable:ct,programLog:q,vertexShader:{log:tt,prefix:S},fragmentShader:{log:ot,prefix:x}})}r.deleteShader(P),r.deleteShader(I),B=new pp(r,T),D=yI(r,T)}let B;this.getUniforms=function(){return B===void 0&&U(this),B};let D;this.getAttributes=function(){return D===void 0&&U(this),D};let A=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=r.getProgramParameter(T,uI)),A},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(T),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=fI++,this.cacheKey=t,this.usedTimes=1,this.program=T,this.vertexShader=P,this.fragmentShader=I,this}let LI=0;class NI{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const n=t.vertexShader,i=t.fragmentShader,r=this._getShaderStage(n),o=this._getShaderStage(i),c=this._getShaderCacheForMaterial(t);return c.has(r)===!1&&(c.add(r),r.usedTimes++),c.has(o)===!1&&(c.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 UI(t),n.set(t,i)),i}}class UI{constructor(t){this.id=LI++,this.code=t,this.usedTimes=0}}function PI(e,t,n,i,r,o,c){const u=new v3,h=new NI,d=new Set,p=[],m=r.logarithmicDepthBuffer,_=r.vertexTextures;let y=r.precision;const M={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function T(D){return d.add(D),D===0?"uv":`uv${D}`}function S(D,A,F,q,tt){const ot=q.fog,ct=tt.geometry,k=D.isMeshStandardMaterial?q.environment:null,Q=(D.isMeshStandardMaterial?n:t).get(D.envMap||k),j=Q&&Q.mapping===qp?Q.image.height:null,pt=M[D.type];D.precision!==null&&(y=r.getMaxPrecision(D.precision),y!==D.precision&&console.warn("THREE.WebGLProgram.getParameters:",D.precision,"not supported, using",y,"instead."));const bt=ct.morphAttributes.position||ct.morphAttributes.normal||ct.morphAttributes.color,z=bt!==void 0?bt.length:0;let it=0;ct.morphAttributes.position!==void 0&&(it=1),ct.morphAttributes.normal!==void 0&&(it=2),ct.morphAttributes.color!==void 0&&(it=3);let Tt,J,dt,At;if(pt){const Be=vr[pt];Tt=Be.vertexShader,J=Be.fragmentShader}else Tt=D.vertexShader,J=D.fragmentShader,h.update(D),dt=h.getVertexShaderID(D),At=h.getFragmentShaderID(D);const xt=e.getRenderTarget(),Vt=e.state.buffers.depth.getReversed(),Gt=tt.isInstancedMesh===!0,$t=tt.isBatchedMesh===!0,Ke=!!D.map,Ge=!!D.matcap,ye=!!Q,H=!!D.aoMap,Wn=!!D.lightMap,xe=!!D.bumpMap,be=!!D.normalMap,Kt=!!D.displacementMap,Dt=!!D.emissiveMap,Et=!!D.metalnessMap,O=!!D.roughnessMap,C=D.anisotropy>0,$=D.clearcoat>0,ut=D.dispersion>0,St=D.iridescence>0,mt=D.sheen>0,Xt=D.transmission>0,Ct=C&&!!D.anisotropyMap,Lt=$&&!!D.clearcoatMap,Se=$&&!!D.clearcoatNormalMap,Rt=$&&!!D.clearcoatRoughnessMap,zt=St&&!!D.iridescenceMap,te=St&&!!D.iridescenceThicknessMap,qt=mt&&!!D.sheenColorMap,Bt=mt&&!!D.sheenRoughnessMap,oe=!!D.specularMap,pe=!!D.specularColorMap,$e=!!D.specularIntensityMap,Y=Xt&&!!D.transmissionMap,Nt=Xt&&!!D.thicknessMap,ft=!!D.gradientMap,yt=!!D.alphaMap,Ut=D.alphaTest>0,Pt=!!D.alphaHash,le=!!D.extensions;let pn=io;D.toneMapped&&(xt===null||xt.isXRRenderTarget===!0)&&(pn=e.toneMapping);const jn={shaderID:pt,shaderType:D.type,shaderName:D.name,vertexShader:Tt,fragmentShader:J,defines:D.defines,customVertexShaderID:dt,customFragmentShaderID:At,isRawShaderMaterial:D.isRawShaderMaterial===!0,glslVersion:D.glslVersion,precision:y,batching:$t,batchingColor:$t&&tt._colorsTexture!==null,instancing:Gt,instancingColor:Gt&&tt.instanceColor!==null,instancingMorph:Gt&&tt.morphTexture!==null,supportsVertexTextures:_,outputColorSpace:xt===null?e.outputColorSpace:xt.isXRRenderTarget===!0?xt.texture.colorSpace:Bi,alphaToCoverage:!!D.alphaToCoverage,map:Ke,matcap:Ge,envMap:ye,envMapMode:ye&&Q.mapping,envMapCubeUVHeight:j,aoMap:H,lightMap:Wn,bumpMap:xe,normalMap:be,displacementMap:_&&Kt,emissiveMap:Dt,normalMapObjectSpace:be&&D.normalMapType===L5,normalMapTangentSpace:be&&D.normalMapType===p3,metalnessMap:Et,roughnessMap:O,anisotropy:C,anisotropyMap:Ct,clearcoat:$,clearcoatMap:Lt,clearcoatNormalMap:Se,clearcoatRoughnessMap:Rt,dispersion:ut,iridescence:St,iridescenceMap:zt,iridescenceThicknessMap:te,sheen:mt,sheenColorMap:qt,sheenRoughnessMap:Bt,specularMap:oe,specularColorMap:pe,specularIntensityMap:$e,transmission:Xt,transmissionMap:Y,thicknessMap:Nt,gradientMap:ft,opaque:D.transparent===!1&&D.blending===Sc&&D.alphaToCoverage===!1,alphaMap:yt,alphaTest:Ut,alphaHash:Pt,combine:D.combine,mapUv:Ke&&T(D.map.channel),aoMapUv:H&&T(D.aoMap.channel),lightMapUv:Wn&&T(D.lightMap.channel),bumpMapUv:xe&&T(D.bumpMap.channel),normalMapUv:be&&T(D.normalMap.channel),displacementMapUv:Kt&&T(D.displacementMap.channel),emissiveMapUv:Dt&&T(D.emissiveMap.channel),metalnessMapUv:Et&&T(D.metalnessMap.channel),roughnessMapUv:O&&T(D.roughnessMap.channel),anisotropyMapUv:Ct&&T(D.anisotropyMap.channel),clearcoatMapUv:Lt&&T(D.clearcoatMap.channel),clearcoatNormalMapUv:Se&&T(D.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Rt&&T(D.clearcoatRoughnessMap.channel),iridescenceMapUv:zt&&T(D.iridescenceMap.channel),iridescenceThicknessMapUv:te&&T(D.iridescenceThicknessMap.channel),sheenColorMapUv:qt&&T(D.sheenColorMap.channel),sheenRoughnessMapUv:Bt&&T(D.sheenRoughnessMap.channel),specularMapUv:oe&&T(D.specularMap.channel),specularColorMapUv:pe&&T(D.specularColorMap.channel),specularIntensityMapUv:$e&&T(D.specularIntensityMap.channel),transmissionMapUv:Y&&T(D.transmissionMap.channel),thicknessMapUv:Nt&&T(D.thicknessMap.channel),alphaMapUv:yt&&T(D.alphaMap.channel),vertexTangents:!!ct.attributes.tangent&&(be||C),vertexColors:D.vertexColors,vertexAlphas:D.vertexColors===!0&&!!ct.attributes.color&&ct.attributes.color.itemSize===4,pointsUvs:tt.isPoints===!0&&!!ct.attributes.uv&&(Ke||yt),fog:!!ot,useFog:D.fog===!0,fogExp2:!!ot&&ot.isFogExp2,flatShading:D.flatShading===!0,sizeAttenuation:D.sizeAttenuation===!0,logarithmicDepthBuffer:m,reverseDepthBuffer:Vt,skinning:tt.isSkinnedMesh===!0,morphTargets:ct.morphAttributes.position!==void 0,morphNormals:ct.morphAttributes.normal!==void 0,morphColors:ct.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:it,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numClippingPlanes:c.numPlanes,numClipIntersection:c.numIntersection,dithering:D.dithering,shadowMapEnabled:e.shadowMap.enabled&&F.length>0,shadowMapType:e.shadowMap.type,toneMapping:pn,decodeVideoTexture:Ke&&D.map.isVideoTexture===!0&&Oe.getTransfer(D.map.colorSpace)===rn,decodeVideoTextureEmissive:Dt&&D.emissiveMap.isVideoTexture===!0&&Oe.getTransfer(D.emissiveMap.colorSpace)===rn,premultipliedAlpha:D.premultipliedAlpha,doubleSided:D.side===Ps,flipSided:D.side===Zi,useDepthPacking:D.depthPacking>=0,depthPacking:D.depthPacking||0,index0AttributeName:D.index0AttributeName,extensionClipCullDistance:le&&D.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(le&&D.extensions.multiDraw===!0||$t)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:D.customProgramCacheKey()};return jn.vertexUv1s=d.has(1),jn.vertexUv2s=d.has(2),jn.vertexUv3s=d.has(3),d.clear(),jn}function x(D){const A=[];if(D.shaderID?A.push(D.shaderID):(A.push(D.customVertexShaderID),A.push(D.customFragmentShaderID)),D.defines!==void 0)for(const F in D.defines)A.push(F),A.push(D.defines[F]);return D.isRawShaderMaterial===!1&&(R(A,D),w(A,D),A.push(e.outputColorSpace)),A.push(D.customProgramCacheKey),A.join()}function R(D,A){D.push(A.precision),D.push(A.outputColorSpace),D.push(A.envMapMode),D.push(A.envMapCubeUVHeight),D.push(A.mapUv),D.push(A.alphaMapUv),D.push(A.lightMapUv),D.push(A.aoMapUv),D.push(A.bumpMapUv),D.push(A.normalMapUv),D.push(A.displacementMapUv),D.push(A.emissiveMapUv),D.push(A.metalnessMapUv),D.push(A.roughnessMapUv),D.push(A.anisotropyMapUv),D.push(A.clearcoatMapUv),D.push(A.clearcoatNormalMapUv),D.push(A.clearcoatRoughnessMapUv),D.push(A.iridescenceMapUv),D.push(A.iridescenceThicknessMapUv),D.push(A.sheenColorMapUv),D.push(A.sheenRoughnessMapUv),D.push(A.specularMapUv),D.push(A.specularColorMapUv),D.push(A.specularIntensityMapUv),D.push(A.transmissionMapUv),D.push(A.thicknessMapUv),D.push(A.combine),D.push(A.fogExp2),D.push(A.sizeAttenuation),D.push(A.morphTargetsCount),D.push(A.morphAttributeCount),D.push(A.numDirLights),D.push(A.numPointLights),D.push(A.numSpotLights),D.push(A.numSpotLightMaps),D.push(A.numHemiLights),D.push(A.numRectAreaLights),D.push(A.numDirLightShadows),D.push(A.numPointLightShadows),D.push(A.numSpotLightShadows),D.push(A.numSpotLightShadowsWithMaps),D.push(A.numLightProbes),D.push(A.shadowMapType),D.push(A.toneMapping),D.push(A.numClippingPlanes),D.push(A.numClipIntersection),D.push(A.depthPacking)}function w(D,A){u.disableAll(),A.supportsVertexTextures&&u.enable(0),A.instancing&&u.enable(1),A.instancingColor&&u.enable(2),A.instancingMorph&&u.enable(3),A.matcap&&u.enable(4),A.envMap&&u.enable(5),A.normalMapObjectSpace&&u.enable(6),A.normalMapTangentSpace&&u.enable(7),A.clearcoat&&u.enable(8),A.iridescence&&u.enable(9),A.alphaTest&&u.enable(10),A.vertexColors&&u.enable(11),A.vertexAlphas&&u.enable(12),A.vertexUv1s&&u.enable(13),A.vertexUv2s&&u.enable(14),A.vertexUv3s&&u.enable(15),A.vertexTangents&&u.enable(16),A.anisotropy&&u.enable(17),A.alphaHash&&u.enable(18),A.batching&&u.enable(19),A.dispersion&&u.enable(20),A.batchingColor&&u.enable(21),D.push(u.mask),u.disableAll(),A.fog&&u.enable(0),A.useFog&&u.enable(1),A.flatShading&&u.enable(2),A.logarithmicDepthBuffer&&u.enable(3),A.reverseDepthBuffer&&u.enable(4),A.skinning&&u.enable(5),A.morphTargets&&u.enable(6),A.morphNormals&&u.enable(7),A.morphColors&&u.enable(8),A.premultipliedAlpha&&u.enable(9),A.shadowMapEnabled&&u.enable(10),A.doubleSided&&u.enable(11),A.flipSided&&u.enable(12),A.useDepthPacking&&u.enable(13),A.dithering&&u.enable(14),A.transmission&&u.enable(15),A.sheen&&u.enable(16),A.opaque&&u.enable(17),A.pointsUvs&&u.enable(18),A.decodeVideoTexture&&u.enable(19),A.decodeVideoTextureEmissive&&u.enable(20),A.alphaToCoverage&&u.enable(21),D.push(u.mask)}function E(D){const A=M[D.type];let F;if(A){const q=vr[A];F=bN.clone(q.uniforms)}else F=D.uniforms;return F}function P(D,A){let F;for(let q=0,tt=p.length;q0?i.push(x):y.transparent===!0?r.push(x):n.push(x)}function h(m,_,y,M,T,S){const x=c(m,_,y,M,T,S);y.transmission>0?i.unshift(x):y.transparent===!0?r.unshift(x):n.unshift(x)}function d(m,_){n.length>1&&n.sort(m||II),i.length>1&&i.sort(_||TT),r.length>1&&r.sort(_||TT)}function p(){for(let m=t,_=e.length;m<_;m++){const y=e[m];if(y.id===null)break;y.id=null,y.object=null,y.geometry=null,y.material=null,y.group=null}}return{opaque:n,transmissive:i,transparent:r,init:o,push:u,unshift:h,finish:p,sort:d}}function BI(){let e=new WeakMap;function t(i,r){const o=e.get(i);let c;return o===void 0?(c=new ET,e.set(i,[c])):r>=o.length?(c=new ET,o.push(c)):c=o[r],c}function n(){e=new WeakMap}return{get:t,dispose:n}}function FI(){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 he};break;case"SpotLight":n={position:new G,direction:new G,color:new he,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new G,color:new he,distance:0,decay:0};break;case"HemisphereLight":n={direction:new G,skyColor:new he,groundColor:new he};break;case"RectAreaLight":n={color:new he,position:new G,halfWidth:new G,halfHeight:new G};break}return e[t.id]=n,n}}}function kI(){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 Te};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}let zI=0;function VI(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function HI(e){const t=new FI,n=kI(),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 r=new G,o=new ve,c=new ve;function u(d){let p=0,m=0,_=0;for(let D=0;D<9;D++)i.probe[D].set(0,0,0);let y=0,M=0,T=0,S=0,x=0,R=0,w=0,E=0,P=0,I=0,U=0;d.sort(VI);for(let D=0,A=d.length;D0&&(e.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=It.LTC_FLOAT_1,i.rectAreaLTC2=It.LTC_FLOAT_2):(i.rectAreaLTC1=It.LTC_HALF_1,i.rectAreaLTC2=It.LTC_HALF_2)),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=_;const B=i.hash;(B.directionalLength!==y||B.pointLength!==M||B.spotLength!==T||B.rectAreaLength!==S||B.hemiLength!==x||B.numDirectionalShadows!==R||B.numPointShadows!==w||B.numSpotShadows!==E||B.numSpotMaps!==P||B.numLightProbes!==U)&&(i.directional.length=y,i.spot.length=T,i.rectArea.length=S,i.point.length=M,i.hemi.length=x,i.directionalShadow.length=R,i.directionalShadowMap.length=R,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=R,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=E+P-I,i.spotLightMap.length=P,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=U,B.directionalLength=y,B.pointLength=M,B.spotLength=T,B.rectAreaLength=S,B.hemiLength=x,B.numDirectionalShadows=R,B.numPointShadows=w,B.numSpotShadows=E,B.numSpotMaps=P,B.numLightProbes=U,i.version=zI++)}function h(d,p){let m=0,_=0,y=0,M=0,T=0;const S=p.matrixWorldInverse;for(let x=0,R=d.length;x=c.length?(u=new AT(e),c.push(u)):u=c[o],u}function i(){t=new WeakMap}return{get:n,dispose:i}}const WI=`void main() { gl_Position = vec4( position, 1.0 ); }`,jI=`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 XI(e,t,n){let i=new z1;const r=new Te,o=new Te,c=new Xe,u=new kN({depthPacking:D5}),h=new zN,d={},p=n.maxTextureSize,m={[ua]:Zi,[Zi]:ua,[Ps]:Ps},_=new ro({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Te},radius:{value:4}},vertexShader:WI,fragmentShader:jI}),y=_.clone();y.defines.HORIZONTAL_PASS=1;const M=new Qi;M.setAttribute("position",new Ii(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const T=new qe(M,_),S=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=t3;let x=this.type;this.render=function(I,U,B){if(S.enabled===!1||S.autoUpdate===!1&&S.needsUpdate===!1||I.length===0)return;const D=e.getRenderTarget(),A=e.getActiveCubeFace(),F=e.getActiveMipmapLevel(),q=e.state;q.setBlending(no),q.buffers.color.setClear(1,1,1,1),q.buffers.depth.setTest(!0),q.setScissorTest(!1);const tt=x!==sa&&this.type===sa,ot=x===sa&&this.type!==sa;for(let ct=0,k=I.length;ctp||r.y>p)&&(r.x>p&&(o.x=Math.floor(p/pt.x),r.x=o.x*pt.x,j.mapSize.x=o.x),r.y>p&&(o.y=Math.floor(p/pt.y),r.y=o.y*pt.y,j.mapSize.y=o.y)),j.map===null||tt===!0||ot===!0){const z=this.type!==sa?{minFilter:Oi,magFilter:Oi}:{};j.map!==null&&j.map.dispose(),j.map=new ol(r.x,r.y,z),j.map.texture.name=Q.name+".shadowMap",j.camera.updateProjectionMatrix()}e.setRenderTarget(j.map),e.clear();const bt=j.getViewportCount();for(let z=0;z0||U.map&&U.alphaTest>0){const q=A.uuid,tt=U.uuid;let ot=d[q];ot===void 0&&(ot={},d[q]=ot);let ct=ot[tt];ct===void 0&&(ct=A.clone(),ot[tt]=ct,U.addEventListener("dispose",P)),A=ct}if(A.visible=U.visible,A.wireframe=U.wireframe,D===sa?A.side=U.shadowSide!==null?U.shadowSide:U.side:A.side=U.shadowSide!==null?U.shadowSide:m[U.side],A.alphaMap=U.alphaMap,A.alphaTest=U.alphaTest,A.map=U.map,A.clipShadows=U.clipShadows,A.clippingPlanes=U.clippingPlanes,A.clipIntersection=U.clipIntersection,A.displacementMap=U.displacementMap,A.displacementScale=U.displacementScale,A.displacementBias=U.displacementBias,A.wireframeLinewidth=U.wireframeLinewidth,A.linewidth=U.linewidth,B.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const q=e.properties.get(A);q.light=B}return A}function E(I,U,B,D,A){if(I.visible===!1)return;if(I.layers.test(U.layers)&&(I.isMesh||I.isLine||I.isPoints)&&(I.castShadow||I.receiveShadow&&A===sa)&&(!I.frustumCulled||i.intersectsObject(I))){I.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,I.matrixWorld);const tt=t.update(I),ot=I.material;if(Array.isArray(ot)){const ct=tt.groups;for(let k=0,Q=ct.length;k=1):j.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),k=Q>=2);let pt=null,bt={};const z=e.getParameter(e.SCISSOR_BOX),it=e.getParameter(e.VIEWPORT),Tt=new Xe().fromArray(z),J=new Xe().fromArray(it);function dt(Y,Nt,ft,yt){const Ut=new Uint8Array(4),Pt=e.createTexture();e.bindTexture(Y,Pt),e.texParameteri(Y,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(Y,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let le=0;le"u"?!1:/OculusBrowser/g.test(navigator.userAgent),d=new Te,p=new WeakMap;let m;const _=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(O,C){return y?new OffscreenCanvas(O,C):Wf("canvas")}function T(O,C,$){let ut=1;const St=Et(O);if((St.width>$||St.height>$)&&(ut=$/Math.max(St.width,St.height)),ut<1)if(typeof HTMLImageElement<"u"&&O instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&O instanceof ImageBitmap||typeof VideoFrame<"u"&&O instanceof VideoFrame){const mt=Math.floor(ut*St.width),Xt=Math.floor(ut*St.height);m===void 0&&(m=M(mt,Xt));const Ct=C?M(mt,Xt):m;return Ct.width=mt,Ct.height=Xt,Ct.getContext("2d").drawImage(O,0,0,mt,Xt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+St.width+"x"+St.height+") to ("+mt+"x"+Xt+")."),Ct}else return"data"in O&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+St.width+"x"+St.height+")."),O;return O}function S(O){return O.generateMipmaps}function x(O){e.generateMipmap(O)}function R(O){return O.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:O.isWebGL3DRenderTarget?e.TEXTURE_3D:O.isWebGLArrayRenderTarget||O.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function w(O,C,$,ut,St=!1){if(O!==null){if(e[O]!==void 0)return e[O];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+O+"'")}let mt=C;if(C===e.RED&&($===e.FLOAT&&(mt=e.R32F),$===e.HALF_FLOAT&&(mt=e.R16F),$===e.UNSIGNED_BYTE&&(mt=e.R8)),C===e.RED_INTEGER&&($===e.UNSIGNED_BYTE&&(mt=e.R8UI),$===e.UNSIGNED_SHORT&&(mt=e.R16UI),$===e.UNSIGNED_INT&&(mt=e.R32UI),$===e.BYTE&&(mt=e.R8I),$===e.SHORT&&(mt=e.R16I),$===e.INT&&(mt=e.R32I)),C===e.RG&&($===e.FLOAT&&(mt=e.RG32F),$===e.HALF_FLOAT&&(mt=e.RG16F),$===e.UNSIGNED_BYTE&&(mt=e.RG8)),C===e.RG_INTEGER&&($===e.UNSIGNED_BYTE&&(mt=e.RG8UI),$===e.UNSIGNED_SHORT&&(mt=e.RG16UI),$===e.UNSIGNED_INT&&(mt=e.RG32UI),$===e.BYTE&&(mt=e.RG8I),$===e.SHORT&&(mt=e.RG16I),$===e.INT&&(mt=e.RG32I)),C===e.RGB_INTEGER&&($===e.UNSIGNED_BYTE&&(mt=e.RGB8UI),$===e.UNSIGNED_SHORT&&(mt=e.RGB16UI),$===e.UNSIGNED_INT&&(mt=e.RGB32UI),$===e.BYTE&&(mt=e.RGB8I),$===e.SHORT&&(mt=e.RGB16I),$===e.INT&&(mt=e.RGB32I)),C===e.RGBA_INTEGER&&($===e.UNSIGNED_BYTE&&(mt=e.RGBA8UI),$===e.UNSIGNED_SHORT&&(mt=e.RGBA16UI),$===e.UNSIGNED_INT&&(mt=e.RGBA32UI),$===e.BYTE&&(mt=e.RGBA8I),$===e.SHORT&&(mt=e.RGBA16I),$===e.INT&&(mt=e.RGBA32I)),C===e.RGB&&$===e.UNSIGNED_INT_5_9_9_9_REV&&(mt=e.RGB9_E5),C===e.RGBA){const Xt=St?wp:Oe.getTransfer(ut);$===e.FLOAT&&(mt=e.RGBA32F),$===e.HALF_FLOAT&&(mt=e.RGBA16F),$===e.UNSIGNED_BYTE&&(mt=Xt===rn?e.SRGB8_ALPHA8:e.RGBA8),$===e.UNSIGNED_SHORT_4_4_4_4&&(mt=e.RGBA4),$===e.UNSIGNED_SHORT_5_5_5_1&&(mt=e.RGB5_A1)}return(mt===e.R16F||mt===e.R32F||mt===e.RG16F||mt===e.RG32F||mt===e.RGBA16F||mt===e.RGBA32F)&&t.get("EXT_color_buffer_float"),mt}function E(O,C){let $;return O?C===null||C===al||C===Lc?$=e.DEPTH24_STENCIL8:C===tr?$=e.DEPTH32F_STENCIL8:C===Vf&&($=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):C===null||C===al||C===Lc?$=e.DEPTH_COMPONENT24:C===tr?$=e.DEPTH_COMPONENT32F:C===Vf&&($=e.DEPTH_COMPONENT16),$}function P(O,C){return S(O)===!0||O.isFramebufferTexture&&O.minFilter!==Oi&&O.minFilter!==hs?Math.log2(Math.max(C.width,C.height))+1:O.mipmaps!==void 0&&O.mipmaps.length>0?O.mipmaps.length:O.isCompressedTexture&&Array.isArray(O.image)?C.mipmaps.length:1}function I(O){const C=O.target;C.removeEventListener("dispose",I),B(C),C.isVideoTexture&&p.delete(C)}function U(O){const C=O.target;C.removeEventListener("dispose",U),A(C)}function B(O){const C=i.get(O);if(C.__webglInit===void 0)return;const $=O.source,ut=_.get($);if(ut){const St=ut[C.__cacheKey];St.usedTimes--,St.usedTimes===0&&D(O),Object.keys(ut).length===0&&_.delete($)}i.remove(O)}function D(O){const C=i.get(O);e.deleteTexture(C.__webglTexture);const $=O.source,ut=_.get($);delete ut[C.__cacheKey],c.memory.textures--}function A(O){const C=i.get(O);if(O.depthTexture&&(O.depthTexture.dispose(),i.remove(O.depthTexture)),O.isWebGLCubeRenderTarget)for(let ut=0;ut<6;ut++){if(Array.isArray(C.__webglFramebuffer[ut]))for(let St=0;St=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+O+" texture units while this GPU supports only "+r.maxTextures),F+=1,O}function ot(O){const C=[];return C.push(O.wrapS),C.push(O.wrapT),C.push(O.wrapR||0),C.push(O.magFilter),C.push(O.minFilter),C.push(O.anisotropy),C.push(O.internalFormat),C.push(O.format),C.push(O.type),C.push(O.generateMipmaps),C.push(O.premultiplyAlpha),C.push(O.flipY),C.push(O.unpackAlignment),C.push(O.colorSpace),C.join()}function ct(O,C){const $=i.get(O);if(O.isVideoTexture&&Kt(O),O.isRenderTargetTexture===!1&&O.version>0&&$.__version!==O.version){const ut=O.image;if(ut===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ut.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{J($,O,C);return}}n.bindTexture(e.TEXTURE_2D,$.__webglTexture,e.TEXTURE0+C)}function k(O,C){const $=i.get(O);if(O.version>0&&$.__version!==O.version){J($,O,C);return}n.bindTexture(e.TEXTURE_2D_ARRAY,$.__webglTexture,e.TEXTURE0+C)}function Q(O,C){const $=i.get(O);if(O.version>0&&$.__version!==O.version){J($,O,C);return}n.bindTexture(e.TEXTURE_3D,$.__webglTexture,e.TEXTURE0+C)}function j(O,C){const $=i.get(O);if(O.version>0&&$.__version!==O.version){dt($,O,C);return}n.bindTexture(e.TEXTURE_CUBE_MAP,$.__webglTexture,e.TEXTURE0+C)}const pt={[Dc]:e.REPEAT,[$a]:e.CLAMP_TO_EDGE,[Ep]:e.MIRRORED_REPEAT},bt={[Oi]:e.NEAREST,[i3]:e.NEAREST_MIPMAP_NEAREST,[Tf]:e.NEAREST_MIPMAP_LINEAR,[hs]:e.LINEAR,[lp]:e.LINEAR_MIPMAP_NEAREST,[oa]:e.LINEAR_MIPMAP_LINEAR},z={[N5]:e.NEVER,[F5]:e.ALWAYS,[U5]:e.LESS,[m3]:e.LEQUAL,[P5]:e.EQUAL,[B5]:e.GEQUAL,[O5]:e.GREATER,[I5]:e.NOTEQUAL};function it(O,C){if(C.type===tr&&t.has("OES_texture_float_linear")===!1&&(C.magFilter===hs||C.magFilter===lp||C.magFilter===Tf||C.magFilter===oa||C.minFilter===hs||C.minFilter===lp||C.minFilter===Tf||C.minFilter===oa)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(O,e.TEXTURE_WRAP_S,pt[C.wrapS]),e.texParameteri(O,e.TEXTURE_WRAP_T,pt[C.wrapT]),(O===e.TEXTURE_3D||O===e.TEXTURE_2D_ARRAY)&&e.texParameteri(O,e.TEXTURE_WRAP_R,pt[C.wrapR]),e.texParameteri(O,e.TEXTURE_MAG_FILTER,bt[C.magFilter]),e.texParameteri(O,e.TEXTURE_MIN_FILTER,bt[C.minFilter]),C.compareFunction&&(e.texParameteri(O,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(O,e.TEXTURE_COMPARE_FUNC,z[C.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(C.magFilter===Oi||C.minFilter!==Tf&&C.minFilter!==oa||C.type===tr&&t.has("OES_texture_float_linear")===!1)return;if(C.anisotropy>1||i.get(C).__currentAnisotropy){const $=t.get("EXT_texture_filter_anisotropic");e.texParameterf(O,$.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(C.anisotropy,r.getMaxAnisotropy())),i.get(C).__currentAnisotropy=C.anisotropy}}}function Tt(O,C){let $=!1;O.__webglInit===void 0&&(O.__webglInit=!0,C.addEventListener("dispose",I));const ut=C.source;let St=_.get(ut);St===void 0&&(St={},_.set(ut,St));const mt=ot(C);if(mt!==O.__cacheKey){St[mt]===void 0&&(St[mt]={texture:e.createTexture(),usedTimes:0},c.memory.textures++,$=!0),St[mt].usedTimes++;const Xt=St[O.__cacheKey];Xt!==void 0&&(St[O.__cacheKey].usedTimes--,Xt.usedTimes===0&&D(C)),O.__cacheKey=mt,O.__webglTexture=St[mt].texture}return $}function J(O,C,$){let ut=e.TEXTURE_2D;(C.isDataArrayTexture||C.isCompressedArrayTexture)&&(ut=e.TEXTURE_2D_ARRAY),C.isData3DTexture&&(ut=e.TEXTURE_3D);const St=Tt(O,C),mt=C.source;n.bindTexture(ut,O.__webglTexture,e.TEXTURE0+$);const Xt=i.get(mt);if(mt.version!==Xt.__version||St===!0){n.activeTexture(e.TEXTURE0+$);const Ct=Oe.getPrimaries(Oe.workingColorSpace),Lt=C.colorSpace===Qa?null:Oe.getPrimaries(C.colorSpace),Se=C.colorSpace===Qa||Ct===Lt?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,C.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,C.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,C.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Se);let Rt=T(C.image,!1,r.maxTextureSize);Rt=Dt(C,Rt);const zt=o.convert(C.format,C.colorSpace),te=o.convert(C.type);let qt=w(C.internalFormat,zt,te,C.colorSpace,C.isVideoTexture);it(ut,C);let Bt;const oe=C.mipmaps,pe=C.isVideoTexture!==!0,$e=Xt.__version===void 0||St===!0,Y=mt.dataReady,Nt=P(C,Rt);if(C.isDepthTexture)qt=E(C.format===Nc,C.type),$e&&(pe?n.texStorage2D(e.TEXTURE_2D,1,qt,Rt.width,Rt.height):n.texImage2D(e.TEXTURE_2D,0,qt,Rt.width,Rt.height,0,zt,te,null));else if(C.isDataTexture)if(oe.length>0){pe&&$e&&n.texStorage2D(e.TEXTURE_2D,Nt,qt,oe[0].width,oe[0].height);for(let ft=0,yt=oe.length;ft0){const Ut=nT(Bt.width,Bt.height,C.format,C.type);for(const Pt of C.layerUpdates){const le=Bt.data.subarray(Pt*Ut/Bt.data.BYTES_PER_ELEMENT,(Pt+1)*Ut/Bt.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ft,0,0,Pt,Bt.width,Bt.height,1,zt,le)}C.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ft,0,0,0,Bt.width,Bt.height,Rt.depth,zt,Bt.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ft,qt,Bt.width,Bt.height,Rt.depth,0,Bt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else pe?Y&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,ft,0,0,0,Bt.width,Bt.height,Rt.depth,zt,te,Bt.data):n.texImage3D(e.TEXTURE_2D_ARRAY,ft,qt,Bt.width,Bt.height,Rt.depth,0,zt,te,Bt.data)}else{pe&&$e&&n.texStorage2D(e.TEXTURE_2D,Nt,qt,oe[0].width,oe[0].height);for(let ft=0,yt=oe.length;ft0){const ft=nT(Rt.width,Rt.height,C.format,C.type);for(const yt of C.layerUpdates){const Ut=Rt.data.subarray(yt*ft/Rt.data.BYTES_PER_ELEMENT,(yt+1)*ft/Rt.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,yt,Rt.width,Rt.height,1,zt,te,Ut)}C.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,Rt.width,Rt.height,Rt.depth,zt,te,Rt.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,qt,Rt.width,Rt.height,Rt.depth,0,zt,te,Rt.data);else if(C.isData3DTexture)pe?($e&&n.texStorage3D(e.TEXTURE_3D,Nt,qt,Rt.width,Rt.height,Rt.depth),Y&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,Rt.width,Rt.height,Rt.depth,zt,te,Rt.data)):n.texImage3D(e.TEXTURE_3D,0,qt,Rt.width,Rt.height,Rt.depth,0,zt,te,Rt.data);else if(C.isFramebufferTexture){if($e)if(pe)n.texStorage2D(e.TEXTURE_2D,Nt,qt,Rt.width,Rt.height);else{let ft=Rt.width,yt=Rt.height;for(let Ut=0;Ut>=1,yt>>=1}}else if(oe.length>0){if(pe&&$e){const ft=Et(oe[0]);n.texStorage2D(e.TEXTURE_2D,Nt,qt,ft.width,ft.height)}for(let ft=0,yt=oe.length;ft0&&Nt++;const yt=Et(zt[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,Nt,oe,yt.width,yt.height)}for(let yt=0;yt<6;yt++)if(Rt){pe?Y&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+yt,0,0,0,zt[yt].width,zt[yt].height,qt,Bt,zt[yt].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+yt,0,oe,zt[yt].width,zt[yt].height,0,qt,Bt,zt[yt].data);for(let Ut=0;Ut>mt),te=Math.max(1,C.height>>mt);St===e.TEXTURE_3D||St===e.TEXTURE_2D_ARRAY?n.texImage3D(St,mt,Lt,zt,te,C.depth,0,Xt,Ct,null):n.texImage2D(St,mt,Lt,zt,te,0,Xt,Ct,null)}n.bindFramebuffer(e.FRAMEBUFFER,O),be(C)?u.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,ut,St,Rt.__webglTexture,0,xe(C)):(St===e.TEXTURE_2D||St>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&St<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,ut,St,Rt.__webglTexture,mt),n.bindFramebuffer(e.FRAMEBUFFER,null)}function xt(O,C,$){if(e.bindRenderbuffer(e.RENDERBUFFER,O),C.depthBuffer){const ut=C.depthTexture,St=ut&&ut.isDepthTexture?ut.type:null,mt=E(C.stencilBuffer,St),Xt=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,Ct=xe(C);be(C)?u.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ct,mt,C.width,C.height):$?e.renderbufferStorageMultisample(e.RENDERBUFFER,Ct,mt,C.width,C.height):e.renderbufferStorage(e.RENDERBUFFER,mt,C.width,C.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,Xt,e.RENDERBUFFER,O)}else{const ut=C.textures;for(let St=0;St{delete C.__boundDepthTexture,delete C.__depthDisposeCallback,ut.removeEventListener("dispose",St)};ut.addEventListener("dispose",St),C.__depthDisposeCallback=St}C.__boundDepthTexture=ut}if(O.depthTexture&&!C.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");Vt(C.__webglFramebuffer,O)}else if($){C.__webglDepthbuffer=[];for(let ut=0;ut<6;ut++)if(n.bindFramebuffer(e.FRAMEBUFFER,C.__webglFramebuffer[ut]),C.__webglDepthbuffer[ut]===void 0)C.__webglDepthbuffer[ut]=e.createRenderbuffer(),xt(C.__webglDepthbuffer[ut],O,!1);else{const St=O.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,mt=C.__webglDepthbuffer[ut];e.bindRenderbuffer(e.RENDERBUFFER,mt),e.framebufferRenderbuffer(e.FRAMEBUFFER,St,e.RENDERBUFFER,mt)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,C.__webglFramebuffer),C.__webglDepthbuffer===void 0)C.__webglDepthbuffer=e.createRenderbuffer(),xt(C.__webglDepthbuffer,O,!1);else{const ut=O.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,St=C.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,St),e.framebufferRenderbuffer(e.FRAMEBUFFER,ut,e.RENDERBUFFER,St)}n.bindFramebuffer(e.FRAMEBUFFER,null)}function $t(O,C,$){const ut=i.get(O);C!==void 0&&At(ut.__webglFramebuffer,O,O.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),$!==void 0&&Gt(O)}function Ke(O){const C=O.texture,$=i.get(O),ut=i.get(C);O.addEventListener("dispose",U);const St=O.textures,mt=O.isWebGLCubeRenderTarget===!0,Xt=St.length>1;if(Xt||(ut.__webglTexture===void 0&&(ut.__webglTexture=e.createTexture()),ut.__version=C.version,c.memory.textures++),mt){$.__webglFramebuffer=[];for(let Ct=0;Ct<6;Ct++)if(C.mipmaps&&C.mipmaps.length>0){$.__webglFramebuffer[Ct]=[];for(let Lt=0;Lt0){$.__webglFramebuffer=[];for(let Ct=0;Ct0&&be(O)===!1){$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,$.__webglMultisampledFramebuffer);for(let Ct=0;Ct0)for(let Lt=0;Lt0)for(let Lt=0;Lt0){if(be(O)===!1){const C=O.textures,$=O.width,ut=O.height;let St=e.COLOR_BUFFER_BIT;const mt=O.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,Xt=i.get(O),Ct=C.length>1;if(Ct)for(let Lt=0;Lt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&C.__useRenderToTexture!==!1}function Kt(O){const C=c.render.frame;p.get(O)!==C&&(p.set(O,C),O.update())}function Dt(O,C){const $=O.colorSpace,ut=O.format,St=O.type;return O.isCompressedTexture===!0||O.isVideoTexture===!0||$!==Bi&&$!==Qa&&(Oe.getTransfer($)===rn?(ut!==Os||St!==fa)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",$)),C}function Et(O){return typeof HTMLImageElement<"u"&&O instanceof HTMLImageElement?(d.width=O.naturalWidth||O.width,d.height=O.naturalHeight||O.height):typeof VideoFrame<"u"&&O instanceof VideoFrame?(d.width=O.displayWidth,d.height=O.displayHeight):(d.width=O.width,d.height=O.height),d}this.allocateTextureUnit=tt,this.resetTextureUnits=q,this.setTexture2D=ct,this.setTexture2DArray=k,this.setTexture3D=Q,this.setTextureCube=j,this.rebindTextures=$t,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=Ge,this.updateMultisampleRenderTarget=Wn,this.setupDepthRenderbuffer=Gt,this.setupFrameBufferTexture=At,this.useMultisampledRTT=be}function ZI(e,t){function n(i,r=Qa){let o;const c=Oe.getTransfer(r);if(i===fa)return e.UNSIGNED_BYTE;if(i===C1)return e.UNSIGNED_SHORT_4_4_4_4;if(i===D1)return e.UNSIGNED_SHORT_5_5_5_1;if(i===a3)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===s3)return e.BYTE;if(i===r3)return e.SHORT;if(i===Vf)return e.UNSIGNED_SHORT;if(i===R1)return e.INT;if(i===al)return e.UNSIGNED_INT;if(i===tr)return e.FLOAT;if(i===th)return e.HALF_FLOAT;if(i===o3)return e.ALPHA;if(i===l3)return e.RGB;if(i===Os)return e.RGBA;if(i===c3)return e.LUMINANCE;if(i===u3)return e.LUMINANCE_ALPHA;if(i===Mc)return e.DEPTH_COMPONENT;if(i===Nc)return e.DEPTH_STENCIL;if(i===L1)return e.RED;if(i===N1)return e.RED_INTEGER;if(i===f3)return e.RG;if(i===U1)return e.RG_INTEGER;if(i===P1)return e.RGBA_INTEGER;if(i===cp||i===up||i===fp||i===hp)if(c===rn)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(i===cp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===up)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===fp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===hp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(i===cp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===up)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===fp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===hp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===sv||i===rv||i===av||i===ov)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(i===sv)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===rv)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===av)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ov)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===lv||i===cv||i===uv)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(i===lv||i===cv)return c===rn?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(i===uv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===fv||i===hv||i===dv||i===pv||i===mv||i===gv||i===_v||i===vv||i===yv||i===xv||i===Sv||i===Mv||i===bv||i===Tv)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(i===fv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===hv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===dv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===pv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===mv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===gv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===_v)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===vv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===yv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===xv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Sv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Mv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===bv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Tv)return c===rn?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===dp||i===Ev||i===Av)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(i===dp)return c===rn?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ev)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Av)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===h3||i===wv||i===Rv||i===Cv)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(i===dp)return o.COMPRESSED_RED_RGTC1_EXT;if(i===wv)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Rv)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Cv)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Lc?e.UNSIGNED_INT_24_8:e[i]!==void 0?e[i]:null}return{convert:n}}const QI=` void main() { gl_Position = vec4( position, 1.0 ); }`,JI=` 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 $I{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,n,i){if(this.texture===null){const r=new Zn,o=t.properties.get(r);o.__webglTexture=n.texture,(n.depthNear!==i.depthNear||n.depthFar!==i.depthFar)&&(this.depthNear=n.depthNear,this.depthFar=n.depthFar),this.texture=r}}getMesh(t){if(this.texture!==null&&this.mesh===null){const n=t.cameras[0].viewport,i=new ro({vertexShader:QI,fragmentShader:JI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new qe(new Kp(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class tB extends hl{constructor(t,n){super();const i=this;let r=null,o=1,c=null,u="local-floor",h=1,d=null,p=null,m=null,_=null,y=null,M=null;const T=new $I,S=n.getContextAttributes();let x=null,R=null;const w=[],E=[],P=new Te;let I=null;const U=new Ni;U.viewport=new Xe;const B=new Ni;B.viewport=new Xe;const D=[U,B],A=new aU;let F=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let dt=w[J];return dt===void 0&&(dt=new s_,w[J]=dt),dt.getTargetRaySpace()},this.getControllerGrip=function(J){let dt=w[J];return dt===void 0&&(dt=new s_,w[J]=dt),dt.getGripSpace()},this.getHand=function(J){let dt=w[J];return dt===void 0&&(dt=new s_,w[J]=dt),dt.getHandSpace()};function tt(J){const dt=E.indexOf(J.inputSource);if(dt===-1)return;const At=w[dt];At!==void 0&&(At.update(J.inputSource,J.frame,d||c),At.dispatchEvent({type:J.type,data:J.inputSource}))}function ot(){r.removeEventListener("select",tt),r.removeEventListener("selectstart",tt),r.removeEventListener("selectend",tt),r.removeEventListener("squeeze",tt),r.removeEventListener("squeezestart",tt),r.removeEventListener("squeezeend",tt),r.removeEventListener("end",ot),r.removeEventListener("inputsourceschange",ct);for(let J=0;J=0&&(E[xt]=null,w[xt].disconnect(At))}for(let dt=0;dt=E.length){E.push(At),xt=Gt;break}else if(E[Gt]===null){E[Gt]=At,xt=Gt;break}if(xt===-1)break}const Vt=w[xt];Vt&&Vt.connect(At)}}const k=new G,Q=new G;function j(J,dt,At){k.setFromMatrixPosition(dt.matrixWorld),Q.setFromMatrixPosition(At.matrixWorld);const xt=k.distanceTo(Q),Vt=dt.projectionMatrix.elements,Gt=At.projectionMatrix.elements,$t=Vt[14]/(Vt[10]-1),Ke=Vt[14]/(Vt[10]+1),Ge=(Vt[9]+1)/Vt[5],ye=(Vt[9]-1)/Vt[5],H=(Vt[8]-1)/Vt[0],Wn=(Gt[8]+1)/Gt[0],xe=$t*H,be=$t*Wn,Kt=xt/(-H+Wn),Dt=Kt*-H;if(dt.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Dt),J.translateZ(Kt),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),Vt[10]===-1)J.projectionMatrix.copy(dt.projectionMatrix),J.projectionMatrixInverse.copy(dt.projectionMatrixInverse);else{const Et=$t+Kt,O=Ke+Kt,C=xe-Dt,$=be+(xt-Dt),ut=Ge*Ke/O*Et,St=ye*Ke/O*Et;J.projectionMatrix.makePerspective(C,$,ut,St,Et,O),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function pt(J,dt){dt===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(dt.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(r===null)return;let dt=J.near,At=J.far;T.texture!==null&&(T.depthNear>0&&(dt=T.depthNear),T.depthFar>0&&(At=T.depthFar)),A.near=B.near=U.near=dt,A.far=B.far=U.far=At,(F!==A.near||q!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),F=A.near,q=A.far),U.layers.mask=J.layers.mask|2,B.layers.mask=J.layers.mask|4,A.layers.mask=U.layers.mask|B.layers.mask;const xt=J.parent,Vt=A.cameras;pt(A,xt);for(let Gt=0;Gt0&&(S.alphaTest.value=x.alphaTest);const R=t.get(x),w=R.envMap,E=R.envMapRotation;w&&(S.envMap.value=w,Bo.copy(E),Bo.x*=-1,Bo.y*=-1,Bo.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Bo.y*=-1,Bo.z*=-1),S.envMapRotation.value.setFromMatrix4(eB.makeRotationFromEuler(Bo)),S.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=x.reflectivity,S.ior.value=x.ior,S.refractionRatio.value=x.refractionRatio),x.lightMap&&(S.lightMap.value=x.lightMap,S.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,S.lightMapTransform)),x.aoMap&&(S.aoMap.value=x.aoMap,S.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,S.aoMapTransform))}function c(S,x){S.diffuse.value.copy(x.color),S.opacity.value=x.opacity,x.map&&(S.map.value=x.map,n(x.map,S.mapTransform))}function u(S,x){S.dashSize.value=x.dashSize,S.totalSize.value=x.dashSize+x.gapSize,S.scale.value=x.scale}function h(S,x,R,w){S.diffuse.value.copy(x.color),S.opacity.value=x.opacity,S.size.value=x.size*R,S.scale.value=w*.5,x.map&&(S.map.value=x.map,n(x.map,S.uvTransform)),x.alphaMap&&(S.alphaMap.value=x.alphaMap,n(x.alphaMap,S.alphaMapTransform)),x.alphaTest>0&&(S.alphaTest.value=x.alphaTest)}function d(S,x){S.diffuse.value.copy(x.color),S.opacity.value=x.opacity,S.rotation.value=x.rotation,x.map&&(S.map.value=x.map,n(x.map,S.mapTransform)),x.alphaMap&&(S.alphaMap.value=x.alphaMap,n(x.alphaMap,S.alphaMapTransform)),x.alphaTest>0&&(S.alphaTest.value=x.alphaTest)}function p(S,x){S.specular.value.copy(x.specular),S.shininess.value=Math.max(x.shininess,1e-4)}function m(S,x){x.gradientMap&&(S.gradientMap.value=x.gradientMap)}function _(S,x){S.metalness.value=x.metalness,x.metalnessMap&&(S.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,S.metalnessMapTransform)),S.roughness.value=x.roughness,x.roughnessMap&&(S.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,S.roughnessMapTransform)),x.envMap&&(S.envMapIntensity.value=x.envMapIntensity)}function y(S,x,R){S.ior.value=x.ior,x.sheen>0&&(S.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),S.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(S.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,S.sheenColorMapTransform)),x.sheenRoughnessMap&&(S.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,S.sheenRoughnessMapTransform))),x.clearcoat>0&&(S.clearcoat.value=x.clearcoat,S.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(S.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,S.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(S.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Zi&&S.clearcoatNormalScale.value.negate())),x.dispersion>0&&(S.dispersion.value=x.dispersion),x.iridescence>0&&(S.iridescence.value=x.iridescence,S.iridescenceIOR.value=x.iridescenceIOR,S.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(S.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,S.iridescenceMapTransform)),x.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),x.transmission>0&&(S.transmission.value=x.transmission,S.transmissionSamplerMap.value=R.texture,S.transmissionSamplerSize.value.set(R.width,R.height),x.transmissionMap&&(S.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,S.transmissionMapTransform)),S.thickness.value=x.thickness,x.thicknessMap&&(S.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=x.attenuationDistance,S.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(S.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(S.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,S.anisotropyMapTransform))),S.specularIntensity.value=x.specularIntensity,S.specularColor.value.copy(x.specularColor),x.specularColorMap&&(S.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,S.specularColorMapTransform)),x.specularIntensityMap&&(S.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,S.specularIntensityMapTransform))}function M(S,x){x.matcap&&(S.matcap.value=x.matcap)}function T(S,x){const R=t.get(x).light;S.referencePosition.value.setFromMatrixPosition(R.matrixWorld),S.nearDistance.value=R.shadow.camera.near,S.farDistance.value=R.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function iB(e,t,n,i){let r={},o={},c=[];const u=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function h(R,w){const E=w.program;i.uniformBlockBinding(R,E)}function d(R,w){let E=r[R.id];E===void 0&&(M(R),E=p(R),r[R.id]=E,R.addEventListener("dispose",S));const P=w.program;i.updateUBOMapping(R,P);const I=t.render.frame;o[R.id]!==I&&(_(R),o[R.id]=I)}function p(R){const w=m();R.__bindingPointIndex=w;const E=e.createBuffer(),P=R.__size,I=R.usage;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,P,I),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,E),E}function m(){for(let R=0;R0&&(E+=P-I),R.__size=E,R.__cache={},this}function T(R){const w={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(w.boundary=4,w.storage=4):R.isVector2?(w.boundary=8,w.storage=8):R.isVector3||R.isColor?(w.boundary=16,w.storage=12):R.isVector4?(w.boundary=16,w.storage=16):R.isMatrix3?(w.boundary=48,w.storage=48):R.isMatrix4?(w.boundary=64,w.storage=64):R.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",R),w}function S(R){const w=R.target;w.removeEventListener("dispose",S);const E=c.indexOf(w.__bindingPointIndex);c.splice(E,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete o[w.id]}function x(){for(const R in r)e.deleteBuffer(r[R]);c=[],r={},o={}}return{bind:h,update:d,dispose:x}}class sB{constructor(t={}){const{canvas:n=eN(),context:i=null,depth:r=!0,stencil:o=!1,alpha:c=!1,antialias:u=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:d=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:m=!1,reverseDepthBuffer:_=!1}=t;this.isWebGLRenderer=!0;let y;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");y=i.getContextAttributes().alpha}else y=c;const M=new Uint32Array(4),T=new Int32Array(4);let S=null,x=null;const R=[],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=oi,this.toneMapping=io,this.toneMappingExposure=1;const E=this;let P=!1,I=0,U=0,B=null,D=-1,A=null;const F=new Xe,q=new Xe;let tt=null;const ot=new he(0);let ct=0,k=n.width,Q=n.height,j=1,pt=null,bt=null;const z=new Xe(0,0,k,Q),it=new Xe(0,0,k,Q);let Tt=!1;const J=new z1;let dt=!1,At=!1;this.transmissionResolutionScale=1;const xt=new ve,Vt=new ve,Gt=new G,$t=new Xe,Ke={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1;function ye(){return B===null?j:1}let H=i;function Wn(N,K){return n.getContext(N,K)}try{const N={alpha:!0,depth:r,stencil:o,antialias:u,premultipliedAlpha:h,preserveDrawingBuffer:d,powerPreference:p,failIfMajorPerformanceCaveat:m};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${w1}`),n.addEventListener("webglcontextlost",yt,!1),n.addEventListener("webglcontextrestored",Ut,!1),n.addEventListener("webglcontextcreationerror",Pt,!1),H===null){const K="webgl2";if(H=Wn(K,N),H===null)throw Wn(K)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let xe,be,Kt,Dt,Et,O,C,$,ut,St,mt,Xt,Ct,Lt,Se,Rt,zt,te,qt,Bt,oe,pe,$e,Y;function Nt(){xe=new p6(H),xe.init(),pe=new ZI(H,xe),be=new o6(H,xe,t,pe),Kt=new YI(H,xe),be.reverseDepthBuffer&&_&&Kt.buffers.depth.setReversed(!0),Dt=new _6(H),Et=new OI,O=new KI(H,xe,Kt,Et,be,pe,Dt),C=new c6(E),$=new d6(E),ut=new bU(H),$e=new r6(H,ut),St=new m6(H,ut,Dt,$e),mt=new y6(H,St,ut,Dt),qt=new v6(H,be,O),Rt=new l6(Et),Xt=new PI(E,C,$,xe,be,$e,Rt),Ct=new nB(E,Et),Lt=new BI,Se=new GI(xe),te=new s6(E,C,$,Kt,mt,y,h),zt=new XI(E,mt,be),Y=new iB(H,Dt,be,Kt),Bt=new a6(H,xe,Dt),oe=new g6(H,xe,Dt),Dt.programs=Xt.programs,E.capabilities=be,E.extensions=xe,E.properties=Et,E.renderLists=Lt,E.shadowMap=zt,E.state=Kt,E.info=Dt}Nt();const ft=new tB(E,H);this.xr=ft,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const N=xe.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){const N=xe.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(N){N!==void 0&&(j=N,this.setSize(k,Q,!1))},this.getSize=function(N){return N.set(k,Q)},this.setSize=function(N,K,rt=!0){if(ft.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}k=N,Q=K,n.width=Math.floor(N*j),n.height=Math.floor(K*j),rt===!0&&(n.style.width=N+"px",n.style.height=K+"px"),this.setViewport(0,0,N,K)},this.getDrawingBufferSize=function(N){return N.set(k*j,Q*j).floor()},this.setDrawingBufferSize=function(N,K,rt){k=N,Q=K,j=rt,n.width=Math.floor(N*rt),n.height=Math.floor(K*rt),this.setViewport(0,0,N,K)},this.getCurrentViewport=function(N){return N.copy(F)},this.getViewport=function(N){return N.copy(z)},this.setViewport=function(N,K,rt,at){N.isVector4?z.set(N.x,N.y,N.z,N.w):z.set(N,K,rt,at),Kt.viewport(F.copy(z).multiplyScalar(j).round())},this.getScissor=function(N){return N.copy(it)},this.setScissor=function(N,K,rt,at){N.isVector4?it.set(N.x,N.y,N.z,N.w):it.set(N,K,rt,at),Kt.scissor(q.copy(it).multiplyScalar(j).round())},this.getScissorTest=function(){return Tt},this.setScissorTest=function(N){Kt.setScissorTest(Tt=N)},this.setOpaqueSort=function(N){pt=N},this.setTransparentSort=function(N){bt=N},this.getClearColor=function(N){return N.copy(te.getClearColor())},this.setClearColor=function(){te.setClearColor(...arguments)},this.getClearAlpha=function(){return te.getClearAlpha()},this.setClearAlpha=function(){te.setClearAlpha(...arguments)},this.clear=function(N=!0,K=!0,rt=!0){let at=0;if(N){let X=!1;if(B!==null){const wt=B.texture.format;X=wt===P1||wt===U1||wt===N1}if(X){const wt=B.texture.type,Ot=wt===fa||wt===al||wt===Vf||wt===Lc||wt===C1||wt===D1,Ft=te.getClearColor(),kt=te.getClearAlpha(),ce=Ft.r,ue=Ft.g,ee=Ft.b;Ot?(M[0]=ce,M[1]=ue,M[2]=ee,M[3]=kt,H.clearBufferuiv(H.COLOR,0,M)):(T[0]=ce,T[1]=ue,T[2]=ee,T[3]=kt,H.clearBufferiv(H.COLOR,0,T))}else at|=H.COLOR_BUFFER_BIT}K&&(at|=H.DEPTH_BUFFER_BIT),rt&&(at|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(at)},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",yt,!1),n.removeEventListener("webglcontextrestored",Ut,!1),n.removeEventListener("webglcontextcreationerror",Pt,!1),te.dispose(),Lt.dispose(),Se.dispose(),Et.dispose(),C.dispose(),$.dispose(),mt.dispose(),$e.dispose(),Y.dispose(),Xt.dispose(),ft.dispose(),ft.removeEventListener("sessionstart",gu),ft.removeEventListener("sessionend",_u),cr.stop()};function yt(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),P=!0}function Ut(){console.log("THREE.WebGLRenderer: Context Restored."),P=!1;const N=Dt.autoReset,K=zt.enabled,rt=zt.autoUpdate,at=zt.needsUpdate,X=zt.type;Nt(),Dt.autoReset=N,zt.enabled=K,zt.autoUpdate=rt,zt.needsUpdate=at,zt.type=X}function Pt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function le(N){const K=N.target;K.removeEventListener("dispose",le),pn(K)}function pn(N){jn(N),Et.remove(N)}function jn(N){const K=Et.get(N).programs;K!==void 0&&(K.forEach(function(rt){Xt.releaseProgram(rt)}),N.isShaderMaterial&&Xt.releaseShaderCache(N))}this.renderBufferDirect=function(N,K,rt,at,X,wt){K===null&&(K=Ke);const Ot=X.isMesh&&X.matrixWorld.determinant()<0,Ft=yu(N,K,rt,at,X);Kt.setMaterial(at,Ot);let kt=rt.index,ce=1;if(at.wireframe===!0){if(kt=St.getWireframeAttribute(rt),kt===void 0)return;ce=2}const ue=rt.drawRange,ee=rt.attributes.position;let Le=ue.start*ce,Ne=(ue.start+ue.count)*ce;wt!==null&&(Le=Math.max(Le,wt.start*ce),Ne=Math.min(Ne,(wt.start+wt.count)*ce)),kt!==null?(Le=Math.max(Le,0),Ne=Math.min(Ne,kt.count)):ee!=null&&(Le=Math.max(Le,0),Ne=Math.min(Ne,ee.count));const un=Ne-Le;if(un<0||un===1/0)return;$e.setup(X,at,Ft,rt,kt);let ke,fe=Bt;if(kt!==null&&(ke=ut.get(kt),fe=oe,fe.setIndex(ke)),X.isMesh)at.wireframe===!0?(Kt.setLineWidth(at.wireframeLinewidth*ye()),fe.setMode(H.LINES)):fe.setMode(H.TRIANGLES);else if(X.isLine){let se=at.linewidth;se===void 0&&(se=1),Kt.setLineWidth(se*ye()),X.isLineSegments?fe.setMode(H.LINES):X.isLineLoop?fe.setMode(H.LINE_LOOP):fe.setMode(H.LINE_STRIP)}else X.isPoints?fe.setMode(H.POINTS):X.isSprite&&fe.setMode(H.TRIANGLES);if(X.isBatchedMesh)if(X._multiDrawInstances!==null)Vo("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),fe.renderMultiDrawInstances(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount,X._multiDrawInstances);else if(xe.get("WEBGL_multi_draw"))fe.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{const se=X._multiDrawStarts,Xn=X._multiDrawCounts,Pe=X._multiDrawCount,Fi=kt?ut.get(kt).bytesPerElement:1,Gs=Et.get(at).currentProgram.getUniforms();for(let Ai=0;Ai{function wt(){if(at.forEach(function(Ot){Et.get(Ot).currentProgram.isReady()&&at.delete(Ot)}),at.size===0){X(N);return}setTimeout(wt,10)}xe.get("KHR_parallel_shader_compile")!==null?wt():setTimeout(wt,10)})};let li=null;function Vs(N){li&&li(N)}function gu(){cr.stop()}function _u(){cr.start()}const cr=new I3;cr.setAnimationLoop(Vs),typeof self<"u"&&cr.setContext(self),this.setAnimationLoop=function(N){li=N,ft.setAnimationLoop(N),N===null?cr.stop():cr.start()},ft.addEventListener("sessionstart",gu),ft.addEventListener("sessionend",_u),this.render=function(N,K){if(K!==void 0&&K.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),ft.enabled===!0&&ft.isPresenting===!0&&(ft.cameraAutoUpdate===!0&&ft.updateCamera(K),K=ft.getCamera()),N.isScene===!0&&N.onBeforeRender(E,N,K,B),x=Se.get(N,w.length),x.init(K),w.push(x),Vt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),J.setFromProjectionMatrix(Vt),At=this.localClippingEnabled,dt=Rt.init(this.clippingPlanes,At),S=Lt.get(N,R.length),S.init(),R.push(S),ft.enabled===!0&&ft.isPresenting===!0){const wt=E.xr.getDepthSensingMesh();wt!==null&&ho(wt,K,-1/0,E.sortObjects)}ho(N,K,0,E.sortObjects),S.finish(),E.sortObjects===!0&&S.sort(pt,bt),Ge=ft.enabled===!1||ft.isPresenting===!1||ft.hasDepthSensing()===!1,Ge&&te.addToRenderList(S,N),this.info.render.frame++,dt===!0&&Rt.beginShadows();const rt=x.state.shadowsArray;zt.render(rt,N,K),dt===!0&&Rt.endShadows(),this.info.autoReset===!0&&this.info.reset();const at=S.opaque,X=S.transmissive;if(x.setupLights(),K.isArrayCamera){const wt=K.cameras;if(X.length>0)for(let Ot=0,Ft=wt.length;Ot0&&vu(at,X,N,K),Ge&&te.render(N),gl(S,N,K);B!==null&&U===0&&(O.updateMultisampleRenderTarget(B),O.updateRenderTargetMipmap(B)),N.isScene===!0&&N.onAfterRender(E,N,K),$e.resetDefaultState(),D=-1,A=null,w.pop(),w.length>0?(x=w[w.length-1],dt===!0&&Rt.setGlobalState(E.clippingPlanes,x.state.camera)):x=null,R.pop(),R.length>0?S=R[R.length-1]:S=null};function ho(N,K,rt,at){if(N.visible===!1)return;if(N.layers.test(K.layers)){if(N.isGroup)rt=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(K);else if(N.isLight)x.pushLight(N),N.castShadow&&x.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||J.intersectsSprite(N)){at&&$t.setFromMatrixPosition(N.matrixWorld).applyMatrix4(Vt);const Ot=mt.update(N),Ft=N.material;Ft.visible&&S.push(N,Ot,Ft,rt,$t.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||J.intersectsObject(N))){const Ot=mt.update(N),Ft=N.material;if(at&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),$t.copy(N.boundingSphere.center)):(Ot.boundingSphere===null&&Ot.computeBoundingSphere(),$t.copy(Ot.boundingSphere.center)),$t.applyMatrix4(N.matrixWorld).applyMatrix4(Vt)),Array.isArray(Ft)){const kt=Ot.groups;for(let ce=0,ue=kt.length;ce0&&po(X,K,rt),wt.length>0&&po(wt,K,rt),Ot.length>0&&po(Ot,K,rt),Kt.buffers.depth.setTest(!0),Kt.buffers.depth.setMask(!0),Kt.buffers.color.setMask(!0),Kt.setPolygonOffset(!1)}function vu(N,K,rt,at){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;x.state.transmissionRenderTarget[at.id]===void 0&&(x.state.transmissionRenderTarget[at.id]=new ol(1,1,{generateMipmaps:!0,type:xe.has("EXT_color_buffer_half_float")||xe.has("EXT_color_buffer_float")?th:fa,minFilter:oa,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Oe.workingColorSpace}));const wt=x.state.transmissionRenderTarget[at.id],Ot=at.viewport||F;wt.setSize(Ot.z*E.transmissionResolutionScale,Ot.w*E.transmissionResolutionScale);const Ft=E.getRenderTarget();E.setRenderTarget(wt),E.getClearColor(ot),ct=E.getClearAlpha(),ct<1&&E.setClearColor(16777215,.5),E.clear(),Ge&&te.render(rt);const kt=E.toneMapping;E.toneMapping=io;const ce=at.viewport;if(at.viewport!==void 0&&(at.viewport=void 0),x.setupLightsView(at),dt===!0&&Rt.setGlobalState(E.clippingPlanes,at),po(N,rt,at),O.updateMultisampleRenderTarget(wt),O.updateRenderTargetMipmap(wt),xe.has("WEBGL_multisampled_render_to_texture")===!1){let ue=!1;for(let ee=0,Le=K.length;ee0),ee=!!rt.morphAttributes.position,Le=!!rt.morphAttributes.normal,Ne=!!rt.morphAttributes.color;let un=io;at.toneMapped&&(B===null||B.isXRRenderTarget===!0)&&(un=E.toneMapping);const ke=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,fe=ke!==void 0?ke.length:0,se=Et.get(at),Xn=x.state.lights;if(dt===!0&&(At===!0||N!==A)){const En=N===A&&at.id===D;Rt.setState(at,N,En)}let Pe=!1;at.version===se.__version?(se.needsLights&&se.lightsStateVersion!==Xn.state.version||se.outputColorSpace!==Ft||X.isBatchedMesh&&se.batching===!1||!X.isBatchedMesh&&se.batching===!0||X.isBatchedMesh&&se.batchingColor===!0&&X.colorTexture===null||X.isBatchedMesh&&se.batchingColor===!1&&X.colorTexture!==null||X.isInstancedMesh&&se.instancing===!1||!X.isInstancedMesh&&se.instancing===!0||X.isSkinnedMesh&&se.skinning===!1||!X.isSkinnedMesh&&se.skinning===!0||X.isInstancedMesh&&se.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&se.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&se.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&se.instancingMorph===!1&&X.morphTexture!==null||se.envMap!==kt||at.fog===!0&&se.fog!==wt||se.numClippingPlanes!==void 0&&(se.numClippingPlanes!==Rt.numPlanes||se.numIntersection!==Rt.numIntersection)||se.vertexAlphas!==ce||se.vertexTangents!==ue||se.morphTargets!==ee||se.morphNormals!==Le||se.morphColors!==Ne||se.toneMapping!==un||se.morphTargetsCount!==fe)&&(Pe=!0):(Pe=!0,se.__version=at.version);let Fi=se.currentProgram;Pe===!0&&(Fi=Tn(at,K,X));let Gs=!1,Ai=!1,ni=!1;const tn=Fi.getUniforms(),wi=se.uniforms;if(Kt.useProgram(Fi.program)&&(Gs=!0,Ai=!0,ni=!0),at.id!==D&&(D=at.id,Ai=!0),Gs||A!==N){Kt.buffers.depth.getReversed()?(xt.copy(N.projectionMatrix),iN(xt),sN(xt),tn.setValue(H,"projectionMatrix",xt)):tn.setValue(H,"projectionMatrix",N.projectionMatrix),tn.setValue(H,"viewMatrix",N.matrixWorldInverse);const ui=tn.map.cameraPosition;ui!==void 0&&ui.setValue(H,Gt.setFromMatrixPosition(N.matrixWorld)),be.logarithmicDepthBuffer&&tn.setValue(H,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(at.isMeshPhongMaterial||at.isMeshToonMaterial||at.isMeshLambertMaterial||at.isMeshBasicMaterial||at.isMeshStandardMaterial||at.isShaderMaterial)&&tn.setValue(H,"isOrthographic",N.isOrthographicCamera===!0),A!==N&&(A=N,Ai=!0,ni=!0)}if(X.isSkinnedMesh){tn.setOptional(H,X,"bindMatrix"),tn.setOptional(H,X,"bindMatrixInverse");const En=X.skeleton;En&&(En.boneTexture===null&&En.computeBoneTexture(),tn.setValue(H,"boneTexture",En.boneTexture,O))}X.isBatchedMesh&&(tn.setOptional(H,X,"batchingTexture"),tn.setValue(H,"batchingTexture",X._matricesTexture,O),tn.setOptional(H,X,"batchingIdTexture"),tn.setValue(H,"batchingIdTexture",X._indirectTexture,O),tn.setOptional(H,X,"batchingColorTexture"),X._colorsTexture!==null&&tn.setValue(H,"batchingColorTexture",X._colorsTexture,O));const vi=rt.morphAttributes;if((vi.position!==void 0||vi.normal!==void 0||vi.color!==void 0)&&qt.update(X,rt,Fi),(Ai||se.receiveShadow!==X.receiveShadow)&&(se.receiveShadow=X.receiveShadow,tn.setValue(H,"receiveShadow",X.receiveShadow)),at.isMeshGouraudMaterial&&at.envMap!==null&&(wi.envMap.value=kt,wi.flipEnvMap.value=kt.isCubeTexture&&kt.isRenderTargetTexture===!1?-1:1),at.isMeshStandardMaterial&&at.envMap===null&&K.environment!==null&&(wi.envMapIntensity.value=K.environmentIntensity),Ai&&(tn.setValue(H,"toneMappingExposure",E.toneMappingExposure),se.needsLights&&Am(wi,ni),wt&&at.fog===!0&&Ct.refreshFogUniforms(wi,wt),Ct.refreshMaterialUniforms(wi,at,j,Q,x.state.transmissionRenderTarget[N.id]),pp.upload(H,ci(se),wi,O)),at.isShaderMaterial&&at.uniformsNeedUpdate===!0&&(pp.upload(H,ci(se),wi,O),at.uniformsNeedUpdate=!1),at.isSpriteMaterial&&tn.setValue(H,"center",X.center),tn.setValue(H,"modelViewMatrix",X.modelViewMatrix),tn.setValue(H,"normalMatrix",X.normalMatrix),tn.setValue(H,"modelMatrix",X.matrixWorld),at.isShaderMaterial||at.isRawShaderMaterial){const En=at.uniformsGroups;for(let ui=0,_l=En.length;ui<_l;ui++){const ki=En[ui];Y.update(ki,Fi),Y.bind(ki,Fi)}}return Fi}function Am(N,K){N.ambientLightColor.needsUpdate=K,N.lightProbe.needsUpdate=K,N.directionalLights.needsUpdate=K,N.directionalLightShadows.needsUpdate=K,N.pointLights.needsUpdate=K,N.pointLightShadows.needsUpdate=K,N.spotLights.needsUpdate=K,N.spotLightShadows.needsUpdate=K,N.rectAreaLights.needsUpdate=K,N.hemisphereLights.needsUpdate=K}function wm(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return U},this.getRenderTarget=function(){return B},this.setRenderTargetTextures=function(N,K,rt){Et.get(N.texture).__webglTexture=K,Et.get(N.depthTexture).__webglTexture=rt;const at=Et.get(N);at.__hasExternalTextures=!0,at.__autoAllocateDepthBuffer=rt===void 0,at.__autoAllocateDepthBuffer||xe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),at.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(N,K){const rt=Et.get(N);rt.__webglFramebuffer=K,rt.__useDefaultFramebuffer=K===void 0};const ph=H.createFramebuffer();this.setRenderTarget=function(N,K=0,rt=0){B=N,I=K,U=rt;let at=!0,X=null,wt=!1,Ot=!1;if(N){const kt=Et.get(N);if(kt.__useDefaultFramebuffer!==void 0)Kt.bindFramebuffer(H.FRAMEBUFFER,null),at=!1;else if(kt.__webglFramebuffer===void 0)O.setupRenderTarget(N);else if(kt.__hasExternalTextures)O.rebindTextures(N,Et.get(N.texture).__webglTexture,Et.get(N.depthTexture).__webglTexture);else if(N.depthBuffer){const ee=N.depthTexture;if(kt.__boundDepthTexture!==ee){if(ee!==null&&Et.has(ee)&&(N.width!==ee.image.width||N.height!==ee.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");O.setupDepthRenderbuffer(N)}}const ce=N.texture;(ce.isData3DTexture||ce.isDataArrayTexture||ce.isCompressedArrayTexture)&&(Ot=!0);const ue=Et.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(Array.isArray(ue[K])?X=ue[K][rt]:X=ue[K],wt=!0):N.samples>0&&O.useMultisampledRTT(N)===!1?X=Et.get(N).__webglMultisampledFramebuffer:Array.isArray(ue)?X=ue[rt]:X=ue,F.copy(N.viewport),q.copy(N.scissor),tt=N.scissorTest}else F.copy(z).multiplyScalar(j).floor(),q.copy(it).multiplyScalar(j).floor(),tt=Tt;if(rt!==0&&(X=ph),Kt.bindFramebuffer(H.FRAMEBUFFER,X)&&at&&Kt.drawBuffers(N,X),Kt.viewport(F),Kt.scissor(q),Kt.setScissorTest(tt),wt){const kt=Et.get(N.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+K,kt.__webglTexture,rt)}else if(Ot){const kt=Et.get(N.texture),ce=K;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,kt.__webglTexture,rt,ce)}else if(N!==null&&rt!==0){const kt=Et.get(N.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,kt.__webglTexture,rt)}D=-1},this.readRenderTargetPixels=function(N,K,rt,at,X,wt,Ot){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ft=Et.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Ot!==void 0&&(Ft=Ft[Ot]),Ft){Kt.bindFramebuffer(H.FRAMEBUFFER,Ft);try{const kt=N.texture,ce=kt.format,ue=kt.type;if(!be.textureFormatReadable(ce)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!be.textureTypeReadable(ue)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=N.width-at&&rt>=0&&rt<=N.height-X&&H.readPixels(K,rt,at,X,pe.convert(ce),pe.convert(ue),wt)}finally{const kt=B!==null?Et.get(B).__webglFramebuffer:null;Kt.bindFramebuffer(H.FRAMEBUFFER,kt)}}},this.readRenderTargetPixelsAsync=async function(N,K,rt,at,X,wt,Ot){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ft=Et.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Ot!==void 0&&(Ft=Ft[Ot]),Ft){const kt=N.texture,ce=kt.format,ue=kt.type;if(!be.textureFormatReadable(ce))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!be.textureTypeReadable(ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(K>=0&&K<=N.width-at&&rt>=0&&rt<=N.height-X){Kt.bindFramebuffer(H.FRAMEBUFFER,Ft);const ee=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,ee),H.bufferData(H.PIXEL_PACK_BUFFER,wt.byteLength,H.STREAM_READ),H.readPixels(K,rt,at,X,pe.convert(ce),pe.convert(ue),0);const Le=B!==null?Et.get(B).__webglFramebuffer:null;Kt.bindFramebuffer(H.FRAMEBUFFER,Le);const Ne=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await nN(H,Ne,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,ee),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,wt),H.deleteBuffer(ee),H.deleteSync(Ne),wt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(N,K=null,rt=0){N.isTexture!==!0&&(Vo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),K=arguments[0]||null,N=arguments[1]);const at=Math.pow(2,-rt),X=Math.floor(N.image.width*at),wt=Math.floor(N.image.height*at),Ot=K!==null?K.x:0,Ft=K!==null?K.y:0;O.setTexture2D(N,0),H.copyTexSubImage2D(H.TEXTURE_2D,rt,0,0,Ot,Ft,X,wt),Kt.unbindTexture()};const mo=H.createFramebuffer(),xu=H.createFramebuffer();this.copyTextureToTexture=function(N,K,rt=null,at=null,X=0,wt=null){N.isTexture!==!0&&(Vo("WebGLRenderer: copyTextureToTexture function signature has changed."),at=arguments[0]||null,N=arguments[1],K=arguments[2],wt=arguments[3]||0,rt=null),wt===null&&(X!==0?(Vo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),wt=X,X=0):wt=0);let Ot,Ft,kt,ce,ue,ee,Le,Ne,un;const ke=N.isCompressedTexture?N.mipmaps[wt]:N.image;if(rt!==null)Ot=rt.max.x-rt.min.x,Ft=rt.max.y-rt.min.y,kt=rt.isBox3?rt.max.z-rt.min.z:1,ce=rt.min.x,ue=rt.min.y,ee=rt.isBox3?rt.min.z:0;else{const vi=Math.pow(2,-X);Ot=Math.floor(ke.width*vi),Ft=Math.floor(ke.height*vi),N.isDataArrayTexture?kt=ke.depth:N.isData3DTexture?kt=Math.floor(ke.depth*vi):kt=1,ce=0,ue=0,ee=0}at!==null?(Le=at.x,Ne=at.y,un=at.z):(Le=0,Ne=0,un=0);const fe=pe.convert(K.format),se=pe.convert(K.type);let Xn;K.isData3DTexture?(O.setTexture3D(K,0),Xn=H.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?(O.setTexture2DArray(K,0),Xn=H.TEXTURE_2D_ARRAY):(O.setTexture2D(K,0),Xn=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,K.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,K.unpackAlignment);const Pe=H.getParameter(H.UNPACK_ROW_LENGTH),Fi=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Gs=H.getParameter(H.UNPACK_SKIP_PIXELS),Ai=H.getParameter(H.UNPACK_SKIP_ROWS),ni=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,ke.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,ke.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,ce),H.pixelStorei(H.UNPACK_SKIP_ROWS,ue),H.pixelStorei(H.UNPACK_SKIP_IMAGES,ee);const tn=N.isDataArrayTexture||N.isData3DTexture,wi=K.isDataArrayTexture||K.isData3DTexture;if(N.isDepthTexture){const vi=Et.get(N),En=Et.get(K),ui=Et.get(vi.__renderTarget),_l=Et.get(En.__renderTarget);Kt.bindFramebuffer(H.READ_FRAMEBUFFER,ui.__webglFramebuffer),Kt.bindFramebuffer(H.DRAW_FRAMEBUFFER,_l.__webglFramebuffer);for(let ki=0;ki=2.0 are supported."));return}const d=new FB(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(c),d.setPlugins(u),d.parse(i,r)}parseAsync(t,n){const i=this;return new Promise(function(r,o){i.parse(t,n,r,o)})}}function aB(){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 Re={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 oB{constructor(t){this.parser=t,this.name=Re.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,n=this.parser.json.nodes||[];for(let i=0,r=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,c)}}class SB{constructor(t){this.parser=t,this.name=Re.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,r=i.json,o=r.textures[t];if(!o.extensions||!o.extensions[n])return null;const c=o.extensions[n],u=r.images[c.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,c.source,h);if(r.extensionsRequired&&r.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 MB{constructor(t){this.parser=t,this.name=Re.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,r=i.json,o=r.textures[t];if(!o.extensions||!o.extensions[n])return null;const c=o.extensions[n],u=r.images[c.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,c.source,h);if(r.extensionsRequired&&r.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 bB{constructor(t){this.name=Re.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 r=i.extensions[this.name],o=this.parser.getDependency("buffer",r.buffer),c=this.parser.options.meshoptDecoder;if(!c||!c.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=r.byteOffset||0,d=r.byteLength||0,p=r.count,m=r.byteStride,_=new Uint8Array(u,h,d);return c.decodeGltfBufferAsync?c.decodeGltfBufferAsync(p,m,_,r.mode,r.filter).then(function(y){return y.buffer}):c.ready.then(function(){const y=new ArrayBuffer(p*m);return c.decodeGltfBuffer(new Uint8Array(y),p,m,_,r.mode,r.filter),y})})}else return null}}class TB{constructor(t){this.name=Re.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 r=n.meshes[i.mesh];for(const d of r.primitives)if(d.mode!==Us.TRIANGLES&&d.mode!==Us.TRIANGLE_STRIP&&d.mode!==Us.TRIANGLE_FAN&&d.mode!==void 0)return null;const c=i.extensions[this.name].attributes,u=[],h={};for(const d in c)u.push(this.parser.getDependency("accessor",c[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],_=d[0].count,y=[];for(const M of m){const T=new ve,S=new G,x=new nr,R=new G(1,1,1),w=new PN(M.geometry,M.material,_);for(let E=0;E<_;E++)h.TRANSLATION&&S.fromBufferAttribute(h.TRANSLATION,E),h.ROTATION&&x.fromBufferAttribute(h.ROTATION,E),h.SCALE&&R.fromBufferAttribute(h.SCALE,E),w.setMatrixAt(E,T.compose(S,x,R));for(const E in h)if(E==="_COLOR_0"){const P=h[E];w.instanceColor=new Nv(P.array,P.itemSize,P.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&M.geometry.setAttribute(E,h[E]);Mn.prototype.copy.call(w,M),this.parser.assignFinalMaterial(w),y.push(w)}return p.isGroup?(p.clear(),p.add(...y),p):y[0]}))}}const V3="glTF",yf=12,RT={JSON:1313821514,BIN:5130562};class EB{constructor(t){this.name=Re.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(t,0,yf),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(t.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==V3)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-yf,o=new DataView(t,yf);let c=0;for(;c0||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 BB=new ve;class FB{constructor(t={},n={}){this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new aB,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,r=-1,o=!1,c=-1;if(typeof navigator<"u"){const u=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(u)===!0;const h=u.match(/Version\/(\d+)/);r=i&&h?parseInt(h[1],10):-1,o=u.indexOf("Firefox")>-1,c=o?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&r<17||o&&c<98?this.textureLoader=new JN(this.options.manager):this.textureLoader=new rU(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new P3(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,r=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(c){return c._markDefs&&c._markDefs()}),Promise.all(this._invokeAll(function(c){return c.beforeRoot&&c.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(c){const u={scene:c[0][r.scene||0],scenes:c[0],animations:c[1],cameras:c[2],asset:r.asset,parser:i,userData:{}};return Fo(o,u,r),ra(u,r),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 r=0,o=n.length;r{const h=this.associations.get(c);h!=null&&this.associations.set(u,h);for(const[d,p]of c.children.entries())o(p,u.children[d])};return o(i,r),r.name+="_instance_"+t.uses[n]++,r}_invokeOne(t){const n=Object.values(this.plugins);n.push(this);for(let i=0;i=2&&S.setY(D,I[U*h+1]),h>=3&&S.setZ(D,I[U*h+2]),h>=4&&S.setW(D,I[U*h+3]),h>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}S.normalized=M}return S})}loadTexture(t){const n=this.json,i=this.options,o=n.textures[t].source,c=n.images[o];let u=this.textureLoader;if(c.uri){const h=i.manager.getHandler(c.uri);h!==null&&(u=h)}return this.loadTextureImage(t,o,u)}loadTextureImage(t,n,i){const r=this,o=this.json,c=o.textures[t],u=o.images[n],h=(u.uri||u.bufferView)+":"+c.sampler;if(this.textureCache[h])return this.textureCache[h];const d=this.loadImageSource(n,i).then(function(p){p.flipY=!1,p.name=c.name||u.name||"",p.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(p.name=u.uri);const _=(o.samplers||{})[c.sampler]||{};return p.magFilter=CT[_.magFilter]||hs,p.minFilter=CT[_.minFilter]||oa,p.wrapS=DT[_.wrapS]||Dc,p.wrapT=DT[_.wrapT]||Dc,p.generateMipmaps=!p.isCompressedTexture&&p.minFilter!==Oi&&p.minFilter!==hs,r.associations.set(p,{textures:t}),p}).catch(function(){return null});return this.textureCache[h]=d,d}loadImageSource(t,n){const i=this,r=this.json,o=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(m=>m.clone());const c=r.images[t],u=self.URL||self.webkitURL;let h=c.uri||"",d=!1;if(c.bufferView!==void 0)h=i.getDependency("bufferView",c.bufferView).then(function(m){d=!0;const _=new Blob([m],{type:c.mimeType});return h=u.createObjectURL(_),h});else if(c.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(_,y){let M=_;n.isImageBitmapLoader===!0&&(M=function(T){const S=new Zn(T);S.needsUpdate=!0,_(S)}),n.load(Uf.resolveURL(m,o.path),M,void 0,y)})}).then(function(m){return d===!0&&u.revokeObjectURL(h),ra(m,c),m.userData.mimeType=c.mimeType||IB(c.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,r){const o=this;return this.getDependency("texture",i.index).then(function(c){if(!c)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(c=c.clone(),c.channel=i.texCoord),o.extensions[Re.KHR_TEXTURE_TRANSFORM]){const u=i.extensions!==void 0?i.extensions[Re.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const h=o.associations.get(c);c=o.extensions[Re.KHR_TEXTURE_TRANSFORM].extendTexture(c,u),o.associations.set(c,h)}}return r!==void 0&&(c.colorSpace=r),t[n]=c,c})}assignFinalMaterial(t){const n=t.geometry;let i=t.material;const r=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,c=n.attributes.normal===void 0;if(t.isPoints){const u="PointsMaterial:"+i.uuid;let h=this.cache.get(u);h||(h=new C3,Sr.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 V1,Sr.prototype.copy.call(h,i),h.color.copy(i.color),h.map=i.map,this.cache.add(u,h)),i=h}if(r||o||c){let u="ClonedMaterial:"+i.uuid+":";r&&(u+="derivative-tangents:"),o&&(u+="vertex-colors:"),c&&(u+="flat-shading:");let h=this.cache.get(u);h||(h=i.clone(),o&&(h.vertexColors=!0),c&&(h.flatShading=!0),r&&(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 jf}loadMaterial(t){const n=this,i=this.json,r=this.extensions,o=i.materials[t];let c;const u={},h=o.extensions||{},d=[];if(h[Re.KHR_MATERIALS_UNLIT]){const m=r[Re.KHR_MATERIALS_UNLIT];c=m.getMaterialType(),d.push(m.extendParams(u,o,n))}else{const m=o.pbrMetallicRoughness||{};if(u.color=new he(1,1,1),u.opacity=1,Array.isArray(m.baseColorFactor)){const _=m.baseColorFactor;u.color.setRGB(_[0],_[1],_[2],Bi),u.opacity=_[3]}m.baseColorTexture!==void 0&&d.push(n.assignTexture(u,"map",m.baseColorTexture,oi)),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))),c=this._invokeOne(function(_){return _.getMaterialType&&_.getMaterialType(t)}),d.push(Promise.all(this._invokeAll(function(_){return _.extendMaterialParams&&_.extendMaterialParams(t,u)})))}o.doubleSided===!0&&(u.side=Ps);const p=o.alphaMode||v_.OPAQUE;if(p===v_.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,p===v_.MASK&&(u.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&c!==Li&&(d.push(n.assignTexture(u,"normalMap",o.normalTexture)),u.normalScale=new Te(1,1),o.normalTexture.scale!==void 0)){const m=o.normalTexture.scale;u.normalScale.set(m,m)}if(o.occlusionTexture!==void 0&&c!==Li&&(d.push(n.assignTexture(u,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&c!==Li){const m=o.emissiveFactor;u.emissive=new he().setRGB(m[0],m[1],m[2],Bi)}return o.emissiveTexture!==void 0&&c!==Li&&d.push(n.assignTexture(u,"emissiveMap",o.emissiveTexture,oi)),Promise.all(d).then(function(){const m=new c(u);return o.name&&(m.name=o.name),ra(m,o),n.associations.set(m,{materials:t}),o.extensions&&Fo(r,m,o),m})}createUniqueName(t){const n=Ye.sanitizeNodeName(t||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(t){const n=this,i=this.extensions,r=this.primitiveCache;function o(u){return i[Re.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,n).then(function(h){return LT(h,u,n)})}const c=[];for(let u=0,h=t.length;u0&&PB(x,o),x.name=n.createUniqueName(o.name||"mesh_"+t),ra(x,o),S.extensions&&Fo(r,x,S),n.assignFinalMaterial(x),m.push(x)}for(let y=0,M=m.length;y1?p=new Yi:d.length===1?p=d[0]:p=new Mn,p!==d[0])for(let m=0,_=d.length;m<_;m++)p.add(d[m]);if(o.name&&(p.userData.name=o.name,p.name=c),ra(p,o),o.extensions&&Fo(i,p,o),o.matrix!==void 0){const m=new ve;m.fromArray(o.matrix),p.applyMatrix4(m)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return r.associations.has(p)||r.associations.set(p,{}),r.associations.get(p).nodes=t,p}),this.nodeCache[t]}loadScene(t){const n=this.extensions,i=this.json.scenes[t],r=this,o=new Yi;i.name&&(o.name=r.createUniqueName(i.name)),ra(o,i),i.extensions&&Fo(n,o,i);const c=i.nodes||[],u=[];for(let h=0,d=c.length;h{const m=new Map;for(const[_,y]of r.associations)(_ instanceof Sr||_ instanceof Zn)&&m.set(_,y);return p.traverse(_=>{const y=r.associations.get(_);y!=null&&m.set(_,y)}),m};return r.associations=d(o),o})}_createAnimationTracks(t,n,i,r,o){const c=[],u=t.name?t.name:t.uuid,h=[];ja[o.path]===ja.weights?t.traverse(function(_){_.morphTargetInfluences&&h.push(_.name?_.name:_.uuid)}):h.push(u);let d;switch(ja[o.path]){case ja.weights:d=Oc;break;case ja.rotation:d=Ic;break;case ja.position:case ja.scale:d=Bc;break;default:switch(i.itemSize){case 1:d=Oc;break;case 2:case 3:default:d=Bc;break}break}const p=r.interpolation!==void 0?LB[r.interpolation]:Gf,m=this._getArrayFromAccessor(i);for(let _=0,y=h.length;_{const o=r==null?void 0:r.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.scene=new CN,this.camera=new Ni(60,window.innerWidth/window.innerHeight,.1,100),this.camera.position.set(0,1.5,0),this.renderer=new sB({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 sU(16777215,.7);this.scene.add(t);const n=new O3(16777215,.8);n.position.set(5,10,5),this.scene.add(n)}setupScene(){const t=this.createBallTexture(),n=new Xo(.2,64,64),i=new rr({map:t.diff,bumpMap:t.bump,bumpScale:.005,roughness:.5,metalness:.1,clearcoat:.4,clearcoatRoughness:.2});this.ballFallbackMaterial=i,this.ball=new qe(n,i);const r=new Xo(.205,32,32),o=new Li({color:65382,wireframe:!0,transparent:!0,opacity:0});this.ballWire=new qe(r,o),this.ball.add(this.ballWire),this.ball.position.set(0,.2,this.ballStartZ),this.scene.add(this.ball),this.trailGroup=new Yi;const c=new Xo(.18,16,16);for(let ot=0;ot{const n=t.scene;this.fitModel(n,.42),n.traverse(i=>{i instanceof qe&&(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(r=>{if(!(r instanceof qe))return;r.frustumCulled=!1,r.castShadow=!1,r.receiveShadow=!1;const o=Array.isArray(r.material)?r.material:[r.material];for(const c of o)c&&("transparent"in c&&(c.transparent=!1),"opacity"in c&&(c.opacity=1),"alphaTest"in c&&(c.alphaTest=0),"depthWrite"in c&&(c.depthWrite=!0),"depthTest"in c&&(c.depthTest=!0),"side"in c&&(c.side=Ps),c.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(r=>r.duration>.05);if(i.length>0){const r=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 xU(n),this.playerMixer.addEventListener("finished",this.onPlayerActionFinished);const c=this.playerMixer.clipAction(r);if(c.clampWhenFinished=!0,c.loop=Ef,c.enabled=!0,this.playerKickAction=c,o){const u=this.playerMixer.clipAction(o);u.loop=Ef,u.clampWhenFinished=!0,u.enabled=!0,this.playerRunAction=u}console.info(`Using player animations: kick=${r.name} (${r.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=NT(t.scene),i=NT(t.scene);this.prepareGloveModel(n,!0),this.prepareGloveModel(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){const r=new Ki().setFromObject(t).getSize(new G),c=1/Math.max(r.y,1e-4);t.scale.setScalar(c),n&&(t.scale.x*=-1),t.updateMatrixWorld(!0);const u=new G;let h=!1;if(t.traverse(d=>{if(h||!(d instanceof E3))return;const p=d.skeleton;if(!p||p.bones.length===0)return;(p.bones.find(_=>!_.parent||_.parent.type!=="Bone")||p.bones[0]).getWorldPosition(u),t.worldToLocal(u),h=!0}),!h){const d=new Ki().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)}fitModel(t,n,i=!1){const o=new Ki().setFromObject(t).getSize(new G),c=Math.max(o.y,1e-4),u=n/c;t.scale.setScalar(u);const d=new Ki().setFromObject(t).getCenter(new G);if(t.position.sub(d),i){const p=new Ki().setFromObject(t);t.position.y-=p.min.y}}findKickBone(t){let n=null;return t.traverse(i=>{if(i.type!=="Bone")return;const r=i.name.toLowerCase();(!n&&r.includes("right")&&(r.includes("upleg")||r.includes("thigh")||r.includes("leg"))||!n&&(r.includes("leg")||r.includes("thigh")))&&(n=i)}),n}findBoneByAliases(t,n){let i=null;return t.traverse(r=>{if(i||r.type!=="Bone")return;const o=r.name.toLowerCase();n.some(c=>o.includes(c))&&(i=r)}),i}findKickRigBones(t){const n=this.findBoneByAliases(t,["rightupleg","right_thigh","rthigh","mixamorigrightupleg"]),i=this.findBoneByAliases(t,["rightleg","right_calf","rcalf","mixamorigrightleg"]),r=this.findBoneByAliases(t,["rightfoot","rfoot","mixamorigrightfoot"]),o=this.findBoneByAliases(t,["leftupleg","left_thigh","lthigh","mixamorigleftupleg"]),c=this.findBoneByAliases(t,["hips","pelvis","mixamorighips"]),u=this.findBoneByAliases(t,["spine02","spine2"])||this.findBoneByAliases(t,["spine01","spine1"])||this.findBoneByAliases(t,["spine"]);return{hips:c,spine:u,rightUpLeg:n,rightLeg:i,rightFoot:r,leftUpLeg:o}}screenToWorld(t,n,i){const r=Math.abs(this.camera.position.z-i),o=gr.degToRad(this.camera.fov),c=2*Math.tan(o/2)*r,u=c*this.camera.aspect,h=this.camera.position.x+(t-.5)*u,d=this.camera.position.y-(n-.5)*c;return new G(h,d,i)}updateGloveLandmarks(t){if(this.lastGloveLandmarks=t,!t){this.applyGlovePose(this.leftGlove,null,!0),this.applyGlovePose(this.rightGlove,null,!1);return}const n=this.getGlovePose(t,!0),i=this.getGlovePose(t,!1),r=this.swapGloveHands?i:n,o=this.swapGloveHands?n:i;this.applyGlovePose(this.leftGlove,r,!0),this.applyGlovePose(this.rightGlove,o,!1)}setGloveStaticWrap(t){this.gloveStaticWrap=t}setSwapGloveHands(t){this.swapGloveHands=t}getSwapGloveHands(){return this.swapGloveHands}calibrateGloves(t=this.lastGloveLandmarks){if(!t)return!1;this.swapGloveHands=!1;const n=this.getGlovePose(t,!0),i=this.getGlovePose(t,!1),r=this.swapGloveHands?i:n,o=this.swapGloveHands?n:i;let c=!1;const u=(h,d)=>{if(!d)return;const p=this.gloveCalibration[h];p.scale=gr.clamp(d.handLength*3.6,.3,.62),p.forwardMul=.02,p.sideMul=h==="left"?-.015:.015,c=!0};return u("left",r),u("right",o),c}pickBestLandmark(t,n){let i=null,r=-1;for(const o of n){const c=t[o];if(!c)continue;const u=c.visibility??1;u>r&&(i=c,r=u)}return i}getGlovePose(t,n){const i=this.pickBestLandmark(t,n?[15]:[16]);if(!i||(i.visibility??1)<.08)return null;const r=this.pickBestLandmark(t,n?[19,17,21]:[20,18,22]),o=this.pickBestLandmark(t,n?[19]:[20]),c=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=A=>this.screenToWorld(1-A.x,A.y,p),_=(A,F=.08)=>A&&(A.visibility??1)>=F?m(A):null,y=m(i),M=_(o),T=_(c),S=_(u),x=_(r,.05),R=_(h,.05),w=_(d,.05);let E=new G(n?-1:1,0,0),P=.08,I=!1;const U=[M,T,S].filter(A=>!!A).filter(A=>{const F=A.distanceTo(y);return F>.02&&F<.55});if(U.length>0){const A=new G;for(const tt of U)A.add(tt);A.multiplyScalar(1/U.length);const F=new G().subVectors(A,y),q=F.length();q>1e-4&&(E=F.multiplyScalar(1/q),P=gr.clamp(q,.045,.18),I=!0)}if(!I&&R){const A=new G().subVectors(y,R),F=A.length();F>1e-4&&(E=A.multiplyScalar(1/F),P=gr.clamp(F*.45,.045,.16),I=!0)}if(!I&&w){const A=new G().subVectors(y,w),F=A.length();F>1e-4&&(E=A.multiplyScalar(1/F),P=gr.clamp(F*.3,.045,.16))}let B=y.clone().addScaledVector(E,P*.18);if(U.length>=2){const A=new G;for(const F of U)A.add(F);A.multiplyScalar(1/U.length),B=y.clone().multiplyScalar(.42).add(A.multiplyScalar(.58))}else x&&B.lerp(x,.2);const D=Math.atan2(E.y,E.x);return{palm:B,dir:E,handLength:P,angle:D}}applyGlovePose(t,n,i){const r=i?"left":"right",o=i?"left":"right",c=this.gloveCalibration[o],u=new G;let h=c.rotationOffset;if(!n)u.set(i?-.18:.18,1.02,-.55);else{u.copy(n.palm).addScaledVector(n.dir,n.handLength*c.forwardMul);const p=new G(-n.dir.y,n.dir.x,0).normalize();u.addScaledVector(p,n.handLength*c.sideMul),h=this.gloveStaticWrap?c.rotationOffset:n.angle+c.rotationOffset}let d=this.gloveFollowState.get(r);if(!d)d={pos:u.clone(),angle:h},this.gloveFollowState.set(r,d);else{d.pos.lerp(u,.55);let p=h-d.angle;for(;p>Math.PI;)p-=Math.PI*2;for(;p<-Math.PI;)p+=Math.PI*2;d.angle+=p*.55}t.visible=!0,t.position.copy(d.pos),t.rotation.set(0,0,d.angle),t.scale.set(c.scale,c.scale,c.scale)}clearKickContactTimer(){this.kickContactTimer&&(clearTimeout(this.kickContactTimer),this.kickContactTimer=null)}startBallFlight(){!this.pendingBallLaunch||this.isBallActive||(this.isBallActive=!0,this.pendingBallLaunch=!1,this.timeScale=.25,this.timeScaleTimer=4)}scheduleBallLaunch(t){this.clearKickContactTimer(),this.kickContactTimer=setTimeout(()=>{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(Ef,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,r=this.ballWire.material;this.isSuperBall?(i.color.setHex(16777215),i.emissive.setHex(16711765),i.emissiveIntensity=.8,r.color.setHex(65535),r.opacity=1,this.strikerAura.material.opacity=.5):(i.color.setHex(16777215),i.emissive.setHex(0),i.emissiveIntensity=0,r.opacity=0,this.strikerAura.material.opacity=0);let o=0,c=1.5;const u=Math.abs(this.camera.position.z-this.catchPlaneZ),h=gr.degToRad(this.camera.fov),d=2*Math.tan(h/2)*u,p=d*this.camera.aspect;if(n!==void 0){let R,w;n===0?(R=.1,w=.35):n===1?(R=.375,w=.625):(R=.65,w=.9);const E=.3,P=.6,I=R+Math.random()*(w-R),U=E+Math.random()*(P-E);o=this.camera.position.x+(I-.5)*p,c=this.camera.position.y-(U-.5)*d}else o=this.camera.position.x+(Math.random()-.5)*p*.8,c=this.camera.position.y+(Math.random()-.5)*d*.6;const m=this.isSuperBall?1.2/t:2/t,_=o-this.ball.position.x,y=c-this.ball.position.y,M=this.catchPlaneZ-this.ball.position.z;this.ballVelocity.set(_/m,y/m,M/m);const T=9.8*.2;this.ballVelocity.y+=T*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 x=new G().crossVectors(this.ballSpin,this.ballVelocity).multiplyScalar(.015);this.ballVelocity.sub(x.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(Ef,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,r=this.striker.position.y,o=this.strikerKickBone,c=o?o.rotation.x:0,u=this.strikerKickRig,h=["hips","spine","rightUpLeg","rightLeg","rightFoot","leftUpLeg"],d=new Map;if(u)for(const _ of h){const y=u[_];y&&d.set(_,y.rotation.clone())}const p=_=>{const y=Math.min(1,(_-t)/n),M=gr.clamp(y/.32,0,1),T=gr.clamp((y-.32)/.34,0,1),S=gr.clamp((y-.66)/.34,0,1),x=M*M,R=T<.5?2*T*T:1-Math.pow(-2*T+2,2)/2,w=S<.5?2*S*S:1-Math.pow(-2*S+2,2)/2,E=x*(1-w)+R*(1-w);if(this.striker.position.y=r+Math.sin(y*Math.PI)*.4,u&&d.size>0){const P=u.hips,I=u.spine,U=u.rightUpLeg,B=u.rightLeg,D=u.rightFoot,A=u.leftUpLeg,F=d.get("hips");P&&F&&(P.rotation.x=F.x-.2*x+.14*R-.06*w,P.rotation.y=F.y+.06*R);const q=d.get("spine");I&&q&&(I.rotation.x=q.x+.18*x-.12*R+.05*w);const tt=d.get("rightUpLeg");U&&tt&&(U.rotation.x=tt.x+.75*x-1.25*R+.35*w,U.rotation.y=tt.y-.08*R);const ot=d.get("rightLeg");B&&ot&&(B.rotation.x=ot.x-.95*x+1.05*R-.15*w);const ct=d.get("rightFoot");D&&ct&&(D.rotation.x=ct.x+.35*R-.08*w);const k=d.get("leftUpLeg");A&&k&&(A.rotation.x=k.x+.2*E)}else this.striker.rotation.x=i+Math.sin(y*Math.PI*2)*.2,o&&(o.rotation.x=c-Math.sin(y*Math.PI)*1);if(y<1)this.kickAnimFrame=requestAnimationFrame(p);else if(this.striker.position.y=r,this.striker.rotation.x=i,u&&d.size>0)for(const[P,I]of d.entries()){const U=u[P];U&&U.rotation.copy(I)}else o&&(o.rotation.x=c)};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 r=new G().crossVectors(this.ballSpin,this.ballVelocity).multiplyScalar(.015);if(this.ballVelocity.addScaledVector(r,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 r=this.particles[i];if(r.life-=n*1.5,r.life<=0){this.particleGroup.remove(r.mesh),this.particles.splice(i,1);continue}r.mesh.position.addScaledVector(r.velocity,n),r.mesh.rotation.x+=n*5,r.mesh.rotation.y+=n*5,r.velocity.y-=9.8*n,r.isSuper&&r.mesh.scale.multiplyScalar(1+n),r.mesh.material.opacity=r.life}this.renderer.render(this.scene,this.camera)}hideTrails(){for(let t=0;t{n.beginPath();for(let m=0;m<5;m++){const _=m/5*Math.PI*2-Math.PI/2,y=d+Math.cos(_)*55,M=p+Math.sin(_)*55;m===0?n.moveTo(y,M):n.lineTo(y,M)}n.closePath(),n.fill()});const r=new Zb(t);r.colorSpace=oi;const o=document.createElement("canvas");o.width=512,o.height=512;const c=o.getContext("2d");c.fillStyle="#808080",c.fillRect(0,0,512,512);const u=c.getImageData(0,0,512,512);for(let d=0;d{c.beginPath();for(let m=0;m<5;m++){const _=m/5*Math.PI*2-Math.PI/2,y=d+Math.cos(_)*57,M=p+Math.sin(_)*57;m===0?c.moveTo(y,M):c.lineTo(y,M)}c.closePath(),c.stroke();for(let m=0;m<5;m++){const _=m/5*Math.PI*2-Math.PI/2,y=d+Math.cos(_)*57,M=p+Math.sin(_)*57,T=d+Math.cos(_)*110,S=p+Math.sin(_)*110;c.beginPath(),c.moveTo(y,M),c.lineTo(T,S),c.stroke()}});const h=new Zb(o);return{diff:r,bump:h}}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}}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,r=n?65535:16776960;for(let o=0;o>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&r=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}r--}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 X3(e){Fc.setTimeout((()=>{throw e}),0)}var Fv,WB=W3(610401301,!1),PT=W3(748402147,!0);function OT(){var e=Fc.navigator;return e&&(e=e.userAgent)?e:""}const IT=Fc.navigator;function Jp(e){return Jp[" "](e),e}Fv=IT&&IT.userAgentData||null,Jp[" "]=function(){};const q3={};let wf=null;function jB(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 r=0;return(function(o,c){function u(d){for(;h>4),m!=64&&(c(p<<4&240|m>>2),_!=64&&c(m<<6&192|_))}})(e,(function(o){i[r++]=o})),r!==n?i.subarray(0,r):i}function Y3(){if(!wf){wf={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let n=0;n<5;n++){const i=e.concat(t[n].split(""));q3[n]=i;for(let r=0;r0)&&(OT().indexOf("Trident")!=-1||OT().indexOf("MSIE")!=-1))&&typeof btoa=="function";const BT=/[-_.]/g,qB={"-":"+",_:"/",".":"="};function YB(e){return qB[e]||""}function Z3(e){if(!K3)return jB(e);e=BT.test(e)?e.replace(BT,YB):e,e=atob(e);const t=new Uint8Array(e.length);for(let n=0;n=t||(n[e]=i+1,J3(e=Error(),"incident"),X3(e))}}function eu(){return typeof BigInt=="function"}var nu=typeof Symbol=="function"&&typeof Symbol()=="symbol";function Cr(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 QB=Cr("jas",void 0,!0),FT=Cr(void 0,"0di"),xf=Cr(void 0,"1oa"),ds=Cr(void 0,Symbol()),JB=Cr(void 0,"0ub"),$B=Cr(void 0,"0ubs"),zv=Cr(void 0,"0ubsb"),t8=Cr(void 0,"0actk"),Vc=Cr("m_m","Pa",!0),kT=Cr();const $3={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},tw=Object.defineProperties,Zt=nu?QB:"Ga";var dl;const zT=[];function nh(e,t){nu||Zt in e||tw(e,$3),e[Zt]|=t}function ei(e,t){nu||Zt in e||tw(e,$3),e[Zt]=t}function ih(e){return nh(e,34),e}function Xf(e){return nh(e,8192),e}ei(zT,7),dl=Object.freeze(zT);var Hc={};function gs(e,t){return t===void 0?e.h!==ul&&!!(2&(0|e.v[Zt])):!!(2&t)&&e.h!==ul}const ul={};function $1(e,t){if(e!=null){if(typeof e=="string")e=e?new Mr(e,kc):cl();else if(e.constructor!==Mr)if(Q1(e))e=e.length?new Mr(new Uint8Array(e),kc):cl();else{if(!t)throw Error();e=void 0}}return e}class VT{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 e8=Object.freeze({});function ew(e,t,n){const i=128&t?0:-1,r=e.length;var o;(o=!!r)&&(o=(o=e[r-1])!=null&&typeof o=="object"&&o.constructor===Object);const c=r+(o?-1:0);for(t=128&t?1:0;ttypeof e=="number")),HT=$p((e=>typeof e=="string")),i8=$p((e=>typeof e=="boolean")),tm=typeof Fc.BigInt=="function"&&typeof Fc.BigInt(0)=="bigint";function ps(e){var t=e;if(HT(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(n8(t)&&!Number.isSafeInteger(t))throw Error(String(t));return tm?BigInt(e):e=i8(e)?e?"1":"0":HT(e)?e.trim()||"0":String(e)}var Vv=$p((e=>tm?e>=r8&&e<=o8:e[0]==="-"?GT(e,s8):GT(e,a8)));const s8=Number.MIN_SAFE_INTEGER.toString(),r8=tm?BigInt(Number.MIN_SAFE_INTEGER):void 0,a8=Number.MAX_SAFE_INTEGER.toString(),o8=tm?BigInt(Number.MAX_SAFE_INTEGER):void 0;function GT(e,t){if(e.length>t.length)return!1;if(e.lengthr)return!1;if(i>>0;yn=t,zn=(e-t)/4294967296>>>0}function Gc(e){if(e<0){WT(-e);const[t,n]=ny(yn,zn);yn=t>>>0,zn=n>>>0}else WT(e)}function ty(e){const t=c8||(c8=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),zn=0,yn=t.getUint32(0,!0)}function iw(e,t){const n=4294967296*t+(e>>>0);return Number.isSafeInteger(n)?n:qf(e,t)}function u8(e,t){return ps(eu()?BigInt.asUintN(64,(BigInt(t>>>0)<>>0)):qf(e,t))}function sw(e,t){return eu()?ps(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(t))<>>=0,(t>>>=0)<=2097151)var n=""+(4294967296*t+e);else eu()?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+jT(n)+jT(e));return n}function jT(e){return e=String(e),"0000000".slice(e.length)+e}function ey(e,t){if(2147483648&t)if(eu())e=""+(BigInt(0|t)<>>0));else{const[n,i]=ny(e,t);e="-"+qf(n,i)}else e=qf(e,t);return e}function em(e){if(e.length<16)Gc(Number(e));else if(eu())e=BigInt(e),yn=Number(e&BigInt(4294967295))>>>0,zn=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+(e[0]==="-");zn=yn=0;const n=e.length;for(let i=t,r=(n-t)%6+t;r<=n;i=r,r+=6){const o=Number(e.slice(i,r));zn*=1e6,yn=1e6*yn+o,yn>=4294967296&&(zn+=Math.trunc(yn/4294967296),zn>>>=0,yn>>>=0)}if(t){const[i,r]=ny(yn,zn);yn=i,zn=r}}}function ny(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function ir(e){return Array.prototype.slice.call(e)}const sh=typeof BigInt=="function"?BigInt.asIntN:void 0,f8=typeof BigInt=="function"?BigInt.asUintN:void 0,fl=Number.isSafeInteger,nm=Number.isFinite,Wc=Math.trunc,h8=ps(0);function Rf(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 xr(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function Yf(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 rw(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}const d8=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function rh(e){switch(typeof e){case"bigint":return!0;case"number":return nm(e);case"string":return d8.test(e);default:return!1}}function su(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return nm(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 nm(e)?e>>>0:void 0}function ow(e){const t=e.length;return(e[0]==="-"?t<20||t===20&&e<="-9223372036854775808":t<19||t===19&&e<="9223372036854775807")?e:(em(e),ey(yn,zn))}function iy(e){if(e=Wc(e),!fl(e)){Gc(e);var t=yn,n=zn;(e=2147483648&n)&&(n=~n>>>0,(t=1+~t>>>0)==0&&(n=n+1>>>0)),e=typeof(t=iw(t,n))=="number"?e?-t:t:e?"-"+t:t}return e}function lw(e){var t=Wc(Number(e));return fl(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),ow(e))}function cw(e){var t=Wc(Number(e));return fl(t)?ps(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),eu()?ps(sh(64,BigInt(e))):ps(ow(e)))}function uw(e){return fl(e)?e=ps(iy(e)):(e=Wc(e),fl(e)?e=String(e):(Gc(e),e=ey(yn,zn)),e=ps(e)),e}function Lp(e){const t=typeof e;return e==null?e:t==="bigint"?ps(sh(64,e)):rh(e)?t==="string"?cw(e):uw(e):void 0}function fw(e){if(typeof e!="string")throw Error();return e}function ah(e){if(e!=null&&typeof e!="string")throw Error();return e}function _i(e){return e==null||typeof e=="string"?e:void 0}function sy(e,t,n,i){return e!=null&&e[Vc]===Hc?e:Array.isArray(e)?((i=(n=0|e[Zt])|32&i|2&i)!==n&&ei(e,i),new t(e)):(n?2&i?((e=t[FT])||(ih((e=new t).v),e=t[FT]=e),t=e):t=new t:t=void 0,t)}function p8(e,t,n){if(t)t:{if(!rh(t=e))throw kv("int64");switch(typeof t){case"string":t=cw(t);break t;case"bigint":t=ps(sh(64,t));break t;default:t=uw(t)}}else t=Lp(e);return(e=t)==null?n?h8:void 0:e}const m8={};let g8=(function(){try{return Jp(new class extends Map{constructor(){super()}}),!1}catch{return!0}})();class S_{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 _8=g8?(Object.setPrototypeOf(S_.prototype,Map.prototype),Object.defineProperties(S_.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),S_):class extends Map{constructor(){super()}};function XT(e){return e}function M_(e){if(2&e.J)throw Error("Cannot mutate an immutable Map")}var ha=class extends _8{constructor(e,t,n=XT,i=XT){super(),this.J=0|e[Zt],this.K=t,this.S=n,this.fa=this.K?v8:i;for(let r=0;r{e.call(t,r.get(i),i,r)})):super.forEach(e,t)}set(e,t){return M_(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 v8(e,t,n,i,r,o){return e=sy(e,i,n,o),r&&(e=ay(e)),e}function y8(e){return[e,this.get(e)]}let x8;function qT(){return x8||(x8=new ha(ih([]),void 0,void 0,void 0,m8))}function im(e){return ds?e[ds]:void 0}function Np(e,t){for(const n in e)!isNaN(n)&&t(e,+n,e[n])}ha.prototype.toJSON=void 0;var Hv=class{};const S8={Ka:!0};function M8(e,t){t<100||zc($B,1)}function sm(e,t,n,i){const r=i!==void 0;i=!!i;var o,c=ds;!r&&nu&&c&&(o=e[c])&&Np(o,M8),c=[];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||r||(d=!0,o=o-m+m)),t=void 0;for(var _=0;_=o){const M=_-m;(t??(t={}))[M]=y}else c[_]=y}if(h)for(let y in h){if((u=h[y])==null||(u=n(u,i))==null)continue;let M;_=+y,p&&!Number.isNaN(_)&&(M=_+m){M[S]=ir(x)})),M.da=y.da,M})(e)),c}function b8(e){return e[0]=Kf(e[0]),e[1]=Kf(e[1]),e}function Kf(e){switch(typeof e){case"number":return Number.isFinite(e)?e:""+e;case"bigint":return Vv(e)?Number(e):""+e;case"boolean":return e?1:0;case"object":if(Array.isArray(e)){var t=0|e[Zt];return e.length===0&&1&t?void 0:sm(e,t,Kf)}if(e!=null&&e[Vc]===Hc)return hw(e);if(e instanceof Mr){if((t=e.g)==null)e="";else if(typeof t=="string")e=t;else{if(K3){for(var n="",i=0,r=t.length-10240;i>2];o=n[(3&o)<<4|c>>4],c=n[(15&c)<<2|u>>6],u=n[63&u],i[p++]=h+o+c+u}switch(h=0,u=r,t.length-d){case 2:u=n[(15&(h=t[d+1]))<<2]||r;case 1:t=t[d],i[p]=n[t>>2]+n[(3&t)<<4|h>>4]+u+r}t=i.join("")}e=e.g=t}return e}return e instanceof ha?e=e.size!==0?e.V(b8):void 0:void 0}return e}let T8,E8;function hw(e){return sm(e=e.v,0|e[Zt],Kf)}function $o(e,t){return dw(e,t[0],t[1])}function dw(e,t,n,i=0){if(e==null){var r=32;n?(e=[n],r|=128):e=[],t&&(r=-16760833&r|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error("narr");if(r=0|e[Zt],PT&&1&r)throw Error("rfarr");if(2048&r&&!(2&r)&&(function(){if(PT)throw Error("carr");zc(t8,5)})(),256&r)throw Error("farr");if(64&r)return(r|i)!==r&&ei(e,r|i),e;if(n&&(r|=128,n!==e[0]))throw Error("mid");t:{r|=64;var o=(n=e).length;if(o){var c=o-1;const h=n[c];if(h!=null&&typeof h=="object"&&h.constructor===Object){if((c-=t=128&r?0:-1)>=1024)throw Error("pvtlmt");for(var u in h)(o=+u)1024)throw Error("spvt");r=-16760833&r|(1023&u)<<14}}}return ei(e,64|r|i),e}function A8(e,t){if(typeof e!="object")return e;if(Array.isArray(e)){var n=0|e[Zt];return e.length===0&&1&n?void 0:YT(e,n,t)}if(e!=null&&e[Vc]===Hc)return KT(e);if(e instanceof ha){if(2&(t=e.J))return e;if(!e.size)return;if(n=ih(e.V()),e.K)for(e=0;e=o)if(c=e[o],c!=null&&typeof c=="object"&&c.constructor===Object)n=c[t],u=!0;else{if(r!==o)return;n=c}else n=e[r];if(i&&n!=null){if((i=i(n))==null)return i;if(!Object.is(i,n))return u?c[t]=i:e[r]=i,i}return n}}function an(e,t,n,i){ou(e),Qn(e=e.v,0|e[Zt],t,n,i)}function Qn(e,t,n,i,r){const o=n+(r?0:-1);var c=e.length-1;if(c>=1+(r?0:-1)&&o>=c){const u=e[c];if(u!=null&&typeof u=="object"&&u.constructor===Object)return u[n]=i,t}return o<=c?(e[o]=i,t):(i!==void 0&&(n>=(c=(t??(t=0|e[Zt]))>>14&1023||536870912)?i!=null&&(e[c+(r?0:-1)]={[n]:i}):e[o]=i),t)}function Ko(){return e8===void 0?2:4}function Zo(e,t,n,i,r){let o=e.v,c=0|o[Zt];i=gs(e,c)?1:i,r=!!r||i===3,i===2&&au(e)&&(o=e.v,c=0|o[Zt]);let u=(e=ly(o,t))===dl?7:0|e[Zt],h=cy(u,c);var d=!(4&h);if(d){4&h&&(e=ir(e),u=0,h=el(h,c),c=Qn(o,c,t,e));let p=0,m=0;for(;p{const u=sy(c,n,!1,t);return o=u!==c&&u!=null,u})))!=null)return o&&!gs(i)&&pl(e,t),i}function He(e,t,n,i){let r=e.v,o=0|r[Zt];if((t=yw(r,o,t,n,i))==null)return t;if(o=0|r[Zt],!gs(e,o)){const c=ay(t);c!==t&&(au(e)&&(r=e.v,o=0|r[Zt]),o=Qn(r,o,n,t=c,i),pl(r,o))}return t}function xw(e,t,n,i,r,o,c,u){var h=gs(e,n);o=h?1:o,c=!!c||o===3,h=u&&!h,(o===2||h)&&au(e)&&(n=0|(t=e.v)[Zt]);var d=(e=ly(t,r))===dl?7:0|e[Zt],p=cy(d,n);if(u=!(4&p)){var m=e,_=n;const y=!!(2&p);y&&(_|=2);let M=!y,T=!0,S=0,x=0;for(;S32)for(r|=(127&n)>>4,o=3;o<32&&128&n;o+=7)n=c[u++],r|=(127&n)<>>0,r>>>0);throw Error()}function gy(e){let t=0,n=e.g;const i=n+10,r=e.h;for(;n>>0}function Pp(e){var t=e.h;const n=e.g;var i=t[n],r=t[n+1];const o=t[n+2];return t=t[n+3],nl(e,e.g+4),e=2*((r=(i<<0|r<<8|o<<16|t<<24)>>>0)>>31)+1,i=r>>>23&255,r&=8388607,i==255?r?NaN:e*(1/0):i==0?1401298464324817e-60*e*r:e*Math.pow(2,i-150)*(r+8388608)}function w8(e){return ao(e)}function nl(e,t){if(e.g=t,t>e.l)throw Error()}function Mw(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 bw(e,t){if(t==0)return cl();var n=Mw(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):l8?e.slice(n,t):new Uint8Array(e.subarray(n,t))),n.length==0?cl():new Mr(n,kc)}var ZT=[];function Tw(e,t,n,i){if(Op.length){const r=Op.pop();return r.o(i),r.g.init(e,t,n,i),r}return new R8(e,t,n,i)}function Ew(e){e.g.clear(),e.l=-1,e.h=-1,Op.length<100&&Op.push(e)}function Aw(e){var t=e.g;if(t.g==t.l)return!1;e.m=e.g.g;var n=Er(e.g);if(t=n>>>3,!((n&=7)>=0&&n<=5)||t<1)throw Error();return e.l=t,e.h=n,!0}function mp(e){switch(e.h){case 0:e.h!=0?mp(e):gy(e.g);break;case 1:nl(e=e.g,e.g+8);break;case 2:if(e.h!=2)mp(e);else{var t=Er(e.g);nl(e=e.g,e.g+t)}break;case 5:nl(e=e.g,e.g+4);break;case 3:for(t=e.l;;){if(!Aw(e))throw Error();if(e.h==4){if(e.l!=t)throw Error();break}mp(e)}break;default:throw Error()}}function oh(e,t,n){const i=e.g.l;var r=Er(e.g);let o=(r=e.g.g+r)-i;if(o<=0&&(e.g.l=r,n(t,e,void 0,void 0,void 0),o=r-e.g.g),o)throw Error();return e.g.g=r,e.g.l=i,t}function _y(e){var t=Er(e.g),n=Mw(e=e.g,t);if(e=e.h,VB){var i,r=e;(i=x_)||(i=x_=new TextDecoder("utf-8",{fatal:!0})),t=n+t,r=n===0&&t===r.length?r:r.subarray(n,t);try{var o=i.decode(r)}catch(u){if(Qd===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),Qd=!0}catch{Qd=!1}}throw!Qd&&(x_=void 0),u}}else{t=(o=n)+t,n=[];let u,h=null;for(;o=t?ko():(u=e[o++],c<194||(192&u)!=128?(o--,ko()):n.push((31&c)<<6|63&u)):c<240?o>=t-1?ko():(u=e[o++],(192&u)!=128||c===224&&u<160||c===237&&u>=160||(192&(i=e[o++]))!=128?(o--,ko()):n.push((15&c)<<12|(63&u)<<6|63&i)):c<=244?o>=t-2?ko():(u=e[o++],(192&u)!=128||u-144+(c<<28)>>30!=0||(192&(i=e[o++]))!=128||(192&(r=e[o++]))!=128?(o--,ko()):(c=(7&c)<<18|(63&u)<<12|(63&i)<<6|63&r,c-=65536,n.push(55296+(c>>10&1023),56320+(1023&c)))):ko(),n.length>=8192&&(h=UT(h,n),n.length=0)}o=UT(h,n)}return o}function ww(e){const t=Er(e.g);return bw(e.g,t)}function am(e,t,n){var i=Er(e.g);for(i=e.g.g+i;e.g.g>>0,this.g=t>>>0}};let C8;function JT(e){return e?/^-?\d+$/.test(e)?(em(e),new Wv(yn,zn)):null:D8||(D8=new Wv(0,0))}var Wv=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let D8;function Ec(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 cu(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function om(e,t){if(t>=0)cu(e,t);else{for(let n=0;n<9;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function vy(e){var t=yn;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 jc(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function ks(e,t,n){cu(e.g,8*t+n)}function yy(e,t){return ks(e,t,2),t=e.g.end(),jc(e,t),t.push(e.h),t}function xy(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 lm(e,t,n){ks(e,t,2),cu(e.g,n.length),jc(e,e.g.end()),jc(e,n)}function Ip(e,t,n,i){n!=null&&(t=yy(e,t),i(n,e),xy(e,t))}function Dr(){const e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var Sy=Dr(),Rw=Dr(),My=Dr(),by=Dr(),Ty=Dr(),Cw=Dr(),L8=Dr(),cm=Dr(),Dw=Dr(),Lw=Dr();function Lr(e,t,n){var i=e.v;ds&&ds in i&&(i=i[ds])&&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 Qt=class{constructor(e,t){this.v=dw(e,t,void 0,2048)}toJSON(){return hw(this)}j(){var r;var e=hF,t=this.v,n=e.g,i=ds;if(nu&&i&&((r=t[i])==null?void 0:r[n])!=null&&zc(JB,3),t=e.g,kT&&ds&&kT===void 0&&(i=(n=this.v)[ds])&&(i=i.da))try{i(n,t,S8)}catch(o){X3(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[Zt];return oy(this,e,t)?ry(this,e,!0):new this.constructor(ru(e,t,!1))}};Qt.prototype[Vc]=Hc,Qt.prototype.toString=function(){return this.v.toString()};var uu=class{constructor(e,t,n){this.g=e,this.h=t,e=Sy,this.l=!!e&&n===e||!1}};function um(e,t){return new uu(e,t,Sy)}function Nw(e,t,n,i,r){Ip(e,n,Iw(t,i),r)}const N8=um((function(e,t,n,i,r){return e.h===2&&(oh(e,hy(t,i,n),r),!0)}),Nw),U8=um((function(e,t,n,i,r){return e.h===2&&(oh(e,hy(t,i,n),r),!0)}),Nw);var fm=Symbol(),hm=Symbol(),jv=Symbol(),$T=Symbol(),tE=Symbol();let Uw,Pw;function ml(e,t,n,i){var r=i[e];if(r)return r;(r={}).qa=i,r.T=(function(m){switch(typeof m){case"boolean":return T8||(T8=[0,void 0,!0]);case"number":return m>0?void 0:m===0?E8||(E8=[0,void 0]):[-m,void 0];case"string":return[0,m];case"object":return m}})(i[0]);var o=i[1];let c=1;o&&o.constructor===Object&&(r.ba=o,typeof(o=i[++c])=="function"&&(r.ma=!0,Uw??(Uw=o),Pw??(Pw=i[c+1]),o=i[c+=2]));const u={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var h=0;hr(o,c,u,i):r}function Ay(e,t,n,i,r){const o=n.g;let c,u;e[t]=(h,d,p)=>o(h,d,p,u||(u=ml(hm,Ey,Ay,i).T),c||(c=wy(i)),r)}function wy(e){let t=e[jv];if(t!=null)return t;const n=ml(hm,Ey,Ay,e);return t=n.ma?(i,r)=>Uw(i,r,n):(i,r)=>{for(;Aw(r)&&r.h!=4;){var o=r.l,c=n[o];if(c==null){var u=n.ba;u&&(u=u[o])&&(u=O8(u))!=null&&(c=n[o]=u)}if(c==null||!c(r,i,o)){if(c=(u=r).m,mp(u),u.ha)var h=void 0;else h=u.g.g-c,u.g.g=c,h=bw(u.g,h);c=void 0,u=i,h&&((c=u[ds]??(u[ds]=new Hv))[o]??(c[o]=[])).push(h)}}return(i=im(i))&&(i.da=n.qa[tE]),!0},e[jv]=t,e[tE]=P8.bind(e),t}function P8(e,t,n,i){var r=this[hm];const o=this[jv],c=$o(void 0,r.T),u=im(e);if(u){var h=!1,d=r.ba;if(d){if(r=(p,m,_)=>{if(_.length!==0)if(d[m])for(const y of _){p=Tw(y);try{h=!0,o(c,p)}finally{Ew(p)}}else i==null||i(e,m,_)},t==null)Np(u,r);else if(u!=null){const p=u[t];p&&r(u,t,p)}if(h){let p=0|e[Zt];if(2&p&&2048&p&&!(n!=null&&n.Ka))throw Error();const m=iu(p),_=(y,M)=>{if(da(e,y,m)!=null){if((n==null?void 0:n.Qa)===1)return;throw Error()}M!=null&&(p=Qn(e,p,y,M,m)),delete u[y]};t==null?ew(c,0|c[Zt],((y,M)=>{_(y,M)})):_(t,da(c,t,m))}}}}function O8(e){const t=(e=Ow(e))[0].g;if(e=e[1]){const n=wy(e),i=ml(hm,Ey,Ay,e).T;return(r,o,c)=>t(r,o,c,i,n)}return t}function dm(e,t,n){e[t]=n.h}function pm(e,t,n,i){let r,o;const c=n.h;e[t]=(u,h,d)=>c(u,h,d,o||(o=ml(fm,dm,pm,i).T),r||(r=Bw(i)))}function Bw(e){let t=e[$T];if(!t){const n=ml(fm,dm,pm,e);t=(i,r)=>Fw(i,r,n),e[$T]=t}return t}function Fw(e,t,n){ew(e,0|e[Zt],((i,r)=>{if(r!=null){var o=(function(c,u){var h=c[u];if(h)return h;if((h=c.ba)&&(h=h[u])){var d=(h=Ow(h))[0].h;if(h=h[1]){const p=Bw(h),m=ml(fm,dm,pm,h).T;h=c.ma?Pw(m,p):(_,y,M)=>d(_,y,M,m,p)}else h=d;return c[u]=h}})(n,i);o?o(t,r,i):i<500||zc(zv,3)}})),(e=im(e))&&Np(e,((i,r,o)=>{for(jc(t,t.g.end()),i=0;i{Ip(e,n,$o([c,o],i),r)}));else if(Array.isArray(t)){for(let o=0;o>BigInt(32))),Ec(e.g,n.h,n.g);break;default:n=JT(t),Ec(e.g,n.h,n.g)}}function Vw(e,t,n){(t=su(t))!=null&&t!=null&&(ks(e,n,0),om(e.g,t))}function Hw(e,t,n){(t=rw(t))!=null&&(ks(e,n,0),e.g.g.push(t?1:0))}function Gw(e,t,n){(t=_i(t))!=null&&lm(e,n,j3(t))}function Ww(e,t,n,i,r){Ip(e,n,Iw(t,i),r)}function jw(e,t,n){(t=t==null||typeof t=="string"||t instanceof Mr?t:void 0)!=null&&lm(e,n,py(t,!0).buffer)}function Xw(e,t,n){(t=aw(t))!=null&&t!=null&&(ks(e,n,0),cu(e.g,t))}function qw(e,t,n){return(e.h===5||e.h===2)&&(t=lu(t,0|t[Zt],n),e.h==2?am(e,Pp,t):t.push(Pp(e.g)),!0)}var Vn=Ti((function(e,t,n){return e.h===5&&(Ei(t,n,Pp(e.g)),!0)}),kw,cm),F8=hu(qw,(function(e,t,n){if((t=fu(xr,t))!=null)for(let c=0;c=0?i=String(r):((r=i.indexOf("."))!==-1&&(i=i.substring(0,r)),(r=i[0]!=="-"&&((r=i.length)<20||r===20&&i<="18446744073709551615"))||(em(i),i=qf(yn,zn))),i;if(r==="number")return(i=Wc(i))>=0&&fl(i)||(Gc(i),i=iw(yn,zn)),i}})(t),t!=null&&(typeof t=="string"&&QT(t),t!=null))switch(ks(e,n,0),typeof t){case"number":e=e.g,Gc(t),Ec(e,yn,zn);break;case"bigint":n=BigInt.asUintN(64,t),n=new Gv(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),Ec(e.g,n.h,n.g);break;default:n=QT(t),Ec(e.g,n.h,n.g)}}),L8),Kn=Ti((function(e,t,n){return e.h===0&&(Ei(t,n,ao(e.g)),!0)}),Vw,by),lh=hu((function(e,t,n){return(e.h===0||e.h===2)&&(t=lu(t,0|t[Zt],n),e.h==2?am(e,ao,t):t.push(ao(e.g)),!0)}),(function(e,t,n){if((t=fu(su,t))!=null&&t.length){n=yy(e,n);for(let i=0;i{{const o={ea:!0};i&&Object.assign(o,i),n=Tw(n,void 0,void 0,o);try{const c=new e,u=c.v;wy(t)(u,n);var r=c}finally{Ew(n)}}return r}}function mm(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 c=this.g;return this.g=[],c}}}};Fw(this.v,t,ml(fm,dm,pm,e)),jc(t,t.g.end());const n=new Uint8Array(t.h),i=t.l,r=i.length;let o=0;for(let c=0;cr;n=iE.createPolicy("goog#html",{createHTML:i,createScript:i,createScriptURL:i})}catch{}return n})()),e=(t=E_)?t.createScriptURL(e):e,new class{constructor(n){this.g=n}toString(){return this.g+""}}(e)}function Jd(e,...t){if(t.length===0)return sE(e[0]);let n=e[0];for(let i=0;i({index:Is(i,1)??0??-1,score:Un(i,2)??0,categoryName:_i(xn(i,3))??""??"",displayName:_i(xn(i,4))??""??""}))),headIndex:t,headName:n}}function gF(e){const t={classifications:pa(e,Q8,1).map((n=>{var i;return Iy(((i=He(n,n4,4))==null?void 0:i.g())??[],Is(n,2)??0,_i(xn(n,3))??"")}))};return(function(n){return n==null?n:typeof n=="bigint"?(Vv(n)?n=Number(n):(n=sh(64,n),n=Vv(n)?Number(n):String(n)),n):rh(n)?typeof n=="number"?iy(n):lw(n):void 0})(xn(e,2,void 0,void 0,Lp))!=null&&(t.timestampMs=C4(xn(e,2,void 0,void 0,Lp)??pw)),t}function D4(e){var c,u;var t=Zo(e,3,xr,Ko()),n=Zo(e,2,su,Ko()),i=Zo(e,1,_i,Ko()),r=Zo(e,9,_i,Ko());const o={categories:[],keypoints:[]};for(let h=0;ht>127?t-256:t))}function gE(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,r=0;for(let o=0;o=1&&Number(e[1])>=17))}async function _E(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",(r=>{i(r)}),!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 U4(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 Jt(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 vE(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,r]=U4(t);return!e.l||i===e.i.canvas.width&&r===e.i.canvas.height||(e.i.canvas.width=i,e.i.canvas.height=r),[i,r]}function yE(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 r=0;r>2),n(t);for(const r of i)e.i._free(r);e.i._free(t)}function pr(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function qa(e,t,n){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(r,o,c)=>{o?(n(i,c),i=[]):i.push(r)}}hc.forVisionTasks=function(e,t=!1){return tp("vision",e??Jd``,t)},hc.forTextTasks=function(e,t=!1){return tp("text",e??Jd``,t)},hc.forGenAiTasks=function(e,t=!1){return tp("genai",e??Jd``,t)},hc.forAudioTasks=function(e,t=!1){return tp("audio",e??Jd``,t)},hc.isSimdSupported=function(e=!1){return L4(e)};async function vF(e,t,n,i){return e=await(async(r,o,c,u,h)=>{if(o&&await _E(o),!self.ModuleFactory||c&&(await _E(c),!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 r(h,u)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile:r=>r.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&r.endsWith(".data")?n.assetBinaryPath.toString():r}),await e.o(i),e}function R_(e,t){const n=He(e.baseOptions,Bp,1)||new Bp;typeof t=="string"?(an(n,2,ah(t)),an(n,1)):t instanceof Uint8Array&&(an(n,1,$1(t,!1)),an(n,2)),ae(e.baseOptions,0,1,n)}function xE(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 jt(e,t){e.C=Math.max(e.C,t)}function ym(e,t){e.B=new Ji,_s(e.B,2,"PassThroughCalculator"),vn(e.B,"free_memory"),Ie(e.B,"free_memory_unused_out"),bn(t,"free_memory"),zs(t,e.B)}function Xc(e,t){vn(e.B,t),Ie(e.B,t+"_unused_out")}function xm(e){e.g.addBoolToStream(!0,"free_memory",e.C)}var Zv=class{constructor(e){this.g=e,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){var n,i,r,o,c,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(!((r=He(this.baseOptions,Bp,1))!=null&&r.g()||(o=He(this.baseOptions,Bp,1))!=null&&o.l()||(c=e.baseOptions)!=null&&c.modelAssetBuffer||(u=e.baseOptions)!=null&&u.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if((function(d,p){let m=He(d.baseOptions,fE,3);if(!m){var _=m=new fE,y=new rE;Pf(_,4,gp,y)}"delegate"in p&&(p.delegate==="GPU"?(p=m,_=new W8,Pf(p,2,gp,_)):(p=m,_=new rE,Pf(p,4,gp,_))),ae(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),R_(this,"/model.dat"),this.m(),this.L()}));if(h.modelAssetBuffer instanceof Uint8Array)R_(this,h.modelAssetBuffer);else if(h.modelAssetBuffer)return(async function(d){const p=[];for(var m=0;;){const{done:_,value:y}=await d.read();if(_)break;p.push(y),m+=y.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];d=new Uint8Array(m),m=0;for(const _ of p)d.set(_,m),m+=_.length;return d})(h.modelAssetBuffer).then((d=>{R_(this,d),this.m(),this.L()}))}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let e;if(this.g.ca((t=>{e=j8(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,xE(this)}finishProcessing(){this.g.finishProcessing(),xE(this)}close(){this.B=void 0,this.g.closeGraph()}};function so(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Zv.prototype.close=Zv.prototype.close;class yF{constructor(t,n,i,r){this.g=t,this.h=n,this.m=i,this.l=r}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function SE(e,t,n){const i=e.g;if(n=so(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 ME(e,t){const n=e.g,i=so(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(i);const r=so(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,r),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=so(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 yF(n,i,r,o)}function By(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function xF(e,t,n,i){return By(e,t),e.h||(e.m(),e.D()),n?(e.u||(e.u=ME(e,!0)),n=e.u):(e.A||(e.A=ME(e,!1)),n=e.A),t.useProgram(e.h),n.bind(),e.l(),e=i(),n.g.bindVertexArray(null),e}function P4(e,t,n){return By(e,t),e=so(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 O4(e,t,n){By(e,t),e.B||(e.B=so(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 SF(e){var t;(t=e.g)==null||t.bindFramebuffer(e.g.FRAMEBUFFER,null)}var I4=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=so(e.createProgram(),"Failed to create WebGL program"),this.X=SE(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=SE(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 aa(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 Qv(e){var t=aa(e,1);if(!t){if(t=aa(e,0))t=new Float32Array(t).map((i=>i/255));else{t=new Float32Array(e.width*e.height);const i=qc(e);var n=Fy(e);if(O4(n,i,B4(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 r=0,o=0;rMath.round(255*n)))),e.g.push(t)),t;var e,t}ia(){return Qv(this)}N(){return B4(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=qc(this),r=Fy(this);i.activeTexture(i.TEXTURE1),n=P4(r,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,n);const o=F4(this);i.texImage2D(i.TEXTURE_2D,0,o,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),O4(r,i,n),xF(r,i,!1,(()=>{k4(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Jv(this)})),SF(r),Jv(this)}}e.push(n)}return new ri(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&qc(this).deleteTexture(aa(this,2)),bE=-1}};ri.prototype.close=ri.prototype.close,ri.prototype.clone=ri.prototype.clone,ri.prototype.getAsWebGLTexture=ri.prototype.N,ri.prototype.getAsFloat32Array=ri.prototype.ia,ri.prototype.getAsUint8Array=ri.prototype.ja,ri.prototype.hasWebGLTexture=ri.prototype.R,ri.prototype.hasFloat32Array=ri.prototype.ka,ri.prototype.hasUint8Array=ri.prototype.Fa;var bE=250;function ar(...e){return e.map((([t,n])=>({start:t,end:n})))}const MF=(function(e){return class extends e{Ja(){this.i._registerModelResourcesGraphService()}}})((TE=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:N4()?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,r){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Jt(this,i||"input_audio",(o=>{Jt(this,r=r||"audio_header",(c=>{this.i._configureAudio(o,c,e,t??0,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ca(e){pr(this,"__graph_config__",(t=>{e(t)})),Jt(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,r){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),Jt(this,i,(c=>{this.i._addAudioToInputStream(this.g,t,n,c,r)}))}addGpuBufferToStream(e,t,n){Jt(this,t,(i=>{const[r,o]=vE(this,e,i);this.i._addBoundTextureToStream(i,r,o,n)}))}addBoolToStream(e,t,n){Jt(this,t,(i=>{this.i._addBoolToInputStream(e,i,n)}))}addDoubleToStream(e,t,n){Jt(this,t,(i=>{this.i._addDoubleToInputStream(e,i,n)}))}addFloatToStream(e,t,n){Jt(this,t,(i=>{this.i._addFloatToInputStream(e,i,n)}))}addIntToStream(e,t,n){Jt(this,t,(i=>{this.i._addIntToInputStream(e,i,n)}))}addUintToStream(e,t,n){Jt(this,t,(i=>{this.i._addUintToInputStream(e,i,n)}))}addStringToStream(e,t,n){Jt(this,t,(i=>{Jt(this,e,(r=>{this.i._addStringToInputStream(r,i,n)}))}))}addStringRecordToStream(e,t,n){Jt(this,t,(i=>{yE(this,Object.keys(e),(r=>{yE(this,Object.values(e),(o=>{this.i._addFlatHashMapToInputStream(r,o,Object.keys(e).length,i,n)}))}))}))}addProtoToStream(e,t,n,i){Jt(this,n,(r=>{Jt(this,t,(o=>{const c=this.i._malloc(e.length);this.i.HEAPU8.set(e,c),this.i._addProtoToInputStream(c,e.length,o,r,i),this.i._free(c)}))}))}addEmptyPacketToStream(e,t){Jt(this,e,(n=>{this.i._addEmptyPacketToInputStream(n,t)}))}addBoolVectorToStream(e,t,n){Jt(this,t,(i=>{const r=this.i._allocateBoolVector(e.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(const o of e)this.i._addBoolVectorEntry(r,o);this.i._addBoolVectorToInputStream(r,i,n)}))}addDoubleVectorToStream(e,t,n){Jt(this,t,(i=>{const r=this.i._allocateDoubleVector(e.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(const o of e)this.i._addDoubleVectorEntry(r,o);this.i._addDoubleVectorToInputStream(r,i,n)}))}addFloatVectorToStream(e,t,n){Jt(this,t,(i=>{const r=this.i._allocateFloatVector(e.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(const o of e)this.i._addFloatVectorEntry(r,o);this.i._addFloatVectorToInputStream(r,i,n)}))}addIntVectorToStream(e,t,n){Jt(this,t,(i=>{const r=this.i._allocateIntVector(e.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(const o of e)this.i._addIntVectorEntry(r,o);this.i._addIntVectorToInputStream(r,i,n)}))}addUintVectorToStream(e,t,n){Jt(this,t,(i=>{const r=this.i._allocateUintVector(e.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(const o of e)this.i._addUintVectorEntry(r,o);this.i._addUintVectorToInputStream(r,i,n)}))}addStringVectorToStream(e,t,n){Jt(this,t,(i=>{const r=this.i._allocateStringVector(e.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(const o of e)Jt(this,o,(c=>{this.i._addStringVectorEntry(r,c)}));this.i._addStringVectorToInputStream(r,i,n)}))}addBoolToInputSidePacket(e,t){Jt(this,t,(n=>{this.i._addBoolToInputSidePacket(e,n)}))}addDoubleToInputSidePacket(e,t){Jt(this,t,(n=>{this.i._addDoubleToInputSidePacket(e,n)}))}addFloatToInputSidePacket(e,t){Jt(this,t,(n=>{this.i._addFloatToInputSidePacket(e,n)}))}addIntToInputSidePacket(e,t){Jt(this,t,(n=>{this.i._addIntToInputSidePacket(e,n)}))}addUintToInputSidePacket(e,t){Jt(this,t,(n=>{this.i._addUintToInputSidePacket(e,n)}))}addStringToInputSidePacket(e,t){Jt(this,t,(n=>{Jt(this,e,(i=>{this.i._addStringToInputSidePacket(i,n)}))}))}addProtoToInputSidePacket(e,t,n){Jt(this,n,(i=>{Jt(this,t,(r=>{const o=this.i._malloc(e.length);this.i.HEAPU8.set(e,o),this.i._addProtoToInputSidePacket(o,e.length,r,i),this.i._free(o)}))}))}addBoolVectorToInputSidePacket(e,t){Jt(this,t,(n=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const r of e)this.i._addBoolVectorEntry(i,r);this.i._addBoolVectorToInputSidePacket(i,n)}))}addDoubleVectorToInputSidePacket(e,t){Jt(this,t,(n=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const r of e)this.i._addDoubleVectorEntry(i,r);this.i._addDoubleVectorToInputSidePacket(i,n)}))}addFloatVectorToInputSidePacket(e,t){Jt(this,t,(n=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const r of e)this.i._addFloatVectorEntry(i,r);this.i._addFloatVectorToInputSidePacket(i,n)}))}addIntVectorToInputSidePacket(e,t){Jt(this,t,(n=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const r of e)this.i._addIntVectorEntry(i,r);this.i._addIntVectorToInputSidePacket(i,n)}))}addUintVectorToInputSidePacket(e,t){Jt(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 r of e)this.i._addUintVectorEntry(i,r);this.i._addUintVectorToInputSidePacket(i,n)}))}addStringVectorToInputSidePacket(e,t){Jt(this,t,(n=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const r of e)Jt(this,r,(o=>{this.i._addStringVectorEntry(i,o)}));this.i._addStringVectorToInputSidePacket(i,n)}))}attachBoolListener(e,t){pr(this,e,t),Jt(this,e,(n=>{this.i._attachBoolListener(n)}))}attachBoolVectorListener(e,t){qa(this,e,t),Jt(this,e,(n=>{this.i._attachBoolVectorListener(n)}))}attachIntListener(e,t){pr(this,e,t),Jt(this,e,(n=>{this.i._attachIntListener(n)}))}attachIntVectorListener(e,t){qa(this,e,t),Jt(this,e,(n=>{this.i._attachIntVectorListener(n)}))}attachUintListener(e,t){pr(this,e,t),Jt(this,e,(n=>{this.i._attachUintListener(n)}))}attachUintVectorListener(e,t){qa(this,e,t),Jt(this,e,(n=>{this.i._attachUintVectorListener(n)}))}attachDoubleListener(e,t){pr(this,e,t),Jt(this,e,(n=>{this.i._attachDoubleListener(n)}))}attachDoubleVectorListener(e,t){qa(this,e,t),Jt(this,e,(n=>{this.i._attachDoubleVectorListener(n)}))}attachFloatListener(e,t){pr(this,e,t),Jt(this,e,(n=>{this.i._attachFloatListener(n)}))}attachFloatVectorListener(e,t){qa(this,e,t),Jt(this,e,(n=>{this.i._attachFloatVectorListener(n)}))}attachStringListener(e,t){pr(this,e,t),Jt(this,e,(n=>{this.i._attachStringListener(n)}))}attachStringVectorListener(e,t){qa(this,e,t),Jt(this,e,(n=>{this.i._attachStringVectorListener(n)}))}attachProtoListener(e,t,n){pr(this,e,t),Jt(this,e,(i=>{this.i._attachProtoListener(i,n||!1)}))}attachProtoVectorListener(e,t,n){qa(this,e,t),Jt(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?'),pr(this,e,((i,r)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,r)})),Jt(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 TE{get ga(){return this.i}pa(e,t,n){Jt(this,t,(i=>{const[r,o]=vE(this,e,i);this.ga._addBoundTextureAsImageToStream(i,r,o,n)}))}Z(e,t){pr(this,e,t),Jt(this,e,(n=>{this.ga._attachImageListener(n)}))}aa(e,t){qa(this,e,t),Jt(this,e,(n=>{this.ga._attachImageVectorListener(n)}))}}));var TE,or=class extends MF{};async function Fe(e,t,n){return(async function(i,r,o,c){return vF(i,r,o,c)})(e,n.canvas??(N4()?void 0:document.createElement("canvas")),t,n)}function z4(e,t,n,i){if(e.U){const o=new o4;if(n!=null&&n.regionOfInterest){if(!e.oa)throw Error("This task doesn't support region-of-interest.");var r=n.regionOfInterest;if(r.left>=r.right||r.top>=r.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(r.left<0||r.top<0||r.right>1||r.bottom>1)throw Error("Expected RectF values to be in [0,1].");ie(o,1,(r.left+r.right)/2),ie(o,2,(r.top+r.bottom)/2),ie(o,4,r.right-r.left),ie(o,3,r.bottom-r.top)}else ie(o,1,.5),ie(o,2,.5),ie(o,4,1),ie(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(ie(o,5,-Math.PI*n.rotationDegrees/180),(n==null?void 0:n.rotationDegrees)%180!=0){const[c,u]=U4(t);n=Un(o,3)*u/c,r=Un(o,4)*c/u,ie(o,4,n),ie(o,3,r)}}e.g.addProtoToStream(o.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.pa(t,e.X,i??performance.now()),e.finishProcessing()}function lr(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'.");z4(e,t,n,e.C+1)}function Ur(e,t,n,i){var r;if(!((r=e.baseOptions)!=null&&r.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");z4(e,t,n,i)}function Yc(e,t,n,i){var r=t.data;const o=t.width,c=o*(t=t.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==c)throw Error("Unsupported channel count: "+r.length/c);return e=new ri([r],n,!1,e.g.i.canvas,e.P,o,t),i?e.clone():e}var vs=class extends Zv{constructor(e,t,n,i){super(e),this.g=e,this.X=t,this.U=n,this.oa=i,this.P=new I4}l(e,t=!0){if("runningMode"in e&&an(this.baseOptions,2,Yf(!!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()}};vs.prototype.close=vs.prototype.close;var Ds=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},ae(e=this.h=new _m,0,1,t=new Dn),ie(this.h,2,.5),ie(this.h,3,.3)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&ie(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&ie(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},lr(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Ur(this,e,n,t),this.j}m(){var e=new xs;bn(e,"image_in"),bn(e,"norm_rect_in"),je(e,"detections");const t=new ys;Lr(t,iF,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),vn(n,"IMAGE:image_in"),vn(n,"NORM_RECT:norm_rect_in"),Ie(n,"DETECTIONS:detections"),n.o(t),zs(e,n),this.g.attachProtoVectorListener("detections",((i,r)=>{for(const o of i)i=s4(o),this.j.detections.push(D4(i));jt(this,r)})),this.g.attachEmptyPacketListener("detections",(i=>{jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ds.prototype.detectForVideo=Ds.prototype.G,Ds.prototype.detect=Ds.prototype.F,Ds.prototype.setOptions=Ds.prototype.o,Ds.createFromModelPath=async function(e,t){return Fe(Ds,e,{baseOptions:{modelAssetPath:t}})},Ds.createFromModelBuffer=function(e,t){return Fe(Ds,e,{baseOptions:{modelAssetBuffer:t}})},Ds.createFromOptions=function(e,t){return Fe(Ds,e,t)};var ky=ar([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]),zy=ar([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]),Vy=ar([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),V4=ar([474,475],[475,476],[476,477],[477,474]),Hy=ar([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]),Gy=ar([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),H4=ar([469,470],[470,471],[471,472],[472,469]),Wy=ar([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]),G4=[...ky,...zy,...Vy,...Hy,...Gy,...Wy],W4=ar([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 EE(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Rn=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,ae(e=this.h=new h4,0,1,t=new Dn),this.A=new f4,ae(this.h,0,3,this.A),this.u=new _m,ae(this.h,0,2,this.u),ma(this.u,4,1),ie(this.u,2,.5),ie(this.A,2,.5),ie(this.h,4,.5)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){return"numFaces"in e&&ma(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&ie(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&ie(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&ie(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 EE(this),lr(this,e,t),this.j}G(e,t,n){return EE(this),Ur(this,e,n,t),this.j}m(){var e=new xs;bn(e,"image_in"),bn(e,"norm_rect"),je(e,"face_landmarks");const t=new ys;Lr(t,rF,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),vn(n,"IMAGE:image_in"),vn(n,"NORM_RECT:norm_rect"),Ie(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),zs(e,n),this.g.attachProtoVectorListener("face_landmarks",((i,r)=>{for(const o of i)i=ch(o),this.j.faceLandmarks.push(vm(i));jt(this,r)})),this.g.attachEmptyPacketListener("face_landmarks",(i=>{jt(this,i)})),this.outputFaceBlendshapes&&(je(e,"blendshapes"),Ie(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((i,r)=>{if(this.outputFaceBlendshapes)for(const o of i)i=gm(o),this.j.faceBlendshapes.push(Iy(i.g()??[]));jt(this,r)})),this.g.attachEmptyPacketListener("blendshapes",(i=>{jt(this,i)}))),this.outputFacialTransformationMatrixes&&(je(e,"face_geometry"),Ie(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((i,r)=>{if(this.outputFacialTransformationMatrixes)for(const o of i)(i=He(i=sF(o),K8,2))&&this.j.facialTransformationMatrixes.push({rows:Is(i,1)??0??0,columns:Is(i,2)??0??0,data:Zo(i,3,xr,Ko()).slice()??[]});jt(this,r)})),this.g.attachEmptyPacketListener("face_geometry",(i=>{jt(this,i)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Rn.prototype.detectForVideo=Rn.prototype.G,Rn.prototype.detect=Rn.prototype.F,Rn.prototype.setOptions=Rn.prototype.o,Rn.createFromModelPath=function(e,t){return Fe(Rn,e,{baseOptions:{modelAssetPath:t}})},Rn.createFromModelBuffer=function(e,t){return Fe(Rn,e,{baseOptions:{modelAssetBuffer:t}})},Rn.createFromOptions=function(e,t){return Fe(Rn,e,t)},Rn.FACE_LANDMARKS_LIPS=ky,Rn.FACE_LANDMARKS_LEFT_EYE=zy,Rn.FACE_LANDMARKS_LEFT_EYEBROW=Vy,Rn.FACE_LANDMARKS_LEFT_IRIS=V4,Rn.FACE_LANDMARKS_RIGHT_EYE=Hy,Rn.FACE_LANDMARKS_RIGHT_EYEBROW=Gy,Rn.FACE_LANDMARKS_RIGHT_IRIS=H4,Rn.FACE_LANDMARKS_FACE_OVAL=Wy,Rn.FACE_LANDMARKS_CONTOURS=G4,Rn.FACE_LANDMARKS_TESSELATION=W4;var jy=ar([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 AE(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function wE(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 RE(e,t=!0){const n=[];for(const r of e){var i=gm(r);e=[];for(const o of i.g())i=t&&Is(o,1)!=null?Is(o,1)??0:-1,e.push({score:Un(o,2)??0,index:i,categoryName:_i(xn(o,3))??""??"",displayName:_i(xn(o,4))??""??""});n.push(e)}return n}var ls=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ae(e=this.j=new m4,0,1,t=new Dn),this.u=new Ny,ae(this.j,0,2,this.u),this.D=new Ly,ae(this.u,0,3,this.D),this.A=new p4,ae(this.u,0,2,this.A),this.h=new aF,ae(this.j,0,3,this.h),ie(this.A,2,.5),ie(this.u,4,.5),ie(this.D,2,.5)}get baseOptions(){return He(this.j,Dn,1)}set baseOptions(e){ae(this.j,0,1,e)}o(e){var r,o,c,u;if(ma(this.A,3,e.numHands??1),"minHandDetectionConfidence"in e&&ie(this.A,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&ie(this.u,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&ie(this.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new fc,n=t,i=Kv(e.cannedGesturesClassifierOptions,(r=He(this.h,fc,3))==null?void 0:r.l());ae(n,0,2,i),ae(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((o=He(this.h,fc,3))==null||o.g());return e.customGesturesClassifierOptions?(ae(n=t=new fc,0,2,i=Kv(e.customGesturesClassifierOptions,(c=He(this.h,fc,4))==null?void 0:c.l())),ae(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((u=He(this.h,fc,4))==null||u.g()),this.l(e)}Ha(e,t){return AE(this),lr(this,e,t),wE(this)}Ia(e,t,n){return AE(this),Ur(this,e,n,t),wE(this)}m(){var e=new xs;bn(e,"image_in"),bn(e,"norm_rect"),je(e,"hand_gestures"),je(e,"hand_landmarks"),je(e,"world_hand_landmarks"),je(e,"handedness");const t=new ys;Lr(t,oF,this.j);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),vn(n,"IMAGE:image_in"),vn(n,"NORM_RECT:norm_rect"),Ie(n,"HAND_GESTURES:hand_gestures"),Ie(n,"LANDMARKS:hand_landmarks"),Ie(n,"WORLD_LANDMARKS:world_hand_landmarks"),Ie(n,"HANDEDNESS:handedness"),n.o(t),zs(e,n),this.g.attachProtoVectorListener("hand_landmarks",((i,r)=>{for(const o of i){i=ch(o);const c=[];for(const u of pa(i,a4,1))c.push({x:Un(u,1)??0,y:Un(u,2)??0,z:Un(u,3)??0,visibility:Un(u,4)??0});this.landmarks.push(c)}jt(this,r)})),this.g.attachEmptyPacketListener("hand_landmarks",(i=>{jt(this,i)})),this.g.attachProtoVectorListener("world_hand_landmarks",((i,r)=>{for(const o of i){i=Ac(o);const c=[];for(const u of pa(i,r4,1))c.push({x:Un(u,1)??0,y:Un(u,2)??0,z:Un(u,3)??0,visibility:Un(u,4)??0});this.worldLandmarks.push(c)}jt(this,r)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(i=>{jt(this,i)})),this.g.attachProtoVectorListener("hand_gestures",((i,r)=>{this.gestures.push(...RE(i,!1)),jt(this,r)})),this.g.attachEmptyPacketListener("hand_gestures",(i=>{jt(this,i)})),this.g.attachProtoVectorListener("handedness",((i,r)=>{this.handedness.push(...RE(i)),jt(this,r)})),this.g.attachEmptyPacketListener("handedness",(i=>{jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function CE(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}ls.prototype.recognizeForVideo=ls.prototype.Ia,ls.prototype.recognize=ls.prototype.Ha,ls.prototype.setOptions=ls.prototype.o,ls.createFromModelPath=function(e,t){return Fe(ls,e,{baseOptions:{modelAssetPath:t}})},ls.createFromModelBuffer=function(e,t){return Fe(ls,e,{baseOptions:{modelAssetBuffer:t}})},ls.createFromOptions=function(e,t){return Fe(ls,e,t)},ls.HAND_CONNECTIONS=jy;var cs=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ae(e=this.h=new Ny,0,1,t=new Dn),this.u=new Ly,ae(this.h,0,3,this.u),this.j=new p4,ae(this.h,0,2,this.j),ma(this.j,3,1),ie(this.j,2,.5),ie(this.u,2,.5),ie(this.h,4,.5)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){return"numHands"in e&&ma(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&ie(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&ie(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&ie(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],lr(this,e,t),CE(this)}G(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Ur(this,e,n,t),CE(this)}m(){var e=new xs;bn(e,"image_in"),bn(e,"norm_rect"),je(e,"hand_landmarks"),je(e,"world_hand_landmarks"),je(e,"handedness");const t=new ys;Lr(t,lF,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),vn(n,"IMAGE:image_in"),vn(n,"NORM_RECT:norm_rect"),Ie(n,"LANDMARKS:hand_landmarks"),Ie(n,"WORLD_LANDMARKS:world_hand_landmarks"),Ie(n,"HANDEDNESS:handedness"),n.o(t),zs(e,n),this.g.attachProtoVectorListener("hand_landmarks",((i,r)=>{for(const o of i)i=ch(o),this.landmarks.push(vm(i));jt(this,r)})),this.g.attachEmptyPacketListener("hand_landmarks",(i=>{jt(this,i)})),this.g.attachProtoVectorListener("world_hand_landmarks",((i,r)=>{for(const o of i)i=Ac(o),this.worldLandmarks.push(If(i));jt(this,r)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(i=>{jt(this,i)})),this.g.attachProtoVectorListener("handedness",((i,r)=>{var o=this.handedness,c=o.push;const u=[];for(const h of i){i=gm(h);const d=[];for(const p of i.g())d.push({score:Un(p,2)??0,index:Is(p,1)??0??-1,categoryName:_i(xn(p,3))??""??"",displayName:_i(xn(p,4))??""??""});u.push(d)}c.call(o,...u),jt(this,r)})),this.g.attachEmptyPacketListener("handedness",(i=>{jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};cs.prototype.detectForVideo=cs.prototype.G,cs.prototype.detect=cs.prototype.F,cs.prototype.setOptions=cs.prototype.o,cs.createFromModelPath=function(e,t){return Fe(cs,e,{baseOptions:{modelAssetPath:t}})},cs.createFromModelBuffer=function(e,t){return Fe(cs,e,{baseOptions:{modelAssetBuffer:t}})},cs.createFromOptions=function(e,t){return Fe(cs,e,t)},cs.HAND_CONNECTIONS=jy;var j4=ar([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 DE(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function LE(e){try{if(!e.D)return e.h;e.D(e.h)}finally{xm(e)}}function np(e,t){e=ch(e),t.push(vm(e))}var gn=class extends vs{constructor(e,t){super(new or(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,ae(e=this.j=new x4,0,1,t=new Dn),this.I=new Ly,ae(this.j,0,2,this.I),this.W=new cF,ae(this.j,0,3,this.W),this.u=new _m,ae(this.j,0,4,this.u),this.O=new f4,ae(this.j,0,5,this.O),this.A=new v4,ae(this.j,0,6,this.A),this.M=new y4,ae(this.j,0,7,this.M),ie(this.u,2,.5),ie(this.u,3,.3),ie(this.O,2,.5),ie(this.A,2,.5),ie(this.A,3,.3),ie(this.M,2,.5),ie(this.I,2,.5)}get baseOptions(){return He(this.j,Dn,1)}set baseOptions(e){ae(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&ie(this.u,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&ie(this.u,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&ie(this.O,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&ie(this.A,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&ie(this.A,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&ie(this.M,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&ie(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,DE(this),lr(this,e,i),LE(this)}G(e,t,n,i){const r=typeof n!="function"?n:{};return this.D=typeof n=="function"?n:i,DE(this),Ur(this,e,r,t),LE(this)}m(){var e=new xs;bn(e,"input_frames_image"),je(e,"pose_landmarks"),je(e,"pose_world_landmarks"),je(e,"face_landmarks"),je(e,"left_hand_landmarks"),je(e,"left_hand_world_landmarks"),je(e,"right_hand_landmarks"),je(e,"right_hand_world_landmarks");const t=new ys,n=new eE;_s(n,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),(function(r,o){if(o!=null)if(Array.isArray(o))an(r,2,sm(o,0,Kf));else{if(!(typeof o=="string"||o instanceof Mr||Q1(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Za(r,2,$1(o,!1),cl())}})(n,this.j.g());const i=new Ji;_s(i,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),dy(i,8,eE,n),vn(i,"IMAGE:input_frames_image"),Ie(i,"POSE_LANDMARKS:pose_landmarks"),Ie(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Ie(i,"FACE_LANDMARKS:face_landmarks"),Ie(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Ie(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Ie(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Ie(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),zs(e,i),ym(this,e),this.g.attachProtoListener("pose_landmarks",((r,o)=>{np(r,this.h.poseLandmarks),jt(this,o)})),this.g.attachEmptyPacketListener("pose_landmarks",(r=>{jt(this,r)})),this.g.attachProtoListener("pose_world_landmarks",((r,o)=>{var c=this.h.poseWorldLandmarks;r=Ac(r),c.push(If(r)),jt(this,o)})),this.g.attachEmptyPacketListener("pose_world_landmarks",(r=>{jt(this,r)})),this.outputPoseSegmentationMasks&&(Ie(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Xc(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",((r,o)=>{this.h.poseSegmentationMasks=[Yc(this,r,!0,!this.D)],jt(this,o)})),this.g.attachEmptyPacketListener("pose_segmentation_mask",(r=>{this.h.poseSegmentationMasks=[],jt(this,r)}))),this.g.attachProtoListener("face_landmarks",((r,o)=>{np(r,this.h.faceLandmarks),jt(this,o)})),this.g.attachEmptyPacketListener("face_landmarks",(r=>{jt(this,r)})),this.outputFaceBlendshapes&&(je(e,"extra_blendshapes"),Ie(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",((r,o)=>{var c=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(r=gm(r),c.push(Iy(r.g()??[]))),jt(this,o)})),this.g.attachEmptyPacketListener("extra_blendshapes",(r=>{jt(this,r)}))),this.g.attachProtoListener("left_hand_landmarks",((r,o)=>{np(r,this.h.leftHandLandmarks),jt(this,o)})),this.g.attachEmptyPacketListener("left_hand_landmarks",(r=>{jt(this,r)})),this.g.attachProtoListener("left_hand_world_landmarks",((r,o)=>{var c=this.h.leftHandWorldLandmarks;r=Ac(r),c.push(If(r)),jt(this,o)})),this.g.attachEmptyPacketListener("left_hand_world_landmarks",(r=>{jt(this,r)})),this.g.attachProtoListener("right_hand_landmarks",((r,o)=>{np(r,this.h.rightHandLandmarks),jt(this,o)})),this.g.attachEmptyPacketListener("right_hand_landmarks",(r=>{jt(this,r)})),this.g.attachProtoListener("right_hand_world_landmarks",((r,o)=>{var c=this.h.rightHandWorldLandmarks;r=Ac(r),c.push(If(r)),jt(this,o)})),this.g.attachEmptyPacketListener("right_hand_world_landmarks",(r=>{jt(this,r)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};gn.prototype.detectForVideo=gn.prototype.G,gn.prototype.detect=gn.prototype.F,gn.prototype.setOptions=gn.prototype.o,gn.createFromModelPath=function(e,t){return Fe(gn,e,{baseOptions:{modelAssetPath:t}})},gn.createFromModelBuffer=function(e,t){return Fe(gn,e,{baseOptions:{modelAssetBuffer:t}})},gn.createFromOptions=function(e,t){return Fe(gn,e,t)},gn.HAND_CONNECTIONS=jy,gn.POSE_CONNECTIONS=j4,gn.FACE_LANDMARKS_LIPS=ky,gn.FACE_LANDMARKS_LEFT_EYE=zy,gn.FACE_LANDMARKS_LEFT_EYEBROW=Vy,gn.FACE_LANDMARKS_LEFT_IRIS=V4,gn.FACE_LANDMARKS_RIGHT_EYE=Hy,gn.FACE_LANDMARKS_RIGHT_EYEBROW=Gy,gn.FACE_LANDMARKS_RIGHT_IRIS=H4,gn.FACE_LANDMARKS_FACE_OVAL=Wy,gn.FACE_LANDMARKS_CONTOURS=G4,gn.FACE_LANDMARKS_TESSELATION=W4;var Ls=class extends vs{constructor(e,t){super(new or(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},ae(e=this.h=new S4,0,1,t=new Dn)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){return ae(this.h,0,2,Kv(e,He(this.h,Cy,2))),this.l(e)}sa(e,t){return this.j={classifications:[]},lr(this,e,t),this.j}ta(e,t,n){return this.j={classifications:[]},Ur(this,e,n,t),this.j}m(){var e=new xs;bn(e,"input_image"),bn(e,"norm_rect"),je(e,"classifications");const t=new ys;Lr(t,uF,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),vn(n,"IMAGE:input_image"),vn(n,"NORM_RECT:norm_rect"),Ie(n,"CLASSIFICATIONS:classifications"),n.o(t),zs(e,n),this.g.attachProtoListener("classifications",((i,r)=>{this.j=gF(J8(i)),jt(this,r)})),this.g.attachEmptyPacketListener("classifications",(i=>{jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ls.prototype.classifyForVideo=Ls.prototype.ta,Ls.prototype.classify=Ls.prototype.sa,Ls.prototype.setOptions=Ls.prototype.o,Ls.createFromModelPath=function(e,t){return Fe(Ls,e,{baseOptions:{modelAssetPath:t}})},Ls.createFromModelBuffer=function(e,t){return Fe(Ls,e,{baseOptions:{modelAssetBuffer:t}})},Ls.createFromOptions=function(e,t){return Fe(Ls,e,t)};var us=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect",!0),this.h=new M4,this.embeddings={embeddings:[]},ae(e=this.h,0,1,t=new Dn)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){var t=this.h,n=He(this.h,uE,2);return n=n?n.clone():new uE,e.l2Normalize!==void 0?an(n,1,Yf(e.l2Normalize)):"l2Normalize"in e&&an(n,1),e.quantize!==void 0?an(n,2,Yf(e.quantize)):"quantize"in e&&an(n,2),ae(t,0,2,n),this.l(e)}za(e,t){return lr(this,e,t),this.embeddings}Aa(e,t,n){return Ur(this,e,n,t),this.embeddings}m(){var e=new xs;bn(e,"image_in"),bn(e,"norm_rect"),je(e,"embeddings_out");const t=new ys;Lr(t,fF,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),vn(n,"IMAGE:image_in"),vn(n,"NORM_RECT:norm_rect"),Ie(n,"EMBEDDINGS:embeddings_out"),n.o(t),zs(e,n),this.g.attachProtoListener("embeddings_out",((i,r)=>{i=eF(i),this.embeddings=(function(o){return{embeddings:pa(o,tF,1).map((c=>{var d,p;const u={headIndex:Is(c,3)??0??-1,headName:_i(xn(c,4))??""??""};var h=c.v;return yw(h,0|h[Zt],cE,b_(c,1))!==void 0?(c=Zo(c=He(c,cE,b_(c,1),void 0),1,xr,Ko()),u.floatEmbedding=c.slice()):(h=new Uint8Array(0),u.quantizedEmbedding=((p=(d=He(c,$8,b_(c,2),void 0))==null?void 0:d.na())==null?void 0:p.h())??h),u})),timestampMs:C4(xn(o,2,void 0,void 0,Lp)??pw)}})(i),jt(this,r)})),this.g.attachEmptyPacketListener("embeddings_out",(i=>{jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};us.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=gE(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=gE(mE(e.quantizedEmbedding),mE(t.quantizedEmbedding))}return e},us.prototype.embedForVideo=us.prototype.Aa,us.prototype.embed=us.prototype.za,us.prototype.setOptions=us.prototype.o,us.createFromModelPath=function(e,t){return Fe(us,e,{baseOptions:{modelAssetPath:t}})},us.createFromModelBuffer=function(e,t){return Fe(us,e,{baseOptions:{modelAssetBuffer:t}})},us.createFromOptions=function(e,t){return Fe(us,e,t)};var $v=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 bF(e){var n,i;const t=(function(r){return pa(r,Ji,1)})(e.ca()).filter((r=>(_i(xn(r,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=He(t[0],ys,7))==null?void 0:n.j())==null?void 0:i.g())??new Map).forEach(((r,o)=>{e.u[Number(o)]=_i(xn(r,1))??""}))}function NE(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function UE(e){try{const t=new $v(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{xm(e)}}$v.prototype.close=$v.prototype.close;var Xi=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Oy,this.A=new b4,ae(this.h,0,3,this.A),ae(e=this.h,0,1,t=new Dn)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?an(this.h,2,ah(e.displayNamesLocale)):"displayNamesLocale"in e&&an(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}L(){bF(this)}segment(e,t,n){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:n,NE(this),lr(this,e,i),UE(this)}La(e,t,n,i){const r=typeof n!="function"?n:{};return this.j=typeof n=="function"?n:i,NE(this),Ur(this,e,r,t),UE(this)}Da(){return this.u}m(){var e=new xs;bn(e,"image_in"),bn(e,"norm_rect");const t=new ys;Lr(t,E4,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),vn(n,"IMAGE:image_in"),vn(n,"NORM_RECT:norm_rect"),n.o(t),zs(e,n),ym(this,e),this.outputConfidenceMasks&&(je(e,"confidence_masks"),Ie(n,"CONFIDENCE_MASKS:confidence_masks"),Xc(this,"confidence_masks"),this.g.aa("confidence_masks",((i,r)=>{this.confidenceMasks=i.map((o=>Yc(this,o,!0,!this.j))),jt(this,r)})),this.g.attachEmptyPacketListener("confidence_masks",(i=>{this.confidenceMasks=[],jt(this,i)}))),this.outputCategoryMask&&(je(e,"category_mask"),Ie(n,"CATEGORY_MASK:category_mask"),Xc(this,"category_mask"),this.g.Z("category_mask",((i,r)=>{this.categoryMask=Yc(this,i,!1,!this.j),jt(this,r)})),this.g.attachEmptyPacketListener("category_mask",(i=>{this.categoryMask=void 0,jt(this,i)}))),je(e,"quality_scores"),Ie(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((i,r)=>{this.qualityScores=i,jt(this,r)})),this.g.attachEmptyPacketListener("quality_scores",(i=>{this.categoryMask=void 0,jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Xi.prototype.getLabels=Xi.prototype.Da,Xi.prototype.segmentForVideo=Xi.prototype.La,Xi.prototype.segment=Xi.prototype.segment,Xi.prototype.setOptions=Xi.prototype.o,Xi.createFromModelPath=function(e,t){return Fe(Xi,e,{baseOptions:{modelAssetPath:t}})},Xi.createFromModelBuffer=function(e,t){return Fe(Xi,e,{baseOptions:{modelAssetBuffer:t}})},Xi.createFromOptions=function(e,t){return Fe(Xi,e,t)};var t1=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()}};t1.prototype.close=t1.prototype.close;var mr=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Oy,this.u=new b4,ae(this.h,0,3,this.u),ae(e=this.h,0,1,t=new Dn)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(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 r=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 A4,t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var o=new w_;Za(o,3,Yf(!0),!1),Za(o,1,Rf(t.keypoint.x),0),Za(o,2,Rf(t.keypoint.y),0),Pf(i,1,Yv,o)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");{const u=new dF;for(o of t.scribble)Za(t=new w_,3,Yf(!0),!1),Za(t,1,Rf(o.x),0),Za(t,2,Rf(o.y),0),dy(u,1,w_,t);Pf(i,2,Yv,u)}}this.g.addProtoToStream(i.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",n),lr(this,e,r);t:{try{const u=new t1(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=u;break t}this.j(u)}finally{xm(this)}c=void 0}return c}m(){var e=new xs;bn(e,"image_in"),bn(e,"roi_in"),bn(e,"norm_rect_in");const t=new ys;Lr(t,E4,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),vn(n,"IMAGE:image_in"),vn(n,"ROI:roi_in"),vn(n,"NORM_RECT:norm_rect_in"),n.o(t),zs(e,n),ym(this,e),this.outputConfidenceMasks&&(je(e,"confidence_masks"),Ie(n,"CONFIDENCE_MASKS:confidence_masks"),Xc(this,"confidence_masks"),this.g.aa("confidence_masks",((i,r)=>{this.confidenceMasks=i.map((o=>Yc(this,o,!0,!this.j))),jt(this,r)})),this.g.attachEmptyPacketListener("confidence_masks",(i=>{this.confidenceMasks=[],jt(this,i)}))),this.outputCategoryMask&&(je(e,"category_mask"),Ie(n,"CATEGORY_MASK:category_mask"),Xc(this,"category_mask"),this.g.Z("category_mask",((i,r)=>{this.categoryMask=Yc(this,i,!1,!this.j),jt(this,r)})),this.g.attachEmptyPacketListener("category_mask",(i=>{this.categoryMask=void 0,jt(this,i)}))),je(e,"quality_scores"),Ie(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((i,r)=>{this.qualityScores=i,jt(this,r)})),this.g.attachEmptyPacketListener("quality_scores",(i=>{this.categoryMask=void 0,jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};mr.prototype.segment=mr.prototype.segment,mr.prototype.setOptions=mr.prototype.o,mr.createFromModelPath=function(e,t){return Fe(mr,e,{baseOptions:{modelAssetPath:t}})},mr.createFromModelBuffer=function(e,t){return Fe(mr,e,{baseOptions:{modelAssetBuffer:t}})},mr.createFromOptions=function(e,t){return Fe(mr,e,t)};var Ns=class extends vs{constructor(e,t){super(new or(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},ae(e=this.h=new w4,0,1,t=new Dn)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?an(this.h,2,ah(e.displayNamesLocale)):"displayNamesLocale"in e&&an(this.h,2),e.maxResults!==void 0?ma(this.h,3,e.maxResults):"maxResults"in e&&an(this.h,3),e.scoreThreshold!==void 0?ie(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&an(this.h,4),e.categoryAllowlist!==void 0?Up(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&an(this.h,5),e.categoryDenylist!==void 0?Up(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&an(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},lr(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Ur(this,e,n,t),this.j}m(){var e=new xs;bn(e,"input_frame_gpu"),bn(e,"norm_rect"),je(e,"detections");const t=new ys;Lr(t,pF,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),vn(n,"IMAGE:input_frame_gpu"),vn(n,"NORM_RECT:norm_rect"),Ie(n,"DETECTIONS:detections"),n.o(t),zs(e,n),this.g.attachProtoVectorListener("detections",((i,r)=>{for(const o of i)i=s4(o),this.j.detections.push(D4(i));jt(this,r)})),this.g.attachEmptyPacketListener("detections",(i=>{jt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ns.prototype.detectForVideo=Ns.prototype.G,Ns.prototype.detect=Ns.prototype.F,Ns.prototype.setOptions=Ns.prototype.o,Ns.createFromModelPath=async function(e,t){return Fe(Ns,e,{baseOptions:{modelAssetPath:t}})},Ns.createFromModelBuffer=function(e,t){return Fe(Ns,e,{baseOptions:{modelAssetBuffer:t}})},Ns.createFromOptions=function(e,t){return Fe(Ns,e,t)};var e1=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 PE(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function OE(e){try{const t=new e1(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.u)return t;e.u(t)}finally{xm(e)}}e1.prototype.close=e1.prototype.close;var qi=class extends vs{constructor(e,t){super(new or(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,ae(e=this.h=new R4,0,1,t=new Dn),this.A=new y4,ae(this.h,0,3,this.A),this.j=new v4,ae(this.h,0,2,this.j),ma(this.j,4,1),ie(this.j,2,.5),ie(this.A,2,.5),ie(this.h,4,.5)}get baseOptions(){return He(this.h,Dn,1)}set baseOptions(e){ae(this.h,0,1,e)}o(e){return"numPoses"in e&&ma(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&ie(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&ie(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&ie(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,PE(this),lr(this,e,i),OE(this)}G(e,t,n,i){const r=typeof n!="function"?n:{};return this.u=typeof n=="function"?n:i,PE(this),Ur(this,e,r,t),OE(this)}m(){var e=new xs;bn(e,"image_in"),bn(e,"norm_rect"),je(e,"normalized_landmarks"),je(e,"world_landmarks"),je(e,"segmentation_masks");const t=new ys;Lr(t,mF,this.h);const n=new Ji;_s(n,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),vn(n,"IMAGE:image_in"),vn(n,"NORM_RECT:norm_rect"),Ie(n,"NORM_LANDMARKS:normalized_landmarks"),Ie(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),zs(e,n),ym(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((i,r)=>{this.landmarks=[];for(const o of i)i=ch(o),this.landmarks.push(vm(i));jt(this,r)})),this.g.attachEmptyPacketListener("normalized_landmarks",(i=>{this.landmarks=[],jt(this,i)})),this.g.attachProtoVectorListener("world_landmarks",((i,r)=>{this.worldLandmarks=[];for(const o of i)i=Ac(o),this.worldLandmarks.push(If(i));jt(this,r)})),this.g.attachEmptyPacketListener("world_landmarks",(i=>{this.worldLandmarks=[],jt(this,i)})),this.outputSegmentationMasks&&(Ie(n,"SEGMENTATION_MASK:segmentation_masks"),Xc(this,"segmentation_masks"),this.g.aa("segmentation_masks",((i,r)=>{this.segmentationMasks=i.map((o=>Yc(this,o,!0,!this.u))),jt(this,r)})),this.g.attachEmptyPacketListener("segmentation_masks",(i=>{this.segmentationMasks=[],jt(this,i)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};qi.prototype.detectForVideo=qi.prototype.G,qi.prototype.detect=qi.prototype.F,qi.prototype.setOptions=qi.prototype.o,qi.createFromModelPath=function(e,t){return Fe(qi,e,{baseOptions:{modelAssetPath:t}})},qi.createFromModelBuffer=function(e,t){return Fe(qi,e,{baseOptions:{modelAssetBuffer:t}})},qi.createFromOptions=function(e,t){return Fe(qi,e,t)},qi.POSE_CONNECTIONS=j4;const Xy=Mt.createContext({});function qy(e){const t=Mt.useRef(null);return t.current===null&&(t.current=e()),t.current}const TF=typeof window<"u",X4=TF?Mt.useLayoutEffect:Mt.useEffect,Sm=Mt.createContext(null);function Yy(e,t){e.indexOf(t)===-1&&e.push(t)}function Fp(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Ar=(e,t,n)=>n>t?t:n{};const lo={},q4=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Y4(e){return typeof e=="object"&&e!==null}const K4=e=>/^0[^.\s]+$/u.test(e);function Z4(e){let t;return()=>(t===void 0&&(t=e()),t)}const Fs=e=>e,EF=(e,t)=>n=>t(e(n)),uh=(...e)=>e.reduce(EF),Zf=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i};class Zy{constructor(){this.subscriptions=[]}add(t){return Yy(this.subscriptions,t),()=>Fp(this.subscriptions,t)}notify(t,n,i){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,i);else for(let o=0;oe*1e3,Bs=e=>e/1e3;function Q4(e,t){return t?e*(1e3/t):0}const J4=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,AF=1e-7,wF=12;function RF(e,t,n,i,r){let o,c,u=0;do c=t+(n-t)/2,o=J4(c,i,r)-e,o>0?n=c:t=c;while(Math.abs(o)>AF&&++uRF(o,0,1,e,n);return o=>o===0||o===1?o:J4(r(o),t,i)}const $4=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,tR=e=>t=>1-e(1-t),eR=fh(.33,1.53,.69,.99),Qy=tR(eR),nR=$4(Qy),iR=e=>e>=1?1:(e*=2)<1?.5*Qy(e):.5*(2-Math.pow(2,-10*(e-1))),Jy=e=>1-Math.sin(Math.acos(e)),sR=tR(Jy),rR=$4(Jy),CF=fh(.42,0,1,1),DF=fh(0,0,.58,1),aR=fh(.42,0,.58,1),LF=e=>Array.isArray(e)&&typeof e[0]!="number",oR=e=>Array.isArray(e)&&typeof e[0]=="number",NF={linear:Fs,easeIn:CF,easeInOut:aR,easeOut:DF,circIn:Jy,circInOut:rR,circOut:sR,backIn:Qy,backInOut:nR,backOut:eR,anticipate:iR},UF=e=>typeof e=="string",IE=e=>{if(oR(e)){Ky(e.length===4);const[t,n,i,r]=e;return fh(t,n,i,r)}else if(UF(e))return NF[e];return e},ip=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function PF(e,t){let n=new Set,i=new Set,r=!1,o=!1;const c=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function h(p){c.has(p)&&(d.schedule(p),e()),p(u)}const d={schedule:(p,m=!1,_=!1)=>{const M=_&&r?n:i;return m&&c.add(p),M.add(p),p},cancel:p=>{i.delete(p),c.delete(p)},process:p=>{if(u=p,r){o=!0;return}r=!0;const m=n;n=i,i=m,n.forEach(h),n.clear(),r=!1,o&&(o=!1,d.process(p))}};return d}const OF=40;function lR(e,t){let n=!1,i=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,c=ip.reduce((w,E)=>(w[E]=PF(o),w),{}),{setup:u,read:h,resolveKeyframes:d,preUpdate:p,update:m,preRender:_,render:y,postRender:M}=c,T=()=>{const w=lo.useManualTiming,E=w?r.timestamp:performance.now();n=!1,w||(r.delta=i?1e3/60:Math.max(Math.min(E-r.timestamp,OF),1)),r.timestamp=E,r.isProcessing=!0,u.process(r),h.process(r),d.process(r),p.process(r),m.process(r),_.process(r),y.process(r),M.process(r),r.isProcessing=!1,n&&t&&(i=!1,e(T))},S=()=>{n=!0,i=!0,r.isProcessing||e(T)};return{schedule:ip.reduce((w,E)=>{const P=c[E];return w[E]=(I,U=!1,B=!1)=>(n||S(),P.schedule(I,U,B)),w},{}),cancel:w=>{for(let E=0;E(_p===void 0&&Ui.set(mi.isProcessing||lo.useManualTiming?mi.timestamp:performance.now()),_p),set:e=>{_p=e,queueMicrotask(IF)}},cR=e=>t=>typeof t=="string"&&t.startsWith(e),uR=cR("--"),BF=cR("var(--"),$y=e=>BF(e)?FF.test(e.split("/*")[0].trim()):!1,FF=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function BE(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const du={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Qf={...du,transform:e=>Ar(0,1,e)},sp={...du,default:1},Bf=e=>Math.round(e*1e5)/1e5,tx=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function kF(e){return e==null}const zF=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ex=(e,t)=>n=>!!(typeof n=="string"&&zF.test(n)&&n.startsWith(e)||t&&!kF(n)&&Object.prototype.hasOwnProperty.call(n,t)),fR=(e,t,n)=>i=>{if(typeof i!="string")return i;const[r,o,c,u]=i.match(tx);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(c),alpha:u!==void 0?parseFloat(u):1}},VF=e=>Ar(0,255,e),D_={...du,transform:e=>Math.round(VF(e))},Qo={test:ex("rgb","red"),parse:fR("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+D_.transform(e)+", "+D_.transform(t)+", "+D_.transform(n)+", "+Bf(Qf.transform(i))+")"};function HF(e){let t="",n="",i="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,i+=i,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:r?parseInt(r,16)/255:1}}const n1={test:ex("#"),parse:HF,transform:Qo.transform},hh=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Ya=hh("deg"),br=hh("%"),Wt=hh("px"),GF=hh("vh"),WF=hh("vw"),FE={...br,parse:e=>br.parse(e)/100,transform:e=>br.transform(e*100)},vc={test:ex("hsl","hue"),parse:fR("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+br.transform(Bf(t))+", "+br.transform(Bf(n))+", "+Bf(Qf.transform(i))+")"},kn={test:e=>Qo.test(e)||n1.test(e)||vc.test(e),parse:e=>Qo.test(e)?Qo.parse(e):vc.test(e)?vc.parse(e):n1.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Qo.transform(e):vc.transform(e),getAnimatableNone:e=>{const t=kn.parse(e);return t.alpha=0,kn.transform(t)}},jF=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function XF(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(tx))==null?void 0:t.length)||0)+(((n=e.match(jF))==null?void 0:n.length)||0)>0}const hR="number",dR="color",qF="var",YF="var(",kE="${}",KF=/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 Kc(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},r=[];let o=0;const u=t.replace(KF,h=>(kn.test(h)?(i.color.push(o),r.push(dR),n.push(kn.parse(h))):h.startsWith(YF)?(i.var.push(o),r.push(qF),n.push(h)):(i.number.push(o),r.push(hR),n.push(parseFloat(h))),++o,kE)).split(kE);return{values:n,split:u,indexes:i,types:r}}function ZF(e){return Kc(e).values}function pR({split:e,types:t}){const n=e.length;return i=>{let r="";for(let o=0;otypeof e=="number"?0:kn.test(e)?kn.getAnimatableNone(e):e,$F=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:JF(e);function t9(e){const t=Kc(e);return pR(t)(t.values.map((i,r)=>$F(i,t.split[r])))}const sr={test:XF,parse:ZF,createTransformer:QF,getAnimatableNone:t9};function L_(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 e9({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let r=0,o=0,c=0;if(!t)r=o=c=n;else{const u=n<.5?n*(1+t):n+t-n*t,h=2*n-u;r=L_(h,u,e+1/3),o=L_(h,u,e),c=L_(h,u,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(c*255),alpha:i}}function kp(e,t){return n=>n>0?t:e}const dn=(e,t,n)=>e+(t-e)*n,N_=(e,t,n)=>{const i=e*e,r=n*(t*t-i)+i;return r<0?0:Math.sqrt(r)},n9=[n1,Qo,vc],i9=e=>n9.find(t=>t.test(e));function zE(e){const t=i9(e);if(!t)return!1;let n=t.parse(e);return t===vc&&(n=e9(n)),n}const VE=(e,t)=>{const n=zE(e),i=zE(t);if(!n||!i)return kp(e,t);const r={...n};return o=>(r.red=N_(n.red,i.red,o),r.green=N_(n.green,i.green,o),r.blue=N_(n.blue,i.blue,o),r.alpha=dn(n.alpha,i.alpha,o),Qo.transform(r))},i1=new Set(["none","hidden"]);function s9(e,t){return i1.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function r9(e,t){return n=>dn(e,t,n)}function nx(e){return typeof e=="number"?r9:typeof e=="string"?$y(e)?kp:kn.test(e)?VE:l9:Array.isArray(e)?mR:typeof e=="object"?kn.test(e)?VE:a9:kp}function mR(e,t){const n=[...e],i=n.length,r=e.map((o,c)=>nx(o)(o,t[c]));return o=>{for(let c=0;c{for(const o in i)n[o]=i[o](r);return n}}function o9(e,t){const n=[],i={color:0,var:0,number:0};for(let r=0;r{const n=sr.createTransformer(t),i=Kc(e),r=Kc(t);return i.indexes.var.length===r.indexes.var.length&&i.indexes.color.length===r.indexes.color.length&&i.indexes.number.length>=r.indexes.number.length?i1.has(e)&&!r.values.length||i1.has(t)&&!i.values.length?s9(e,t):uh(mR(o9(i,r),r.values),n):kp(e,t)};function gR(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?dn(e,t,n):nx(e)(e,t)}const c9=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>cn.update(t,n),stop:()=>co(t),now:()=>mi.isProcessing?mi.timestamp:Ui.now()}},_R=(e,t,n=10)=>{let i="";const r=Math.max(Math.round(t/n),2);for(let o=0;o=zp?1/0:t}function u9(e,t=100,n){const i=n({...e,keyframes:[0,t]}),r=Math.min(ix(i),zp);return{type:"keyframes",ease:o=>i.next(r*o).value/t,duration:Bs(r)}}const Cn={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 s1(e,t){return e*Math.sqrt(1-t*t)}const f9=12;function h9(e,t,n){let i=n;for(let r=1;r{const p=d*c,m=p*e,_=p-n,y=s1(d,c),M=Math.exp(-m);return U_-_/y*M},o=d=>{const m=d*c*e,_=m*n+n,y=Math.pow(c,2)*Math.pow(d,2)*e,M=Math.exp(-m),T=s1(Math.pow(d,2),c);return(-r(d)+U_>0?-1:1)*((_-y)*M)/T}):(r=d=>{const p=Math.exp(-d*e),m=(d-n)*e+1;return-U_+p*m},o=d=>{const p=Math.exp(-d*e),m=(n-d)*(e*e);return p*m});const u=5/e,h=h9(r,o,u);if(e=ms(e),isNaN(h))return{stiffness:Cn.stiffness,damping:Cn.damping,duration:e};{const d=Math.pow(h,2)*i;return{stiffness:d,damping:c*2*Math.sqrt(i*d),duration:e}}}const p9=["duration","bounce"],m9=["stiffness","damping","mass"];function HE(e,t){return t.some(n=>e[n]!==void 0)}function g9(e){let t={velocity:Cn.velocity,stiffness:Cn.stiffness,damping:Cn.damping,mass:Cn.mass,isResolvedFromDuration:!1,...e};if(!HE(e,m9)&&HE(e,p9))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),r=i*i,o=2*Ar(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:Cn.mass,stiffness:r,damping:o}}else{const n=d9({...e,velocity:0});t={...t,...n,mass:Cn.mass},t.isResolvedFromDuration=!0}return t}function Vp(e=Cn.visualDuration,t=Cn.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:r}=n;const o=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:h,damping:d,mass:p,duration:m,velocity:_,isResolvedFromDuration:y}=g9({...n,velocity:-Bs(n.velocity||0)}),M=_||0,T=d/(2*Math.sqrt(h*p)),S=c-o,x=Bs(Math.sqrt(h/p)),R=Math.abs(S)<5;i||(i=R?Cn.restSpeed.granular:Cn.restSpeed.default),r||(r=R?Cn.restDelta.granular:Cn.restDelta.default);let w,E,P,I,U,B;if(T<1)P=s1(x,T),I=(M+T*x*S)/P,w=A=>{const F=Math.exp(-T*x*A);return c-F*(I*Math.sin(P*A)+S*Math.cos(P*A))},U=T*x*I+S*P,B=T*x*S-I*P,E=A=>Math.exp(-T*x*A)*(U*Math.sin(P*A)+B*Math.cos(P*A));else if(T===1){w=F=>c-Math.exp(-x*F)*(S+(M+x*S)*F);const A=M+x*S;E=F=>Math.exp(-x*F)*(x*A*F-M)}else{const A=x*Math.sqrt(T*T-1);w=ot=>{const ct=Math.exp(-T*x*ot),k=Math.min(A*ot,300);return c-ct*((M+T*x*S)*Math.sinh(k)+A*S*Math.cosh(k))/A};const F=(M+T*x*S)/A,q=T*x*F-S*A,tt=T*x*S-F*A;E=ot=>{const ct=Math.exp(-T*x*ot),k=Math.min(A*ot,300);return ct*(q*Math.sinh(k)+tt*Math.cosh(k))}}const D={calculatedDuration:y&&m||null,velocity:A=>ms(E(A)),next:A=>{if(!y&&T<1){const q=Math.exp(-T*x*A),tt=Math.sin(P*A),ot=Math.cos(P*A),ct=c-q*(I*tt+S*ot),k=ms(q*(U*tt+B*ot));return u.done=Math.abs(k)<=i&&Math.abs(c-ct)<=r,u.value=u.done?c:ct,u}const F=w(A);if(y)u.done=A>=m;else{const q=ms(E(A));u.done=Math.abs(q)<=i&&Math.abs(c-F)<=r}return u.value=u.done?c:F,u},toString:()=>{const A=Math.min(ix(D),zp),F=_R(q=>D.next(A*q).value,A,30);return A+"ms "+F},toTransition:()=>{}};return D}Vp.applyToOptions=e=>{const t=u9(e,100,Vp);return e.ease=t.ease,e.duration=ms(t.duration),e.type="keyframes",e};const _9=5;function vR(e,t,n){const i=Math.max(t-_9,0);return Q4(n-e(i),t-i)}function r1({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:c,min:u,max:h,restDelta:d=.5,restSpeed:p}){const m=e[0],_={done:!1,value:m},y=B=>u!==void 0&&Bh,M=B=>u===void 0?h:h===void 0||Math.abs(u-B)-T*Math.exp(-B/i),w=B=>x+R(B),E=B=>{const D=R(B),A=w(B);_.done=Math.abs(D)<=d,_.value=_.done?x:A};let P,I;const U=B=>{y(_.value)&&(P=B,I=Vp({keyframes:[_.value,M(_.value)],velocity:vR(w,B,_.value),damping:r,stiffness:o,restDelta:d,restSpeed:p}))};return U(0),{calculatedDuration:null,next:B=>{let D=!1;return!I&&P===void 0&&(D=!0,E(B),U(B)),P!==void 0&&B>=P?I.next(B-P):(!D&&E(B),_)}}}function v9(e,t,n){const i=[],r=n||lo.mix||gR,o=e.length-1;for(let c=0;ct[0];if(o===2&&t[0]===t[1])return()=>t[1];const c=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const u=v9(t,i,r),h=u.length,d=p=>{if(c&&p1)for(;md(Ar(e[0],e[o-1],p)):d}function x9(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const r=Zf(0,t,i);e.push(dn(n,1,r))}}function S9(e){const t=[0];return x9(t,e.length-1),t}function M9(e,t){return e.map(n=>n*t)}function b9(e,t){return e.map(()=>t||aR).splice(0,e.length-1)}function Ff({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const r=LF(i)?i.map(IE):IE(i),o={done:!1,value:t[0]},c=M9(n&&n.length===t.length?n:S9(t),e),u=y9(c,t,{ease:Array.isArray(r)?r:b9(t,r)});return{calculatedDuration:e,next:h=>(o.value=u(h),o.done=h>=e,o)}}const T9=e=>e!==null;function Mm(e,{repeat:t,repeatType:n="loop"},i,r=1){const o=e.filter(T9),u=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!u||i===void 0?o[u]:i}const E9={decay:r1,inertia:r1,tween:Ff,keyframes:Ff,spring:Vp};function yR(e){typeof e.type=="string"&&(e.type=E9[e.type])}class sx{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 A9=e=>e/100;class Hp extends sx{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,r;const{motionValue:n}=this.options;n&&n.updatedAt!==Ui.now()&&this.tick(Ui.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(r=(i=this.options).onStop)==null||r.call(i))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;yR(t);const{type:n=Ff,repeat:i=0,repeatDelay:r=0,repeatType:o,velocity:c=0}=t;let{keyframes:u}=t;const h=n||Ff;h!==Ff&&typeof u[0]!="number"&&(this.mixKeyframes=uh(A9,gR(u[0],u[1])),u=[0,100]);const d=h({...t,keyframes:u});o==="mirror"&&(this.mirroredGenerator=h({...t,keyframes:[...u].reverse(),velocity:-c})),d.calculatedDuration===null&&(d.calculatedDuration=ix(d));const{calculatedDuration:p}=d;this.calculatedDuration=p,this.resolvedDuration=p+r,this.totalDuration=this.resolvedDuration*(i+1)-r,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:r,mixKeyframes:o,mirroredGenerator:c,resolvedDuration:u,calculatedDuration:h}=this;if(this.startTime===null)return i.next(0);const{delay:d=0,keyframes:p,repeat:m,repeatType:_,repeatDelay:y,type:M,onUpdate:T,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-r/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const x=this.currentTime-d*(this.playbackSpeed>=0?1:-1),R=this.playbackSpeed>=0?x<0:x>r;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let w=this.currentTime,E=i;if(m){const B=Math.min(this.currentTime,r)/u;let D=Math.floor(B),A=B%1;!A&&B>=1&&(A=1),A===1&&D--,D=Math.min(D,m+1),!!(D%2)&&(_==="reverse"?(A=1-A,y&&(A-=y/u)):_==="mirror"&&(E=c)),w=Ar(0,1,A)*u}let P;R?(this.delayState.value=p[0],P=this.delayState):P=E.next(w),o&&!R&&(P.value=o(P.value));let{done:I}=P;!R&&h!==null&&(I=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const U=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&I);return U&&M!==r1&&(P.value=Mm(p,this.options,S,this.speed)),T&&T(P.value),U&&this.finish(),P}then(t,n){return this.finished.then(t,n)}get duration(){return Bs(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Bs(t)}get time(){return Bs(this.currentTime)}set time(t){t=ms(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 vR(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(Ui.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=Bs(this.currentTime))}play(){var r,o;if(this.isStopped)return;const{driver:t=c9,startTime:n}=this.options;this.driver||(this.driver=t(c=>this.tick(c))),(o=(r=this.options).onPlay)==null||o.call(r);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(Ui.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 w9(e){for(let t=1;te*180/Math.PI,a1=e=>{const t=Jo(Math.atan2(e[1],e[0]));return o1(t)},R9={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:a1,rotateZ:a1,skewX:e=>Jo(Math.atan(e[1])),skewY:e=>Jo(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},o1=e=>(e=e%360,e<0&&(e+=360),e),GE=a1,WE=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),jE=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),C9={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:WE,scaleY:jE,scale:e=>(WE(e)+jE(e))/2,rotateX:e=>o1(Jo(Math.atan2(e[6],e[5]))),rotateY:e=>o1(Jo(Math.atan2(-e[2],e[0]))),rotateZ:GE,rotate:GE,skewX:e=>Jo(Math.atan(e[4])),skewY:e=>Jo(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function l1(e){return e.includes("scale")?1:0}function c1(e,t){if(!e||e==="none")return l1(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,r;if(n)i=C9,r=n;else{const u=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=R9,r=u}if(!r)return l1(t);const o=i[t],c=r[1].split(",").map(L9);return typeof o=="function"?o(c):c[o]}const D9=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return c1(n,t)};function L9(e){return parseFloat(e.trim())}const pu=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],mu=new Set(pu),XE=e=>e===du||e===Wt,N9=new Set(["x","y","z"]),U9=pu.filter(e=>!N9.has(e));function P9(e){const t=[];return U9.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const eo={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:i})=>{const r=e.max-e.min;return i==="border-box"?r:r-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:i})=>{const r=e.max-e.min;return i==="border-box"?r:r-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})=>c1(t,"x"),y:(e,{transform:t})=>c1(t,"y")};eo.translateX=eo.x;eo.translateY=eo.y;const sl=new Set;let u1=!1,f1=!1,h1=!1;function xR(){if(f1){const e=Array.from(sl).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const r=P9(i);r.length&&(n.set(i,r),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const r=n.get(i);r&&r.forEach(([o,c])=>{var u;(u=i.getValue(o))==null||u.set(c)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}f1=!1,u1=!1,sl.forEach(e=>e.complete(h1)),sl.clear()}function SR(){sl.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(f1=!0)})}function O9(){h1=!0,SR(),xR(),h1=!1}class rx{constructor(t,n,i,r,o,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=r,this.element=o,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(sl.add(this),u1||(u1=!0,cn.read(SR),cn.resolveKeyframes(xR))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:r}=this;if(t[0]===null){const o=r==null?void 0:r.get(),c=t[t.length-1];if(o!==void 0)t[0]=o;else if(i&&n){const u=i.readValue(n,c);u!=null&&(t[0]=u)}t[0]===void 0&&(t[0]=c),r&&o===void 0&&r.set(t[0])}w9(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),sl.delete(this)}cancel(){this.state==="scheduled"&&(sl.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const I9=e=>e.startsWith("--");function MR(e,t,n){I9(t)?e.style.setProperty(t,n):e.style[t]=n}const B9={};function bR(e,t){const n=Z4(e);return()=>B9[t]??n()}const F9=bR(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),TR=bR(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Cf=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,qE={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Cf([0,.65,.55,1]),circOut:Cf([.55,0,1,.45]),backIn:Cf([.31,.01,.66,-.59]),backOut:Cf([.33,1.53,.69,.99])};function ER(e,t){if(e)return typeof e=="function"?TR()?_R(e,t):"ease-out":oR(e)?Cf(e):Array.isArray(e)?e.map(n=>ER(n,t)||qE.easeOut):qE[e]}function k9(e,t,n,{delay:i=0,duration:r=300,repeat:o=0,repeatType:c="loop",ease:u="easeOut",times:h}={},d=void 0){const p={[t]:n};h&&(p.offset=h);const m=ER(u,r);Array.isArray(m)&&(p.easing=m);const _={delay:i,duration:r,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:o+1,direction:c==="reverse"?"alternate":"normal"};return d&&(_.pseudoElement=d),e.animate(p,_)}function AR(e){return typeof e=="function"&&"applyToOptions"in e}function z9({type:e,...t}){return AR(e)&&TR()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class wR extends sx{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:i,keyframes:r,pseudoElement:o,allowFlatten:c=!1,finalKeyframe:u,onComplete:h}=t;this.isPseudoElement=!!o,this.allowFlatten=c,this.options=t,Ky(typeof t.type!="string");const d=z9(t);this.animation=k9(n,i,r,d,o),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Mm(r,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(p),MR(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,r;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((r=(i=this.animation).commitStyles)==null||r.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 Bs(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Bs(t)}get time(){return Bs(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ms(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:r}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&F9()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),i&&(this.animation.rangeEnd=i),Fs):r(this)}}const RR={anticipate:iR,backInOut:nR,circInOut:rR};function V9(e){return e in RR}function H9(e){typeof e.ease=="string"&&V9(e.ease)&&(e.ease=RR[e.ease])}const P_=10;class G9 extends wR{constructor(t){H9(t),yR(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:r,element:o,...c}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const u=new Hp({...c,autoplay:!1}),h=Math.max(P_,Ui.now()-this.startTime),d=Ar(0,P_,h-P_),p=u.sample(h).value,{name:m}=this.options;o&&m&&MR(o,m,p),n.setWithVelocity(u.sample(Math.max(0,h-d)).value,p,d),u.stop()}}const YE=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(sr.test(e)||e==="0")&&!e.startsWith("url("));function W9(e){const t=e[0];if(e.length===1)return!0;for(let n=0;nObject.hasOwnProperty.call(Element.prototype,"animate"));function Z9(e){var m;const{motionValue:t,name:n,repeatDelay:i,repeatType:r,damping:o,type:c,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 K9()&&n&&(CR.has(n)||Y9.has(n)&&q9(u))&&(n!=="transform"||!p)&&!d&&!i&&r!=="mirror"&&o!==0&&c!=="inertia"}const Q9=40;class J9 extends sx{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:c="loop",keyframes:u,name:h,motionValue:d,element:p,...m}){var M;super(),this.stop=()=>{var T,S;this._animation&&(this._animation.stop(),(T=this.stopTimeline)==null||T.call(this)),(S=this.keyframeResolver)==null||S.cancel()},this.createdAt=Ui.now();const _={autoplay:t,delay:n,type:i,repeat:r,repeatDelay:o,repeatType:c,name:h,motionValue:d,element:p,...m},y=(p==null?void 0:p.KeyframeResolver)||rx;this.keyframeResolver=new y(u,(T,S,x)=>this.onKeyframesResolved(T,S,_,!x),h,d,p),(M=this.keyframeResolver)==null||M.scheduleResolve()}onKeyframesResolved(t,n,i,r){var x,R;this.keyframeResolver=void 0;const{name:o,type:c,velocity:u,delay:h,isHandoff:d,onUpdate:p}=i;this.resolvedAt=Ui.now();let m=!0;j9(t,o,c,u)||(m=!1,(lo.instantAnimations||!h)&&(p==null||p(Mm(t,i,n))),t[0]=t[t.length-1],d1(i),i.repeat=0);const y={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Q9?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},M=m&&!d&&Z9(y),T=(R=(x=y.motionValue)==null?void 0:x.owner)==null?void 0:R.current;let S;if(M)try{S=new G9({...y,element:T})}catch{S=new Hp(y)}else S=new Hp(y);S.finished.then(()=>{this.notifyFinished()}).catch(Fs),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(),O9()),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 DR(e,t,n,i=0,r=1){const o=Array.from(e).sort((d,p)=>d.sortNodePosition(p)).indexOf(t),c=e.size,u=(c-1)*i;return typeof n=="function"?n(o,c):r===1?o*i:u-o*i}const $9=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function t7(e){const t=$9.exec(e);if(!t)return[,];const[,n,i,r]=t;return[`--${n??i}`,r]}function LR(e,t,n=1){const[i,r]=t7(e);if(!i)return;const o=window.getComputedStyle(t).getPropertyValue(i);if(o){const c=o.trim();return q4(c)?parseFloat(c):c}return $y(r)?LR(r,t,n+1):r}const e7={type:"spring",stiffness:500,damping:25,restSpeed:10},n7=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),i7={type:"keyframes",duration:.8},s7={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},r7=(e,{keyframes:t})=>t.length>2?i7:mu.has(e)?e.startsWith("scale")?n7(t[1]):e7:s7;function NR(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...i}=e;return{...t,...i}}return e}function ax(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?NR(n,e):n}const a7=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function o7(e){for(const t in e)if(!a7.has(t))return!0;return!1}const ox=(e,t,n,i={},r,o)=>c=>{const u=ax(i,e)||{},h=u.delay||i.delay||0;let{elapsed:d=0}=i;d=d-ms(h);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...u,delay:-d,onUpdate:_=>{t.set(_),u.onUpdate&&u.onUpdate(_)},onComplete:()=>{c(),u.onComplete&&u.onComplete()},name:e,motionValue:t,element:o?void 0:r};o7(u)||Object.assign(p,r7(e,p)),p.duration&&(p.duration=ms(p.duration)),p.repeatDelay&&(p.repeatDelay=ms(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let m=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(d1(p),p.delay===0&&(m=!0)),(lo.instantAnimations||lo.skipAnimations||r!=null&&r.shouldSkipAnimations)&&(m=!0,d1(p),p.delay=0),p.allowFlatten=!u.type&&!u.ease,m&&!o&&t.get()!==void 0){const _=Mm(p.keyframes,u);if(_!==void 0){cn.update(()=>{p.onUpdate(_),p.onComplete()});return}}return u.isSync?new Hp(p):new J9(p)};function KE(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function lx(e,t,n,i){if(typeof t=="function"){const[r,o]=KE(i);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=KE(i);t=t(n!==void 0?n:e.custom,r,o)}return t}function rl(e,t,n){const i=e.getProps();return lx(i,t,n!==void 0?n:i.custom,e)}const UR=new Set(["width","height","top","left","right","bottom",...pu]),ZE=30,l7=e=>!isNaN(parseFloat(e));class c7{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var o;const r=Ui.now();if(this.updatedAt!==r&&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 c of this.dependents)c.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ui.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=l7(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 Zy);const i=this.events[t].add(n);return t==="change"?()=>{i(),cn.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=Ui.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>ZE)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,ZE);return Q4(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 Zc(e,t){return new c7(e,t)}const p1=e=>Array.isArray(e);function u7(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Zc(n))}function f7(e){return p1(e)?e[e.length-1]||0:e}function h7(e,t){const n=rl(e,t);let{transitionEnd:i={},transition:r={},...o}=n||{};o={...o,...i};for(const c in o){const u=f7(o[c]);u7(e,c,u)}}const gi=e=>!!(e&&e.getVelocity);function d7(e){return!!(gi(e)&&e.add)}function m1(e,t){const n=e.getValue("willChange");if(d7(n))return n.add(t);if(!n&&lo.WillChange){const i=new lo.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function cx(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const p7="framerAppearId",PR="data-"+cx(p7);function OR(e){return e.props[PR]}function m7({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function IR(e,t,{delay:n=0,transitionOverride:i,type:r}={}){let{transition:o,transitionEnd:c,...u}=t;const h=e.getDefaultTransition();o=o?NR(o,h):h;const d=o==null?void 0:o.reduceMotion;i&&(o=i);const p=[],m=r&&e.animationState&&e.animationState.getState()[r];for(const _ in u){const y=e.getValue(_,e.latestValues[_]??null),M=u[_];if(M===void 0||m&&m7(m,_))continue;const T={delay:n,...ax(o||{},_)},S=y.get();if(S!==void 0&&!y.isAnimating()&&!Array.isArray(M)&&M===S&&!T.velocity){cn.update(()=>y.set(M));continue}let x=!1;if(window.MotionHandoffAnimation){const E=OR(e);if(E){const P=window.MotionHandoffAnimation(E,_,cn);P!==null&&(T.startTime=P,x=!0)}}m1(e,_);const R=d??e.shouldReduceMotion;y.start(ox(_,y,M,R&&UR.has(_)?{type:!1}:T,e,x));const w=y.animation;w&&p.push(w)}if(c){const _=()=>cn.update(()=>{c&&h7(e,c)});p.length?Promise.all(p).then(_):_()}return p}function g1(e,t,n={}){var h;const i=rl(e,t,n.type==="exit"?(h=e.presenceContext)==null?void 0:h.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(r=n.transitionOverride);const o=i?()=>Promise.all(IR(e,i,n)):()=>Promise.resolve(),c=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:_}=r;return g7(e,t,d,p,m,_,n)}:()=>Promise.resolve(),{when:u}=r;if(u){const[d,p]=u==="beforeChildren"?[o,c]:[c,o];return d().then(()=>p())}else return Promise.all([o(),c(n.delay)])}function g7(e,t,n=0,i=0,r=0,o=1,c){const u=[];for(const h of e.variantChildren)h.notify("AnimationStart",t),u.push(g1(h,t,{...c,delay:n+(typeof i=="function"?0:i)+DR(e.variantChildren,h,i,r,o)}).then(()=>h.notify("AnimationComplete",t)));return Promise.all(u)}function _7(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const r=t.map(o=>g1(e,o,n));i=Promise.all(r)}else if(typeof t=="string")i=g1(e,t,n);else{const r=typeof t=="function"?rl(e,t,n.custom):t;i=Promise.all(IR(e,r,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const v7={test:e=>e==="auto",parse:e=>e},BR=e=>t=>t.test(e),FR=[du,Wt,br,Ya,WF,GF,v7],QE=e=>FR.find(BR(e));function y7(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||K4(e):!0}const x7=new Set(["brightness","contrast","saturate","opacity"]);function S7(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(tx)||[];if(!i)return e;const r=n.replace(i,"");let o=x7.has(t)?1:0;return i!==n&&(o*=100),t+"("+o+r+")"}const M7=/\b([a-z-]*)\(.*?\)/gu,_1={...sr,getAnimatableNone:e=>{const t=e.match(M7);return t?t.map(S7).join(" "):e}},v1={...sr,getAnimatableNone:e=>{const t=sr.parse(e);return sr.createTransformer(e)(t.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},JE={...du,transform:Math.round},b7={rotate:Ya,rotateX:Ya,rotateY:Ya,rotateZ:Ya,scale:sp,scaleX:sp,scaleY:sp,scaleZ:sp,skew:Ya,skewX:Ya,skewY:Ya,distance:Wt,translateX:Wt,translateY:Wt,translateZ:Wt,x:Wt,y:Wt,z:Wt,perspective:Wt,transformPerspective:Wt,opacity:Qf,originX:FE,originY:FE,originZ:Wt},ux={borderWidth:Wt,borderTopWidth:Wt,borderRightWidth:Wt,borderBottomWidth:Wt,borderLeftWidth:Wt,borderRadius:Wt,borderTopLeftRadius:Wt,borderTopRightRadius:Wt,borderBottomRightRadius:Wt,borderBottomLeftRadius:Wt,width:Wt,maxWidth:Wt,height:Wt,maxHeight:Wt,top:Wt,right:Wt,bottom:Wt,left:Wt,inset:Wt,insetBlock:Wt,insetBlockStart:Wt,insetBlockEnd:Wt,insetInline:Wt,insetInlineStart:Wt,insetInlineEnd:Wt,padding:Wt,paddingTop:Wt,paddingRight:Wt,paddingBottom:Wt,paddingLeft:Wt,paddingBlock:Wt,paddingBlockStart:Wt,paddingBlockEnd:Wt,paddingInline:Wt,paddingInlineStart:Wt,paddingInlineEnd:Wt,margin:Wt,marginTop:Wt,marginRight:Wt,marginBottom:Wt,marginLeft:Wt,marginBlock:Wt,marginBlockStart:Wt,marginBlockEnd:Wt,marginInline:Wt,marginInlineStart:Wt,marginInlineEnd:Wt,fontSize:Wt,backgroundPositionX:Wt,backgroundPositionY:Wt,...b7,zIndex:JE,fillOpacity:Qf,strokeOpacity:Qf,numOctaves:JE},T7={...ux,color:kn,backgroundColor:kn,outlineColor:kn,fill:kn,stroke:kn,borderColor:kn,borderTopColor:kn,borderRightColor:kn,borderBottomColor:kn,borderLeftColor:kn,filter:_1,WebkitFilter:_1,mask:v1,WebkitMask:v1},kR=e=>T7[e],E7=new Set([_1,v1]);function zR(e,t){let n=kR(e);return E7.has(n)||(n=sr),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const A7=new Set(["auto","none","0"]);function w7(e,t,n){let i=0,r;for(;i{t.getValue(h).set(d)}),this.resolveNoneKeyframes()}}function VR(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let i=document;const r=(n==null?void 0:n[e])??i.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e).filter(i=>i!=null)}const HR=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function vp(e){return Y4(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:fx}=lR(queueMicrotask,!1),Qs={x:!1,y:!1};function GR(){return Qs.x||Qs.y}function C7(e){return e==="x"||e==="y"?Qs[e]?null:(Qs[e]=!0,()=>{Qs[e]=!1}):Qs.x||Qs.y?null:(Qs.x=Qs.y=!0,()=>{Qs.x=Qs.y=!1})}function WR(e,t){const n=VR(e),i=new AbortController,r={passive:!0,...t,signal:i.signal};return[n,r,()=>i.abort()]}function D7(e){return!(e.pointerType==="touch"||GR())}function L7(e,t,n={}){const[i,r,o]=WR(e,n);return i.forEach(c=>{let u=!1,h=!1,d;const p=()=>{c.removeEventListener("pointerleave",M)},m=S=>{d&&(d(S),d=void 0),p()},_=S=>{u=!1,window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",_),h&&(h=!1,m(S))},y=()=>{u=!0,window.addEventListener("pointerup",_,r),window.addEventListener("pointercancel",_,r)},M=S=>{if(S.pointerType!=="touch"){if(u){h=!0;return}m(S)}},T=S=>{if(!D7(S))return;h=!1;const x=t(c,S);typeof x=="function"&&(d=x,c.addEventListener("pointerleave",M,r))};c.addEventListener("pointerenter",T,r),c.addEventListener("pointerdown",y,r)}),o}const jR=(e,t)=>t?e===t?!0:jR(e,t.parentElement):!1,hx=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,N7=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function U7(e){return N7.has(e.tagName)||e.isContentEditable===!0}const P7=new Set(["INPUT","SELECT","TEXTAREA"]);function O7(e){return P7.has(e.tagName)||e.isContentEditable===!0}const yp=new WeakSet;function $E(e){return t=>{t.key==="Enter"&&e(t)}}function O_(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const I7=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=$E(()=>{if(yp.has(n))return;O_(n,"down");const r=$E(()=>{O_(n,"up")}),o=()=>O_(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function tA(e){return hx(e)&&!GR()}const eA=new WeakSet;function B7(e,t,n={}){const[i,r,o]=WR(e,n),c=u=>{const h=u.currentTarget;if(!tA(u)||eA.has(u))return;yp.add(h),n.stopPropagation&&eA.add(u);const d=t(h,u),p=(y,M)=>{window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",_),yp.has(h)&&yp.delete(h),tA(y)&&typeof d=="function"&&d(y,{success:M})},m=y=>{p(y,h===window||h===document||n.useGlobalTarget||jR(h,y.target))},_=y=>{p(y,!1)};window.addEventListener("pointerup",m,r),window.addEventListener("pointercancel",_,r)};return i.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",c,r),vp(u)&&(u.addEventListener("focus",d=>I7(d,r)),!U7(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function dx(e){return Y4(e)&&"ownerSVGElement"in e}const xp=new WeakMap;let Ka;const XR=(e,t,n)=>(i,r)=>r&&r[0]?r[0][e+"Size"]:dx(i)&&"getBBox"in i?i.getBBox()[t]:i[n],F7=XR("inline","width","offsetWidth"),k7=XR("block","height","offsetHeight");function z7({target:e,borderBoxSize:t}){var n;(n=xp.get(e))==null||n.forEach(i=>{i(e,{get width(){return F7(e,t)},get height(){return k7(e,t)}})})}function V7(e){e.forEach(z7)}function H7(){typeof ResizeObserver>"u"||(Ka=new ResizeObserver(V7))}function G7(e,t){Ka||H7();const n=VR(e);return n.forEach(i=>{let r=xp.get(i);r||(r=new Set,xp.set(i,r)),r.add(t),Ka==null||Ka.observe(i)}),()=>{n.forEach(i=>{const r=xp.get(i);r==null||r.delete(t),r!=null&&r.size||Ka==null||Ka.unobserve(i)})}}const Sp=new Set;let yc;function W7(){yc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Sp.forEach(t=>t(e))},window.addEventListener("resize",yc)}function j7(e){return Sp.add(e),yc||W7(),()=>{Sp.delete(e),!Sp.size&&typeof yc=="function"&&(window.removeEventListener("resize",yc),yc=void 0)}}function nA(e,t){return typeof e=="function"?j7(e):G7(e,t)}function X7(e){return dx(e)&&e.tagName==="svg"}const q7=[...FR,kn,sr],Y7=e=>q7.find(BR(e)),iA=()=>({translate:0,scale:1,origin:0,originPoint:0}),xc=()=>({x:iA(),y:iA()}),sA=()=>({min:0,max:0}),Yn=()=>({x:sA(),y:sA()}),K7=new WeakMap;function bm(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Jf(e){return typeof e=="string"||Array.isArray(e)}const px=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],mx=["initial",...px];function Tm(e){return bm(e.animate)||mx.some(t=>Jf(e[t]))}function qR(e){return!!(Tm(e)||e.variants)}function Z7(e,t,n){for(const i in t){const r=t[i],o=n[i];if(gi(r))e.addValue(i,r);else if(gi(o))e.addValue(i,Zc(r,{owner:e}));else if(o!==r)if(e.hasValue(i)){const c=e.getValue(i);c.liveStyle===!0?c.jump(r):c.hasAnimated||c.set(r)}else{const c=e.getStaticValue(i);e.addValue(i,Zc(c!==void 0?c:r,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const y1={current:null},YR={current:!1},Q7=typeof window<"u";function J7(){if(YR.current=!0,!!Q7)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>y1.current=e.matches;e.addEventListener("change",t),t()}else y1.current=!1}const rA=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Gp={};function KR(e){Gp=e}function $7(){return Gp}class tk{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:r,skipAnimations:o,blockInitialAnimation:c,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=rx,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 y=Ui.now();this.renderScheduledAtthis.bindToMotionValue(o,r)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(YR.current||J7(),this.shouldReduceMotion=y1.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(),co(this.notifyUpdate),co(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&&CR.has(t)&&this.current instanceof HTMLElement){const{factory:c,keyframes:u,times:h,ease:d,duration:p}=n.accelerate,m=new wR({element:this.current,name:t,keyframes:u,times:h,ease:d,duration:ms(p)}),_=c(m);this.valueSubscriptions.set(t,()=>{_(),m.cancel()});return}const i=mu.has(t);i&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",c=>{this.latestValues[t]=c,this.props.onUpdate&&cn.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,()=>{r(),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 Gp){const n=Gp[t];if(!n)continue;const{isEnabled:i,Feature:r}=n;if(!this.features[t]&&r&&i(this.props)&&(this.features[t]=new r(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):Yn()}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=Zc(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"&&(q4(i)||K4(i))?i=parseFloat(i):!Y7(i)&&sr.test(n)&&(i=zR(t,n)),this.setBaseTarget(t,gi(i)?i.get():i)),gi(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 c=lx(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);c&&(i=c[t])}if(n&&i!==void 0)return i;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!gi(r)?r:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Zy),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){fx.render(this.render)}}class ZR extends tk{constructor(){super(...arguments),this.KeyframeResolver=R7}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;gi(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class fo{constructor(t){this.isMounted=!1,this.node=t}update(){}}function QR({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function ek({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function nk(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 I_(e){return e===void 0||e===1}function x1({scale:e,scaleX:t,scaleY:n}){return!I_(e)||!I_(t)||!I_(n)}function Wo(e){return x1(e)||JR(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function JR(e){return aA(e.x)||aA(e.y)}function aA(e){return e&&e!=="0%"}function Wp(e,t,n){const i=e-n,r=t*i;return n+r}function oA(e,t,n,i,r){return r!==void 0&&(e=Wp(e,r,i)),Wp(e,n,i)+t}function S1(e,t=0,n=1,i,r){e.min=oA(e.min,t,n,i,r),e.max=oA(e.max,t,n,i,r)}function $R(e,{x:t,y:n}){S1(e.x,t.translate,t.scale,t.originPoint),S1(e.y,n.translate,n.scale,n.originPoint)}const lA=.999999999999,cA=1.0000000000001;function ik(e,t,n,i=!1){var u;const r=n.length;if(!r)return;t.x=t.y=1;let o,c;for(let h=0;hlA&&(t.x=1),t.ylA&&(t.y=1)}function yr(e,t){e.min+=t,e.max+=t}function uA(e,t,n,i,r=.5){const o=dn(e.min,e.max,r);S1(e,t,n,o,i)}function fA(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Mp(e,t,n){const i=n??e;uA(e.x,fA(t.x,i.x),t.scaleX,t.scale,t.originX),uA(e.y,fA(t.y,i.y),t.scaleY,t.scale,t.originY)}function tC(e,t){return QR(nk(e.getBoundingClientRect(),t))}function sk(e,t,n){const i=tC(e,n),{scroll:r}=t;return r&&(yr(i.x,r.offset.x),yr(i.y,r.offset.y)),i}const rk={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ak=pu.length;function ok(e,t,n){let i="",r=!0;for(let o=0;o{if(!t.target)return e;if(typeof e=="string")if(Wt.test(e))e=parseFloat(e);else return e;const n=hA(e,t.target.x),i=hA(e,t.target.y);return`${n}% ${i}%`}},lk={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,r=sr.parse(e);if(r.length>5)return i;const o=sr.createTransformer(e),c=typeof r[0]!="number"?1:0,u=n.x.scale*t.x,h=n.y.scale*t.y;r[0+c]/=u,r[1+c]/=h;const d=dn(u,h,.5);return typeof r[2+c]=="number"&&(r[2+c]/=d),typeof r[3+c]=="number"&&(r[3+c]/=d),o(r)}},M1={borderRadius:{...Sf,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Sf,borderTopRightRadius:Sf,borderBottomLeftRadius:Sf,borderBottomRightRadius:Sf,boxShadow:lk};function nC(e,{layout:t,layoutId:n}){return mu.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!M1[e]||e==="opacity")}function _x(e,t,n){var c;const i=e.style,r=t==null?void 0:t.style,o={};if(!i)return o;for(const u in i)(gi(i[u])||r&&gi(r[u])||nC(u,e)||((c=n==null?void 0:n.getValue(u))==null?void 0:c.liveStyle)!==void 0)&&(o[u]=i[u]);return o}function ck(e){return window.getComputedStyle(e)}class uk extends ZR{constructor(){super(...arguments),this.type="html",this.renderInstance=eC}readValueFromInstance(t,n){var i;if(mu.has(n))return(i=this.projection)!=null&&i.isProjecting?l1(n):D9(t,n);{const r=ck(t),o=(uR(n)?r.getPropertyValue(n):r[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return tC(t,n)}build(t,n,i){gx(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return _x(t,n,i)}}const fk={offset:"stroke-dashoffset",array:"stroke-dasharray"},hk={offset:"strokeDashoffset",array:"strokeDasharray"};function dk(e,t,n=1,i=0,r=!0){e.pathLength=1;const o=r?fk:hk;e[o.offset]=`${-i}`,e[o.array]=`${t} ${n}`}const pk=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function iC(e,{attrX:t,attrY:n,attrScale:i,pathLength:r,pathSpacing:o=1,pathOffset:c=0,...u},h,d,p){if(gx(e,u,d),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:m,style:_}=e;m.transform&&(_.transform=m.transform,delete m.transform),(_.transform||m.transformOrigin)&&(_.transformOrigin=m.transformOrigin??"50% 50%",delete m.transformOrigin),_.transform&&(_.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete m.transformBox);for(const y of pk)m[y]!==void 0&&(_[y]=m[y],delete m[y]);t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),i!==void 0&&(m.scale=i),r!==void 0&&dk(m,r,o,c,!1)}const sC=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"]),rC=e=>typeof e=="string"&&e.toLowerCase()==="svg";function mk(e,t,n,i){eC(e,t,void 0,i);for(const r in t.attrs)e.setAttribute(sC.has(r)?r:cx(r),t.attrs[r])}function aC(e,t,n){const i=_x(e,t,n);for(const r in e)if(gi(e[r])||gi(t[r])){const o=pu.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;i[o]=e[r]}return i}class gk extends ZR{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Yn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(mu.has(n)){const i=kR(n);return i&&i.default||0}return n=sC.has(n)?n:cx(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return aC(t,n,i)}build(t,n,i){iC(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,r){mk(t,n,i,r)}mount(t){this.isSVGTag=rC(t.tagName),super.mount(t)}}const _k=mx.length;function oC(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?oC(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<_k;n++){const i=mx[n],r=e.props[i];(Jf(r)||r===!1)&&(t[i]=r)}return t}function lC(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let i=0;iPromise.all(t.map(({animation:n,options:i})=>_7(e,n,i)))}function Sk(e){let t=xk(e),n=dA(),i=!0,r=!1;const o=d=>(p,m)=>{var y;const _=rl(e,m,d==="exit"?(y=e.presenceContext)==null?void 0:y.custom:void 0);if(_){const{transition:M,transitionEnd:T,...S}=_;p={...p,...S,...T}}return p};function c(d){t=d(e)}function u(d){const{props:p}=e,m=oC(e.parent)||{},_=[],y=new Set;let M={},T=1/0;for(let x=0;xT&&P,A=!1;const F=Array.isArray(E)?E:[E];let q=F.reduce(o(R),{});I===!1&&(q={});const{prevResolvedValues:tt={}}=w,ot={...tt,...q},ct=j=>{D=!0,y.has(j)&&(A=!0,y.delete(j)),w.needsAnimating[j]=!0;const pt=e.getValue(j);pt&&(pt.liveStyle=!1)};for(const j in ot){const pt=q[j],bt=tt[j];if(M.hasOwnProperty(j))continue;let z=!1;p1(pt)&&p1(bt)?z=!lC(pt,bt):z=pt!==bt,z?pt!=null?ct(j):y.add(j):pt!==void 0&&y.has(j)?ct(j):w.protectedKeys[j]=!0}w.prevProp=E,w.prevResolvedValues=q,w.isActive&&(M={...M,...q}),(i||r)&&e.blockInitialAnimation&&(D=!1);const k=U&&B;D&&(!k||A)&&_.push(...F.map(j=>{const pt={type:R};if(typeof j=="string"&&(i||r)&&!k&&e.manuallyAnimateOnMount&&e.parent){const{parent:bt}=e,z=rl(bt,j);if(bt.enteringChildren&&z){const{delayChildren:it}=z.transition||{};pt.delay=DR(bt.enteringChildren,e,it)}}return{animation:j,options:pt}}))}if(y.size){const x={};if(typeof p.initial!="boolean"){const R=rl(e,Array.isArray(p.initial)?p.initial[0]:p.initial);R&&R.transition&&(x.transition=R.transition)}y.forEach(R=>{const w=e.getBaseTarget(R),E=e.getValue(R);E&&(E.liveStyle=!0),x[R]=w??null}),_.push({animation:x})}let S=!!_.length;return i&&(p.initial===!1||p.initial===p.animate)&&!e.manuallyAnimateOnMount&&(S=!1),i=!1,r=!1,S?t(_):Promise.resolve()}function h(d,p){var _;if(n[d].isActive===p)return Promise.resolve();(_=e.variantChildren)==null||_.forEach(y=>{var M;return(M=y.animationState)==null?void 0:M.setActive(d,p)}),n[d].isActive=p;const m=u(d);for(const y in n)n[y].protectedKeys={};return m}return{animateChanges:u,setActive:h,setAnimateFunction:c,getState:()=>n,reset:()=>{n=dA(),r=!0}}}function Mk(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!lC(t,e):!1}function zo(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function dA(){return{animate:zo(!0),whileInView:zo(),whileHover:zo(),whileTap:zo(),whileDrag:zo(),whileFocus:zo(),exit:zo()}}function b1(e,t){e.min=t.min,e.max=t.max}function Zs(e,t){b1(e.x,t.x),b1(e.y,t.y)}function pA(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const cC=1e-4,bk=1-cC,Tk=1+cC,uC=.01,Ek=0-uC,Ak=0+uC;function Pi(e){return e.max-e.min}function wk(e,t,n){return Math.abs(e-t)<=n}function mA(e,t,n,i=.5){e.origin=i,e.originPoint=dn(t.min,t.max,e.origin),e.scale=Pi(n)/Pi(t),e.translate=dn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=bk&&e.scale<=Tk||isNaN(e.scale))&&(e.scale=1),(e.translate>=Ek&&e.translate<=Ak||isNaN(e.translate))&&(e.translate=0)}function kf(e,t,n,i){mA(e.x,t.x,n.x,i?i.originX:void 0),mA(e.y,t.y,n.y,i?i.originY:void 0)}function gA(e,t,n,i=0){const r=i?dn(n.min,n.max,i):n.min;e.min=r+t.min,e.max=e.min+Pi(t)}function Rk(e,t,n,i){gA(e.x,t.x,n.x,i==null?void 0:i.x),gA(e.y,t.y,n.y,i==null?void 0:i.y)}function _A(e,t,n,i=0){const r=i?dn(n.min,n.max,i):n.min;e.min=t.min-r,e.max=e.min+Pi(t)}function jp(e,t,n,i){_A(e.x,t.x,n.x,i==null?void 0:i.x),_A(e.y,t.y,n.y,i==null?void 0:i.y)}function vA(e,t,n,i,r){return e-=t,e=Wp(e,1/n,i),r!==void 0&&(e=Wp(e,1/r,i)),e}function Ck(e,t=0,n=1,i=.5,r,o=e,c=e){if(br.test(t)&&(t=parseFloat(t),t=dn(c.min,c.max,t/100)-c.min),typeof t!="number")return;let u=dn(o.min,o.max,i);e===o&&(u-=t),e.min=vA(e.min,t,n,u,r),e.max=vA(e.max,t,n,u,r)}function yA(e,t,[n,i,r],o,c){Ck(e,t[n],t[i],t[r],t.scale,o,c)}const Dk=["x","scaleX","originX"],Lk=["y","scaleY","originY"];function xA(e,t,n,i){yA(e.x,t,Dk,n?n.x:void 0,i?i.x:void 0),yA(e.y,t,Lk,n?n.y:void 0,i?i.y:void 0)}function SA(e){return e.translate===0&&e.scale===1}function fC(e){return SA(e.x)&&SA(e.y)}function MA(e,t){return e.min===t.min&&e.max===t.max}function Nk(e,t){return MA(e.x,t.x)&&MA(e.y,t.y)}function bA(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function hC(e,t){return bA(e.x,t.x)&&bA(e.y,t.y)}function TA(e){return Pi(e.x)/Pi(e.y)}function EA(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function _r(e){return[e("x"),e("y")]}function Uk(e,t,n){let i="";const r=e.x.translate/t.x,o=e.y.translate/t.y,c=(n==null?void 0:n.z)||0;if((r||o||c)&&(i=`translate3d(${r}px, ${o}px, ${c}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:p,rotateX:m,rotateY:_,skewX:y,skewY:M}=n;d&&(i=`perspective(${d}px) ${i}`),p&&(i+=`rotate(${p}deg) `),m&&(i+=`rotateX(${m}deg) `),_&&(i+=`rotateY(${_}deg) `),y&&(i+=`skewX(${y}deg) `),M&&(i+=`skewY(${M}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 dC=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Pk=dC.length,AA=e=>typeof e=="string"?parseFloat(e):e,wA=e=>typeof e=="number"||Wt.test(e);function Ok(e,t,n,i,r,o){r?(e.opacity=dn(0,n.opacity??1,Ik(i)),e.opacityExit=dn(t.opacity??1,0,Bk(i))):o&&(e.opacity=dn(t.opacity??1,n.opacity??1,i));for(let c=0;cit?1:n(Zf(e,t,i))}function Fk(e,t,n){const i=gi(e)?e:Zc(e);return i.start(ox("",i,t,n)),i.animation}function $f(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}const kk=(e,t)=>e.depth-t.depth;class zk{constructor(){this.children=[],this.isDirty=!1}add(t){Yy(this.children,t),this.isDirty=!0}remove(t){Fp(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(kk),this.isDirty=!1,this.children.forEach(t)}}function Vk(e,t){const n=Ui.now(),i=({timestamp:r})=>{const o=r-n;o>=t&&(co(i),e(o-t))};return cn.setup(i,!0),()=>co(i)}function bp(e){return gi(e)?e.get():e}class Hk{constructor(){this.members=[]}add(t){Yy(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 r=i.instance;(!r||r.isConnected===!1)&&!i.snapshot&&(Fp(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(Fp(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 r=this.members[i];if(r.isPresent!==!1&&((n=r.instance)==null?void 0:n.isConnected)!==!1)return this.promote(r),!0}return!1}promote(t,n){var r;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:c}=t.options;(o===void 0||o!==c)&&(t.resumeFrom=i,n&&(i.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),(r=t.root)!=null&&r.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,i,r,o,c;(i=(n=t.options).onExitComplete)==null||i.call(n),(c=(r=t.resumingFrom)==null?void 0:(o=r.options).onExitComplete)==null||c.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 Tp={hasAnimatedSinceResize:!0,hasEverUpdated:!1},B_=["","X","Y","Z"],Gk=1e3;let Wk=0;function F_(e,t,n,i){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),i&&(i[e]=0))}function mC(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=OR(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",cn,!(r||o))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&mC(i)}function gC({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:r}){return class{constructor(c={},u=t==null?void 0:t()){this.id=Wk++,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(qk),this.nodes.forEach($k),this.nodes.forEach(tz),this.nodes.forEach(Yk)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,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;cn.read(()=>{m=window.innerWidth}),e(c,()=>{const y=window.innerWidth;y!==m&&(m=y,this.root.updateBlockedByResize=!0,p&&p(),p=Vk(_,250),Tp.hasAnimatedSinceResize&&(Tp.hasAnimatedSinceResize=!1,this.nodes.forEach(LA)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&d&&(u||h)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:m,hasRelativeLayoutChanged:_,layout:y})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const M=this.options.transition||d.getDefaultTransition()||rz,{onLayoutAnimationStart:T,onLayoutAnimationComplete:S}=d.getProps(),x=!this.targetLayout||!hC(this.targetLayout,y),R=!m&&_;if(this.options.layoutRoot||this.resumeFrom||R||m&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...ax(M,"layout"),onPlay:T,onComplete:S};(d.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(p,R)}else m||LA(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=y})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),co(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(ez),this.animationId++)}getTransformTemplate(){const{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&mC(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&&!Pi(this.snapshot.measuredBox.x)&&!Pi(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 P=E/1e3;NA(m.x,c.x,P),NA(m.y,c.y,P),this.setTargetDelta(m),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(jp(_,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),iz(this.relativeTarget,this.relativeTargetOrigin,_,P),w&&Nk(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Yn()),Zs(w,this.relativeTarget)),T&&(this.animationValues=p,Ok(p,d,this.latestValues,P,R,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){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&&(co(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=cn.update(()=>{Tp.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Zc(0)),this.motionValue.jump(0,!1),this.currentAnimation=Fk(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),c.onUpdate&&c.onUpdate(p)},onStop:()=>{},onComplete:()=>{c.onComplete&&c.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 c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Gk),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:u,target:h,layout:d,latestValues:p}=c;if(!(!u||!h||!d)){if(this!==c&&this.layout&&d&&_C(this.options.animationType,this.layout.layoutBox,d.layoutBox)){h=this.target||Yn();const m=Pi(this.layout.layoutBox.x);h.x.min=c.target.x.min,h.x.max=h.x.min+m;const _=Pi(this.layout.layoutBox.y);h.y.min=c.target.y.min,h.y.max=h.y.min+_}Zs(u,h),Mp(u,p),kf(this.projectionDeltaWithTransform,this.layoutCorrected,u,p)}}registerSharedNode(c,u){this.sharedNodes.has(c)||this.sharedNodes.set(c,new Hk),this.sharedNodes.get(c).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 c=this.getStack();return c?c.lead===this:!0}getLead(){var u;const{layoutId:c}=this.options;return c?((u=this.getStack())==null?void 0:u.lead)||this:this}getPrevLead(){var u;const{layoutId:c}=this.options;return c?(u=this.getStack())==null?void 0:u.prevLead:void 0}getStack(){const{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:u,preserveFollowOpacity:h}={}){const d=this.getStack();d&&d.promote(this,h),c&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let u=!1;const{latestValues:h}=c;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(u=!0),!u)return;const d={};h.z&&F_("z",c,d,this.animationValues);for(let p=0;p{var u;return(u=c.currentAnimation)==null?void 0:u.stop()}),this.root.nodes.forEach(CA),this.root.sharedNodes.clear()}}}function jk(e){e.updateLayout()}function Xk(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:r}=e.layout,{animationType:o}=e.options,c=t.source!==e.layout.source;if(o==="size")_r(m=>{const _=c?t.measuredBox[m]:t.layoutBox[m],y=Pi(_);_.min=i[m].min,_.max=_.min+y});else if(o==="x"||o==="y"){const m=o==="x"?"y":"x";b1(c?t.measuredBox[m]:t.layoutBox[m],i[m])}else _C(o,t.layoutBox,i)&&_r(m=>{const _=c?t.measuredBox[m]:t.layoutBox[m],y=Pi(i[m]);_.max=_.min+y,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+y)});const u=xc();kf(u,i,t.layoutBox);const h=xc();c?kf(h,e.applyTransform(r,!0),t.measuredBox):kf(h,i,t.layoutBox);const d=!fC(u);let p=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:_,layout:y}=m;if(_&&y){const M=e.options.layoutAnchor||void 0,T=Yn();jp(T,t.layoutBox,_.layoutBox,M);const S=Yn();jp(S,i,y.layoutBox,M),hC(T,S)||(p=!0),m.options.layoutRoot&&(e.relativeTarget=S,e.relativeTargetOrigin=T,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 qk(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 Yk(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Kk(e){e.clearSnapshot()}function CA(e){e.clearMeasurements()}function Zk(e){e.isLayoutDirty=!0,e.updateLayout()}function DA(e){e.isLayoutDirty=!1}function Qk(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Jk(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function LA(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function $k(e){e.resolveTargetDelta()}function tz(e){e.calcProjection()}function ez(e){e.resetSkewAndRotation()}function nz(e){e.removeLeadSnapshot()}function NA(e,t,n){e.translate=dn(t.translate,0,n),e.scale=dn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function UA(e,t,n,i){e.min=dn(t.min,n.min,i),e.max=dn(t.max,n.max,i)}function iz(e,t,n,i){UA(e.x,t.x,n.x,i),UA(e.y,t.y,n.y,i)}function sz(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const rz={duration:.45,ease:[.4,0,.1,1]},PA=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),OA=PA("applewebkit/")&&!PA("chrome/")?Math.round:Fs;function IA(e){e.min=OA(e.min),e.max=OA(e.max)}function az(e){IA(e.x),IA(e.y)}function _C(e,t,n){return e==="position"||e==="preserve-aspect"&&!wk(TA(t),TA(n),.2)}function oz(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const lz=gC({attachResizeListener:(e,t)=>$f(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}),k_={current:void 0},vC=gC({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!k_.current){const e=new lz({});e.mount(window),e.setOptions({layoutScroll:!0}),k_.current=e}return k_.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),vx=Mt.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function BA(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function cz(...e){return t=>{let n=!1;const i=e.map(r=>{const o=BA(r,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let r=0;r{const{width:y,height:M,top:T,left:S,right:x,bottom:R}=h.current;if(t||o===!1||!u.current||!y||!M)return;const w=n==="left"?`left: ${S}`:`right: ${x}`,E=i==="bottom"?`bottom: ${R}`:`top: ${T}`;u.current.dataset.motionPopId=c;const P=document.createElement("style");d&&(P.nonce=d);const I=r??document.head;return I.appendChild(P),P.sheet&&P.sheet.insertRule(` [data-motion-pop-id="${c}"] { position: absolute !important; width: ${y}px !important; height: ${M}px !important; ${w}px !important; ${E}px !important; } `),()=>{var U;(U=u.current)==null||U.removeAttribute("data-motion-pop-id"),I.contains(P)&&I.removeChild(P)}},[t]),_t.jsx(fz,{isPresent:t,childRef:u,sizeRef:h,pop:o,children:o===!1?e:Mt.cloneElement(e,{ref:m})})}const dz=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:r,presenceAffectsLayout:o,mode:c,anchorX:u,anchorY:h,root:d})=>{const p=qy(pz),m=Mt.useId();let _=!0,y=Mt.useMemo(()=>(_=!1,{id:m,initial:t,isPresent:n,custom:r,onExitComplete:M=>{p.set(M,!0);for(const T of p.values())if(!T)return;i&&i()},register:M=>(p.set(M,!1),()=>p.delete(M))}),[n,p,i]);return o&&_&&(y={...y}),Mt.useMemo(()=>{p.forEach((M,T)=>p.set(T,!1))},[n]),Mt.useEffect(()=>{!n&&!p.size&&i&&i()},[n]),e=_t.jsx(hz,{pop:c==="popLayout",isPresent:n,anchorX:u,anchorY:h,root:d,children:e}),_t.jsx(Sm.Provider,{value:y,children:e})};function pz(){return new Map}function yC(e=!0){const t=Mt.useContext(Sm);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:r}=t,o=Mt.useId();Mt.useEffect(()=>{if(e)return r(o)},[e]);const c=Mt.useCallback(()=>e&&i&&i(o),[o,i,e]);return!n&&i?[!1,c]:[!0]}const rp=e=>e.key||"";function FA(e){const t=[];return Mt.Children.forEach(e,n=>{Mt.isValidElement(n)&&t.push(n)}),t}const z_=({children:e,custom:t,initial:n=!0,onExitComplete:i,presenceAffectsLayout:r=!0,mode:o="sync",propagate:c=!1,anchorX:u="left",anchorY:h="top",root:d})=>{const[p,m]=yC(c),_=Mt.useMemo(()=>FA(e),[e]),y=c&&!p?[]:_.map(rp),M=Mt.useRef(!0),T=Mt.useRef(_),S=qy(()=>new Map),x=Mt.useRef(new Set),[R,w]=Mt.useState(_),[E,P]=Mt.useState(_);X4(()=>{M.current=!1,T.current=_;for(let B=0;B{const D=rp(B),A=c&&!p?!1:_===E||y.includes(D),F=()=>{if(x.current.has(D))return;if(S.has(D))x.current.add(D),S.set(D,!0);else return;let q=!0;S.forEach(tt=>{tt||(q=!1)}),q&&(U==null||U(),P(T.current),c&&(m==null||m()),i&&i())};return _t.jsx(dz,{isPresent:A,initial:!M.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:d,onExitComplete:A?void 0:F,anchorX:u,anchorY:h,children:B},D)})})},xC=Mt.createContext({strict:!1}),kA={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 zA=!1;function mz(){if(zA)return;const e={};for(const t in kA)e[t]={isEnabled:n=>kA[t].some(i=>!!n[i])};KR(e),zA=!0}function SC(){return mz(),$7()}function gz(e){const t=SC();for(const n in e)t[n]={...t[n],...e[n]};KR(t)}const _z=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 Xp(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||_z.has(e)}let MC=e=>!Xp(e);function vz(e){typeof e=="function"&&(MC=t=>t.startsWith("on")?!Xp(t):e(t))}try{vz(require("@emotion/is-prop-valid").default)}catch{}function yz(e,t,n){const i={};for(const r in e)r==="values"&&typeof e.values=="object"||gi(e[r])||(MC(r)||n===!0&&Xp(r)||!t&&!Xp(r)||e.draggable&&r.startsWith("onDrag"))&&(i[r]=e[r]);return i}const Em=Mt.createContext({});function xz(e,t){if(Tm(e)){const{initial:n,animate:i}=e;return{initial:n===!1||Jf(n)?n:void 0,animate:Jf(i)?i:void 0}}return e.inherit!==!1?t:{}}function Sz(e){const{initial:t,animate:n}=xz(e,Mt.useContext(Em));return Mt.useMemo(()=>({initial:t,animate:n}),[VA(t),VA(n)])}function VA(e){return Array.isArray(e)?e.join(" "):e}const yx=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function bC(e,t,n){for(const i in t)!gi(t[i])&&!nC(i,n)&&(e[i]=t[i])}function Mz({transformTemplate:e},t){return Mt.useMemo(()=>{const n=yx();return gx(n,t,e),Object.assign({},n.vars,n.style)},[t])}function bz(e,t){const n=e.style||{},i={};return bC(i,n,e),Object.assign(i,Mz(e,t)),i}function Tz(e,t){const n={},i=bz(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 TC=()=>({...yx(),attrs:{}});function Ez(e,t,n,i){const r=Mt.useMemo(()=>{const o=TC();return iC(o,t,rC(i),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};bC(o,e.style,e),r.style={...o,...r.style}}return r}const Az=["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 xx(e){return typeof e!="string"||e.includes("-")?!1:!!(Az.indexOf(e)>-1||/[A-Z]/u.test(e))}function wz(e,t,n,{latestValues:i},r,o=!1,c){const h=(c??xx(e)?Ez:Tz)(t,i,r,e),d=yz(t,typeof e=="string",o),p=e!==Mt.Fragment?{...d,...h,ref:n}:{},{children:m}=t,_=Mt.useMemo(()=>gi(m)?m.get():m,[m]);return Mt.createElement(e,{...p,children:_})}function Rz({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,r){return{latestValues:Cz(n,i,r,e),renderState:t()}}function Cz(e,t,n,i){const r={},o=i(e,{});for(const _ in o)r[_]=bp(o[_]);let{initial:c,animate:u}=e;const h=Tm(e),d=qR(e);t&&d&&!h&&e.inherit!==!1&&(c===void 0&&(c=t.initial),u===void 0&&(u=t.animate));let p=n?n.initial===!1:!1;p=p||c===!1;const m=p?u:c;if(m&&typeof m!="boolean"&&!bm(m)){const _=Array.isArray(m)?m:[m];for(let y=0;y<_.length;y++){const M=lx(e,_[y]);if(M){const{transitionEnd:T,transition:S,...x}=M;for(const R in x){let w=x[R];if(Array.isArray(w)){const E=p?w.length-1:0;w=w[E]}w!==null&&(r[R]=w)}for(const R in T)r[R]=T[R]}}}return r}const EC=e=>(t,n)=>{const i=Mt.useContext(Em),r=Mt.useContext(Sm),o=()=>Rz(e,t,i,r);return n?o():qy(o)},Dz=EC({scrapeMotionValuesFromProps:_x,createRenderState:yx}),Lz=EC({scrapeMotionValuesFromProps:aC,createRenderState:TC}),Nz=Symbol.for("motionComponentSymbol");function Uz(e,t,n){const i=Mt.useRef(n);Mt.useInsertionEffect(()=>{i.current=n});const r=Mt.useRef(null);return Mt.useCallback(o=>{var u;o&&((u=e.onMount)==null||u.call(e,o));const c=i.current;if(typeof c=="function")if(o){const h=c(o);typeof h=="function"&&(r.current=h)}else r.current?(r.current(),r.current=null):c(o);else c&&(c.current=o);t&&(o?t.mount(o):t.unmount())},[t])}const AC=Mt.createContext({});function dc(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Pz(e,t,n,i,r,o){var w,E;const{visualElement:c}=Mt.useContext(Em),u=Mt.useContext(xC),h=Mt.useContext(Sm),d=Mt.useContext(vx),p=d.reducedMotion,m=d.skipAnimations,_=Mt.useRef(null),y=Mt.useRef(!1);i=i||u.renderer,!_.current&&i&&(_.current=i(e,{visualState:t,parent:c,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:p,skipAnimations:m,isSVG:o}),y.current&&_.current&&(_.current.manuallyAnimateOnMount=!0));const M=_.current,T=Mt.useContext(AC);M&&!M.projection&&r&&(M.type==="html"||M.type==="svg")&&Oz(_.current,n,r,T);const S=Mt.useRef(!1);Mt.useInsertionEffect(()=>{M&&S.current&&M.update(n,h)});const x=n[PR],R=Mt.useRef(!!x&&typeof window<"u"&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,x))&&((E=window.MotionHasOptimisedAnimation)==null?void 0:E.call(window,x)));return X4(()=>{y.current=!0,M&&(S.current=!0,window.MotionIsMounted=!0,M.updateFeatures(),M.scheduleRenderMicrotask(),R.current&&M.animationState&&M.animationState.animateChanges())}),Mt.useEffect(()=>{M&&(!R.current&&M.animationState&&M.animationState.animateChanges(),R.current&&(queueMicrotask(()=>{var P;(P=window.MotionHandoffMarkAsComplete)==null||P.call(window,x)}),R.current=!1),M.enteringChildren=void 0)}),M}function Oz(e,t,n,i){const{layoutId:r,layout:o,drag:c,dragConstraints:u,layoutScroll:h,layoutRoot:d,layoutAnchor:p,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:wC(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!c||u&&dc(u),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,crossfade:m,layoutScroll:h,layoutRoot:d,layoutAnchor:p})}function wC(e){if(e)return e.options.allowProjection!==!1?e.projection:wC(e.parent)}function V_(e,{forwardMotionProps:t=!1,type:n}={},i,r){i&&gz(i);const o=n?n==="svg":xx(e),c=o?Lz:Dz;function u(d,p){let m;const _={...Mt.useContext(vx),...d,layoutId:Iz(d)},{isStatic:y}=_,M=Sz(d),T=c(d,y);if(!y&&typeof window<"u"){Bz();const S=Fz(_);m=S.MeasureLayout,M.visualElement=Pz(e,T,_,r,S.ProjectionNode,o)}return _t.jsxs(Em.Provider,{value:M,children:[m&&M.visualElement?_t.jsx(m,{visualElement:M.visualElement,..._}):null,wz(e,d,Uz(T,M.visualElement,p),T,y,t,o)]})}u.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=Mt.forwardRef(u);return h[Nz]=e,h}function Iz({layoutId:e}){const t=Mt.useContext(Xy).id;return t&&e!==void 0?t+"-"+e:e}function Bz(e,t){Mt.useContext(xC).strict}function Fz(e){const t=SC(),{drag:n,layout:i}=t;if(!n&&!i)return{};const r={...n,...i};return{MeasureLayout:n!=null&&n.isEnabled(e)||i!=null&&i.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function kz(e,t){if(typeof Proxy>"u")return V_;const n=new Map,i=(o,c)=>V_(o,c,e,t),r=(o,c)=>i(o,c);return new Proxy(r,{get:(o,c)=>c==="create"?i:(n.has(c)||n.set(c,V_(c,void 0,e,t)),n.get(c))})}const zz=(e,t)=>t.isSVG??xx(e)?new gk(t):new uk(t,{allowProjection:e!==Mt.Fragment});class Vz extends fo{constructor(t){super(t),t.animationState||(t.animationState=Sk(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();bm(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 Hz=0;class Gz extends fo{constructor(){super(...arguments),this.id=Hz++,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:c,custom:u}=this.node.getProps();if(typeof c=="string"){const h=rl(this.node,c,u);if(h){const{transition:d,transitionEnd:p,...m}=h;for(const _ in m)(o=this.node.getValue(_))==null||o.jump(m[_])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.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 Wz={animation:{Feature:Vz},exit:{Feature:Gz}};function dh(e){return{point:{x:e.pageX,y:e.pageY}}}const jz=e=>t=>hx(t)&&e(t,dh(t));function zf(e,t,n,i){return $f(e,t,jz(n),i)}const RC=({current:e})=>e?e.ownerDocument.defaultView:null,HA=(e,t)=>Math.abs(e-t);function Xz(e,t){const n=HA(e.x,t.x),i=HA(e.y,t.y);return Math.sqrt(n**2+i**2)}const GA=new Set(["auto","scroll"]);class CC{constructor(t,n,{transformPagePoint:i,contextWindow:r=window,dragSnapToOrigin:o=!1,distanceThreshold:c=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=y=>{this.handleScroll(y.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ap(this.lastRawMoveEventInfo,this.transformPagePoint));const y=H_(this.lastMoveEventInfo,this.history),M=this.startEvent!==null,T=Xz(y.offset,{x:0,y:0})>=this.distanceThreshold;if(!M&&!T)return;const{point:S}=y,{timestamp:x}=mi;this.history.push({...S,timestamp:x});const{onStart:R,onMove:w}=this.handlers;M||(R&&R(this.lastMoveEvent,y),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,y)},this.handlePointerMove=(y,M)=>{this.lastMoveEvent=y,this.lastRawMoveEventInfo=M,this.lastMoveEventInfo=ap(M,this.transformPagePoint),cn.update(this.updatePoint,!0)},this.handlePointerUp=(y,M)=>{this.end();const{onEnd:T,onSessionEnd:S,resumeAnimation:x}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const R=H_(y.type==="pointercancel"?this.lastMoveEventInfo:ap(M,this.transformPagePoint),this.history);this.startEvent&&T&&T(y,R),S&&S(y,R)},!hx(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=c,this.contextWindow=r||window;const h=dh(t),d=ap(h,this.transformPagePoint),{point:p}=d,{timestamp:m}=mi;this.history=[{...p,timestamp:m}];const{onSessionStart:_}=n;_&&_(t,H_(d,this.history)),this.removeListeners=uh(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);(GA.has(i.overflowX)||GA.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,r=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:r.x-n.x,y:r.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,r),cn.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),co(this.updatePoint)}}function ap(e,t){return t?{point:t(e.point)}:e}function WA(e,t){return{x:e.x-t.x,y:e.y-t.y}}function H_({point:e},t){return{point:e,delta:WA(e,DC(t)),offset:WA(e,qz(t)),velocity:Yz(t,.1)}}function qz(e){return e[0]}function DC(e){return e[e.length-1]}function Yz(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const r=DC(e);for(;n>=0&&(i=e[n],!(r.timestamp-i.timestamp>ms(t)));)n--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&r.timestamp-i.timestamp>ms(t)*2&&(i=e[1]);const o=Bs(r.timestamp-i.timestamp);if(o===0)return{x:0,y:0};const c={x:(r.x-i.x)/o,y:(r.y-i.y)/o};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function Kz(e,{min:t,max:n},i){return t!==void 0&&en&&(e=i?dn(n,e,i.max):Math.min(e,n)),e}function jA(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 Zz(e,{top:t,left:n,bottom:i,right:r}){return{x:jA(e.x,n,r),y:jA(e.y,t,i)}}function XA(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.mini?n=Zf(t.min,t.max-i,e.min):i>r&&(n=Zf(e.min,e.max-r,t.min)),Ar(0,1,n)}function $z(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 T1=.35;function tV(e=T1){return e===!1?e=0:e===!0&&(e=T1),{x:qA(e,"left","right"),y:qA(e,"top","bottom")}}function qA(e,t,n){return{min:YA(e,t),max:YA(e,n)}}function YA(e,t){return typeof e=="number"?e:e[t]||0}const eV=new WeakMap;class nV{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=Yn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=m=>{n&&this.snapToCursor(dh(m).point),this.stopAnimation()},c=(m,_)=>{const{drag:y,dragPropagation:M,onDragStart:T}=this.getProps();if(y&&!M&&(this.openDragLock&&this.openDragLock(),this.openDragLock=C7(y),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=_,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),_r(x=>{let R=this.getAxisMotionValue(x).get()||0;if(br.test(R)){const{projection:w}=this.visualElement;if(w&&w.layout){const E=w.layout.layoutBox[x];E&&(R=Pi(E)*(parseFloat(R)/100))}}this.originPoint[x]=R}),T&&cn.update(()=>T(m,_),!1,!0),m1(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},u=(m,_)=>{this.latestPointerEvent=m,this.latestPanInfo=_;const{dragPropagation:y,dragDirectionLock:M,onDirectionLock:T,onDrag:S}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:x}=_;if(M&&this.currentDirection===null){this.currentDirection=sV(x),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",_.point,x),this.updateAxis("y",_.point,x),this.visualElement.render(),S&&cn.update(()=>S(m,_),!1,!0)},h=(m,_)=>{this.latestPointerEvent=m,this.latestPanInfo=_,this.stop(m,_),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 CC(t,{onSessionStart:o,onStart:c,onMove:u,onSessionEnd:h,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:i,contextWindow:RC(this.visualElement),element:this.visualElement.current})}stop(t,n){const i=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!i)return;const{velocity:c}=r;this.startAnimation(c);const{onDragEnd:u}=this.getProps();u&&cn.postRender(()=>u(i,r))}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:r}=this.getProps();if(!i||!op(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let c=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(c=Kz(c,this.constraints[t],this.elastic[t])),o.set(c)}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,r=this.constraints;t&&dc(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=Zz(i.layoutBox,t):this.constraints=!1,this.elastic=tV(n),r!==this.constraints&&!dc(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&_r(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=$z(i.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!dc(t))return!1;const i=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=sk(i,r.root,this.visualElement.getTransformPagePoint());let c=Qz(r.layout.layoutBox,o);if(n){const u=n(ek(c));this.hasMutatedConstraints=!!u,u&&(c=QR(u))}return c}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:r,dragTransition:o,dragSnapToOrigin:c,onDragTransitionEnd:u}=this.getProps(),h=this.constraints||{},d=_r(p=>{if(!op(p,n,this.currentDirection))return;let m=h&&h[p]||{};(c===!0||c===p)&&(m={min:0,max:0});const _=r?200:1e6,y=r?40:1e7,M={type:"inertia",velocity:i?t[p]:0,bounceStiffness:_,bounceDamping:y,timeConstant:750,restDelta:1,restSpeed:10,...o,...m};return this.startAxisValueAnimation(p,M)});return Promise.all(d).then(u)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return m1(this.visualElement,t),i.start(ox(t,i,0,n,this.visualElement,!1))}stopAnimation(){_r(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),r=i[n];return r||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){_r(n=>{const{drag:i}=this.getProps();if(!op(n,i,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(n);if(r&&r.layout){const{min:c,max:u}=r.layout.layoutBox[n],h=o.get()||0;o.set(t[n]-dn(c,u,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!dc(n)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};_r(c=>{const u=this.getAxisMotionValue(c);if(u&&this.constraints!==!1){const h=u.get();r[c]=Jz({min:h,max:h},this.constraints[c])}});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(),_r(c=>{if(!op(c,t,null))return;const u=this.getAxisMotionValue(c),{min:h,max:d}=this.constraints[c];u.set(dn(h,d,r[c]))}),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(),_=d.target,y=_!==t&&O7(_);p&&m&&!y&&this.start(d)});let i;const r=()=>{const{dragConstraints:d}=this.getProps();dc(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),i||(i=iV(t,d.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,c=o.addEventListener("measure",r);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),cn.read(r);const u=$f(window,"resize",()=>this.scalePositionWithinConstraints()),h=o.addEventListener("didUpdate",(({delta:d,hasLayoutChanged:p})=>{this.isDragging&&p&&(_r(m=>{const _=this.getAxisMotionValue(m);_&&(this.originPoint[m]+=d[m].translate,_.set(_.get()+d[m].translate))}),this.visualElement.render())}));return()=>{u(),n(),c(),h&&h(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:c=T1,dragMomentum:u=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:r,dragConstraints:o,dragElastic:c,dragMomentum:u}}}function KA(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function iV(e,t,n){const i=nA(e,KA(n)),r=nA(t,KA(n));return()=>{i(),r()}}function op(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function sV(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class rV extends fo{constructor(t){super(t),this.removeGroupControls=Fs,this.removeListeners=Fs,this.controls=new nV(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Fs}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 G_=e=>(t,n)=>{e&&cn.update(()=>e(t,n),!1,!0)};class aV extends fo{constructor(){super(...arguments),this.removePointerDownListener=Fs}onPointerDown(t){this.session=new CC(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:RC(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:G_(t),onStart:G_(n),onMove:G_(i),onEnd:(o,c)=>{delete this.session,r&&cn.postRender(()=>r(o,c))}}}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 W_=!1;class oV extends Mt.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:r}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),i&&i.register&&r&&i.register(o),W_&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Tp.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:r,isPresent:o}=this.props,{projection:c}=i;return c&&(c.isPresent=o,t.layoutDependency!==n&&c.setOptions({...c.options,layoutDependency:n}),W_=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?c.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?c.promote():c.relegate()||cn.postRender(()=>{const u=c.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(),fx.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:r}=t;W_=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function LC(e){const[t,n]=yC(),i=Mt.useContext(Xy);return _t.jsx(oV,{...e,layoutGroup:i,switchLayoutGroup:Mt.useContext(AC),isPresent:t,safeToRemove:n})}const lV={pan:{Feature:aV},drag:{Feature:rV,ProjectionNode:vC,MeasureLayout:LC}};function ZA(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=i[r];o&&cn.postRender(()=>o(t,dh(t)))}class cV extends fo{mount(){const{current:t}=this.node;t&&(this.unmount=L7(t,(n,i)=>(ZA(this.node,i,"Start"),r=>ZA(this.node,r,"End"))))}unmount(){}}class uV extends fo{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=uh($f(this.node.current,"focus",()=>this.onFocus()),$f(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function QA(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 r="onTap"+(n==="End"?"":n),o=i[r];o&&cn.postRender(()=>o(t,dh(t)))}class fV extends fo{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=B7(t,(r,o)=>(QA(this.node,o,"Start"),(c,{success:u})=>QA(this.node,c,u?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const E1=new WeakMap,j_=new WeakMap,hV=e=>{const t=E1.get(e.target);t&&t(e)},dV=e=>{e.forEach(hV)};function pV({root:e,...t}){const n=e||document;j_.has(n)||j_.set(n,{});const i=j_.get(n),r=JSON.stringify(t);return i[r]||(i[r]=new IntersectionObserver(dV,{root:e,...t})),i[r]}function mV(e,t,n){const i=pV(t);return E1.set(e,n),i.observe(e),()=>{E1.delete(e),i.unobserve(e)}}const gV={some:0,all:1};class _V extends fo{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:r="some",once:o}=t,c={root:n?n.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:gV[r]},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:_}=this.node.getProps(),y=p?m:_;y&&y(d)};this.stopObserver=mV(this.node.current,c,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(vV(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function vV({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const yV={inView:{Feature:_V},tap:{Feature:fV},focus:{Feature:uV},hover:{Feature:cV}},xV={layout:{ProjectionNode:vC,MeasureLayout:LC}},SV={...Wz,...yV,...lV,...xV},X_=kz(SV,zz);/** * @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 MV=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),bV=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,i)=>i?i.toUpperCase():n.toLowerCase()),JA=e=>{const t=bV(e);return t.charAt(0).toUpperCase()+t.slice(1)},NC=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim(),TV=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 EV={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 AV=Mt.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:o,iconNode:c,...u},h)=>Mt.createElement("svg",{ref:h,...EV,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:NC("lucide",r),...!o&&!TV(u)&&{"aria-hidden":"true"},...u},[...c.map(([d,p])=>Mt.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 Sx=(e,t)=>{const n=Mt.forwardRef(({className:i,...r},o)=>Mt.createElement(AV,{ref:o,iconNode:t,className:NC(`lucide-${MV(JA(e))}`,`lucide-${e}`,i),...r}));return n.displayName=JA(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 wV=[["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"}]],RV=Sx("play",wV);/** * @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 CV=[["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"}]],DV=Sx("rotate-ccw",CV);/** * @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 LV=[["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"}]],NV=Sx("shield",LV);function UV(e){const t=[...e];for(let i=t.length-1;i>0;i--){const r=Math.floor(Math.random()*(i+1));[t[i],t[r]]=[t[r],t[i]]}const n=t.indexOf(e[0]);return{options:t,correctZone:n}}function PV(e){let t="",n=0,i=0,r=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,_=p*m;t=`${p}x = ${_}, x = ?`,n=m}}let o=Math.floor(Math.random()*3)+1,c=Math.floor(Math.random()*3)+1;Math.random()>.5&&(o*=-1),Math.random()>.5&&(c*=-1),i=n+o,r=n+c*2,i===r&&(r+=1),i===n&&(i+=1),r===n&&(r-=1);const{options:u,correctZone:h}=UV([n,i,r]);return{question:t,correctAnswer:n,options:u,correctZone:h}}const fs=new(window.AudioContext||window.webkitAudioContext);let Mf=null;function bf(e){if(fs.state==="suspended"&&fs.resume(),e==="BGM_START"){if(Mf)return;const r=[220,261.63,329.63,440,392,329.63,261.63,196];let o=0;Mf=setInterval(()=>{const c=fs.currentTime,u=fs.createOscillator(),h=fs.createGain();u.type="sawtooth",u.frequency.setValueAtTime(r[o%r.length]/2,c),h.gain.setValueAtTime(.04,c),h.gain.exponentialRampToValueAtTime(.001,c+.2);const d=fs.createBiquadFilter();d.type="lowpass",d.frequency.setValueAtTime(600,c),d.frequency.exponentialRampToValueAtTime(100,c+.2),u.connect(d),d.connect(h),h.connect(fs.destination),u.start(c),u.stop(c+.2),o++},280);return}if(e==="BGM_STOP"){Mf&&(clearInterval(Mf),Mf=null);return}const t=fs.createOscillator(),n=fs.createGain();t.connect(n),n.connect(fs.destination);const i=fs.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 r=fs.createOscillator();r.type="square",r.frequency.setValueAtTime(200,i),r.frequency.exponentialRampToValueAtTime(1e3,i+.3),r.connect(n),r.start(i),r.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 r=fs.createOscillator();t.type="sine",r.type="square",t.frequency.setValueAtTime(800,i),t.frequency.exponentialRampToValueAtTime(100,i+.3),r.frequency.setValueAtTime(1200,i),r.frequency.exponentialRampToValueAtTime(200,i+.3),r.connect(n),n.gain.setValueAtTime(.2,i),n.gain.exponentialRampToValueAtTime(.01,i+.3),t.start(i),t.stop(i+.3),r.start(i),r.stop(i+.3)}}const $A=[{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}];function OV(){const e=Mt.useRef(null),t=Mt.useRef(null),n=Mt.useRef(null),i=Mt.useRef(null),r=Mt.useRef(null),o=Mt.useRef(null),[c,u]=Mt.useState([]),[h,d]=Mt.useState(!1),[p,m]=Mt.useState("IDLE"),_=Mt.useRef("IDLE"),[y,M]=Mt.useState(1),T=Mt.useRef(1),[S,x]=Mt.useState(0),[R,w]=Mt.useState(0),[E,P]=Mt.useState(0),I=Mt.useRef(0),[U,B]=Mt.useState(null),[D,A]=Mt.useState(null),F=Mt.useRef(null),[q,tt]=Mt.useState(!1),[ot,ct]=Mt.useState(!0),[k,Q]=Mt.useState(!1),[j,pt]=Mt.useState(""),bt=Mt.useRef(!1),[z,it]=Mt.useState(!1),[Tt,J]=Mt.useState(!1),[dt,At]=Mt.useState(null),[xt,Vt]=Mt.useState(!1),Gt=Mt.useRef(null),$t=Mt.useRef(-1);Mt.useEffect(()=>{async function Dt(){const Et=await hc.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.21/wasm");o.current=await qi.createFromOptions(Et,{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});let O=null;if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)try{O=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:640,height:480}}),e.current&&(e.current.srcObject=O,e.current.play().catch(C=>{C.name!=="AbortError"&&console.error("Error playing video:",C)})),t.current&&(t.current.srcObject=O,t.current.play().catch(C=>{C.name!=="AbortError"&&console.error("Error playing preview:",C)}))}catch(C){console.error("Camera access denied:",C),At("Camera access denied. Please allow camera permissions in your browser or open the app in a new tab.")}n.current&&!r.current&&(r.current=new zB(n.current,()=>{var C;return Ge((C=r.current)!=null&&C.isSuperBall?"SUPER_SAVE":"SAVE")},()=>Ge("GOAL")),r.current.setGloveStaticWrap(!0),r.current.setSwapGloveHands(!1)),d(!0)}return Dt(),()=>{var Et,O;(Et=r.current)==null||Et.cleanup(),(O=o.current)==null||O.close(),e.current&&e.current.srcObject&&(e.current.srcObject.getTracks().forEach($=>$.stop()),e.current.srcObject=null)}},[]);const Ke=()=>{if(_.current!=="PLAYING"||!r.current||I.current>=10)return;const Dt=PV(T.current);A(Dt),F.current=Dt,r.current.shootBall(T.current,Dt.correctZone);const Et=r.current.isSuperBall;it(Et),Et&&(J(!0),setTimeout(()=>J(!1),500)),bf("KICK"),Et&&bf("WHOOSH")},Ge=Dt=>{bf(Dt),r.current&&r.current.hideTrails();let Et="";if(F.current){const O=F.current.options[F.current.correctZone];Et=Dt==="GOAL"?`Miss... = ${O}`:`Correct! = ${O}`}else Et=Dt==="SAVE"?"SAVE!":Dt==="SUPER_SAVE"?"SUPER SAVE!!":"GOAL!";if(Dt==="SAVE"||Dt==="SUPER_SAVE"){const O=Dt==="SAVE"?100:300;x(C=>C+O*T.current)}else w(O=>O+1);P(O=>{const C=O+1;return I.current=C,C}),B({text:Et,type:Dt}),setTimeout(()=>B(null),1e3),setTimeout(Ke,2e3)};Mt.useEffect(()=>{const Dt=()=>{i.current&&(i.current.width=window.innerWidth,i.current.height=window.innerHeight)};window.addEventListener("resize",Dt),Dt();let Et;const O=()=>{var C;if(e.current&&o.current&&e.current.readyState>=2){const $=performance.now();if($t.current!==e.current.currentTime){$t.current=e.current.currentTime;const ut=o.current.detectForVideo(e.current,$);if(ut.landmarks&&ut.landmarks[0]?Gt.current=ut.landmarks[0]:Gt.current=null,(C=r.current)==null||C.updateGloveLandmarks(Gt.current),!bt.current&&Gt.current&&r.current&&r.current.calibrateGloves(Gt.current)){bt.current=!0;const mt=r.current.getSwapGloveHands();Q(mt),pt(mt?"Gloves calibrated (mapping swapped)":"Gloves calibrated"),setTimeout(()=>pt(""),1600)}}}if(r.current&&Gt.current&&_.current==="PLAYING"){const $=r.current.getBallScreenPosition();if($){const ut=$.x,St=$.y;let mt=!1;const Xt=[15,17,19,21,16,18,20,22];for(const Ct of Xt){const Lt=Gt.current[Ct];if(!Lt||(Lt.visibility||1)<.3)continue;const Se=1-Lt.x,Rt=Lt.y;if(Math.hypot(Se-ut,Rt-St)<.15){mt=!0;break}}mt&&(r.current.isBallActive=!1,r.current.triggerParticleSave(),Ge(r.current.isSuperBall?"SUPER_SAVE":"SAVE"))}}if(i.current&&Gt.current){const $=i.current.getContext("2d");if($&&($.clearRect(0,0,i.current.width,i.current.height),q)){const ut=i.current.width,St=i.current.height,mt=[{id:0,xMin:.1,xMax:.35,yMin:.25,yMax:.65},{id:1,xMin:.38,xMax:.62,yMin:.25,yMax:.65},{id:2,xMin:.65,xMax:.9,yMin:.25,yMax:.65}];$.strokeStyle="#00FF00",$.lineWidth=4;for(const Ct of mt)$.strokeRect(Ct.xMin*ut,Ct.yMin*St,(Ct.xMax-Ct.xMin)*ut,(Ct.yMax-Ct.yMin)*St);const Xt=[15,17,19,21,16,18,20,22];$.fillStyle="#FF0055";for(const Ct of Xt){const Lt=Gt.current[Ct];Lt&&($.beginPath(),$.arc((1-Lt.x)*ut,Lt.y*St,15,0,Math.PI*2),$.fill())}if(r.current){const Ct=new G(-3,1.5,r.current.catchPlaneZ).project(r.current.camera),Lt=new G(3,1.5,r.current.catchPlaneZ).project(r.current.camera),Se=new G(0,3,r.current.catchPlaneZ).project(r.current.camera),Rt=new G(0,0,r.current.catchPlaneZ).project(r.current.camera),zt=(Ct.x+1)/2*ut,te=(Lt.x+1)/2*ut,qt=(-Se.y+1)/2*St,Bt=(-Rt.y+1)/2*St;$.strokeStyle="#FFFF00",$.lineWidth=4,$.strokeRect(zt,qt,te-zt,Bt-qt)}}}Et=requestAnimationFrame(O)};return O(),()=>{cancelAnimationFrame(Et),window.removeEventListener("resize",Dt)}},[y]);const ye=Dt=>{try{const Et=JSON.parse(localStorage.getItem("ar-goalkeeper-scores")||"[]");Dt&&Dt>0&&(Et.push({id:Date.now().toString(),name:"YOU",score:Dt,isYou:!0}),Et.sort((C,$)=>$.score-C.score),localStorage.setItem("ar-goalkeeper-scores",JSON.stringify(Et.slice(0,10))));const O=[...$A,...Et];O.sort((C,$)=>$.score-C.score),u(O.slice(0,5))}catch(Et){console.error(Et),u($A)}};Mt.useEffect(()=>{ye()},[]),Mt.useEffect(()=>{E>=10&&p==="PLAYING"&&(m("GAMEOVER"),_.current="GAMEOVER",bf("BGM_STOP"),r.current&&(r.current.isBallActive=!1),ye(S))},[E,S,p]);const H=Dt=>{M(Dt),T.current=Dt},Wn=()=>{var Dt;x(0),w(0),P(0),I.current=0,m("PLAYING"),_.current="PLAYING",bt.current=!1,Q(!1),(Dt=r.current)==null||Dt.setSwapGloveHands(!1),bf("BGM_START"),it(!1),setTimeout(()=>{_.current==="PLAYING"&&Ke()},1e3)},xe=()=>{if(!r.current)return;if(r.current.calibrateGloves(Gt.current)){const Et=r.current.getSwapGloveHands();Q(Et),pt(Et?"Gloves recalibrated (mapping swapped)":"Gloves recalibrated")}else pt("Calibration failed: show both hands to camera");setTimeout(()=>pt(""),2e3)},be=()=>{var Et;const Dt=!ot;ct(Dt),(Et=r.current)==null||Et.setGloveStaticWrap(Dt),pt(Dt?"Glove mode: static wrap":"Glove mode: dynamic angle"),setTimeout(()=>pt(""),1400)},Kt=()=>{var Et;const Dt=!k;Q(Dt),(Et=r.current)==null||Et.setSwapGloveHands(Dt),pt(Dt?"Hand mapping swapped":"Hand mapping normal"),setTimeout(()=>pt(""),1400)};return _t.jsxs("div",{className:`relative w-screen h-screen overflow-hidden text-white font-anime tracking-wide ${Tt?"camera-shake":""}`,style:{background:"radial-gradient(circle at center, #1a2a1a 0%, #050505 100%)"},children:[z&&p==="PLAYING"&&_t.jsx("div",{className:"speed-lines pointer-events-none"}),_t.jsx("video",{ref:e,playsInline:!0,muted:!0,className:`absolute inset-0 w-full h-full object-cover -scale-x-100 ${p==="PLAYING"?"opacity-40":"opacity-0"}`}),_t.jsx("div",{className:`absolute inset-0 pointer-events-none ${p==="PLAYING"?"opacity-40":"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)"}}),_t.jsx("div",{ref:n,className:"absolute inset-0 w-full h-full pointer-events-none"}),_t.jsx("canvas",{ref:i,className:"absolute inset-0 w-full h-full pointer-events-none opacity-50 z-10"}),_t.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col pointer-events-none",children:[p==="PLAYING"&&D&&_t.jsx("div",{className:"absolute inset-0 z-30 pointer-events-none",children:D.options.map((Dt,Et)=>{const O=Et===0?"22.5%":Et===1?"50%":"77.5%";return _t.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/10 rounded-[2rem] shadow-[0_0_10px_rgba(255,255,255,0.05)]",style:{left:O,top:"45%"},children:_t.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:Dt})},Et)})}),p==="PLAYING"&&_t.jsxs("header",{className:"absolute top-8 left-8 right-8 flex justify-between items-start z-50 pointer-events-auto",children:[_t.jsxs("div",{className:"flex gap-4",children:[_t.jsx("div",{className:"bg-white border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#FFE600] transition-transform",children:_t.jsxs("div",{className:"skew-x-[15deg]",children:[_t.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-[#FF0055] mb-[-4px]",children:"SCORE"}),_t.jsx("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-black tracking-widest",children:String(S).padStart(5,"0")})]})}),_t.jsx("div",{className:"bg-black border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#FF0055]",children:_t.jsxs("div",{className:"skew-x-[15deg]",children:[_t.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-[#FF0055] mb-[-4px]",children:"GOALS"}),_t.jsx("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-white tracking-widest",children:String(R).padStart(2,"0")})]})})]}),_t.jsx("div",{className:"flex flex-col items-end gap-2",children:_t.jsx("div",{className:"bg-white border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#00E5FF]",children:_t.jsxs("div",{className:"skew-x-[15deg]",children:[_t.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-black mb-[-4px]",children:"KICKS"}),_t.jsxs("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-black tracking-widest",children:[String(E).padStart(2,"0")," ",_t.jsx("span",{className:"text-black/50 text-[20px] font-black tracking-wide",children:"/ 10"})]})]})})})]}),p==="PLAYING"&&D&&_t.jsx("div",{className:"absolute bottom-20 left-1/2 -translate-x-1/2 z-50 flex flex-col items-center pointer-events-none",children:_t.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:_t.jsxs("div",{className:"skew-x-[10deg] text-white flex flex-col items-center",children:[_t.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"}),_t.jsx("div",{className:"text-[52px] sm:text-[64px] font-comic font-black tracking-widest drop-shadow-xl leading-none",children:D.question})]})})}),_t.jsx(z_,{children:p==="IDLE"&&_t.jsx(X_.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:_t.jsxs("div",{className:"max-w-3xl w-full py-8",children:[_t.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:_t.jsx(NV,{className:"w-10 h-10 sm:w-12 sm:h-12 text-white -rotate-12"})}),_t.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"}),_t.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!"}),_t.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:[_t.jsx("span",{className:"animate-pulse",children:"โ–ถ"})," LIVE TRACKING ACTIVE"]}),dt?_t.jsx("div",{className:"flex flex-col items-center gap-4 py-4 sm:py-8",children:_t.jsx("p",{className:"text-[#FF0055] font-anime font-black text-xl sm:text-2xl tracking-widest mt-4 max-w-md text-center",children:dt})}):h?_t.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[_t.jsxs("div",{children:[_t.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"}),_t.jsx("div",{className:"flex flex-wrap justify-center gap-3 sm:gap-4",children:[1,1.5,2].map((Dt,Et)=>{const O=["GENIN","CHUNIN","JONIN"];return _t.jsx("button",{onClick:()=>H(Dt),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 ${y===Dt?"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:_t.jsx("div",{className:"skew-x-[15deg]",children:O[Et]})},Dt)})})]}),_t.jsx("button",{onClick:Wn,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:_t.jsxs("div",{className:"skew-x-[10deg] flex items-center justify-center gap-3 sm:gap-4",children:[_t.jsx(RV,{className:"fill-current w-8 h-8 sm:w-10 sm:h-10"})," ",_t.jsx("span",{className:"mt-1",children:"START GAME!"})]})}),_t.jsx("button",{onClick:()=>Vt(!xt),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:_t.jsx("div",{className:"skew-x-[10deg]",children:xt?"HIDE RANKING":"SHOW RANKING"})}),xt&&_t.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:_t.jsxs("div",{className:"skew-x-[5deg]",children:[_t.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 ๐Ÿ†"}),_t.jsx("div",{className:"flex flex-col gap-2 sm:gap-3",children:c.map((Dt,Et)=>_t.jsxs("div",{className:`flex justify-between items-center px-3 sm:px-4 py-2 border-2 ${Dt.isYou?"bg-[#FF0055] border-black text-white shadow-[4px_4px_0_#000]":"bg-white/10 border-white/20 text-white"}`,children:[_t.jsxs("span",{className:"font-anime font-bold text-base sm:text-lg tracking-widest truncate",children:[Et+1,". ",Dt.name]}),_t.jsx("span",{className:"font-comic font-black text-xl sm:text-2xl tabular-nums ml-4",children:String(Dt.score).padStart(5,"0")})]},Dt.id+Et))})]})})]}):_t.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 sm:py-8",children:[_t.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"}),_t.jsx("p",{className:"text-black font-anime font-black text-xl sm:text-3xl tracking-widest mt-4",children:"LOADING KI..."})]})]})})}),_t.jsx(z_,{children:p==="GAMEOVER"&&_t.jsx(X_.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:_t.jsxs("div",{className:"max-w-3xl w-full py-8",children:[_t.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"}),_t.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"}),_t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6 sm:gap-8 mb-10 sm:mb-16",children:[_t.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:_t.jsxs("div",{className:"skew-x-[10deg]",children:[_t.jsx("div",{className:"text-[14px] sm:text-[18px] font-anime font-black uppercase tracking-widest text-[#FF0055] mb-[4px]",children:"FINAL SCORE"}),_t.jsx("div",{className:"text-5xl sm:text-7xl font-comic font-[900] text-black tabular-nums leading-none tracking-widest",children:String(S).padStart(5,"0")})]})}),_t.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:_t.jsxs("div",{className:"skew-x-[10deg]",children:[_t.jsx("div",{className:"text-[14px] sm:text-[18px] font-anime font-black uppercase tracking-widest text-[#00E5FF] mb-[4px]",children:"CONCEDED"}),_t.jsx("div",{className:"text-5xl sm:text-7xl font-comic font-[900] text-white tabular-nums leading-none tracking-widest",children:String(R).padStart(2,"0")})]})})]}),_t.jsx("button",{onClick:Wn,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:_t.jsxs("div",{className:"skew-x-[10deg] flex items-center justify-center gap-3 sm:gap-4",children:[_t.jsx(DV,{className:"w-6 h-6 sm:w-8 sm:h-8 stroke-[4]"})," PLAY AGAIN!"]})}),_t.jsx("button",{onClick:()=>Vt(!xt),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:_t.jsx("div",{className:"skew-x-[10deg]",children:xt?"HIDE RANKING":"SHOW RANKING"})}),xt&&_t.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:_t.jsxs("div",{className:"skew-x-[-5deg]",children:[_t.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 ๐Ÿ†"}),_t.jsx("div",{className:"flex flex-col gap-2 sm:gap-3",children:c.map((Dt,Et)=>_t.jsxs("div",{className:`flex justify-between items-center px-3 sm:px-4 py-2 border-2 ${Dt.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:[_t.jsxs("span",{className:"font-anime font-bold text-base sm:text-lg tracking-widest truncate",children:[Et+1,". ",Dt.name]}),_t.jsx("span",{className:"font-comic font-black text-xl sm:text-2xl tabular-nums ml-4",children:String(Dt.score).padStart(5,"0")})]},Dt.id+Et))})]})})]})})}),_t.jsx(z_,{children:U&&_t.jsx(X_.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:_t.jsx("div",{className:`w-full flex items-center justify-center py-8 ${U.type==="SUPER_SAVE"?"cut-in-banner":""}`,children:_t.jsx("div",{className:`uppercase whitespace-nowrap text-center font-comic px-10 cut-in-text ${U.type==="SAVE"?"text-[#ffcc00] text-[120px] opacity-90 drop-shadow-[0_10px_0_#997300]":U.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:U.type==="SUPER_SAVE"?"4px #fff":"3px #000"},children:U.text})})})}),_t.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"]}),p!=="PLAYING"&&_t.jsx("div",{className:"absolute bottom-8 right-8 w-48 h-36 bg-white border-4 border-black box-content overflow-hidden shadow-[6px_6px_0_#00E5FF] skew-x-[-10deg] z-50 pointer-events-none fade-in",children:_t.jsxs("div",{className:"skew-x-[10deg] w-full h-full transform scale-110",children:[_t.jsx("video",{ref:t,playsInline:!0,muted:!0,className:"w-full h-full object-cover -scale-x-100"}),_t.jsxs("div",{className:"absolute top-2 left-2 text-[10px] font-anime font-black tracking-widest uppercase bg-[#FF0055] px-2 py-0.5 text-white flex items-center gap-1 border-2 border-black",children:[_t.jsx("div",{className:"w-1.5 h-1.5 bg-white animate-[pulse_1s_ease-in-out_infinite]"}),"REC"]})]})}),_t.jsxs("div",{className:"absolute bottom-4 right-4 z-50 pointer-events-auto flex flex-col items-end gap-2",children:[j&&_t.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:j}),_t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[_t.jsx("button",{onClick:xe,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"}),_t.jsxs("button",{onClick:be,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: ",ot?"STATIC":"DYNAMIC"]}),_t.jsxs("button",{onClick:Kt,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: ",k?"SWAPPED":"NORMAL"]}),_t.jsxs("button",{onClick:()=>tt(!q),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: ",q?"ON":"OFF"]})]})]})]})]})}qL.createRoot(document.getElementById("root")).render(_t.jsx(Mt.StrictMode,{children:_t.jsx(OV,{})}));