(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode("*{margin:0;padding:0;box-sizing:border-box}html,body{width:100%;height:100%;background:#fceded}#root{width:100vw;height:90dvh}[class*=leva-] button[class*=title]{text-transform:capitalize}#leva__root{z-index:999999!important;position:relative}.ga-canvas{opacity:0;transition:opacity var(--ga-canvas-fade-duration, .4s) ease-out}.ga-canvas[data-ready=true]{opacity:1}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})(); function dL(n,e){for(var t=0;ti[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}function ef(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var CS={exports:{}},yg={};var dw;function hL(){if(dw)return yg;dw=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,r,s){var l=null;if(s!==void 0&&(l=""+s),r.key!==void 0&&(l=""+r.key),"key"in r){s={};for(var u in r)u!=="key"&&(s[u]=r[u])}else s=r;return r=s.ref,{$$typeof:n,type:i,key:l,ref:r!==void 0?r:null,props:s}}return yg.Fragment=e,yg.jsx=t,yg.jsxs=t,yg}var hw;function pL(){return hw||(hw=1,CS.exports=hL()),CS.exports}var xt=pL(),RS={exports:{}},mn={};var pw;function mL(){if(pw)return mn;pw=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function x(q){return q===null||typeof q!="object"?null:(q=b&&q[b]||q["@@iterator"],typeof q=="function"?q:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},A=Object.assign,T={};function M(q,ce,Se){this.props=q,this.context=ce,this.refs=T,this.updater=Se||E}M.prototype.isReactComponent={},M.prototype.setState=function(q,ce){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,ce,"setState")},M.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function R(){}R.prototype=M.prototype;function O(q,ce,Se){this.props=q,this.context=ce,this.refs=T,this.updater=Se||E}var D=O.prototype=new R;D.constructor=O,A(D,M.prototype),D.isPureReactComponent=!0;var F=Array.isArray;function U(){}var k={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function L(q,ce,Se){var Ge=Se.ref;return{$$typeof:n,type:q,key:ce,ref:Ge!==void 0?Ge:null,props:Se}}function z(q,ce){return L(q.type,ce,q.props)}function W(q){return typeof q=="object"&&q!==null&&q.$$typeof===n}function J(q){var ce={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(Se){return ce[Se]})}var $=/\/+/g;function oe(q,ce){return typeof q=="object"&&q!==null&&q.key!=null?J(""+q.key):ce.toString(36)}function ne(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(U,U):(q.status="pending",q.then(function(ce){q.status==="pending"&&(q.status="fulfilled",q.value=ce)},function(ce){q.status==="pending"&&(q.status="rejected",q.reason=ce)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function Y(q,ce,Se,Ge,Ye){var ve=typeof q;(ve==="undefined"||ve==="boolean")&&(q=null);var Oe=!1;if(q===null)Oe=!0;else switch(ve){case"bigint":case"string":case"number":Oe=!0;break;case"object":switch(q.$$typeof){case n:case e:Oe=!0;break;case g:return Oe=q._init,Y(Oe(q._payload),ce,Se,Ge,Ye)}}if(Oe)return Ye=Ye(q),Oe=Ge===""?"."+oe(q,0):Ge,F(Ye)?(Se="",Oe!=null&&(Se=Oe.replace($,"$&/")+"/"),Y(Ye,ce,Se,"",function(_t){return _t})):Ye!=null&&(W(Ye)&&(Ye=z(Ye,Se+(Ye.key==null||q&&q.key===Ye.key?"":(""+Ye.key).replace($,"$&/")+"/")+Oe)),ce.push(Ye)),1;Oe=0;var it=Ge===""?".":Ge+":";if(F(q))for(var gt=0;gt>>1,xe=Y[ge];if(0>>1;ger(Se,ie))Ger(Ye,Se)?(Y[ge]=Ye,Y[Ge]=ie,ge=Ge):(Y[ge]=Se,Y[ce]=ie,ge=ce);else if(Ger(Ye,ie))Y[ge]=Ye,Y[Ge]=ie,ge=Ge;else break e}}return K}function r(Y,K){var ie=Y.sortIndex-K.sortIndex;return ie!==0?ie:Y.id-K.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var l=Date,u=l.now();n.unstable_now=function(){return l.now()-u}}var h=[],p=[],g=1,y=null,b=3,x=!1,E=!1,A=!1,T=!1,M=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function D(Y){for(var K=t(p);K!==null;){if(K.callback===null)i(p);else if(K.startTime<=Y)i(p),K.sortIndex=K.expirationTime,e(h,K);else break;K=t(p)}}function F(Y){if(A=!1,D(Y),!E)if(t(h)!==null)E=!0,U||(U=!0,J());else{var K=t(p);K!==null&&ne(F,K.startTime-Y)}}var U=!1,k=-1,H=5,L=-1;function z(){return T?!0:!(n.unstable_now()-LY&&z());){var ge=y.callback;if(typeof ge=="function"){y.callback=null,b=y.priorityLevel;var xe=ge(y.expirationTime<=Y);if(Y=n.unstable_now(),typeof xe=="function"){y.callback=xe,D(Y),K=!0;break t}y===t(h)&&i(h),D(Y)}else i(h);y=t(h)}if(y!==null)K=!0;else{var q=t(p);q!==null&&ne(F,q.startTime-Y),K=!1}}break e}finally{y=null,b=ie,x=!1}K=void 0}}finally{K?J():U=!1}}}var J;if(typeof O=="function")J=function(){O(W)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,oe=$.port2;$.port1.onmessage=W,J=function(){oe.postMessage(null)}}else J=function(){M(W,0)};function ne(Y,K){k=M(function(){Y(n.unstable_now())},K)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(Y){Y.callback=null},n.unstable_forceFrameRate=function(Y){0>Y||125ge?(Y.sortIndex=ie,e(p,Y),t(h)===null&&Y===t(p)&&(A?(R(k),k=-1):A=!0,ne(F,ie-ge))):(Y.sortIndex=xe,e(h,Y),E||x||(E=!0,U||(U=!0,J()))),Y},n.unstable_shouldYield=z,n.unstable_wrapCallback=function(Y){var K=b;return function(){var ie=b;b=K;try{return Y.apply(this,arguments)}finally{b=ie}}}})(IS)),IS}var vw;function f3(){return vw||(vw=1,OS.exports=gL()),OS.exports}var PS={exports:{}},_a={};var yw;function vL(){if(yw)return _a;yw=1;var n=C0();function e(h){var p="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),PS.exports=vL(),PS.exports}var xw;function yL(){if(xw)return bg;xw=1;var n=f3(),e=C0(),t=d3();function i(a){var o="https://react.dev/errors/"+a;if(1xe||(a.current=ge[xe],ge[xe]=null,xe--)}function Se(a,o){xe++,ge[xe]=a.current,a.current=o}var Ge=q(null),Ye=q(null),ve=q(null),Oe=q(null);function it(a,o){switch(Se(ve,o),Se(Ye,a),Se(Ge,null),o.nodeType){case 9:case 11:a=(a=o.documentElement)&&(a=a.namespaceURI)?NT(a):0;break;default:if(a=o.tagName,o=o.namespaceURI)o=NT(o),a=UT(o,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}ce(Ge),Se(Ge,a)}function gt(){ce(Ge),ce(Ye),ce(ve)}function _t(a){a.memoizedState!==null&&Se(Oe,a);var o=Ge.current,d=UT(o,a.type);o!==d&&(Se(Ye,a),Se(Ge,d))}function jt(a){Ye.current===a&&(ce(Ge),ce(Ye)),Oe.current===a&&(ce(Oe),pg._currentValue=ie)}var pt,mt;function He(a){if(pt===void 0)try{throw Error()}catch(d){var o=d.stack.trim().match(/\n( *(at )?)/);pt=o&&o[1]||"",mt=-1)":-1S||se[m]!==Ce[S]){var We=` `+se[m].replace(" at new "," at ");return a.displayName&&We.includes("")&&(We=We.replace("",a.displayName)),We}while(1<=m&&0<=S);break}}}finally{Ue=!1,Error.prepareStackTrace=d}return(d=a?a.displayName||a.name:"")?He(d):""}function ft(a,o){switch(a.tag){case 26:case 27:case 5:return He(a.type);case 16:return He("Lazy");case 13:return a.child!==o&&o!==null?He("Suspense Fallback"):He("Suspense");case 19:return He("SuspenseList");case 0:case 15:return Re(a.type,!1);case 11:return Re(a.type.render,!1);case 1:return Re(a.type,!0);case 31:return He("Activity");default:return""}}function Z(a){try{var o="",d=null;do o+=ft(a,d),d=a,a=a.return;while(a);return o}catch(m){return` Error generating stack: `+m.message+` `+m.stack}}var At=Object.prototype.hasOwnProperty,dt=n.unstable_scheduleCallback,Ct=n.unstable_cancelCallback,tt=n.unstable_shouldYield,V=n.unstable_requestPaint,N=n.unstable_now,ee=n.unstable_getCurrentPriorityLevel,Ee=n.unstable_ImmediatePriority,Te=n.unstable_UserBlockingPriority,pe=n.unstable_NormalPriority,Et=n.unstable_LowPriority,$e=n.unstable_IdlePriority,lt=n.log,Lt=n.unstable_setDisableYieldValue,Ze=null,rt=null;function vt(a){if(typeof lt=="function"&&Lt(a),rt&&typeof rt.setStrictMode=="function")try{rt.setStrictMode(Ze,a)}catch{}}var te=Math.clz32?Math.clz32:re,be=Math.log,ct=Math.LN2;function re(a){return a>>>=0,a===0?32:31-(be(a)/ct|0)|0}var Pe=256,ze=262144,at=4194304;function je(a){var o=a&42;if(o!==0)return o;switch(a&-a){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 a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Ve(a,o,d){var m=a.pendingLanes;if(m===0)return 0;var S=0,w=a.suspendedLanes,B=a.pingedLanes;a=a.warmLanes;var j=m&134217727;return j!==0?(m=j&~w,m!==0?S=je(m):(B&=j,B!==0?S=je(B):d||(d=j&~a,d!==0&&(S=je(d))))):(j=m&~w,j!==0?S=je(j):B!==0?S=je(B):d||(d=m&~a,d!==0&&(S=je(d)))),S===0?0:o!==0&&o!==S&&(o&w)===0&&(w=S&-S,d=o&-o,w>=d||w===32&&(d&4194048)!==0)?o:S}function nt(a,o){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&o)===0}function It(a,o){switch(a){case 1:case 2:case 4:case 8:case 64:return o+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 o+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 an(){var a=at;return at<<=1,(at&62914560)===0&&(at=4194304),a}function sn(a){for(var o=[],d=0;31>d;d++)o.push(a);return o}function Vn(a,o){a.pendingLanes|=o,o!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function _i(a,o,d,m,S,w){var B=a.pendingLanes;a.pendingLanes=d,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=d,a.entangledLanes&=d,a.errorRecoveryDisabledLanes&=d,a.shellSuspendCounter=0;var j=a.entanglements,se=a.expirationTimes,Ce=a.hiddenUpdates;for(d=B&~d;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var Zt=/[\n"\\]/g;function Ut(a){return a.replace(Zt,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Sn(a,o,d,m,S,w,B,j){a.name="",B!=null&&typeof B!="function"&&typeof B!="symbol"&&typeof B!="boolean"?a.type=B:a.removeAttribute("type"),o!=null?B==="number"?(o===0&&a.value===""||a.value!=o)&&(a.value=""+ut(o)):a.value!==""+ut(o)&&(a.value=""+ut(o)):B!=="submit"&&B!=="reset"||a.removeAttribute("value"),o!=null?Tn(a,B,ut(o)):d!=null?Tn(a,B,ut(d)):m!=null&&a.removeAttribute("value"),S==null&&w!=null&&(a.defaultChecked=!!w),S!=null&&(a.checked=S&&typeof S!="function"&&typeof S!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?a.name=""+ut(j):a.removeAttribute("name")}function di(a,o,d,m,S,w,B,j){if(w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(a.type=w),o!=null||d!=null){if(!(w!=="submit"&&w!=="reset"||o!=null)){en(a);return}d=d!=null?""+ut(d):"",o=o!=null?""+ut(o):d,j||o===a.value||(a.value=o),a.defaultValue=o}m=m??S,m=typeof m!="function"&&typeof m!="symbol"&&!!m,a.checked=j?a.checked:!!m,a.defaultChecked=!!m,B!=null&&typeof B!="function"&&typeof B!="symbol"&&typeof B!="boolean"&&(a.name=B),en(a)}function Tn(a,o,d){o==="number"&&St(a.ownerDocument)===a||a.defaultValue===""+d||(a.defaultValue=""+d)}function oi(a,o,d,m){if(a=a.options,o){o={};for(var S=0;S"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kp=!1;if(Vs)try{var Hc={};Object.defineProperty(Hc,"passive",{get:function(){Kp=!0}}),window.addEventListener("test",Hc,Hc),window.removeEventListener("test",Hc,Hc)}catch{Kp=!1}var Ia=null,Bd=null,Wl=null;function lf(){if(Wl)return Wl;var a,o=Bd,d=o.length,m,S="value"in Ia?Ia.value:Ia.textContent,w=S.length;for(a=0;a=$c),uv=" ",hf=!1;function jd(a,o){switch(a){case"keyup":return cv.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rm(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var jl=!1;function fv(a,o){switch(a){case"compositionend":return rm(o);case"keypress":return o.which!==32?null:(hf=!0,uv);case"textInput":return a=o.data,a===uv&&hf?null:a;default:return null}}function am(a,o){if(jl)return a==="compositionend"||!$l&&jd(a,o)?(a=lf(),Wl=Bd=Ia=null,jl=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1=o)return{node:d,offset:o-a};a=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=gf(d)}}function pi(a,o){return a&&o?a===o?!0:a&&a.nodeType===3?!1:o&&o.nodeType===3?pi(a,o.parentNode):"contains"in a?a.contains(o):a.compareDocumentPosition?!!(a.compareDocumentPosition(o)&16):!1:!1}function gv(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var o=St(a.document);o instanceof a.HTMLIFrameElement;){try{var d=typeof o.contentWindow.location.href=="string"}catch{d=!1}if(d)a=o.contentWindow;else break;o=St(a.document)}return o}function hm(a){var o=a&&a.nodeName&&a.nodeName.toLowerCase();return o&&(o==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||o==="textarea"||a.contentEditable==="true")}var vv=Vs&&"documentMode"in document&&11>=document.documentMode,Ws=null,Xs=null,Zc=null,Yd=!1;function Kc(a,o,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Yd||Ws==null||Ws!==St(m)||(m=Ws,"selectionStart"in m&&hm(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),Zc&&qc(Zc,m)||(Zc=m,m=gy(Xs,"onSelect"),0>=B,S-=B,Pi=1<<32-te(o)+S|d<Mn?(kn=Ht,Ht=null):kn=Ht.sibling;var ei=Le(ye,Ht,we[Mn],qe);if(ei===null){Ht===null&&(Ht=kn);break}a&&Ht&&ei.alternate===null&&o(ye,Ht),fe=w(ei,fe,Mn),Jn===null?$t=ei:Jn.sibling=ei,Jn=ei,Ht=kn}if(Mn===we.length)return d(ye,Ht),Nn&&js(ye,Mn),$t;if(Ht===null){for(;MnMn?(kn=Ht,Ht=null):kn=Ht.sibling;var Cu=Le(ye,Ht,ei.value,qe);if(Cu===null){Ht===null&&(Ht=kn);break}a&&Ht&&Cu.alternate===null&&o(ye,Ht),fe=w(Cu,fe,Mn),Jn===null?$t=Cu:Jn.sibling=Cu,Jn=Cu,Ht=kn}if(ei.done)return d(ye,Ht),Nn&&js(ye,Mn),$t;if(Ht===null){for(;!ei.done;Mn++,ei=we.next())ei=et(ye,ei.value,qe),ei!==null&&(fe=w(ei,fe,Mn),Jn===null?$t=ei:Jn.sibling=ei,Jn=ei);return Nn&&js(ye,Mn),$t}for(Ht=m(Ht);!ei.done;Mn++,ei=we.next())ei=ke(Ht,ye,Mn,ei.value,qe),ei!==null&&(a&&ei.alternate!==null&&Ht.delete(ei.key===null?Mn:ei.key),fe=w(ei,fe,Mn),Jn===null?$t=ei:Jn.sibling=ei,Jn=ei);return a&&Ht.forEach(function(fL){return o(ye,fL)}),Nn&&js(ye,Mn),$t}function yi(ye,fe,we,qe){if(typeof we=="object"&&we!==null&&we.type===A&&we.key===null&&(we=we.props.children),typeof we=="object"&&we!==null){switch(we.$$typeof){case x:e:{for(var $t=we.key;fe!==null;){if(fe.key===$t){if($t=we.type,$t===A){if(fe.tag===7){d(ye,fe.sibling),qe=S(fe,we.props.children),qe.return=ye,ye=qe;break e}}else if(fe.elementType===$t||typeof $t=="object"&&$t!==null&&$t.$$typeof===H&&Ql($t)===fe.type){d(ye,fe.sibling),qe=S(fe,we.props),rs(qe,we),qe.return=ye,ye=qe;break e}d(ye,fe);break}else o(ye,fe);fe=fe.sibling}we.type===A?(qe=al(we.props.children,ye.mode,qe,we.key),qe.return=ye,ye=qe):(qe=$s(we.type,we.key,we.props,null,ye.mode,qe),rs(qe,we),qe.return=ye,ye=qe)}return B(ye);case E:e:{for($t=we.key;fe!==null;){if(fe.key===$t)if(fe.tag===4&&fe.stateNode.containerInfo===we.containerInfo&&fe.stateNode.implementation===we.implementation){d(ye,fe.sibling),qe=S(fe,we.children||[]),qe.return=ye,ye=qe;break e}else{d(ye,fe);break}else o(ye,fe);fe=fe.sibling}qe=eh(we,ye.mode,qe),qe.return=ye,ye=qe}return B(ye);case H:return we=Ql(we),yi(ye,fe,we,qe)}if(ne(we))return zt(ye,fe,we,qe);if(J(we)){if($t=J(we),typeof $t!="function")throw Error(i(150));return we=$t.call(we),tn(ye,fe,we,qe)}if(typeof we.then=="function")return yi(ye,fe,wf(we),qe);if(we.$$typeof===O)return yi(ye,fe,au(ye,we),qe);su(ye,we)}return typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint"?(we=""+we,fe!==null&&fe.tag===6?(d(ye,fe.sibling),qe=S(fe,we),qe.return=ye,ye=qe):(d(ye,fe),qe=Jd(we,ye.mode,qe),qe.return=ye,ye=qe),B(ye)):d(ye,fe)}return function(ye,fe,we,qe){try{nc=0;var $t=yi(ye,fe,we,qe);return tc=null,$t}catch(Ht){if(Ht===Kl||Ht===yn)throw Ht;var Jn=Ii(29,Ht,null,ye.mode);return Jn.lanes=qe,Jn.return=ye,Jn}}}var Co=uh(!0),fh=uh(!1),ta=!1;function Af(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Mm(a,o){a=a.updateQueue,o.updateQueue===a&&(o.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function Ro(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function dl(a,o,d){var m=a.updateQueue;if(m===null)return null;if(m=m.shared,(Vt&2)!==0){var S=m.pending;return S===null?o.next=o:(o.next=S.next,S.next=o),m.pending=o,o=ns(a),il(a,null,d),o}return Sr(a,m,o,d),ns(a)}function hl(a,o,d){if(o=o.updateQueue,o!==null&&(o=o.shared,(d&4194048)!==0)){var m=o.lanes;m&=a.pendingLanes,d|=m,o.lanes=d,Ka(a,d)}}function Xt(a,o){var d=a.updateQueue,m=a.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var S=null,w=null;if(d=d.firstBaseUpdate,d!==null){do{var B={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};w===null?S=w=B:w=w.next=B,d=d.next}while(d!==null);w===null?S=w=o:w=w.next=o}else S=w=o;d={baseState:m.baseState,firstBaseUpdate:S,lastBaseUpdate:w,shared:m.shared,callbacks:m.callbacks},a.updateQueue=d;return}a=d.lastBaseUpdate,a===null?d.firstBaseUpdate=o:a.next=o,d.lastBaseUpdate=o}var Em=!1;function Cf(){if(Em){var a=is;if(a!==null)throw a}}function ou(a,o,d,m){Em=!1;var S=a.updateQueue;ta=!1;var w=S.firstBaseUpdate,B=S.lastBaseUpdate,j=S.shared.pending;if(j!==null){S.shared.pending=null;var se=j,Ce=se.next;se.next=null,B===null?w=Ce:B.next=Ce,B=se;var We=a.alternate;We!==null&&(We=We.updateQueue,j=We.lastBaseUpdate,j!==B&&(j===null?We.firstBaseUpdate=Ce:j.next=Ce,We.lastBaseUpdate=se))}if(w!==null){var et=S.baseState;B=0,We=Ce=se=null,j=w;do{var Le=j.lane&-536870913,ke=Le!==j.lane;if(ke?(gn&Le)===Le:(m&Le)===Le){Le!==0&&Le===Ao&&(Em=!0),We!==null&&(We=We.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var zt=a,tn=j;Le=o;var yi=d;switch(tn.tag){case 1:if(zt=tn.payload,typeof zt=="function"){et=zt.call(yi,et,Le);break e}et=zt;break e;case 3:zt.flags=zt.flags&-65537|128;case 0:if(zt=tn.payload,Le=typeof zt=="function"?zt.call(yi,et,Le):zt,Le==null)break e;et=y({},et,Le);break e;case 2:ta=!0}}Le=j.callback,Le!==null&&(a.flags|=64,ke&&(a.flags|=8192),ke=S.callbacks,ke===null?S.callbacks=[Le]:ke.push(Le))}else ke={lane:Le,tag:j.tag,payload:j.payload,callback:j.callback,next:null},We===null?(Ce=We=ke,se=et):We=We.next=ke,B|=Le;if(j=j.next,j===null){if(j=S.shared.pending,j===null)break;ke=j,j=ke.next,ke.next=null,S.lastBaseUpdate=ke,S.shared.pending=null}}while(!0);We===null&&(se=et),S.baseState=se,S.firstBaseUpdate=Ce,S.lastBaseUpdate=We,w===null&&(S.shared.lanes=0),oo|=B,a.lanes=B,a.memoizedState=et}}function lu(a,o){if(typeof a!="function")throw Error(i(191,a));a.call(o)}function wv(a,o){var d=a.callbacks;if(d!==null)for(a.callbacks=null,a=0;aw?w:8;var B=Y.T,j={};Y.T=j,jm(a,!1,o,d);try{var se=S(),Ce=Y.S;if(Ce!==null&&Ce(j,se),se!==null&&typeof se=="object"&&typeof se.then=="function"){var We=_m(se,m);If(a,o,We,Ha(a))}else If(a,o,m,Ha(a))}catch(et){If(a,o,{then:function(){},status:"rejected",reason:et},Ha())}finally{K.p=w,B!==null&&j.types!==null&&(B.types=j.types),Y.T=B}}function tS(){}function Xm(a,o,d,m){if(a.tag!==5)throw Error(i(476));var S=Jv(a).queue;Qv(a,S,o,ie,d===null?tS:function(){return ey(a),d(m)})}function Jv(a){var o=a.memoizedState;if(o!==null)return o;o={memoizedState:ie,baseState:ie,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:ie},next:null};var d={};return o.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:d},next:null},a.memoizedState=o,a=a.alternate,a!==null&&(a.memoizedState=o),o}function ey(a){var o=Jv(a);o.next===null&&(o=a.alternate.memoizedState),If(a,o.next.queue,{},Ha())}function $m(){return nn(pg)}function ty(){return Yi().memoizedState}function ny(){return Yi().memoizedState}function nS(a){for(var o=a.return;o!==null;){switch(o.tag){case 24:case 3:var d=Ha();a=Ro(d);var m=dl(o,a,d);m!==null&&(xn(m,o,d),hl(m,o,d)),o={cache:ym()},a.payload=o;return}o=o.return}}function iS(a,o,d){var m=Ha();d={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},xh(a)?ry(o,d):(d=Kd(a,o,d,m),d!==null&&(xn(d,a,m),ay(d,o,m)))}function iy(a,o,d){var m=Ha();If(a,o,d,m)}function If(a,o,d,m){var S={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(xh(a))ry(o,S);else{var w=a.alternate;if(a.lanes===0&&(w===null||w.lanes===0)&&(w=o.lastRenderedReducer,w!==null))try{var B=o.lastRenderedState,j=w(B,d);if(S.hasEagerState=!0,S.eagerState=j,Jr(j,B))return Sr(a,o,S,0),cn===null&&_f(),!1}catch{}if(d=Kd(a,o,S,m),d!==null)return xn(d,a,m),ay(d,o,m),!0}return!1}function jm(a,o,d,m){if(m={lane:2,revertLane:Ne(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},xh(a)){if(o)throw Error(i(479))}else o=Kd(a,d,m,2),o!==null&&xn(o,a,2)}function xh(a){var o=a.alternate;return a===hn||o!==null&&o===hn}function ry(a,o){uu=as=!0;var d=a.pending;d===null?o.next=o:(o.next=d.next,d.next=o),a.pending=o}function ay(a,o,d){if((d&4194048)!==0){var m=o.lanes;m&=a.pendingLanes,d|=m,o.lanes=d,Ka(a,d)}}var du={readContext:nn,use:pl,useCallback:Li,useContext:Li,useEffect:Li,useImperativeHandle:Li,useLayoutEffect:Li,useInsertionEffect:Li,useMemo:Li,useReducer:Li,useRef:Li,useState:Li,useDebugValue:Li,useDeferredValue:Li,useTransition:Li,useSyncExternalStore:Li,useId:Li,useHostTransitionStatus:Li,useFormState:Li,useActionState:Li,useOptimistic:Li,useMemoCache:Li,useCacheRefresh:Li};du.useEffectEvent=Li;var sy={readContext:nn,use:pl,useCallback:function(a,o){return pr().memoizedState=[a,o===void 0?null:o],a},useContext:nn,useEffect:Vv,useImperativeHandle:function(a,o,d){d=d!=null?d.concat([a]):null,yh(4194308,4,jv.bind(null,o,a),d)},useLayoutEffect:function(a,o){return yh(4194308,4,a,o)},useInsertionEffect:function(a,o){yh(4,2,a,o)},useMemo:function(a,o){var d=pr();o=o===void 0?null:o;var m=a();if(ic){vt(!0);try{a()}finally{vt(!1)}}return d.memoizedState=[m,o],m},useReducer:function(a,o,d){var m=pr();if(d!==void 0){var S=d(o);if(ic){vt(!0);try{d(o)}finally{vt(!1)}}}else S=o;return m.memoizedState=m.baseState=S,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:S},m.queue=a,a=a.dispatch=iS.bind(null,hn,a),[m.memoizedState,a]},useRef:function(a){var o=pr();return a={current:a},o.memoizedState=a},useState:function(a){a=Nm(a);var o=a.queue,d=iy.bind(null,hn,o);return o.dispatch=d,[a.memoizedState,d]},useDebugValue:Gm,useDeferredValue:function(a,o){var d=pr();return Wm(d,a,o)},useTransition:function(){var a=Nm(!1);return a=Qv.bind(null,hn,a.queue,!0,!1),pr().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,o,d){var m=hn,S=pr();if(Nn){if(d===void 0)throw Error(i(407));d=d()}else{if(d=o(),cn===null)throw Error(i(349));(gn&127)!==0||Ov(m,o,d)}S.memoizedState=d;var w={value:d,getSnapshot:o};return S.queue=w,Vv(Pv.bind(null,m,w,a),[a]),m.flags|=2048,ml(9,{destroy:void 0},Iv.bind(null,m,w,d,o),null),d},useId:function(){var a=pr(),o=cn.identifierPrefix;if(Nn){var d=Ts,m=Pi;d=(m&~(1<<32-te(m)-1)).toString(32)+d,o="_"+o+"R_"+d,d=hh++,0<\/script>",w=w.removeChild(w.firstChild);break;case"select":w=typeof m.is=="string"?B.createElement("select",{is:m.is}):B.createElement("select"),m.multiple?w.multiple=!0:m.size&&(w.size=m.size);break;default:w=typeof m.is=="string"?B.createElement(S,{is:m.is}):B.createElement(S)}}w[Si]=o,w[ji]=m;e:for(B=o.child;B!==null;){if(B.tag===5||B.tag===6)w.appendChild(B.stateNode);else if(B.tag!==4&&B.tag!==27&&B.child!==null){B.child.return=B,B=B.child;continue}if(B===o)break e;for(;B.sibling===null;){if(B.return===null||B.return===o)break e;B=B.return}B.sibling.return=B.return,B=B.sibling}o.stateNode=w;e:switch(oa(w,S,m),S){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&no(o)}}return ci(o),Uf(o,o.type,a===null?null:a.memoizedProps,o.pendingProps,d),null;case 6:if(a&&o.stateNode!=null)a.memoizedProps!==m&&no(o);else{if(typeof m!="string"&&o.stateNode===null)throw Error(i(166));if(a=ve.current,iu(o)){if(a=o.stateNode,d=o.memoizedProps,m=null,S=Vi,S!==null)switch(S.tag){case 27:case 5:m=S.memoizedProps}a[Si]=o,a=!!(a.nodeValue===d||m!==null&&m.suppressHydrationWarning===!0||PT(a.nodeValue,d)),a||Ys(o,!0)}else a=vy(a).createTextNode(m),a[Si]=o,o.stateNode=a}return ci(o),null;case 31:if(d=o.memoizedState,a===null||a.memoizedState!==null){if(m=iu(o),d!==null){if(a===null){if(!m)throw Error(i(318));if(a=o.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(557));a[Si]=o}else ll(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;ci(o),a=!1}else d=ih(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=d),a=!0;if(!a)return o.flags&256?(qi(o),o):(qi(o),null);if((o.flags&128)!==0)throw Error(i(558))}return ci(o),null;case 13:if(m=o.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(S=iu(o),m!==null&&m.dehydrated!==null){if(a===null){if(!S)throw Error(i(318));if(S=o.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(i(317));S[Si]=o}else ll(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;ci(o),S=!1}else S=ih(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=S),S=!0;if(!S)return o.flags&256?(qi(o),o):(qi(o),null)}return qi(o),(o.flags&128)!==0?(o.lanes=d,o):(d=m!==null,a=a!==null&&a.memoizedState!==null,d&&(m=o.child,S=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(S=m.alternate.memoizedState.cachePool.pool),w=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(w=m.memoizedState.cachePool.pool),w!==S&&(m.flags|=2048)),d!==a&&d&&(o.child.flags|=8192),Io(o,o.updateQueue),ci(o),null);case 4:return gt(),a===null&&lS(o.stateNode.containerInfo),ci(o),null;case 10:return Qs(o.type),ci(o),null;case 19:if(ce(Un),m=o.memoizedState,m===null)return ci(o),null;if(S=(o.flags&128)!==0,w=m.rendering,w===null)if(S)io(m,!1);else{if(Ni!==0||a!==null&&(a.flags&128)!==0)for(a=o.child;a!==null;){if(w=Ua(a),w!==null){for(o.flags|=128,io(m,!1),a=w.updateQueue,o.updateQueue=a,Io(o,a),o.subtreeFlags=0,a=d,d=o.child;d!==null;)Qc(d,a),d=d.sibling;return Se(Un,Un.current&1|2),Nn&&js(o,m.treeForkCount),o.child}a=a.sibling}m.tail!==null&&N()>Ki&&(o.flags|=128,S=!0,io(m,!1),o.lanes=4194304)}else{if(!S)if(a=Ua(w),a!==null){if(o.flags|=128,S=!0,a=a.updateQueue,o.updateQueue=a,Io(o,a),io(m,!0),m.tail===null&&m.tailMode==="hidden"&&!w.alternate&&!Nn)return ci(o),null}else 2*N()-m.renderingStartTime>Ki&&d!==536870912&&(o.flags|=128,S=!0,io(m,!1),o.lanes=4194304);m.isBackwards?(w.sibling=o.child,o.child=w):(a=m.last,a!==null?a.sibling=w:o.child=w,m.last=w)}return m.tail!==null?(a=m.tail,m.rendering=a,m.tail=a.sibling,m.renderingStartTime=N(),a.sibling=null,d=Un.current,Se(Un,S?d&1|2:d&1),Nn&&js(o,m.treeForkCount),a):(ci(o),null);case 22:case 23:return qi(o),Rf(),m=o.memoizedState!==null,a!==null?a.memoizedState!==null!==m&&(o.flags|=8192):m&&(o.flags|=8192),m?(d&536870912)!==0&&(o.flags&128)===0&&(ci(o),o.subtreeFlags&6&&(o.flags|=8192)):ci(o),d=o.updateQueue,d!==null&&Io(o,d.retryQueue),d=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),m=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(m=o.memoizedState.cachePool.pool),m!==d&&(o.flags|=2048),a!==null&&ce(fl),null;case 24:return d=null,a!==null&&(d=a.memoizedState.cache),o.memoizedState.cache!==d&&(o.flags|=2048),Qs(sr),ci(o),null;case 25:return null;case 30:return null}throw Error(i(156,o.tag))}function os(a,o){switch(th(o),o.tag){case 1:return a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 3:return Qs(sr),gt(),a=o.flags,(a&65536)!==0&&(a&128)===0?(o.flags=a&-65537|128,o):null;case 26:case 27:case 5:return jt(o),null;case 31:if(o.memoizedState!==null){if(qi(o),o.alternate===null)throw Error(i(340));ll()}return a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 13:if(qi(o),a=o.memoizedState,a!==null&&a.dehydrated!==null){if(o.alternate===null)throw Error(i(340));ll()}return a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 19:return ce(Un),null;case 4:return gt(),null;case 10:return Qs(o.type),null;case 22:case 23:return qi(o),Rf(),a!==null&&ce(fl),a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 24:return Qs(sr),null;case 25:return null;default:return null}}function za(a,o){switch(th(o),o.tag){case 3:Qs(sr),gt();break;case 26:case 27:case 5:jt(o);break;case 4:gt();break;case 31:o.memoizedState!==null&&qi(o);break;case 13:qi(o);break;case 19:ce(Un);break;case 10:Qs(o.type);break;case 22:case 23:qi(o),Rf(),a!==null&&ce(fl);break;case 24:Qs(sr)}}function ls(a,o){try{var d=o.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var S=m.next;d=S;do{if((d.tag&a)===a){m=void 0;var w=d.create,B=d.inst;m=w(),B.destroy=m}d=d.next}while(d!==S)}}catch(j){Wn(o,o.return,j)}}function Dr(a,o,d){try{var m=o.updateQueue,S=m!==null?m.lastEffect:null;if(S!==null){var w=S.next;m=w;do{if((m.tag&a)===a){var B=m.inst,j=B.destroy;if(j!==void 0){B.destroy=void 0,S=o;var se=d,Ce=j;try{Ce()}catch(We){Wn(S,se,We)}}}m=m.next}while(m!==w)}}catch(We){Wn(o,o.return,We)}}function ws(a){var o=a.updateQueue;if(o!==null){var d=a.stateNode;try{wv(o,d)}catch(m){Wn(a,a.return,m)}}}function Er(a,o,d){d.props=gl(a.type,a.memoizedProps),d.state=a.memoizedState;try{d.componentWillUnmount()}catch(m){Wn(a,o,m)}}function Po(a,o){try{var d=a.ref;if(d!==null){switch(a.tag){case 26:case 27:case 5:var m=a.stateNode;break;case 30:m=a.stateNode;break;default:m=a.stateNode}typeof d=="function"?a.refCleanup=d(m):d.current=m}}catch(S){Wn(a,o,S)}}function Or(a,o){var d=a.ref,m=a.refCleanup;if(d!==null)if(typeof m=="function")try{m()}catch(S){Wn(a,o,S)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(S){Wn(a,o,S)}else d.current=null}function Ff(a){var o=a.type,d=a.memoizedProps,m=a.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":d.autoFocus&&m.focus();break e;case"img":d.src?m.src=d.src:d.srcSet&&(m.srcset=d.srcSet)}}catch(S){Wn(a,a.return,S)}}function gr(a,o,d){try{var m=a.stateNode;NP(m,a.type,d,o),m[ji]=o}catch(S){Wn(a,a.return,S)}}function Ai(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&Mu(a.type)||a.tag===4}function In(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Ai(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&Mu(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function ro(a,o,d){var m=a.tag;if(m===5||m===6)a=a.stateNode,o?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(a,o):(o=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,o.appendChild(a),d=d._reactRootContainer,d!=null||o.onclick!==null||(o.onclick=_o));else if(m!==4&&(m===27&&Mu(a.type)&&(d=a.stateNode,o=null),a=a.child,a!==null))for(ro(a,o,d),a=a.sibling;a!==null;)ro(a,o,d),a=a.sibling}function ia(a,o,d){var m=a.tag;if(m===5||m===6)a=a.stateNode,o?d.insertBefore(a,o):d.appendChild(a);else if(m!==4&&(m===27&&Mu(a.type)&&(d=a.stateNode),a=a.child,a!==null))for(ia(a,o,d),a=a.sibling;a!==null;)ia(a,o,d),a=a.sibling}function Ih(a){var o=a.stateNode,d=a.memoizedProps;try{for(var m=a.type,S=o.attributes;S.length;)o.removeAttributeNode(S[0]);oa(o,m,d),o[Si]=a,o[ji]=d}catch(w){Wn(a,a.return,w)}}var cs=!1,gi=!1,As=!1,py=typeof WeakSet=="function"?WeakSet:Set,Tr=null;function aS(a,o){if(a=a.containerInfo,fS=Ey,a=gv(a),hm(a)){if("selectionStart"in a)var d={start:a.selectionStart,end:a.selectionEnd};else e:{d=(d=a.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var S=m.anchorOffset,w=m.focusNode;m=m.focusOffset;try{d.nodeType,w.nodeType}catch{d=null;break e}var B=0,j=-1,se=-1,Ce=0,We=0,et=a,Le=null;t:for(;;){for(var ke;et!==d||S!==0&&et.nodeType!==3||(j=B+S),et!==w||m!==0&&et.nodeType!==3||(se=B+m),et.nodeType===3&&(B+=et.nodeValue.length),(ke=et.firstChild)!==null;)Le=et,et=ke;for(;;){if(et===a)break t;if(Le===d&&++Ce===S&&(j=B),Le===w&&++We===m&&(se=B),(ke=et.nextSibling)!==null)break;et=Le,Le=et.parentNode}et=ke}d=j===-1||se===-1?null:{start:j,end:se}}else d=null}d=d||{start:0,end:0}}else d=null;for(dS={focusedElem:a,selectionRange:d},Ey=!1,Tr=o;Tr!==null;)if(o=Tr,a=o.child,(o.subtreeFlags&1028)!==0&&a!==null)a.return=o,Tr=a;else for(;Tr!==null;){switch(o=Tr,w=o.alternate,a=o.flags,o.tag){case 0:if((a&4)!==0&&(a=o.updateQueue,a=a!==null?a.events:null,a!==null))for(d=0;d title"))),oa(w,m,d),w[Si]=a,G(w),m=w;break e;case"link":var B=ZT("link","href",S).get(m+(d.href||""));if(B){for(var j=0;jyi&&(B=yi,yi=tn,tn=B);var ye=Yc(j,tn),fe=Yc(j,yi);if(ye&&fe&&(ke.rangeCount!==1||ke.anchorNode!==ye.node||ke.anchorOffset!==ye.offset||ke.focusNode!==fe.node||ke.focusOffset!==fe.offset)){var we=et.createRange();we.setStart(ye.node,ye.offset),ke.removeAllRanges(),tn>yi?(ke.addRange(we),ke.extend(fe.node,fe.offset)):(we.setEnd(fe.node,fe.offset),ke.addRange(we))}}}}for(et=[],ke=j;ke=ke.parentNode;)ke.nodeType===1&&et.push({element:ke,left:ke.scrollLeft,top:ke.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;jd?32:d,Y.T=null,d=yu,yu=null;var w=ka,B=ps;if(ii=0,gu=ka=null,ps=0,(Vt&6)!==0)throw Error(i(331));var j=Vt;if(Vt|=4,ya(w.current),sg(w,w.current,B,d),Vt=j,Ot(0,!1),rt&&typeof rt.onPostCommitFiberRoot=="function")try{rt.onPostCommitFiberRoot(Ze,w)}catch{}return!0}finally{K.p=S,Y.T=m,co(a,o)}}function cg(a,o,d){o=Pa(d,o),o=Jm(a.stateNode,o,2),a=dl(a,o,2),a!==null&&(Vn(a,2),ht(a))}function Wn(a,o,d){if(a.tag===3)cg(a,a,d);else for(;o!==null;){if(o.tag===3){cg(o,a,d);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Qi===null||!Qi.has(m))){a=Pa(d,a),d=eg(2),m=dl(o,d,2),m!==null&&(cy(d,m,o,a),Vn(m,2),ht(m));break}}o=o.return}}function Xf(a,o,d){var m=a.pingCache;if(m===null){m=a.pingCache=new pn;var S=new Set;m.set(o,S)}else S=m.get(o),S===void 0&&(S=new Set,m.set(o,S));S.has(d)||(og=!0,S.add(d),a=c.bind(null,a,o,d),o.then(a,a))}function c(a,o,d){var m=a.pingCache;m!==null&&m.delete(o),a.pingedLanes|=a.suspendedLanes&d,a.warmLanes&=~d,cn===a&&(gn&d)===d&&(Ni===4||Ni===3&&(gn&62914560)===gn&&300>N()-mu?(Vt&2)===0&&El(a,0):kf|=d,Mi===gn&&(Mi=0)),ht(a)}function f(a,o){o===0&&(o=an()),a=ea(a,o),a!==null&&(Vn(a,o),ht(a))}function v(a){var o=a.memoizedState,d=0;o!==null&&(d=o.retryLane),f(a,d)}function _(a,o){var d=0;switch(a.tag){case 31:case 13:var m=a.stateNode,S=a.memoizedState;S!==null&&(d=S.retryLane);break;case 19:m=a.stateNode;break;case 22:m=a.stateNode._retryCache;break;default:throw Error(i(314))}m!==null&&m.delete(o),f(a,d)}function C(a,o){return dt(a,o)}var I=null,X=null,le=!1,Fe=!1,st=!1,Tt=0;function ht(a){a!==X&&a.next===null&&(X===null?I=X=a:X=X.next=a),Fe=!0,le||(le=!0,_e())}function Ot(a,o){if(!st&&Fe){st=!0;do for(var d=!1,m=I;m!==null;){if(a!==0){var S=m.pendingLanes;if(S===0)var w=0;else{var B=m.suspendedLanes,j=m.pingedLanes;w=(1<<31-te(42|a)+1)-1,w&=S&~(B&~j),w=w&201326741?w&201326741|1:w?w|2:0}w!==0&&(d=!0,De(m,w))}else w=gn,w=Ve(m,m===cn?w:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(w&3)===0||nt(m,w)||(d=!0,De(m,w));m=m.next}while(d);st=!1}}function fn(){Ji()}function Ji(){Fe=le=!1;var a=0;Tt!==0&&zP()&&(a=Tt);for(var o=N(),d=null,m=I;m!==null;){var S=m.next,w=Su(m,o);w===0?(m.next=null,d===null?I=S:d.next=S,S===null&&(X=d)):(d=m,(a!==0||(w&3)!==0)&&(Fe=!0)),m=S}ii!==0&&ii!==5||Ot(a),Tt!==0&&(Tt=0)}function Su(a,o){for(var d=a.suspendedLanes,m=a.pingedLanes,S=a.expirationTimes,w=a.pendingLanes&-62914561;0j)break;var We=se.transferSize,et=se.initiatorType;We&<(et)&&(se=se.responseEnd,B+=We*(se"u"?null:document;function $T(a,o,d){var m=Fh;if(m&&typeof o=="string"&&o){var S=Ut(o);S='link[rel="'+a+'"][href="'+S+'"]',typeof d=="string"&&(S+='[crossorigin="'+d+'"]'),XT.has(S)||(XT.add(S),a={rel:a,crossOrigin:d,href:o},m.querySelector(S)===null&&(o=m.createElement("link"),oa(o,"link",a),G(o),m.head.appendChild(o)))}}function $P(a){vc.D(a),$T("dns-prefetch",a,null)}function jP(a,o){vc.C(a,o),$T("preconnect",a,o)}function qP(a,o,d){vc.L(a,o,d);var m=Fh;if(m&&a&&o){var S='link[rel="preload"][as="'+Ut(o)+'"]';o==="image"&&d&&d.imageSrcSet?(S+='[imagesrcset="'+Ut(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(S+='[imagesizes="'+Ut(d.imageSizes)+'"]')):S+='[href="'+Ut(a)+'"]';var w=S;switch(o){case"style":w=Bh(a);break;case"script":w=kh(a)}fo.has(w)||(a=y({rel:"preload",href:o==="image"&&d&&d.imageSrcSet?void 0:a,as:o},d),fo.set(w,a),m.querySelector(S)!==null||o==="style"&&m.querySelector(dg(w))||o==="script"&&m.querySelector(hg(w))||(o=m.createElement("link"),oa(o,"link",a),G(o),m.head.appendChild(o)))}}function YP(a,o){vc.m(a,o);var d=Fh;if(d&&a){var m=o&&typeof o.as=="string"?o.as:"script",S='link[rel="modulepreload"][as="'+Ut(m)+'"][href="'+Ut(a)+'"]',w=S;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":w=kh(a)}if(!fo.has(w)&&(a=y({rel:"modulepreload",href:a},o),fo.set(w,a),d.querySelector(S)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(hg(w)))return}m=d.createElement("link"),oa(m,"link",a),G(m),d.head.appendChild(m)}}}function ZP(a,o,d){vc.S(a,o,d);var m=Fh;if(m&&a){var S=ki(m).hoistableStyles,w=Bh(a);o=o||"default";var B=S.get(w);if(!B){var j={loading:0,preload:null};if(B=m.querySelector(dg(w)))j.loading=5;else{a=y({rel:"stylesheet",href:a,"data-precedence":o},d),(d=fo.get(w))&&bS(a,d);var se=B=m.createElement("link");G(se),oa(se,"link",a),se._p=new Promise(function(Ce,We){se.onload=Ce,se.onerror=We}),se.addEventListener("load",function(){j.loading|=1}),se.addEventListener("error",function(){j.loading|=2}),j.loading|=4,by(B,o,m)}B={type:"stylesheet",instance:B,count:1,state:j},S.set(w,B)}}}function KP(a,o){vc.X(a,o);var d=Fh;if(d&&a){var m=ki(d).hoistableScripts,S=kh(a),w=m.get(S);w||(w=d.querySelector(hg(S)),w||(a=y({src:a,async:!0},o),(o=fo.get(S))&&xS(a,o),w=d.createElement("script"),G(w),oa(w,"link",a),d.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},m.set(S,w))}}function QP(a,o){vc.M(a,o);var d=Fh;if(d&&a){var m=ki(d).hoistableScripts,S=kh(a),w=m.get(S);w||(w=d.querySelector(hg(S)),w||(a=y({src:a,async:!0,type:"module"},o),(o=fo.get(S))&&xS(a,o),w=d.createElement("script"),G(w),oa(w,"link",a),d.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},m.set(S,w))}}function jT(a,o,d,m){var S=(S=ve.current)?yy(S):null;if(!S)throw Error(i(446));switch(a){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(o=Bh(d.href),d=ki(S).hoistableStyles,m=d.get(o),m||(m={type:"style",instance:null,count:0,state:null},d.set(o,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){a=Bh(d.href);var w=ki(S).hoistableStyles,B=w.get(a);if(B||(S=S.ownerDocument||S,B={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},w.set(a,B),(w=S.querySelector(dg(a)))&&!w._p&&(B.instance=w,B.state.loading=5),fo.has(a)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},fo.set(a,d),w||JP(S,a,d,B.state))),o&&m===null)throw Error(i(528,""));return B}if(o&&m!==null)throw Error(i(529,""));return null;case"script":return o=d.async,d=d.src,typeof d=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=kh(d),d=ki(S).hoistableScripts,m=d.get(o),m||(m={type:"script",instance:null,count:0,state:null},d.set(o,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,a))}}function Bh(a){return'href="'+Ut(a)+'"'}function dg(a){return'link[rel="stylesheet"]['+a+"]"}function qT(a){return y({},a,{"data-precedence":a.precedence,precedence:null})}function JP(a,o,d,m){a.querySelector('link[rel="preload"][as="style"]['+o+"]")?m.loading=1:(o=a.createElement("link"),m.preload=o,o.addEventListener("load",function(){return m.loading|=1}),o.addEventListener("error",function(){return m.loading|=2}),oa(o,"link",d),G(o),a.head.appendChild(o))}function kh(a){return'[src="'+Ut(a)+'"]'}function hg(a){return"script[async]"+a}function YT(a,o,d){if(o.count++,o.instance===null)switch(o.type){case"style":var m=a.querySelector('style[data-href~="'+Ut(d.href)+'"]');if(m)return o.instance=m,G(m),m;var S=y({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return m=(a.ownerDocument||a).createElement("style"),G(m),oa(m,"style",S),by(m,d.precedence,a),o.instance=m;case"stylesheet":S=Bh(d.href);var w=a.querySelector(dg(S));if(w)return o.state.loading|=4,o.instance=w,G(w),w;m=qT(d),(S=fo.get(S))&&bS(m,S),w=(a.ownerDocument||a).createElement("link"),G(w);var B=w;return B._p=new Promise(function(j,se){B.onload=j,B.onerror=se}),oa(w,"link",m),o.state.loading|=4,by(w,d.precedence,a),o.instance=w;case"script":return w=kh(d.src),(S=a.querySelector(hg(w)))?(o.instance=S,G(S),S):(m=d,(S=fo.get(w))&&(m=y({},d),xS(m,S)),a=a.ownerDocument||a,S=a.createElement("script"),G(S),oa(S,"link",m),a.head.appendChild(S),o.instance=S);case"void":return null;default:throw Error(i(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(m=o.instance,o.state.loading|=4,by(m,d.precedence,a));return o.instance}function by(a,o,d){for(var m=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),S=m.length?m[m.length-1]:null,w=S,B=0;B title"):null)}function eL(a,o,d){if(d===1||o.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;return o.rel==="stylesheet"?(a=o.disabled,typeof o.precedence=="string"&&a==null):!0;case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function QT(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function tL(a,o,d,m){if(d.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var S=Bh(m.href),w=o.querySelector(dg(S));if(w){o=w._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(a.count++,a=_y.bind(a),o.then(a,a)),d.state.loading|=4,d.instance=w,G(w);return}w=o.ownerDocument||o,m=qT(m),(S=fo.get(S))&&bS(m,S),w=w.createElement("link"),G(w);var B=w;B._p=new Promise(function(j,se){B.onload=j,B.onerror=se}),oa(w,"link",m),d.instance=w}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(d,o),(o=d.state.preload)&&(d.state.loading&3)===0&&(a.count++,d=_y.bind(a),o.addEventListener("load",d),o.addEventListener("error",d))}}var _S=0;function nL(a,o){return a.stylesheets&&a.count===0&&My(a,a.stylesheets),0_S?50:800)+o);return a.unsuspend=d,function(){a.unsuspend=null,clearTimeout(m),clearTimeout(S)}}:null}function _y(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)My(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Sy=null;function My(a,o){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Sy=new Map,o.forEach(iL,a),Sy=null,_y.call(a))}function iL(a,o){if(!(o.state.loading&4)){var d=Sy.get(a);if(d)var m=d.get(null);else{d=new Map,Sy.set(a,d);for(var S=a.querySelectorAll("link[data-precedence],style[data-precedence]"),w=0;w"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),DS.exports=yL(),DS.exports}var h3=bL(),Jx=d3();const xL=ef(Jx);const Rd="182",od={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ld={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},p3=0,dM=1,m3=2,_L=3,g3=0,_p=1,Xg=2,fd=3,Nl=0,Lr=1,Bi=2,$r=0,gd=1,kb=2,hM=3,pM=4,e_=5,Ac=100,v3=101,y3=102,b3=103,oE=104,x3=200,Bu=201,_3=202,lE=203,Hb=204,Tp=205,S3=206,M3=207,cE=208,E3=209,T3=210,w3=211,A3=212,C3=213,R3=214,Vb=0,a0=1,Gb=2,_d=3,Wb=4,Xb=5,$b=6,jb=7,R0=0,D3=1,O3=2,Us=0,uE=1,fE=2,dE=3,t_=4,hE=5,pE=6,mE=7,mM="attached",I3="detached",n_=300,Ul=301,Xu=302,s0=303,o0=304,Fp=306,l0=1e3,_s=1001,c0=1002,jn=1003,gE=1004,SL=1004,vp=1005,ML=1005,Kn=1006,$g=1007,EL=1007,$o=1008,TL=1008,fr=1009,vE=1010,yE=1011,wp=1012,i_=1013,Bs=1014,xr=1015,vo=1016,r_=1017,a_=1018,Sd=1020,bE=35902,xE=35899,_E=1021,SE=1022,ca=1023,zl=1026,Dc=1027,Hu=1028,D0=1029,Md=1030,s_=1031,wL=1032,o_=1033,jg=33776,qg=33777,Yg=33778,Zg=33779,qb=35840,Yb=35841,Zb=35842,Kb=35843,Qb=36196,Jb=37492,ex=37496,tx=37488,nx=37489,ix=37490,rx=37491,ax=37808,sx=37809,ox=37810,lx=37811,cx=37812,ux=37813,fx=37814,dx=37815,hx=37816,px=37817,mx=37818,gx=37819,vx=37820,yx=37821,bx=36492,xx=36494,_x=36495,Sx=36283,Mx=36284,Ex=36285,Tx=36286,P3=2200,L3=2201,N3=2202,u0=2300,wx=2301,Pb=2302,dd=2400,hd=2401,f0=2402,l_=2500,ME=2501,AL=0,CL=1,RL=2,tf=3200,DL=3201,OL=3202,IL=3203,nf=0,U3=1,Xo="",Zn="srgb",Fl="srgb-linear",d0="linear",ui="srgb",PL="",LL="rg",NL="ga",UL=0,cd=7680,zL=7681,FL=7682,BL=7683,kL=34055,HL=34056,VL=5386,GL=512,WL=513,XL=514,$L=515,jL=516,qL=517,YL=518,gM=519,z3=512,F3=513,B3=514,c_=515,k3=516,H3=517,u_=518,V3=519,h0=35044,ZL=35048,KL=35040,QL=35045,JL=35049,eN=35041,tN=35046,nN=35050,iN=35042,rN="100",vM="300 es",Ns=2e3,Ap=2001,aN={COMPUTE:"compute",RENDER:"render"},sN={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},oN={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function G3(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const lN={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function yp(n,e){return new lN[n](e)}function W3(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function p0(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function X3(){const n=p0("canvas");return n.style.display="block",n}const Sw={};let $u=null;function cN(n){$u=n}function uN(){return $u}function m0(...n){const e="THREE."+n.shift();$u?$u("log",e,...n):console.log(e,...n)}function Rt(...n){const e="THREE."+n.shift();$u?$u("warn",e,...n):console.warn(e,...n)}function Gt(...n){const e="THREE."+n.shift();$u?$u("error",e,...n):console.error(e,...n)}function Cp(...n){const e=n.join(" ");e in Sw||(Sw[e]=!0,Rt(...n))}function fN(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}let Hs=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,l=r.length;s>8&255]+Sa[n>>16&255]+Sa[n>>24&255]+"-"+Sa[e&255]+Sa[e>>8&255]+"-"+Sa[e>>16&15|64]+Sa[e>>24&255]+"-"+Sa[t&63|128]+Sa[t>>8&255]+"-"+Sa[t>>16&255]+Sa[t>>24&255]+Sa[i&255]+Sa[i>>8&255]+Sa[i>>16&255]+Sa[i>>24&255]).toLowerCase()}function ln(n,e,t){return Math.max(e,Math.min(t,n))}function EE(n,e){return(n%e+e)%e}function dN(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function hN(n,e,t){return n!==e?(t-n)/(e-n):0}function Kg(n,e,t){return(1-t)*n+t*e}function pN(n,e,t,i){return Kg(n,e,1-Math.exp(-t*i))}function mN(n,e=1){return e-Math.abs(EE(n,e*2)-e)}function gN(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function vN(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function yN(n,e){return n+Math.floor(Math.random()*(e-n+1))}function bN(n,e){return n+Math.random()*(e-n)}function xN(n){return n*(.5-Math.random())}function _N(n){n!==void 0&&(Mw=n);let e=Mw+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function SN(n){return n*vd}function MN(n){return n*Rp}function EN(n){return(n&n-1)===0&&n!==0}function TN(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function wN(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function AN(n,e,t,i,r){const s=Math.cos,l=Math.sin,u=s(t/2),h=l(t/2),p=s((e+i)/2),g=l((e+i)/2),y=s((e-i)/2),b=l((e-i)/2),x=s((i-e)/2),E=l((i-e)/2);switch(r){case"XYX":n.set(u*g,h*y,h*b,u*p);break;case"YZY":n.set(h*b,u*g,h*y,u*p);break;case"ZXZ":n.set(h*y,h*b,u*g,u*p);break;case"XZX":n.set(u*g,h*E,h*x,u*p);break;case"YXY":n.set(h*x,u*g,h*E,u*p);break;case"ZYZ":n.set(h*E,h*x,u*g,u*p);break;default:Rt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ja(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function _n(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const CN={DEG2RAD:vd,RAD2DEG:Rp,generateUUID:zs,clamp:ln,euclideanModulo:EE,mapLinear:dN,inverseLerp:hN,lerp:Kg,damp:pN,pingpong:mN,smoothstep:gN,smootherstep:vN,randInt:yN,randFloat:bN,randFloatSpread:xN,seededRandom:_N,degToRad:SN,radToDeg:MN,isPowerOfTwo:EN,ceilPowerOfTwo:TN,floorPowerOfTwo:wN,setQuaternionFromProperEuler:AN,normalize:_n,denormalize:ja};class Be{constructor(e=0,t=0){Be.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ln(this.x,e.x,t.x),this.y=ln(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ln(this.x,e,t),this.y=ln(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ln(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,l=this.y-e.y;return this.x=s*i-l*r+e.x,this.y=s*r+l*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ca{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,l,u){let h=i[r+0],p=i[r+1],g=i[r+2],y=i[r+3],b=s[l+0],x=s[l+1],E=s[l+2],A=s[l+3];if(u<=0){e[t+0]=h,e[t+1]=p,e[t+2]=g,e[t+3]=y;return}if(u>=1){e[t+0]=b,e[t+1]=x,e[t+2]=E,e[t+3]=A;return}if(y!==A||h!==b||p!==x||g!==E){let T=h*b+p*x+g*E+y*A;T<0&&(b=-b,x=-x,E=-E,A=-A,T=-T);let M=1-u;if(T<.9995){const R=Math.acos(T),O=Math.sin(R);M=Math.sin(M*R)/O,u=Math.sin(u*R)/O,h=h*M+b*u,p=p*M+x*u,g=g*M+E*u,y=y*M+A*u}else{h=h*M+b*u,p=p*M+x*u,g=g*M+E*u,y=y*M+A*u;const R=1/Math.sqrt(h*h+p*p+g*g+y*y);h*=R,p*=R,g*=R,y*=R}}e[t]=h,e[t+1]=p,e[t+2]=g,e[t+3]=y}static multiplyQuaternionsFlat(e,t,i,r,s,l){const u=i[r],h=i[r+1],p=i[r+2],g=i[r+3],y=s[l],b=s[l+1],x=s[l+2],E=s[l+3];return e[t]=u*E+g*y+h*x-p*b,e[t+1]=h*E+g*b+p*y-u*x,e[t+2]=p*E+g*x+u*b-h*y,e[t+3]=g*E-u*y-h*b-p*x,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,l=e._order,u=Math.cos,h=Math.sin,p=u(i/2),g=u(r/2),y=u(s/2),b=h(i/2),x=h(r/2),E=h(s/2);switch(l){case"XYZ":this._x=b*g*y+p*x*E,this._y=p*x*y-b*g*E,this._z=p*g*E+b*x*y,this._w=p*g*y-b*x*E;break;case"YXZ":this._x=b*g*y+p*x*E,this._y=p*x*y-b*g*E,this._z=p*g*E-b*x*y,this._w=p*g*y+b*x*E;break;case"ZXY":this._x=b*g*y-p*x*E,this._y=p*x*y+b*g*E,this._z=p*g*E+b*x*y,this._w=p*g*y-b*x*E;break;case"ZYX":this._x=b*g*y-p*x*E,this._y=p*x*y+b*g*E,this._z=p*g*E-b*x*y,this._w=p*g*y+b*x*E;break;case"YZX":this._x=b*g*y+p*x*E,this._y=p*x*y+b*g*E,this._z=p*g*E-b*x*y,this._w=p*g*y-b*x*E;break;case"XZY":this._x=b*g*y-p*x*E,this._y=p*x*y-b*g*E,this._z=p*g*E+b*x*y,this._w=p*g*y+b*x*E;break;default:Rt("Quaternion: .setFromEuler() encountered an unknown order: "+l)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],l=t[1],u=t[5],h=t[9],p=t[2],g=t[6],y=t[10],b=i+u+y;if(b>0){const x=.5/Math.sqrt(b+1);this._w=.25/x,this._x=(g-h)*x,this._y=(s-p)*x,this._z=(l-r)*x}else if(i>u&&i>y){const x=2*Math.sqrt(1+i-u-y);this._w=(g-h)/x,this._x=.25*x,this._y=(r+l)/x,this._z=(s+p)/x}else if(u>y){const x=2*Math.sqrt(1+u-i-y);this._w=(s-p)/x,this._x=(r+l)/x,this._y=.25*x,this._z=(h+g)/x}else{const x=2*Math.sqrt(1+y-i-u);this._w=(l-r)/x,this._x=(s+p)/x,this._y=(h+g)/x,this._z=.25*x}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ln(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,l=e._w,u=t._x,h=t._y,p=t._z,g=t._w;return this._x=i*g+l*u+r*p-s*h,this._y=r*g+l*h+s*u-i*p,this._z=s*g+l*p+i*h-r*u,this._w=l*g-i*u-r*h-s*p,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,r=e._y,s=e._z,l=e._w,u=this.dot(e);u<0&&(i=-i,r=-r,s=-s,l=-l,u=-u);let h=1-t;if(u<.9995){const p=Math.acos(u),g=Math.sin(p);h=Math.sin(h*p)/g,t=Math.sin(t*p)/g,this._x=this._x*h+i*t,this._y=this._y*h+r*t,this._z=this._z*h+s*t,this._w=this._w*h+l*t,this._onChangeCallback()}else this._x=this._x*h+i*t,this._y=this._y*h+r*t,this._z=this._z*h+s*t,this._w=this._w*h+l*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Q{constructor(e=0,t=0,i=0){Q.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ew.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ew.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,l=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*l,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*l,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*l,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,l=e.y,u=e.z,h=e.w,p=2*(l*r-u*i),g=2*(u*t-s*r),y=2*(s*i-l*t);return this.x=t+h*p+l*y-u*g,this.y=i+h*g+u*p-s*y,this.z=r+h*y+s*g-l*p,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ln(this.x,e.x,t.x),this.y=ln(this.y,e.y,t.y),this.z=ln(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ln(this.x,e,t),this.y=ln(this.y,e,t),this.z=ln(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,l=t.x,u=t.y,h=t.z;return this.x=r*h-s*u,this.y=s*l-i*h,this.z=i*u-r*l,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return LS.copy(this).projectOnVector(e),this.sub(LS)}reflect(e){return this.sub(LS.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ln(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const LS=new Q,Ew=new Ca;class vn{constructor(e,t,i,r,s,l,u,h,p){vn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,l,u,h,p)}set(e,t,i,r,s,l,u,h,p){const g=this.elements;return g[0]=e,g[1]=r,g[2]=u,g[3]=t,g[4]=s,g[5]=h,g[6]=i,g[7]=l,g[8]=p,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,l=i[0],u=i[3],h=i[6],p=i[1],g=i[4],y=i[7],b=i[2],x=i[5],E=i[8],A=r[0],T=r[3],M=r[6],R=r[1],O=r[4],D=r[7],F=r[2],U=r[5],k=r[8];return s[0]=l*A+u*R+h*F,s[3]=l*T+u*O+h*U,s[6]=l*M+u*D+h*k,s[1]=p*A+g*R+y*F,s[4]=p*T+g*O+y*U,s[7]=p*M+g*D+y*k,s[2]=b*A+x*R+E*F,s[5]=b*T+x*O+E*U,s[8]=b*M+x*D+E*k,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],l=e[4],u=e[5],h=e[6],p=e[7],g=e[8];return t*l*g-t*u*p-i*s*g+i*u*h+r*s*p-r*l*h}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],l=e[4],u=e[5],h=e[6],p=e[7],g=e[8],y=g*l-u*p,b=u*h-g*s,x=p*s-l*h,E=t*y+i*b+r*x;if(E===0)return this.set(0,0,0,0,0,0,0,0,0);const A=1/E;return e[0]=y*A,e[1]=(r*p-g*i)*A,e[2]=(u*i-r*l)*A,e[3]=b*A,e[4]=(g*t-r*h)*A,e[5]=(r*s-u*t)*A,e[6]=x*A,e[7]=(i*h-p*t)*A,e[8]=(l*t-i*s)*A,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,l,u){const h=Math.cos(s),p=Math.sin(s);return this.set(i*h,i*p,-i*(h*l+p*u)+l+e,-r*p,r*h,-r*(-p*l+h*u)+u+t,0,0,1),this}scale(e,t){return this.premultiply(NS.makeScale(e,t)),this}rotate(e){return this.premultiply(NS.makeRotation(-e)),this}translate(e,t){return this.premultiply(NS.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const NS=new vn,Tw=new vn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ww=new vn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function RN(){const n={enabled:!0,workingColorSpace:Fl,spaces:{},convert:function(r,s,l){return this.enabled===!1||s===l||!s||!l||(this.spaces[s].transfer===ui&&(r.r=Oc(r.r),r.g=Oc(r.g),r.b=Oc(r.b)),this.spaces[s].primaries!==this.spaces[l].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[l].fromXYZ)),this.spaces[l].transfer===ui&&(r.r=Sp(r.r),r.g=Sp(r.g),r.b=Sp(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Xo?d0:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,l){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[l].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Cp("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Cp("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Fl]:{primaries:e,whitePoint:i,transfer:d0,toXYZ:Tw,fromXYZ:ww,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Zn},outputColorSpaceConfig:{drawingBufferColorSpace:Zn}},[Zn]:{primaries:e,whitePoint:i,transfer:ui,toXYZ:Tw,fromXYZ:ww,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Zn}}}),n}const Hn=RN();function Oc(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Sp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Vh;class $3{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Vh===void 0&&(Vh=p0("canvas")),Vh.width=e.width,Vh.height=e.height;const r=Vh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Vh}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=p0("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let l=0;l1),this.pmremVersion=0}get width(){return this.source.getSize(zS).x}get height(){return this.source.getSize(zS).y}get depth(){return this.source.getSize(zS).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Rt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Rt(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==n_)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case l0:e.x=e.x-Math.floor(e.x);break;case _s:e.x=e.x<0?0:1;break;case c0:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case l0:e.y=e.y-Math.floor(e.y);break;case _s:e.y=e.y<0?0:1;break;case c0:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}$i.DEFAULT_IMAGE=null;$i.DEFAULT_MAPPING=n_;$i.DEFAULT_ANISOTROPY=1;class fi{constructor(e=0,t=0,i=0,r=1){fi.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,l=e.elements;return this.x=l[0]*t+l[4]*i+l[8]*r+l[12]*s,this.y=l[1]*t+l[5]*i+l[9]*r+l[13]*s,this.z=l[2]*t+l[6]*i+l[10]*r+l[14]*s,this.w=l[3]*t+l[7]*i+l[11]*r+l[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const h=e.elements,p=h[0],g=h[4],y=h[8],b=h[1],x=h[5],E=h[9],A=h[2],T=h[6],M=h[10];if(Math.abs(g-b)<.01&&Math.abs(y-A)<.01&&Math.abs(E-T)<.01){if(Math.abs(g+b)<.1&&Math.abs(y+A)<.1&&Math.abs(E+T)<.1&&Math.abs(p+x+M-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const O=(p+1)/2,D=(x+1)/2,F=(M+1)/2,U=(g+b)/4,k=(y+A)/4,H=(E+T)/4;return O>D&&O>F?O<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(O),r=U/i,s=k/i):D>F?D<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(D),i=U/r,s=H/r):F<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(F),i=k/s,r=H/s),this.set(i,r,s,t),this}let R=Math.sqrt((T-E)*(T-E)+(y-A)*(y-A)+(b-g)*(b-g));return Math.abs(R)<.001&&(R=1),this.x=(T-E)/R,this.y=(y-A)/R,this.z=(b-g)/R,this.w=Math.acos((p+x+M-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ln(this.x,e.x,t.x),this.y=ln(this.y,e.y,t.y),this.z=ln(this.z,e.z,t.z),this.w=ln(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ln(this.x,e,t),this.y=ln(this.y,e,t),this.z=ln(this.z,e,t),this.w=ln(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class TE extends Hs{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Kn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new fi(0,0,e,t),this.scissorTest=!1,this.viewport=new fi(0,0,e,t);const r={width:e,height:t,depth:i.depth},s=new $i(r);this.textures=[];const l=i.count;for(let u=0;u1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Bo),Bo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(xg),Iy.subVectors(this.max,xg),Gh.subVectors(e.a,xg),Wh.subVectors(e.b,xg),Xh.subVectors(e.c,xg),Ru.subVectors(Wh,Gh),Du.subVectors(Xh,Wh),$f.subVectors(Gh,Xh);let t=[0,-Ru.z,Ru.y,0,-Du.z,Du.y,0,-$f.z,$f.y,Ru.z,0,-Ru.x,Du.z,0,-Du.x,$f.z,0,-$f.x,-Ru.y,Ru.x,0,-Du.y,Du.x,0,-$f.y,$f.x,0];return!FS(t,Gh,Wh,Xh,Iy)||(t=[1,0,0,0,1,0,0,0,1],!FS(t,Gh,Wh,Xh,Iy))?!1:(Py.crossVectors(Ru,Du),t=[Py.x,Py.y,Py.z],FS(t,Gh,Wh,Xh,Iy))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Bo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Bo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(yc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),yc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),yc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),yc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),yc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),yc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),yc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),yc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(yc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const yc=[new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q],Bo=new Q,Oy=new Ra,Gh=new Q,Wh=new Q,Xh=new Q,Ru=new Q,Du=new Q,$f=new Q,xg=new Q,Iy=new Q,Py=new Q,jf=new Q;function FS(n,e,t,i,r){for(let s=0,l=n.length-3;s<=l;s+=3){jf.fromArray(n,s);const u=r.x*Math.abs(jf.x)+r.y*Math.abs(jf.y)+r.z*Math.abs(jf.z),h=e.dot(jf),p=t.dot(jf),g=i.dot(jf);if(Math.max(-Math.max(h,p,g),Math.min(h,p,g))>u)return!1}return!0}const LN=new Ra,_g=new Q,BS=new Q;class ua{constructor(e=new Q,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):LN.setFromPoints(e).getCenter(i);let r=0;for(let s=0,l=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;_g.subVectors(e,this.center);const t=_g.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(_g,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(BS.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_g.copy(e.center).add(BS)),this.expandByPoint(_g.copy(e.center).sub(BS))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const bc=new Q,kS=new Q,Ly=new Q,Ou=new Q,HS=new Q,Ny=new Q,VS=new Q;class Dd{constructor(e=new Q,t=new Q(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,bc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=bc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(bc.copy(this.origin).addScaledVector(this.direction,t),bc.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){kS.copy(e).add(t).multiplyScalar(.5),Ly.copy(t).sub(e).normalize(),Ou.copy(this.origin).sub(kS);const s=e.distanceTo(t)*.5,l=-this.direction.dot(Ly),u=Ou.dot(this.direction),h=-Ou.dot(Ly),p=Ou.lengthSq(),g=Math.abs(1-l*l);let y,b,x,E;if(g>0)if(y=l*h-u,b=l*u-h,E=s*g,y>=0)if(b>=-E)if(b<=E){const A=1/g;y*=A,b*=A,x=y*(y+l*b+2*u)+b*(l*y+b+2*h)+p}else b=s,y=Math.max(0,-(l*b+u)),x=-y*y+b*(b+2*h)+p;else b=-s,y=Math.max(0,-(l*b+u)),x=-y*y+b*(b+2*h)+p;else b<=-E?(y=Math.max(0,-(-l*s+u)),b=y>0?-s:Math.min(Math.max(-s,-h),s),x=-y*y+b*(b+2*h)+p):b<=E?(y=0,b=Math.min(Math.max(-s,-h),s),x=b*(b+2*h)+p):(y=Math.max(0,-(l*s+u)),b=y>0?s:Math.min(Math.max(-s,-h),s),x=-y*y+b*(b+2*h)+p);else b=l>0?-s:s,y=Math.max(0,-(l*b+u)),x=-y*y+b*(b+2*h)+p;return i&&i.copy(this.origin).addScaledVector(this.direction,y),r&&r.copy(kS).addScaledVector(Ly,b),x}intersectSphere(e,t){bc.subVectors(e.center,this.origin);const i=bc.dot(this.direction),r=bc.dot(bc)-i*i,s=e.radius*e.radius;if(r>s)return null;const l=Math.sqrt(s-r),u=i-l,h=i+l;return h<0?null:u<0?this.at(h,t):this.at(u,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,l,u,h;const p=1/this.direction.x,g=1/this.direction.y,y=1/this.direction.z,b=this.origin;return p>=0?(i=(e.min.x-b.x)*p,r=(e.max.x-b.x)*p):(i=(e.max.x-b.x)*p,r=(e.min.x-b.x)*p),g>=0?(s=(e.min.y-b.y)*g,l=(e.max.y-b.y)*g):(s=(e.max.y-b.y)*g,l=(e.min.y-b.y)*g),i>l||s>r||((s>i||isNaN(i))&&(i=s),(l=0?(u=(e.min.z-b.z)*y,h=(e.max.z-b.z)*y):(u=(e.max.z-b.z)*y,h=(e.min.z-b.z)*y),i>h||u>r)||((u>i||i!==i)&&(i=u),(h=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,bc)!==null}intersectTriangle(e,t,i,r,s){HS.subVectors(t,e),Ny.subVectors(i,e),VS.crossVectors(HS,Ny);let l=this.direction.dot(VS),u;if(l>0){if(r)return null;u=1}else if(l<0)u=-1,l=-l;else return null;Ou.subVectors(this.origin,e);const h=u*this.direction.dot(Ny.crossVectors(Ou,Ny));if(h<0)return null;const p=u*this.direction.dot(HS.cross(Ou));if(p<0||h+p>l)return null;const g=-u*Ou.dot(VS);return g<0?null:this.at(g/l,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class rn{constructor(e,t,i,r,s,l,u,h,p,g,y,b,x,E,A,T){rn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,l,u,h,p,g,y,b,x,E,A,T)}set(e,t,i,r,s,l,u,h,p,g,y,b,x,E,A,T){const M=this.elements;return M[0]=e,M[4]=t,M[8]=i,M[12]=r,M[1]=s,M[5]=l,M[9]=u,M[13]=h,M[2]=p,M[6]=g,M[10]=y,M[14]=b,M[3]=x,M[7]=E,M[11]=A,M[15]=T,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 rn().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/$h.setFromMatrixColumn(e,0).length(),s=1/$h.setFromMatrixColumn(e,1).length(),l=1/$h.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*l,t[9]=i[9]*l,t[10]=i[10]*l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,l=Math.cos(i),u=Math.sin(i),h=Math.cos(r),p=Math.sin(r),g=Math.cos(s),y=Math.sin(s);if(e.order==="XYZ"){const b=l*g,x=l*y,E=u*g,A=u*y;t[0]=h*g,t[4]=-h*y,t[8]=p,t[1]=x+E*p,t[5]=b-A*p,t[9]=-u*h,t[2]=A-b*p,t[6]=E+x*p,t[10]=l*h}else if(e.order==="YXZ"){const b=h*g,x=h*y,E=p*g,A=p*y;t[0]=b+A*u,t[4]=E*u-x,t[8]=l*p,t[1]=l*y,t[5]=l*g,t[9]=-u,t[2]=x*u-E,t[6]=A+b*u,t[10]=l*h}else if(e.order==="ZXY"){const b=h*g,x=h*y,E=p*g,A=p*y;t[0]=b-A*u,t[4]=-l*y,t[8]=E+x*u,t[1]=x+E*u,t[5]=l*g,t[9]=A-b*u,t[2]=-l*p,t[6]=u,t[10]=l*h}else if(e.order==="ZYX"){const b=l*g,x=l*y,E=u*g,A=u*y;t[0]=h*g,t[4]=E*p-x,t[8]=b*p+A,t[1]=h*y,t[5]=A*p+b,t[9]=x*p-E,t[2]=-p,t[6]=u*h,t[10]=l*h}else if(e.order==="YZX"){const b=l*h,x=l*p,E=u*h,A=u*p;t[0]=h*g,t[4]=A-b*y,t[8]=E*y+x,t[1]=y,t[5]=l*g,t[9]=-u*g,t[2]=-p*g,t[6]=x*y+E,t[10]=b-A*y}else if(e.order==="XZY"){const b=l*h,x=l*p,E=u*h,A=u*p;t[0]=h*g,t[4]=-y,t[8]=p*g,t[1]=b*y+A,t[5]=l*g,t[9]=x*y-E,t[2]=E*y-x,t[6]=u*g,t[10]=A*y+b}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(NN,e,UN)}lookAt(e,t,i){const r=this.elements;return Ds.subVectors(e,t),Ds.lengthSq()===0&&(Ds.z=1),Ds.normalize(),Iu.crossVectors(i,Ds),Iu.lengthSq()===0&&(Math.abs(i.z)===1?Ds.x+=1e-4:Ds.z+=1e-4,Ds.normalize(),Iu.crossVectors(i,Ds)),Iu.normalize(),Uy.crossVectors(Ds,Iu),r[0]=Iu.x,r[4]=Uy.x,r[8]=Ds.x,r[1]=Iu.y,r[5]=Uy.y,r[9]=Ds.y,r[2]=Iu.z,r[6]=Uy.z,r[10]=Ds.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,l=i[0],u=i[4],h=i[8],p=i[12],g=i[1],y=i[5],b=i[9],x=i[13],E=i[2],A=i[6],T=i[10],M=i[14],R=i[3],O=i[7],D=i[11],F=i[15],U=r[0],k=r[4],H=r[8],L=r[12],z=r[1],W=r[5],J=r[9],$=r[13],oe=r[2],ne=r[6],Y=r[10],K=r[14],ie=r[3],ge=r[7],xe=r[11],q=r[15];return s[0]=l*U+u*z+h*oe+p*ie,s[4]=l*k+u*W+h*ne+p*ge,s[8]=l*H+u*J+h*Y+p*xe,s[12]=l*L+u*$+h*K+p*q,s[1]=g*U+y*z+b*oe+x*ie,s[5]=g*k+y*W+b*ne+x*ge,s[9]=g*H+y*J+b*Y+x*xe,s[13]=g*L+y*$+b*K+x*q,s[2]=E*U+A*z+T*oe+M*ie,s[6]=E*k+A*W+T*ne+M*ge,s[10]=E*H+A*J+T*Y+M*xe,s[14]=E*L+A*$+T*K+M*q,s[3]=R*U+O*z+D*oe+F*ie,s[7]=R*k+O*W+D*ne+F*ge,s[11]=R*H+O*J+D*Y+F*xe,s[15]=R*L+O*$+D*K+F*q,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],l=e[1],u=e[5],h=e[9],p=e[13],g=e[2],y=e[6],b=e[10],x=e[14],E=e[3],A=e[7],T=e[11],M=e[15],R=h*x-p*b,O=u*x-p*y,D=u*b-h*y,F=l*x-p*g,U=l*b-h*g,k=l*y-u*g;return t*(A*R-T*O+M*D)-i*(E*R-T*F+M*U)+r*(E*O-A*F+M*k)-s*(E*D-A*U+T*k)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],l=e[4],u=e[5],h=e[6],p=e[7],g=e[8],y=e[9],b=e[10],x=e[11],E=e[12],A=e[13],T=e[14],M=e[15],R=y*T*p-A*b*p+A*h*x-u*T*x-y*h*M+u*b*M,O=E*b*p-g*T*p-E*h*x+l*T*x+g*h*M-l*b*M,D=g*A*p-E*y*p+E*u*x-l*A*x-g*u*M+l*y*M,F=E*y*h-g*A*h-E*u*b+l*A*b+g*u*T-l*y*T,U=t*R+i*O+r*D+s*F;if(U===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/U;return e[0]=R*k,e[1]=(A*b*s-y*T*s-A*r*x+i*T*x+y*r*M-i*b*M)*k,e[2]=(u*T*s-A*h*s+A*r*p-i*T*p-u*r*M+i*h*M)*k,e[3]=(y*h*s-u*b*s-y*r*p+i*b*p+u*r*x-i*h*x)*k,e[4]=O*k,e[5]=(g*T*s-E*b*s+E*r*x-t*T*x-g*r*M+t*b*M)*k,e[6]=(E*h*s-l*T*s-E*r*p+t*T*p+l*r*M-t*h*M)*k,e[7]=(l*b*s-g*h*s+g*r*p-t*b*p-l*r*x+t*h*x)*k,e[8]=D*k,e[9]=(E*y*s-g*A*s-E*i*x+t*A*x+g*i*M-t*y*M)*k,e[10]=(l*A*s-E*u*s+E*i*p-t*A*p-l*i*M+t*u*M)*k,e[11]=(g*u*s-l*y*s-g*i*p+t*y*p+l*i*x-t*u*x)*k,e[12]=F*k,e[13]=(g*A*r-E*y*r+E*i*b-t*A*b-g*i*T+t*y*T)*k,e[14]=(E*u*r-l*A*r-E*i*h+t*A*h+l*i*T-t*u*T)*k,e[15]=(l*y*r-g*u*r+g*i*h-t*y*h-l*i*b+t*u*b)*k,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,l=e.x,u=e.y,h=e.z,p=s*l,g=s*u;return this.set(p*l+i,p*u-r*h,p*h+r*u,0,p*u+r*h,g*u+i,g*h-r*l,0,p*h-r*u,g*h+r*l,s*h*h+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,l){return this.set(1,i,s,0,e,1,l,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,l=t._y,u=t._z,h=t._w,p=s+s,g=l+l,y=u+u,b=s*p,x=s*g,E=s*y,A=l*g,T=l*y,M=u*y,R=h*p,O=h*g,D=h*y,F=i.x,U=i.y,k=i.z;return r[0]=(1-(A+M))*F,r[1]=(x+D)*F,r[2]=(E-O)*F,r[3]=0,r[4]=(x-D)*U,r[5]=(1-(b+M))*U,r[6]=(T+R)*U,r[7]=0,r[8]=(E+O)*k,r[9]=(T-R)*k,r[10]=(1-(b+A))*k,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;if(e.x=r[12],e.y=r[13],e.z=r[14],this.determinant()===0)return i.set(1,1,1),t.identity(),this;let s=$h.set(r[0],r[1],r[2]).length();const l=$h.set(r[4],r[5],r[6]).length(),u=$h.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),ko.copy(this);const p=1/s,g=1/l,y=1/u;return ko.elements[0]*=p,ko.elements[1]*=p,ko.elements[2]*=p,ko.elements[4]*=g,ko.elements[5]*=g,ko.elements[6]*=g,ko.elements[8]*=y,ko.elements[9]*=y,ko.elements[10]*=y,t.setFromRotationMatrix(ko),i.x=s,i.y=l,i.z=u,this}makePerspective(e,t,i,r,s,l,u=Ns,h=!1){const p=this.elements,g=2*s/(t-e),y=2*s/(i-r),b=(t+e)/(t-e),x=(i+r)/(i-r);let E,A;if(h)E=s/(l-s),A=l*s/(l-s);else if(u===Ns)E=-(l+s)/(l-s),A=-2*l*s/(l-s);else if(u===Ap)E=-l/(l-s),A=-l*s/(l-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+u);return p[0]=g,p[4]=0,p[8]=b,p[12]=0,p[1]=0,p[5]=y,p[9]=x,p[13]=0,p[2]=0,p[6]=0,p[10]=E,p[14]=A,p[3]=0,p[7]=0,p[11]=-1,p[15]=0,this}makeOrthographic(e,t,i,r,s,l,u=Ns,h=!1){const p=this.elements,g=2/(t-e),y=2/(i-r),b=-(t+e)/(t-e),x=-(i+r)/(i-r);let E,A;if(h)E=1/(l-s),A=l/(l-s);else if(u===Ns)E=-2/(l-s),A=-(l+s)/(l-s);else if(u===Ap)E=-1/(l-s),A=-s/(l-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+u);return p[0]=g,p[4]=0,p[8]=0,p[12]=b,p[1]=0,p[5]=y,p[9]=0,p[13]=x,p[2]=0,p[6]=0,p[10]=E,p[14]=A,p[3]=0,p[7]=0,p[11]=0,p[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const $h=new Q,ko=new rn,NN=new Q(0,0,0),UN=new Q(1,1,1),Iu=new Q,Uy=new Q,Ds=new Q,Aw=new rn,Cw=new Ca;class ks{constructor(e=0,t=0,i=0,r=ks.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],l=r[4],u=r[8],h=r[1],p=r[5],g=r[9],y=r[2],b=r[6],x=r[10];switch(t){case"XYZ":this._y=Math.asin(ln(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-g,x),this._z=Math.atan2(-l,s)):(this._x=Math.atan2(b,p),this._z=0);break;case"YXZ":this._x=Math.asin(-ln(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(u,x),this._z=Math.atan2(h,p)):(this._y=Math.atan2(-y,s),this._z=0);break;case"ZXY":this._x=Math.asin(ln(b,-1,1)),Math.abs(b)<.9999999?(this._y=Math.atan2(-y,x),this._z=Math.atan2(-l,p)):(this._y=0,this._z=Math.atan2(h,s));break;case"ZYX":this._y=Math.asin(-ln(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(b,x),this._z=Math.atan2(h,s)):(this._x=0,this._z=Math.atan2(-l,p));break;case"YZX":this._z=Math.asin(ln(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-g,p),this._y=Math.atan2(-y,s)):(this._x=0,this._y=Math.atan2(u,x));break;case"XZY":this._z=Math.asin(-ln(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(b,p),this._y=Math.atan2(u,s)):(this._x=Math.atan2(-g,x),this._y=0);break;default:Rt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Aw.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Aw,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Cw.setFromEuler(this),this.setFromQuaternion(Cw,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ks.DEFAULT_ORDER="XYZ";class Dp{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){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.geometryInfo=this._geometryInfo.map(u=>({...u,boundingBox:u.boundingBox?u.boundingBox.toJSON():void 0,boundingSphere:u.boundingSphere?u.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(u=>({...u})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(u,h){return u[h.uuid]===void 0&&(u[h.uuid]=h.toJSON(e)),h.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.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 p=0,g=h.length;p0){r.children=[];for(let u=0;u0){r.animations=[];for(let u=0;u0&&(i.geometries=u),h.length>0&&(i.materials=h),p.length>0&&(i.textures=p),g.length>0&&(i.images=g),y.length>0&&(i.shapes=y),b.length>0&&(i.skeletons=b),x.length>0&&(i.animations=x),E.length>0&&(i.nodes=E)}return i.object=r,i;function l(u){const h=[];for(const p in u){const g=u[p];delete g.metadata,h.push(g)}return h}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Ho.subVectors(r,t),_c.subVectors(i,t),WS.subVectors(e,t);const l=Ho.dot(Ho),u=Ho.dot(_c),h=Ho.dot(WS),p=_c.dot(_c),g=_c.dot(WS),y=l*p-u*u;if(y===0)return s.set(0,0,0),null;const b=1/y,x=(p*h-u*g)*b,E=(l*g-u*h)*b;return s.set(1-x-E,E,x)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Sc)===null?!1:Sc.x>=0&&Sc.y>=0&&Sc.x+Sc.y<=1}static getInterpolation(e,t,i,r,s,l,u,h){return this.getBarycoord(e,t,i,r,Sc)===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(s,Sc.x),h.addScaledVector(l,Sc.y),h.addScaledVector(u,Sc.z),h)}static getInterpolatedAttribute(e,t,i,r,s,l){return qS.setScalar(0),YS.setScalar(0),ZS.setScalar(0),qS.fromBufferAttribute(e,t),YS.fromBufferAttribute(e,i),ZS.fromBufferAttribute(e,r),l.setScalar(0),l.addScaledVector(qS,s.x),l.addScaledVector(YS,s.y),l.addScaledVector(ZS,s.z),l}static isFrontFacing(e,t,i,r){return Ho.subVectors(i,t),_c.subVectors(e,t),Ho.cross(_c).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ho.subVectors(this.c,this.b),_c.subVectors(this.a,this.b),Ho.cross(_c).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xs.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return xs.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return xs.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return xs.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xs.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let l,u;Yh.subVectors(r,i),Zh.subVectors(s,i),XS.subVectors(e,i);const h=Yh.dot(XS),p=Zh.dot(XS);if(h<=0&&p<=0)return t.copy(i);$S.subVectors(e,r);const g=Yh.dot($S),y=Zh.dot($S);if(g>=0&&y<=g)return t.copy(r);const b=h*y-g*p;if(b<=0&&h>=0&&g<=0)return l=h/(h-g),t.copy(i).addScaledVector(Yh,l);jS.subVectors(e,s);const x=Yh.dot(jS),E=Zh.dot(jS);if(E>=0&&x<=E)return t.copy(s);const A=x*p-h*E;if(A<=0&&p>=0&&E<=0)return u=p/(p-E),t.copy(i).addScaledVector(Zh,u);const T=g*E-x*y;if(T<=0&&y-g>=0&&x-E>=0)return Lw.subVectors(s,r),u=(y-g)/(y-g+(x-E)),t.copy(r).addScaledVector(Lw,u);const M=1/(T+A+b);return l=A*M,u=b*M,t.copy(i).addScaledVector(Yh,l).addScaledVector(Zh,u)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const j3={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},Pu={h:0,s:0,l:0},Fy={h:0,s:0,l:0};function KS(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}let Mt=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Zn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Hn.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=Hn.workingColorSpace){return this.r=e,this.g=t,this.b=i,Hn.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Hn.workingColorSpace){if(e=EE(e,1),t=ln(t,0,1),i=ln(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,l=2*i-s;this.r=KS(l,s,e+1/3),this.g=KS(l,s,e),this.b=KS(l,s,e-1/3)}return Hn.colorSpaceToWorking(this,r),this}setStyle(e,t=Zn){function i(s){s!==void 0&&parseFloat(s)<1&&Rt("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const l=r[1],u=r[2];switch(l){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Rt("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],l=s.length;if(l===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(l===6)return this.setHex(parseInt(s,16),t);Rt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Zn){const i=j3[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Rt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Oc(e.r),this.g=Oc(e.g),this.b=Oc(e.b),this}copyLinearToSRGB(e){return this.r=Sp(e.r),this.g=Sp(e.g),this.b=Sp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Zn){return Hn.workingToColorSpace(Ma.copy(this),e),Math.round(ln(Ma.r*255,0,255))*65536+Math.round(ln(Ma.g*255,0,255))*256+Math.round(ln(Ma.b*255,0,255))}getHexString(e=Zn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Hn.workingColorSpace){Hn.workingToColorSpace(Ma.copy(this),t);const i=Ma.r,r=Ma.g,s=Ma.b,l=Math.max(i,r,s),u=Math.min(i,r,s);let h,p;const g=(u+l)/2;if(u===l)h=0,p=0;else{const y=l-u;switch(p=g<=.5?y/(l+u):y/(2-l-u),l){case i:h=(r-s)/y+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Rt(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Rt(`Material: '${t}' 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[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==gd&&(i.blending=this.blending),this.side!==Nl&&(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!==Hb&&(i.blendSrc=this.blendSrc),this.blendDst!==Tp&&(i.blendDst=this.blendDst),this.blendEquation!==Ac&&(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!==_d&&(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!==gM&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==cd&&(i.stencilFail=this.stencilFail),this.stencilZFail!==cd&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==cd&&(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.allowOverride===!1&&(i.allowOverride=!1),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(s){const l=[];for(const u in s){const h=s[u];delete h.metadata,l.push(h)}return l}if(t){const s=r(e.textures),l=r(e.images);s.length>0&&(i.textures=s),l.length>0&&(i.images=l)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class rf extends jr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mt(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 ks,this.combine=R0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Cc=VN();function VN(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let h=0;h<256;++h){const p=h-127;p<-27?(i[h]=0,i[h|256]=32768,r[h]=24,r[h|256]=24):p<-14?(i[h]=1024>>-p-14,i[h|256]=1024>>-p-14|32768,r[h]=-p-1,r[h|256]=-p-1):p<=15?(i[h]=p+15<<10,i[h|256]=p+15<<10|32768,r[h]=13,r[h|256]=13):p<128?(i[h]=31744,i[h|256]=64512,r[h]=24,r[h|256]=24):(i[h]=31744,i[h|256]=64512,r[h]=13,r[h|256]=13)}const s=new Uint32Array(2048),l=new Uint32Array(64),u=new Uint32Array(64);for(let h=1;h<1024;++h){let p=h<<13,g=0;for(;(p&8388608)===0;)p<<=1,g-=8388608;p&=-8388609,g+=947912704,s[h]=p|g}for(let h=1024;h<2048;++h)s[h]=939524096+(h-1024<<13);for(let h=1;h<31;++h)l[h]=h<<23;l[31]=1199570944,l[32]=2147483648;for(let h=33;h<63;++h)l[h]=2147483648+(h-32<<23);l[63]=3347054592;for(let h=1;h<64;++h)h!==32&&(u[h]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:l,offsetTable:u}}function vs(n){Math.abs(n)>65504&&Rt("DataUtils.toHalfFloat(): Value out of range."),n=ln(n,-65504,65504),Cc.floatView[0]=n;const e=Cc.uint32View[0],t=e>>23&511;return Cc.baseTable[t]+((e&8388607)>>Cc.shiftTable[t])}function Hg(n){const e=n>>10;return Cc.uint32View[0]=Cc.mantissaTable[Cc.offsetTable[e]+(n&1023)]+Cc.exponentTable[e],Cc.floatView[0]}class GN{static toHalfFloat(e){return vs(e)}static fromHalfFloat(e){return Hg(e)}}const Ar=new Q,By=new Be;let WN=0;class si{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:WN++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=h0,this.updateRanges=[],this.gpuType=xr,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;rt.count&&Rt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ra);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Gt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Q(-1/0,-1/0,-1/0),new Q(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0){const h=this.parameters;for(const p in h)h[p]!==void 0&&(e[p]=h[p]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const h in i){const p=i[h];e.data.attributes[h]=p.toJSON(e.data)}const r={};let s=!1;for(const h in this.morphAttributes){const p=this.morphAttributes[h],g=[];for(let y=0,b=p.length;y0&&(r[h]=g,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(e.data.groups=JSON.parse(JSON.stringify(l)));const u=this.boundingSphere;return u!==null&&(e.data.boundingSphere=u.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const p in r){const g=r[p];this.setAttribute(p,g.clone(t))}const s=e.morphAttributes;for(const p in s){const g=[],y=s[p];for(let b=0,x=y.length;b0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,l=r.length;s(e.far-e.near)**2))&&(Nw.copy(s).invert(),qf.copy(e.ray).applyMatrix4(Nw),!(i.boundingBox!==null&&qf.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,qf)))}_computeIntersections(e,t,i){let r;const s=this.geometry,l=this.material,u=s.index,h=s.attributes.position,p=s.attributes.uv,g=s.attributes.uv1,y=s.attributes.normal,b=s.groups,x=s.drawRange;if(u!==null)if(Array.isArray(l))for(let E=0,A=b.length;Et.far?null:{distance:p,point:Xy.clone(),object:n}}function $y(n,e,t,i,r,s,l,u,h,p){n.getVertexPosition(u,Hy),n.getVertexPosition(h,Vy),n.getVertexPosition(p,Gy);const g=QN(n,e,t,i,Hy,Vy,Gy,zw);if(g){const y=new Q;xs.getBarycoord(zw,Hy,Vy,Gy,y),r&&(g.uv=xs.getInterpolatedAttribute(r,u,h,p,y,new Be)),s&&(g.uv1=xs.getInterpolatedAttribute(s,u,h,p,y,new Be)),l&&(g.normal=xs.getInterpolatedAttribute(l,u,h,p,y,new Q),g.normal.dot(i.direction)>0&&g.normal.multiplyScalar(-1));const b={a:u,b:h,c:p,normal:new Q,materialIndex:0};xs.getNormal(Hy,Vy,Gy,b.normal),g.face=b,g.barycoord=y}return g}class Od extends dn{constructor(e=1,t=1,i=1,r=1,s=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:l};const u=this;r=Math.floor(r),s=Math.floor(s),l=Math.floor(l);const h=[],p=[],g=[],y=[];let b=0,x=0;E("z","y","x",-1,-1,i,t,e,l,s,0),E("z","y","x",1,-1,i,t,-e,l,s,1),E("x","z","y",1,1,e,i,t,r,l,2),E("x","z","y",1,-1,e,i,-t,r,l,3),E("x","y","z",1,-1,e,t,i,r,s,4),E("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(h),this.setAttribute("position",new Nt(p,3)),this.setAttribute("normal",new Nt(g,3)),this.setAttribute("uv",new Nt(y,2));function E(A,T,M,R,O,D,F,U,k,H,L){const z=D/k,W=F/H,J=D/2,$=F/2,oe=U/2,ne=k+1,Y=H+1;let K=0,ie=0;const ge=new Q;for(let xe=0;xe0?1:-1,g.push(ge.x,ge.y,ge.z),y.push(ce/k),y.push(1-xe/H),K+=1}}for(let xe=0;xe0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class h_ extends Qn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new rn,this.projectionMatrix=new rn,this.projectionMatrixInverse=new rn,this.coordinateSystem=Ns,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Lu=new Q,Fw=new Be,Bw=new Be;let nr=class extends h_{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Rp*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(vd*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Rp*2*Math.atan(Math.tan(vd*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Lu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Lu.x,Lu.y).multiplyScalar(-e/Lu.z),Lu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Lu.x,Lu.y).multiplyScalar(-e/Lu.z)}getViewSize(e,t){return this.getViewBounds(e,Fw,Bw),t.subVectors(Bw,Fw)}setViewOffset(e,t,i,r,s,l){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(vd*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const l=this.view;if(this.view!==null&&this.view.enabled){const h=l.fullWidth,p=l.fullHeight;s+=l.offsetX*r/h,t-=l.offsetY*i/p,r*=l.width/h,i*=l.height/p}const u=this.filmOffset;u!==0&&(s+=e*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};const Qh=-90,Jh=1;class Z3 extends Qn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new nr(Qh,Jh,e,t);r.layers=this.layers,this.add(r);const s=new nr(Qh,Jh,e,t);s.layers=this.layers,this.add(s);const l=new nr(Qh,Jh,e,t);l.layers=this.layers,this.add(l);const u=new nr(Qh,Jh,e,t);u.layers=this.layers,this.add(u);const h=new nr(Qh,Jh,e,t);h.layers=this.layers,this.add(h);const p=new nr(Qh,Jh,e,t);p.layers=this.layers,this.add(p)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,l,u,h]=t;for(const p of t)this.remove(p);if(e===Ns)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),l.up.set(0,0,1),l.lookAt(0,-1,0),u.up.set(0,1,0),u.lookAt(0,0,1),h.up.set(0,1,0),h.lookAt(0,0,-1);else if(e===Ap)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),l.up.set(0,0,-1),l.lookAt(0,-1,0),u.up.set(0,-1,0),u.lookAt(0,0,1),h.up.set(0,-1,0),h.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const p of t)this.add(p),p.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,l,u,h,p,g]=this.children,y=e.getRenderTarget(),b=e.getActiveCubeFace(),x=e.getActiveMipmapLevel(),E=e.xr.enabled;e.xr.enabled=!1;const A=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,l),e.setRenderTarget(i,2,r),e.render(t,u),e.setRenderTarget(i,3,r),e.render(t,h),e.setRenderTarget(i,4,r),e.render(t,p),i.texture.generateMipmaps=A,e.setRenderTarget(i,5,r),e.render(t,g),e.setRenderTarget(y,b,x),e.xr.enabled=E,i.texture.needsPMREMUpdate=!0}}class O0 extends $i{constructor(e=[],t=Ul,i,r,s,l,u,h,p,g){super(e,t,i,r,s,l,u,h,p,g),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class CE extends ai{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new O0(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #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 Od(5,5,5),s=new Ln({name:"CubemapFromEquirect",uniforms:Op(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Lr,blending:$r});s.uniforms.tEquirect.value=t;const l=new $n(r,s),u=t.minFilter;return t.minFilter===$o&&(t.minFilter=Kn),new Z3(1,10,this).update(e,l),t.minFilter=u,l.geometry.dispose(),l.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const s=e.getRenderTarget();for(let l=0;l<6;l++)e.setRenderTarget(this,l),e.clear(t,i,r);e.setRenderTarget(s)}}class bp extends Qn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const nU={type:"move"};class Lb{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new bp,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 bp,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Q,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Q),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new bp,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Q,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Q),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,l=null;const u=this._targetRay,h=this._grip,p=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(p&&e.hand){l=!0;for(const A of e.hand.values()){const T=t.getJointPose(A,i),M=this._getHandJoint(p,A);T!==null&&(M.matrix.fromArray(T.transform.matrix),M.matrix.decompose(M.position,M.rotation,M.scale),M.matrixWorldNeedsUpdate=!0,M.jointRadius=T.radius),M.visible=T!==null}const g=p.joints["index-finger-tip"],y=p.joints["thumb-tip"],b=g.position.distanceTo(y.position),x=.02,E=.005;p.inputState.pinching&&b>x+E?(p.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!p.inputState.pinching&&b<=x-E&&(p.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else h!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(h.matrix.fromArray(s.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,s.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(s.linearVelocity)):h.hasLinearVelocity=!1,s.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(s.angularVelocity)):h.hasAngularVelocity=!1));u!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),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(nU)))}return u!==null&&(u.visible=r!==null),h!==null&&(h.visible=s!==null),p!==null&&(p.visible=l!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new bp;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class p_{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Mt(e),this.density=t}clone(){return new p_(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class m_{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Mt(e),this.near=t,this.far=i}clone(){return new m_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ps extends Qn{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 ks,this.environmentIntensity=1,this.environmentRotation=new ks,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class g_{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=h0,this.updateRanges=[],this.version=0,this.uuid=zs()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;re.far||t.push({distance:h,point:Eg.clone(),uv:xs.getInterpolation(Eg,jy,wg,qy,kw,e1,Hw,new Be),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Yy(n,e,t,i,r,s){ip.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Tg.x=s*ip.x-r*ip.y,Tg.y=r*ip.x+s*ip.y):Tg.copy(ip),n.copy(e),n.x+=Tg.x,n.y+=Tg.y,n.applyMatrix4(K3)}const Zy=new Q,Vw=new Q;class J3 extends Qn{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i0){let i,r;for(i=1,r=t.length;i0){Zy.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(Zy);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Zy.setFromMatrixPosition(e.matrixWorld),Vw.setFromMatrixPosition(this.matrixWorld);const i=Zy.distanceTo(Vw)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r=l)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||oU.getNormalMatrix(e),r=this.coplanarPoint(i1).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Yf=new ua,lU=new Be(.5,.5),Jy=new Q;class Bp{constructor(e=new Tc,t=new Tc,i=new Tc,r=new Tc,s=new Tc,l=new Tc){this.planes=[e,t,i,r,s,l]}set(e,t,i,r,s,l){const u=this.planes;return u[0].copy(e),u[1].copy(t),u[2].copy(i),u[3].copy(r),u[4].copy(s),u[5].copy(l),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Ns,i=!1){const r=this.planes,s=e.elements,l=s[0],u=s[1],h=s[2],p=s[3],g=s[4],y=s[5],b=s[6],x=s[7],E=s[8],A=s[9],T=s[10],M=s[11],R=s[12],O=s[13],D=s[14],F=s[15];if(r[0].setComponents(p-l,x-g,M-E,F-R).normalize(),r[1].setComponents(p+l,x+g,M+E,F+R).normalize(),r[2].setComponents(p+u,x+y,M+A,F+O).normalize(),r[3].setComponents(p-u,x-y,M-A,F-O).normalize(),i)r[4].setComponents(h,b,T,D).normalize(),r[5].setComponents(p-h,x-b,M-T,F-D).normalize();else if(r[4].setComponents(p-h,x-b,M-T,F-D).normalize(),t===Ns)r[5].setComponents(p+h,x+b,M+T,F+D).normalize();else if(t===Ap)r[5].setComponents(h,b,T,D).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Yf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Yf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Yf)}intersectsSprite(e){Yf.center.set(0,0,0);const t=lU.distanceTo(e.center);return Yf.radius=.7071067811865476+t,Yf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Yf)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,Jy.y=r.normal.y>0?e.max.y:e.min.y,Jy.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Jy)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Cl=new rn,Rl=new Bp;class y_{constructor(){this.coordinateSystem=Ns}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const u=s[this.index];l.push(u),this.index++,u.start=e,u.count=t,u.z=i,u.index=r}reset(){this.list.length=0,this.index=0}}const gs=new rn,dU=new Mt(1,1,1),Kw=new Bp,hU=new y_,eb=new Ra,Zf=new ua,Rg=new Q,Qw=new Q,pU=new Q,a1=new fU,Ea=new $n,tb=[];function mU(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new si(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ra);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(r1),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=i):(r=this._instanceInfo.length,this._instanceInfo.push(i));const s=this._matricesTexture;gs.identity().toArray(s.image.data,r*16),s.needsUpdate=!0;const l=this._colorsTexture;return l&&(dU.toArray(l.image.data,r*4),l.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const l=e.getIndex();if(l!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=i===-1?l.count:i),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let h;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(r1),h=this._availableGeometryIds.shift(),s[h]=r):(h=this._geometryCount,this._geometryCount++,s.push(r)),this.setGeometryAt(h,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),l=t.getIndex(),u=this._geometryInfo[e];if(r&&l.count>u.reservedIndexCount||t.attributes.position.count>u.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const h=u.vertexStart,p=u.reservedVertexCount;u.vertexCount=t.getAttribute("position").count;for(const g in i.attributes){const y=t.getAttribute(g),b=i.getAttribute(g);mU(y,b,h);const x=y.itemSize;for(let E=y.count,A=p;E=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let r=0,s=i.length;ru).sort((l,u)=>i[l].vertexStart-i[u].vertexStart),s=this.geometry;for(let l=0,u=i.length;l=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const s=new Ra,l=i.index,u=i.attributes.position;for(let h=r.start,p=r.start+r.count;h=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const s=new ua;this.getBoundingBoxAt(e,eb),eb.getCenter(s.center);const l=i.index,u=i.attributes.position;let h=0;for(let p=r.start,g=r.start+r.count;pu.active);if(Math.max(...i.map(u=>u.vertexStart+u.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(h=>h.indexStart+h.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new dn,this._initializeGeometry(s));const l=this.geometry;s.index&&Kf(s.index.array,l.index.array);for(const u in s.attributes)Kf(s.attributes[u].array,l.attributes[u].array)}raycast(e,t){const i=this._instanceInfo,r=this._geometryInfo,s=this.matrixWorld,l=this.geometry;Ea.material=this.material,Ea.geometry.index=l.index,Ea.geometry.attributes=l.attributes,Ea.geometry.boundingBox===null&&(Ea.geometry.boundingBox=new Ra),Ea.geometry.boundingSphere===null&&(Ea.geometry.boundingSphere=new ua);for(let u=0,h=i.length;u({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const l=r.getIndex(),u=l===null?1:l.array.BYTES_PER_ELEMENT,h=this._instanceInfo,p=this._multiDrawStarts,g=this._multiDrawCounts,y=this._geometryInfo,b=this.perObjectFrustumCulled,x=this._indirectTexture,E=x.image.data,A=i.isArrayCamera?hU:Kw;b&&!i.isArrayCamera&&(gs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Kw.setFromProjectionMatrix(gs,i.coordinateSystem,i.reversedDepth));let T=0;if(this.sortObjects){gs.copy(this.matrixWorld).invert(),Rg.setFromMatrixPosition(i.matrixWorld).applyMatrix4(gs),Qw.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(gs);for(let O=0,D=h.length;O0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,l=r.length;si)return;s1.applyMatrix4(n.matrixWorld);const p=e.ray.origin.distanceTo(s1);if(!(pe.far))return{distance:p,point:eA.clone().applyMatrix4(n.matrixWorld),index:l,face:null,faceIndex:null,barycoord:null,object:n}}const tA=new Q,nA=new Q;class Hl extends ju{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,l=r.length;sr.far)return;s.push({distance:p,distanceToRay:Math.sqrt(u),point:h,index:e,face:null,faceIndex:null,barycoord:null,object:l})}}class aD extends $i{constructor(e,t,i,r,s=Kn,l=Kn,u,h,p){super(e,t,i,r,s,l,u,h,p),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const g=this;function y(){g.needsUpdate=!0,g._requestVideoFrameCallbackId=e.requestVideoFrameCallback(y)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(y))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class gU extends aD{constructor(e,t,i,r,s,l,u,h){super({},e,t,i,r,s,l,u,h),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class vU extends $i{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=jn,this.minFilter=jn,this.generateMipmaps=!1,this.needsUpdate=!0}}class b_ extends $i{constructor(e,t,i,r,s,l,u,h,p,g,y,b){super(null,l,u,h,p,g,r,s,y,b),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class yU extends b_{constructor(e,t,i,r,s,l){super(e,t,i,s,l),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=_s,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class bU extends b_{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Ul),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class xU extends $i{constructor(e,t,i,r,s,l,u,h,p){super(e,t,i,r,s,l,u,h,p),this.isCanvasTexture=!0,this.needsUpdate=!0}}class qu extends $i{constructor(e,t,i=Bs,r,s,l,u=jn,h=jn,p,g=zl,y=1){if(g!==zl&&g!==Dc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const b={width:e,height:t,depth:y};super(b,r,s,l,u,h,g,i,p),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Vu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class sD extends qu{constructor(e,t=Bs,i=Ul,r,s,l=jn,u=jn,h,p=zl){const g={width:e,height:e,depth:1},y=[g,g,g,g,g,g];super(e,e,t,i,r,s,l,u,h,p),this.image=y,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class IE extends $i{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class x_ extends dn{constructor(e=1,t=1,i=4,r=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:r,heightSegments:s},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),r=Math.max(3,Math.floor(r)),s=Math.max(1,Math.floor(s));const l=[],u=[],h=[],p=[],g=t/2,y=Math.PI/2*e,b=t,x=2*y+b,E=i*2+s,A=r+1,T=new Q,M=new Q;for(let R=0;R<=E;R++){let O=0,D=0,F=0,U=0;if(R<=i){const L=R/i,z=L*Math.PI/2;D=-g-e*Math.cos(z),F=e*Math.sin(z),U=-e*Math.cos(z),O=L*y}else if(R<=i+s){const L=(R-i)/s;D=-g+L*t,F=e,U=0,O=y+L*b}else{const L=(R-i-s)/i,z=L*Math.PI/2;D=g+e*Math.sin(z),F=e*Math.cos(z),U=e*Math.sin(z),O=y+b+L*y}const k=Math.max(0,Math.min(1,O/x));let H=0;R===0?H=.5/r:R===E&&(H=-.5/r);for(let L=0;L<=r;L++){const z=L/r,W=z*Math.PI*2,J=Math.sin(W),$=Math.cos(W);M.x=-F*$,M.y=D,M.z=F*J,u.push(M.x,M.y,M.z),T.set(-F*$,U,F*J),T.normalize(),h.push(T.x,T.y,T.z),p.push(z+H,k)}if(R>0){const L=(R-1)*A;for(let z=0;z0&&O(!0),t>0&&O(!1)),this.setIndex(g),this.setAttribute("position",new Nt(y,3)),this.setAttribute("normal",new Nt(b,3)),this.setAttribute("uv",new Nt(x,2));function R(){const D=new Q,F=new Q;let U=0;const k=(t-e)/i;for(let H=0;H<=s;H++){const L=[],z=H/s,W=z*(t-e)+e;for(let J=0;J<=r;J++){const $=J/r,oe=$*h+u,ne=Math.sin(oe),Y=Math.cos(oe);F.x=W*ne,F.y=-z*i+T,F.z=W*Y,y.push(F.x,F.y,F.z),D.set(ne,k,Y).normalize(),b.push(D.x,D.y,D.z),x.push($,1-z),L.push(E++)}A.push(L)}for(let H=0;H0||L!==0)&&(g.push(z,W,$),U+=3),(t>0||L!==s-1)&&(g.push(W,J,$),U+=3)}p.addGroup(M,U,0),M+=U}function O(D){const F=E,U=new Be,k=new Q;let H=0;const L=D===!0?e:t,z=D===!0?1:-1;for(let J=1;J<=r;J++)y.push(0,T*z,0),b.push(0,z,0),x.push(.5,.5),E++;const W=E;for(let J=0;J<=r;J++){const oe=J/r*h+u,ne=Math.cos(oe),Y=Math.sin(oe);k.x=L*Y,k.y=T*z,k.z=L*ne,y.push(k.x,k.y,k.z),b.push(0,z,0),U.x=ne*.5+.5,U.y=Y*.5*z+.5,x.push(U.x,U.y),E++}for(let J=0;J.9&&k<.1&&(O<.2&&(l[R+0]+=1),D<.2&&(l[R+2]+=1),F<.2&&(l[R+4]+=1))}}function b(R){s.push(R.x,R.y,R.z)}function x(R,O){const D=R*3;O.x=e[D+0],O.y=e[D+1],O.z=e[D+2]}function E(){const R=new Q,O=new Q,D=new Q,F=new Q,U=new Be,k=new Be,H=new Be;for(let L=0,z=0;L0)h=r-1;else{h=r;break}if(r=h,i[r]===l)return r/(s-1);const g=i[r],b=i[r+1]-g,x=(l-g)/b;return(r+x)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const l=this.getPoint(r),u=this.getPoint(s),h=t||(l.isVector2?new Be:new Q);return h.copy(u).sub(l).normalize(),h}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new Q,r=[],s=[],l=[],u=new Q,h=new rn;for(let x=0;x<=e;x++){const E=x/e;r[x]=this.getTangentAt(E,new Q)}s[0]=new Q,l[0]=new Q;let p=Number.MAX_VALUE;const g=Math.abs(r[0].x),y=Math.abs(r[0].y),b=Math.abs(r[0].z);g<=p&&(p=g,i.set(1,0,0)),y<=p&&(p=y,i.set(0,1,0)),b<=p&&i.set(0,0,1),u.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],u),l[0].crossVectors(r[0],s[0]);for(let x=1;x<=e;x++){if(s[x]=s[x-1].clone(),l[x]=l[x-1].clone(),u.crossVectors(r[x-1],r[x]),u.length()>Number.EPSILON){u.normalize();const E=Math.acos(ln(r[x-1].dot(r[x]),-1,1));s[x].applyMatrix4(h.makeRotationAxis(u,E))}l[x].crossVectors(r[x],s[x])}if(t===!0){let x=Math.acos(ln(s[0].dot(s[e]),-1,1));x/=e,r[0].dot(u.crossVectors(s[0],s[e]))>0&&(x=-x);for(let E=1;E<=e;E++)s[E].applyMatrix4(h.makeRotationAxis(r[E],x*E)),l[E].crossVectors(r[E],s[E])}return{tangents:r,normals:s,binormals:l}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class M_ extends Qo{constructor(e=0,t=0,i=1,r=1,s=0,l=Math.PI*2,u=!1,h=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=l,this.aClockwise=u,this.aRotation=h}getPoint(e,t=new Be){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const l=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(u)/s)+1)*s:h===0&&u===s-1&&(u=s-2,h=1);let p,g;this.closed||u>0?p=r[(u-1)%s]:(cb.subVectors(r[0],r[1]).add(r[0]),p=cb);const y=r[u%s],b=r[(u+1)%s];if(this.closed||u+2r.length-2?r.length-1:l+1],y=r[l>r.length-3?r.length-1:l+2];return i.set(aA(u,h.x,p.x,g.x,y.x),aA(u,h.y,p.y,g.y,y.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const l=r[s]-i,u=this.curves[s],h=u.getLength(),p=h===0?0:1-l/h;return u.getPointAt(p,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const y=p.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}this.curves.push(p);const g=p.getPoint(1);return this.currentPoint.copy(g),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class yd extends Dx{constructor(e){super(e),this.uuid=zs(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i80*t){u=n[0],h=n[1];let g=u,y=h;for(let b=t;bg&&(g=x),E>y&&(y=E)}p=Math.max(g-u,y-h),p=p!==0?32767/p:0}return g0(s,l,t,u,h,p,0),l}function hD(n,e,t,i,r){let s;if(r===WU(n,e,t,i)>0)for(let l=e;l=e;l-=i)s=sA(l/i|0,n[l],n[l+1],s);return s&&Pp(s,s.next)&&(y0(s),s=s.next),s}function Td(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Pp(t,t.next)||ir(t.prev,t,t.next)===0)){if(y0(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function g0(n,e,t,i,r,s,l){if(!n)return;!l&&s&&FU(n,i,r,s);let u=n;for(;n.prev!==n.next;){const h=n.prev,p=n.next;if(s?DU(n,i,r,s):RU(n)){e.push(h.i,n.i,p.i),y0(n),n=p.next,u=p.next;continue}if(n=p,n===u){l?l===1?(n=OU(Td(n),e),g0(n,e,t,i,r,s,2)):l===2&&IU(n,e,t,i,r,s):g0(Td(n),e,t,i,r,s,1);break}}}function RU(n){const e=n.prev,t=n,i=n.next;if(ir(e,t,i)>=0)return!1;const r=e.x,s=t.x,l=i.x,u=e.y,h=t.y,p=i.y,g=Math.min(r,s,l),y=Math.min(u,h,p),b=Math.max(r,s,l),x=Math.max(u,h,p);let E=i.next;for(;E!==e;){if(E.x>=g&&E.x<=b&&E.y>=y&&E.y<=x&&Vg(r,u,s,h,l,p,E.x,E.y)&&ir(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function DU(n,e,t,i){const r=n.prev,s=n,l=n.next;if(ir(r,s,l)>=0)return!1;const u=r.x,h=s.x,p=l.x,g=r.y,y=s.y,b=l.y,x=Math.min(u,h,p),E=Math.min(g,y,b),A=Math.max(u,h,p),T=Math.max(g,y,b),M=bM(x,E,e,t,i),R=bM(A,T,e,t,i);let O=n.prevZ,D=n.nextZ;for(;O&&O.z>=M&&D&&D.z<=R;){if(O.x>=x&&O.x<=A&&O.y>=E&&O.y<=T&&O!==r&&O!==l&&Vg(u,g,h,y,p,b,O.x,O.y)&&ir(O.prev,O,O.next)>=0||(O=O.prevZ,D.x>=x&&D.x<=A&&D.y>=E&&D.y<=T&&D!==r&&D!==l&&Vg(u,g,h,y,p,b,D.x,D.y)&&ir(D.prev,D,D.next)>=0))return!1;D=D.nextZ}for(;O&&O.z>=M;){if(O.x>=x&&O.x<=A&&O.y>=E&&O.y<=T&&O!==r&&O!==l&&Vg(u,g,h,y,p,b,O.x,O.y)&&ir(O.prev,O,O.next)>=0)return!1;O=O.prevZ}for(;D&&D.z<=R;){if(D.x>=x&&D.x<=A&&D.y>=E&&D.y<=T&&D!==r&&D!==l&&Vg(u,g,h,y,p,b,D.x,D.y)&&ir(D.prev,D,D.next)>=0)return!1;D=D.nextZ}return!0}function OU(n,e){let t=n;do{const i=t.prev,r=t.next.next;!Pp(i,r)&&mD(i,t,t.next,r)&&v0(i,r)&&v0(r,i)&&(e.push(i.i,t.i,r.i),y0(t),y0(t.next),t=n=r),t=t.next}while(t!==n);return Td(t)}function IU(n,e,t,i,r,s){let l=n;do{let u=l.next.next;for(;u!==l.prev;){if(l.i!==u.i&&HU(l,u)){let h=gD(l,u);l=Td(l,l.next),h=Td(h,h.next),g0(l,e,t,i,r,s,0),g0(h,e,t,i,r,s,0);return}u=u.next}l=l.next}while(l!==n)}function PU(n,e,t,i){const r=[];for(let s=0,l=e.length;s=t.next.y&&t.next.y!==t.y){const y=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(y<=i&&y>s&&(s=y,l=t.x=t.x&&t.x>=h&&i!==t.x&&pD(rl.x||t.x===l.x&&zU(l,t)))&&(l=t,g=y)}t=t.next}while(t!==u);return l}function zU(n,e){return ir(n.prev,n,e.prev)<0&&ir(e.next,n,n.next)<0}function FU(n,e,t,i){let r=n;do r.z===0&&(r.z=bM(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,BU(r)}function BU(n){let e,t=1;do{let i=n,r;n=null;let s=null;for(e=0;i;){e++;let l=i,u=0;for(let p=0;p0||h>0&&l;)u!==0&&(h===0||!l||i.z<=l.z)?(r=i,i=i.nextZ,u--):(r=l,l=l.nextZ,h--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;i=l}s.nextZ=null,t*=2}while(e>1);return n}function bM(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function kU(n){let e=n,t=n;do(e.x=(n-l)*(s-u)&&(n-l)*(i-u)>=(t-l)*(e-u)&&(t-l)*(s-u)>=(r-l)*(i-u)}function Vg(n,e,t,i,r,s,l,u){return!(n===l&&e===u)&&pD(n,e,t,i,r,s,l,u)}function HU(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!VU(n,e)&&(v0(n,e)&&v0(e,n)&&GU(n,e)&&(ir(n.prev,n,e.prev)||ir(n,e.prev,e))||Pp(n,e)&&ir(n.prev,n,n.next)>0&&ir(e.prev,e,e.next)>0)}function ir(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Pp(n,e){return n.x===e.x&&n.y===e.y}function mD(n,e,t,i){const r=fb(ir(n,e,t)),s=fb(ir(n,e,i)),l=fb(ir(t,i,n)),u=fb(ir(t,i,e));return!!(r!==s&&l!==u||r===0&&ub(n,t,e)||s===0&&ub(n,i,e)||l===0&&ub(t,n,i)||u===0&&ub(t,e,i))}function ub(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function fb(n){return n>0?1:n<0?-1:0}function VU(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&mD(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function v0(n,e){return ir(n.prev,n,n.next)<0?ir(n,e,n.next)>=0&&ir(n,n.prev,e)>=0:ir(n,e,n.prev)<0||ir(n,n.next,e)<0}function GU(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function gD(n,e){const t=xM(n.i,n.x,n.y),i=xM(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function sA(n,e,t,i){const r=xM(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function y0(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xM(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function WU(n,e,t,i){let r=0;for(let s=e,l=t-i;s2&&n[e-1].equals(n[0])&&n.pop()}function lA(n,e){for(let t=0;tNumber.EPSILON){const Ee=Math.sqrt(N),Te=Math.sqrt(tt*tt+V*V),pe=Ue.x-Ct/Ee,Et=Ue.y+dt/Ee,$e=Re.x-V/Te,lt=Re.y+tt/Te,Lt=(($e-pe)*V-(lt-Et)*tt)/(dt*V-Ct*tt);ft=pe+dt*Lt-He.x,Z=Et+Ct*Lt-He.y;const Ze=ft*ft+Z*Z;if(Ze<=2)return new Be(ft,Z);At=Math.sqrt(Ze/2)}else{let Ee=!1;dt>Number.EPSILON?tt>Number.EPSILON&&(Ee=!0):dt<-Number.EPSILON?tt<-Number.EPSILON&&(Ee=!0):Math.sign(Ct)===Math.sign(V)&&(Ee=!0),Ee?(ft=-Ct,Z=dt,At=Math.sqrt(N)):(ft=dt,Z=Ct,At=Math.sqrt(N/2))}return new Be(ft/At,Z/At)}const ge=[];for(let He=0,Ue=ne.length,Re=Ue-1,ft=He+1;He=0;He--){const Ue=He/T,Re=x*Math.cos(Ue*Math.PI/2),ft=E*Math.sin(Ue*Math.PI/2)+A;for(let Z=0,At=ne.length;Z=0;){const ft=Re;let Z=Re-1;Z<0&&(Z=He.length-1);for(let At=0,dt=g+T*2;At0)&&x.push(O,D,U),(M!==i-1||h0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class xD extends jr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Mt(16777215),this.specular=new Mt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nf,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ks,this.combine=R0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class _D extends jr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Mt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nf,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class HE extends jr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nf,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class SD extends jr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Mt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nf,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ks,this.combine=R0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class VE extends jr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=tf,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class GE extends jr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class MD extends jr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Mt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nf,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ED extends Ya{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function pd(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function TD(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function _M(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,l=0;l!==i;++s){const u=t[s]*e;for(let h=0;h!==e;++h)r[l++]=n[u+h]}return r}function WE(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let l=s[i];if(l!==void 0)if(Array.isArray(l))do l=s[i],l!==void 0&&(e.push(s.time),t.push(...l)),s=n[r++];while(s!==void 0);else if(l.toArray!==void 0)do l=s[i],l!==void 0&&(e.push(s.time),l.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do l=s[i],l!==void 0&&(e.push(s.time),t.push(l)),s=n[r++];while(s!==void 0)}function YU(n,e,t,i,r=30){const s=n.clone();s.name=e;const l=[];for(let h=0;h=i)){y.push(p.times[x]);for(let A=0;As.tracks[h].times[0]&&(u=s.tracks[h].times[0]);for(let h=0;h=u.times[E]){const M=E*y+g,R=M+y-g;A=u.values.slice(M,R)}else{const M=u.createInterpolant(),R=g,O=y-g;M.evaluate(s),A=M.resultBuffer.slice(R,O)}h==="quaternion"&&new Ca().fromArray(A).normalize().conjugate().toArray(A);const T=p.times.length;for(let M=0;M=s)){const u=t[1];e=s)break t}l=i,i=0;break n}break e}for(;i>>1;et;)--l;if(++l,s!==0||l!==r){s>=l&&(l=Math.max(l,1),s=l-1);const u=this.getValueSize();this.times=i.slice(s,l),this.values=this.values.slice(s*u,l*u)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Gt("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(Gt("KeyframeTrack: Track is empty.",this),e=!1);let l=null;for(let u=0;u!==s;u++){const h=i[u];if(typeof h=="number"&&isNaN(h)){Gt("KeyframeTrack: Time is not a valid number.",this,u,h),e=!1;break}if(l!==null&&l>h){Gt("KeyframeTrack: Out of order keys.",this,u,h,l),e=!1;break}l=h}if(r!==void 0&&W3(r))for(let u=0,h=r.length;u!==h;++u){const p=r[u];if(isNaN(p)){Gt("KeyframeTrack: Value is not a valid number.",this,u,p),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Pb,s=e.length-1;let l=1;for(let u=1;u0){e[l]=e[s];for(let u=s*i,h=l*i,p=0;p!==i;++p)t[h+p]=t[u+p];++l}return l!==e.length?(this.times=e.slice(0,l),this.values=t.slice(0,l*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}yo.prototype.ValueTypeName="";yo.prototype.TimeBufferType=Float32Array;yo.prototype.ValueBufferType=Float32Array;yo.prototype.DefaultInterpolation=wx;class Id extends yo{constructor(e,t,i){super(e,t,i)}}Id.prototype.ValueTypeName="bool";Id.prototype.ValueBufferType=Array;Id.prototype.DefaultInterpolation=u0;Id.prototype.InterpolantFactoryMethodLinear=void 0;Id.prototype.InterpolantFactoryMethodSmooth=void 0;class $E extends yo{constructor(e,t,i,r){super(e,t,i,r)}}$E.prototype.ValueTypeName="color";class b0 extends yo{constructor(e,t,i,r){super(e,t,i,r)}}b0.prototype.ValueTypeName="number";class CD extends U0{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,l=this.sampleValues,u=this.valueSize,h=(i-t)/(r-t);let p=e*u;for(let g=p+u;p!==g;p+=4)Ca.slerpFlat(s,0,l,p-u,l,p,h);return s}}class z0 extends yo{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new CD(this.times,this.values,this.getValueSize(),e)}}z0.prototype.ValueTypeName="quaternion";z0.prototype.InterpolantFactoryMethodSmooth=void 0;class Pd extends yo{constructor(e,t,i){super(e,t,i)}}Pd.prototype.ValueTypeName="string";Pd.prototype.ValueBufferType=Array;Pd.prototype.DefaultInterpolation=u0;Pd.prototype.InterpolantFactoryMethodLinear=void 0;Pd.prototype.InterpolantFactoryMethodSmooth=void 0;class x0 extends yo{constructor(e,t,i,r){super(e,t,i,r)}}x0.prototype.ValueTypeName="vector";class _0{constructor(e="",t=-1,i=[],r=l_){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=zs(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let l=0,u=i.length;l!==u;++l)t.push(JU(i[l]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,l=i.length;s!==l;++s)t.push(yo.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,l=[];for(let u=0;u1){const y=g[1];let b=r[y];b||(r[y]=b=[]),b.push(p)}}const l=[];for(const u in r)l.push(this.CreateFromMorphTargetSequence(u,r[u],t,i));return l}static parseAnimation(e,t){if(Rt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Gt("AnimationClip: No animation in JSONLoader data."),null;const i=function(y,b,x,E,A){if(x.length!==0){const T=[],M=[];WE(x,T,M,E),T.length!==0&&A.push(new y(b,T,M))}},r=[],s=e.name||"default",l=e.fps||30,u=e.blendMode;let h=e.length||-1;const p=e.hierarchy||[];for(let y=0;y{t&&t(s),this.manager.itemEnd(e)},0),s;if(Mc[e]!==void 0){Mc[e].push({onLoad:t,onProgress:i,onError:r});return}Mc[e]=[],Mc[e].push({onLoad:t,onProgress:i,onError:r});const l=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),u=this.mimeType,h=this.responseType;fetch(l).then(p=>{if(p.status===200||p.status===0){if(p.status===0&&Rt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||p.body===void 0||p.body.getReader===void 0)return p;const g=Mc[e],y=p.body.getReader(),b=p.headers.get("X-File-Size")||p.headers.get("Content-Length"),x=b?parseInt(b):0,E=x!==0;let A=0;const T=new ReadableStream({start(M){R();function R(){y.read().then(({done:O,value:D})=>{if(O)M.close();else{A+=D.byteLength;const F=new ProgressEvent("progress",{lengthComputable:E,loaded:A,total:x});for(let U=0,k=g.length;U{M.error(O)})}}});return new Response(T)}else throw new ez(`fetch for "${p.url}" responded with ${p.status}: ${p.statusText}`,p)}).then(p=>{switch(h){case"arraybuffer":return p.arrayBuffer();case"blob":return p.blob();case"document":return p.text().then(g=>new DOMParser().parseFromString(g,u));case"json":return p.json();default:if(u==="")return p.text();{const y=/charset="?([^;"\s]*)"?/i.exec(u),b=y&&y[1]?y[1].toLowerCase():void 0,x=new TextDecoder(b);return p.arrayBuffer().then(E=>x.decode(E))}}}).then(p=>{Il.add(`file:${e}`,p);const g=Mc[e];delete Mc[e];for(let y=0,b=g.length;y{const g=Mc[e];if(g===void 0)throw this.manager.itemError(e),p;delete Mc[e];for(let y=0,b=g.length;y{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class tz extends Ms{constructor(e){super(e)}load(e,t,i,r){const s=this,l=new Lc(this.manager);l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(u){try{t(s.parse(JSON.parse(u)))}catch(h){r?r(h):Gt(h),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const l=e.uniforms[s];switch(r.uniforms[s]={},l.type){case"t":r.uniforms[s].value=i(l.value);break;case"c":r.uniforms[s].value=new Mt().setHex(l.value);break;case"v2":r.uniforms[s].value=new Be().fromArray(l.value);break;case"v3":r.uniforms[s].value=new Q().fromArray(l.value);break;case"v4":r.uniforms[s].value=new fi().fromArray(l.value);break;case"m3":r.uniforms[s].value=new vn().fromArray(l.value);break;case"m4":r.uniforms[s].value=new rn().fromArray(l.value);break;default:r.uniforms[s].value=l.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Be().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Be().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return P_.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:yD,SpriteMaterial:RE,RawShaderMaterial:BE,ShaderMaterial:Ln,PointsMaterial:OE,MeshPhysicalMaterial:bD,MeshStandardMaterial:kE,MeshPhongMaterial:xD,MeshToonMaterial:_D,MeshNormalMaterial:HE,MeshLambertMaterial:SD,MeshDepthMaterial:VE,MeshDistanceMaterial:GE,MeshBasicMaterial:rf,MeshMatcapMaterial:MD,LineDashedMaterial:ED,LineBasicMaterial:Ya,Material:jr};return new t[e]}}class SM{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class FD extends dn{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class BD extends Ms{constructor(e){super(e)}load(e,t,i,r){const s=this,l=new Lc(s.manager);l.setPath(s.path),l.setRequestHeader(s.requestHeader),l.setWithCredentials(s.withCredentials),l.load(e,function(u){try{t(s.parse(JSON.parse(u)))}catch(h){r?r(h):Gt(h),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(x,E){if(t[E]!==void 0)return t[E];const T=x.interleavedBuffers[E],M=s(x,T.buffer),R=yp(T.type,M),O=new g_(R,T.stride);return O.uuid=T.uuid,t[E]=O,O}function s(x,E){if(i[E]!==void 0)return i[E];const T=x.arrayBuffers[E],M=new Uint32Array(T).buffer;return i[E]=M,M}const l=e.isInstancedBufferGeometry?new FD:new dn,u=e.data.index;if(u!==void 0){const x=yp(u.type,u.array);l.setIndex(new si(x,1))}const h=e.data.attributes;for(const x in h){const E=h[x];let A;if(E.isInterleavedBufferAttribute){const T=r(e.data,E.data);A=new Ed(T,E.itemSize,E.offset,E.normalized)}else{const T=yp(E.type,E.array),M=E.isInstancedBufferAttribute?Ip:si;A=new M(T,E.itemSize,E.normalized)}E.name!==void 0&&(A.name=E.name),E.usage!==void 0&&A.setUsage(E.usage),l.setAttribute(x,A)}const p=e.data.morphAttributes;if(p)for(const x in p){const E=p[x],A=[];for(let T=0,M=E.length;T0){const h=new jE(t);s=new S0(h),s.setCrossOrigin(this.crossOrigin);for(let p=0,g=e.length;p0){r=new S0(this.manager),r.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l{let M=null,R=null;return T.boundingBox!==void 0&&(M=new Ra().fromJSON(T.boundingBox)),T.boundingSphere!==void 0&&(R=new ua().fromJSON(T.boundingSphere)),{...T,boundingBox:M,boundingSphere:R}}),l._instanceInfo=e.instanceInfo,l._availableInstanceIds=e._availableInstanceIds,l._availableGeometryIds=e._availableGeometryIds,l._nextIndexStart=e.nextIndexStart,l._nextVertexStart=e.nextVertexStart,l._geometryCount=e.geometryCount,l._maxInstanceCount=e.maxInstanceCount,l._maxVertexCount=e.maxVertexCount,l._maxIndexCount=e.maxIndexCount,l._geometryInitialized=e.geometryInitialized,l._matricesTexture=p(e.matricesTexture.uuid),l._indirectTexture=p(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(l._colorsTexture=p(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(l.boundingSphere=new ua().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(l.boundingBox=new Ra().fromJSON(e.boundingBox));break;case"LOD":l=new J3;break;case"Line":l=new ju(u(e.geometry),h(e.material));break;case"LineLoop":l=new iD(u(e.geometry),h(e.material));break;case"LineSegments":l=new Hl(u(e.geometry),h(e.material));break;case"PointCloud":case"Points":l=new rD(u(e.geometry),h(e.material));break;case"Sprite":l=new Q3(h(e.material));break;case"Group":l=new bp;break;case"Bone":l=new DE;break;default:l=new Qn}if(l.uuid=e.uuid,e.name!==void 0&&(l.name=e.name),e.matrix!==void 0?(l.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(l.matrixAutoUpdate=e.matrixAutoUpdate),l.matrixAutoUpdate&&l.matrix.decompose(l.position,l.quaternion,l.scale)):(e.position!==void 0&&l.position.fromArray(e.position),e.rotation!==void 0&&l.rotation.fromArray(e.rotation),e.quaternion!==void 0&&l.quaternion.fromArray(e.quaternion),e.scale!==void 0&&l.scale.fromArray(e.scale)),e.up!==void 0&&l.up.fromArray(e.up),e.castShadow!==void 0&&(l.castShadow=e.castShadow),e.receiveShadow!==void 0&&(l.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(l.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(l.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(l.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(l.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&l.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(l.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(l.visible=e.visible),e.frustumCulled!==void 0&&(l.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(l.renderOrder=e.renderOrder),e.userData!==void 0&&(l.userData=e.userData),e.layers!==void 0&&(l.layers.mask=e.layers),e.children!==void 0){const b=e.children;for(let x=0;x"u"&&Rt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Rt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,l=Il.get(`image-bitmap:${e}`);if(l!==void 0){if(s.manager.itemStart(e),l.then){l.then(p=>{if(d1.has(l)===!0)r&&r(d1.get(l)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(p),s.manager.itemEnd(e),p});return}return setTimeout(function(){t&&t(l),s.manager.itemEnd(e)},0),l}const u={};u.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",u.headers=this.requestHeader,u.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const h=fetch(e,u).then(function(p){return p.blob()}).then(function(p){return createImageBitmap(p,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(p){return Il.add(`image-bitmap:${e}`,p),t&&t(p),s.manager.itemEnd(e),p}).catch(function(p){r&&r(p),d1.set(h,p),Il.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});Il.add(`image-bitmap:${e}`,h),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let db;class ZE{static getContext(){return db===void 0&&(db=new(window.AudioContext||window.webkitAudioContext)),db}static setContext(e){db=e}}class fz extends Ms{constructor(e){super(e)}load(e,t,i,r){const s=this,l=new Lc(this.manager);l.setResponseType("arraybuffer"),l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{const p=h.slice(0);ZE.getContext().decodeAudioData(p,function(y){t(y)}).catch(u)}catch(p){u(p)}},i,r);function u(h){r?r(h):Gt(h),s.manager.itemError(e)}}}const mA=new rn,gA=new rn,Qf=new rn;class dz{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new nr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new nr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Qf.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,l=t.near*Math.tan(vd*t.fov*.5)/t.zoom;let u,h;gA.elements[12]=-r,mA.elements[12]=r,u=-l*t.aspect+s,h=l*t.aspect+s,Qf.elements[0]=2*t.near/(h-u),Qf.elements[8]=(h+u)/(h-u),this.cameraL.projectionMatrix.copy(Qf),u=-l*t.aspect-s,h=l*t.aspect-s,Qf.elements[0]=2*t.near/(h-u),Qf.elements[8]=(h+u)/(h-u),this.cameraR.projectionMatrix.copy(Qf)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(gA),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(mA)}}class kD extends nr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class KE{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Jf=new Q,h1=new Ca,hz=new Q,ed=new Q,td=new Q;class pz extends Qn{constructor(){super(),this.type="AudioListener",this.context=ZE.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new KE}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Jf,h1,hz),ed.set(0,0,-1).applyQuaternion(h1),td.set(0,1,0).applyQuaternion(h1),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Jf.x,i),t.positionY.linearRampToValueAtTime(Jf.y,i),t.positionZ.linearRampToValueAtTime(Jf.z,i),t.forwardX.linearRampToValueAtTime(ed.x,i),t.forwardY.linearRampToValueAtTime(ed.y,i),t.forwardZ.linearRampToValueAtTime(ed.z,i),t.upX.linearRampToValueAtTime(td.x,i),t.upY.linearRampToValueAtTime(td.y,i),t.upZ.linearRampToValueAtTime(td.z,i)}else t.setPosition(Jf.x,Jf.y,Jf.z),t.setOrientation(ed.x,ed.y,ed.z,td.x,td.y,td.z)}}class HD extends Qn{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){Rt("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){Rt("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){Rt("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){Rt("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let h=t,p=t+t;h!==p;++h)if(i[h]!==i[h+t]){u.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,l=r;s!==l;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let l=0;l!==s;++l)e[t+l]=e[i+l]}_slerp(e,t,i,r){Ca.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const l=this._workIndex*s;Ca.multiplyQuaternionsFlat(e,l,e,t,e,i),Ca.slerpFlat(e,t,e,t,e,l,r)}_lerp(e,t,i,r,s){const l=1-r;for(let u=0;u!==s;++u){const h=t+u;e[h]=e[h]*l+e[i+u]*r}}_lerpAdditive(e,t,i,r,s){for(let l=0;l!==s;++l){const u=t+l;e[u]=e[u]+e[i+l]*r}}}const QE="\\[\\]\\.:\\/",yz=new RegExp("["+QE+"]","g"),JE="[^"+QE+"]",bz="[^"+QE.replace("\\.","")+"]",xz=/((?:WC+[\/:])*)/.source.replace("WC",JE),_z=/(WCOD+)?/.source.replace("WCOD",bz),Sz=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",JE),Mz=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",JE),Ez=new RegExp("^"+xz+_z+Sz+Mz+"$"),Tz=["material","materials","bones","map"];class wz{constructor(e,t,i){const r=i||Yn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Yn{constructor(e,t,i){this.path=t,this.parsedPath=i||Yn.parseTrackName(t),this.node=Yn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Yn.Composite(e,t,i):new Yn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(yz,"")}static parseTrackName(e){const t=Ez.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);Tz.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let l=0;l=s){const y=s++,b=e[y];t[b.uuid]=g,e[g]=b,t[p]=y,e[y]=h;for(let x=0,E=r;x!==E;++x){const A=i[x],T=A[y],M=A[g];A[g]=T,A[y]=M}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,l=e.length;for(let u=0,h=arguments.length;u!==h;++u){const p=arguments[u],g=p.uuid,y=t[g];if(y!==void 0)if(delete t[g],y0&&(t[x.uuid]=y),e[y]=x,e.pop();for(let E=0,A=r;E!==A;++E){const T=i[E];T[y]=T[b],T.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const l=this._paths,u=this._parsedPaths,h=this._objects,p=h.length,g=this.nCachedObjects_,y=new Array(p);r=s.length,i[e]=r,l.push(e),u.push(t),s.push(y);for(let b=g,x=h.length;b!==x;++b){const E=h[b];y[b]=new Yn(E,e,t)}return y}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,l=this._bindings,u=l.length-1,h=l[u],p=e[u];t[p]=i,l[i]=h,l.pop(),s[i]=s[u],s.pop(),r[i]=r[u],r.pop()}}}class GD{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,l=s.length,u=new Array(l),h={endingStart:dd,endingEnd:dd};for(let p=0;p!==l;++p){const g=s[p].createInterpolant(null);u[p]=g,g.settings=h}this._interpolantSettings=h,this._interpolants=u,this._propertyBindings=new Array(l),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=L3,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const r=this._clip.duration,s=e._clip.duration,l=s/r,u=r/s;e.warp(1,l,t),this.warp(u,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,l=this.timeScale;let u=this._timeScaleInterpolant;u===null&&(u=r._lendControlInterpolant(),this._timeScaleInterpolant=u);const h=u.parameterPositions,p=u.sampleValues;return h[0]=s,h[1]=s+i,p[0]=e/l,p[1]=t/l,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const h=(e-s)*i;h<0||i===0?t=0:(this._startTime=null,t=i*h)}t*=this._updateTimeScale(e);const l=this._updateTime(t),u=this._updateWeight(e);if(u>0){const h=this._interpolants,p=this._propertyBindings;switch(this.blendMode){case ME:for(let g=0,y=h.length;g!==y;++g)h[g].evaluate(l),p[g].accumulateAdditive(u);break;case l_:default:for(let g=0,y=h.length;g!==y;++g)h[g].evaluate(l),p[g].accumulate(r,u)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const l=i===N3;if(e===0)return s===-1?r:l&&(s&1)===1?t-r:r;if(i===P3){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,l)):this._setEndings(this.repetitions===0,!0,l)),r>=t||r<0){const u=Math.floor(r/t);r-=t*u,s+=Math.abs(u);const h=this.repetitions-s;if(h<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(h===1){const p=e<0;this._setEndings(p,!p,l)}else this._setEndings(!1,!1,l);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:u})}}else this.time=r;if(l&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=hd,r.endingEnd=hd):(e?r.endingStart=this.zeroSlopeAtStart?hd:dd:r.endingStart=f0,t?r.endingEnd=this.zeroSlopeAtEnd?hd:dd:r.endingEnd=f0)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let l=this._weightInterpolant;l===null&&(l=r._lendControlInterpolant(),this._weightInterpolant=l);const u=l.parameterPositions,h=l.sampleValues;return u[0]=s,h[0]=t,u[1]=s+e,h[1]=i,this}}const Cz=new Float32Array(1);class Rz extends Hs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,l=e._propertyBindings,u=e._interpolants,h=i.uuid,p=this._bindingsByRootAndName;let g=p[h];g===void 0&&(g={},p[h]=g);for(let y=0;y!==s;++y){const b=r[y],x=b.name;let E=g[x];if(E!==void 0)++E.referenceCount,l[y]=E;else{if(E=l[y],E!==void 0){E._cacheIndex===null&&(++E.referenceCount,this._addInactiveBinding(E,h,x));continue}const A=t&&t._propertyBindings[y].binding.parsedPath;E=new VD(Yn.create(i,x,A),b.ValueTypeName,b.getValueSize()),++E.referenceCount,this._addInactiveBinding(E,h,x),l[y]=E}u[y].resultBuffer=E.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),l=this._accuIndex^=1;for(let p=0;p!==i;++p)t[p]._update(r,e,s,l);const u=this._bindings,h=this._nActiveBindings;for(let p=0;p!==h;++p)u[p].apply(l);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,xA).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const _A=new Q,hb=new Q,sp=new Q,op=new Q,p1=new Q,Bz=new Q,kz=new Q;class Hz{constructor(e=new Q,t=new Q){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){_A.subVectors(e,this.start),hb.subVectors(this.end,this.start);const i=hb.dot(hb);let s=hb.dot(_A)/i;return t&&(s=ln(s,0,1)),s}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=Bz,i=kz){const r=10000000000000001e-32;let s,l;const u=this.start,h=e.start,p=this.end,g=e.end;sp.subVectors(p,u),op.subVectors(g,h),p1.subVectors(u,h);const y=sp.dot(sp),b=op.dot(op),x=op.dot(p1);if(y<=r&&b<=r)return t.copy(u),i.copy(h),t.sub(i),t.dot(t);if(y<=r)s=0,l=x/b,l=ln(l,0,1);else{const E=sp.dot(p1);if(b<=r)l=0,s=ln(-E/y,0,1);else{const A=sp.dot(op),T=y*b-A*A;T!==0?s=ln((A*x-E*b)/T,0,1):s=0,l=(A*s+x)/b,l<0?(l=0,s=ln(-E/y,0,1)):l>1&&(l=1,s=ln((A-E)/y,0,1))}}return t.copy(u).add(sp.multiplyScalar(s)),i.copy(h).add(op.multiplyScalar(l)),t.sub(i),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const SA=new Q;class Vz extends Qn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new dn,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let l=0,u=1,h=32;l1)for(let y=0;y.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{AA.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(AA,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class tF extends Hl{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new dn;r.setAttribute("position",new Nt(t,3)),r.setAttribute("color",new Nt(i,3));const s=new Ya({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new Mt,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class nF{constructor(){this.type="ShapePath",this.color=new Mt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Dx,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,l){return this.currentPath.bezierCurveTo(e,t,i,r,s,l),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(M){const R=[];for(let O=0,D=M.length;ONumber.EPSILON){if(z<0&&(k=R[U],L=-L,H=R[F],z=-z),M.yH.y)continue;if(M.y===k.y){if(M.x===k.x)return!0}else{const W=z*(M.x-k.x)-L*(M.y-k.y);if(W===0)return!0;if(W<0)continue;D=!D}}else{if(M.y!==k.y)continue;if(H.x<=M.x&&M.x<=k.x||k.x<=M.x&&M.x<=H.x)return!0}}return D}const r=jo.isClockWise,s=this.subPaths;if(s.length===0)return[];let l,u,h;const p=[];if(s.length===1)return u=s[0],h=new yd,h.curves=u.curves,p.push(h),p;let g=!r(s[0].getPoints());g=e?!g:g;const y=[],b=[];let x=[],E=0,A;b[E]=void 0,x[E]=[];for(let M=0,R=s.length;M1){let M=!1,R=0;for(let O=0,D=b.length;O0&&M===!1&&(x=y)}let T;for(let M=0,R=b.length;Me?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function aF(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function sF(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function TM(n,e,t,i){const r=oF(i);switch(t){case _E:return n*e;case Hu:return n*e/r.components*r.byteLength;case D0:return n*e/r.components*r.byteLength;case Md:return n*e*2/r.components*r.byteLength;case s_:return n*e*2/r.components*r.byteLength;case SE:return n*e*3/r.components*r.byteLength;case ca:return n*e*4/r.components*r.byteLength;case o_:return n*e*4/r.components*r.byteLength;case jg:case qg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Yg:case Zg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Yb:case Kb:return Math.max(n,16)*Math.max(e,8)/4;case qb:case Zb:return Math.max(n,8)*Math.max(e,8)/2;case Qb:case Jb:case tx:case nx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ex:case ix:case rx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ax:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case sx:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case ox:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case lx:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case cx:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case ux:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case fx:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case dx:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case hx:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case px:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case mx:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case gx:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case vx:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case yx:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case bx:case xx:case _x:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Sx:case Mx:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Ex:case Tx:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function oF(n){switch(n){case fr:case vE:return{byteLength:1,components:1};case wp:case yE:case vo:return{byteLength:2,components:1};case r_:case a_:return{byteLength:2,components:4};case Bs:case i_:case xr:return{byteLength:4,components:1};case bE:case xE:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}class lF{static contain(e,t){return rF(e,t)}static cover(e,t){return aF(e,t)}static fill(e){return sF(e)}static getByteLength(e,t,i,r){return TM(e,t,i,r)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Rd}}));typeof window<"u"&&(window.__THREE__?Rt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Rd);function $D(){let n=null,e=!1,t=null,i=null;function r(s,l){t(s,l),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function cF(n){const e=new WeakMap;function t(u,h){const p=u.array,g=u.usage,y=p.byteLength,b=n.createBuffer();n.bindBuffer(h,b),n.bufferData(h,p,g),u.onUploadCallback();let x;if(p instanceof Float32Array)x=n.FLOAT;else if(typeof Float16Array<"u"&&p instanceof Float16Array)x=n.HALF_FLOAT;else if(p instanceof Uint16Array)u.isFloat16BufferAttribute?x=n.HALF_FLOAT:x=n.UNSIGNED_SHORT;else if(p instanceof Int16Array)x=n.SHORT;else if(p instanceof Uint32Array)x=n.UNSIGNED_INT;else if(p instanceof Int32Array)x=n.INT;else if(p instanceof Int8Array)x=n.BYTE;else if(p instanceof Uint8Array)x=n.UNSIGNED_BYTE;else if(p instanceof Uint8ClampedArray)x=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+p);return{buffer:b,type:x,bytesPerElement:p.BYTES_PER_ELEMENT,version:u.version,size:y}}function i(u,h,p){const g=h.array,y=h.updateRanges;if(n.bindBuffer(p,u),y.length===0)n.bufferSubData(p,0,g);else{y.sort((x,E)=>x.start-E.start);let b=0;for(let x=1;x 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`,wF=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,AF=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,CF=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,RF=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,DF=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,OF=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,IF=`#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`,PF=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,LF=`#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`,NF=`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`,UF=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,zF=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,FF=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,BF=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,kF="gl_FragColor = linearToOutputTexel( gl_FragColor );",HF=`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 ); }`,VF=`#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`,GF=`#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`,WF=`#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`,XF=`#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`,$F=`#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`,jF=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,qF=`#ifdef USE_FOG varying float vFogDepth; #endif`,YF=`#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`,ZF=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,KF=`#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 }`,QF=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,JF=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,eB=`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`,tB=`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`,nB=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,iB=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,rB=`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`,aB=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,sB=`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`,oB=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = 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 = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = vec3( 0.04 ); material.specularColorBlended = mix( material.specularColor, 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.0001, 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`,lB=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; vec3 specularColor; vec3 specularColorBlended; float roughness; float metalness; 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; vec3 iridescenceFresnelDielectric; vec3 iridescenceFresnelMetallic; #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 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.specularColorBlended; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float rInv = 1.0 / ( roughness + 0.1 ); float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; float DG = exp( a * dotNV + b ); return saturate( DG ); } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; 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 float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; float Ess_V = dfgV.x + dfgV.y; float Ess_L = dfgL.x + dfgL.y; float Ems_V = 1.0 - Ess_V; float Ems_L = 1.0 - Ess_L; vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); float compensationFactor = Ems_V * Ems_L; vec3 multiScatter = Fms * compensationFactor; return singleScatter + multiScatter; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseContribution * 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 ); float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); irradiance *= sheenEnergyComp; #endif reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); } 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 ) { vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; diffuse *= sheenEnergyComp; #endif reflectedLight.indirectDiffuse += diffuse; } 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 ) * RECIPROCAL_PI; #endif vec3 singleScatteringDielectric = vec3( 0.0 ); vec3 multiScatteringDielectric = vec3( 0.0 ); vec3 singleScatteringMetallic = vec3( 0.0 ); vec3 multiScatteringMetallic = vec3( 0.0 ); #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #endif vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; vec3 indirectSpecular = radiance * singleScattering; indirectSpecular += multiScattering * cosineWeightedIrradiance; vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; indirectSpecular *= sheenEnergyComp; indirectDiffuse *= sheenEnergyComp; #endif reflectedLight.indirectSpecular += indirectSpecular; reflectedLight.indirectDiffuse += indirectDiffuse; } #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 ); }`,cB=` 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.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); 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 ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 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`,uB=`#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`,fB=`#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`,dB=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,hB=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,pB=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,mB=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,gB=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,vB=`#ifdef USE_MAP uniform sampler2D map; #endif`,yB=`#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`,bB=`#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`,xB=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,_B=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,SB=`#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`,MB=`#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`,EB=`#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`,TB=`#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`,wB=`#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`,AB=`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;`,CB=`#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`,RB=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,DB=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,OB=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,IB=`#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`,PB=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,LB=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,NB=`#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`,UB=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,zB=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,FB=`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 ); }`,BB=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,kB=`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;`,HB=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,VB=`#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`,GB=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,WB=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,XB=`#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 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #else uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #endif 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 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #else uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #endif 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 #if defined( SHADOWMAP_TYPE_PCF ) uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #elif defined( SHADOWMAP_TYPE_BASIC ) uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #endif 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 #if defined( SHADOWMAP_TYPE_PCF ) float interleavedGradientNoise( vec2 position ) { return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); } vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { const float goldenAngle = 2.399963229728653; float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); float theta = float( sampleIndex ) * goldenAngle + phi; return vec2( cos( theta ), sin( theta ) ) * r; } #endif #if defined( SHADOWMAP_TYPE_PCF ) float getShadow( sampler2DShadow 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 ) { vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float radius = shadowRadius * texelSize.x; float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; shadow = ( texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_VSM ) 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 ) { vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; float mean = distribution.x; float variance = distribution.y * distribution.y; #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( mean, shadowCoord.z ); #else float hard_shadow = step( shadowCoord.z, mean ); #endif if ( hard_shadow == 1.0 ) { shadow = 1.0; } else { variance = max( variance, 0.0000001 ); float d = shadowCoord.z - mean; float p_max = variance / ( variance + d * d ); p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); shadow = max( hard_shadow, p_max ); } } return mix( 1.0, shadow, shadowIntensity ); } #else 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 ) { float depth = texture2D( shadowMap, shadowCoord.xy ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, shadowCoord.z ); #else shadow = step( shadowCoord.z, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; float texelSize = shadowRadius / shadowMapSize.x; vec3 absDir = abs( bd3D ); vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); tangent = normalize( cross( bd3D, tangent ) ); vec3 bitangent = cross( bd3D, tangent ); float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; shadow = ( texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_BASIC ) float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; float depth = textureCube( shadowMap, bd3D ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, dp ); #else shadow = step( dp, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #endif #endif`,$B=`#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`,jB=`#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`,qB=`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 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 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; }`,YB=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,ZB=`#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`,KB=`#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`,QB=`#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`,JB=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,e4=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,t4=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,n4=`#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; }`,i4=`#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.diffuseContribution, material.specularColorBlended, 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`,r4=`#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`,a4=`#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`,s4=`#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`,o4=`#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`,l4=`#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 c4=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,u4=`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 }`,f4=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,d4=`#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 }`,h4=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,p4=`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 }`,m4=`#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; }`,g4=`#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 #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,v4=`#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; }`,y4=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #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 = vec4( dist, 0.0, 0.0, 1.0 ); }`,b4=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,x4=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,_4=`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 }`,S4=`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 }`,M4=`#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 }`,E4=`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 }`,T4=`#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 }`,w4=`#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 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 }`,A4=`#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; }`,C4=`#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 }`,R4=`#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 }`,D4=`#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 void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,O4=`#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 }`,I4=`#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 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 }`,P4=`#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 }`,L4=`#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 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 outgoingLight = outgoingLight + 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 }`,N4=`#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 }`,U4=`#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 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 }`,z4=`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 }`,F4=`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 }`,B4=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,k4=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,H4=`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 }`,V4=`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 }`,En={alphahash_fragment:uF,alphahash_pars_fragment:fF,alphamap_fragment:dF,alphamap_pars_fragment:hF,alphatest_fragment:pF,alphatest_pars_fragment:mF,aomap_fragment:gF,aomap_pars_fragment:vF,batching_pars_vertex:yF,batching_vertex:bF,begin_vertex:xF,beginnormal_vertex:_F,bsdfs:SF,iridescence_fragment:MF,bumpmap_pars_fragment:EF,clipping_planes_fragment:TF,clipping_planes_pars_fragment:wF,clipping_planes_pars_vertex:AF,clipping_planes_vertex:CF,color_fragment:RF,color_pars_fragment:DF,color_pars_vertex:OF,color_vertex:IF,common:PF,cube_uv_reflection_fragment:LF,defaultnormal_vertex:NF,displacementmap_pars_vertex:UF,displacementmap_vertex:zF,emissivemap_fragment:FF,emissivemap_pars_fragment:BF,colorspace_fragment:kF,colorspace_pars_fragment:HF,envmap_fragment:VF,envmap_common_pars_fragment:GF,envmap_pars_fragment:WF,envmap_pars_vertex:XF,envmap_physical_pars_fragment:nB,envmap_vertex:$F,fog_vertex:jF,fog_pars_vertex:qF,fog_fragment:YF,fog_pars_fragment:ZF,gradientmap_pars_fragment:KF,lightmap_pars_fragment:QF,lights_lambert_fragment:JF,lights_lambert_pars_fragment:eB,lights_pars_begin:tB,lights_toon_fragment:iB,lights_toon_pars_fragment:rB,lights_phong_fragment:aB,lights_phong_pars_fragment:sB,lights_physical_fragment:oB,lights_physical_pars_fragment:lB,lights_fragment_begin:cB,lights_fragment_maps:uB,lights_fragment_end:fB,logdepthbuf_fragment:dB,logdepthbuf_pars_fragment:hB,logdepthbuf_pars_vertex:pB,logdepthbuf_vertex:mB,map_fragment:gB,map_pars_fragment:vB,map_particle_fragment:yB,map_particle_pars_fragment:bB,metalnessmap_fragment:xB,metalnessmap_pars_fragment:_B,morphinstance_vertex:SB,morphcolor_vertex:MB,morphnormal_vertex:EB,morphtarget_pars_vertex:TB,morphtarget_vertex:wB,normal_fragment_begin:AB,normal_fragment_maps:CB,normal_pars_fragment:RB,normal_pars_vertex:DB,normal_vertex:OB,normalmap_pars_fragment:IB,clearcoat_normal_fragment_begin:PB,clearcoat_normal_fragment_maps:LB,clearcoat_pars_fragment:NB,iridescence_pars_fragment:UB,opaque_fragment:zB,packing:FB,premultiplied_alpha_fragment:BB,project_vertex:kB,dithering_fragment:HB,dithering_pars_fragment:VB,roughnessmap_fragment:GB,roughnessmap_pars_fragment:WB,shadowmap_pars_fragment:XB,shadowmap_pars_vertex:$B,shadowmap_vertex:jB,shadowmask_pars_fragment:qB,skinbase_vertex:YB,skinning_pars_vertex:ZB,skinning_vertex:KB,skinnormal_vertex:QB,specularmap_fragment:JB,specularmap_pars_fragment:e4,tonemapping_fragment:t4,tonemapping_pars_fragment:n4,transmission_fragment:i4,transmission_pars_fragment:r4,uv_pars_fragment:a4,uv_pars_vertex:s4,uv_vertex:o4,worldpos_vertex:l4,background_vert:c4,background_frag:u4,backgroundCube_vert:f4,backgroundCube_frag:d4,cube_vert:h4,cube_frag:p4,depth_vert:m4,depth_frag:g4,distance_vert:v4,distance_frag:y4,equirect_vert:b4,equirect_frag:x4,linedashed_vert:_4,linedashed_frag:S4,meshbasic_vert:M4,meshbasic_frag:E4,meshlambert_vert:T4,meshlambert_frag:w4,meshmatcap_vert:A4,meshmatcap_frag:C4,meshnormal_vert:R4,meshnormal_frag:D4,meshphong_vert:O4,meshphong_frag:I4,meshphysical_vert:P4,meshphysical_frag:L4,meshtoon_vert:N4,meshtoon_frag:U4,points_vert:z4,points_frag:F4,shadow_vert:B4,shadow_frag:k4,sprite_vert:H4,sprite_frag:V4},Dt={common:{diffuse:{value:new Mt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new vn}},envmap:{envMap:{value:null},envMapRotation:{value:new vn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new vn},normalScale:{value:new Be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new vn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new vn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new vn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new vn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Mt(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 Mt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0},uvTransform:{value:new vn}},sprite:{diffuse:{value:new Mt(16777215)},opacity:{value:1},center:{value:new Be(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}}},Go={basic:{uniforms:Wa([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:En.meshbasic_vert,fragmentShader:En.meshbasic_frag},lambert:{uniforms:Wa([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Mt(0)}}]),vertexShader:En.meshlambert_vert,fragmentShader:En.meshlambert_frag},phong:{uniforms:Wa([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Mt(0)},specular:{value:new Mt(1118481)},shininess:{value:30}}]),vertexShader:En.meshphong_vert,fragmentShader:En.meshphong_frag},standard:{uniforms:Wa([Dt.common,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.roughnessmap,Dt.metalnessmap,Dt.fog,Dt.lights,{emissive:{value:new Mt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag},toon:{uniforms:Wa([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new Mt(0)}}]),vertexShader:En.meshtoon_vert,fragmentShader:En.meshtoon_frag},matcap:{uniforms:Wa([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:En.meshmatcap_vert,fragmentShader:En.meshmatcap_frag},points:{uniforms:Wa([Dt.points,Dt.fog]),vertexShader:En.points_vert,fragmentShader:En.points_frag},dashed:{uniforms:Wa([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:En.linedashed_vert,fragmentShader:En.linedashed_frag},depth:{uniforms:Wa([Dt.common,Dt.displacementmap]),vertexShader:En.depth_vert,fragmentShader:En.depth_frag},normal:{uniforms:Wa([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:En.meshnormal_vert,fragmentShader:En.meshnormal_frag},sprite:{uniforms:Wa([Dt.sprite,Dt.fog]),vertexShader:En.sprite_vert,fragmentShader:En.sprite_frag},background:{uniforms:{uvTransform:{value:new vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:En.background_vert,fragmentShader:En.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new vn}},vertexShader:En.backgroundCube_vert,fragmentShader:En.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:En.cube_vert,fragmentShader:En.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:En.equirect_vert,fragmentShader:En.equirect_frag},distance:{uniforms:Wa([Dt.common,Dt.displacementmap,{referencePosition:{value:new Q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:En.distance_vert,fragmentShader:En.distance_frag},shadow:{uniforms:Wa([Dt.lights,Dt.fog,{color:{value:new Mt(0)},opacity:{value:1}}]),vertexShader:En.shadow_vert,fragmentShader:En.shadow_frag}};Go.physical={uniforms:Wa([Go.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new vn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new vn},clearcoatNormalScale:{value:new Be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new vn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new vn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new vn},sheen:{value:0},sheenColor:{value:new Mt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new vn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new vn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new vn},transmissionSamplerSize:{value:new Be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new vn},attenuationDistance:{value:0},attenuationColor:{value:new Mt(0)},specularColor:{value:new Mt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new vn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new vn},anisotropyVector:{value:new Be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new vn}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag};const bb={r:0,b:0,g:0},rd=new ks,G4=new rn;function W4(n,e,t,i,r,s,l){const u=new Mt(0);let h=s===!0?0:1,p,g,y=null,b=0,x=null;function E(O){let D=O.isScene===!0?O.background:null;return D&&D.isTexture&&(D=(O.backgroundBlurriness>0?t:e).get(D)),D}function A(O){let D=!1;const F=E(O);F===null?M(u,h):F&&F.isColor&&(M(F,1),D=!0);const U=n.xr.getEnvironmentBlendMode();U==="additive"?i.buffers.color.setClear(0,0,0,1,l):U==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,l),(n.autoClear||D)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function T(O,D){const F=E(D);F&&(F.isCubeTexture||F.mapping===Fp)?(g===void 0&&(g=new $n(new Od(1,1,1),new Ln({name:"BackgroundCubeMaterial",uniforms:Op(Go.backgroundCube.uniforms),vertexShader:Go.backgroundCube.vertexShader,fragmentShader:Go.backgroundCube.fragmentShader,side:Lr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),g.geometry.deleteAttribute("normal"),g.geometry.deleteAttribute("uv"),g.onBeforeRender=function(U,k,H){this.matrixWorld.copyPosition(H.matrixWorld)},Object.defineProperty(g.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(g)),rd.copy(D.backgroundRotation),rd.x*=-1,rd.y*=-1,rd.z*=-1,F.isCubeTexture&&F.isRenderTargetTexture===!1&&(rd.y*=-1,rd.z*=-1),g.material.uniforms.envMap.value=F,g.material.uniforms.flipEnvMap.value=F.isCubeTexture&&F.isRenderTargetTexture===!1?-1:1,g.material.uniforms.backgroundBlurriness.value=D.backgroundBlurriness,g.material.uniforms.backgroundIntensity.value=D.backgroundIntensity,g.material.uniforms.backgroundRotation.value.setFromMatrix4(G4.makeRotationFromEuler(rd)),g.material.toneMapped=Hn.getTransfer(F.colorSpace)!==ui,(y!==F||b!==F.version||x!==n.toneMapping)&&(g.material.needsUpdate=!0,y=F,b=F.version,x=n.toneMapping),g.layers.enableAll(),O.unshift(g,g.geometry,g.material,0,0,null)):F&&F.isTexture&&(p===void 0&&(p=new $n(new Ic(2,2),new Ln({name:"BackgroundMaterial",uniforms:Op(Go.background.uniforms),vertexShader:Go.background.vertexShader,fragmentShader:Go.background.fragmentShader,side:Nl,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),Object.defineProperty(p.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(p)),p.material.uniforms.t2D.value=F,p.material.uniforms.backgroundIntensity.value=D.backgroundIntensity,p.material.toneMapped=Hn.getTransfer(F.colorSpace)!==ui,F.matrixAutoUpdate===!0&&F.updateMatrix(),p.material.uniforms.uvTransform.value.copy(F.matrix),(y!==F||b!==F.version||x!==n.toneMapping)&&(p.material.needsUpdate=!0,y=F,b=F.version,x=n.toneMapping),p.layers.enableAll(),O.unshift(p,p.geometry,p.material,0,0,null))}function M(O,D){O.getRGB(bb,q3(n)),i.buffers.color.setClear(bb.r,bb.g,bb.b,D,l)}function R(){g!==void 0&&(g.geometry.dispose(),g.material.dispose(),g=void 0),p!==void 0&&(p.geometry.dispose(),p.material.dispose(),p=void 0)}return{getClearColor:function(){return u},setClearColor:function(O,D=1){u.set(O),h=D,M(u,h)},getClearAlpha:function(){return h},setClearAlpha:function(O){h=O,M(u,h)},render:A,addToRenderList:T,dispose:R}}function X4(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=b(null);let s=r,l=!1;function u(z,W,J,$,oe){let ne=!1;const Y=y($,J,W);s!==Y&&(s=Y,p(s.object)),ne=x(z,$,J,oe),ne&&E(z,$,J,oe),oe!==null&&e.update(oe,n.ELEMENT_ARRAY_BUFFER),(ne||l)&&(l=!1,D(z,W,J,$),oe!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(oe).buffer))}function h(){return n.createVertexArray()}function p(z){return n.bindVertexArray(z)}function g(z){return n.deleteVertexArray(z)}function y(z,W,J){const $=J.wireframe===!0;let oe=i[z.id];oe===void 0&&(oe={},i[z.id]=oe);let ne=oe[W.id];ne===void 0&&(ne={},oe[W.id]=ne);let Y=ne[$];return Y===void 0&&(Y=b(h()),ne[$]=Y),Y}function b(z){const W=[],J=[],$=[];for(let oe=0;oe=0){const xe=oe[ie];let q=ne[ie];if(q===void 0&&(ie==="instanceMatrix"&&z.instanceMatrix&&(q=z.instanceMatrix),ie==="instanceColor"&&z.instanceColor&&(q=z.instanceColor)),xe===void 0||xe.attribute!==q||q&&xe.data!==q.data)return!0;Y++}return s.attributesNum!==Y||s.index!==$}function E(z,W,J,$){const oe={},ne=W.attributes;let Y=0;const K=J.getAttributes();for(const ie in K)if(K[ie].location>=0){let xe=ne[ie];xe===void 0&&(ie==="instanceMatrix"&&z.instanceMatrix&&(xe=z.instanceMatrix),ie==="instanceColor"&&z.instanceColor&&(xe=z.instanceColor));const q={};q.attribute=xe,xe&&xe.data&&(q.data=xe.data),oe[ie]=q,Y++}s.attributes=oe,s.attributesNum=Y,s.index=$}function A(){const z=s.newAttributes;for(let W=0,J=z.length;W=0){let ge=oe[K];if(ge===void 0&&(K==="instanceMatrix"&&z.instanceMatrix&&(ge=z.instanceMatrix),K==="instanceColor"&&z.instanceColor&&(ge=z.instanceColor)),ge!==void 0){const xe=ge.normalized,q=ge.itemSize,ce=e.get(ge);if(ce===void 0)continue;const Se=ce.buffer,Ge=ce.type,Ye=ce.bytesPerElement,ve=Ge===n.INT||Ge===n.UNSIGNED_INT||ge.gpuType===i_;if(ge.isInterleavedBufferAttribute){const Oe=ge.data,it=Oe.stride,gt=ge.offset;if(Oe.isInstancedInterleavedBuffer){for(let _t=0;_t0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";k="mediump"}return k==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let p=t.precision!==void 0?t.precision:"highp";const g=h(p);g!==p&&(Rt("WebGLRenderer:",p,"not supported, using",g,"instead."),p=g);const y=t.logarithmicDepthBuffer===!0,b=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),x=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),E=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),A=n.getParameter(n.MAX_TEXTURE_SIZE),T=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),M=n.getParameter(n.MAX_VERTEX_ATTRIBS),R=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),O=n.getParameter(n.MAX_VARYING_VECTORS),D=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),F=n.getParameter(n.MAX_SAMPLES),U=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:h,textureFormatReadable:l,textureTypeReadable:u,precision:p,logarithmicDepthBuffer:y,reversedDepthBuffer:b,maxTextures:x,maxVertexTextures:E,maxTextureSize:A,maxCubemapSize:T,maxAttributes:M,maxVertexUniforms:R,maxVaryings:O,maxFragmentUniforms:D,maxSamples:F,samples:U}}function q4(n){const e=this;let t=null,i=0,r=!1,s=!1;const l=new Tc,u=new vn,h={value:null,needsUpdate:!1};this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(y,b){const x=y.length!==0||b||i!==0||r;return r=b,i=y.length,x},this.beginShadows=function(){s=!0,g(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(y,b){t=g(y,b,0)},this.setState=function(y,b,x){const E=y.clippingPlanes,A=y.clipIntersection,T=y.clipShadows,M=n.get(y);if(!r||E===null||E.length===0||s&&!T)s?g(null):p();else{const R=s?0:i,O=R*4;let D=M.clippingState||null;h.value=D,D=g(E,b,O,x);for(let F=0;F!==O;++F)D[F]=t[F];M.clippingState=D,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=R}};function p(){h.value!==t&&(h.value=t,h.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function g(y,b,x,E){const A=y!==null?y.length:0;let T=null;if(A!==0){if(T=h.value,E!==!0||T===null){const M=x+A*4,R=b.matrixWorldInverse;u.getNormalMatrix(R),(T===null||T.length0){const p=new CE(h.height);return p.fromEquirectangularTexture(n,l),e.set(l,p),l.addEventListener("dispose",r),t(p.texture,l.mapping)}else return null}}return l}function r(l){const u=l.target;u.removeEventListener("dispose",r);const h=e.get(u);h!==void 0&&(e.delete(u),h.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}const Gu=4,CA=[.125,.215,.35,.446,.526,.582],ud=20,Z4=256,Og=new qo,RA=new Mt;let v1=null,y1=0,b1=0,x1=!1;const K4=new Q;class wM{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,s={}){const{size:l=256,position:u=K4}=s;v1=this._renderer.getRenderTarget(),y1=this._renderer.getActiveCubeFace(),b1=this._renderer.getActiveMipmapLevel(),x1=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(l);const h=this._allocateTargets();return h.depthBuffer=!0,this._sceneToCubeUV(e,i,r,h,u),t>0&&this._blur(h,0,0,t),this._applyPMREM(h),this._cleanup(h),h}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=IA(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=OA(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?F:0,F,F),y.setRenderTarget(r),M&&y.render(A,h),y.render(e,h)}y.toneMapping=x,y.autoClear=b,e.background=R}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Ul||e.mapping===Xu;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=IA()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=OA());const s=r?this._cubemapMaterial:this._equirectMaterial,l=this._lodMeshes[0];l.material=s;const u=s.uniforms;u.envMap.value=e;const h=this._cubeSize;lp(t,0,0,3*h,2*h),i.setRenderTarget(t),i.render(l,Og)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;sE-Gu?i-E+Gu:0),M=4*(this._cubeSize-A);h.envMap.value=e.texture,h.roughness.value=x,h.mipInt.value=E-t,lp(s,T,M,3*A,2*A),r.setRenderTarget(s),r.render(u,Og),h.envMap.value=s.texture,h.roughness.value=0,h.mipInt.value=E-i,lp(e,T,M,3*A,2*A),r.setRenderTarget(e),r.render(u,Og)}_blur(e,t,i,r,s){const l=this._pingPongRenderTarget;this._halfBlur(e,l,t,i,r,"latitudinal",s),this._halfBlur(l,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,l,u){const h=this._renderer,p=this._blurMaterial;l!=="latitudinal"&&l!=="longitudinal"&&Gt("blur direction must be either latitudinal or longitudinal!");const g=3,y=this._lodMeshes[r];y.material=p;const b=p.uniforms,x=this._sizeLods[i]-1,E=isFinite(s)?Math.PI/(2*x):2*Math.PI/(2*ud-1),A=s/E,T=isFinite(s)?1+Math.floor(g*A):ud;T>ud&&Rt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${T} samples when the maximum is set to ${ud}`);const M=[];let R=0;for(let k=0;kO-Gu?r-O+Gu:0),U=4*(this._cubeSize-D);lp(t,F,U,3*D,2*D),h.setRenderTarget(t),h.render(y,Og)}}function Q4(n){const e=[],t=[],i=[];let r=n;const s=n-Gu+1+CA.length;for(let l=0;ln-Gu?h=CA[l-n+Gu-1]:l===0&&(h=0),t.push(h);const p=1/(u-2),g=-p,y=1+p,b=[g,g,y,g,y,y,g,g,y,y,g,y],x=6,E=6,A=3,T=2,M=1,R=new Float32Array(A*E*x),O=new Float32Array(T*E*x),D=new Float32Array(M*E*x);for(let U=0;U2?0:-1,L=[k,H,0,k+2/3,H,0,k+2/3,H+1,0,k,H,0,k+2/3,H+1,0,k,H+1,0];R.set(L,A*E*U),O.set(b,T*E*U);const z=[U,U,U,U,U,U];D.set(z,M*E*U)}const F=new dn;F.setAttribute("position",new si(R,A)),F.setAttribute("uv",new si(O,T)),F.setAttribute("faceIndex",new si(D,M)),i.push(new $n(F,null)),r>Gu&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function DA(n,e,t){const i=new ai(n,e,t);return i.texture.mapping=Fp,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function lp(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function J4(n,e,t){return new Ln({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Z4,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:L_(),fragmentShader:` precision highp float; precision highp int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform float roughness; uniform float mipInt; #define ENVMAP_TYPE_CUBE_UV #include #define PI 3.14159265359 // Van der Corput radical inverse float radicalInverse_VdC(uint bits) { bits = (bits << 16u) | (bits >> 16u); bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); return float(bits) * 2.3283064365386963e-10; // / 0x100000000 } // Hammersley sequence vec2 hammersley(uint i, uint N) { return vec2(float(i) / float(N), radicalInverse_VdC(i)); } // GGX VNDF importance sampling (Eric Heitz 2018) // "Sampling the GGX Distribution of Visible Normals" // https://jcgt.org/published/0007/04/01/ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { float alpha = roughness * roughness; // Section 3.2: Transform view direction to hemisphere configuration vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); // Section 4.1: Orthonormal basis float lensq = Vh.x * Vh.x + Vh.y * Vh.y; vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); vec3 T2 = cross(Vh, T1); // Section 4.2: Parameterization of projected area float r = sqrt(Xi.x); float phi = 2.0 * PI * Xi.y; float t1 = r * cos(phi); float t2 = r * sin(phi); float s = 0.5 * (1.0 + Vh.z); t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; // Section 4.3: Reprojection onto hemisphere vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh; // Section 3.4: Transform back to ellipsoid configuration return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); } void main() { vec3 N = normalize(vOutputDirection); vec3 V = N; // Assume view direction equals normal for pre-filtering vec3 prefilteredColor = vec3(0.0); float totalWeight = 0.0; // For very low roughness, just sample the environment directly if (roughness < 0.001) { gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); return; } // Tangent space basis for VNDF sampling vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); vec3 tangent = normalize(cross(up, N)); vec3 bitangent = cross(N, tangent); for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); // For PMREM, V = N, so in tangent space V is always (0, 0, 1) vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); // Transform H back to world space vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); vec3 L = normalize(2.0 * dot(V, H) * H - V); float NdotL = max(dot(N, L), 0.0); if(NdotL > 0.0) { // Sample environment at fixed mip level // VNDF importance sampling handles the distribution filtering vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); // Weight by NdotL for the split-sum approximation // VNDF PDF naturally accounts for the visible microfacet distribution prefilteredColor += sampleColor * NdotL; totalWeight += NdotL; } } if (totalWeight > 0.0) { prefilteredColor = prefilteredColor / totalWeight; } gl_FragColor = vec4(prefilteredColor, 1.0); } `,blending:$r,depthTest:!1,depthWrite:!1})}function ek(n,e,t){const i=new Float32Array(ud),r=new Q(0,1,0);return new Ln({name:"SphericalGaussianBlur",defines:{n:ud,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:L_(),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:$r,depthTest:!1,depthWrite:!1})}function OA(){return new Ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:L_(),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:$r,depthTest:!1,depthWrite:!1})}function IA(){return new Ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:L_(),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:$r,depthTest:!1,depthWrite:!1})}function L_(){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 tk(n){let e=new WeakMap,t=null;function i(u){if(u&&u.isTexture){const h=u.mapping,p=h===s0||h===o0,g=h===Ul||h===Xu;if(p||g){let y=e.get(u);const b=y!==void 0?y.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==b)return t===null&&(t=new wM(n)),y=p?t.fromEquirectangular(u,y):t.fromCubemap(u,y),y.texture.pmremVersion=u.pmremVersion,e.set(u,y),y.texture;if(y!==void 0)return y.texture;{const x=u.image;return p&&x&&x.height>0||g&&x&&r(x)?(t===null&&(t=new wM(n)),y=p?t.fromEquirectangular(u):t.fromCubemap(u),y.texture.pmremVersion=u.pmremVersion,e.set(u,y),u.addEventListener("dispose",s),y.texture):null}}}return u}function r(u){let h=0;const p=6;for(let g=0;ge.maxTextureSize&&(U=Math.ceil(F/e.maxTextureSize),F=e.maxTextureSize);const k=new Float32Array(F*U*4*y),H=new f_(k,F,U,y);H.type=xr,H.needsUpdate=!0;const L=D*4;for(let W=0;W #include void main() { gl_FragColor = texture2D( tDiffuse, vUv ); #ifdef LINEAR_TONE_MAPPING gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); #elif defined( REINHARD_TONE_MAPPING ) gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); #elif defined( CINEON_TONE_MAPPING ) gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); #elif defined( ACES_FILMIC_TONE_MAPPING ) gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); #elif defined( AGX_TONE_MAPPING ) gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); #elif defined( NEUTRAL_TONE_MAPPING ) gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); #elif defined( CUSTOM_TONE_MAPPING ) gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); #endif #ifdef SRGB_TRANSFER gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif }`,depthTest:!1,depthWrite:!1}),p=new $n(u,h),g=new qo(-1,1,1,-1,0,1);let y=null,b=null,x=!1,E,A=null,T=[],M=!1;this.setSize=function(R,O){s.setSize(R,O),l.setSize(R,O);for(let D=0;D0&&T[0].isRenderPass===!0;const O=s.width,D=s.height;for(let F=0;F0)return n;const r=e*t;let s=PA[r];if(s===void 0&&(s=new Float32Array(r),PA[r]=s),e!==0){i.toArray(s,0);for(let l=1,u=0;l!==e;++l)u+=t,n[l].toArray(s,u)}return s}function Nr(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=r.concat(s))}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,l=t.length;s!==l;++s){const u=t[s],h=i[u.id];h.needsUpdate!==!1&&u.setValue(e,h.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const l=e[r];l.id in t&&i.push(l)}return i}}function BA(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const e5=37297;let t5=0;function n5(n,e){const t=n.split(` `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let l=r;l":" "} ${u}: ${t[l]}`)}return i.join(` `)}const kA=new vn;function i5(n){Hn._getMatrix(kA,Hn.workingColorSpace,n);const e=`mat3( ${kA.elements.map(t=>t.toFixed(4))} )`;switch(Hn.getTransfer(n)){case d0:return[e,"LinearTransferOETF"];case ui:return[e,"sRGBTransferOETF"];default:return Rt("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function HA(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const l=/ERROR: 0:(\d+)/.exec(s);if(l){const u=parseInt(l[1]);return t.toUpperCase()+` `+s+` `+n5(n.getShaderSource(e),u)}else return s}function r5(n,e){const t=i5(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}const a5={[uE]:"Linear",[fE]:"Reinhard",[dE]:"Cineon",[t_]:"ACESFilmic",[pE]:"AgX",[mE]:"Neutral",[hE]:"Custom"};function s5(n,e){const t=a5[e];return t===void 0?(Rt("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const xb=new Q;function o5(){Hn.getLuminanceCoefficients(xb);const n=xb.x.toFixed(4),e=xb.y.toFixed(4),t=xb.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function l5(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Gg).join(` `)}function c5(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function u5(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function CM(n){return n.replace(f5,h5)}const d5=new Map;function h5(n,e){let t=En[e];if(t===void 0){const i=d5.get(e);if(i!==void 0)t=En[i],Rt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return CM(t)}const p5=/#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 WA(n){return n.replace(p5,m5)}function m5(n,e,t,i){let r="";for(let s=parseInt(e);s0&&(T+=` `),M=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,E].filter(Gg).join(` `),M.length>0&&(M+=` `)):(T=[XA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,E,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+g:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+h:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Gg).join(` `),M=[XA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,E,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+p:"",t.envMap?"#define "+g:"",t.envMap?"#define "+y:"",b?"#define CUBEUV_TEXEL_WIDTH "+b.texelWidth:"",b?"#define CUBEUV_TEXEL_HEIGHT "+b.texelHeight:"",b?"#define CUBEUV_MAX_MIP "+b.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+h:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Us?"#define TONE_MAPPING":"",t.toneMapping!==Us?En.tonemapping_pars_fragment:"",t.toneMapping!==Us?s5("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",En.colorspace_pars_fragment,r5("linearToOutputTexel",t.outputColorSpace),o5(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Gg).join(` `)),l=CM(l),l=VA(l,t),l=GA(l,t),u=CM(u),u=VA(u,t),u=GA(u,t),l=WA(l),u=WA(u),t.isRawShaderMaterial!==!0&&(R=`#version 300 es `,T=[x,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+T,M=["#define varying in",t.glslVersion===vM?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===vM?"":"#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(` `)+` `+M);const O=R+T+l,D=R+M+u,F=BA(r,r.VERTEX_SHADER,O),U=BA(r,r.FRAGMENT_SHADER,D);r.attachShader(A,F),r.attachShader(A,U),t.index0AttributeName!==void 0?r.bindAttribLocation(A,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(A,0,"position"),r.linkProgram(A);function k(W){if(n.debug.checkShaderErrors){const J=r.getProgramInfoLog(A)||"",$=r.getShaderInfoLog(F)||"",oe=r.getShaderInfoLog(U)||"",ne=J.trim(),Y=$.trim(),K=oe.trim();let ie=!0,ge=!0;if(r.getProgramParameter(A,r.LINK_STATUS)===!1)if(ie=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,A,F,U);else{const xe=HA(r,F,"vertex"),q=HA(r,U,"fragment");Gt("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(A,r.VALIDATE_STATUS)+` Material Name: `+W.name+` Material Type: `+W.type+` Program Info Log: `+ne+` `+xe+` `+q)}else ne!==""?Rt("WebGLProgram: Program Info Log:",ne):(Y===""||K==="")&&(ge=!1);ge&&(W.diagnostics={runnable:ie,programLog:ne,vertexShader:{log:Y,prefix:T},fragmentShader:{log:K,prefix:M}})}r.deleteShader(F),r.deleteShader(U),H=new Nb(r,A),L=u5(r,A)}let H;this.getUniforms=function(){return H===void 0&&k(this),H};let L;this.getAttributes=function(){return L===void 0&&k(this),L};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=r.getProgramParameter(A,e5)),z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(A),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=t5++,this.cacheKey=e,this.usedTimes=1,this.program=A,this.vertexShader=F,this.fragmentShader=U,this}let w5=0;class A5{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),l=this._getShaderCacheForMaterial(e);return l.has(r)===!1&&(l.add(r),r.usedTimes++),l.has(s)===!1&&(l.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new C5(e),t.set(e,i)),i}}class C5{constructor(e){this.id=w5++,this.code=e,this.usedTimes=0}}function R5(n,e,t,i,r,s,l){const u=new Dp,h=new A5,p=new Set,g=[],y=new Map,b=r.logarithmicDepthBuffer;let x=r.precision;const E={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function A(L){return p.add(L),L===0?"uv":`uv${L}`}function T(L,z,W,J,$){const oe=J.fog,ne=$.geometry,Y=L.isMeshStandardMaterial?J.environment:null,K=(L.isMeshStandardMaterial?t:e).get(L.envMap||Y),ie=K&&K.mapping===Fp?K.image.height:null,ge=E[L.type];L.precision!==null&&(x=r.getMaxPrecision(L.precision),x!==L.precision&&Rt("WebGLProgram.getParameters:",L.precision,"not supported, using",x,"instead."));const xe=ne.morphAttributes.position||ne.morphAttributes.normal||ne.morphAttributes.color,q=xe!==void 0?xe.length:0;let ce=0;ne.morphAttributes.position!==void 0&&(ce=1),ne.morphAttributes.normal!==void 0&&(ce=2),ne.morphAttributes.color!==void 0&&(ce=3);let Se,Ge,Ye,ve;if(ge){const sn=Go[ge];Se=sn.vertexShader,Ge=sn.fragmentShader}else Se=L.vertexShader,Ge=L.fragmentShader,h.update(L),Ye=h.getVertexShaderID(L),ve=h.getFragmentShaderID(L);const Oe=n.getRenderTarget(),it=n.state.buffers.depth.getReversed(),gt=$.isInstancedMesh===!0,_t=$.isBatchedMesh===!0,jt=!!L.map,pt=!!L.matcap,mt=!!K,He=!!L.aoMap,Ue=!!L.lightMap,Re=!!L.bumpMap,ft=!!L.normalMap,Z=!!L.displacementMap,At=!!L.emissiveMap,dt=!!L.metalnessMap,Ct=!!L.roughnessMap,tt=L.anisotropy>0,V=L.clearcoat>0,N=L.dispersion>0,ee=L.iridescence>0,Ee=L.sheen>0,Te=L.transmission>0,pe=tt&&!!L.anisotropyMap,Et=V&&!!L.clearcoatMap,$e=V&&!!L.clearcoatNormalMap,lt=V&&!!L.clearcoatRoughnessMap,Lt=ee&&!!L.iridescenceMap,Ze=ee&&!!L.iridescenceThicknessMap,rt=Ee&&!!L.sheenColorMap,vt=Ee&&!!L.sheenRoughnessMap,te=!!L.specularMap,be=!!L.specularColorMap,ct=!!L.specularIntensityMap,re=Te&&!!L.transmissionMap,Pe=Te&&!!L.thicknessMap,ze=!!L.gradientMap,at=!!L.alphaMap,je=L.alphaTest>0,Ve=!!L.alphaHash,nt=!!L.extensions;let It=Us;L.toneMapped&&(Oe===null||Oe.isXRRenderTarget===!0)&&(It=n.toneMapping);const an={shaderID:ge,shaderType:L.type,shaderName:L.name,vertexShader:Se,fragmentShader:Ge,defines:L.defines,customVertexShaderID:Ye,customFragmentShaderID:ve,isRawShaderMaterial:L.isRawShaderMaterial===!0,glslVersion:L.glslVersion,precision:x,batching:_t,batchingColor:_t&&$._colorsTexture!==null,instancing:gt,instancingColor:gt&&$.instanceColor!==null,instancingMorph:gt&&$.morphTexture!==null,outputColorSpace:Oe===null?n.outputColorSpace:Oe.isXRRenderTarget===!0?Oe.texture.colorSpace:Fl,alphaToCoverage:!!L.alphaToCoverage,map:jt,matcap:pt,envMap:mt,envMapMode:mt&&K.mapping,envMapCubeUVHeight:ie,aoMap:He,lightMap:Ue,bumpMap:Re,normalMap:ft,displacementMap:Z,emissiveMap:At,normalMapObjectSpace:ft&&L.normalMapType===U3,normalMapTangentSpace:ft&&L.normalMapType===nf,metalnessMap:dt,roughnessMap:Ct,anisotropy:tt,anisotropyMap:pe,clearcoat:V,clearcoatMap:Et,clearcoatNormalMap:$e,clearcoatRoughnessMap:lt,dispersion:N,iridescence:ee,iridescenceMap:Lt,iridescenceThicknessMap:Ze,sheen:Ee,sheenColorMap:rt,sheenRoughnessMap:vt,specularMap:te,specularColorMap:be,specularIntensityMap:ct,transmission:Te,transmissionMap:re,thicknessMap:Pe,gradientMap:ze,opaque:L.transparent===!1&&L.blending===gd&&L.alphaToCoverage===!1,alphaMap:at,alphaTest:je,alphaHash:Ve,combine:L.combine,mapUv:jt&&A(L.map.channel),aoMapUv:He&&A(L.aoMap.channel),lightMapUv:Ue&&A(L.lightMap.channel),bumpMapUv:Re&&A(L.bumpMap.channel),normalMapUv:ft&&A(L.normalMap.channel),displacementMapUv:Z&&A(L.displacementMap.channel),emissiveMapUv:At&&A(L.emissiveMap.channel),metalnessMapUv:dt&&A(L.metalnessMap.channel),roughnessMapUv:Ct&&A(L.roughnessMap.channel),anisotropyMapUv:pe&&A(L.anisotropyMap.channel),clearcoatMapUv:Et&&A(L.clearcoatMap.channel),clearcoatNormalMapUv:$e&&A(L.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:lt&&A(L.clearcoatRoughnessMap.channel),iridescenceMapUv:Lt&&A(L.iridescenceMap.channel),iridescenceThicknessMapUv:Ze&&A(L.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&A(L.sheenColorMap.channel),sheenRoughnessMapUv:vt&&A(L.sheenRoughnessMap.channel),specularMapUv:te&&A(L.specularMap.channel),specularColorMapUv:be&&A(L.specularColorMap.channel),specularIntensityMapUv:ct&&A(L.specularIntensityMap.channel),transmissionMapUv:re&&A(L.transmissionMap.channel),thicknessMapUv:Pe&&A(L.thicknessMap.channel),alphaMapUv:at&&A(L.alphaMap.channel),vertexTangents:!!ne.attributes.tangent&&(ft||tt),vertexColors:L.vertexColors,vertexAlphas:L.vertexColors===!0&&!!ne.attributes.color&&ne.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!ne.attributes.uv&&(jt||at),fog:!!oe,useFog:L.fog===!0,fogExp2:!!oe&&oe.isFogExp2,flatShading:L.flatShading===!0&&L.wireframe===!1,sizeAttenuation:L.sizeAttenuation===!0,logarithmicDepthBuffer:b,reversedDepthBuffer:it,skinning:$.isSkinnedMesh===!0,morphTargets:ne.morphAttributes.position!==void 0,morphNormals:ne.morphAttributes.normal!==void 0,morphColors:ne.morphAttributes.color!==void 0,morphTargetsCount:q,morphTextureStride:ce,numDirLights:z.directional.length,numPointLights:z.point.length,numSpotLights:z.spot.length,numSpotLightMaps:z.spotLightMap.length,numRectAreaLights:z.rectArea.length,numHemiLights:z.hemi.length,numDirLightShadows:z.directionalShadowMap.length,numPointLightShadows:z.pointShadowMap.length,numSpotLightShadows:z.spotShadowMap.length,numSpotLightShadowsWithMaps:z.numSpotLightShadowsWithMaps,numLightProbes:z.numLightProbes,numClippingPlanes:l.numPlanes,numClipIntersection:l.numIntersection,dithering:L.dithering,shadowMapEnabled:n.shadowMap.enabled&&W.length>0,shadowMapType:n.shadowMap.type,toneMapping:It,decodeVideoTexture:jt&&L.map.isVideoTexture===!0&&Hn.getTransfer(L.map.colorSpace)===ui,decodeVideoTextureEmissive:At&&L.emissiveMap.isVideoTexture===!0&&Hn.getTransfer(L.emissiveMap.colorSpace)===ui,premultipliedAlpha:L.premultipliedAlpha,doubleSided:L.side===Bi,flipSided:L.side===Lr,useDepthPacking:L.depthPacking>=0,depthPacking:L.depthPacking||0,index0AttributeName:L.index0AttributeName,extensionClipCullDistance:nt&&L.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(nt&&L.extensions.multiDraw===!0||_t)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:L.customProgramCacheKey()};return an.vertexUv1s=p.has(1),an.vertexUv2s=p.has(2),an.vertexUv3s=p.has(3),p.clear(),an}function M(L){const z=[];if(L.shaderID?z.push(L.shaderID):(z.push(L.customVertexShaderID),z.push(L.customFragmentShaderID)),L.defines!==void 0)for(const W in L.defines)z.push(W),z.push(L.defines[W]);return L.isRawShaderMaterial===!1&&(R(z,L),O(z,L),z.push(n.outputColorSpace)),z.push(L.customProgramCacheKey),z.join()}function R(L,z){L.push(z.precision),L.push(z.outputColorSpace),L.push(z.envMapMode),L.push(z.envMapCubeUVHeight),L.push(z.mapUv),L.push(z.alphaMapUv),L.push(z.lightMapUv),L.push(z.aoMapUv),L.push(z.bumpMapUv),L.push(z.normalMapUv),L.push(z.displacementMapUv),L.push(z.emissiveMapUv),L.push(z.metalnessMapUv),L.push(z.roughnessMapUv),L.push(z.anisotropyMapUv),L.push(z.clearcoatMapUv),L.push(z.clearcoatNormalMapUv),L.push(z.clearcoatRoughnessMapUv),L.push(z.iridescenceMapUv),L.push(z.iridescenceThicknessMapUv),L.push(z.sheenColorMapUv),L.push(z.sheenRoughnessMapUv),L.push(z.specularMapUv),L.push(z.specularColorMapUv),L.push(z.specularIntensityMapUv),L.push(z.transmissionMapUv),L.push(z.thicknessMapUv),L.push(z.combine),L.push(z.fogExp2),L.push(z.sizeAttenuation),L.push(z.morphTargetsCount),L.push(z.morphAttributeCount),L.push(z.numDirLights),L.push(z.numPointLights),L.push(z.numSpotLights),L.push(z.numSpotLightMaps),L.push(z.numHemiLights),L.push(z.numRectAreaLights),L.push(z.numDirLightShadows),L.push(z.numPointLightShadows),L.push(z.numSpotLightShadows),L.push(z.numSpotLightShadowsWithMaps),L.push(z.numLightProbes),L.push(z.shadowMapType),L.push(z.toneMapping),L.push(z.numClippingPlanes),L.push(z.numClipIntersection),L.push(z.depthPacking)}function O(L,z){u.disableAll(),z.instancing&&u.enable(0),z.instancingColor&&u.enable(1),z.instancingMorph&&u.enable(2),z.matcap&&u.enable(3),z.envMap&&u.enable(4),z.normalMapObjectSpace&&u.enable(5),z.normalMapTangentSpace&&u.enable(6),z.clearcoat&&u.enable(7),z.iridescence&&u.enable(8),z.alphaTest&&u.enable(9),z.vertexColors&&u.enable(10),z.vertexAlphas&&u.enable(11),z.vertexUv1s&&u.enable(12),z.vertexUv2s&&u.enable(13),z.vertexUv3s&&u.enable(14),z.vertexTangents&&u.enable(15),z.anisotropy&&u.enable(16),z.alphaHash&&u.enable(17),z.batching&&u.enable(18),z.dispersion&&u.enable(19),z.batchingColor&&u.enable(20),z.gradientMap&&u.enable(21),L.push(u.mask),u.disableAll(),z.fog&&u.enable(0),z.useFog&&u.enable(1),z.flatShading&&u.enable(2),z.logarithmicDepthBuffer&&u.enable(3),z.reversedDepthBuffer&&u.enable(4),z.skinning&&u.enable(5),z.morphTargets&&u.enable(6),z.morphNormals&&u.enable(7),z.morphColors&&u.enable(8),z.premultipliedAlpha&&u.enable(9),z.shadowMapEnabled&&u.enable(10),z.doubleSided&&u.enable(11),z.flipSided&&u.enable(12),z.useDepthPacking&&u.enable(13),z.dithering&&u.enable(14),z.transmission&&u.enable(15),z.sheen&&u.enable(16),z.opaque&&u.enable(17),z.pointsUvs&&u.enable(18),z.decodeVideoTexture&&u.enable(19),z.decodeVideoTextureEmissive&&u.enable(20),z.alphaToCoverage&&u.enable(21),L.push(u.mask)}function D(L){const z=E[L.type];let W;if(z){const J=Go[z];W=Y3.clone(J.uniforms)}else W=L.uniforms;return W}function F(L,z){let W=y.get(z);return W!==void 0?++W.usedTimes:(W=new T5(n,z,L,s),g.push(W),y.set(z,W)),W}function U(L){if(--L.usedTimes===0){const z=g.indexOf(L);g[z]=g[g.length-1],g.pop(),y.delete(L.cacheKey),L.destroy()}}function k(L){h.remove(L)}function H(){h.dispose()}return{getParameters:T,getProgramCacheKey:M,getUniforms:D,acquireProgram:F,releaseProgram:U,releaseShaderCache:k,programs:g,dispose:H}}function D5(){let n=new WeakMap;function e(l){return n.has(l)}function t(l){let u=n.get(l);return u===void 0&&(u={},n.set(l,u)),u}function i(l){n.delete(l)}function r(l,u,h){n.get(l)[u]=h}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function O5(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function $A(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function jA(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function l(y,b,x,E,A,T){let M=n[e];return M===void 0?(M={id:y.id,object:y,geometry:b,material:x,groupOrder:E,renderOrder:y.renderOrder,z:A,group:T},n[e]=M):(M.id=y.id,M.object=y,M.geometry=b,M.material=x,M.groupOrder=E,M.renderOrder=y.renderOrder,M.z=A,M.group=T),e++,M}function u(y,b,x,E,A,T){const M=l(y,b,x,E,A,T);x.transmission>0?i.push(M):x.transparent===!0?r.push(M):t.push(M)}function h(y,b,x,E,A,T){const M=l(y,b,x,E,A,T);x.transmission>0?i.unshift(M):x.transparent===!0?r.unshift(M):t.unshift(M)}function p(y,b){t.length>1&&t.sort(y||O5),i.length>1&&i.sort(b||$A),r.length>1&&r.sort(b||$A)}function g(){for(let y=e,b=n.length;y=s.length?(l=new jA,s.push(l)):l=s[r],l}function t(){n=new WeakMap}return{get:e,dispose:t}}function P5(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Q,color:new Mt};break;case"SpotLight":t={position:new Q,direction:new Q,color:new Mt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Q,color:new Mt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Q,skyColor:new Mt,groundColor:new Mt};break;case"RectAreaLight":t={color:new Mt,position:new Q,halfWidth:new Q,halfHeight:new Q};break}return n[e.id]=t,t}}}function L5(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let N5=0;function U5(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function z5(n){const e=new P5,t=L5(),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 p=0;p<9;p++)i.probe.push(new Q);const r=new Q,s=new rn,l=new rn;function u(p){let g=0,y=0,b=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let x=0,E=0,A=0,T=0,M=0,R=0,O=0,D=0,F=0,U=0,k=0;p.sort(U5);for(let L=0,z=p.length;L0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_FLOAT_1,i.rectAreaLTC2=Dt.LTC_FLOAT_2):(i.rectAreaLTC1=Dt.LTC_HALF_1,i.rectAreaLTC2=Dt.LTC_HALF_2)),i.ambient[0]=g,i.ambient[1]=y,i.ambient[2]=b;const H=i.hash;(H.directionalLength!==x||H.pointLength!==E||H.spotLength!==A||H.rectAreaLength!==T||H.hemiLength!==M||H.numDirectionalShadows!==R||H.numPointShadows!==O||H.numSpotShadows!==D||H.numSpotMaps!==F||H.numLightProbes!==k)&&(i.directional.length=x,i.spot.length=A,i.rectArea.length=T,i.point.length=E,i.hemi.length=M,i.directionalShadow.length=R,i.directionalShadowMap.length=R,i.pointShadow.length=O,i.pointShadowMap.length=O,i.spotShadow.length=D,i.spotShadowMap.length=D,i.directionalShadowMatrix.length=R,i.pointShadowMatrix.length=O,i.spotLightMatrix.length=D+F-U,i.spotLightMap.length=F,i.numSpotLightShadowsWithMaps=U,i.numLightProbes=k,H.directionalLength=x,H.pointLength=E,H.spotLength=A,H.rectAreaLength=T,H.hemiLength=M,H.numDirectionalShadows=R,H.numPointShadows=O,H.numSpotShadows=D,H.numSpotMaps=F,H.numLightProbes=k,i.version=N5++)}function h(p,g){let y=0,b=0,x=0,E=0,A=0;const T=g.matrixWorldInverse;for(let M=0,R=p.length;M=l.length?(u=new qA(n),l.push(u)):u=l[s],u}function i(){e=new WeakMap}return{get:t,dispose:i}}const B5=`void main() { gl_Position = vec4( position, 1.0 ); }`,k5=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; 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 = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); }`,H5=[new Q(1,0,0),new Q(-1,0,0),new Q(0,1,0),new Q(0,-1,0),new Q(0,0,1),new Q(0,0,-1)],V5=[new Q(0,-1,0),new Q(0,-1,0),new Q(0,0,1),new Q(0,0,-1),new Q(0,-1,0),new Q(0,-1,0)],YA=new rn,Ig=new Q,S1=new Q;function G5(n,e,t){let i=new Bp;const r=new Be,s=new Be,l=new fi,u=new VE,h=new GE,p={},g=t.maxTextureSize,y={[Nl]:Lr,[Lr]:Nl,[Bi]:Bi},b=new Ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Be},radius:{value:4}},vertexShader:B5,fragmentShader:k5}),x=b.clone();x.defines.HORIZONTAL_PASS=1;const E=new dn;E.setAttribute("position",new si(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A=new $n(E,b),T=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_p;let M=this.type;this.render=function(U,k,H){if(T.enabled===!1||T.autoUpdate===!1&&T.needsUpdate===!1||U.length===0)return;U.type===Xg&&(Rt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),U.type=_p);const L=n.getRenderTarget(),z=n.getActiveCubeFace(),W=n.getActiveMipmapLevel(),J=n.state;J.setBlending($r),J.buffers.depth.getReversed()===!0?J.buffers.color.setClear(0,0,0,0):J.buffers.color.setClear(1,1,1,1),J.buffers.depth.setTest(!0),J.setScissorTest(!1);const $=M!==this.type;$&&k.traverse(function(oe){oe.material&&(Array.isArray(oe.material)?oe.material.forEach(ne=>ne.needsUpdate=!0):oe.material.needsUpdate=!0)});for(let oe=0,ne=U.length;oeg||r.y>g)&&(r.x>g&&(s.x=Math.floor(g/ie.x),r.x=s.x*ie.x,K.mapSize.x=s.x),r.y>g&&(s.y=Math.floor(g/ie.y),r.y=s.y*ie.y,K.mapSize.y=s.y)),K.map===null||$===!0){if(K.map!==null&&(K.map.depthTexture!==null&&(K.map.depthTexture.dispose(),K.map.depthTexture=null),K.map.dispose()),this.type===fd){if(Y.isPointLight){Rt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}K.map=new ai(r.x,r.y,{format:Md,type:vo,minFilter:Kn,magFilter:Kn,generateMipmaps:!1}),K.map.texture.name=Y.name+".shadowMap",K.map.depthTexture=new qu(r.x,r.y,xr),K.map.depthTexture.name=Y.name+".shadowMapDepth",K.map.depthTexture.format=zl,K.map.depthTexture.compareFunction=null,K.map.depthTexture.minFilter=jn,K.map.depthTexture.magFilter=jn}else{Y.isPointLight?(K.map=new CE(r.x),K.map.depthTexture=new sD(r.x,Bs)):(K.map=new ai(r.x,r.y),K.map.depthTexture=new qu(r.x,r.y,Bs)),K.map.depthTexture.name=Y.name+".shadowMap",K.map.depthTexture.format=zl;const xe=n.state.buffers.depth.getReversed();this.type===_p?(K.map.depthTexture.compareFunction=xe?u_:c_,K.map.depthTexture.minFilter=Kn,K.map.depthTexture.magFilter=Kn):(K.map.depthTexture.compareFunction=null,K.map.depthTexture.minFilter=jn,K.map.depthTexture.magFilter=jn)}K.camera.updateProjectionMatrix()}const ge=K.map.isWebGLCubeRenderTarget?6:1;for(let xe=0;xe0||k.map&&k.alphaTest>0||k.alphaToCoverage===!0){const J=z.uuid,$=k.uuid;let oe=p[J];oe===void 0&&(oe={},p[J]=oe);let ne=oe[$];ne===void 0&&(ne=z.clone(),oe[$]=ne,k.addEventListener("dispose",F)),z=ne}if(z.visible=k.visible,z.wireframe=k.wireframe,L===fd?z.side=k.shadowSide!==null?k.shadowSide:k.side:z.side=k.shadowSide!==null?k.shadowSide:y[k.side],z.alphaMap=k.alphaMap,z.alphaTest=k.alphaToCoverage===!0?.5:k.alphaTest,z.map=k.map,z.clipShadows=k.clipShadows,z.clippingPlanes=k.clippingPlanes,z.clipIntersection=k.clipIntersection,z.displacementMap=k.displacementMap,z.displacementScale=k.displacementScale,z.displacementBias=k.displacementBias,z.wireframeLinewidth=k.wireframeLinewidth,z.linewidth=k.linewidth,H.isPointLight===!0&&z.isMeshDistanceMaterial===!0){const J=n.properties.get(z);J.light=H}return z}function D(U,k,H,L,z){if(U.visible===!1)return;if(U.layers.test(k.layers)&&(U.isMesh||U.isLine||U.isPoints)&&(U.castShadow||U.receiveShadow&&z===fd)&&(!U.frustumCulled||i.intersectsObject(U))){U.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,U.matrixWorld);const $=e.update(U),oe=U.material;if(Array.isArray(oe)){const ne=$.groups;for(let Y=0,K=ne.length;Y=1):ie.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),Y=K>=2);let ge=null,xe={};const q=n.getParameter(n.SCISSOR_BOX),ce=n.getParameter(n.VIEWPORT),Se=new fi().fromArray(q),Ge=new fi().fromArray(ce);function Ye(re,Pe,ze,at){const je=new Uint8Array(4),Ve=n.createTexture();n.bindTexture(re,Ve),n.texParameteri(re,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(re,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let nt=0;nt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new Be,g=new WeakMap;let y;const b=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(V,N){return x?new OffscreenCanvas(V,N):p0("canvas")}function A(V,N,ee){let Ee=1;const Te=tt(V);if((Te.width>ee||Te.height>ee)&&(Ee=ee/Math.max(Te.width,Te.height)),Ee<1)if(typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&V instanceof ImageBitmap||typeof VideoFrame<"u"&&V instanceof VideoFrame){const pe=Math.floor(Ee*Te.width),Et=Math.floor(Ee*Te.height);y===void 0&&(y=E(pe,Et));const $e=N?E(pe,Et):y;return $e.width=pe,$e.height=Et,$e.getContext("2d").drawImage(V,0,0,pe,Et),Rt("WebGLRenderer: Texture has been resized from ("+Te.width+"x"+Te.height+") to ("+pe+"x"+Et+")."),$e}else return"data"in V&&Rt("WebGLRenderer: Image in DataTexture is too big ("+Te.width+"x"+Te.height+")."),V;return V}function T(V){return V.generateMipmaps}function M(V){n.generateMipmap(V)}function R(V){return V.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:V.isWebGL3DRenderTarget?n.TEXTURE_3D:V.isWebGLArrayRenderTarget||V.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function O(V,N,ee,Ee,Te=!1){if(V!==null){if(n[V]!==void 0)return n[V];Rt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+V+"'")}let pe=N;if(N===n.RED&&(ee===n.FLOAT&&(pe=n.R32F),ee===n.HALF_FLOAT&&(pe=n.R16F),ee===n.UNSIGNED_BYTE&&(pe=n.R8)),N===n.RED_INTEGER&&(ee===n.UNSIGNED_BYTE&&(pe=n.R8UI),ee===n.UNSIGNED_SHORT&&(pe=n.R16UI),ee===n.UNSIGNED_INT&&(pe=n.R32UI),ee===n.BYTE&&(pe=n.R8I),ee===n.SHORT&&(pe=n.R16I),ee===n.INT&&(pe=n.R32I)),N===n.RG&&(ee===n.FLOAT&&(pe=n.RG32F),ee===n.HALF_FLOAT&&(pe=n.RG16F),ee===n.UNSIGNED_BYTE&&(pe=n.RG8)),N===n.RG_INTEGER&&(ee===n.UNSIGNED_BYTE&&(pe=n.RG8UI),ee===n.UNSIGNED_SHORT&&(pe=n.RG16UI),ee===n.UNSIGNED_INT&&(pe=n.RG32UI),ee===n.BYTE&&(pe=n.RG8I),ee===n.SHORT&&(pe=n.RG16I),ee===n.INT&&(pe=n.RG32I)),N===n.RGB_INTEGER&&(ee===n.UNSIGNED_BYTE&&(pe=n.RGB8UI),ee===n.UNSIGNED_SHORT&&(pe=n.RGB16UI),ee===n.UNSIGNED_INT&&(pe=n.RGB32UI),ee===n.BYTE&&(pe=n.RGB8I),ee===n.SHORT&&(pe=n.RGB16I),ee===n.INT&&(pe=n.RGB32I)),N===n.RGBA_INTEGER&&(ee===n.UNSIGNED_BYTE&&(pe=n.RGBA8UI),ee===n.UNSIGNED_SHORT&&(pe=n.RGBA16UI),ee===n.UNSIGNED_INT&&(pe=n.RGBA32UI),ee===n.BYTE&&(pe=n.RGBA8I),ee===n.SHORT&&(pe=n.RGBA16I),ee===n.INT&&(pe=n.RGBA32I)),N===n.RGB&&(ee===n.UNSIGNED_INT_5_9_9_9_REV&&(pe=n.RGB9_E5),ee===n.UNSIGNED_INT_10F_11F_11F_REV&&(pe=n.R11F_G11F_B10F)),N===n.RGBA){const Et=Te?d0:Hn.getTransfer(Ee);ee===n.FLOAT&&(pe=n.RGBA32F),ee===n.HALF_FLOAT&&(pe=n.RGBA16F),ee===n.UNSIGNED_BYTE&&(pe=Et===ui?n.SRGB8_ALPHA8:n.RGBA8),ee===n.UNSIGNED_SHORT_4_4_4_4&&(pe=n.RGBA4),ee===n.UNSIGNED_SHORT_5_5_5_1&&(pe=n.RGB5_A1)}return(pe===n.R16F||pe===n.R32F||pe===n.RG16F||pe===n.RG32F||pe===n.RGBA16F||pe===n.RGBA32F)&&e.get("EXT_color_buffer_float"),pe}function D(V,N){let ee;return V?N===null||N===Bs||N===Sd?ee=n.DEPTH24_STENCIL8:N===xr?ee=n.DEPTH32F_STENCIL8:N===wp&&(ee=n.DEPTH24_STENCIL8,Rt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):N===null||N===Bs||N===Sd?ee=n.DEPTH_COMPONENT24:N===xr?ee=n.DEPTH_COMPONENT32F:N===wp&&(ee=n.DEPTH_COMPONENT16),ee}function F(V,N){return T(V)===!0||V.isFramebufferTexture&&V.minFilter!==jn&&V.minFilter!==Kn?Math.log2(Math.max(N.width,N.height))+1:V.mipmaps!==void 0&&V.mipmaps.length>0?V.mipmaps.length:V.isCompressedTexture&&Array.isArray(V.image)?N.mipmaps.length:1}function U(V){const N=V.target;N.removeEventListener("dispose",U),H(N),N.isVideoTexture&&g.delete(N)}function k(V){const N=V.target;N.removeEventListener("dispose",k),z(N)}function H(V){const N=i.get(V);if(N.__webglInit===void 0)return;const ee=V.source,Ee=b.get(ee);if(Ee){const Te=Ee[N.__cacheKey];Te.usedTimes--,Te.usedTimes===0&&L(V),Object.keys(Ee).length===0&&b.delete(ee)}i.remove(V)}function L(V){const N=i.get(V);n.deleteTexture(N.__webglTexture);const ee=V.source,Ee=b.get(ee);delete Ee[N.__cacheKey],l.memory.textures--}function z(V){const N=i.get(V);if(V.depthTexture&&(V.depthTexture.dispose(),i.remove(V.depthTexture)),V.isWebGLCubeRenderTarget)for(let Ee=0;Ee<6;Ee++){if(Array.isArray(N.__webglFramebuffer[Ee]))for(let Te=0;Te=r.maxTextures&&Rt("WebGLTextures: Trying to use "+V+" texture units while this GPU supports only "+r.maxTextures),W+=1,V}function oe(V){const N=[];return N.push(V.wrapS),N.push(V.wrapT),N.push(V.wrapR||0),N.push(V.magFilter),N.push(V.minFilter),N.push(V.anisotropy),N.push(V.internalFormat),N.push(V.format),N.push(V.type),N.push(V.generateMipmaps),N.push(V.premultiplyAlpha),N.push(V.flipY),N.push(V.unpackAlignment),N.push(V.colorSpace),N.join()}function ne(V,N){const ee=i.get(V);if(V.isVideoTexture&&dt(V),V.isRenderTargetTexture===!1&&V.isExternalTexture!==!0&&V.version>0&&ee.__version!==V.version){const Ee=V.image;if(Ee===null)Rt("WebGLRenderer: Texture marked for update but no image data found.");else if(Ee.complete===!1)Rt("WebGLRenderer: Texture marked for update but image is incomplete");else{ve(ee,V,N);return}}else V.isExternalTexture&&(ee.__webglTexture=V.sourceTexture?V.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ee.__webglTexture,n.TEXTURE0+N)}function Y(V,N){const ee=i.get(V);if(V.isRenderTargetTexture===!1&&V.version>0&&ee.__version!==V.version){ve(ee,V,N);return}else V.isExternalTexture&&(ee.__webglTexture=V.sourceTexture?V.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ee.__webglTexture,n.TEXTURE0+N)}function K(V,N){const ee=i.get(V);if(V.isRenderTargetTexture===!1&&V.version>0&&ee.__version!==V.version){ve(ee,V,N);return}t.bindTexture(n.TEXTURE_3D,ee.__webglTexture,n.TEXTURE0+N)}function ie(V,N){const ee=i.get(V);if(V.isCubeDepthTexture!==!0&&V.version>0&&ee.__version!==V.version){Oe(ee,V,N);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture,n.TEXTURE0+N)}const ge={[l0]:n.REPEAT,[_s]:n.CLAMP_TO_EDGE,[c0]:n.MIRRORED_REPEAT},xe={[jn]:n.NEAREST,[gE]:n.NEAREST_MIPMAP_NEAREST,[vp]:n.NEAREST_MIPMAP_LINEAR,[Kn]:n.LINEAR,[$g]:n.LINEAR_MIPMAP_NEAREST,[$o]:n.LINEAR_MIPMAP_LINEAR},q={[z3]:n.NEVER,[V3]:n.ALWAYS,[F3]:n.LESS,[c_]:n.LEQUAL,[B3]:n.EQUAL,[u_]:n.GEQUAL,[k3]:n.GREATER,[H3]:n.NOTEQUAL};function ce(V,N){if(N.type===xr&&e.has("OES_texture_float_linear")===!1&&(N.magFilter===Kn||N.magFilter===$g||N.magFilter===vp||N.magFilter===$o||N.minFilter===Kn||N.minFilter===$g||N.minFilter===vp||N.minFilter===$o)&&Rt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(V,n.TEXTURE_WRAP_S,ge[N.wrapS]),n.texParameteri(V,n.TEXTURE_WRAP_T,ge[N.wrapT]),(V===n.TEXTURE_3D||V===n.TEXTURE_2D_ARRAY)&&n.texParameteri(V,n.TEXTURE_WRAP_R,ge[N.wrapR]),n.texParameteri(V,n.TEXTURE_MAG_FILTER,xe[N.magFilter]),n.texParameteri(V,n.TEXTURE_MIN_FILTER,xe[N.minFilter]),N.compareFunction&&(n.texParameteri(V,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(V,n.TEXTURE_COMPARE_FUNC,q[N.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(N.magFilter===jn||N.minFilter!==vp&&N.minFilter!==$o||N.type===xr&&e.has("OES_texture_float_linear")===!1)return;if(N.anisotropy>1||i.get(N).__currentAnisotropy){const ee=e.get("EXT_texture_filter_anisotropic");n.texParameterf(V,ee.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(N.anisotropy,r.getMaxAnisotropy())),i.get(N).__currentAnisotropy=N.anisotropy}}}function Se(V,N){let ee=!1;V.__webglInit===void 0&&(V.__webglInit=!0,N.addEventListener("dispose",U));const Ee=N.source;let Te=b.get(Ee);Te===void 0&&(Te={},b.set(Ee,Te));const pe=oe(N);if(pe!==V.__cacheKey){Te[pe]===void 0&&(Te[pe]={texture:n.createTexture(),usedTimes:0},l.memory.textures++,ee=!0),Te[pe].usedTimes++;const Et=Te[V.__cacheKey];Et!==void 0&&(Te[V.__cacheKey].usedTimes--,Et.usedTimes===0&&L(N)),V.__cacheKey=pe,V.__webglTexture=Te[pe].texture}return ee}function Ge(V,N,ee){return Math.floor(Math.floor(V/ee)/N)}function Ye(V,N,ee,Ee){const pe=V.updateRanges;if(pe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,N.width,N.height,ee,Ee,N.data);else{pe.sort((Ze,rt)=>Ze.start-rt.start);let Et=0;for(let Ze=1;Ze0){re&&Pe&&t.texStorage2D(n.TEXTURE_2D,at,te,ct[0].width,ct[0].height);for(let je=0,Ve=ct.length;je0){const nt=TM(be.width,be.height,N.format,N.type);for(const It of N.layerUpdates){const an=be.data.subarray(It*nt/be.data.BYTES_PER_ELEMENT,(It+1)*nt/be.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,je,0,0,It,be.width,be.height,1,rt,an)}N.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,je,0,0,0,be.width,be.height,Ze.depth,rt,be.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,je,te,be.width,be.height,Ze.depth,0,be.data,0,0);else Rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else re?ze&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,je,0,0,0,be.width,be.height,Ze.depth,rt,vt,be.data):t.texImage3D(n.TEXTURE_2D_ARRAY,je,te,be.width,be.height,Ze.depth,0,rt,vt,be.data)}else{re&&Pe&&t.texStorage2D(n.TEXTURE_2D,at,te,ct[0].width,ct[0].height);for(let je=0,Ve=ct.length;je0){const je=TM(Ze.width,Ze.height,N.format,N.type);for(const Ve of N.layerUpdates){const nt=Ze.data.subarray(Ve*je/Ze.data.BYTES_PER_ELEMENT,(Ve+1)*je/Ze.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Ve,Ze.width,Ze.height,1,rt,vt,nt)}N.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ze.width,Ze.height,Ze.depth,rt,vt,Ze.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,te,Ze.width,Ze.height,Ze.depth,0,rt,vt,Ze.data);else if(N.isData3DTexture)re?(Pe&&t.texStorage3D(n.TEXTURE_3D,at,te,Ze.width,Ze.height,Ze.depth),ze&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ze.width,Ze.height,Ze.depth,rt,vt,Ze.data)):t.texImage3D(n.TEXTURE_3D,0,te,Ze.width,Ze.height,Ze.depth,0,rt,vt,Ze.data);else if(N.isFramebufferTexture){if(Pe)if(re)t.texStorage2D(n.TEXTURE_2D,at,te,Ze.width,Ze.height);else{let je=Ze.width,Ve=Ze.height;for(let nt=0;nt>=1,Ve>>=1}}else if(ct.length>0){if(re&&Pe){const je=tt(ct[0]);t.texStorage2D(n.TEXTURE_2D,at,te,je.width,je.height)}for(let je=0,Ve=ct.length;je0&&at++;const Ve=tt(rt[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,at,ct,Ve.width,Ve.height)}for(let Ve=0;Ve<6;Ve++)if(Ze){re?ze&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,0,0,rt[Ve].width,rt[Ve].height,te,be,rt[Ve].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,ct,rt[Ve].width,rt[Ve].height,0,te,be,rt[Ve].data);for(let nt=0;nt>pe),vt=Math.max(1,N.height>>pe);Te===n.TEXTURE_3D||Te===n.TEXTURE_2D_ARRAY?t.texImage3D(Te,pe,lt,rt,vt,N.depth,0,Et,$e,null):t.texImage2D(Te,pe,lt,rt,vt,0,Et,$e,null)}t.bindFramebuffer(n.FRAMEBUFFER,V),At(N)?u.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ee,Te,Ze.__webglTexture,0,Z(N)):(Te===n.TEXTURE_2D||Te>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Te<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Ee,Te,Ze.__webglTexture,pe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function gt(V,N,ee){if(n.bindRenderbuffer(n.RENDERBUFFER,V),N.depthBuffer){const Ee=N.depthTexture,Te=Ee&&Ee.isDepthTexture?Ee.type:null,pe=D(N.stencilBuffer,Te),Et=N.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;At(N)?u.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Z(N),pe,N.width,N.height):ee?n.renderbufferStorageMultisample(n.RENDERBUFFER,Z(N),pe,N.width,N.height):n.renderbufferStorage(n.RENDERBUFFER,pe,N.width,N.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Et,n.RENDERBUFFER,V)}else{const Ee=N.textures;for(let Te=0;Te{delete N.__boundDepthTexture,delete N.__depthDisposeCallback,Ee.removeEventListener("dispose",Te)};Ee.addEventListener("dispose",Te),N.__depthDisposeCallback=Te}N.__boundDepthTexture=Ee}if(V.depthTexture&&!N.__autoAllocateDepthBuffer)if(ee)for(let Ee=0;Ee<6;Ee++)_t(N.__webglFramebuffer[Ee],V,Ee);else{const Ee=V.texture.mipmaps;Ee&&Ee.length>0?_t(N.__webglFramebuffer[0],V,0):_t(N.__webglFramebuffer,V,0)}else if(ee){N.__webglDepthbuffer=[];for(let Ee=0;Ee<6;Ee++)if(t.bindFramebuffer(n.FRAMEBUFFER,N.__webglFramebuffer[Ee]),N.__webglDepthbuffer[Ee]===void 0)N.__webglDepthbuffer[Ee]=n.createRenderbuffer(),gt(N.__webglDepthbuffer[Ee],V,!1);else{const Te=V.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,pe=N.__webglDepthbuffer[Ee];n.bindRenderbuffer(n.RENDERBUFFER,pe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Te,n.RENDERBUFFER,pe)}}else{const Ee=V.texture.mipmaps;if(Ee&&Ee.length>0?t.bindFramebuffer(n.FRAMEBUFFER,N.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,N.__webglFramebuffer),N.__webglDepthbuffer===void 0)N.__webglDepthbuffer=n.createRenderbuffer(),gt(N.__webglDepthbuffer,V,!1);else{const Te=V.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,pe=N.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,pe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Te,n.RENDERBUFFER,pe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function pt(V,N,ee){const Ee=i.get(V);N!==void 0&&it(Ee.__webglFramebuffer,V,V.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ee!==void 0&&jt(V)}function mt(V){const N=V.texture,ee=i.get(V),Ee=i.get(N);V.addEventListener("dispose",k);const Te=V.textures,pe=V.isWebGLCubeRenderTarget===!0,Et=Te.length>1;if(Et||(Ee.__webglTexture===void 0&&(Ee.__webglTexture=n.createTexture()),Ee.__version=N.version,l.memory.textures++),pe){ee.__webglFramebuffer=[];for(let $e=0;$e<6;$e++)if(N.mipmaps&&N.mipmaps.length>0){ee.__webglFramebuffer[$e]=[];for(let lt=0;lt0){ee.__webglFramebuffer=[];for(let $e=0;$e0&&At(V)===!1){ee.__webglMultisampledFramebuffer=n.createFramebuffer(),ee.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let $e=0;$e0)for(let lt=0;lt0)for(let lt=0;lt0){if(At(V)===!1){const N=V.textures,ee=V.width,Ee=V.height;let Te=n.COLOR_BUFFER_BIT;const pe=V.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Et=i.get(V),$e=N.length>1;if($e)for(let Lt=0;Lt0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Et.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Et.__webglFramebuffer);for(let Lt=0;Lt0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&N.__useRenderToTexture!==!1}function dt(V){const N=l.render.frame;g.get(V)!==N&&(g.set(V,N),V.update())}function Ct(V,N){const ee=V.colorSpace,Ee=V.format,Te=V.type;return V.isCompressedTexture===!0||V.isVideoTexture===!0||ee!==Fl&&ee!==Xo&&(Hn.getTransfer(ee)===ui?(Ee!==ca||Te!==fr)&&Rt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Gt("WebGLTextures: Unsupported texture color space:",ee)),N}function tt(V){return typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement?(p.width=V.naturalWidth||V.width,p.height=V.naturalHeight||V.height):typeof VideoFrame<"u"&&V instanceof VideoFrame?(p.width=V.displayWidth,p.height=V.displayHeight):(p.width=V.width,p.height=V.height),p}this.allocateTextureUnit=$,this.resetTextureUnits=J,this.setTexture2D=ne,this.setTexture2DArray=Y,this.setTexture3D=K,this.setTextureCube=ie,this.rebindTextures=pt,this.setupRenderTarget=mt,this.updateRenderTargetMipmap=He,this.updateMultisampleRenderTarget=ft,this.setupDepthRenderbuffer=jt,this.setupFrameBufferTexture=it,this.useMultisampledRTT=At,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function KD(n,e){function t(i,r=Xo){let s;const l=Hn.getTransfer(r);if(i===fr)return n.UNSIGNED_BYTE;if(i===r_)return n.UNSIGNED_SHORT_4_4_4_4;if(i===a_)return n.UNSIGNED_SHORT_5_5_5_1;if(i===bE)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===xE)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===vE)return n.BYTE;if(i===yE)return n.SHORT;if(i===wp)return n.UNSIGNED_SHORT;if(i===i_)return n.INT;if(i===Bs)return n.UNSIGNED_INT;if(i===xr)return n.FLOAT;if(i===vo)return n.HALF_FLOAT;if(i===_E)return n.ALPHA;if(i===SE)return n.RGB;if(i===ca)return n.RGBA;if(i===zl)return n.DEPTH_COMPONENT;if(i===Dc)return n.DEPTH_STENCIL;if(i===Hu)return n.RED;if(i===D0)return n.RED_INTEGER;if(i===Md)return n.RG;if(i===s_)return n.RG_INTEGER;if(i===o_)return n.RGBA_INTEGER;if(i===jg||i===qg||i===Yg||i===Zg)if(l===ui)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===jg)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===qg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Yg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Zg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===jg)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===qg)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Yg)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Zg)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===qb||i===Yb||i===Zb||i===Kb)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===qb)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Yb)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Zb)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Kb)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Qb||i===Jb||i===ex||i===tx||i===nx||i===ix||i===rx)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Qb||i===Jb)return l===ui?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===ex)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===tx)return s.COMPRESSED_R11_EAC;if(i===nx)return s.COMPRESSED_SIGNED_R11_EAC;if(i===ix)return s.COMPRESSED_RG11_EAC;if(i===rx)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===ax||i===sx||i===ox||i===lx||i===cx||i===ux||i===fx||i===dx||i===hx||i===px||i===mx||i===gx||i===vx||i===yx)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===ax)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===sx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ox)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===lx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===cx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ux)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===fx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===dx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===hx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===px)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===mx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===gx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===vx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===yx)return l===ui?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===bx||i===xx||i===_x)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===bx)return l===ui?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===xx)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===_x)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Sx||i===Mx||i===Ex||i===Tx)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Sx)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Mx)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ex)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Tx)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Sd?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const j5=` void main() { gl_Position = vec4( position, 1.0 ); }`,q5=` 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 Y5{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new IE(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Ln({vertexShader:j5,fragmentShader:q5,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new $n(new Ic(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Z5 extends Hs{constructor(e,t){super();const i=this;let r=null,s=1,l=null,u="local-floor",h=1,p=null,g=null,y=null,b=null,x=null,E=null;const A=typeof XRWebGLBinding<"u",T=new Y5,M={},R=t.getContextAttributes();let O=null,D=null;const F=[],U=[],k=new Be;let H=null;const L=new nr;L.viewport=new fi;const z=new nr;z.viewport=new fi;const W=[L,z],J=new kD;let $=null,oe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ve){let Oe=F[ve];return Oe===void 0&&(Oe=new Lb,F[ve]=Oe),Oe.getTargetRaySpace()},this.getControllerGrip=function(ve){let Oe=F[ve];return Oe===void 0&&(Oe=new Lb,F[ve]=Oe),Oe.getGripSpace()},this.getHand=function(ve){let Oe=F[ve];return Oe===void 0&&(Oe=new Lb,F[ve]=Oe),Oe.getHandSpace()};function ne(ve){const Oe=U.indexOf(ve.inputSource);if(Oe===-1)return;const it=F[Oe];it!==void 0&&(it.update(ve.inputSource,ve.frame,p||l),it.dispatchEvent({type:ve.type,data:ve.inputSource}))}function Y(){r.removeEventListener("select",ne),r.removeEventListener("selectstart",ne),r.removeEventListener("selectend",ne),r.removeEventListener("squeeze",ne),r.removeEventListener("squeezestart",ne),r.removeEventListener("squeezeend",ne),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",K);for(let ve=0;ve=0&&(U[gt]=null,F[gt].disconnect(it))}for(let Oe=0;Oe=U.length){U.push(it),gt=jt;break}else if(U[jt]===null){U[jt]=it,gt=jt;break}if(gt===-1)break}const _t=F[gt];_t&&_t.connect(it)}}const ie=new Q,ge=new Q;function xe(ve,Oe,it){ie.setFromMatrixPosition(Oe.matrixWorld),ge.setFromMatrixPosition(it.matrixWorld);const gt=ie.distanceTo(ge),_t=Oe.projectionMatrix.elements,jt=it.projectionMatrix.elements,pt=_t[14]/(_t[10]-1),mt=_t[14]/(_t[10]+1),He=(_t[9]+1)/_t[5],Ue=(_t[9]-1)/_t[5],Re=(_t[8]-1)/_t[0],ft=(jt[8]+1)/jt[0],Z=pt*Re,At=pt*ft,dt=gt/(-Re+ft),Ct=dt*-Re;if(Oe.matrixWorld.decompose(ve.position,ve.quaternion,ve.scale),ve.translateX(Ct),ve.translateZ(dt),ve.matrixWorld.compose(ve.position,ve.quaternion,ve.scale),ve.matrixWorldInverse.copy(ve.matrixWorld).invert(),_t[10]===-1)ve.projectionMatrix.copy(Oe.projectionMatrix),ve.projectionMatrixInverse.copy(Oe.projectionMatrixInverse);else{const tt=pt+dt,V=mt+dt,N=Z-Ct,ee=At+(gt-Ct),Ee=He*mt/V*tt,Te=Ue*mt/V*tt;ve.projectionMatrix.makePerspective(N,ee,Ee,Te,tt,V),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert()}}function q(ve,Oe){Oe===null?ve.matrixWorld.copy(ve.matrix):ve.matrixWorld.multiplyMatrices(Oe.matrixWorld,ve.matrix),ve.matrixWorldInverse.copy(ve.matrixWorld).invert()}this.updateCamera=function(ve){if(r===null)return;let Oe=ve.near,it=ve.far;T.texture!==null&&(T.depthNear>0&&(Oe=T.depthNear),T.depthFar>0&&(it=T.depthFar)),J.near=z.near=L.near=Oe,J.far=z.far=L.far=it,($!==J.near||oe!==J.far)&&(r.updateRenderState({depthNear:J.near,depthFar:J.far}),$=J.near,oe=J.far),J.layers.mask=ve.layers.mask|6,L.layers.mask=J.layers.mask&3,z.layers.mask=J.layers.mask&5;const gt=ve.parent,_t=J.cameras;q(J,gt);for(let jt=0;jt<_t.length;jt++)q(_t[jt],gt);_t.length===2?xe(J,L,z):J.projectionMatrix.copy(L.projectionMatrix),ce(ve,J,gt)};function ce(ve,Oe,it){it===null?ve.matrix.copy(Oe.matrixWorld):(ve.matrix.copy(it.matrixWorld),ve.matrix.invert(),ve.matrix.multiply(Oe.matrixWorld)),ve.matrix.decompose(ve.position,ve.quaternion,ve.scale),ve.updateMatrixWorld(!0),ve.projectionMatrix.copy(Oe.projectionMatrix),ve.projectionMatrixInverse.copy(Oe.projectionMatrixInverse),ve.isPerspectiveCamera&&(ve.fov=Rp*2*Math.atan(1/ve.projectionMatrix.elements[5]),ve.zoom=1)}this.getCamera=function(){return J},this.getFoveation=function(){if(!(b===null&&x===null))return h},this.setFoveation=function(ve){h=ve,b!==null&&(b.fixedFoveation=ve),x!==null&&x.fixedFoveation!==void 0&&(x.fixedFoveation=ve)},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(J)},this.getCameraTexture=function(ve){return M[ve]};let Se=null;function Ge(ve,Oe){if(g=Oe.getViewerPose(p||l),E=Oe,g!==null){const it=g.views;x!==null&&(e.setRenderTargetFramebuffer(D,x.framebuffer),e.setRenderTarget(D));let gt=!1;it.length!==J.cameras.length&&(J.cameras.length=0,gt=!0);for(let mt=0;mt0&&(T.alphaTest.value=M.alphaTest);const R=e.get(M),O=R.envMap,D=R.envMapRotation;O&&(T.envMap.value=O,ad.copy(D),ad.x*=-1,ad.y*=-1,ad.z*=-1,O.isCubeTexture&&O.isRenderTargetTexture===!1&&(ad.y*=-1,ad.z*=-1),T.envMapRotation.value.setFromMatrix4(K5.makeRotationFromEuler(ad)),T.flipEnvMap.value=O.isCubeTexture&&O.isRenderTargetTexture===!1?-1:1,T.reflectivity.value=M.reflectivity,T.ior.value=M.ior,T.refractionRatio.value=M.refractionRatio),M.lightMap&&(T.lightMap.value=M.lightMap,T.lightMapIntensity.value=M.lightMapIntensity,t(M.lightMap,T.lightMapTransform)),M.aoMap&&(T.aoMap.value=M.aoMap,T.aoMapIntensity.value=M.aoMapIntensity,t(M.aoMap,T.aoMapTransform))}function l(T,M){T.diffuse.value.copy(M.color),T.opacity.value=M.opacity,M.map&&(T.map.value=M.map,t(M.map,T.mapTransform))}function u(T,M){T.dashSize.value=M.dashSize,T.totalSize.value=M.dashSize+M.gapSize,T.scale.value=M.scale}function h(T,M,R,O){T.diffuse.value.copy(M.color),T.opacity.value=M.opacity,T.size.value=M.size*R,T.scale.value=O*.5,M.map&&(T.map.value=M.map,t(M.map,T.uvTransform)),M.alphaMap&&(T.alphaMap.value=M.alphaMap,t(M.alphaMap,T.alphaMapTransform)),M.alphaTest>0&&(T.alphaTest.value=M.alphaTest)}function p(T,M){T.diffuse.value.copy(M.color),T.opacity.value=M.opacity,T.rotation.value=M.rotation,M.map&&(T.map.value=M.map,t(M.map,T.mapTransform)),M.alphaMap&&(T.alphaMap.value=M.alphaMap,t(M.alphaMap,T.alphaMapTransform)),M.alphaTest>0&&(T.alphaTest.value=M.alphaTest)}function g(T,M){T.specular.value.copy(M.specular),T.shininess.value=Math.max(M.shininess,1e-4)}function y(T,M){M.gradientMap&&(T.gradientMap.value=M.gradientMap)}function b(T,M){T.metalness.value=M.metalness,M.metalnessMap&&(T.metalnessMap.value=M.metalnessMap,t(M.metalnessMap,T.metalnessMapTransform)),T.roughness.value=M.roughness,M.roughnessMap&&(T.roughnessMap.value=M.roughnessMap,t(M.roughnessMap,T.roughnessMapTransform)),M.envMap&&(T.envMapIntensity.value=M.envMapIntensity)}function x(T,M,R){T.ior.value=M.ior,M.sheen>0&&(T.sheenColor.value.copy(M.sheenColor).multiplyScalar(M.sheen),T.sheenRoughness.value=M.sheenRoughness,M.sheenColorMap&&(T.sheenColorMap.value=M.sheenColorMap,t(M.sheenColorMap,T.sheenColorMapTransform)),M.sheenRoughnessMap&&(T.sheenRoughnessMap.value=M.sheenRoughnessMap,t(M.sheenRoughnessMap,T.sheenRoughnessMapTransform))),M.clearcoat>0&&(T.clearcoat.value=M.clearcoat,T.clearcoatRoughness.value=M.clearcoatRoughness,M.clearcoatMap&&(T.clearcoatMap.value=M.clearcoatMap,t(M.clearcoatMap,T.clearcoatMapTransform)),M.clearcoatRoughnessMap&&(T.clearcoatRoughnessMap.value=M.clearcoatRoughnessMap,t(M.clearcoatRoughnessMap,T.clearcoatRoughnessMapTransform)),M.clearcoatNormalMap&&(T.clearcoatNormalMap.value=M.clearcoatNormalMap,t(M.clearcoatNormalMap,T.clearcoatNormalMapTransform),T.clearcoatNormalScale.value.copy(M.clearcoatNormalScale),M.side===Lr&&T.clearcoatNormalScale.value.negate())),M.dispersion>0&&(T.dispersion.value=M.dispersion),M.iridescence>0&&(T.iridescence.value=M.iridescence,T.iridescenceIOR.value=M.iridescenceIOR,T.iridescenceThicknessMinimum.value=M.iridescenceThicknessRange[0],T.iridescenceThicknessMaximum.value=M.iridescenceThicknessRange[1],M.iridescenceMap&&(T.iridescenceMap.value=M.iridescenceMap,t(M.iridescenceMap,T.iridescenceMapTransform)),M.iridescenceThicknessMap&&(T.iridescenceThicknessMap.value=M.iridescenceThicknessMap,t(M.iridescenceThicknessMap,T.iridescenceThicknessMapTransform))),M.transmission>0&&(T.transmission.value=M.transmission,T.transmissionSamplerMap.value=R.texture,T.transmissionSamplerSize.value.set(R.width,R.height),M.transmissionMap&&(T.transmissionMap.value=M.transmissionMap,t(M.transmissionMap,T.transmissionMapTransform)),T.thickness.value=M.thickness,M.thicknessMap&&(T.thicknessMap.value=M.thicknessMap,t(M.thicknessMap,T.thicknessMapTransform)),T.attenuationDistance.value=M.attenuationDistance,T.attenuationColor.value.copy(M.attenuationColor)),M.anisotropy>0&&(T.anisotropyVector.value.set(M.anisotropy*Math.cos(M.anisotropyRotation),M.anisotropy*Math.sin(M.anisotropyRotation)),M.anisotropyMap&&(T.anisotropyMap.value=M.anisotropyMap,t(M.anisotropyMap,T.anisotropyMapTransform))),T.specularIntensity.value=M.specularIntensity,T.specularColor.value.copy(M.specularColor),M.specularColorMap&&(T.specularColorMap.value=M.specularColorMap,t(M.specularColorMap,T.specularColorMapTransform)),M.specularIntensityMap&&(T.specularIntensityMap.value=M.specularIntensityMap,t(M.specularIntensityMap,T.specularIntensityMapTransform))}function E(T,M){M.matcap&&(T.matcap.value=M.matcap)}function A(T,M){const R=e.get(M).light;T.referencePosition.value.setFromMatrixPosition(R.matrixWorld),T.nearDistance.value=R.shadow.camera.near,T.farDistance.value=R.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function J5(n,e,t,i){let r={},s={},l=[];const u=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function h(R,O){const D=O.program;i.uniformBlockBinding(R,D)}function p(R,O){let D=r[R.id];D===void 0&&(E(R),D=g(R),r[R.id]=D,R.addEventListener("dispose",T));const F=O.program;i.updateUBOMapping(R,F);const U=e.render.frame;s[R.id]!==U&&(b(R),s[R.id]=U)}function g(R){const O=y();R.__bindingPointIndex=O;const D=n.createBuffer(),F=R.__size,U=R.usage;return n.bindBuffer(n.UNIFORM_BUFFER,D),n.bufferData(n.UNIFORM_BUFFER,F,U),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,O,D),D}function y(){for(let R=0;R0&&(D+=F-U),R.__size=D,R.__cache={},this}function A(R){const O={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(O.boundary=4,O.storage=4):R.isVector2?(O.boundary=8,O.storage=8):R.isVector3||R.isColor?(O.boundary=16,O.storage=12):R.isVector4?(O.boundary=16,O.storage=16):R.isMatrix3?(O.boundary=48,O.storage=48):R.isMatrix4?(O.boundary=64,O.storage=64):R.isTexture?Rt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Rt("WebGLRenderer: Unsupported uniform value type.",R),O}function T(R){const O=R.target;O.removeEventListener("dispose",T);const D=l.indexOf(O.__bindingPointIndex);l.splice(D,1),n.deleteBuffer(r[O.id]),delete r[O.id],delete s[O.id]}function M(){for(const R in r)n.deleteBuffer(r[R]);l=[],r={},s={}}return{bind:h,update:p,dispose:M}}const e2=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Dl=null;function t2(){return Dl===null&&(Dl=new Ta(e2,16,16,Md,vo),Dl.name="DFG_LUT",Dl.minFilter=Kn,Dl.magFilter=Kn,Dl.wrapS=_s,Dl.wrapT=_s,Dl.generateMipmaps=!1,Dl.needsUpdate=!0),Dl}class QD{constructor(e={}){const{canvas:t=X3(),context:i=null,depth:r=!0,stencil:s=!1,alpha:l=!1,antialias:u=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:p=!1,powerPreference:g="default",failIfMajorPerformanceCaveat:y=!1,reversedDepthBuffer:b=!1,outputBufferType:x=fr}=e;this.isWebGLRenderer=!0;let E;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");E=i.getContextAttributes().alpha}else E=l;const A=x,T=new Set([o_,s_,D0]),M=new Set([fr,Bs,wp,Sd,r_,a_]),R=new Uint32Array(4),O=new Int32Array(4);let D=null,F=null;const U=[],k=[];let H=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Us,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const L=this;let z=!1;this._outputColorSpace=Zn;let W=0,J=0,$=null,oe=-1,ne=null;const Y=new fi,K=new fi;let ie=null;const ge=new Mt(0);let xe=0,q=t.width,ce=t.height,Se=1,Ge=null,Ye=null;const ve=new fi(0,0,q,ce),Oe=new fi(0,0,q,ce);let it=!1;const gt=new Bp;let _t=!1,jt=!1;const pt=new rn,mt=new Q,He=new fi,Ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Re=!1;function ft(){return $===null?Se:1}let Z=i;function At(G,ue){return t.getContext(G,ue)}try{const G={alpha:!0,depth:r,stencil:s,antialias:u,premultipliedAlpha:h,preserveDrawingBuffer:p,powerPreference:g,failIfMajorPerformanceCaveat:y};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Rd}`),t.addEventListener("webglcontextlost",It,!1),t.addEventListener("webglcontextrestored",an,!1),t.addEventListener("webglcontextcreationerror",sn,!1),Z===null){const ue="webgl2";if(Z=At(ue,G),Z===null)throw At(ue)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(G){throw Gt("WebGLRenderer: "+G.message),G}let dt,Ct,tt,V,N,ee,Ee,Te,pe,Et,$e,lt,Lt,Ze,rt,vt,te,be,ct,re,Pe,ze,at,je;function Ve(){dt=new nk(Z),dt.init(),ze=new KD(Z,dt),Ct=new j4(Z,dt,e,ze),tt=new X5(Z,dt),Ct.reversedDepthBuffer&&b&&tt.buffers.depth.setReversed(!0),V=new ak(Z),N=new D5,ee=new $5(Z,dt,tt,N,Ct,ze,V),Ee=new Y4(L),Te=new tk(L),pe=new cF(Z),at=new X4(Z,pe),Et=new ik(Z,pe,V,at),$e=new ok(Z,Et,pe,V),ct=new sk(Z,Ct,ee),vt=new q4(N),lt=new R5(L,Ee,Te,dt,Ct,at,vt),Lt=new Q5(L,N),Ze=new I5,rt=new F5(dt),be=new W4(L,Ee,Te,tt,$e,E,h),te=new G5(L,$e,Ct),je=new J5(Z,V,Ct,tt),re=new $4(Z,dt,V),Pe=new rk(Z,dt,V),V.programs=lt.programs,L.capabilities=Ct,L.extensions=dt,L.properties=N,L.renderLists=Ze,L.shadowMap=te,L.state=tt,L.info=V}Ve(),A!==fr&&(H=new ck(A,t.width,t.height,r,s));const nt=new Z5(L,Z);this.xr=nt,this.getContext=function(){return Z},this.getContextAttributes=function(){return Z.getContextAttributes()},this.forceContextLoss=function(){const G=dt.get("WEBGL_lose_context");G&&G.loseContext()},this.forceContextRestore=function(){const G=dt.get("WEBGL_lose_context");G&&G.restoreContext()},this.getPixelRatio=function(){return Se},this.setPixelRatio=function(G){G!==void 0&&(Se=G,this.setSize(q,ce,!1))},this.getSize=function(G){return G.set(q,ce)},this.setSize=function(G,ue,Me=!0){if(nt.isPresenting){Rt("WebGLRenderer: Can't change size while VR device is presenting.");return}q=G,ce=ue,t.width=Math.floor(G*Se),t.height=Math.floor(ue*Se),Me===!0&&(t.style.width=G+"px",t.style.height=ue+"px"),H!==null&&H.setSize(t.width,t.height),this.setViewport(0,0,G,ue)},this.getDrawingBufferSize=function(G){return G.set(q*Se,ce*Se).floor()},this.setDrawingBufferSize=function(G,ue,Me){q=G,ce=ue,Se=Me,t.width=Math.floor(G*Me),t.height=Math.floor(ue*Me),this.setViewport(0,0,G,ue)},this.setEffects=function(G){if(A===fr){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(G){for(let ue=0;ue{function Ae(){if(me.forEach(function(Qe){N.get(Qe).currentProgram.isReady()&&me.delete(Qe)}),me.size===0){de(G);return}setTimeout(Ae,10)}dt.get("KHR_parallel_shader_compile")!==null?Ae():setTimeout(Ae,10)})};let Es=null;function qr(G){Es&&Es(G)}function Fr(){hr.stop()}function Oa(){hr.start()}const hr=new $D;hr.setAnimationLoop(qr),typeof self<"u"&&hr.setContext(self),this.setAnimationLoop=function(G){Es=G,nt.setAnimationLoop(G),G===null?hr.stop():hr.start()},nt.addEventListener("sessionstart",Fr),nt.addEventListener("sessionend",Oa),this.render=function(G,ue){if(ue!==void 0&&ue.isCamera!==!0){Gt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;const Me=nt.enabled===!0&&nt.isPresenting===!0,me=H!==null&&($===null||Me)&&H.begin(L,$);if(G.matrixWorldAutoUpdate===!0&&G.updateMatrixWorld(),ue.parent===null&&ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),nt.enabled===!0&&nt.isPresenting===!0&&(H===null||H.isCompositing()===!1)&&(nt.cameraAutoUpdate===!0&&nt.updateCamera(ue),ue=nt.getCamera()),G.isScene===!0&&G.onBeforeRender(L,G,ue,$),F=rt.get(G,k.length),F.init(ue),k.push(F),pt.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),gt.setFromProjectionMatrix(pt,Ns,ue.reversedDepth),jt=this.localClippingEnabled,_t=vt.init(this.clippingPlanes,jt),D=Ze.get(G,U.length),D.init(),U.push(D),nt.enabled===!0&&nt.isPresenting===!0){const Qe=L.xr.getDepthSensingMesh();Qe!==null&&Br(Qe,ue,-1/0,L.sortObjects)}Br(G,ue,0,L.sortObjects),D.finish(),L.sortObjects===!0&&D.sort(Ge,Ye),Re=nt.enabled===!1||nt.isPresenting===!1||nt.hasDepthSensing()===!1,Re&&be.addToRenderList(D,G),this.info.render.frame++,_t===!0&&vt.beginShadows();const de=F.state.shadowsArray;if(te.render(de,G,ue),_t===!0&&vt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(me&&H.hasRenderPass())===!1){const Qe=D.opaque,he=D.transmissive;if(F.setupLights(),ue.isArrayCamera){const Xe=ue.cameras;if(he.length>0)for(let ot=0,wt=Xe.length;ot0&&ji(Qe,he,G,ue),Re&&be.render(G),Si(D,G,ue)}$!==null&&J===0&&(ee.updateMultisampleRenderTarget($),ee.updateRenderTargetMipmap($)),me&&H.end(L),G.isScene===!0&&G.onAfterRender(L,G,ue),at.resetDefaultState(),oe=-1,ne=null,k.pop(),k.length>0?(F=k[k.length-1],_t===!0&&vt.setGlobalState(L.clippingPlanes,F.state.camera)):F=null,U.pop(),U.length>0?D=U[U.length-1]:D=null};function Br(G,ue,Me,me){if(G.visible===!1)return;if(G.layers.test(ue.layers)){if(G.isGroup)Me=G.renderOrder;else if(G.isLOD)G.autoUpdate===!0&&G.update(ue);else if(G.isLight)F.pushLight(G),G.castShadow&&F.pushShadow(G);else if(G.isSprite){if(!G.frustumCulled||gt.intersectsSprite(G)){me&&He.setFromMatrixPosition(G.matrixWorld).applyMatrix4(pt);const Qe=$e.update(G),he=G.material;he.visible&&D.push(G,Qe,he,Me,He.z,null)}}else if((G.isMesh||G.isLine||G.isPoints)&&(!G.frustumCulled||gt.intersectsObject(G))){const Qe=$e.update(G),he=G.material;if(me&&(G.boundingSphere!==void 0?(G.boundingSphere===null&&G.computeBoundingSphere(),He.copy(G.boundingSphere.center)):(Qe.boundingSphere===null&&Qe.computeBoundingSphere(),He.copy(Qe.boundingSphere.center)),He.applyMatrix4(G.matrixWorld).applyMatrix4(pt)),Array.isArray(he)){const Xe=Qe.groups;for(let ot=0,wt=Xe.length;ot0&&Yr(de,ue,Me),Ae.length>0&&Yr(Ae,ue,Me),Qe.length>0&&Yr(Qe,ue,Me),tt.buffers.depth.setTest(!0),tt.buffers.depth.setMask(!0),tt.buffers.color.setMask(!0),tt.setPolygonOffset(!1)}function ji(G,ue,Me,me){if((Me.isScene===!0?Me.overrideMaterial:null)!==null)return;if(F.state.transmissionRenderTarget[me.id]===void 0){const ut=dt.has("EXT_color_buffer_half_float")||dt.has("EXT_color_buffer_float");F.state.transmissionRenderTarget[me.id]=new ai(1,1,{generateMipmaps:!0,type:ut?vo:fr,minFilter:$o,samples:Ct.samples,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Hn.workingColorSpace})}const Ae=F.state.transmissionRenderTarget[me.id],Qe=me.viewport||Y;Ae.setSize(Qe.z*L.transmissionResolutionScale,Qe.w*L.transmissionResolutionScale);const he=L.getRenderTarget(),Xe=L.getActiveCubeFace(),ot=L.getActiveMipmapLevel();L.setRenderTarget(Ae),L.getClearColor(ge),xe=L.getClearAlpha(),xe<1&&L.setClearColor(16777215,.5),L.clear(),Re&&be.render(Me);const wt=L.toneMapping;L.toneMapping=Us;const Je=me.viewport;if(me.viewport!==void 0&&(me.viewport=void 0),F.setupLightsView(me),_t===!0&&vt.setGlobalState(L.clippingPlanes,me),Yr(G,Me,me),ee.updateMultisampleRenderTarget(Ae),ee.updateRenderTargetMipmap(Ae),dt.has("WEBGL_multisampled_render_to_texture")===!1){let ut=!1;for(let Bt=0,on=ue.length;Bt0),Je=!!Me.morphAttributes.position,ut=!!Me.morphAttributes.normal,Bt=!!Me.morphAttributes.color;let on=Us;me.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(on=L.toneMapping);const en=Me.morphAttributes.position||Me.morphAttributes.normal||Me.morphAttributes.color,kt=en!==void 0?en.length:0,St=N.get(me),Zt=F.state.lights;if(_t===!0&&(jt===!0||G!==ne)){const Hi=G===ne&&me.id===oe;vt.setState(me,G,Hi)}let Ut=!1;me.version===St.__version?(St.needsLights&&St.lightsStateVersion!==Zt.state.version||St.outputColorSpace!==he||de.isBatchedMesh&&St.batching===!1||!de.isBatchedMesh&&St.batching===!0||de.isBatchedMesh&&St.batchingColor===!0&&de.colorTexture===null||de.isBatchedMesh&&St.batchingColor===!1&&de.colorTexture!==null||de.isInstancedMesh&&St.instancing===!1||!de.isInstancedMesh&&St.instancing===!0||de.isSkinnedMesh&&St.skinning===!1||!de.isSkinnedMesh&&St.skinning===!0||de.isInstancedMesh&&St.instancingColor===!0&&de.instanceColor===null||de.isInstancedMesh&&St.instancingColor===!1&&de.instanceColor!==null||de.isInstancedMesh&&St.instancingMorph===!0&&de.morphTexture===null||de.isInstancedMesh&&St.instancingMorph===!1&&de.morphTexture!==null||St.envMap!==Xe||me.fog===!0&&St.fog!==Ae||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==vt.numPlanes||St.numIntersection!==vt.numIntersection)||St.vertexAlphas!==ot||St.vertexTangents!==wt||St.morphTargets!==Je||St.morphNormals!==ut||St.morphColors!==Bt||St.toneMapping!==on||St.morphTargetsCount!==kt)&&(Ut=!0):(Ut=!0,St.__version=me.version);let Sn=St.currentProgram;Ut===!0&&(Sn=Ie(me,ue,de));let di=!1,Tn=!1,oi=!1;const wn=Sn.getUniforms(),hi=St.uniforms;if(tt.useProgram(Sn.program)&&(di=!0,Tn=!0,oi=!0),me.id!==oe&&(oe=me.id,Tn=!0),di||ne!==G){tt.buffers.depth.getReversed()&&G.reversedDepth!==!0&&(G._reversedDepth=!0,G.updateProjectionMatrix()),wn.setValue(Z,"projectionMatrix",G.projectionMatrix),wn.setValue(Z,"viewMatrix",G.matrixWorldInverse);const ar=wn.map.cameraPosition;ar!==void 0&&ar.setValue(Z,mt.setFromMatrixPosition(G.matrixWorld)),Ct.logarithmicDepthBuffer&&wn.setValue(Z,"logDepthBufFC",2/(Math.log(G.far+1)/Math.LN2)),(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial)&&wn.setValue(Z,"isOrthographic",G.isOrthographicCamera===!0),ne!==G&&(ne=G,Tn=!0,oi=!0)}if(St.needsLights&&(Zt.state.directionalShadowMap.length>0&&wn.setValue(Z,"directionalShadowMap",Zt.state.directionalShadowMap,ee),Zt.state.spotShadowMap.length>0&&wn.setValue(Z,"spotShadowMap",Zt.state.spotShadowMap,ee),Zt.state.pointShadowMap.length>0&&wn.setValue(Z,"pointShadowMap",Zt.state.pointShadowMap,ee)),de.isSkinnedMesh){wn.setOptional(Z,de,"bindMatrix"),wn.setOptional(Z,de,"bindMatrixInverse");const Hi=de.skeleton;Hi&&(Hi.boneTexture===null&&Hi.computeBoneTexture(),wn.setValue(Z,"boneTexture",Hi.boneTexture,ee))}de.isBatchedMesh&&(wn.setOptional(Z,de,"batchingTexture"),wn.setValue(Z,"batchingTexture",de._matricesTexture,ee),wn.setOptional(Z,de,"batchingIdTexture"),wn.setValue(Z,"batchingIdTexture",de._indirectTexture,ee),wn.setOptional(Z,de,"batchingColorTexture"),de._colorsTexture!==null&&wn.setValue(Z,"batchingColorTexture",de._colorsTexture,ee));const Oi=Me.morphAttributes;if((Oi.position!==void 0||Oi.normal!==void 0||Oi.color!==void 0)&&ct.update(de,Me,Sn),(Tn||St.receiveShadow!==de.receiveShadow)&&(St.receiveShadow=de.receiveShadow,wn.setValue(Z,"receiveShadow",de.receiveShadow)),me.isMeshGouraudMaterial&&me.envMap!==null&&(hi.envMap.value=Xe,hi.flipEnvMap.value=Xe.isCubeTexture&&Xe.isRenderTargetTexture===!1?-1:1),me.isMeshStandardMaterial&&me.envMap===null&&ue.environment!==null&&(hi.envMapIntensity.value=ue.environmentIntensity),hi.dfgLUT!==void 0&&(hi.dfgLUT.value=t2()),Tn&&(wn.setValue(Z,"toneMappingExposure",L.toneMappingExposure),St.needsLights&&Dn(hi,oi),Ae&&me.fog===!0&&Lt.refreshFogUniforms(hi,Ae),Lt.refreshMaterialUniforms(hi,me,Se,ce,F.state.transmissionRenderTarget[G.id]),Nb.upload(Z,Ke(St),hi,ee)),me.isShaderMaterial&&me.uniformsNeedUpdate===!0&&(Nb.upload(Z,Ke(St),hi,ee),me.uniformsNeedUpdate=!1),me.isSpriteMaterial&&wn.setValue(Z,"center",de.center),wn.setValue(Z,"modelViewMatrix",de.modelViewMatrix),wn.setValue(Z,"normalMatrix",de.normalMatrix),wn.setValue(Z,"modelMatrix",de.matrixWorld),me.isShaderMaterial||me.isRawShaderMaterial){const Hi=me.uniformsGroups;for(let ar=0,xo=Hi.length;ar0&&ee.useMultisampledRTT(G)===!1?me=N.get(G).__webglMultisampledFramebuffer:Array.isArray(ot)?me=ot[Me]:me=ot,Y.copy(G.viewport),K.copy(G.scissor),ie=G.scissorTest}else Y.copy(ve).multiplyScalar(Se).floor(),K.copy(Oe).multiplyScalar(Se).floor(),ie=it;if(Me!==0&&(me=un),tt.bindFramebuffer(Z.FRAMEBUFFER,me)&&tt.drawBuffers(G,me),tt.viewport(Y),tt.scissor(K),tt.setScissorTest(ie),de){const he=N.get(G.texture);Z.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_CUBE_MAP_POSITIVE_X+ue,he.__webglTexture,Me)}else if(Ae){const he=ue;for(let Xe=0;Xe=0&&ue<=G.width-me&&Me>=0&&Me<=G.height-de&&(G.textures.length>1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+he),Z.readPixels(ue,Me,me,de,ze.convert(wt),ze.convert(Je),Ae))}finally{const ot=$!==null?N.get($).__webglFramebuffer:null;tt.bindFramebuffer(Z.FRAMEBUFFER,ot)}}},this.readRenderTargetPixelsAsync=async function(G,ue,Me,me,de,Ae,Qe,he=0){if(!(G&&G.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Xe=N.get(G).__webglFramebuffer;if(G.isWebGLCubeRenderTarget&&Qe!==void 0&&(Xe=Xe[Qe]),Xe)if(ue>=0&&ue<=G.width-me&&Me>=0&&Me<=G.height-de){tt.bindFramebuffer(Z.FRAMEBUFFER,Xe);const ot=G.textures[he],wt=ot.format,Je=ot.type;if(!Ct.textureFormatReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ct.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ut=Z.createBuffer();Z.bindBuffer(Z.PIXEL_PACK_BUFFER,ut),Z.bufferData(Z.PIXEL_PACK_BUFFER,Ae.byteLength,Z.STREAM_READ),G.textures.length>1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+he),Z.readPixels(ue,Me,me,de,ze.convert(wt),ze.convert(Je),0);const Bt=$!==null?N.get($).__webglFramebuffer:null;tt.bindFramebuffer(Z.FRAMEBUFFER,Bt);const on=Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE,0);return Z.flush(),await fN(Z,on,4),Z.bindBuffer(Z.PIXEL_PACK_BUFFER,ut),Z.getBufferSubData(Z.PIXEL_PACK_BUFFER,0,Ae),Z.deleteBuffer(ut),Z.deleteSync(on),Ae}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(G,ue=null,Me=0){const me=Math.pow(2,-Me),de=Math.floor(G.image.width*me),Ae=Math.floor(G.image.height*me),Qe=ue!==null?ue.x:0,he=ue!==null?ue.y:0;ee.setTexture2D(G,0),Z.copyTexSubImage2D(Z.TEXTURE_2D,Me,0,0,Qe,he,de,Ae),tt.unbindTexture()};const Ei=Z.createFramebuffer(),ki=Z.createFramebuffer();this.copyTextureToTexture=function(G,ue,Me=null,me=null,de=0,Ae=null){Ae===null&&(de!==0?(Cp("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ae=de,de=0):Ae=0);let Qe,he,Xe,ot,wt,Je,ut,Bt,on;const en=G.isCompressedTexture?G.mipmaps[Ae]:G.image;if(Me!==null)Qe=Me.max.x-Me.min.x,he=Me.max.y-Me.min.y,Xe=Me.isBox3?Me.max.z-Me.min.z:1,ot=Me.min.x,wt=Me.min.y,Je=Me.isBox3?Me.min.z:0;else{const Oi=Math.pow(2,-de);Qe=Math.floor(en.width*Oi),he=Math.floor(en.height*Oi),G.isDataArrayTexture?Xe=en.depth:G.isData3DTexture?Xe=Math.floor(en.depth*Oi):Xe=1,ot=0,wt=0,Je=0}me!==null?(ut=me.x,Bt=me.y,on=me.z):(ut=0,Bt=0,on=0);const kt=ze.convert(ue.format),St=ze.convert(ue.type);let Zt;ue.isData3DTexture?(ee.setTexture3D(ue,0),Zt=Z.TEXTURE_3D):ue.isDataArrayTexture||ue.isCompressedArrayTexture?(ee.setTexture2DArray(ue,0),Zt=Z.TEXTURE_2D_ARRAY):(ee.setTexture2D(ue,0),Zt=Z.TEXTURE_2D),Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL,ue.flipY),Z.pixelStorei(Z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ue.premultiplyAlpha),Z.pixelStorei(Z.UNPACK_ALIGNMENT,ue.unpackAlignment);const Ut=Z.getParameter(Z.UNPACK_ROW_LENGTH),Sn=Z.getParameter(Z.UNPACK_IMAGE_HEIGHT),di=Z.getParameter(Z.UNPACK_SKIP_PIXELS),Tn=Z.getParameter(Z.UNPACK_SKIP_ROWS),oi=Z.getParameter(Z.UNPACK_SKIP_IMAGES);Z.pixelStorei(Z.UNPACK_ROW_LENGTH,en.width),Z.pixelStorei(Z.UNPACK_IMAGE_HEIGHT,en.height),Z.pixelStorei(Z.UNPACK_SKIP_PIXELS,ot),Z.pixelStorei(Z.UNPACK_SKIP_ROWS,wt),Z.pixelStorei(Z.UNPACK_SKIP_IMAGES,Je);const wn=G.isDataArrayTexture||G.isData3DTexture,hi=ue.isDataArrayTexture||ue.isData3DTexture;if(G.isDepthTexture){const Oi=N.get(G),Hi=N.get(ue),ar=N.get(Oi.__renderTarget),xo=N.get(Hi.__renderTarget);tt.bindFramebuffer(Z.READ_FRAMEBUFFER,ar.__webglFramebuffer),tt.bindFramebuffer(Z.DRAW_FRAMEBUFFER,xo.__webglFramebuffer);for(let Kr=0;Kr"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:u;return w1.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:g,w1}var KA;function r2(){return KA||(KA=1,T1.exports=i2()),T1.exports}var QA;function a2(){if(QA)return E1;QA=1;var n=C0(),e=r2();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var i=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,s=n.useRef,l=n.useEffect,u=n.useMemo,h=n.useDebugValue;return E1.useSyncExternalStoreWithSelector=function(p,g,y,b,x){var E=s(null);if(E.current===null){var A={hasValue:!1,value:null};E.current=A}else A=E.current;E=u(function(){function M(U){if(!R){if(R=!0,O=U,U=b(U),x!==void 0&&A.hasValue){var k=A.value;if(x(k,U))return D=k}return D=U}if(k=D,i(O,U))return k;var H=b(U);return x!==void 0&&x(k,H)?(O=U,k):(O=U,D=H)}var R=!1,O,D,F=y===void 0?null:y;return[function(){return M(g())},F===null?void 0:function(){return M(F())}]},[g,y,b,x]);var T=r(p,E[0],E[1]);return l(function(){A.hasValue=!0,A.value=T},[T]),h(T),T},E1}var JA;function s2(){return JA||(JA=1,M1.exports=a2()),M1.exports}var o2=s2();const l2=ef(o2),eC=n=>{let e;const t=new Set,i=(p,g)=>{const y=typeof p=="function"?p(e):p;if(!Object.is(y,e)){const b=e;e=g??(typeof y!="object"||y===null)?y:Object.assign({},e,y),t.forEach(x=>x(e,b))}},r=()=>e,u={setState:i,getState:r,getInitialState:()=>h,subscribe:p=>(t.add(p),()=>t.delete(p))},h=e=n(i,r,u);return u},c2=(n=>n?eC(n):eC),{useSyncExternalStoreWithSelector:u2}=l2,f2=n=>n;function d2(n,e=f2,t){const i=u2(n.subscribe,n.getState,n.getInitialState,e,t);return ae.useDebugValue(i),i}const tC=(n,e)=>{const t=c2(n),i=(r,s=e)=>d2(t,r,s);return Object.assign(i,t),i},h2=((n,e)=>n?tC(n,e):tC);var RM=f3();const p2=ef(RM);function tT(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const r=tT(i,e,t);if(r)return r;i=e?null:i.sibling}}function JD(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const nT=JD(P.createContext(null));let eO=class extends P.Component{render(){return P.createElement(nT.Provider,{value:this._reactInternals},this.props.children)}};function tO(){const n=P.useContext(nT);if(n===null)throw new Error("its-fine: useFiber must be called within a !");const e=P.useId();return P.useMemo(()=>{for(const t of[n,n?.alternate]){if(!t)continue;const i=tT(t,!1,r=>{let s=r.memoizedState;for(;s;){if(s.memoizedState===e)return!0;s=s.next}});if(i)return i}},[n,e])}const m2=Symbol.for("react.context"),g2=n=>n!==null&&typeof n=="object"&&"$$typeof"in n&&n.$$typeof===m2;function v2(){const n=tO(),[e]=P.useState(()=>new Map);e.clear();let t=n;for(;t;){const i=t.type;g2(i)&&i!==nT&&!e.has(i)&&e.set(i,P.use(JD(i))),t=t.return}return e}function y2(){const n=v2();return P.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>P.createElement(e,null,P.createElement(t.Provider,{...i,value:n.get(t)})),e=>P.createElement(eO,{...e})),[n])}function nO(n){let e=n.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const iO=n=>n&&n.isOrthographicCamera,b2=n=>n&&n.hasOwnProperty("current"),x2=n=>n!=null&&(typeof n=="string"||typeof n=="number"||n.isColor),F0=((n,e)=>typeof window<"u"&&(((n=window.document)==null?void 0:n.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?P.useLayoutEffect:P.useEffect;function rO(n){const e=P.useRef(n);return F0(()=>{e.current=n},[n]),e}function _2(){const n=tO(),e=y2();return P.useMemo(()=>({children:t})=>{const r=!!tT(n,!0,s=>s.type===P.StrictMode)?P.StrictMode:P.Fragment;return xt.jsx(r,{children:xt.jsx(e,{children:t})})},[n,e])}function S2({set:n}){return F0(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}const M2=(n=>(n=class extends P.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}},n.getDerivedStateFromError=()=>({error:!0}),n))();function aO(n){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(n)?Math.min(Math.max(n[0],t),n[1]):n}function cp(n){var e;return(e=n.__r3f)==null?void 0:e.root.getState()}const tr={obj:n=>n===Object(n)&&!tr.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,nul:n=>n===null,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:i="reference",strict:r=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(tr.str(n)||tr.num(n)||tr.boo(n))return n===e;const s=tr.obj(n);if(s&&i==="reference")return n===e;const l=tr.arr(n);if(l&&t==="reference")return n===e;if((l||s)&&n===e)return!0;let u;for(u in n)if(!(u in e))return!1;if(s&&t==="shallow"&&i==="shallow"){for(u in r?e:n)if(!tr.equ(n[u],e[u],{strict:r,objects:"reference"}))return!1}else for(u in r?e:n)if(n[u]!==e[u])return!1;if(tr.und(u)){if(l&&n.length===0&&e.length===0||s&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function E2(n){n.type!=="Scene"&&(n.dispose==null||n.dispose());for(const e in n){const t=n[e];t?.type!=="Scene"&&(t==null||t.dispose==null||t.dispose())}}const sO=["children","key","ref"];function T2(n){const e={};for(const t in n)sO.includes(t)||(e[t]=n[t]);return e}function Ox(n,e,t,i){const r=n;let s=r?.__r3f;return s||(s={root:e,type:t,parent:null,children:[],props:T2(i),object:r,eventCount:0,handlers:{},isHidden:!1},r&&(r.__r3f=s)),s}function M0(n,e){if(!e.includes("-"))return{root:n,key:e,target:n[e]};if(e in n)return{root:n,key:e,target:n[e]};let t=n;const i=e.split("-");for(const r of i){if(typeof t!="object"||t===null){if(t!==void 0){const s=i.slice(i.indexOf(r)).join("-");return{root:t,key:s,target:void 0}}return{root:n,key:e,target:void 0}}e=r,n=t,t=t[e]}return{root:n,key:e,target:t}}const nC=/-\d+$/;function Ix(n,e){if(tr.str(e.props.attach)){if(nC.test(e.props.attach)){const r=e.props.attach.replace(nC,""),{root:s,key:l}=M0(n.object,r);Array.isArray(s[l])||(s[l]=[])}const{root:t,key:i}=M0(n.object,e.props.attach);e.previousAttach=t[i],t[i]=e.object}else tr.fun(e.props.attach)&&(e.previousAttach=e.props.attach(n.object,e.object))}function Px(n,e){if(tr.str(e.props.attach)){const{root:t,key:i}=M0(n.object,e.props.attach),r=e.previousAttach;r===void 0?delete t[i]:t[i]=r}else e.previousAttach==null||e.previousAttach(n.object,e.object);delete e.previousAttach}const DM=[...sO,"args","dispose","attach","object","onUpdate","dispose"],iC=new Map;function w2(n){let e=iC.get(n.constructor);try{e||(e=new n.constructor,iC.set(n.constructor,e))}catch{}return e}function A2(n,e){const t={};for(const i in e)if(!DM.includes(i)&&!tr.equ(e[i],n.props[i])){t[i]=e[i];for(const r in e)r.startsWith(`${i}-`)&&(t[r]=e[r])}for(const i in n.props){if(DM.includes(i)||e.hasOwnProperty(i))continue;const{root:r,key:s}=M0(n.object,i);if(r.constructor&&r.constructor.length===0){const l=w2(r);tr.und(l)||(t[s]=l[s])}else t[s]=0}return t}const C2=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],R2=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function ku(n,e){var t;const i=n.__r3f,r=i&&nO(i).getState(),s=i?.eventCount;for(const u in e){let h=e[u];if(DM.includes(u))continue;if(i&&R2.test(u)){typeof h=="function"?i.handlers[u]=h:delete i.handlers[u],i.eventCount=Object.keys(i.handlers).length;continue}if(h===void 0)continue;let{root:p,key:g,target:y}=M0(n,u);if(y===void 0&&(typeof p!="object"||p===null))throw Error(`R3F: Cannot set "${u}". Ensure it is an object before setting "${g}".`);if(y instanceof Dp&&h instanceof Dp)y.mask=h.mask;else if(y instanceof Mt&&x2(h))y.set(h);else if(y!==null&&typeof y=="object"&&typeof y.set=="function"&&typeof y.copy=="function"&&h!=null&&h.constructor&&y.constructor===h.constructor)y.copy(h);else if(y!==null&&typeof y=="object"&&typeof y.set=="function"&&Array.isArray(h))typeof y.fromArray=="function"?y.fromArray(h):y.set(...h);else if(y!==null&&typeof y=="object"&&typeof y.set=="function"&&typeof h=="number")typeof y.setScalar=="function"?y.setScalar(h):y.set(h);else{var l;p[g]=h,r&&!r.linear&&C2.includes(g)&&(l=p[g])!=null&&l.isTexture&&p[g].format===ca&&p[g].type===fr&&(p[g].colorSpace=Zn)}}if(i!=null&&i.parent&&r!=null&&r.internal&&(t=i.object)!=null&&t.isObject3D&&s!==i.eventCount){const u=i.object,h=r.internal.interaction.indexOf(u);h>-1&&r.internal.interaction.splice(h,1),i.eventCount&&u.raycast!==null&&r.internal.interaction.push(u)}return i&&i.props.attach===void 0&&(i.object.isBufferGeometry?i.props.attach="geometry":i.object.isMaterial&&(i.props.attach="material")),i&&Hp(i),n}function Hp(n){var e;if(!n.parent)return;n.props.onUpdate==null||n.props.onUpdate(n.object);const t=(e=n.root)==null||e.getState==null?void 0:e.getState();t&&t.internal.frames===0&&t.invalidate()}function D2(n,e){n.manual||(iO(n)?(n.left=e.width/-2,n.right=e.width/2,n.top=e.height/2,n.bottom=e.height/-2):n.aspect=e.width/e.height,n.updateProjectionMatrix())}const bs=n=>n?.isObject3D;function _b(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function oO(n,e,t,i){const r=t.get(e);r&&(t.delete(e),t.size===0&&(n.delete(i),r.target.releasePointerCapture(i)))}function O2(n,e){const{internal:t}=n.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,r)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((i,r)=>{oO(t.capturedMap,e,i,r)})}function I2(n){function e(h){const{internal:p}=n.getState(),g=h.offsetX-p.initialClick[0],y=h.offsetY-p.initialClick[1];return Math.round(Math.sqrt(g*g+y*y))}function t(h){return h.filter(p=>["Move","Over","Enter","Out","Leave"].some(g=>{var y;return(y=p.__r3f)==null?void 0:y.handlers["onPointer"+g]}))}function i(h,p){const g=n.getState(),y=new Set,b=[],x=p?p(g.internal.interaction):g.internal.interaction;for(let M=0;M{const O=cp(M.object),D=cp(R.object);return!O||!D?M.distance-R.distance:D.events.priority-O.events.priority||M.distance-R.distance}).filter(M=>{const R=_b(M);return y.has(R)?!1:(y.add(R),!0)});g.events.filter&&(A=g.events.filter(A,g));for(const M of A){let R=M.object;for(;R;){var T;(T=R.__r3f)!=null&&T.eventCount&&b.push({...M,eventObject:R}),R=R.parent}}if("pointerId"in h&&g.internal.capturedMap.has(h.pointerId))for(let M of g.internal.capturedMap.get(h.pointerId).values())y.has(_b(M.intersection))||b.push(M.intersection);return b}function r(h,p,g,y){if(h.length){const b={stopped:!1};for(const x of h){let E=cp(x.object);if(E||x.object.traverseAncestors(A=>{const T=cp(A);if(T)return E=T,!1}),E){const{raycaster:A,pointer:T,camera:M,internal:R}=E,O=new Q(T.x,T.y,0).unproject(M),D=L=>{var z,W;return(z=(W=R.capturedMap.get(L))==null?void 0:W.has(x.eventObject))!=null?z:!1},F=L=>{const z={intersection:x,target:p.target};R.capturedMap.has(L)?R.capturedMap.get(L).set(x.eventObject,z):R.capturedMap.set(L,new Map([[x.eventObject,z]])),p.target.setPointerCapture(L)},U=L=>{const z=R.capturedMap.get(L);z&&oO(R.capturedMap,x.eventObject,z,L)};let k={};for(let L in p){let z=p[L];typeof z!="function"&&(k[L]=z)}let H={...x,...k,pointer:T,intersections:h,stopped:b.stopped,delta:g,unprojectedPoint:O,ray:A.ray,camera:M,stopPropagation(){const L="pointerId"in p&&R.capturedMap.get(p.pointerId);if((!L||L.has(x.eventObject))&&(H.stopped=b.stopped=!0,R.hovered.size&&Array.from(R.hovered.values()).find(z=>z.eventObject===x.eventObject))){const z=h.slice(0,h.indexOf(x));s([...z,x])}},target:{hasPointerCapture:D,setPointerCapture:F,releasePointerCapture:U},currentTarget:{hasPointerCapture:D,setPointerCapture:F,releasePointerCapture:U},nativeEvent:p};if(y(H),b.stopped===!0)break}}}return h}function s(h){const{internal:p}=n.getState();for(const g of p.hovered.values())if(!h.length||!h.find(y=>y.object===g.object&&y.index===g.index&&y.instanceId===g.instanceId)){const b=g.eventObject.__r3f;if(p.hovered.delete(_b(g)),b!=null&&b.eventCount){const x=b.handlers,E={...g,intersections:h};x.onPointerOut==null||x.onPointerOut(E),x.onPointerLeave==null||x.onPointerLeave(E)}}}function l(h,p){for(let g=0;gs([]);case"onLostPointerCapture":return p=>{const{internal:g}=n.getState();"pointerId"in p&&g.capturedMap.has(p.pointerId)&&requestAnimationFrame(()=>{g.capturedMap.has(p.pointerId)&&(g.capturedMap.delete(p.pointerId),s([]))})}}return function(g){const{onPointerMissed:y,internal:b}=n.getState();b.lastEvent.current=g;const x=h==="onPointerMove",E=h==="onClick"||h==="onContextMenu"||h==="onDoubleClick",T=i(g,x?t:void 0),M=E?e(g):0;h==="onPointerDown"&&(b.initialClick=[g.offsetX,g.offsetY],b.initialHits=T.map(O=>O.eventObject)),E&&!T.length&&M<=2&&(l(g,b.interaction),y&&y(g)),x&&s(T);function R(O){const D=O.eventObject,F=D.__r3f;if(!(F!=null&&F.eventCount))return;const U=F.handlers;if(x){if(U.onPointerOver||U.onPointerEnter||U.onPointerOut||U.onPointerLeave){const k=_b(O),H=b.hovered.get(k);H?H.stopped&&O.stopPropagation():(b.hovered.set(k,O),U.onPointerOver==null||U.onPointerOver(O),U.onPointerEnter==null||U.onPointerEnter(O))}U.onPointerMove==null||U.onPointerMove(O)}else{const k=U[h];k?(!E||b.initialHits.includes(D))&&(l(g,b.interaction.filter(H=>!b.initialHits.includes(H))),k(O)):E&&b.initialHits.includes(D)&&l(g,b.interaction.filter(H=>!b.initialHits.includes(H)))}}r(T,g,M,R)}}return{handlePointer:u}}const rC=n=>!!(n!=null&&n.render),lO=P.createContext(null),P2=(n,e)=>{const t=h2((u,h)=>{const p=new Q,g=new Q,y=new Q;function b(M=h().camera,R=g,O=h().size){const{width:D,height:F,top:U,left:k}=O,H=D/F;R.isVector3?y.copy(R):y.set(...R);const L=M.getWorldPosition(p).distanceTo(y);if(iO(M))return{width:D/M.zoom,height:F/M.zoom,top:U,left:k,factor:1,distance:L,aspect:H};{const z=M.fov*Math.PI/180,W=2*Math.tan(z/2)*L,J=W*(D/F);return{width:J,height:W,top:U,left:k,factor:D/J,distance:L,aspect:H}}}let x;const E=M=>u(R=>({performance:{...R.performance,current:M}})),A=new Be;return{set:u,get:h,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(M=1)=>n(h(),M),advance:(M,R)=>e(M,R,h()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new KE,pointer:A,mouse:A,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const M=h();x&&clearTimeout(x),M.performance.current!==M.performance.min&&E(M.performance.min),x=setTimeout(()=>E(h().performance.max),M.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:b},setEvents:M=>u(R=>({...R,events:{...R.events,...M}})),setSize:(M,R,O=0,D=0)=>{const F=h().camera,U={width:M,height:R,top:O,left:D};u(k=>({size:U,viewport:{...k.viewport,...b(F,g,U)}}))},setDpr:M=>u(R=>{const O=aO(M);return{viewport:{...R.viewport,dpr:O,initialDpr:R.viewport.initialDpr||O}}}),setFrameloop:(M="always")=>{const R=h().clock;R.stop(),R.elapsedTime=0,M!=="never"&&(R.start(),R.elapsedTime=0),u(()=>({frameloop:M}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:P.createRef(),active:!1,frames:0,priority:0,subscribe:(M,R,O)=>{const D=h().internal;return D.priority=D.priority+(R>0?1:0),D.subscribers.push({ref:M,priority:R,store:O}),D.subscribers=D.subscribers.sort((F,U)=>F.priority-U.priority),()=>{const F=h().internal;F!=null&&F.subscribers&&(F.priority=F.priority-(R>0?1:0),F.subscribers=F.subscribers.filter(U=>U.ref!==M))}}}}}),i=t.getState();let r=i.size,s=i.viewport.dpr,l=i.camera;return t.subscribe(()=>{const{camera:u,size:h,viewport:p,gl:g,set:y}=t.getState();if(h.width!==r.width||h.height!==r.height||p.dpr!==s){r=h,s=p.dpr,D2(u,h),p.dpr>0&&g.setPixelRatio(p.dpr);const b=typeof HTMLCanvasElement<"u"&&g.domElement instanceof HTMLCanvasElement;g.setSize(h.width,h.height,b)}u!==l&&(l=u,y(b=>({viewport:{...b.viewport,...b.viewport.getCurrentViewport(u)}})))}),t.subscribe(u=>n(u)),t};function cO(){const n=P.useContext(lO);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function Di(n=t=>t,e){return cO()(n,e)}function Wo(n,e=0){const t=cO(),i=t.getState().internal.subscribe,r=rO(n);return F0(()=>i(r,e,t),[e,i,t]),null}const L2=1,N2=8,U2=32,z2=2;var F2={version:"9.5.0"};function B2(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var aC={exports:{}},sC={exports:{}},oC;function k2(){return oC||(oC=1,(function(n){n.exports=function(e){function t(c,f,v,_){return new ym(c,f,v,_)}function i(){}function r(c){var f="https://react.dev/errors/"+c;if(1oc||(c.current=Eh[oc],Eh[oc]=null,oc--)}function E(c,f){oc++,Eh[oc]=c.current,c.current=f}function A(c){return c>>>=0,c===0?32:31-(Th(c)/uy|0)|0}function T(c){var f=c&42;if(f!==0)return f;switch(c&-c){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 c&261888;case 262144:case 524288:case 1048576:case 2097152:return c&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return c&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return c}}function M(c,f,v){var _=c.pendingLanes;if(_===0)return 0;var C=0,I=c.suspendedLanes,X=c.pingedLanes;c=c.warmLanes;var le=_&134217727;return le!==0?(_=le&~I,_!==0?C=T(_):(X&=le,X!==0?C=T(X):v||(v=le&~c,v!==0&&(C=T(v))))):(le=_&~I,le!==0?C=T(le):X!==0?C=T(X):v||(v=_&~c,v!==0&&(C=T(v)))),C===0?0:f!==0&&f!==C&&(f&I)===0&&(I=C&-C,v=f&-f,I>=v||I===32&&(v&4194048)!==0)?f:C}function R(c,f){return(c.pendingLanes&~(c.suspendedLanes&~c.pingedLanes)&f)===0}function O(c,f){switch(c){case 1:case 2:case 4:case 8:case 64:return f+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 f+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 D(){var c=hu;return hu<<=1,(hu&62914560)===0&&(hu=4194304),c}function F(c){for(var f=[],v=0;31>v;v++)f.push(c);return f}function U(c,f){c.pendingLanes|=f,f!==268435456&&(c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0)}function k(c,f,v,_,C,I){var X=c.pendingLanes;c.pendingLanes=v,c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0,c.expiredLanes&=v,c.entangledLanes&=v,c.errorRecoveryDisabledLanes&=v,c.shellSuspendCounter=0;var le=c.entanglements,Fe=c.expirationTimes,st=c.hiddenUpdates;for(v=X&~v;0)":-1C||Fe[_]!==st[C]){var Tt=` `+Fe[_].replace(" at new "," at ");return c.displayName&&Tt.includes("")&&(Tt=Tt.replace("",c.displayName)),Tt}while(1<=_&&0<=C);break}}}finally{Uf=!1,Error.prepareStackTrace=v}return(v=c?c.displayName||c.name:"")?ne(v):""}function K(c,f){switch(c.tag){case 26:case 27:case 5:return ne(c.type);case 16:return ne("Lazy");case 13:return c.child!==f&&f!==null?ne("Suspense Fallback"):ne("Suspense");case 19:return ne("SuspenseList");case 0:case 15:return Y(c.type,!1);case 11:return Y(c.type.render,!1);case 1:return Y(c.type,!0);case 31:return ne("Activity");default:return""}}function ie(c){try{var f="",v=null;do f+=K(c,v),v=c,c=c.return;while(c);return f}catch(_){return` Error generating stack: `+_.message+` `+_.stack}}function ge(c,f){if(typeof c=="object"&&c!==null){var v=rg.get(c);return v!==void 0?v:(f={value:c,source:f,stack:ie(f)},rg.set(c,f),f)}return{value:c,source:f,stack:ie(f)}}function xe(c,f){Io[io++]=zf,Io[io++]=ci,ci=c,zf=f}function q(c,f,v){os[za++]=Dr,os[za++]=ws,os[za++]=ls,ls=c;var _=Dr;c=ws;var C=32-ga(_)-1;_&=~(1<>=X,C-=X,Dr=1<<32-ga(f)+C|v<Bn?(wr=Kt,Kt=null):wr=Kt.sibling;var qn=Ot(De,Kt,Ne[Bn],bt);if(qn===null){Kt===null&&(Kt=wr);break}c&&Kt&&qn.alternate===null&&f(De,Kt),_e=I(qn,_e,Bn),Fi===null?qt=qn:Fi.sibling=qn,Fi=qn,Kt=wr}if(Bn===Ne.length)return v(De,Kt),In&&xe(De,Bn),qt;if(Kt===null){for(;BnBn?(wr=Kt,Kt=null):wr=Kt.sibling;var ms=Ot(De,Kt,qn.value,bt);if(ms===null){Kt===null&&(Kt=wr);break}c&&Kt&&ms.alternate===null&&f(De,Kt),_e=I(ms,_e,Bn),Fi===null?qt=ms:Fi.sibling=ms,Fi=ms,Kt=wr}if(qn.done)return v(De,Kt),In&&xe(De,Bn),qt;if(Kt===null){for(;!qn.done;Bn++,qn=Ne.next())qn=ht(De,qn.value,bt),qn!==null&&(_e=I(qn,_e,Bn),Fi===null?qt=qn:Fi.sibling=qn,Fi=qn);return In&&xe(De,Bn),qt}for(Kt=_(Kt);!qn.done;Bn++,qn=Ne.next())qn=fn(Kt,De,Bn,qn.value,bt),qn!==null&&(c&&qn.alternate!==null&&Kt.delete(qn.key===null?Bn:qn.key),_e=I(qn,_e,Bn),Fi===null?qt=qn:Fi.sibling=qn,Fi=qn);return c&&Kt.forEach(function(sS){return f(De,sS)}),In&&xe(De,Bn),qt}function Al(De,_e,Ne,bt){if(typeof Ne=="object"&&Ne!==null&&Ne.type===ec&&Ne.key===null&&(Ne=Ne.props.children),typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case eo:e:{for(var qt=Ne.key;_e!==null;){if(_e.key===qt){if(qt=Ne.type,qt===ec){if(_e.tag===7){v(De,_e.sibling),bt=C(_e,Ne.props.children),bt.return=De,De=bt;break e}}else if(_e.elementType===qt||typeof qt=="object"&&qt!==null&&qt.$$typeof===ta&&an(qt)===_e.type){v(De,_e.sibling),bt=C(_e,Ne.props),zr(bt,Ne),bt.return=De,De=bt;break e}v(De,_e);break}else f(De,_e);_e=_e.sibling}Ne.type===ec?(bt=is(Ne.props.children,De.mode,bt,Ne.key),bt.return=De,De=bt):(bt=Ao(Ne.type,Ne.key,Ne.props,null,De.mode,bt),zr(bt,Ne),bt.return=De,De=bt)}return X(De);case Jl:e:{for(qt=Ne.key;_e!==null;){if(_e.key===qt)if(_e.tag===4&&_e.stateNode.containerInfo===Ne.containerInfo&&_e.stateNode.implementation===Ne.implementation){v(De,_e.sibling),bt=C(_e,Ne.children||[]),bt.return=De,De=bt;break e}else{v(De,_e);break}else f(De,_e);_e=_e.sibling}bt=_m(Ne,De.mode,bt),bt.return=De,De=bt}return X(De);case ta:return Ne=an(Ne),Al(De,_e,Ne,bt)}if(hl(Ne))return Ji(De,_e,Ne,bt);if(g(Ne)){if(qt=g(Ne),typeof qt!="function")throw Error(r(150));return Ne=qt.call(Ne),Su(De,_e,Ne,bt)}if(typeof Ne.then=="function")return Al(De,_e,_i(Ne),bt);if(Ne.$$typeof===rs)return Al(De,_e,N(De,Ne),bt);Ka(De,Ne)}return typeof Ne=="string"&&Ne!==""||typeof Ne=="number"||typeof Ne=="bigint"?(Ne=""+Ne,_e!==null&&_e.tag===6?(v(De,_e.sibling),bt=C(_e,Ne),bt.return=De,De=bt):(v(De,_e),bt=bm(Ne,De.mode,bt),bt.return=De,De=bt),X(De)):v(De,_e)}return function(De,_e,Ne,bt){try{uc=0;var qt=Al(De,_e,Ne,bt);return bl=null,qt}catch(Kt){if(Kt===yr||Kt===ds)throw Kt;var Fi=t(29,Kt,null,De.mode);return Fi.lanes=bt,Fi.return=De,Fi}}}function qr(){for(var c=so,f=fc=so=0;fI?I:8);var X=Xt.T,le={};Xt.T=le,Vd(c,!1,f,v);try{var Fe=C(),st=Xt.S;if(st!==null&&st(le,Fe),Fe!==null&&typeof Fe=="object"&&typeof Fe.then=="function"){var Tt=Pe(Fe,_);df(c,f,Tt,Ti(c))}else df(c,f,_,Ti(c))}catch(ht){df(c,f,{then:function(){},status:"rejected",reason:ht},Ti())}finally{On(I),X!==null&&le.types!==null&&(X.types=le.types),Xt.T=X}}function Q0(c){var f=c.memoizedState;if(f!==null)return f;f={memoizedState:rc,baseState:rc,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:rc},next:null};var v={};return f.next={memoizedState:v,baseState:v,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:v},next:null},c.memoizedState=f,c=c.alternate,c!==null&&(c.memoizedState=f),f}function Jp(){return V(ac)}function Hd(){return St().memoizedState}function J0(){return St().memoizedState}function q_(c){for(var f=c.return;f!==null;){switch(f.tag){case 24:case 3:var v=Ti();c=Zr(v);var _=Ie(f,c,v);_!==null&&(Pi(_,f,v),Ke(_,f,v)),f={cache:Ee()},c.payload=f;return}f=f.return}}function Y_(c,f,v){var _=Ti();v={lane:_,revertLane:0,gesture:null,action:v,hasEagerState:!1,eagerState:null,next:null},Gd(c)?tv(f,v):(v=Oa(c,f,v,_),v!==null&&(Pi(v,c,_),nv(v,f,_)))}function ev(c,f,v){var _=Ti();df(c,f,v,_)}function df(c,f,v,_){var C={lane:_,revertLane:0,gesture:null,action:v,hasEagerState:!1,eagerState:null,next:null};if(Gd(c))tv(f,C);else{var I=c.alternate;if(c.lanes===0&&(I===null||I.lanes===0)&&(I=f.lastRenderedReducer,I!==null))try{var X=f.lastRenderedState,le=I(X,v);if(C.hasEagerState=!0,C.eagerState=le,Zi(le,X))return Fr(c,f,C,0),xn===null&&qr(),!1}catch{}if(v=Oa(c,f,C,_),v!==null)return Pi(v,c,_),nv(v,f,_),!0}return!1}function Vd(c,f,v,_){if(_={lane:2,revertLane:be(),gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Gd(c)){if(f)throw Error(r(479))}else f=Oa(c,v,_,2),f!==null&&Pi(f,c,2)}function Gd(c){var f=c.alternate;return c===pn||f!==null&&f===pn}function tv(c,f){gn=bn=!0;var v=c.pending;v===null?f.next=f:(f.next=v.next,v.next=f),c.pending=f}function nv(c,f,v){if((v&4194048)!==0){var _=f.lanes;_&=c.pendingLanes,v|=_,f.lanes=v,L(c,v)}}function em(c,f,v,_){f=c.memoizedState,v=v(_,f),v=v==null?f:ch({},f,v),c.memoizedState=v,c.lanes===0&&(c.updateQueue.baseState=v)}function Wd(c,f,v,_,C,I,X){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(_,I,X):f.prototype&&f.prototype.isPureReactComponent?!Ve(v,_)||!Ve(C,I):!0}function iv(c,f,v,_){c=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(v,_),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(v,_),f.state!==c&&kf.enqueueReplaceState(f,f.state,null)}function Xl(c,f){var v=f;if("ref"in f){v={};for(var _ in f)_!=="ref"&&(v[_]=f[_])}if(c=c.defaultProps){v===f&&(v=ch({},v));for(var C in c)v[C]===void 0&&(v[C]=c[C])}return v}function Xd(c,f){try{var v=c.onUncaughtError;v(f.value,{componentStack:f.stack})}catch(_){setTimeout(function(){throw _})}}function tm(c,f,v){try{var _=c.onCaughtError;_(v.value,{componentStack:v.stack,errorBoundary:f.tag===1?f.stateNode:null})}catch(C){setTimeout(function(){throw C})}}function nm(c,f,v){return v=Zr(v),v.tag=3,v.payload={element:null},v.callback=function(){Xd(c,f)},v}function rv(c){return c=Zr(c),c.tag=3,c}function av(c,f,v,_){var C=v.type.getDerivedStateFromError;if(typeof C=="function"){var I=_.value;c.payload=function(){return C(I)},c.callback=function(){tm(f,v,_)}}var X=v.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(c.callback=function(){tm(f,v,_),typeof C!="function"&&(zo===null?zo=new Set([this]):zo.add(this));var le=_.stack;this.componentDidCatch(_.value,{componentStack:le!==null?le:""})})}function Z_(c,f,v,_,C){if(v.flags|=32768,_!==null&&typeof _=="object"&&typeof _.then=="function"){if(f=v.alternate,f!==null&&dt(f,v,C,!0),v=ya.current,v!==null){switch(v.tag){case 31:case 13:return ba===null?nu():v.alternate===null&&zi===0&&(zi=3),v.flags&=-257,v.flags|=65536,v.lanes=C,_===ao?v.flags|=16384:(f=v.updateQueue,f===null?v.updateQueue=new Set([_]):f.add(_),au(c,_,C)),!1;case 22:return v.flags|=65536,_===ao?v.flags|=16384:(f=v.updateQueue,f===null?(f={transitions:null,markerInstances:null,retryQueue:new Set([_])},v.updateQueue=f):(v=f.retryQueue,v===null?f.retryQueue=new Set([_]):v.add(_)),au(c,_,C)),!1}throw Error(r(435,v.tag))}return au(c,_,C),nu(),!1}if(In)return f=ya.current,f!==null?((f.flags&65536)===0&&(f.flags|=256),f.flags|=65536,f.lanes=C,_!==Ih&&(c=Error(r(422),{cause:_}),Ue(ge(c,v)))):(_!==Ih&&(f=Error(r(423),{cause:_}),Ue(ge(f,v))),c=c.current.alternate,c.flags|=65536,C&=-C,c.lanes|=C,_=ge(_,v),C=nm(c.stateNode,_,C),yt(c,C),zi!==4&&(zi=2)),!1;var I=Error(r(520),{cause:_});if(I=ge(I,v),Vf===null?Vf=[I]:Vf.push(I),zi!==4&&(zi=2),f===null)return!0;_=ge(_,v),v=f;do{switch(v.tag){case 3:return v.flags|=65536,c=C&-C,v.lanes|=c,c=nm(v.stateNode,_,c),yt(v,c),!1;case 1:if(f=v.type,I=v.stateNode,(v.flags&128)===0&&(typeof f.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(zo===null||!zo.has(I))))return v.flags|=65536,C&=-C,v.lanes|=C,C=rv(C),av(C,c,v,_),yt(v,C),!1}v=v.return}while(v!==null);return!1}function Rr(c,f,v,_){f.child=c===null?sg(f,null,v,_):Ir(f,c.child,v,_)}function sv(c,f,v,_,C){v=v.render;var I=f.ref;if("ref"in _){var X={};for(var le in _)le!=="ref"&&(X[le]=_[le])}else X=_;return tt(f),_=ot(c,f,v,X,I,C),le=Bt(),c!==null&&!Mi?(on(c,f,C),Gs(c,f,C)):(In&&le&&ce(f),f.flags|=1,Rr(c,f,_,C),f.child)}function ov(c,f,v,_,C){if(c===null){var I=v.type;return typeof I=="function"&&!Zl(I)&&I.defaultProps===void 0&&v.compare===null?(f.tag=15,f.type=I,lv(c,f,I,_,C)):(c=Ao(v.type,null,_,f,f.mode,C),c.ref=f.ref,c.return=f,f.child=c)}if(I=c.child,!pf(c,C)){var X=I.memoizedProps;if(v=v.compare,v=v!==null?v:Ve,v(X,_)&&c.ref===f.ref)return Gs(c,f,C)}return f.flags|=1,c=Na(I,_),c.ref=f.ref,c.return=f,f.child=c}function lv(c,f,v,_,C){if(c!==null){var I=c.memoizedProps;if(Ve(I,_)&&c.ref===f.ref)if(Mi=!1,f.pendingProps=_=I,pf(c,C))(c.flags&131072)!==0&&(Mi=!0);else return f.lanes=c.lanes,Gs(c,f,C)}return jd(c,f,v,_,C)}function cv(c,f,v,_){var C=_.children,I=c!==null?c.memoizedState:null;if(c===null&&f.stateNode===null&&(f.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),_.mode==="hidden"){if((f.flags&128)!==0){if(I=I!==null?I.baseLanes|v:v,c!==null){for(_=f.child=c.child,C=0;_!==null;)C=C|_.lanes|_.childLanes,_=_.sibling;_=C&~I}else _=0,f.child=null;return $c(c,f,I,v,_)}if((v&536870912)!==0)f.memoizedState={baseLanes:0,cachePool:null},c!==null&&at(f,I!==null?I.cachePool:null),I!==null?Ei(f,I):ki(),me(f);else return _=f.lanes=536870912,$c(c,f,I!==null?I.baseLanes|v:v,v,_)}else I!==null?(at(f,I.cachePool),Ei(f,I),de(),f.memoizedState=null):(c!==null&&at(f,null),ki(),de());return Rr(c,f,C,v),f.child}function $l(c,f){return c!==null&&c.tag===22||f.stateNode!==null||(f.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),f.sibling}function $c(c,f,v,_,C){var I=ze();return I=I===null?null:{parent:qi?Ci._currentValue:Ci._currentValue2,pool:I},f.memoizedState={baseLanes:v,cachePool:I},c!==null&&at(f,null),ki(),me(f),c!==null&&dt(c,f,_,!0),f.childLanes=C,null}function $d(c,f){return f=nl({mode:f.mode,children:f.children},c.mode),f.ref=c.ref,c.child=f,f.return=c,f}function im(c,f,v){return Ir(f,c.child,null,v),c=$d(f,f.pendingProps),c.flags|=2,Ae(f),f.memoizedState=null,c}function uv(c,f,v){var _=f.pendingProps,C=(f.flags&128)!==0;if(f.flags&=-129,c===null){if(In){if(_.mode==="hidden")return c=$d(f,_),f.lanes=536870912,$l(null,c);if(Me(f),(c=Ai)?(c=Wm(c,ia),c!==null&&(f.memoizedState={dehydrated:c,treeContext:ls!==null?{id:Dr,overflow:ws}:null,retryLane:536870912,hydrationErrors:null},v=xm(c),v.return=f,f.child=v,gr=f,Ai=null)):c=null,c===null)throw gt(f);return f.lanes=536870912,null}return $d(f,_)}var I=c.memoizedState;if(I!==null){var X=I.dehydrated;if(Me(f),C)if(f.flags&256)f.flags&=-257,f=im(c,f,v);else if(f.memoizedState!==null)f.child=c.child,f.flags|=128,f=null;else throw Error(r(558));else if(Mi||dt(c,f,v,!1),C=(v&c.childLanes)!==0,Mi||C){if(_=xn,_!==null&&(X=z(_,v),X!==0&&X!==I.retryLane))throw I.retryLane=X,hr(c,X),Pi(_,c,X),aa;nu(),f=im(c,f,v)}else c=I.treeContext,wi&&(Ai=jv(X),gr=f,In=!0,ro=null,ia=!1,c!==null&&Ge(f,c)),f=$d(f,_),f.flags|=4096;return f}return c=Na(c.child,{mode:_.mode,children:_.children}),c.ref=f.ref,f.child=c,c.return=f,c}function hf(c,f){var v=f.ref;if(v===null)c!==null&&c.ref!==null&&(f.flags|=4194816);else{if(typeof v!="function"&&typeof v!="object")throw Error(r(284));(c===null||c.ref!==v)&&(f.flags|=4194816)}}function jd(c,f,v,_,C){return tt(f),v=ot(c,f,v,_,void 0,C),_=Bt(),c!==null&&!Mi?(on(c,f,C),Gs(c,f,C)):(In&&_&&ce(f),f.flags|=1,Rr(c,f,v,C),f.child)}function rm(c,f,v,_,C,I){return tt(f),f.updateQueue=null,v=Je(f,_,v,C),wt(c),_=Bt(),c!==null&&!Mi?(on(c,f,I),Gs(c,f,I)):(In&&_&&ce(f),f.flags|=1,Rr(c,f,v,I),f.child)}function jl(c,f,v,_,C){if(tt(f),f.stateNode===null){var I=to,X=v.contextType;typeof X=="object"&&X!==null&&(I=V(X)),I=new v(_,I),f.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=kf,f.stateNode=I,I._reactInternals=f,I=f.stateNode,I.props=_,I.state=f.memoizedState,I.refs={},ji(f),X=v.contextType,I.context=typeof X=="object"&&X!==null?V(X):to,I.state=f.memoizedState,X=v.getDerivedStateFromProps,typeof X=="function"&&(em(f,v,X,_),I.state=f.memoizedState),typeof v.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(X=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),X!==I.state&&kf.enqueueReplaceState(I,I.state,null),Dn(f,_,I,C),Pt(),I.state=f.memoizedState),typeof I.componentDidMount=="function"&&(f.flags|=4194308),_=!0}else if(c===null){I=f.stateNode;var le=f.memoizedProps,Fe=Xl(v,le);I.props=Fe;var st=I.context,Tt=v.contextType;X=to,typeof Tt=="object"&&Tt!==null&&(X=V(Tt));var ht=v.getDerivedStateFromProps;Tt=typeof ht=="function"||typeof I.getSnapshotBeforeUpdate=="function",le=f.pendingProps!==le,Tt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(le||st!==X)&&iv(f,I,_,X),Fa=!1;var Ot=f.memoizedState;I.state=Ot,Dn(f,_,I,C),Pt(),st=f.memoizedState,le||Ot!==st||Fa?(typeof ht=="function"&&(em(f,v,ht,_),st=f.memoizedState),(Fe=Fa||Wd(f,v,Fe,_,Ot,st,X))?(Tt||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(f.flags|=4194308)):(typeof I.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=_,f.memoizedState=st),I.props=_,I.state=st,I.context=X,_=Fe):(typeof I.componentDidMount=="function"&&(f.flags|=4194308),_=!1)}else{I=f.stateNode,Yr(c,f),X=f.memoizedProps,Tt=Xl(v,X),I.props=Tt,ht=f.pendingProps,Ot=I.context,st=v.contextType,Fe=to,typeof st=="object"&&st!==null&&(Fe=V(st)),le=v.getDerivedStateFromProps,(st=typeof le=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(X!==ht||Ot!==Fe)&&iv(f,I,_,Fe),Fa=!1,Ot=f.memoizedState,I.state=Ot,Dn(f,_,I,C),Pt();var fn=f.memoizedState;X!==ht||Ot!==fn||Fa||c!==null&&c.dependencies!==null&&Ct(c.dependencies)?(typeof le=="function"&&(em(f,v,le,_),fn=f.memoizedState),(Tt=Fa||Wd(f,v,Tt,_,Ot,fn,Fe)||c!==null&&c.dependencies!==null&&Ct(c.dependencies))?(st||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(_,fn,Fe),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(_,fn,Fe)),typeof I.componentDidUpdate=="function"&&(f.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof I.componentDidUpdate!="function"||X===c.memoizedProps&&Ot===c.memoizedState||(f.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||X===c.memoizedProps&&Ot===c.memoizedState||(f.flags|=1024),f.memoizedProps=_,f.memoizedState=fn),I.props=_,I.state=fn,I.context=Fe,_=Tt):(typeof I.componentDidUpdate!="function"||X===c.memoizedProps&&Ot===c.memoizedState||(f.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||X===c.memoizedProps&&Ot===c.memoizedState||(f.flags|=1024),_=!1)}return I=_,hf(c,f),_=(f.flags&128)!==0,I||_?(I=f.stateNode,v=_&&typeof v.getDerivedStateFromError!="function"?null:I.render(),f.flags|=1,c!==null&&_?(f.child=Ir(f,c.child,null,C),f.child=Ir(f,null,v,C)):Rr(c,f,v,C),f.memoizedState=I.state,c=f.child):c=Gs(c,f,C),c}function fv(c,f,v,_){return mt(),f.flags|=256,Rr(c,f,v,_),f.child}function am(c){return{baseLanes:c,cachePool:je()}}function sm(c,f,v){return c=c!==null?c.childLanes&~v:0,f&&(c|=sa),c}function om(c,f,v){var _=f.pendingProps,C=!1,I=(f.flags&128)!==0,X;if((X=I)||(X=c!==null&&c.memoizedState===null?!1:(Gi.current&2)!==0),X&&(C=!0,f.flags&=-129),X=(f.flags&32)!==0,f.flags&=-33,c===null){if(In){if(C?ue(f):de(),(c=Ai)?(c=Kv(c,ia),c!==null&&(f.memoizedState={dehydrated:c,treeContext:ls!==null?{id:Dr,overflow:ws}:null,retryLane:536870912,hydrationErrors:null},v=xm(c),v.return=f,f.child=v,gr=f,Ai=null)):c=null,c===null)throw gt(f);return vh(c)?f.lanes=32:f.lanes=536870912,null}var le=_.children;return _=_.fallback,C?(de(),C=f.mode,le=nl({mode:"hidden",children:le},C),_=is(_,C,v,null),le.return=f,_.return=f,le.sibling=_,f.child=le,_=f.child,_.memoizedState=am(v),_.childLanes=sm(c,X,v),f.memoizedState=hc,$l(null,_)):(ue(f),qd(f,le))}var Fe=c.memoizedState;if(Fe!==null&&(le=Fe.dehydrated,le!==null)){if(I)f.flags&256?(ue(f),f.flags&=-257,f=ql(c,f,v)):f.memoizedState!==null?(de(),f.child=c.child,f.flags|=128,f=null):(de(),le=_.fallback,C=f.mode,_=nl({mode:"visible",children:_.children},C),le=is(le,C,v,null),le.flags|=2,_.return=f,le.return=f,_.sibling=le,f.child=_,Ir(f,c.child,null,v),_=f.child,_.memoizedState=am(v),_.childLanes=sm(c,X,v),f.memoizedState=hc,f=$l(null,_));else if(ue(f),vh(le))X=yh(le).digest,_=Error(r(419)),_.stack="",_.digest=X,Ue({value:_,source:null,stack:null}),f=ql(c,f,v);else if(Mi||dt(c,f,v,!1),X=(v&c.childLanes)!==0,Mi||X){if(X=xn,X!==null&&(_=z(X,v),_!==0&&_!==Fe.retryLane))throw Fe.retryLane=_,hr(c,_),Pi(X,c,_),aa;ml(le)||nu(),f=ql(c,f,v)}else ml(le)?(f.flags|=192,f.child=c.child,f=null):(c=Fe.treeContext,wi&&(Ai=qv(le),gr=f,In=!0,ro=null,ia=!1,c!==null&&Ge(f,c)),f=qd(f,_.children),f.flags|=4096);return f}return C?(de(),le=_.fallback,C=f.mode,Fe=c.child,I=Fe.sibling,_=Na(Fe,{mode:"hidden",children:_.children}),_.subtreeFlags=Fe.subtreeFlags&65011712,I!==null?le=Na(I,le):(le=is(le,C,v,null),le.flags|=2),le.return=f,_.return=f,_.sibling=le,f.child=_,$l(null,_),_=f.child,le=c.child.memoizedState,le===null?le=am(v):(C=le.cachePool,C!==null?(Fe=qi?Ci._currentValue:Ci._currentValue2,C=C.parent!==Fe?{parent:Fe,pool:Fe}:C):C=je(),le={baseLanes:le.baseLanes|v,cachePool:C}),_.memoizedState=le,_.childLanes=sm(c,X,v),f.memoizedState=hc,$l(c.child,_)):(ue(f),v=c.child,c=v.sibling,v=Na(v,{mode:"visible",children:_.children}),v.return=f,v.sibling=null,c!==null&&(X=f.deletions,X===null?(f.deletions=[c],f.flags|=16):X.push(c)),f.child=v,f.memoizedState=null,v)}function qd(c,f){return f=nl({mode:"visible",children:f},c.mode),f.return=c,c.child=f}function nl(c,f){return c=t(22,c,null,f),c.lanes=0,c}function ql(c,f,v){return Ir(f,c.child,null,v),c=qd(f,f.pendingProps.children),c.flags|=2,f.memoizedState=null,c}function dv(c,f,v){c.lanes|=f;var _=c.alternate;_!==null&&(_.lanes|=f),Z(c.return,f,v)}function jc(c,f,v,_,C,I){var X=c.memoizedState;X===null?c.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:_,tail:v,tailMode:C,treeForkCount:I}:(X.isBackwards=f,X.rendering=null,X.renderingStartTime=0,X.last=_,X.tail=v,X.tailMode=C,X.treeForkCount=I)}function lm(c,f,v){var _=f.pendingProps,C=_.revealOrder,I=_.tail;_=_.children;var X=Gi.current,le=(X&2)!==0;if(le?(X=X&1|2,f.flags|=128):X&=1,E(Gi,X),Rr(c,f,_,v),_=In?zf:0,!le&&c!==null&&(c.flags&128)!==0)e:for(c=f.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&dv(c,v,f);else if(c.tag===19)dv(c,v,f);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===f)break e;for(;c.sibling===null;){if(c.return===null||c.return===f)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}switch(C){case"forwards":for(v=f.child,C=null;v!==null;)c=v.alternate,c!==null&&Qe(c)===null&&(C=v),v=v.sibling;v=C,v===null?(C=f.child,f.child=null):(C=v.sibling,v.sibling=null),jc(f,!1,C,v,I,_);break;case"backwards":case"unstable_legacy-backwards":for(v=null,C=f.child,f.child=null;C!==null;){if(c=C.alternate,c!==null&&Qe(c)===null){f.child=C;break}c=C.sibling,C.sibling=v,v=C,C=c}jc(f,!0,v,null,I,_);break;case"together":jc(f,!1,null,null,void 0,_);break;default:f.memoizedState=null}return f.child}function Gs(c,f,v){if(c!==null&&(f.dependencies=c.dependencies),Uo|=f.lanes,(v&f.childLanes)===0)if(c!==null){if(dt(c,f,v,!1),(v&f.childLanes)===0)return null}else return null;if(c!==null&&f.child!==c.child)throw Error(r(153));if(f.child!==null){for(c=f.child,v=Na(c,c.pendingProps),f.child=v,v.return=f;c.sibling!==null;)c=c.sibling,v=v.sibling=Na(c,c.pendingProps),v.return=f;v.sibling=null}return f.child}function pf(c,f){return(c.lanes&f)!==0?!0:(c=c.dependencies,!!(c!==null&&Ct(c)))}function cm(c,f,v){switch(f.tag){case 3:Ye(f,f.stateNode.containerInfo),Re(f,Ci,c.memoizedState.cache),mt();break;case 27:case 5:Oe(f);break;case 4:Ye(f,f.stateNode.containerInfo);break;case 10:Re(f,f.type,f.memoizedProps.value);break;case 31:if(f.memoizedState!==null)return f.flags|=128,Me(f),null;break;case 13:var _=f.memoizedState;if(_!==null)return _.dehydrated!==null?(ue(f),f.flags|=128,null):(v&f.child.childLanes)!==0?om(c,f,v):(ue(f),c=Gs(c,f,v),c!==null?c.sibling:null);ue(f);break;case 19:var C=(c.flags&128)!==0;if(_=(v&f.childLanes)!==0,_||(dt(c,f,v,!1),_=(v&f.childLanes)!==0),C){if(_)return lm(c,f,v);f.flags|=128}if(C=f.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),E(Gi,Gi.current),_)break;return null;case 22:return f.lanes=0,cv(c,f,v,f.pendingProps);case 24:Re(f,Ci,c.memoizedState.cache)}return Gs(c,f,v)}function um(c,f,v){if(c!==null)if(c.memoizedProps!==f.pendingProps)Mi=!0;else{if(!pf(c,v)&&(f.flags&128)===0)return Mi=!1,cm(c,f,v);Mi=(c.flags&131072)!==0}else Mi=!1,In&&(f.flags&1048576)!==0&&q(f,zf,f.index);switch(f.lanes=0,f.tag){case 16:e:{var _=f.pendingProps;if(c=an(f.elementType),f.type=c,typeof c=="function")Zl(c)?(_=Xl(c,_),f.tag=1,f=jl(null,f,c,_,v)):(f.tag=0,f=jd(null,f,c,_,v));else{if(c!=null){var C=c.$$typeof;if(C===su){f.tag=11,f=sv(null,f,c,_,v);break e}else if(C===fh){f.tag=14,f=ov(null,f,c,_,v);break e}}throw f=y(c)||c,Error(r(306,f,""))}}return f;case 0:return jd(c,f,f.type,f.pendingProps,v);case 1:return _=f.type,C=Xl(_,f.pendingProps),jl(c,f,_,C,v);case 3:e:{if(Ye(f,f.stateNode.containerInfo),c===null)throw Error(r(387));var I=f.pendingProps;C=f.memoizedState,_=C.element,Yr(c,f),Dn(f,I,null,v);var X=f.memoizedState;if(I=X.cache,Re(f,Ci,I),I!==C.cache&&At(f,[Ci],v,!0),Pt(),I=X.element,wi&&C.isDehydrated)if(C={element:I,isDehydrated:!1,cache:X.cache},f.updateQueue.baseState=C,f.memoizedState=C,f.flags&256){f=fv(c,f,I,v);break e}else if(I!==_){_=ge(Error(r(424)),f),Ue(_),f=fv(c,f,I,v);break e}else for(wi&&(Ai=$v(f.stateNode.containerInfo),gr=f,In=!0,ro=null,ia=!0),v=sg(f,null,I,v),f.child=v;v;)v.flags=v.flags&-3|4096,v=v.sibling;else{if(mt(),I===_){f=Gs(c,f,v);break e}Rr(c,f,I,v)}f=f.child}return f;case 26:if(ss)return hf(c,f),c===null?(v=Ym(f.type,null,f.pendingProps,null))?f.memoizedState=v:In||(f.stateNode=Sh(f.type,f.pendingProps,Or.current,f)):f.memoizedState=Ym(f.type,c.memoizedProps,f.pendingProps,c.memoizedState),null;case 27:if(mr)return Oe(f),c===null&&mr&&In&&(_=f.stateNode=Mh(f.type,f.pendingProps,Or.current,Er.current,!1),gr=f,ia=!0,Ai=Gm(f.type,_,Ai)),Rr(c,f,f.pendingProps.children,v),hf(c,f),c===null&&(f.flags|=4194304),f.child;case 5:return c===null&&In&&(sy(f.type,f.pendingProps,Er.current),(C=_=Ai)&&(_=Yv(_,f.type,f.pendingProps,ia),_!==null?(f.stateNode=_,gr=f,Ai=Xv(_),ia=!1,C=!0):C=!1),C||gt(f)),Oe(f),C=f.type,I=f.pendingProps,X=c!==null?c.memoizedProps:null,_=I.children,na(C,I)?_=null:X!==null&&na(C,X)&&(f.flags|=32),f.memoizedState!==null&&(C=ot(c,f,ut,null,null,v),qi?ac._currentValue=C:ac._currentValue2=C),hf(c,f),Rr(c,f,_,v),f.child;case 6:return c===null&&In&&(qm(f.pendingProps,Er.current),(c=v=Ai)&&(v=Zv(v,f.pendingProps,ia),v!==null?(f.stateNode=v,gr=f,Ai=null,c=!0):c=!1),c||gt(f)),null;case 13:return om(c,f,v);case 4:return Ye(f,f.stateNode.containerInfo),_=f.pendingProps,c===null?f.child=Ir(f,null,_,v):Rr(c,f,_,v),f.child;case 11:return sv(c,f,f.type,f.pendingProps,v);case 7:return Rr(c,f,f.pendingProps,v),f.child;case 8:return Rr(c,f,f.pendingProps.children,v),f.child;case 12:return Rr(c,f,f.pendingProps.children,v),f.child;case 10:return _=f.pendingProps,Re(f,f.type,_.value),Rr(c,f,_.children,v),f.child;case 9:return C=f.type._context,_=f.pendingProps.children,tt(f),C=V(C),_=_(C),f.flags|=1,Rr(c,f,_,v),f.child;case 14:return ov(c,f,f.type,f.pendingProps,v);case 15:return lv(c,f,f.type,f.pendingProps,v);case 19:return lm(c,f,v);case 31:return uv(c,f,v);case 22:return cv(c,f,v,f.pendingProps);case 24:return tt(f),_=V(Ci),c===null?(C=ze(),C===null&&(C=xn,I=Ee(),C.pooledCache=I,I.refCount++,I!==null&&(C.pooledCacheLanes|=v),C=I),f.memoizedState={parent:_,cache:C},ji(f),Re(f,Ci,C)):((c.lanes&v)!==0&&(Yr(c,f),Dn(f,null,null,v),Pt()),C=c.memoizedState,I=f.memoizedState,C.parent!==_?(C={parent:_,cache:_},f.memoizedState=C,f.lanes===0&&(f.memoizedState=f.updateQueue.baseState=C),Re(f,Ci,_)):(_=I.cache,Re(f,Ci,_),_!==C.cache&&At(f,[Ci],v,!0))),Rr(c,f,f.pendingProps.children,v),f.child;case 29:throw f.pendingProps}throw Error(r(156,f.tag))}function Qa(c){c.flags|=4}function mf(c){Ua&&(c.flags|=8)}function hv(c,f){if(c!==null&&c.child===f.child)return!1;if((f.flags&16)!==0)return!0;for(c=f.child;c!==null;){if((c.flags&8218)!==0||(c.subtreeFlags&8218)!==0)return!0;c=c.sibling}return!1}function fm(c,f,v,_){if(Un)for(v=f.child;v!==null;){if(v.tag===5||v.tag===6)Rf(c,v.stateNode);else if(!(v.tag===4||mr&&v.tag===27)&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===f)break;for(;v.sibling===null;){if(v.return===null||v.return===f)return;v=v.return}v.sibling.return=v.return,v=v.sibling}else if(Ua)for(var C=f.child;C!==null;){if(C.tag===5){var I=C.stateNode;v&&_&&(I=Hv(I,C.type,C.memoizedProps)),Rf(c,I)}else if(C.tag===6)I=C.stateNode,v&&_&&(I=Hm(I,C.memoizedProps)),Rf(c,I);else if(C.tag!==4){if(C.tag===22&&C.memoizedState!==null)I=C.child,I!==null&&(I.return=C),fm(c,C,!0,!0);else if(C.child!==null){C.child.return=C,C=C.child;continue}}if(C===f)break;for(;C.sibling===null;){if(C.return===null||C.return===f)return;C=C.return}C.sibling.return=C.return,C=C.sibling}}function pv(c,f,v,_){var C=!1;if(Ua)for(var I=f.child;I!==null;){if(I.tag===5){var X=I.stateNode;v&&_&&(X=Hv(X,I.type,I.memoizedProps)),Bm(c,X)}else if(I.tag===6)X=I.stateNode,v&&_&&(X=Hm(X,I.memoizedProps)),Bm(c,X);else if(I.tag!==4){if(I.tag===22&&I.memoizedState!==null)C=I.child,C!==null&&(C.return=I),pv(c,I,!0,!0),C=!0;else if(I.child!==null){I.child.return=I,I=I.child;continue}}if(I===f)break;for(;I.sibling===null;){if(I.return===null||I.return===f)return C;I=I.return}I.sibling.return=I.return,I=I.sibling}return C}function mv(c,f){if(Ua&&hv(c,f)){c=f.stateNode;var v=c.containerInfo,_=Fm();pv(_,f,!1,!1),c.pendingChildren=_,Qa(f),kv(v,_)}}function dm(c,f,v,_){if(Un)c.memoizedProps!==_&&Qa(f);else if(Ua){var C=c.stateNode,I=c.memoizedProps;if((c=hv(c,f))||I!==_){var X=Er.current;I=Bv(C,v,I,_,!c,null),I===C?f.stateNode=C:(mf(f),pa(I,v,_,X)&&Qa(f),f.stateNode=I,c&&fm(I,f,!1,!1))}else f.stateNode=C}}function Jr(c,f,v,_,C){if((c.mode&32)!==0&&(v===null?Df(f,_):fu(f,v,_))){if(c.flags|=16777216,(C&335544128)===C||Am(f,_))if(Li(c.stateNode,f,_))c.flags|=8192;else if(Nn())c.flags|=8192;else throw ra=ao,Lh}else c.flags&=-16777217}function qc(c,f){if(Jm(f)){if(c.flags|=16777216,!eg(f))if(Nn())c.flags|=8192;else throw ra=ao,Lh}else c.flags&=-16777217}function gf(c,f){f!==null&&(c.flags|=4),c.flags&16384&&(f=c.tag!==22?D():536870912,c.lanes|=f,xu|=f)}function Yc(c,f){if(!In)switch(c.tailMode){case"hidden":f=c.tail;for(var v=null;f!==null;)f.alternate!==null&&(v=f),f=f.sibling;v===null?c.tail=null:v.sibling=null;break;case"collapsed":v=c.tail;for(var _=null;v!==null;)v.alternate!==null&&(_=v),v=v.sibling;_===null?f||c.tail===null?c.tail=null:c.tail.sibling=null:_.sibling=null}}function pi(c){var f=c.alternate!==null&&c.alternate.child===c.child,v=0,_=0;if(f)for(var C=c.child;C!==null;)v|=C.lanes|C.childLanes,_|=C.subtreeFlags&65011712,_|=C.flags&65011712,C.return=c,C=C.sibling;else for(C=c.child;C!==null;)v|=C.lanes|C.childLanes,_|=C.subtreeFlags,_|=C.flags,C.return=c,C=C.sibling;return c.subtreeFlags|=_,c.childLanes=v,f}function gv(c,f,v){var _=f.pendingProps;switch(Se(f),f.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pi(f),null;case 1:return pi(f),null;case 3:return v=f.stateNode,_=null,c!==null&&(_=c.memoizedState.cache),f.memoizedState.cache!==_&&(f.flags|=2048),ft(Ci),ve(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(c===null||c.child===null)&&(pt(f)?Qa(f):c===null||c.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,He())),mv(c,f),pi(f),null;case 26:if(ss){var C=f.type,I=f.memoizedState;return c===null?(Qa(f),I!==null?(pi(f),qc(f,I)):(pi(f),Jr(f,C,null,_,v))):I?I!==c.memoizedState?(Qa(f),pi(f),qc(f,I)):(pi(f),f.flags&=-16777217):(I=c.memoizedProps,Un?I!==_&&Qa(f):dm(c,f,C,_),pi(f),Jr(f,C,I,_,v)),null}case 27:if(mr){if(it(f),v=Or.current,C=f.type,c!==null&&f.stateNode!=null)Un?c.memoizedProps!==_&&Qa(f):dm(c,f,C,_);else{if(!_){if(f.stateNode===null)throw Error(r(166));return pi(f),null}c=Er.current,pt(f)?_t(f,c):(c=Mh(C,_,v,c,!0),f.stateNode=c,Qa(f))}return pi(f),null}case 5:if(it(f),C=f.type,c!==null&&f.stateNode!=null)dm(c,f,C,_);else{if(!_){if(f.stateNode===null)throw Error(r(166));return pi(f),null}if(I=Er.current,pt(f))_t(f,I),iy(f.stateNode,C,_,I)&&(f.flags|=64);else{var X=Tm(C,_,Or.current,I,f);mf(f),fm(X,f,!1,!1),f.stateNode=X,pa(X,C,_,I)&&Qa(f)}}return pi(f),Jr(f,f.type,c===null?null:c.memoizedProps,f.pendingProps,v),null;case 6:if(c&&f.stateNode!=null)v=c.memoizedProps,Un?v!==_&&Qa(f):Ua&&(v!==_?(c=Or.current,v=Er.current,mf(f),f.stateNode=Do(_,c,v,f)):f.stateNode=c.stateNode);else{if(typeof _!="string"&&f.stateNode===null)throw Error(r(166));if(c=Or.current,v=Er.current,pt(f)){if(!wi)throw Error(r(176));if(c=f.stateNode,v=f.memoizedProps,_=null,C=gr,C!==null)switch(C.tag){case 27:case 5:_=C.memoizedProps}tS(c,v,f,_)||gt(f,!0)}else mf(f),f.stateNode=Do(_,c,v,f)}return pi(f),null;case 31:if(v=f.memoizedState,c===null||c.memoizedState!==null){if(_=pt(f),v!==null){if(c===null){if(!_)throw Error(r(318));if(!wi)throw Error(r(556));if(c=f.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(r(557));Xm(c,f)}else mt(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;pi(f),c=!1}else v=He(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=v),c=!0;if(!c)return f.flags&256?(Ae(f),f):(Ae(f),null);if((f.flags&128)!==0)throw Error(r(558))}return pi(f),null;case 13:if(_=f.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(C=pt(f),_!==null&&_.dehydrated!==null){if(c===null){if(!C)throw Error(r(318));if(!wi)throw Error(r(344));if(C=f.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(r(317));Jv(C,f)}else mt(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;pi(f),C=!1}else C=He(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=C),C=!0;if(!C)return f.flags&256?(Ae(f),f):(Ae(f),null)}return Ae(f),(f.flags&128)!==0?(f.lanes=v,f):(v=_!==null,c=c!==null&&c.memoizedState!==null,v&&(_=f.child,C=null,_.alternate!==null&&_.alternate.memoizedState!==null&&_.alternate.memoizedState.cachePool!==null&&(C=_.alternate.memoizedState.cachePool.pool),I=null,_.memoizedState!==null&&_.memoizedState.cachePool!==null&&(I=_.memoizedState.cachePool.pool),I!==C&&(_.flags|=2048)),v!==c&&v&&(f.child.flags|=8192),gf(f,f.updateQueue),pi(f),null);case 4:return ve(),mv(c,f),c===null&&li(f.stateNode.containerInfo),pi(f),null;case 10:return ft(f.type),pi(f),null;case 19:if(x(Gi),_=f.memoizedState,_===null)return pi(f),null;if(C=(f.flags&128)!==0,I=_.rendering,I===null)if(C)Yc(_,!1);else{if(zi!==0||c!==null&&(c.flags&128)!==0)for(c=f.child;c!==null;){if(I=Qe(c),I!==null){for(f.flags|=128,Yc(_,!1),c=I.updateQueue,f.updateQueue=c,gf(f,c),f.subtreeFlags=0,c=v,v=f.child;v!==null;)sh(v,c),v=v.sibling;return E(Gi,Gi.current&1|2),In&&xe(f,_.treeForkCount),f.child}c=c.sibling}_.tail!==null&&Hr()>wl&&(f.flags|=128,C=!0,Yc(_,!1),f.lanes=4194304)}else{if(!C)if(c=Qe(I),c!==null){if(f.flags|=128,C=!0,c=c.updateQueue,f.updateQueue=c,gf(f,c),Yc(_,!0),_.tail===null&&_.tailMode==="hidden"&&!I.alternate&&!In)return pi(f),null}else 2*Hr()-_.renderingStartTime>wl&&v!==536870912&&(f.flags|=128,C=!0,Yc(_,!1),f.lanes=4194304);_.isBackwards?(I.sibling=f.child,f.child=I):(c=_.last,c!==null?c.sibling=I:f.child=I,_.last=I)}return _.tail!==null?(c=_.tail,_.rendering=c,_.tail=c.sibling,_.renderingStartTime=Hr(),c.sibling=null,v=Gi.current,E(Gi,C?v&1|2:v&1),In&&xe(f,_.treeForkCount),c):(pi(f),null);case 22:case 23:return Ae(f),G(),_=f.memoizedState!==null,c!==null?c.memoizedState!==null!==_&&(f.flags|=8192):_&&(f.flags|=8192),_?(v&536870912)!==0&&(f.flags&128)===0&&(pi(f),f.subtreeFlags&6&&(f.flags|=8192)):pi(f),v=f.updateQueue,v!==null&&gf(f,v.retryQueue),v=null,c!==null&&c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(v=c.memoizedState.cachePool.pool),_=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(_=f.memoizedState.cachePool.pool),_!==v&&(f.flags|=2048),c!==null&&x(yl),null;case 24:return v=null,c!==null&&(v=c.memoizedState.cache),f.memoizedState.cache!==v&&(f.flags|=2048),ft(Ci),pi(f),null;case 25:return null;case 30:return null}throw Error(r(156,f.tag))}function hm(c,f){switch(Se(f),f.tag){case 1:return c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 3:return ft(Ci),ve(),c=f.flags,(c&65536)!==0&&(c&128)===0?(f.flags=c&-65537|128,f):null;case 26:case 27:case 5:return it(f),null;case 31:if(f.memoizedState!==null){if(Ae(f),f.alternate===null)throw Error(r(340));mt()}return c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 13:if(Ae(f),c=f.memoizedState,c!==null&&c.dehydrated!==null){if(f.alternate===null)throw Error(r(340));mt()}return c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 19:return x(Gi),null;case 4:return ve(),null;case 10:return ft(f.type),null;case 22:case 23:return Ae(f),G(),c!==null&&x(yl),c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 24:return ft(Ci),null;case 25:return null;default:return null}}function vv(c,f){switch(Se(f),f.tag){case 3:ft(Ci),ve();break;case 26:case 27:case 5:it(f);break;case 4:ve();break;case 31:f.memoizedState!==null&&Ae(f);break;case 13:Ae(f);break;case 19:x(Gi);break;case 10:ft(f.type);break;case 22:case 23:Ae(f),G(),c!==null&&x(yl);break;case 24:ft(Ci)}}function Ws(c,f){try{var v=f.updateQueue,_=v!==null?v.lastEffect:null;if(_!==null){var C=_.next;v=C;do{if((v.tag&c)===c){_=void 0;var I=v.create,X=v.inst;_=I(),X.destroy=_}v=v.next}while(v!==C)}}catch(le){nn(f,f.return,le)}}function Xs(c,f,v){try{var _=f.updateQueue,C=_!==null?_.lastEffect:null;if(C!==null){var I=C.next;_=I;do{if((_.tag&c)===c){var X=_.inst,le=X.destroy;if(le!==void 0){X.destroy=void 0,C=f;var Fe=v,st=le;try{st()}catch(Tt){nn(C,Fe,Tt)}}}_=_.next}while(_!==I)}}catch(Tt){nn(f,f.return,Tt)}}function Zc(c){var f=c.updateQueue;if(f!==null){var v=c.stateNode;try{un(f,v)}catch(_){nn(c,c.return,_)}}}function Yd(c,f,v){v.props=Xl(c.type,c.memoizedProps),v.state=c.memoizedState;try{v.componentWillUnmount()}catch(_){nn(c,f,_)}}function Kc(c,f){try{var v=c.ref;if(v!==null){switch(c.tag){case 26:case 27:case 5:var _=lu(c.stateNode);break;case 30:_=c.stateNode;break;default:_=c.stateNode}typeof v=="function"?c.refCleanup=v(_):v.current=_}}catch(C){nn(c,f,C)}}function kr(c,f){var v=c.ref,_=c.refCleanup;if(v!==null)if(typeof _=="function")try{_()}catch(C){nn(c,f,C)}finally{c.refCleanup=null,c=c.alternate,c!=null&&(c.refCleanup=null)}else if(typeof v=="function")try{v(null)}catch(C){nn(c,f,C)}else v.current=null}function Yl(c){var f=c.type,v=c.memoizedProps,_=c.stateNode;try{Ov(_,f,v,c)}catch(C){nn(c,c.return,C)}}function vf(c,f,v){try{Iv(c.stateNode,c.type,v,f,c)}catch(_){nn(c,c.return,_)}}function pm(c){return c.tag===5||c.tag===3||(ss?c.tag===26:!1)||(mr?c.tag===27&&sc(c.type):!1)||c.tag===4}function So(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||pm(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(mr&&c.tag===27&&sc(c.type)||c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function Zd(c,f,v){var _=c.tag;if(_===5||_===6)c=c.stateNode,f?Lv(v,c,f):Lm(v,c);else if(_!==4&&(mr&&_===27&&sc(c.type)&&(v=c.stateNode,f=null),c=c.child,c!==null))for(Zd(c,f,v),c=c.sibling;c!==null;)Zd(c,f,v),c=c.sibling}function yf(c,f,v){var _=c.tag;if(_===5||_===6)c=c.stateNode,f?Pv(v,c,f):Pm(v,c);else if(_!==4&&(mr&&_===27&&sc(c.type)&&(v=c.stateNode),c=c.child,c!==null))for(yf(c,f,v),c=c.sibling;c!==null;)yf(c,f,v),c=c.sibling}function mm(c,f,v){c=c.containerInfo;try{km(c,v)}catch(_){nn(f,f.return,_)}}function yv(c){var f=c.stateNode,v=c.memoizedProps;try{or(c.type,v,f,c)}catch(_){nn(c,c.return,_)}}function K_(c,f){for(dh(c.containerInfo),Ki=f;Ki!==null;)if(c=Ki,f=c.child,(c.subtreeFlags&1028)!==0&&f!==null)f.return=c,Ki=f;else for(;Ki!==null;){c=Ki;var v=c.alternate;switch(f=c.flags,c.tag){case 0:if((f&4)!==0&&(f=c.updateQueue,f=f!==null?f.events:null,f!==null))for(var _=0;_";case vu:return":has("+(eu(c)||"")+")";case yu:return'[role="'+c.value+'"]';case Sl:return'"'+c.value+'"';case Hf:return'[data-testname="'+c.value+'"]';default:throw Error(r(365))}}function tu(c,f){var v=[];c=[c,0];for(var _=0;_v?32:v;v=Xt.T;var C=as();try{On(_),Xt.T=null,_=zh,zh=null;var I=Fo,X=co;if(cr=0,gc=Fo=null,co=0,(An&6)!==0)throw Error(r(331));var le=An;if(An|=4,eh(I.current),Qd(I,I.current,X,_),An=le,$e(0,!1),va&&typeof va.onPostCommitFiberRoot=="function")try{va.onPostCommitFiberRoot(cc,I)}catch{}return!0}finally{On(C),Xt.T=v,ah(c,f)}}function ul(c,f,v){f=ge(v,f),f=nm(c.stateNode,f,2),c=Ie(c,f,2),c!==null&&(U(c,2),Et(c))}function nn(c,f,v){if(c.tag===3)ul(c,c,v);else for(;f!==null;){if(f.tag===3){ul(f,c,v);break}else if(f.tag===1){var _=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof _.componentDidCatch=="function"&&(zo===null||!zo.has(_))){c=ge(v,c),v=rv(2),_=Ie(f,v,2),_!==null&&(av(v,_,f,c),U(_,2),Et(_));break}}f=f.return}}function au(c,f,v){var _=c.pingCache;if(_===null){_=c.pingCache=new Ha;var C=new Set;_.set(f,C)}else C=_.get(f),C===void 0&&(C=new Set,_.set(f,C));C.has(v)||(El=!0,C.add(v),c=Mv.bind(null,c,f,v),f.then(c,c))}function Mv(c,f,v){var _=c.pingCache;_!==null&&_.delete(f),c.pingedLanes|=c.suspendedLanes&v,c.warmLanes&=~v,xn===c&&(Pn&v)===v&&(zi===4||zi===3&&(Pn&62914560)===Pn&&300>Hr()-Gf?(An&2)===0&&Vi(c,0):bu|=v,xu===Pn&&(xu=0)),Et(c)}function Ev(c,f){f===0&&(f=D()),c=hr(c,f),c!==null&&(U(c,f),Et(c))}function Q_(c){var f=c.memoizedState,v=0;f!==null&&(v=f.retryLane),Ev(c,v)}function J_(c,f){var v=0;switch(c.tag){case 31:case 13:var _=c.stateNode,C=c.memoizedState;C!==null&&(v=C.retryLane);break;case 19:_=c.stateNode;break;case 22:_=c.stateNode._retryCache;break;default:throw Error(r(314))}_!==null&&_.delete(f),Ev(c,v)}function sr(c,f){return Lf(c,f)}function ym(c,f,v,_){this.tag=c,this.key=v,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=_,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zl(c){return c=c.prototype,!(!c||!c.isReactComponent)}function Na(c,f){var v=c.alternate;return v===null?(v=t(c.tag,f,c.key,c.mode),v.elementType=c.elementType,v.type=c.type,v.stateNode=c.stateNode,v.alternate=c,c.alternate=v):(v.pendingProps=f,v.type=c.type,v.flags=0,v.subtreeFlags=0,v.deletions=null),v.flags=c.flags&65011712,v.childLanes=c.childLanes,v.lanes=c.lanes,v.child=c.child,v.memoizedProps=c.memoizedProps,v.memoizedState=c.memoizedState,v.updateQueue=c.updateQueue,f=c.dependencies,v.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},v.sibling=c.sibling,v.index=c.index,v.ref=c.ref,v.refCleanup=c.refCleanup,v}function sh(c,f){c.flags&=65011714;var v=c.alternate;return v===null?(c.childLanes=0,c.lanes=f,c.child=null,c.subtreeFlags=0,c.memoizedProps=null,c.memoizedState=null,c.updateQueue=null,c.dependencies=null,c.stateNode=null):(c.childLanes=v.childLanes,c.lanes=v.lanes,c.child=v.child,c.subtreeFlags=0,c.deletions=null,c.memoizedProps=v.memoizedProps,c.memoizedState=v.memoizedState,c.updateQueue=v.updateQueue,c.type=v.type,f=v.dependencies,c.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext}),c}function Ao(c,f,v,_,C,I){var X=0;if(_=c,typeof c=="function")Zl(c)&&(X=1);else if(typeof c=="string")X=ss&&mr?_h(c,v,Er.current)?26:tg(c)?27:5:ss?_h(c,v,Er.current)?26:5:mr&&tg(c)?27:5;else e:switch(c){case Af:return c=t(31,v,f,C),c.elementType=Af,c.lanes=I,c;case ec:return is(v.children,C,I,f);case tc:X=8,C|=24;break;case nc:return c=t(12,v,f,C|2),c.elementType=nc,c.lanes=I,c;case uh:return c=t(13,v,f,C),c.elementType=uh,c.lanes=I,c;case Co:return c=t(19,v,f,C),c.elementType=Co,c.lanes=I,c;default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case rs:X=10;break e;case wf:X=9;break e;case su:X=11;break e;case fh:X=14;break e;case ta:X=16,_=null;break e}X=29,v=Error(r(130,c===null?"null":typeof c,"")),_=null}return f=t(X,v,f,C),f.elementType=c,f.type=_,f.lanes=I,f}function is(c,f,v,_){return c=t(7,c,_,f),c.lanes=v,c}function bm(c,f,v){return c=t(6,c,null,f),c.lanes=v,c}function xm(c){var f=t(18,null,null,0);return f.stateNode=c,f}function _m(c,f,v){return f=t(4,c.children!==null?c.children:[],c.key,f),f.lanes=v,f.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},f}function Tv(c,f,v,_,C,I,X,le,Fe){this.tag=1,this.containerInfo=c,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=ma,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=F(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=F(0),this.hiddenUpdates=F(null),this.identifierPrefix=_,this.onUncaughtError=C,this.onCaughtError=I,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Fe,this.incompleteTransitions=new Map}function fl(c,f,v,_,C,I,X,le,Fe,st,Tt,ht){return c=new Tv(c,f,v,X,Fe,st,Tt,ht,le),f=1,I===!0&&(f|=24),I=t(3,null,null,f),c.current=I,I.stateNode=c,f=Ee(),f.refCount++,c.pooledCache=f,f.refCount++,I.memoizedState={element:_,isDehydrated:v,cache:f},ji(I),c}function oh(c){return c?(c=to,c):to}function Ef(c){var f=c._reactInternals;if(f===void 0)throw typeof c.render=="function"?Error(r(188)):(c=Object.keys(c).join(","),Error(r(268,c)));return c=u(f),c=c!==null?h(c):null,c===null?null:lu(c.stateNode)}function Sm(c,f,v,_,C,I){C=oh(C),_.context===null?_.context=C:_.pendingContext=C,_=Zr(f),_.payload={element:v},I=I===void 0?null:I,I!==null&&(_.callback=I),v=Ie(c,_,f),v!==null&&(Pi(v,c,f),Ke(v,c,f))}function Kl(c,f){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var v=c.retryLane;c.retryLane=v!==0&&v=st&&I>=ht&&C<=Tt&&X<=Ot){c.splice(f,1);break}else if(_!==st||v.width!==Fe.width||OtX){if(!(I!==ht||v.height!==Fe.height||Tt<_||st>C)){st>_&&(Fe.width+=st-_,Fe.x=_),TtI&&(Fe.height+=ht-I,Fe.y=I),Otv&&(v=le)),le ")+` No matching component was found for: `)+c.join(" > ")}return null},yn.getPublicRootInstance=function(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 27:case 5:return lu(c.child.stateNode);default:return c.child.stateNode}},yn.injectIntoDevTools=function(){var c={bundleType:0,version:Em,rendererPackageName:Cf,currentDispatcherRef:Xt,reconcilerVersion:"19.2.0"};if(ou!==null&&(c.rendererConfig=ou),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")c=!1;else{var f=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(f.isDisabled||!f.supportsFiber)c=!0;else{try{cc=f.inject(c),va=f}catch{}c=!!f.checkDCE}}return c},yn.isAlreadyRendering=function(){return(An&6)!==0},yn.observeVisibleRects=function(c,f,v,_){if(!pr)throw Error(r(363));c=da(c,f);var C=gh(c,v,_).disconnect;return{disconnect:function(){C()}}},yn.shouldError=function(){return null},yn.shouldSuspend=function(){return!1},yn.startHostTransition=function(c,f,v,_){if(c.tag!==5)throw Error(r(476));var C=Q0(c).queue;K0(c,C,f,rc,v===null?i:function(){var I=Q0(c);return I.next===null&&(I=c.alternate.memoizedState),df(c,I.next.queue,{},Ti()),v(_)})},yn.updateContainer=function(c,f,v,_){var C=f.current,I=Ti();return Sm(C,I,c,f,v,_),I},yn.updateContainerSync=function(c,f,v,_){return Sm(f.current,2,c,f,v,_),2},yn},n.exports.default=n.exports,Object.defineProperty(n.exports,"__esModule",{value:!0})})(sC)),sC.exports}var lC;function H2(){return lC||(lC=1,aC.exports=k2()),aC.exports}var V2=H2();const G2=B2(V2);function W2(n){const e=G2(n);return e.injectIntoDevTools(),e}const uO=0,Lp={},X2=/^three(?=[A-Z])/,U_=n=>`${n[0].toUpperCase()}${n.slice(1)}`;let $2=0;const j2=n=>typeof n=="function";function fO(n){if(j2(n)){const e=`${$2++}`;return Lp[e]=n,e}else Object.assign(Lp,n)}function dO(n,e){const t=U_(n),i=Lp[t];if(n!=="primitive"&&!i)throw new Error(`R3F: ${t} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(n==="primitive"&&!e.object)throw new Error("R3F: Primitives without 'object' are invalid!");if(e.args!==void 0&&!Array.isArray(e.args))throw new Error("R3F: The args prop must be an array!")}function q2(n,e,t){var i;return n=U_(n)in Lp?n:n.replace(X2,""),dO(n,e),n==="primitive"&&(i=e.object)!=null&&i.__r3f&&delete e.object.__r3f,Ox(e.object,t,n,e)}function Y2(n){if(!n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Px(n.parent,n):bs(n.object)&&(n.object.visible=!1),n.isHidden=!0,Hp(n)}}function hO(n){if(n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Ix(n.parent,n):bs(n.object)&&n.props.visible!==!1&&(n.object.visible=!0),n.isHidden=!1,Hp(n)}}function iT(n,e,t){const i=e.root.getState();if(!(!n.parent&&n.object!==i.scene)){if(!e.object){var r,s;const l=Lp[U_(e.type)];e.object=(r=e.props.object)!=null?r:new l(...(s=e.props.args)!=null?s:[]),e.object.__r3f=e}if(ku(e.object,e.props),e.props.attach)Ix(n,e);else if(bs(e.object)&&bs(n.object)){const l=n.object.children.indexOf(t?.object);if(t&&l!==-1){const u=n.object.children.indexOf(e.object);if(u!==-1){n.object.children.splice(u,1);const h=u{try{n.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():RM.unstable_scheduleCallback(RM.unstable_IdlePriority,e)}}function OM(n,e,t){if(!e)return;e.parent=null;const i=n.children.indexOf(e);i!==-1&&n.children.splice(i,1),e.props.attach?Px(n,e):bs(e.object)&&bs(n.object)&&(n.object.remove(e.object),O2(nO(e),e.object));const r=e.props.dispose!==null&&t!==!1;for(let s=e.children.length-1;s>=0;s--){const l=e.children[s];OM(e,l,r)}e.children.length=0,delete e.object.__r3f,r&&e.type!=="primitive"&&e.object.type!=="Scene"&&pO(e.object),t===void 0&&Hp(e)}function Z2(n,e){for(const t of[n,n.alternate])if(t!==null)if(typeof t.ref=="function"){t.refCleanup==null||t.refCleanup();const i=t.ref(e);typeof i=="function"&&(t.refCleanup=i)}else t.ref&&(t.ref.current=e)}const Ub=[];function K2(){for(const[t]of Ub){const i=t.parent;if(i){t.props.attach?Px(i,t):bs(t.object)&&bs(i.object)&&i.object.remove(t.object);for(const r of t.children)r.props.attach?Px(t,r):bs(r.object)&&bs(t.object)&&t.object.remove(r.object)}t.isHidden&&hO(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&pO(t.object)}for(const[t,i,r]of Ub){t.props=i;const s=t.parent;if(s){var n,e;const l=Lp[U_(t.type)];t.object=(n=t.props.object)!=null?n:new l(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,Z2(r,t.object),ku(t.object,t.props),t.props.attach?Ix(s,t):bs(t.object)&&bs(s.object)&&s.object.add(t.object);for(const u of t.children)u.props.attach?Ix(t,u):bs(u.object)&&bs(t.object)&&t.object.add(u.object);Hp(t)}}Ub.length=0}const C1=()=>{},uC={};let Sb=uO;const Q2=0,J2=4,IM=W2({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:q2,removeChild:OM,appendChild:A1,appendInitialChild:A1,insertBefore:cC,appendChildToContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||A1(t,e)},removeChildFromContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||OM(t,e)},insertInContainerBefore(n,e,t){const i=n.getState().scene.__r3f;!e||!t||!i||cC(i,e,t)},getRootHostContext:()=>uC,getChildHostContext:()=>uC,commitUpdate(n,e,t,i,r){var s,l,u;dO(e,i);let h=!1;if((n.type==="primitive"&&t.object!==i.object||((s=i.args)==null?void 0:s.length)!==((l=t.args)==null?void 0:l.length)||(u=i.args)!=null&&u.some((g,y)=>{var b;return g!==((b=t.args)==null?void 0:b[y])}))&&(h=!0),h)Ub.push([n,{...i},r]);else{const g=A2(n,i);Object.keys(g).length&&(Object.assign(n.props,g),ku(n.object,g))}(r.sibling===null||(r.flags&J2)===Q2)&&K2()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:n=>n?.object,prepareForCommit:()=>null,preparePortalMount:n=>Ox(n.getState().scene,n,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:Y2,unhideInstance:hO,createTextInstance:C1,hideTextInstance:C1,unhideTextInstance:C1,scheduleTimeout:typeof setTimeout=="function"?setTimeout:void 0,cancelTimeout:typeof clearTimeout=="function"?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:P.createContext(null),setCurrentUpdatePriority(n){Sb=n},getCurrentUpdatePriority(){return Sb},resolveUpdatePriority(){var n;if(Sb!==uO)return Sb;switch(typeof window<"u"&&((n=window.event)==null?void 0:n.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return z2;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return N2;default:return U2}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:F2.version,applyViewTransitionName(n,e,t){},restoreViewTransitionName(n,e){},cancelViewTransitionName(n,e,t){},cancelRootViewTransitionName(n){},restoreRootViewTransitionName(n){},InstanceMeasurement:null,measureInstance:n=>null,wasInstanceInViewport:n=>!0,hasInstanceChanged:(n,e)=>!1,hasInstanceAffectedParent:(n,e)=>!1,suspendOnActiveViewTransition(n,e){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(n){},createViewTransitionInstance:n=>null,getCurrentGestureOffset(n){throw new Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance(n,e){return n},cloneMutableTextInstance(n){return n},cloneRootViewTransitionContainer(n){throw new Error("Not implemented.")},removeRootViewTransitionClone(n,e){throw new Error("Not implemented.")},createFragmentInstance:n=>null,updateFragmentInstanceFiber(n,e){},commitNewChildToFragmentInstance(n,e){},deleteChildFromFragmentInstance(n,e){},measureClonedInstance:n=>null,maySuspendCommitOnUpdate:(n,e,t)=>!1,maySuspendCommitInSyncRender:(n,e)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(n,e)=>null}),wd=new Map,up={objects:"shallow",strict:!1};function e6(n,e){if(!e&&typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:t,height:i,top:r,left:s}=n.parentElement.getBoundingClientRect();return{width:t,height:i,top:r,left:s}}else if(!e&&typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...e}}function t6(n){const e=wd.get(n),t=e?.fiber,i=e?.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,s=i||P2(NM,dC),l=t||IM.createContainer(s,L2,null,!1,null,"",r,r,r,null);e||wd.set(n,{fiber:l,store:s});let u,h,p=!1,g=null;return{async configure(y={}){let b;g=new Promise(q=>b=q);let{gl:x,size:E,scene:A,events:T,onCreated:M,shadows:R=!1,linear:O=!1,flat:D=!1,legacy:F=!1,orthographic:U=!1,frameloop:k="always",dpr:H=[1,2],performance:L,raycaster:z,camera:W,onPointerMissed:J}=y,$=s.getState(),oe=$.gl;if(!$.gl){const q={canvas:n,powerPreference:"high-performance",antialias:!0,alpha:!0},ce=typeof x=="function"?await x(q):x;rC(ce)?oe=ce:oe=new QD({...q,...x}),$.set({gl:oe})}let ne=$.raycaster;ne||$.set({raycaster:ne=new WD});const{params:Y,...K}=z||{};if(tr.equ(K,ne,up)||ku(ne,{...K}),tr.equ(Y,ne.params,up)||ku(ne,{params:{...ne.params,...Y}}),!$.camera||$.camera===h&&!tr.equ(h,W,up)){h=W;const q=W?.isCamera,ce=q?W:U?new qo(0,0,0,0,.1,1e3):new nr(75,0,.1,1e3);q||(ce.position.z=5,W&&(ku(ce,W),ce.manual||("aspect"in W||"left"in W||"right"in W||"bottom"in W||"top"in W)&&(ce.manual=!0,ce.updateProjectionMatrix())),!$.camera&&!(W!=null&&W.rotation)&&ce.lookAt(0,0,0)),$.set({camera:ce}),ne.camera=ce}if(!$.scene){let q;A!=null&&A.isScene?(q=A,Ox(q,s,"",{})):(q=new Ps,Ox(q,s,"",{}),A&&ku(q,A)),$.set({scene:q})}T&&!$.events.handlers&&$.set({events:T(s)});const ie=e6(n,E);if(tr.equ(ie,$.size,up)||$.setSize(ie.width,ie.height,ie.top,ie.left),H&&$.viewport.dpr!==aO(H)&&$.setDpr(H),$.frameloop!==k&&$.setFrameloop(k),$.onPointerMissed||$.set({onPointerMissed:J}),L&&!tr.equ(L,$.performance,up)&&$.set(q=>({performance:{...q.performance,...L}})),!$.xr){var ge;const q=(Ge,Ye)=>{const ve=s.getState();ve.frameloop!=="never"&&dC(Ge,!0,ve,Ye)},ce=()=>{const Ge=s.getState();Ge.gl.xr.enabled=Ge.gl.xr.isPresenting,Ge.gl.xr.setAnimationLoop(Ge.gl.xr.isPresenting?q:null),Ge.gl.xr.isPresenting||NM(Ge)},Se={connect(){const Ge=s.getState().gl;Ge.xr.addEventListener("sessionstart",ce),Ge.xr.addEventListener("sessionend",ce)},disconnect(){const Ge=s.getState().gl;Ge.xr.removeEventListener("sessionstart",ce),Ge.xr.removeEventListener("sessionend",ce)}};typeof((ge=oe.xr)==null?void 0:ge.addEventListener)=="function"&&Se.connect(),$.set({xr:Se})}if(oe.shadowMap){const q=oe.shadowMap.enabled,ce=oe.shadowMap.type;if(oe.shadowMap.enabled=!!R,tr.boo(R))oe.shadowMap.type=Xg;else if(tr.str(R)){var xe;const Se={basic:g3,percentage:_p,soft:Xg,variance:fd};oe.shadowMap.type=(xe=Se[R])!=null?xe:Xg}else tr.obj(R)&&Object.assign(oe.shadowMap,R);(q!==oe.shadowMap.enabled||ce!==oe.shadowMap.type)&&(oe.shadowMap.needsUpdate=!0)}return Hn.enabled=!F,p||(oe.outputColorSpace=O?Fl:Zn,oe.toneMapping=D?Us:t_),$.legacy!==F&&$.set(()=>({legacy:F})),$.linear!==O&&$.set(()=>({linear:O})),$.flat!==D&&$.set(()=>({flat:D})),x&&!tr.fun(x)&&!rC(x)&&!tr.equ(x,oe,up)&&ku(oe,x),u=M,p=!0,b(),this},render(y){return!p&&!g&&this.configure(),g.then(()=>{IM.updateContainer(xt.jsx(n6,{store:s,children:y,onCreated:u,rootElement:n}),l,null,()=>{})}),s},unmount(){mO(n)}}}function n6({store:n,children:e,onCreated:t,rootElement:i}){return F0(()=>{const r=n.getState();r.set(s=>({internal:{...s.internal,active:!0}})),t&&t(r),n.getState().events.connected||r.events.connect==null||r.events.connect(i)},[]),xt.jsx(lO.Provider,{value:n,children:e})}function mO(n,e){const t=wd.get(n),i=t?.fiber;if(i){const r=t?.store.getState();r&&(r.internal.active=!1),IM.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{var s,l,u,h;r.events.disconnect==null||r.events.disconnect(),(s=r.gl)==null||(l=s.renderLists)==null||l.dispose==null||l.dispose(),(u=r.gl)==null||u.forceContextLoss==null||u.forceContextLoss(),(h=r.gl)!=null&&h.xr&&r.xr.disconnect(),E2(r.scene),wd.delete(n)}catch{}},500)})}}function gO(n,e){const t={callback:n};return e.add(t),()=>{e.delete(t)}}const vO=new Set,yO=new Set,i6=new Set,r6=n=>gO(n,vO),a6=n=>gO(n,yO);function R1(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function e0(n,e){switch(n){case"before":return R1(vO,e);case"after":return R1(yO,e);case"tail":return R1(i6,e)}}let D1,O1;function PM(n,e,t){let i=e.clock.getDelta();e.frameloop==="never"&&typeof n=="number"&&(i=n-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=n),D1=e.internal.subscribers;for(let r=0;r0)&&!((e=fp.gl.xr)!=null&&e.isPresenting)&&(I1+=PM(n,fp))}if(LM=!1,e0("after",n),I1===0)return e0("tail",n),Lx=!1,cancelAnimationFrame(fC)}function NM(n,e=1){var t;if(!n)return wd.forEach(i=>NM(i.store.getState(),e));(t=n.gl.xr)!=null&&t.isPresenting||!n.internal.active||n.frameloop==="never"||(e>1?n.internal.frames=Math.min(60,n.internal.frames+e):LM?n.internal.frames=2:n.internal.frames=1,Lx||(Lx=!0,requestAnimationFrame(bO)))}function dC(n,e=!0,t,i){if(e&&e0("before",n),t)PM(n,t,i);else for(const r of wd.values())PM(n,r.store.getState());e&&e0("after",n)}const P1={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function s6(n){const{handlePointer:e}=I2(n);return{priority:1,enabled:!0,compute(t,i,r){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(P1).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:r}=n.getState();(t=r.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{const{set:i,events:r}=n.getState();if(r.disconnect==null||r.disconnect(),i(s=>({events:{...s.events,connected:t}})),r.handlers)for(const s in r.handlers){const l=r.handlers[s],[u,h]=P1[s];t.addEventListener(u,l,{passive:h})}},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){if(i.handlers)for(const r in i.handlers){const s=i.handlers[r],[l]=P1[r];i.connected.removeEventListener(l,s)}t(r=>({events:{...r.events,connected:void 0}}))}}}}function hC(n,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...i),e)}}function o6({debounce:n,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const r=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!r)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,l]=P.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),u=P.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s,orientationHandler:null}),h=n?typeof n=="number"?n:n.scroll:null,p=n?typeof n=="number"?n:n.resize:null,g=P.useRef(!1);P.useEffect(()=>(g.current=!0,()=>{g.current=!1}));const[y,b,x]=P.useMemo(()=>{const M=()=>{if(!u.current.element)return;const{left:R,top:O,width:D,height:F,bottom:U,right:k,x:H,y:L}=u.current.element.getBoundingClientRect(),z={left:R,top:O,width:D,height:F,bottom:U,right:k,x:H,y:L};u.current.element instanceof HTMLElement&&i&&(z.height=u.current.element.offsetHeight,z.width=u.current.element.offsetWidth),Object.freeze(z),g.current&&!f6(u.current.lastBounds,z)&&l(u.current.lastBounds=z)};return[M,p?hC(M,p):M,h?hC(M,h):M]},[l,i,h,p]);function E(){u.current.scrollContainers&&(u.current.scrollContainers.forEach(M=>M.removeEventListener("scroll",x,!0)),u.current.scrollContainers=null),u.current.resizeObserver&&(u.current.resizeObserver.disconnect(),u.current.resizeObserver=null),u.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",u.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",u.current.orientationHandler))}function A(){u.current.element&&(u.current.resizeObserver=new r(x),u.current.resizeObserver.observe(u.current.element),e&&u.current.scrollContainers&&u.current.scrollContainers.forEach(M=>M.addEventListener("scroll",x,{capture:!0,passive:!0})),u.current.orientationHandler=()=>{x()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",u.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",u.current.orientationHandler))}const T=M=>{!M||M===u.current.element||(E(),u.current.element=M,u.current.scrollContainers=xO(M),A())};return c6(x,!!e),l6(b),P.useEffect(()=>{E(),A()},[e,x,b]),P.useEffect(()=>E,[]),[T,s,y]}function l6(n){P.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[n])}function c6(n,e){P.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",t,!0)}}},[n,e])}function xO(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:i,overflowY:r}=window.getComputedStyle(n);return[t,i,r].some(s=>s==="auto"||s==="scroll")&&e.push(n),[...e,...xO(n.parentElement)]}const u6=["x","y","top","bottom","left","right","width","height"],f6=(n,e)=>u6.every(t=>n[t]===e[t]);function d6({ref:n,children:e,fallback:t,resize:i,style:r,gl:s,events:l=s6,eventSource:u,eventPrefix:h,shadows:p,linear:g,flat:y,legacy:b,orthographic:x,frameloop:E,dpr:A,performance:T,raycaster:M,camera:R,scene:O,onPointerMissed:D,onCreated:F,...U}){P.useMemo(()=>fO(n2),[]);const k=_2(),[H,L]=o6({scroll:!0,debounce:{scroll:50,resize:0},...i}),z=P.useRef(null),W=P.useRef(null);P.useImperativeHandle(n,()=>z.current);const J=rO(D),[$,oe]=P.useState(!1),[ne,Y]=P.useState(!1);if($)throw $;if(ne)throw ne;const K=P.useRef(null);F0(()=>{const ge=z.current;if(L.width>0&&L.height>0&&ge){K.current||(K.current=t6(ge));async function xe(){await K.current.configure({gl:s,scene:O,events:l,shadows:p,linear:g,flat:y,legacy:b,orthographic:x,frameloop:E,dpr:A,performance:T,raycaster:M,camera:R,size:L,onPointerMissed:(...q)=>J.current==null?void 0:J.current(...q),onCreated:q=>{q.events.connect==null||q.events.connect(u?b2(u)?u.current:u:W.current),h&&q.setEvents({compute:(ce,Se)=>{const Ge=ce[h+"X"],Ye=ce[h+"Y"];Se.pointer.set(Ge/Se.size.width*2-1,-(Ye/Se.size.height)*2+1),Se.raycaster.setFromCamera(Se.pointer,Se.camera)}}),F?.(q)}}),K.current.render(xt.jsx(k,{children:xt.jsx(M2,{set:Y,children:xt.jsx(P.Suspense,{fallback:xt.jsx(S2,{set:oe}),children:e??null})})}))}xe()}}),P.useEffect(()=>{const ge=z.current;if(ge)return()=>mO(ge)},[]);const ie=u?"none":"auto";return xt.jsx("div",{ref:W,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:ie,...r},...U,children:xt.jsx("div",{ref:H,style:{width:"100%",height:"100%"},children:xt.jsx("canvas",{ref:z,style:{display:"block"},children:t})})})}function h6(n){return xt.jsx(eO,{children:xt.jsx(d6,{...n})})}function Nx(){return Nx=Object.assign?Object.assign.bind():function(n){for(var e=1;et?+pC(n-t,t-e,i)+t:n}function m6(n,[e,t],[i,r]){const[[s,l],[u,h]]=n;return[mC(e,s,l,i),mC(t,u,h,r)]}function g6(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function v6(n){var e=g6(n,"string");return typeof e=="symbol"?e:String(e)}function ys(n,e,t){return e=v6(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function gC(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function rr(n){for(var e=1;e{var t,i;return e.target===n.currentTarget||((t=n.currentTarget)===null||t===void 0||(i=t.contains)===null||i===void 0?void 0:i.call(t,e.target))})}function T6(n){return n.type==="touchend"||n.type==="touchcancel"?n.changedTouches:n.targetTouches}function MO(n){return z_(n)?T6(n)[0]:n}function w6(n){return E6(n).map(e=>e.identifier)}function L1(n){const e=MO(n);return z_(n)?e.identifier:e.pointerId}function yC(n){const e=MO(n);return[e.clientX,e.clientY]}function A6(n){const e={};if("buttons"in n&&(e.buttons=n.buttons),"shiftKey"in n){const{shiftKey:t,altKey:i,metaKey:r,ctrlKey:s}=n;Object.assign(e,{shiftKey:t,altKey:i,metaKey:r,ctrlKey:s})}return e}function Ux(n,...e){return typeof n=="function"?n(...e):n}function C6(){}function R6(...n){return n.length===0?C6:n.length===1?n[0]:function(){let e;for(const t of n)e=t.apply(this,arguments)||e;return e}}function bC(n,e){return Object.assign({},e,n||{})}const D6=32;class O6{constructor(e,t,i){this.ctrl=e,this.args=t,this.key=i,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:i,args:r}=this;t[i]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=r,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,i=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=i.from?Ux(i.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:i,shared:r}=this;t.args=this.args;let s=0;if(e&&(t.event=e,i.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,r.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,r.locked=!!document.pointerLockElement,Object.assign(r,A6(e)),r.down=r.pressed=r.buttons%2===1||r.touches>0,s=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const U=t._delta.map(Math.abs);wa.addTo(t._distance,U)}this.axisIntent&&this.axisIntent(e);const[l,u]=t._movement,[h,p]=i.threshold,{_step:g,values:y}=t;if(i.hasCustomTransform?(g[0]===!1&&(g[0]=Math.abs(l)>=h&&y[0]),g[1]===!1&&(g[1]=Math.abs(u)>=p&&y[1])):(g[0]===!1&&(g[0]=Math.abs(l)>=h&&Math.sign(l)*h),g[1]===!1&&(g[1]=Math.abs(u)>=p&&Math.sign(u)*p)),t.intentional=g[0]!==!1||g[1]!==!1,!t.intentional)return;const b=[0,0];if(i.hasCustomTransform){const[U,k]=y;b[0]=g[0]!==!1?U-g[0]:0,b[1]=g[1]!==!1?k-g[1]:0}else b[0]=g[0]!==!1?l-g[0]:0,b[1]=g[1]!==!1?u-g[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(b);const x=t.offset,E=t._active&&!t._blocked||t.active;E&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=r[this.ingKey]=t._active,e&&(t.first&&("bounds"in i&&(t._bounds=Ux(i.bounds,t)),this.setup&&this.setup()),t.movement=b,this.computeOffset()));const[A,T]=t.offset,[[M,R],[O,D]]=t._bounds;t.overflow=[AR?1:0,TD?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const F=t._active?i.rubberband||[0,0]:[0,0];if(t.offset=m6(t._bounds,t.offset,F),t.delta=wa.sub(t.offset,x),this.computeMovement(),E&&(!t.last||s>D6)){t.delta=wa.sub(t.offset,x);const U=t.delta.map(Math.abs);wa.addTo(t.distance,U),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&s>0&&(t.velocity=[U[0]/s,U[1]/s],t.timeDelta=s)}}emit(){const e=this.state,t=this.shared,i=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!i.triggerAllEvents)return;const r=this.handler(rr(rr(rr({},t),e),{},{[this.aliasKey]:e.values}));r!==void 0&&(e.memo=r)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function I6([n,e],t){const i=Math.abs(n),r=Math.abs(e);if(i>r&&i>t)return"x";if(r>i&&r>t)return"y"}class P6 extends O6{constructor(...e){super(...e),ys(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=wa.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=wa.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,i=this.config;if(!t.axis&&e){const r=typeof i.axisThreshold=="object"?i.axisThreshold[SO(e)]:i.axisThreshold;t.axis=I6(t._movement,r)}t._blocked=(i.lockDirection||!!i.axis)&&!t.axis||!!i.axis&&i.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const L6=n=>n,xC=.15,EO={enabled(n=!0){return n},eventOptions(n,e,t){return rr(rr({},t.shared.eventOptions),n)},preventDefault(n=!1){return n},triggerAllEvents(n=!1){return n},rubberband(n=0){switch(n){case!0:return[xC,xC];case!1:return[0,0];default:return wa.toVector(n)}},from(n){if(typeof n=="function")return n;if(n!=null)return wa.toVector(n)},transform(n,e,t){const i=n||t.shared.transform;return this.hasCustomTransform=!!i,i||L6},threshold(n){return wa.toVector(n,0)}},N6=0,B0=rr(rr({},EO),{},{axis(n,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(n=N6){return n},bounds(n={}){if(typeof n=="function")return s=>B0.bounds(n(s));if("current"in n)return()=>n.current;if(typeof HTMLElement=="function"&&n instanceof HTMLElement)return n;const{left:e=-1/0,right:t=1/0,top:i=-1/0,bottom:r=1/0}=n;return[[e,t],[i,r]]}}),_C={ArrowRight:(n,e=1)=>[n*e,0],ArrowLeft:(n,e=1)=>[-1*n*e,0],ArrowUp:(n,e=1)=>[0,-1*n*e],ArrowDown:(n,e=1)=>[0,n*e]};class U6 extends P6{constructor(...e){super(...e),ys(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),i=e.currentTarget.getBoundingClientRect(),r={left:t.left-i.left+e.offset[0],right:t.right-i.right+e.offset[0],top:t.top-i.top+e.offset[1],bottom:t.bottom-i.bottom+e.offset[1]};e._bounds=B0.bounds(r)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,i=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const r=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(r&&r.size>1&&i._pointerActive)&&(this.start(e),this.setupPointer(e),i._pointerId=L1(e),i._pointerActive=!0,this.computeValues(yC(e)),this.computeInitial(),t.preventScrollAxis&&SO(e)!=="mouse"?(i._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,i=this.config;if(!t._pointerActive)return;const r=L1(e);if(t._pointerId!==void 0&&r!==t._pointerId)return;const s=yC(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=wa.sub(s,t._values),this.computeValues(s)),wa.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(i.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===i.preventScrollAxis||i.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const t=this.state,i=this.config;if(!t._active||!t._pointerActive)return;const r=L1(e);if(t._pointerId!==void 0&&r!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[s,l]=t._distance;if(t.tap=s<=i.tapsThreshold&&l<=i.tapsThreshold,t.tap&&i.filterTaps)t._force=!0;else{const[u,h]=t._delta,[p,g]=t._movement,[y,b]=i.swipe.velocity,[x,E]=i.swipe.distance,A=i.swipe.duration;if(t.elapsedTimey&&Math.abs(p)>x&&(t.swipe[0]=Math.sign(u)),M>b&&Math.abs(g)>E&&(t.swipe[1]=Math.sign(h))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,i=t.device;t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,i,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,i,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,i,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,z6(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=_C[e.key];if(t){const i=this.state,r=e.shiftKey?10:e.altKey?.1:1;this.start(e),i._delta=t(this.config.keyboardDisplacement,r),i._keyboardActive=!0,wa.addTo(i._movement,i._delta),this.compute(e),this.emit()}}keyUp(e){e.key in _C&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function z6(n){"persist"in n&&typeof n.persist=="function"&&n.persist()}const k0=typeof window<"u"&&window.document&&window.document.createElement;function TO(){return k0&&"ontouchstart"in window}function F6(){return TO()||k0&&window.navigator.maxTouchPoints>1}function B6(){return k0&&"onpointerdown"in window}function k6(){return k0&&"exitPointerLock"in window.document}function H6(){try{return"constructor"in GestureEvent}catch{return!1}}const mo={isBrowser:k0,gesture:H6(),touch:TO(),touchscreen:F6(),pointer:B6(),pointerLock:k6()},V6=250,G6=180,W6=.5,X6=50,$6=250,j6=10,SC={mouse:0,touch:0,pen:8},q6=rr(rr({},B0),{},{device(n,e,{pointer:{touch:t=!1,lock:i=!1,mouse:r=!1}={}}){return this.pointerLock=i&&mo.pointerLock,mo.touch&&t?"touch":this.pointerLock?"mouse":mo.pointer&&!r?"pointer":mo.touch?"touch":"mouse"},preventScrollAxis(n,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&n?V6:void 0,!(!mo.touchscreen||t===!1))return n||(t!==void 0?"y":void 0)},pointerCapture(n,e,{pointer:{capture:t=!0,buttons:i=1,keys:r=!0}={}}){return this.pointerButtons=i,this.keys=r,!this.pointerLock&&this.device==="pointer"&&t},threshold(n,e,{filterTaps:t=!1,tapsThreshold:i=3,axis:r=void 0}){const s=wa.toVector(n,t?i:r?1:0);return this.filterTaps=t,this.tapsThreshold=i,s},swipe({velocity:n=W6,distance:e=X6,duration:t=$6}={}){return{velocity:this.transform(wa.toVector(n)),distance:this.transform(wa.toVector(e)),duration:t}},delay(n=0){switch(n){case!0:return G6;case!1:return 0;default:return n}},axisThreshold(n){return n?rr(rr({},SC),n):SC},keyboardDisplacement(n=j6){return n}});rr(rr({},EO),{},{device(n,e,{shared:t,pointer:{touch:i=!1}={}}){if(t.target&&!mo.touch&&mo.gesture)return"gesture";if(mo.touch&&i)return"touch";if(mo.touchscreen){if(mo.pointer)return"pointer";if(mo.touch)return"touch"}},bounds(n,e,{scaleBounds:t={},angleBounds:i={}}){const r=l=>{const u=bC(Ux(t,l),{min:-1/0,max:1/0});return[u.min,u.max]},s=l=>{const u=bC(Ux(i,l),{min:-1/0,max:1/0});return[u.min,u.max]};return typeof t!="function"&&typeof i!="function"?[r(),s()]:l=>[r(l),s(l)]},threshold(n,e,t){return this.lockDirection=t.axis==="lock",wa.toVector(n,this.lockDirection?[.1,3]:0)},modifierKey(n){return n===void 0?"ctrlKey":n},pinchOnWheel(n=!0){return n}});rr(rr({},B0),{},{mouseOnly:(n=!0)=>n});rr(rr({},B0),{},{mouseOnly:(n=!0)=>n});const wO=new Map,UM=new Map;function Y6(n){wO.set(n.key,n.engine),UM.set(n.key,n.resolver)}const Z6={key:"drag",engine:U6,resolver:q6};function K6(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,s;for(s=0;s=0)&&(t[r]=n[r]);return t}function Q6(n,e){if(n==null)return{};var t=K6(n,e),i,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}const J6={target(n){if(n)return()=>"current"in n?n.current:n},enabled(n=!0){return n},window(n=mo.isBrowser?window:void 0){return n},eventOptions({passive:n=!0,capture:e=!1}={}){return{passive:n,capture:e}},transform(n){return n}},eH=["target","eventOptions","window","enabled","transform"];function zb(n={},e){const t={};for(const[i,r]of Object.entries(e))switch(typeof r){case"function":t[i]=r.call(t,n[i],i,n);break;case"object":t[i]=zb(n[i],r);break;case"boolean":r&&(t[i]=n[i]);break}return t}function tH(n,e,t={}){const i=n,{target:r,eventOptions:s,window:l,enabled:u,transform:h}=i,p=Q6(i,eH);if(t.shared=zb({target:r,eventOptions:s,window:l,enabled:u,transform:h},J6),e){const g=UM.get(e);t[e]=zb(rr({shared:t.shared},p),g)}else for(const g in p){const y=UM.get(g);y&&(t[g]=zb(rr({shared:t.shared},p[g]),y))}return t}class AO{constructor(e,t){ys(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,i,r,s){const l=this._listeners,u=M6(t,i),h=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=rr(rr({},h),s);e.addEventListener(u,r,p);const g=()=>{e.removeEventListener(u,r,p),l.delete(g)};return l.add(g),g}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class nH{constructor(){ys(this,"_timeouts",new Map)}add(e,t,i=140,...r){this.remove(e),this._timeouts.set(e,window.setTimeout(t,i,...r))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>{window.clearTimeout(e)}),this._timeouts.clear()}}class iH{constructor(e){ys(this,"gestures",new Set),ys(this,"_targetEventStore",new AO(this)),ys(this,"gestureEventStores",{}),ys(this,"gestureTimeoutStores",{}),ys(this,"handlers",{}),ys(this,"config",{}),ys(this,"pointerIds",new Set),ys(this,"touchIds",new Set),ys(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),rH(this,e)}setEventIds(e){if(z_(e))return this.touchIds=new Set(w6(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=tH(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,i={};let r;if(!(t.target&&(r=t.target(),!r))){if(t.enabled){for(const l of this.gestures){const u=this.config[l],h=MC(i,u.eventOptions,!!r);if(u.enabled){const p=wO.get(l);new p(this,e,l).bind(h)}}const s=MC(i,t.eventOptions,!!r);for(const l in this.nativeHandlers)s(l,"",u=>this.nativeHandlers[l](rr(rr({},this.state.shared),{},{event:u,args:e})),void 0,!0)}for(const s in i)i[s]=R6(...i[s]);if(!r)return i;for(const s in i){const{device:l,capture:u,passive:h}=S6(s);this._targetEventStore.add(r,l,"",i[s],{capture:u,passive:h})}}}}function dp(n,e){n.gestures.add(e),n.gestureEventStores[e]=new AO(n,e),n.gestureTimeoutStores[e]=new nH}function rH(n,e){e.drag&&dp(n,"drag"),e.wheel&&dp(n,"wheel"),e.scroll&&dp(n,"scroll"),e.move&&dp(n,"move"),e.pinch&&dp(n,"pinch"),e.hover&&dp(n,"hover")}const MC=(n,e,t)=>(i,r,s,l={},u=!1)=>{var h,p;const g=(h=l.capture)!==null&&h!==void 0?h:e.capture,y=(p=l.passive)!==null&&p!==void 0?p:e.passive;let b=u?i:x6(i,r,g);t&&y&&(b+="Passive"),n[b]=n[b]||[],n[b].push(s)};function aH(n,e={},t,i){const r=ae.useMemo(()=>new iH(n),[]);if(r.applyHandlers(n,i),r.applyConfig(e,t),ae.useEffect(r.effect.bind(r)),ae.useEffect(()=>r.clean.bind(r),[]),e.target===void 0)return r.bind.bind(r)}function sH(n,e){return Y6(Z6),aH({drag:n},e||{},"drag")}var oH=Object.defineProperty,lH=(n,e,t)=>e in n?oH(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,cH=(n,e,t)=>(lH(n,e+"",t),t);class uH{constructor(){cH(this,"_listeners")}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,l=r.length;se in n?fH(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Qt=(n,e,t)=>(dH(n,typeof e!="symbol"?e+"":e,t),t);const Mb=new Dd,EC=new Tc,hH=Math.cos(70*(Math.PI/180)),TC=(n,e)=>(n%e+e)%e;let pH=class extends uH{constructor(e,t){super(),Qt(this,"object"),Qt(this,"domElement"),Qt(this,"enabled",!0),Qt(this,"target",new Q),Qt(this,"minDistance",0),Qt(this,"maxDistance",1/0),Qt(this,"minZoom",0),Qt(this,"maxZoom",1/0),Qt(this,"minPolarAngle",0),Qt(this,"maxPolarAngle",Math.PI),Qt(this,"minAzimuthAngle",-1/0),Qt(this,"maxAzimuthAngle",1/0),Qt(this,"enableDamping",!1),Qt(this,"dampingFactor",.05),Qt(this,"enableZoom",!0),Qt(this,"zoomSpeed",1),Qt(this,"enableRotate",!0),Qt(this,"rotateSpeed",1),Qt(this,"enablePan",!0),Qt(this,"panSpeed",1),Qt(this,"screenSpacePanning",!0),Qt(this,"keyPanSpeed",7),Qt(this,"zoomToCursor",!1),Qt(this,"autoRotate",!1),Qt(this,"autoRotateSpeed",2),Qt(this,"reverseOrbit",!1),Qt(this,"reverseHorizontalOrbit",!1),Qt(this,"reverseVerticalOrbit",!1),Qt(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Qt(this,"mouseButtons",{LEFT:od.ROTATE,MIDDLE:od.DOLLY,RIGHT:od.PAN}),Qt(this,"touches",{ONE:ld.ROTATE,TWO:ld.DOLLY_PAN}),Qt(this,"target0"),Qt(this,"position0"),Qt(this,"zoom0"),Qt(this,"_domElementKeyEvents",null),Qt(this,"getPolarAngle"),Qt(this,"getAzimuthalAngle"),Qt(this,"setPolarAngle"),Qt(this,"setAzimuthalAngle"),Qt(this,"getDistance"),Qt(this,"getZoomScale"),Qt(this,"listenToKeyEvents"),Qt(this,"stopListenToKeyEvents"),Qt(this,"saveState"),Qt(this,"reset"),Qt(this,"update"),Qt(this,"connect"),Qt(this,"dispose"),Qt(this,"dollyIn"),Qt(this,"dollyOut"),Qt(this,"getScale"),Qt(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>g.phi,this.getAzimuthalAngle=()=>g.theta,this.setPolarAngle=te=>{let be=TC(te,2*Math.PI),ct=g.phi;ct<0&&(ct+=2*Math.PI),be<0&&(be+=2*Math.PI);let re=Math.abs(be-ct);2*Math.PI-re{let be=TC(te,2*Math.PI),ct=g.theta;ct<0&&(ct+=2*Math.PI),be<0&&(be+=2*Math.PI);let re=Math.abs(be-ct);2*Math.PI-rei.object.position.distanceTo(i.target),this.listenToKeyEvents=te=>{te.addEventListener("keydown",pe),this._domElementKeyEvents=te},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",pe),this._domElementKeyEvents=null},this.saveState=()=>{i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=()=>{i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(r),i.update(),h=u.NONE},this.update=(()=>{const te=new Q,be=new Q(0,1,0),ct=new Ca().setFromUnitVectors(e.up,be),re=ct.clone().invert(),Pe=new Q,ze=new Ca,at=2*Math.PI;return function(){const Ve=i.object.position;ct.setFromUnitVectors(e.up,be),re.copy(ct).invert(),te.copy(Ve).sub(i.target),te.applyQuaternion(ct),g.setFromVector3(te),i.autoRotate&&h===u.NONE&&oe(J()),i.enableDamping?(g.theta+=y.theta*i.dampingFactor,g.phi+=y.phi*i.dampingFactor):(g.theta+=y.theta,g.phi+=y.phi);let nt=i.minAzimuthAngle,It=i.maxAzimuthAngle;isFinite(nt)&&isFinite(It)&&(nt<-Math.PI?nt+=at:nt>Math.PI&&(nt-=at),It<-Math.PI?It+=at:It>Math.PI&&(It-=at),nt<=It?g.theta=Math.max(nt,Math.min(It,g.theta)):g.theta=g.theta>(nt+It)/2?Math.max(nt,g.theta):Math.min(It,g.theta)),g.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,g.phi)),g.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(x,i.dampingFactor):i.target.add(x),i.zoomToCursor&&L||i.object.isOrthographicCamera?g.radius=Se(g.radius):g.radius=Se(g.radius*b),te.setFromSpherical(g),te.applyQuaternion(re),Ve.copy(i.target).add(te),i.object.matrixAutoUpdate||i.object.updateMatrix(),i.object.lookAt(i.target),i.enableDamping===!0?(y.theta*=1-i.dampingFactor,y.phi*=1-i.dampingFactor,x.multiplyScalar(1-i.dampingFactor)):(y.set(0,0,0),x.set(0,0,0));let an=!1;if(i.zoomToCursor&&L){let sn=null;if(i.object instanceof nr&&i.object.isPerspectiveCamera){const Vn=te.length();sn=Se(Vn*b);const _i=Vn-sn;i.object.position.addScaledVector(k,_i),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const Vn=new Q(H.x,H.y,0);Vn.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/b)),i.object.updateProjectionMatrix(),an=!0;const _i=new Q(H.x,H.y,0);_i.unproject(i.object),i.object.position.sub(_i).add(Vn),i.object.updateMatrixWorld(),sn=te.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;sn!==null&&(i.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(sn).add(i.object.position):(Mb.origin.copy(i.object.position),Mb.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(Mb.direction))p||8*(1-ze.dot(i.object.quaternion))>p?(i.dispatchEvent(r),Pe.copy(i.object.position),ze.copy(i.object.quaternion),an=!1,!0):!1}})(),this.connect=te=>{i.domElement=te,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",lt),i.domElement.addEventListener("pointerdown",tt),i.domElement.addEventListener("pointercancel",N),i.domElement.addEventListener("wheel",Te)},this.dispose=()=>{var te,be,ct,re,Pe,ze;i.domElement&&(i.domElement.style.touchAction="auto"),(te=i.domElement)==null||te.removeEventListener("contextmenu",lt),(be=i.domElement)==null||be.removeEventListener("pointerdown",tt),(ct=i.domElement)==null||ct.removeEventListener("pointercancel",N),(re=i.domElement)==null||re.removeEventListener("wheel",Te),(Pe=i.domElement)==null||Pe.ownerDocument.removeEventListener("pointermove",V),(ze=i.domElement)==null||ze.ownerDocument.removeEventListener("pointerup",N),i._domElementKeyEvents!==null&&i._domElementKeyEvents.removeEventListener("keydown",pe)};const i=this,r={type:"change"},s={type:"start"},l={type:"end"},u={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let h=u.NONE;const p=1e-6,g=new EM,y=new EM;let b=1;const x=new Q,E=new Be,A=new Be,T=new Be,M=new Be,R=new Be,O=new Be,D=new Be,F=new Be,U=new Be,k=new Q,H=new Be;let L=!1;const z=[],W={};function J(){return 2*Math.PI/60/60*i.autoRotateSpeed}function $(){return Math.pow(.95,i.zoomSpeed)}function oe(te){i.reverseOrbit||i.reverseHorizontalOrbit?y.theta+=te:y.theta-=te}function ne(te){i.reverseOrbit||i.reverseVerticalOrbit?y.phi+=te:y.phi-=te}const Y=(()=>{const te=new Q;return function(ct,re){te.setFromMatrixColumn(re,0),te.multiplyScalar(-ct),x.add(te)}})(),K=(()=>{const te=new Q;return function(ct,re){i.screenSpacePanning===!0?te.setFromMatrixColumn(re,1):(te.setFromMatrixColumn(re,0),te.crossVectors(i.object.up,te)),te.multiplyScalar(ct),x.add(te)}})(),ie=(()=>{const te=new Q;return function(ct,re){const Pe=i.domElement;if(Pe&&i.object instanceof nr&&i.object.isPerspectiveCamera){const ze=i.object.position;te.copy(ze).sub(i.target);let at=te.length();at*=Math.tan(i.object.fov/2*Math.PI/180),Y(2*ct*at/Pe.clientHeight,i.object.matrix),K(2*re*at/Pe.clientHeight,i.object.matrix)}else Pe&&i.object instanceof qo&&i.object.isOrthographicCamera?(Y(ct*(i.object.right-i.object.left)/i.object.zoom/Pe.clientWidth,i.object.matrix),K(re*(i.object.top-i.object.bottom)/i.object.zoom/Pe.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function ge(te){i.object instanceof nr&&i.object.isPerspectiveCamera||i.object instanceof qo&&i.object.isOrthographicCamera?b=te:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function xe(te){ge(b/te)}function q(te){ge(b*te)}function ce(te){if(!i.zoomToCursor||!i.domElement)return;L=!0;const be=i.domElement.getBoundingClientRect(),ct=te.clientX-be.left,re=te.clientY-be.top,Pe=be.width,ze=be.height;H.x=ct/Pe*2-1,H.y=-(re/ze)*2+1,k.set(H.x,H.y,1).unproject(i.object).sub(i.object.position).normalize()}function Se(te){return Math.max(i.minDistance,Math.min(i.maxDistance,te))}function Ge(te){E.set(te.clientX,te.clientY)}function Ye(te){ce(te),D.set(te.clientX,te.clientY)}function ve(te){M.set(te.clientX,te.clientY)}function Oe(te){A.set(te.clientX,te.clientY),T.subVectors(A,E).multiplyScalar(i.rotateSpeed);const be=i.domElement;be&&(oe(2*Math.PI*T.x/be.clientHeight),ne(2*Math.PI*T.y/be.clientHeight)),E.copy(A),i.update()}function it(te){F.set(te.clientX,te.clientY),U.subVectors(F,D),U.y>0?xe($()):U.y<0&&q($()),D.copy(F),i.update()}function gt(te){R.set(te.clientX,te.clientY),O.subVectors(R,M).multiplyScalar(i.panSpeed),ie(O.x,O.y),M.copy(R),i.update()}function _t(te){ce(te),te.deltaY<0?q($()):te.deltaY>0&&xe($()),i.update()}function jt(te){let be=!1;switch(te.code){case i.keys.UP:ie(0,i.keyPanSpeed),be=!0;break;case i.keys.BOTTOM:ie(0,-i.keyPanSpeed),be=!0;break;case i.keys.LEFT:ie(i.keyPanSpeed,0),be=!0;break;case i.keys.RIGHT:ie(-i.keyPanSpeed,0),be=!0;break}be&&(te.preventDefault(),i.update())}function pt(){if(z.length==1)E.set(z[0].pageX,z[0].pageY);else{const te=.5*(z[0].pageX+z[1].pageX),be=.5*(z[0].pageY+z[1].pageY);E.set(te,be)}}function mt(){if(z.length==1)M.set(z[0].pageX,z[0].pageY);else{const te=.5*(z[0].pageX+z[1].pageX),be=.5*(z[0].pageY+z[1].pageY);M.set(te,be)}}function He(){const te=z[0].pageX-z[1].pageX,be=z[0].pageY-z[1].pageY,ct=Math.sqrt(te*te+be*be);D.set(0,ct)}function Ue(){i.enableZoom&&He(),i.enablePan&&mt()}function Re(){i.enableZoom&&He(),i.enableRotate&&pt()}function ft(te){if(z.length==1)A.set(te.pageX,te.pageY);else{const ct=vt(te),re=.5*(te.pageX+ct.x),Pe=.5*(te.pageY+ct.y);A.set(re,Pe)}T.subVectors(A,E).multiplyScalar(i.rotateSpeed);const be=i.domElement;be&&(oe(2*Math.PI*T.x/be.clientHeight),ne(2*Math.PI*T.y/be.clientHeight)),E.copy(A)}function Z(te){if(z.length==1)R.set(te.pageX,te.pageY);else{const be=vt(te),ct=.5*(te.pageX+be.x),re=.5*(te.pageY+be.y);R.set(ct,re)}O.subVectors(R,M).multiplyScalar(i.panSpeed),ie(O.x,O.y),M.copy(R)}function At(te){const be=vt(te),ct=te.pageX-be.x,re=te.pageY-be.y,Pe=Math.sqrt(ct*ct+re*re);F.set(0,Pe),U.set(0,Math.pow(F.y/D.y,i.zoomSpeed)),xe(U.y),D.copy(F)}function dt(te){i.enableZoom&&At(te),i.enablePan&&Z(te)}function Ct(te){i.enableZoom&&At(te),i.enableRotate&&ft(te)}function tt(te){var be,ct;i.enabled!==!1&&(z.length===0&&((be=i.domElement)==null||be.ownerDocument.addEventListener("pointermove",V),(ct=i.domElement)==null||ct.ownerDocument.addEventListener("pointerup",N)),Lt(te),te.pointerType==="touch"?Et(te):ee(te))}function V(te){i.enabled!==!1&&(te.pointerType==="touch"?$e(te):Ee(te))}function N(te){var be,ct,re;Ze(te),z.length===0&&((be=i.domElement)==null||be.releasePointerCapture(te.pointerId),(ct=i.domElement)==null||ct.ownerDocument.removeEventListener("pointermove",V),(re=i.domElement)==null||re.ownerDocument.removeEventListener("pointerup",N)),i.dispatchEvent(l),h=u.NONE}function ee(te){let be;switch(te.button){case 0:be=i.mouseButtons.LEFT;break;case 1:be=i.mouseButtons.MIDDLE;break;case 2:be=i.mouseButtons.RIGHT;break;default:be=-1}switch(be){case od.DOLLY:if(i.enableZoom===!1)return;Ye(te),h=u.DOLLY;break;case od.ROTATE:if(te.ctrlKey||te.metaKey||te.shiftKey){if(i.enablePan===!1)return;ve(te),h=u.PAN}else{if(i.enableRotate===!1)return;Ge(te),h=u.ROTATE}break;case od.PAN:if(te.ctrlKey||te.metaKey||te.shiftKey){if(i.enableRotate===!1)return;Ge(te),h=u.ROTATE}else{if(i.enablePan===!1)return;ve(te),h=u.PAN}break;default:h=u.NONE}h!==u.NONE&&i.dispatchEvent(s)}function Ee(te){if(i.enabled!==!1)switch(h){case u.ROTATE:if(i.enableRotate===!1)return;Oe(te);break;case u.DOLLY:if(i.enableZoom===!1)return;it(te);break;case u.PAN:if(i.enablePan===!1)return;gt(te);break}}function Te(te){i.enabled===!1||i.enableZoom===!1||h!==u.NONE&&h!==u.ROTATE||(te.preventDefault(),i.dispatchEvent(s),_t(te),i.dispatchEvent(l))}function pe(te){i.enabled===!1||i.enablePan===!1||jt(te)}function Et(te){switch(rt(te),z.length){case 1:switch(i.touches.ONE){case ld.ROTATE:if(i.enableRotate===!1)return;pt(),h=u.TOUCH_ROTATE;break;case ld.PAN:if(i.enablePan===!1)return;mt(),h=u.TOUCH_PAN;break;default:h=u.NONE}break;case 2:switch(i.touches.TWO){case ld.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Ue(),h=u.TOUCH_DOLLY_PAN;break;case ld.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Re(),h=u.TOUCH_DOLLY_ROTATE;break;default:h=u.NONE}break;default:h=u.NONE}h!==u.NONE&&i.dispatchEvent(s)}function $e(te){switch(rt(te),h){case u.TOUCH_ROTATE:if(i.enableRotate===!1)return;ft(te),i.update();break;case u.TOUCH_PAN:if(i.enablePan===!1)return;Z(te),i.update();break;case u.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;dt(te),i.update();break;case u.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Ct(te),i.update();break;default:h=u.NONE}}function lt(te){i.enabled!==!1&&te.preventDefault()}function Lt(te){z.push(te)}function Ze(te){delete W[te.pointerId];for(let be=0;be{q(te),i.update()},this.dollyOut=(te=$())=>{xe(te),i.update()},this.getScale=()=>b,this.setScale=te=>{ge(te),i.update()},this.getZoomScale=()=>$(),t!==void 0&&this.connect(t),this.update()}};function mH(n,e,t){const i=Di(x=>x.size),r=Di(x=>x.viewport),s=typeof n=="number"?n:i.width*r.dpr,l=i.height*r.dpr,u=(typeof n=="number"?t:n)||{},{samples:h=0,depth:p,...g}=u,y=p??u.depthBuffer,b=P.useMemo(()=>{const x=new ai(s,l,{minFilter:Kn,magFilter:Kn,type:vo,...g});return y&&(x.depthTexture=new qu(s,l,xr)),x.samples=h,x},[]);return P.useLayoutEffect(()=>{b.setSize(s,l),h&&(b.samples=h)},[h,b,s,l]),P.useEffect(()=>()=>b.dispose(),[]),b}const gH=n=>typeof n=="function",vH=P.forwardRef(({envMap:n,resolution:e=256,frames:t=1/0,makeDefault:i,children:r,...s},l)=>{const u=Di(({set:T})=>T),h=Di(({camera:T})=>T),p=Di(({size:T})=>T),g=P.useRef(null);P.useImperativeHandle(l,()=>g.current,[]);const y=P.useRef(null),b=mH(e);P.useLayoutEffect(()=>{s.manual||(g.current.aspect=p.width/p.height)},[p,s]),P.useLayoutEffect(()=>{g.current.updateProjectionMatrix()});let x=0,E=null;const A=gH(r);return Wo(T=>{A&&(t===1/0||x{if(i){const T=h;return u(()=>({camera:g.current})),()=>u(()=>({camera:T}))}},[g,i,u]),P.createElement(P.Fragment,null,P.createElement("perspectiveCamera",Nx({ref:g},s),!A&&r),P.createElement("group",{ref:y},A&&r(b.texture)))}),yH=P.forwardRef(({makeDefault:n,camera:e,regress:t,domElement:i,enableDamping:r=!0,keyEvents:s=!1,onChange:l,onStart:u,onEnd:h,...p},g)=>{const y=Di(U=>U.invalidate),b=Di(U=>U.camera),x=Di(U=>U.gl),E=Di(U=>U.events),A=Di(U=>U.setEvents),T=Di(U=>U.set),M=Di(U=>U.get),R=Di(U=>U.performance),O=e||b,D=i||E.connected||x.domElement,F=P.useMemo(()=>new pH(O),[O]);return Wo(()=>{F.enabled&&F.update()},-1),P.useEffect(()=>(s&&F.connect(s===!0?D:s),F.connect(D),()=>{F.dispose()}),[s,D,t,F,y]),P.useEffect(()=>{const U=L=>{y(),t&&R.regress(),l&&l(L)},k=L=>{u&&u(L)},H=L=>{h&&h(L)};return F.addEventListener("change",U),F.addEventListener("start",k),F.addEventListener("end",H),()=>{F.removeEventListener("start",k),F.removeEventListener("end",H),F.removeEventListener("change",U)}},[l,u,h,F,y,A]),P.useEffect(()=>{if(n){const U=M().controls;return T({controls:F}),()=>T({controls:U})}},[n,F]),P.createElement("primitive",Nx({ref:g,object:F,enableDamping:r},p))});var Fb={exports:{}},bH=Fb.exports,wC;function xH(){return wC||(wC=1,(function(n,e){(function(t,i){n.exports=i()})(bH,function(){var t=function(){function i(x){return l.appendChild(x.dom),x}function r(x){for(var E=0;Eh+1e3&&(g.update(1e3*p/(x-h),100),h=x,p=0,b)){var E=performance.memory;b.update(E.usedJSHeapSize/1048576,E.jsHeapSizeLimit/1048576)}return x},update:function(){u=this.end()},domElement:l,setMode:r}};return t.Panel=function(i,r,s){var l=1/0,u=0,h=Math.round,p=h(window.devicePixelRatio||1),g=80*p,y=48*p,b=3*p,x=2*p,E=3*p,A=15*p,T=74*p,M=30*p,R=document.createElement("canvas");R.width=g,R.height=y,R.style.cssText="width:80px;height:48px";var O=R.getContext("2d");return O.font="bold "+9*p+"px Helvetica,Arial,sans-serif",O.textBaseline="top",O.fillStyle=s,O.fillRect(0,0,g,y),O.fillStyle=r,O.fillText(i,b,x),O.fillRect(E,A,T,M),O.fillStyle=s,O.globalAlpha=.9,O.fillRect(E,A,T,M),{dom:R,update:function(D,F){l=Math.min(l,D),u=Math.max(u,D),O.fillStyle=s,O.globalAlpha=1,O.fillRect(0,0,g,A),O.fillStyle=r,O.fillText(h(D)+" "+i+" ("+h(l)+"-"+h(u)+")",b,x),O.drawImage(R,E+p,A,T-p,M,E,A,T-p,M),O.fillRect(E+T-p,A,p,M),O.fillStyle=s,O.globalAlpha=.9,O.fillRect(E+T-p,A,p,h((1-D/F)*M))}}},t})})(Fb)),Fb.exports}var _H=xH();const SH=ef(_H);function MH(n,e=[],t){const[i,r]=P.useState();return P.useLayoutEffect(()=>{const s=n();return r(s),()=>void 0},e),i}function EH({showPanel:n=0,className:e,parent:t}){const i=MH(()=>new SH,[]);return P.useEffect(()=>{if(i){const r=t&&t.current||document.body;i.showPanel(n),r?.appendChild(i.dom);const s=(e??"").split(" ").filter(h=>h);s.length&&i.dom.classList.add(...s);const l=r6(()=>i.begin()),u=a6(()=>i.end());return()=>{s.length&&i.dom.classList.remove(...s),r?.removeChild(i.dom),l(),u()}}},[t,i,e,n]),null}var N1=1/1e3,TH=1e3,wH=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(n){typeof document<"u"&&document.hidden!==void 0&&(n?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=n)}get delta(){return this._delta*N1}get fixedDelta(){return this._fixedDelta*N1}set fixedDelta(n){this._fixedDelta=n*TH}get elapsed(){return this._elapsed*N1}update(n){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(n!==void 0?n:performance.now())-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(n){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},AH=(()=>{const n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]),t=new dn;return t.setAttribute("position",new si(n,3)),t.setAttribute("uv",new si(e,2)),t})(),Za=class zM{static get fullscreenGeometry(){return AH}constructor(e="Pass",t=new Ps,i=new qo){this.name=e,this.renderer=null,this.scene=t,this.camera=i,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){const t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;t!==null?t.material=e:(t=new $n(zM.fullscreenGeometry,e),t.frustumCulled=!1,this.scene===null&&(this.scene=new Ps),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=tf){}render(e,t,i,r,s){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,i){}dispose(){for(const e of Object.keys(this)){const t=this[e];(t instanceof ai||t instanceof jr||t instanceof $i||t instanceof zM)&&this[e].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},CH=class extends Za{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(n,e,t,i,r){const s=n.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},RH=`#ifdef COLOR_WRITE #include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #endif #ifdef DEPTH_WRITE #include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif } #endif #ifdef USE_WEIGHTS uniform vec4 channelWeights; #endif uniform float opacity;varying vec2 vUv;void main(){ #ifdef COLOR_WRITE vec4 texel=texture2D(inputBuffer,vUv); #ifdef USE_WEIGHTS texel*=channelWeights; #endif gl_FragColor=opacity*texel; #ifdef COLOR_SPACE_CONVERSION #include #endif #include #else gl_FragColor=vec4(0.0); #endif #ifdef DEPTH_WRITE gl_FragDepth=readDepth(vUv); #endif }`,rT="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",CO=class extends Ln{constructor(){super({name:"CopyMaterial",defines:{COLOR_SPACE_CONVERSION:"1",DEPTH_PACKING:"0",COLOR_WRITE:"1"},uniforms:{inputBuffer:new Wt(null),depthBuffer:new Wt(null),channelWeights:new Wt(null),opacity:new Wt(1)},blending:$r,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:RH,vertexShader:rT}),this.depthFunc=a0}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(n){const e=n!==null;this.colorWrite!==e&&(e?this.defines.COLOR_WRITE=!0:delete this.defines.COLOR_WRITE,this.colorWrite=e,this.needsUpdate=!0),this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){const e=n!==null;this.depthWrite!==e&&(e?this.defines.DEPTH_WRITE=!0:delete this.defines.DEPTH_WRITE,this.depthTest=e,this.depthWrite=e,this.needsUpdate=!0),this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}get colorSpaceConversion(){return this.defines.COLOR_SPACE_CONVERSION!==void 0}set colorSpaceConversion(n){this.colorSpaceConversion!==n&&(n?this.defines.COLOR_SPACE_CONVERSION=!0:delete this.defines.COLOR_SPACE_CONVERSION,this.needsUpdate=!0)}get channelWeights(){return this.uniforms.channelWeights.value}set channelWeights(n){n!==null?(this.defines.USE_WEIGHTS="1",this.uniforms.channelWeights.value=n):delete this.defines.USE_WEIGHTS,this.needsUpdate=!0}setInputBuffer(n){this.uniforms.inputBuffer.value=n}getOpacity(n){return this.uniforms.opacity.value}setOpacity(n){this.uniforms.opacity.value=n}},RO=class extends Za{constructor(n,e=!0){super("CopyPass"),this.fullscreenMaterial=new CO,this.needsSwap=!1,this.renderTarget=n,n===void 0&&(this.renderTarget=new ai(1,1,{minFilter:Kn,magFilter:Kn,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=e}get resize(){return this.autoResize}set resize(n){this.autoResize=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(n){this.autoResize=n}render(n,e,t,i,r){this.fullscreenMaterial.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){this.autoResize&&this.renderTarget.setSize(n,e)}initialize(n,e,t){t!==void 0&&(this.renderTarget.texture.type=t,t!==fr?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":n!==null&&n.outputColorSpace===Zn&&(this.renderTarget.texture.colorSpace=Zn))}},AC=new Mt,DO=class extends Za{constructor(n=!0,e=!0,t=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=n,this.depth=e,this.stencil=t,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(n,e,t){this.color=n,this.depth=e,this.stencil=t}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(n){this.overrideClearColor=n}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(n){this.overrideClearAlpha=n}render(n,e,t,i,r){const s=this.overrideClearColor,l=this.overrideClearAlpha,u=n.getClearAlpha(),h=s!==null,p=l>=0;h?(n.getClearColor(AC),n.setClearColor(s,p?l:u)):p&&n.setClearAlpha(l),n.setRenderTarget(this.renderToScreen?null:e),n.clear(this.color,this.depth,this.stencil),h?n.setClearColor(AC,u):p&&n.setClearAlpha(u)}},DH=class extends Za{constructor(n,e){super("MaskPass",n,e),this.needsSwap=!1,this.clearPass=new DO(!1,!1,!0),this.inverse=!1}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get inverted(){return this.inverse}set inverted(n){this.inverse=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(n){this.inverted=n}render(n,e,t,i,r){const s=n.getContext(),l=n.state.buffers,u=this.scene,h=this.camera,p=this.clearPass,g=this.inverted?0:1,y=1-g;l.color.setMask(!1),l.depth.setMask(!1),l.color.setLocked(!0),l.depth.setLocked(!0),l.stencil.setTest(!0),l.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),l.stencil.setFunc(s.ALWAYS,g,4294967295),l.stencil.setClear(y),l.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?p.render(n,null):(p.render(n,e),p.render(n,t))),this.renderToScreen?(n.setRenderTarget(null),n.render(u,h)):(n.setRenderTarget(e),n.render(u,h),n.setRenderTarget(t),n.render(u,h)),l.color.setLocked(!1),l.depth.setLocked(!1),l.stencil.setLocked(!1),l.stencil.setFunc(s.EQUAL,1,4294967295),l.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),l.stencil.setLocked(!0)}},OH=class{constructor(n=null,{depthBuffer:e=!0,stencilBuffer:t=!1,multisampling:i=0,frameBufferType:r}={}){this.renderer=null,this.inputBuffer=this.createBuffer(e,t,r,i),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new RO,this.depthTexture=null,this.passes=[],this.timer=new wH,this.autoRenderToScreen=!0,this.setRenderer(n)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(n){const e=this.inputBuffer,t=this.multisampling;t>0&&n>0?(this.inputBuffer.samples=n,this.outputBuffer.samples=n,this.inputBuffer.dispose(),this.outputBuffer.dispose()):t!==n&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,n),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(n){if(this.renderer=n,n!==null){const e=n.getSize(new Be),t=n.getContext().getContextAttributes().alpha,i=this.inputBuffer.texture.type;i===fr&&n.outputColorSpace===Zn&&(this.inputBuffer.texture.colorSpace=Zn,this.outputBuffer.texture.colorSpace=Zn,this.inputBuffer.dispose(),this.outputBuffer.dispose()),n.autoClear=!1,this.setSize(e.width,e.height);for(const r of this.passes)r.initialize(n,t,i)}}replaceRenderer(n,e=!0){const t=this.renderer,i=t.domElement.parentNode;return this.setRenderer(n),e&&i!==null&&(i.removeChild(t.domElement),i.appendChild(n.domElement)),t}createDepthTexture(){const n=this.depthTexture=new qu;return this.inputBuffer.depthTexture=n,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(n.format=Dc,n.type=Sd):n.type=Bs,n}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(const n of this.passes)n.setDepthTexture(null)}}createBuffer(n,e,t,i){const r=this.renderer,s=r===null?new Be:r.getDrawingBufferSize(new Be),l={minFilter:Kn,magFilter:Kn,stencilBuffer:e,depthBuffer:n,type:t},u=new ai(s.width,s.height,l);return i>0&&(u.samples=i),t===fr&&r!==null&&r.outputColorSpace===Zn&&(u.texture.colorSpace=Zn),u.texture.name="EffectComposer.Buffer",u.texture.generateMipmaps=!1,u}setMainScene(n){for(const e of this.passes)e.mainScene=n}setMainCamera(n){for(const e of this.passes)e.mainCamera=n}addPass(n,e){const t=this.passes,i=this.renderer,r=i.getDrawingBufferSize(new Be),s=i.getContext().getContextAttributes().alpha,l=this.inputBuffer.texture.type;if(n.setRenderer(i),n.setSize(r.width,r.height),n.initialize(i,s,l),this.autoRenderToScreen&&(t.length>0&&(t[t.length-1].renderToScreen=!1),n.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?t.splice(e,0,n):t.push(n),this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!0),n.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){const u=this.createDepthTexture();for(n of t)n.setDepthTexture(u)}else n.setDepthTexture(this.depthTexture)}removePass(n){const e=this.passes,t=e.indexOf(n);if(t!==-1&&e.splice(t,1).length>0){if(this.depthTexture!==null){const s=(u,h)=>u||h.needsDepthTexture;e.reduce(s,!1)||(n.getDepthTexture()===this.depthTexture&&n.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&t===e.length&&(n.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){const n=this.passes;this.deleteDepthTexture(),n.length>0&&(this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!1),this.passes=[])}render(n){const e=this.renderer,t=this.copyPass;let i=this.inputBuffer,r=this.outputBuffer,s=!1,l,u,h;n===void 0&&(this.timer.update(),n=this.timer.getDelta());for(const p of this.passes)p.enabled&&(p.render(e,i,r,n,s),p.needsSwap&&(s&&(t.renderToScreen=p.renderToScreen,l=e.getContext(),u=e.state.buffers.stencil,u.setFunc(l.NOTEQUAL,1,4294967295),t.render(e,i,r,n,s),u.setFunc(l.EQUAL,1,4294967295)),h=i,i=r,r=h),p instanceof DH?s=!0:p instanceof CH&&(s=!1))}setSize(n,e,t){const i=this.renderer,r=i.getSize(new Be);(n===void 0||e===void 0)&&(n=r.width,e=r.height),(r.width!==n||r.height!==e)&&i.setSize(n,e,t);const s=i.getDrawingBufferSize(new Be);this.inputBuffer.setSize(s.width,s.height),this.outputBuffer.setSize(s.width,s.height);for(const l of this.passes)l.setSize(s.width,s.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(const n of this.passes)n.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),Za.fullscreenGeometry.dispose()}},Wu={NONE:0,DEPTH:1,CONVOLUTION:2},ti={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},IH=class{constructor(){this.shaderParts=new Map([[ti.FRAGMENT_HEAD,null],[ti.FRAGMENT_MAIN_UV,null],[ti.FRAGMENT_MAIN_IMAGE,null],[ti.VERTEX_HEAD,null],[ti.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=Wu.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=Fl}},U1=!1,CC=class{constructor(n=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(n),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case Bi:t=this.materialsFlatShadedDoubleSide;break;case Lr:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case Bi:t=this.materialsDoubleSide;break;case Lr:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(n){if(!(n instanceof Ln))return n.clone();const e=n.uniforms,t=new Map;for(const r in e){const s=e[r].value;s.isRenderTargetTexture&&(e[r].value=null,t.set(r,s))}const i=n.clone();for(const r of t)e[r[0]].value=r[1],i.uniforms[r[0]].value=r[1];return i}setMaterial(n){if(this.disposeMaterials(),this.material=n,n!==null){const e=this.materials=[this.cloneMaterial(n),this.cloneMaterial(n),this.cloneMaterial(n)];for(const t of e)t.uniforms=Object.assign({},n.uniforms),t.side=Nl;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=Lr,i}),this.materialsDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=Bi,i}),this.materialsFlatShaded=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i}),this.materialsFlatShadedBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=Lr,i}),this.materialsFlatShadedDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=Bi,i})}}render(n,e,t){const i=n.shadowMap.enabled;if(n.shadowMap.enabled=!1,U1){const r=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),n.render(e,t);for(const s of r)s[0].material=s[1];this.meshCount!==r.size&&r.clear()}else{const r=e.overrideMaterial;e.overrideMaterial=this.material,n.render(e,t),e.overrideMaterial=r}n.shadowMap.enabled=i}disposeMaterials(){if(this.material!==null){const n=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(const e of n)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return U1}static set workaroundEnabled(n){U1=n}},Uu=-1,Aa=class extends Hs{constructor(n,e=Uu,t=Uu,i=1){super(),this.resizable=n,this.baseSize=new Be(1,1),this.preferredSize=new Be(e,t),this.target=this.preferredSize,this.s=i,this.effectiveSize=new Be,this.addEventListener("change",()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){const n=this.baseSize,e=this.preferredSize,t=this.effectiveSize,i=this.scale;e.width!==Uu?t.width=e.width:e.height!==Uu?t.width=Math.round(e.height*(n.width/Math.max(n.height,1))):t.width=Math.round(n.width*i),e.height!==Uu?t.height=e.height:e.width!==Uu?t.height=Math.round(e.width/Math.max(n.width/Math.max(n.height,1),1)):t.height=Math.round(n.height*i)}get width(){return this.effectiveSize.width}set width(n){this.preferredWidth=n}get height(){return this.effectiveSize.height}set height(n){this.preferredHeight=n}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(n){this.s!==n&&(this.s=n,this.preferredSize.setScalar(Uu),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(n){this.scale=n}get baseWidth(){return this.baseSize.width}set baseWidth(n){this.baseSize.width!==n&&(this.baseSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(n){this.baseWidth=n}get baseHeight(){return this.baseSize.height}set baseHeight(n){this.baseSize.height!==n&&(this.baseSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(n){this.baseHeight=n}setBaseSize(n,e){(this.baseSize.width!==n||this.baseSize.height!==e)&&(this.baseSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(n){this.preferredSize.width!==n&&(this.preferredSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(n){this.preferredWidth=n}get preferredHeight(){return this.preferredSize.height}set preferredHeight(n){this.preferredSize.height!==n&&(this.preferredSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(n){this.preferredHeight=n}setPreferredSize(n,e){(this.preferredSize.width!==n||this.preferredSize.height!==e)&&(this.preferredSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(n){this.s=n.scale,this.baseSize.set(n.baseWidth,n.baseHeight),this.preferredSize.set(n.preferredWidth,n.preferredHeight),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return Uu}},Rn={SET:30,ADD:0,ALPHA:1,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},PH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",LH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,src.a*opacity);}",NH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=(dst.rgb+src.rgb)*0.5;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",UH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.xy,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",zH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/max(b,1e-9))),vec3(1.0),step(1.0,a));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",FH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",BH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",kH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=abs(dst.rgb-src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",HH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb/max(src.rgb,1e-9);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",VH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-2.0*dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",GH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb,1.0);vec3 b=min(src.rgb,1.0);vec3 c=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",WH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=step(1.0,dst.rgb+src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",XH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.x,a.yz));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",$H="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",jH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=src.rgb*max(1.0-dst.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",qH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",YH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",ZH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb+src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",KH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(2.0*src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",QH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.xy,b.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",JH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",eV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-abs(1.0-dst.rgb-src.rgb),0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",tV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,opacity);}",nV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=2.0*src.rgb*dst.rgb;vec3 b=1.0-2.0*(1.0-src.rgb)*(1.0-dst.rgb);vec3 c=mix(a,b,step(0.5,dst.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",iV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 c=mix(mix(src2,dst.rgb,step(0.5*dst.rgb,src.rgb)),max(src2-1.0,vec3(0.0)),step(dst.rgb,src2-1.0));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",rV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb*dst.rgb/max(1.0-src.rgb,1e-9),1.0);vec3 c=mix(a,src.rgb,step(1.0,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",aV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.x,b.y,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",sV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-min(dst.rgb*src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",oV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 d=dst.rgb+(src2-1.0);vec3 w=step(0.5,src.rgb);vec3 a=dst.rgb-(1.0-src2)*dst.rgb*(1.0-dst.rgb);vec3 b=mix(d*(sqrt(dst.rgb)-dst.rgb),d*dst.rgb*((16.0*dst.rgb-12.0)*dst.rgb+3.0),w*(1.0-step(0.25,dst.rgb)));vec3 c=mix(a,b,w);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",lV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return src;}",cV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",uV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=mix(max(1.0-min((1.0-dst.rgb)/(2.0*src.rgb),1.0),0.0),min(dst.rgb/(2.0*(1.0-src.rgb)),1.0),step(0.5,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",fV=new Map([[Rn.ADD,PH],[Rn.ALPHA,LH],[Rn.AVERAGE,NH],[Rn.COLOR,UH],[Rn.COLOR_BURN,zH],[Rn.COLOR_DODGE,FH],[Rn.DARKEN,BH],[Rn.DIFFERENCE,kH],[Rn.DIVIDE,HH],[Rn.DST,null],[Rn.EXCLUSION,VH],[Rn.HARD_LIGHT,GH],[Rn.HARD_MIX,WH],[Rn.HUE,XH],[Rn.INVERT,$H],[Rn.INVERT_RGB,jH],[Rn.LIGHTEN,qH],[Rn.LINEAR_BURN,YH],[Rn.LINEAR_DODGE,ZH],[Rn.LINEAR_LIGHT,KH],[Rn.LUMINOSITY,QH],[Rn.MULTIPLY,JH],[Rn.NEGATION,eV],[Rn.NORMAL,tV],[Rn.OVERLAY,nV],[Rn.PIN_LIGHT,iV],[Rn.REFLECT,rV],[Rn.SATURATION,aV],[Rn.SCREEN,sV],[Rn.SOFT_LIGHT,oV],[Rn.SRC,lV],[Rn.SUBTRACT,cV],[Rn.VIVID_LIGHT,uV]]),dV=class extends Hs{constructor(n,e=1){super(),this._blendFunction=n,this.opacity=new Wt(e)}getOpacity(){return this.opacity.value}setOpacity(n){this.opacity.value=n}get blendFunction(){return this._blendFunction}set blendFunction(n){this._blendFunction=n,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(n){this.blendFunction=n}getShaderCode(){return fV.get(this.blendFunction)}},Yu=class extends Hs{constructor(n,e,{attributes:t=Wu.NONE,blendFunction:i=Rn.NORMAL,defines:r=new Map,uniforms:s=new Map,extensions:l=null,vertexShader:u=null}={}){super(),this.name=n,this.renderer=null,this.attributes=t,this.fragmentShader=e,this.vertexShader=u,this.defines=r,this.uniforms=s,this.extensions=l,this.blendMode=new dV(i),this.blendMode.addEventListener("change",h=>this.setChanged()),this._inputColorSpace=Fl,this._outputColorSpace=Xo}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(n){this._inputColorSpace=n,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n,this.setChanged()}set mainScene(n){}set mainCamera(n){}getName(){return this.name}setRenderer(n){this.renderer=n}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(n){this.attributes=n,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(n){this.fragmentShader=n,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(n){this.vertexShader=n,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(n,e=tf){}update(n,e,t){}setSize(n,e){}initialize(n,e,t){}dispose(){for(const n of Object.keys(this)){const e=this[n];(e instanceof ai||e instanceof jr||e instanceof $i||e instanceof Za)&&this[n].dispose()}}},aT={MEDIUM:2,LARGE:3},hV=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; #include }`,pV="uniform vec4 texelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize.xy*vec2(kernel)+texelSize.zw)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",mV=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],gV=class extends Ln{constructor(n=new fi){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new Wt(null),texelSize:new Wt(new fi),scale:new Wt(1),kernel:new Wt(0)},blending:$r,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:hV,vertexShader:pV}),this.setTexelSize(n.x,n.y),this.kernelSize=aT.MEDIUM}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.inputBuffer=n}get kernelSequence(){return mV[this.kernelSize]}get scale(){return this.uniforms.scale.value}set scale(n){this.uniforms.scale.value=n}getScale(){return this.uniforms.scale.value}setScale(n){this.uniforms.scale.value=n}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(n){this.uniforms.kernel.value=n}setKernel(n){this.kernel=n}setTexelSize(n,e){this.uniforms.texelSize.value.set(n,e,n*.5,e*.5)}setSize(n,e){const t=1/n,i=1/e;this.uniforms.texelSize.value.set(t,i,t*.5,i*.5)}},vV=class extends Za{constructor({kernelSize:n=aT.MEDIUM,resolutionScale:e=.5,width:t=Aa.AUTO_SIZE,height:i=Aa.AUTO_SIZE,resolutionX:r=t,resolutionY:s=i}={}){super("KawaseBlurPass"),this.renderTargetA=new ai(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";const l=this.resolution=new Aa(this,r,s,e);l.addEventListener("change",u=>this.setSize(l.baseWidth,l.baseHeight)),this._blurMaterial=new gV,this._blurMaterial.kernelSize=n,this.copyMaterial=new CO}getResolution(){return this.resolution}get blurMaterial(){return this._blurMaterial}set blurMaterial(n){this._blurMaterial=n}get dithering(){return this.copyMaterial.dithering}set dithering(n){this.copyMaterial.dithering=n}get kernelSize(){return this.blurMaterial.kernelSize}set kernelSize(n){this.blurMaterial.kernelSize=n}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get scale(){return this.blurMaterial.scale}set scale(n){this.blurMaterial.scale=n}getScale(){return this.blurMaterial.scale}setScale(n){this.blurMaterial.scale=n}getKernelSize(){return this.kernelSize}setKernelSize(n){this.kernelSize=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,r){const s=this.scene,l=this.camera,u=this.renderTargetA,h=this.renderTargetB,p=this.blurMaterial,g=p.kernelSequence;let y=e;this.fullscreenMaterial=p;for(let b=0,x=g.length;b #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef RANGE uniform vec2 range; #elif defined(THRESHOLD) uniform float threshold;uniform float smoothing; #endif varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);float mask=1.0; #ifdef RANGE float low=step(range.x,l);float high=step(l,range.y);mask=low*high; #elif defined(THRESHOLD) mask=smoothstep(threshold,threshold+smoothing,l); #endif #ifdef COLOR gl_FragColor=texel*mask; #else gl_FragColor=vec4(l*mask); #endif }`,bV=class extends Ln{constructor(n=!1,e=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:Rd.replace(/\D+/g,"")},uniforms:{inputBuffer:new Wt(null),threshold:new Wt(0),smoothing:new Wt(1),range:new Wt(null)},blending:$r,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:yV,vertexShader:rT}),this.colorOutput=n,this.luminanceRange=e}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get threshold(){return this.uniforms.threshold.value}set threshold(n){this.smoothing>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=n}getThreshold(){return this.threshold}setThreshold(n){this.threshold=n}get smoothing(){return this.uniforms.smoothing.value}set smoothing(n){this.threshold>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=n}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(n){this.smoothing=n}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(n){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(n){n?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(n){return this.colorOutput}setColorOutputEnabled(n){this.colorOutput=n}get useRange(){return this.luminanceRange!==null}set useRange(n){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(n){n!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=n,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(n){this.luminanceRange=n}},OO=class extends Za{constructor({renderTarget:n,luminanceRange:e,colorOutput:t,resolutionScale:i=1,width:r=Aa.AUTO_SIZE,height:s=Aa.AUTO_SIZE,resolutionX:l=r,resolutionY:u=s}={}){super("LuminancePass"),this.fullscreenMaterial=new bV(t,e),this.needsSwap=!1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new ai(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");const h=this.resolution=new Aa(this,l,u,i);h.addEventListener("change",p=>this.setSize(h.baseWidth,h.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(n,e,t,i,r){const s=this.fullscreenMaterial;s.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}initialize(n,e,t){t!==void 0&&t!==fr&&(this.renderTarget.texture.type=t,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},xV=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #define WEIGHT_INNER 0.125 #define WEIGHT_OUTER 0.0555555 varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;float clampToBorder(const in vec2 uv){return float(uv.s>=0.0&&uv.s<=1.0&&uv.t>=0.0&&uv.t<=1.0);}void main(){vec4 c=vec4(0.0);vec4 w=WEIGHT_INNER*vec4(clampToBorder(vUv00),clampToBorder(vUv01),clampToBorder(vUv02),clampToBorder(vUv03));c+=w.x*texture2D(inputBuffer,vUv00);c+=w.y*texture2D(inputBuffer,vUv01);c+=w.z*texture2D(inputBuffer,vUv02);c+=w.w*texture2D(inputBuffer,vUv03);w=WEIGHT_OUTER*vec4(clampToBorder(vUv04),clampToBorder(vUv05),clampToBorder(vUv06),clampToBorder(vUv07));c+=w.x*texture2D(inputBuffer,vUv04);c+=w.y*texture2D(inputBuffer,vUv05);c+=w.z*texture2D(inputBuffer,vUv06);c+=w.w*texture2D(inputBuffer,vUv07);w=WEIGHT_OUTER*vec4(clampToBorder(vUv08),clampToBorder(vUv09),clampToBorder(vUv10),clampToBorder(vUv11));c+=w.x*texture2D(inputBuffer,vUv08);c+=w.y*texture2D(inputBuffer,vUv09);c+=w.z*texture2D(inputBuffer,vUv10);c+=w.w*texture2D(inputBuffer,vUv11);c+=WEIGHT_OUTER*texture2D(inputBuffer,vUv);gl_FragColor=c; #include }`,_V="uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;void main(){vUv=position.xy*0.5+0.5;vUv00=vUv+texelSize*vec2(-1.0,1.0);vUv01=vUv+texelSize*vec2(1.0,1.0);vUv02=vUv+texelSize*vec2(-1.0,-1.0);vUv03=vUv+texelSize*vec2(1.0,-1.0);vUv04=vUv+texelSize*vec2(-2.0,2.0);vUv05=vUv+texelSize*vec2(0.0,2.0);vUv06=vUv+texelSize*vec2(2.0,2.0);vUv07=vUv+texelSize*vec2(-2.0,0.0);vUv08=vUv+texelSize*vec2(2.0,0.0);vUv09=vUv+texelSize*vec2(-2.0,-2.0);vUv10=vUv+texelSize*vec2(0.0,-2.0);vUv11=vUv+texelSize*vec2(2.0,-2.0);gl_Position=vec4(position.xy,1.0,1.0);}",SV=class extends Ln{constructor(){super({name:"DownsamplingMaterial",uniforms:{inputBuffer:new Wt(null),texelSize:new Wt(new Be)},blending:$r,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:xV,vertexShader:_V})}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},MV=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer;uniform mediump sampler2D supportBuffer; #else uniform lowp sampler2D inputBuffer;uniform lowp sampler2D supportBuffer; #endif uniform float radius;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vec4 c=vec4(0.0);c+=texture2D(inputBuffer,vUv0)*0.0625;c+=texture2D(inputBuffer,vUv1)*0.125;c+=texture2D(inputBuffer,vUv2)*0.0625;c+=texture2D(inputBuffer,vUv3)*0.125;c+=texture2D(inputBuffer,vUv)*0.25;c+=texture2D(inputBuffer,vUv4)*0.125;c+=texture2D(inputBuffer,vUv5)*0.0625;c+=texture2D(inputBuffer,vUv6)*0.125;c+=texture2D(inputBuffer,vUv7)*0.0625;vec4 baseColor=texture2D(supportBuffer,vUv);gl_FragColor=mix(baseColor,c,radius); #include }`,EV="uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,1.0);vUv1=vUv+texelSize*vec2(0.0,1.0);vUv2=vUv+texelSize*vec2(1.0,1.0);vUv3=vUv+texelSize*vec2(-1.0,0.0);vUv4=vUv+texelSize*vec2(1.0,0.0);vUv5=vUv+texelSize*vec2(-1.0,-1.0);vUv6=vUv+texelSize*vec2(0.0,-1.0);vUv7=vUv+texelSize*vec2(1.0,-1.0);gl_Position=vec4(position.xy,1.0,1.0);}",TV=class extends Ln{constructor(){super({name:"UpsamplingMaterial",uniforms:{inputBuffer:new Wt(null),supportBuffer:new Wt(null),texelSize:new Wt(new Be),radius:new Wt(.85)},blending:$r,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:MV,vertexShader:EV})}set inputBuffer(n){this.uniforms.inputBuffer.value=n}set supportBuffer(n){this.uniforms.supportBuffer.value=n}get radius(){return this.uniforms.radius.value}set radius(n){this.uniforms.radius.value=n}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},wV=class extends Za{constructor(){super("MipmapBlurPass"),this.needsSwap=!1,this.renderTarget=new ai(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="Upsampling.Mipmap0",this.downsamplingMipmaps=[],this.upsamplingMipmaps=[],this.downsamplingMaterial=new SV,this.upsamplingMaterial=new TV,this.resolution=new Be}get texture(){return this.renderTarget.texture}get levels(){return this.downsamplingMipmaps.length}set levels(n){if(this.levels!==n){const e=this.renderTarget;this.dispose(),this.downsamplingMipmaps=[],this.upsamplingMipmaps=[];for(let t=0;t=0;--b){const x=g[b];h.setSize(y.width,y.height),h.inputBuffer=y.texture,h.supportBuffer=p[b].texture,n.setRenderTarget(x),n.render(s,l),y=x}}setSize(n,e){const t=this.resolution;t.set(n,e);let i=t.width,r=t.height;for(let s=0,l=this.downsamplingMipmaps.length;sthis.setSize(x.baseWidth,x.baseHeight))}get texture(){return this.mipmapBlurPass.enabled?this.mipmapBlurPass.texture:this.renderTarget.texture}getTexture(){return this.texture}getResolution(){return this.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get dithering(){return this.blurPass.dithering}set dithering(n){this.blurPass.dithering=n}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(n){this.blurPass.kernelSize=n}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(n){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(n){this.uniforms.get("intensity").value=n}getIntensity(){return this.intensity}setIntensity(n){this.intensity=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}update(n,e,t){const i=this.renderTarget,r=this.luminancePass;r.enabled?(r.render(n,e),this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(n,r.renderTarget):this.blurPass.render(n,r.renderTarget,i)):this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(n,e):this.blurPass.render(n,e,i)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.blurPass.resolution.copy(t),this.luminancePass.setSize(n,e),this.mipmapBlurPass.setSize(n,e)}initialize(n,e,t){this.blurPass.initialize(n,e,t),this.luminancePass.initialize(n,e,t),this.mipmapBlurPass.initialize(n,e,t),t!==void 0&&(this.renderTarget.texture.type=t,n!==null&&n.outputColorSpace===Zn&&(this.renderTarget.texture.colorSpace=Zn))}},RV=`#ifdef RADIAL_MODULATION uniform float modulationOffset; #endif varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=inputColor.ra;vec2 ba=inputColor.ba; #ifdef RADIAL_MODULATION const vec2 center=vec2(0.5);float d=distance(uv,center)*2.0;d=max(d-modulationOffset,0.0);if(vActive>0.0&&d>0.0){ra=texture2D(inputBuffer,mix(uv,vUvR,d)).ra;ba=texture2D(inputBuffer,mix(uv,vUvB,d)).ba;} #else if(vActive>0.0){ra=texture2D(inputBuffer,vUvR).ra;ba=texture2D(inputBuffer,vUvB).ba;} #endif outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}`,DV="uniform vec2 offset;varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vActive=(shift.x!=0.0||shift.y!=0.0)?1.0:0.0;vUvR=uv+shift;vUvB=uv-shift;}",OV=class extends Yu{constructor({offset:n=new Be(.001,5e-4),radialModulation:e=!1,modulationOffset:t=.15}={}){super("ChromaticAberrationEffect",RV,{vertexShader:DV,attributes:Wu.CONVOLUTION,uniforms:new Map([["offset",new Wt(n)],["modulationOffset",new Wt(t)]])}),this.radialModulation=e}get offset(){return this.uniforms.get("offset").value}set offset(n){this.uniforms.get("offset").value=n}get radialModulation(){return this.defines.has("RADIAL_MODULATION")}set radialModulation(n){n?this.defines.set("RADIAL_MODULATION","1"):this.defines.delete("RADIAL_MODULATION"),this.setChanged()}get modulationOffset(){return this.uniforms.get("modulationOffset").value}set modulationOffset(n){this.uniforms.get("modulationOffset").value=n}getOffset(){return this.offset}setOffset(n){this.offset=n}},IO=class extends Za{constructor(n,e,t=null){super("RenderPass",n,e),this.needsSwap=!1,this.clearPass=new DO,this.overrideMaterialManager=t===null?null:new CC(t),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get renderToScreen(){return super.renderToScreen}set renderToScreen(n){super.renderToScreen=n,this.clearPass.renderToScreen=n}get overrideMaterial(){const n=this.overrideMaterialManager;return n!==null?n.material:null}set overrideMaterial(n){const e=this.overrideMaterialManager;n!==null?e!==null?e.setMaterial(n):this.overrideMaterialManager=new CC(n):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(n){this.overrideMaterial=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getSelection(){return this.selection}setSelection(n){this.selection=n}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(n){this.ignoreBackground=n}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(n){this.skipShadowMapUpdate=n}getClearPass(){return this.clearPass}render(n,e,t,i,r){const s=this.scene,l=this.camera,u=this.selection,h=l.layers.mask,p=s.background,g=n.shadowMap.autoUpdate,y=this.renderToScreen?null:e;u!==null&&l.layers.set(u.getLayer()),this.skipShadowMapUpdate&&(n.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(n,e),n.setRenderTarget(y),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(n,s,l):n.render(s,l),l.layers.mask=h,s.background=p,n.shadowMap.autoUpdate=g}},Xa={LINEAR:0,REINHARD:1,REINHARD2:2,REINHARD2_ADAPTIVE:3,UNCHARTED2:4,OPTIMIZED_CINEON:5,CINEON:5,ACES_FILMIC:6,AGX:7,NEUTRAL:8},Pg={DEFAULT:0,ESKIL:1},IV=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*(1.0+time))); #ifdef PREMULTIPLY outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a); #else outputColor=vec4(noise,inputColor.a); #endif }`,PV=class extends Yu{constructor({blendFunction:n=Rn.SCREEN,premultiply:e=!1}={}){super("NoiseEffect",IV,{blendFunction:n}),this.premultiply=e}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(n){this.premultiply!==n&&(n?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(n){this.premultiply=n}},LV=`#include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif #ifdef DOWNSAMPLE_NORMALS uniform lowp sampler2D normalBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]this.setSize(u.baseWidth,u.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(n,e=tf){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e}render(n,e,t,i,r){n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.fullscreenMaterial.setSize(n,e)}initialize(n,e,t){const i=n.getContext();if(!(i.getExtension("EXT_color_buffer_float")||i.getExtension("EXT_color_buffer_half_float")))throw new Error("Rendering to float texture is not supported.")}},FV=`#include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) uniform lowp sampler2D luminanceBuffer0;uniform lowp sampler2D luminanceBuffer1;uniform float minLuminance;uniform float deltaTime;uniform float tau;varying vec2 vUv;void main(){float l0=unpackRGBAToFloat(texture2D(luminanceBuffer0,vUv)); #if __VERSION__ < 300 float l1=texture2DLodEXT(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r; #else float l1=textureLod(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r; #endif l0=max(minLuminance,l0);l1=max(minLuminance,l1);float adaptedLum=l0+(l1-l0)*(1.0-exp(-deltaTime*tau));gl_FragColor=(adaptedLum==1.0)?vec4(1.0):packFloatToRGBA(adaptedLum);}`,BV=class extends Ln{constructor(){super({name:"AdaptiveLuminanceMaterial",defines:{MIP_LEVEL_1X1:"0.0"},uniforms:{luminanceBuffer0:new Wt(null),luminanceBuffer1:new Wt(null),minLuminance:new Wt(.01),deltaTime:new Wt(0),tau:new Wt(1)},extensions:{shaderTextureLOD:!0},blending:$r,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:FV,vertexShader:rT})}set luminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}setLuminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}set luminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}setLuminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}set mipLevel1x1(n){this.defines.MIP_LEVEL_1X1=n.toFixed(1),this.needsUpdate=!0}setMipLevel1x1(n){this.mipLevel1x1=n}set deltaTime(n){this.uniforms.deltaTime.value=n}setDeltaTime(n){this.uniforms.deltaTime.value=n}get minLuminance(){return this.uniforms.minLuminance.value}set minLuminance(n){this.uniforms.minLuminance.value=n}getMinLuminance(){return this.uniforms.minLuminance.value}setMinLuminance(n){this.uniforms.minLuminance.value=n}get adaptationRate(){return this.uniforms.tau.value}set adaptationRate(n){this.uniforms.tau.value=n}getAdaptationRate(){return this.uniforms.tau.value}setAdaptationRate(n){this.uniforms.tau.value=n}},kV=class extends Za{constructor(n,{minLuminance:e=.01,adaptationRate:t=1}={}){super("AdaptiveLuminancePass"),this.fullscreenMaterial=new BV,this.needsSwap=!1,this.renderTargetPrevious=new ai(1,1,{minFilter:jn,magFilter:jn,depthBuffer:!1}),this.renderTargetPrevious.texture.name="Luminance.Previous";const i=this.fullscreenMaterial;i.luminanceBuffer0=this.renderTargetPrevious.texture,i.luminanceBuffer1=n,i.minLuminance=e,i.adaptationRate=t,this.renderTargetAdapted=this.renderTargetPrevious.clone(),this.renderTargetAdapted.texture.name="Luminance.Adapted",this.copyPass=new RO(this.renderTargetPrevious,!1)}get texture(){return this.renderTargetAdapted.texture}getTexture(){return this.renderTargetAdapted.texture}set mipLevel1x1(n){this.fullscreenMaterial.mipLevel1x1=n}get adaptationRate(){return this.fullscreenMaterial.adaptationRate}set adaptationRate(n){this.fullscreenMaterial.adaptationRate=n}render(n,e,t,i,r){this.fullscreenMaterial.deltaTime=i,n.setRenderTarget(this.renderToScreen?null:this.renderTargetAdapted),n.render(this.scene,this.camera),this.copyPass.render(n,this.renderTargetAdapted)}},HV=`#include uniform float whitePoint; #if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3 uniform float middleGrey; #if TONE_MAPPING_MODE == 3 uniform lowp sampler2D luminanceBuffer; #else uniform float averageLuminance; #endif vec3 Reinhard2ToneMapping(vec3 color){color*=toneMappingExposure;float l=luminance(color); #if TONE_MAPPING_MODE == 3 float lumAvg=unpackRGBAToFloat(texture2D(luminanceBuffer,vec2(0.5))); #else float lumAvg=averageLuminance; #endif float lumScaled=(l*middleGrey)/max(lumAvg,1e-6);float lumCompressed=lumScaled*(1.0+lumScaled/(whitePoint*whitePoint));lumCompressed/=(1.0+lumScaled);return clamp(lumCompressed*color,0.0,1.0);} #elif TONE_MAPPING_MODE == 4 #define A 0.15 #define B 0.50 #define C 0.10 #define D 0.20 #define E 0.02 #define F 0.30 vec3 Uncharted2Helper(const in vec3 x){return((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}vec3 Uncharted2ToneMapping(vec3 color){color*=toneMappingExposure;return clamp(Uncharted2Helper(color)/Uncharted2Helper(vec3(whitePoint)),0.0,1.0);} #endif void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){ #if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3 outputColor=vec4(Reinhard2ToneMapping(inputColor.rgb),inputColor.a); #elif TONE_MAPPING_MODE == 4 outputColor=vec4(Uncharted2ToneMapping(inputColor.rgb),inputColor.a); #else outputColor=vec4(toneMapping(inputColor.rgb),inputColor.a); #endif }`,VV=class extends Yu{constructor({blendFunction:n=Rn.SRC,adaptive:e=!1,mode:t=e?Xa.REINHARD2_ADAPTIVE:Xa.AGX,resolution:i=256,maxLuminance:r=4,whitePoint:s=r,middleGrey:l=.6,minLuminance:u=.01,averageLuminance:h=1,adaptationRate:p=1}={}){super("ToneMappingEffect",HV,{blendFunction:n,uniforms:new Map([["luminanceBuffer",new Wt(null)],["maxLuminance",new Wt(r)],["whitePoint",new Wt(s)],["middleGrey",new Wt(l)],["averageLuminance",new Wt(h)]])}),this.renderTargetLuminance=new ai(1,1,{minFilter:$o,depthBuffer:!1}),this.renderTargetLuminance.texture.generateMipmaps=!0,this.renderTargetLuminance.texture.name="Luminance",this.luminancePass=new OO({renderTarget:this.renderTargetLuminance}),this.adaptiveLuminancePass=new kV(this.luminancePass.texture,{minLuminance:u,adaptationRate:p}),this.uniforms.get("luminanceBuffer").value=this.adaptiveLuminancePass.texture,this.resolution=i,this.mode=t}get mode(){return Number(this.defines.get("TONE_MAPPING_MODE"))}set mode(n){if(this.mode===n)return;const t=Rd.replace(/\D+/g,"")>=168?"CineonToneMapping(texel)":"OptimizedCineonToneMapping(texel)";switch(this.defines.clear(),this.defines.set("TONE_MAPPING_MODE",n.toFixed(0)),n){case Xa.LINEAR:this.defines.set("toneMapping(texel)","LinearToneMapping(texel)");break;case Xa.REINHARD:this.defines.set("toneMapping(texel)","ReinhardToneMapping(texel)");break;case Xa.CINEON:case Xa.OPTIMIZED_CINEON:this.defines.set("toneMapping(texel)",t);break;case Xa.ACES_FILMIC:this.defines.set("toneMapping(texel)","ACESFilmicToneMapping(texel)");break;case Xa.AGX:this.defines.set("toneMapping(texel)","AgXToneMapping(texel)");break;case Xa.NEUTRAL:this.defines.set("toneMapping(texel)","NeutralToneMapping(texel)");break;default:this.defines.set("toneMapping(texel)","texel");break}this.adaptiveLuminancePass.enabled=n===Xa.REINHARD2_ADAPTIVE,this.setChanged()}getMode(){return this.mode}setMode(n){this.mode=n}get whitePoint(){return this.uniforms.get("whitePoint").value}set whitePoint(n){this.uniforms.get("whitePoint").value=n}get middleGrey(){return this.uniforms.get("middleGrey").value}set middleGrey(n){this.uniforms.get("middleGrey").value=n}get averageLuminance(){return this.uniforms.get("averageLuminance").value}set averageLuminance(n){this.uniforms.get("averageLuminance").value=n}get adaptiveLuminanceMaterial(){return this.adaptiveLuminancePass.fullscreenMaterial}getAdaptiveLuminanceMaterial(){return this.adaptiveLuminanceMaterial}get resolution(){return this.luminancePass.resolution.width}set resolution(n){const e=Math.max(0,Math.ceil(Math.log2(n))),t=Math.pow(2,e);this.luminancePass.resolution.setPreferredSize(t,t),this.adaptiveLuminanceMaterial.mipLevel1x1=e}getResolution(){return this.resolution}setResolution(n){this.resolution=n}get adaptive(){return this.mode===Xa.REINHARD2_ADAPTIVE}set adaptive(n){this.mode=n?Xa.REINHARD2_ADAPTIVE:Xa.REINHARD2}get adaptationRate(){return this.adaptiveLuminanceMaterial.adaptationRate}set adaptationRate(n){this.adaptiveLuminanceMaterial.adaptationRate=n}get distinction(){return console.warn(this.name,"distinction was removed."),1}set distinction(n){console.warn(this.name,"distinction was removed.")}update(n,e,t){this.adaptiveLuminancePass.enabled&&(this.luminancePass.render(n,e),this.adaptiveLuminancePass.render(n,null,null,t))}initialize(n,e,t){this.adaptiveLuminancePass.initialize(n,e,t)}},GV=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; #if VIGNETTE_TECHNIQUE == 0 float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); #else vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); #endif outputColor=vec4(color,inputColor.a);}`,WV=class extends Yu{constructor({blendFunction:n,eskil:e=!1,technique:t=e?Pg.ESKIL:Pg.DEFAULT,offset:i=.5,darkness:r=.5}={}){super("VignetteEffect",GV,{blendFunction:n,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new Wt(i)],["darkness",new Wt(r)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(n){this.technique!==n&&(this.defines.set("VIGNETTE_TECHNIQUE",n.toFixed(0)),this.setChanged())}get eskil(){return this.technique===Pg.ESKIL}set eskil(n){this.technique=n?Pg.ESKIL:Pg.DEFAULT}getTechnique(){return this.technique}setTechnique(n){this.technique=n}get offset(){return this.uniforms.get("offset").value}set offset(n){this.uniforms.get("offset").value=n}getOffset(){return this.offset}setOffset(n){this.offset=n}get darkness(){return this.uniforms.get("darkness").value}set darkness(n){this.uniforms.get("darkness").value=n}getDarkness(){return this.darkness}setDarkness(n){this.darkness=n}},XV=`#include #include #include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #if DEPTH_PACKING == 3201 uniform lowp sampler2D depthBuffer; #elif defined(GL_FRAGMENT_PRECISION_HIGH) uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else float depth=texture2D(depthBuffer,uv).r; #endif #if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH) float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d; #elif defined(USE_REVERSED_DEPTH_BUFFER) depth=1.0-depth; #endif return depth;}float getViewZ(const in float depth){ #ifdef PERSPECTIVE_CAMERA return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); #else return orthographicDepthToViewZ(depth,cameraNear,cameraFar); #endif }vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0; #ifdef ENCODE_OUTPUT #include #endif #include }`,$V="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}",jV=class extends Ln{constructor(n,e,t,i,r=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:Rd.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new Wt(null),depthBuffer:new Wt(null),resolution:new Wt(new Be),texelSize:new Wt(new Be),cameraNear:new Wt(.3),cameraFar:new Wt(1e3),aspect:new Wt(1),time:new Wt(0)},blending:$r,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:r}),n&&this.setShaderParts(n),e&&this.setDefines(e),t&&this.setUniforms(t),this.copyCameraSettings(i)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){this.uniforms.depthBuffer.value=n}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=tf){this.depthBuffer=n,this.depthPacking=e}setShaderData(n){this.setShaderParts(n.shaderParts),this.setDefines(n.defines),this.setUniforms(n.uniforms),this.setExtensions(n.extensions)}setShaderParts(n){return this.fragmentShader=XV.replace(ti.FRAGMENT_HEAD,n.get(ti.FRAGMENT_HEAD)||"").replace(ti.FRAGMENT_MAIN_UV,n.get(ti.FRAGMENT_MAIN_UV)||"").replace(ti.FRAGMENT_MAIN_IMAGE,n.get(ti.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=$V.replace(ti.VERTEX_HEAD,n.get(ti.VERTEX_HEAD)||"").replace(ti.VERTEX_MAIN_SUPPORT,n.get(ti.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(n){for(const e of n.entries())this.defines[e[0]]=e[1];return this.needsUpdate=!0,this}setUniforms(n){for(const e of n.entries())this.uniforms[e[0]]=e[1];return this}setExtensions(n){this.extensions={};for(const e of n)this.extensions[e]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(n){this.encodeOutput!==n&&(n?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(n){return this.encodeOutput}setOutputEncodingEnabled(n){this.encodeOutput=n}get time(){return this.uniforms.time.value}set time(n){this.uniforms.time.value=n}setDeltaTime(n){this.uniforms.time.value+=n}adoptCameraSettings(n){this.copyCameraSettings(n)}copyCameraSettings(n){n&&(this.uniforms.cameraNear.value=n.near,this.uniforms.cameraFar.value=n.far,n instanceof nr?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(n,e){const t=this.uniforms;t.resolution.value.set(n,e),t.texelSize.value.set(1/n,1/e),t.aspect.value=n/e}static get Section(){return ti}};function RC(n,e,t){for(const i of e){const r="$1"+n+i.charAt(0).toUpperCase()+i.slice(1),s=new RegExp("([^\\.])(\\b"+i+"\\b)","g");for(const l of t.entries())l[1]!==null&&t.set(l[0],l[1].replace(s,r))}}function qV(n,e,t){let i=e.getFragmentShader(),r=e.getVertexShader();const s=i!==void 0&&/mainImage/.test(i),l=i!==void 0&&/mainUv/.test(i);if(t.attributes|=e.getAttributes(),i===void 0)throw new Error(`Missing fragment shader (${e.name})`);if(l&&(t.attributes&Wu.CONVOLUTION)!==0)throw new Error(`Effects that transform UVs are incompatible with convolution effects (${e.name})`);if(!s&&!l)throw new Error(`Could not find mainImage or mainUv function (${e.name})`);{const u=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,h=t.shaderParts;let p=h.get(ti.FRAGMENT_HEAD)||"",g=h.get(ti.FRAGMENT_MAIN_UV)||"",y=h.get(ti.FRAGMENT_MAIN_IMAGE)||"",b=h.get(ti.VERTEX_HEAD)||"",x=h.get(ti.VERTEX_MAIN_SUPPORT)||"";const E=new Set,A=new Set;if(l&&(g+=` ${n}MainUv(UV); `,t.uvTransformation=!0),r!==null&&/mainSupport/.test(r)){const R=/mainSupport *\([\w\s]*?uv\s*?\)/.test(r);x+=` ${n}MainSupport(`,x+=R?`vUv); `:`); `;for(const O of r.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(const D of O[1].split(/\s*,\s*/))t.varyings.add(D),E.add(D),A.add(D);for(const O of r.matchAll(u))A.add(O[1])}for(const R of i.matchAll(u))A.add(R[1]);for(const R of e.defines.keys())A.add(R.replace(/\([\w\s,]*\)/g,""));for(const R of e.uniforms.keys())A.add(R);A.delete("while"),A.delete("for"),A.delete("if"),e.uniforms.forEach((R,O)=>t.uniforms.set(n+O.charAt(0).toUpperCase()+O.slice(1),R)),e.defines.forEach((R,O)=>t.defines.set(n+O.charAt(0).toUpperCase()+O.slice(1),R));const T=new Map([["fragment",i],["vertex",r]]);RC(n,A,t.defines),RC(n,A,T),i=T.get("fragment"),r=T.get("vertex");const M=e.blendMode;if(t.blendModes.set(M.blendFunction,M),s){e.inputColorSpace!==null&&e.inputColorSpace!==t.colorSpace&&(y+=e.inputColorSpace===Zn?`color0 = sRGBTransferOETF(color0); `:`color0 = sRGBToLinear(color0); `),e.outputColorSpace!==Xo?t.colorSpace=e.outputColorSpace:e.inputColorSpace!==null&&(t.colorSpace=e.inputColorSpace);const R=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;y+=`${n}MainImage(color0, UV, `,(t.attributes&Wu.DEPTH)!==0&&R.test(i)&&(y+="depth, ",t.readDepth=!0),y+=`color1); `;const O=n+"BlendOpacity";t.uniforms.set(O,M.opacity),y+=`color0 = blend${M.blendFunction}(color0, color1, ${O}); `,p+=`uniform float ${O}; `}if(p+=i+` `,r!==null&&(b+=r+` `),h.set(ti.FRAGMENT_HEAD,p),h.set(ti.FRAGMENT_MAIN_UV,g),h.set(ti.FRAGMENT_MAIN_IMAGE,y),h.set(ti.VERTEX_HEAD,b),h.set(ti.VERTEX_MAIN_SUPPORT,x),e.extensions!==null)for(const R of e.extensions)t.extensions.add(R)}}var YV=class extends Za{constructor(n,...e){super("EffectPass"),this.fullscreenMaterial=new jV(null,null,null,n),this.listener=t=>this.handleEvent(t),this.effects=[],this.setEffects(e),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(n){for(const e of this.effects)e.mainScene=n}set mainCamera(n){this.fullscreenMaterial.copyCameraSettings(n);for(const e of this.effects)e.mainCamera=n}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(n){this.fullscreenMaterial.encodeOutput=n}get dithering(){return this.fullscreenMaterial.dithering}set dithering(n){const e=this.fullscreenMaterial;e.dithering=n,e.needsUpdate=!0}setEffects(n){for(const e of this.effects)e.removeEventListener("change",this.listener);this.effects=n.sort((e,t)=>t.attributes-e.attributes);for(const e of this.effects)e.addEventListener("change",this.listener)}updateMaterial(){const n=new IH;let e=0;for(const l of this.effects)if(l.blendMode.blendFunction===Rn.DST)n.attributes|=l.getAttributes()&Wu.DEPTH;else{if((n.attributes&l.getAttributes()&Wu.CONVOLUTION)!==0)throw new Error(`Convolution effects cannot be merged (${l.name})`);qV("e"+e++,l,n)}let t=n.shaderParts.get(ti.FRAGMENT_HEAD),i=n.shaderParts.get(ti.FRAGMENT_MAIN_IMAGE),r=n.shaderParts.get(ti.FRAGMENT_MAIN_UV);const s=/\bblend\b/g;for(const l of n.blendModes.values())t+=l.getShaderCode().replace(s,`blend${l.blendFunction}`)+` `;(n.attributes&Wu.DEPTH)!==0?(n.readDepth&&(i=`float depth = readDepth(UV); `+i),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,n.colorSpace===Zn&&(i+=`color0 = sRGBToLinear(color0); `),n.uvTransformation?(r=`vec2 transformedUv = vUv; `+r,n.defines.set("UV","transformedUv")):n.defines.set("UV","vUv"),n.shaderParts.set(ti.FRAGMENT_HEAD,t),n.shaderParts.set(ti.FRAGMENT_MAIN_IMAGE,i),n.shaderParts.set(ti.FRAGMENT_MAIN_UV,r);for(const[l,u]of n.shaderParts)u!==null&&n.shaderParts.set(l,u.trim().replace(/^#/,` #`));this.skipRendering=e===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(n)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(n,e=tf){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(n,e)}render(n,e,t,i,r){for(const s of this.effects)s.update(n,e,i);if(!this.skipRendering||this.renderToScreen){const s=this.fullscreenMaterial;s.inputBuffer=e.texture,s.time+=i*this.timeScale,n.setRenderTarget(this.renderToScreen?null:t),n.render(this.scene,this.camera)}}setSize(n,e){this.fullscreenMaterial.setSize(n,e);for(const t of this.effects)t.setSize(n,e)}initialize(n,e,t){this.renderer=n;for(const i of this.effects)i.initialize(n,e,t);this.updateMaterial(),t!==void 0&&t!==fr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const n of this.effects)n.removeEventListener("change",this.listener),n.dispose()}handleEvent(n){n.type==="change"&&this.recompile()}},ZV=class extends Za{constructor(n,e,{renderTarget:t,resolutionScale:i=1,width:r=Aa.AUTO_SIZE,height:s=Aa.AUTO_SIZE,resolutionX:l=r,resolutionY:u=s}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new IO(n,e,new HE);const h=this.renderPass;h.ignoreBackground=!0,h.skipShadowMapUpdate=!0;const p=h.getClearPass();p.overrideClearColor=new Mt(7829503),p.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new ai(1,1,{minFilter:jn,magFilter:jn}),this.renderTarget.texture.name="NormalPass.Target");const g=this.resolution=new Aa(this,l,u,i);g.addEventListener("change",y=>this.setSize(g.baseWidth,g.baseHeight))}set mainScene(n){this.renderPass.mainScene=n}set mainCamera(n){this.renderPass.mainCamera=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,r){const s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(n,s,s)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}};function t0(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}new Be;new Be;function PO(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}var po=function n(e,t,i){var r=this;PO(this,n),t0(this,"dot2",function(s,l){return r.x*s+r.y*l}),t0(this,"dot3",function(s,l,u){return r.x*s+r.y*l+r.z*u}),this.x=e,this.y=t,this.z=i},KV=[new po(1,1,0),new po(-1,1,0),new po(1,-1,0),new po(-1,-1,0),new po(1,0,1),new po(-1,0,1),new po(1,0,-1),new po(-1,0,-1),new po(0,1,1),new po(0,-1,1),new po(0,1,-1),new po(0,-1,-1)],DC=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],OC=new Array(512),IC=new Array(512),QV=function(e){e>0&&e<1&&(e*=65536),e=Math.floor(e),e<256&&(e|=e<<8);for(var t=0;t<256;t++){var i;t&1?i=DC[t]^e&255:i=DC[t]^e>>8&255,OC[t]=OC[t+256]=i,IC[t]=IC[t+256]=KV[i%12]}};QV(0);function JV(n){if(typeof n=="number")n=Math.abs(n);else if(typeof n=="string"){var e=n;n=0;for(var t=0;t(n.getAttributes()&2)===2,n8=P.memo(P.forwardRef(({children:n,camera:e,scene:t,resolutionScale:i,enabled:r=!0,renderPriority:s=1,autoClear:l=!0,depthBuffer:u,enableNormalPass:h,stencilBuffer:p,multisampling:g=8,frameBufferType:y=vo},b)=>{const{gl:x,scene:E,camera:A,size:T}=Di(),M=t||E,R=e||A,[O,D,F]=P.useMemo(()=>{const H=new OH(x,{depthBuffer:u,stencilBuffer:p,multisampling:g,frameBufferType:y});H.addPass(new IO(M,R));let L=null,z=null;return h&&(z=new ZV(M,R),z.enabled=!1,H.addPass(z),i!==void 0&&(L=new zV({normalBuffer:z.texture,resolutionScale:i}),L.enabled=!1,H.addPass(L))),[H,z,L]},[R,x,u,p,g,y,M,h,i]);P.useEffect(()=>O?.setSize(T.width,T.height),[O,T]),Wo((H,L)=>{if(r){const z=x.autoClear;x.autoClear=l,p&&!l&&x.clearStencil(),O.render(L),x.autoClear=z}},r?s:0);const U=P.useRef(null);P.useLayoutEffect(()=>{const H=[],L=U.current.__r3f;if(L&&O){const z=L.children;for(let W=0;W{for(const z of H)O?.removePass(z);D&&(D.enabled=!1),F&&(F.enabled=!1)}},[O,n,R,D,F]),P.useEffect(()=>{const H=x.toneMapping;return x.toneMapping=Us,()=>{x.toneMapping=H}},[x]);const k=P.useMemo(()=>({composer:O,normalPass:D,downSamplingPass:F,resolutionScale:i,camera:R,scene:M}),[O,D,F,i,R,M]);return P.useImperativeHandle(b,()=>O,[O]),xt.jsx(t8.Provider,{value:k,children:xt.jsx("group",{ref:U,children:n})})}));let i8=0;const NC=new WeakMap,H0=(n,e)=>function({blendFunction:t=e?.blendFunction,opacity:i=e?.opacity,...r}){let s=NC.get(n);if(!s){const h=`@react-three/postprocessing/${n.name}-${i8++}`;fO({[h]:n}),NC.set(n,s=h)}const l=Di(h=>h.camera),u=ae.useMemo(()=>[...e?.args??[],...r.args??[{...e,...r}]],[JSON.stringify(r)]);return xt.jsx(s,{camera:l,"blendMode-blendFunction":t,"blendMode-opacity-value":i,...r,args:u})},r8=H0(CV,{blendFunction:0}),a8=H0(OV),s8=H0(PV,{blendFunction:5}),o8=H0(VV),l8=H0(WV);function UC(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function Ld(...n){return e=>{let t=!1;const i=n.map(r=>{const s=UC(r,e);return!t&&typeof s=="function"&&(t=!0),s});if(t)return()=>{for(let r=0;r{let{children:s,...l}=i;LO(s)&&typeof zx=="function"&&(s=zx(s._payload));const u=P.Children.toArray(s),h=u.find(p8);if(h){const p=h.props.children,g=u.map(y=>y===h?P.Children.count(p)>1?P.Children.only(null):P.isValidElement(p)?p.props.children:null:y);return xt.jsx(e,{...l,ref:r,children:P.isValidElement(p)?P.cloneElement(p,void 0,g):null})}return xt.jsx(e,{...l,ref:r,children:s})});return t.displayName=`${n}.Slot`,t}function d8(n){const e=P.forwardRef((t,i)=>{let{children:r,...s}=t;if(LO(r)&&typeof zx=="function"&&(r=zx(r._payload)),P.isValidElement(r)){const l=g8(r),u=m8(s,r.props);return r.type!==P.Fragment&&(u.ref=i?Ld(i,l):l),P.cloneElement(r,u)}return P.Children.count(r)>1?P.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var h8=Symbol("radix.slottable");function p8(n){return P.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===h8}function m8(n,e){const t={...e};for(const i in e){const r=n[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?t[i]=(...u)=>{const h=s(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...s}:i==="className"&&(t[i]=[r,s].filter(Boolean).join(" "))}return{...n,...t}}function g8(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var v8=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],y8=v8.reduce((n,e)=>{const t=f8(`Primitive.${e}`),i=P.forwardRef((r,s)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),xt.jsx(h,{...u,ref:s})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),Zu=globalThis?.document?P.useLayoutEffect:()=>{},b8="Portal",NO=P.forwardRef((n,e)=>{const{container:t,...i}=n,[r,s]=P.useState(!1);Zu(()=>s(!0),[]);const l=t||r&&globalThis?.document?.body;return l?xL.createPortal(xt.jsx(y8.div,{...i,ref:e}),l):null});NO.displayName=b8;var x8=NO,zC=Object.prototype.hasOwnProperty;function E0(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&E0(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(zC.call(n,t)&&++i&&!zC.call(e,t)||!(t in e)||!E0(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}function F_(n,e){if(Object.is(n,e))return!0;if(typeof n!="object"||n===null||typeof e!="object"||e===null)return!1;const t=Object.keys(n);if(t.length!==Object.keys(e).length)return!1;for(let i=0;i0;)l[u]=arguments[u+4];n.call(this,l),n.captureStackTrace&&n.captureStackTrace(this,e),this.rule=t,this.value=i,this.cause=r,this.target=s}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Error),Bl=function(e,t){e===void 0&&(e=[]),t===void 0&&(t=[]),this.chain=e,this.nextRuleModifiers=t};Bl.prototype._applyRule=function(e,t){var i=this;return function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return i.chain.push(new B_(t,e.apply(i,r),r,i.nextRuleModifiers)),i.nextRuleModifiers=[],i}};Bl.prototype._applyModifier=function(e,t){return this.nextRuleModifiers.push(new _8(t,e.simple,e.async)),this};Bl.prototype._clone=function(){return new Bl(this.chain.slice(),this.nextRuleModifiers.slice())};Bl.prototype.test=function(e){return this.chain.every(function(t){return t._test(e)})};Bl.prototype.testAll=function(e){var t=[];return this.chain.forEach(function(i){try{i._check(e)}catch(r){t.push(new sT(i,e,r))}}),t};Bl.prototype.check=function(e){this.chain.forEach(function(t){try{t._check(e)}catch(i){throw new sT(t,e,i)}})};Bl.prototype.testAsync=function(e){var t=this;return new Promise(function(i,r){FO(e,t.chain.slice(),i,r)})};function FO(n,e,t,i){if(e.length){var r=e.shift();r._testAsync(n).then(function(){FO(n,e,t,i)},function(s){i(new sT(r,n,s))})}else t(n)}var FC=function(n,e){return e&&typeof n=="string"&&n.trim().length===0?!0:n==null};function S8(n,e){return e===void 0&&(e=!1),{simple:function(t){return FC(t,e)||n.check(t)===void 0},async:function(t){return FC(t,e)||n.testAsync(t)}}}function Ss(){return typeof Proxy<"u"?BO(new Bl):FM(new Bl)}var T0={};Ss.extend=function(n){Object.assign(T0,n)};Ss.clearCustomRules=function(){T0={}};function BO(n){return new Proxy(n,{get:function(t,i){if(i in t)return t[i];var r=BO(n._clone());if(i in Fx)return r._applyModifier(Fx[i],i);if(i in T0)return r._applyRule(T0[i],i);if(i in BM)return r._applyRule(BM[i],i)}})}function FM(n){var e=function(r,s){return Object.keys(r).forEach(function(l){s[l]=function(){for(var u=[],h=arguments.length;h--;)u[h]=arguments[h];var p=FM(s._clone()),g=p._applyRule(r[l],l).apply(void 0,u);return g}}),s},t=e(BM,n),i=e(T0,t);return Object.keys(Fx).forEach(function(r){Object.defineProperty(i,r,{get:function(){var s=FM(i._clone());return s._applyModifier(Fx[r],r)}})}),i}var Fx={not:{simple:function(n){return function(e){return!n(e)}},async:function(n){return function(e){return Promise.resolve(n(e)).then(function(t){return!t}).catch(function(){return!0})}}},some:{simple:function(n){return function(e){return Eb(e).some(function(t){try{return n(t)}catch{return!1}})}},async:function(n){return function(e){return Promise.all(Eb(e).map(function(t){try{return n(t).catch(function(){return!1})}catch{return!1}})).then(function(t){return t.some(Boolean)})}}},every:{simple:function(n){return function(e){return e!==!1&&Eb(e).every(n)}},async:function(n){return function(e){return Promise.all(Eb(e).map(n)).then(function(t){return t.every(Boolean)})}}},strict:{simple:function(n,e){return function(t){return BC(e)&&t&&typeof t=="object"?Object.keys(e.args[0]).length===Object.keys(t).length&&n(t):n(t)}},async:function(n,e){return function(t){return Promise.resolve(n(t)).then(function(i){return BC(e)&&t&&typeof t=="object"?Object.keys(e.args[0]).length===Object.keys(t).length&&i:i}).catch(function(){return!1})}}}};function BC(n){return n&&n.name==="schema"&&n.args.length>0&&typeof n.args[0]=="object"}function Eb(n){return typeof n=="string"?n.split(""):n}var BM={equal:function(n){return function(e){return e==n}},exact:function(n){return function(e){return e===n}},number:function(n){return n===void 0&&(n=!0),function(e){return typeof e=="number"&&(n||isFinite(e))}},integer:function(){return function(n){var e=Number.isInteger||M8;return e(n)}},numeric:function(){return function(n){return!isNaN(parseFloat(n))&&isFinite(n)}},string:function(){return hp("string")},boolean:function(){return hp("boolean")},undefined:function(){return hp("undefined")},null:function(){return hp("null")},array:function(){return hp("array")},object:function(){return hp("object")},instanceOf:function(n){return function(e){return e instanceof n}},pattern:function(n){return function(e){return n.test(e)}},lowercase:function(){return function(n){return typeof n=="boolean"||n===n.toLowerCase()&&n.trim()!==""}},uppercase:function(){return function(n){return n===n.toUpperCase()&&n.trim()!==""}},vowel:function(){return function(n){return/^[aeiou]+$/i.test(n)}},consonant:function(){return function(n){return/^(?=[^aeiou])([a-z]+)$/i.test(n)}},first:function(n){return function(e){return e[0]==n}},last:function(n){return function(e){return e[e.length-1]==n}},empty:function(){return function(n){return n.length===0}},length:function(n,e){return function(t){return t.length>=n&&t.length<=(e||n)}},minLength:function(n){return function(e){return e.length>=n}},maxLength:function(n){return function(e){return e.length<=n}},negative:function(){return function(n){return n<0}},positive:function(){return function(n){return n>=0}},between:function(n,e){return function(t){return t>=n&&t<=e}},range:function(n,e){return function(t){return t>=n&&t<=e}},lessThan:function(n){return function(e){return en}},greaterThanOrEqual:function(n){return function(e){return e>=n}},even:function(){return function(n){return n%2===0}},odd:function(){return function(n){return n%2!==0}},includes:function(n){return function(e){return~e.indexOf(n)}},schema:function(n){return E8(n)},passesAnyOf:function(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];return function(t){return n.some(function(i){return i.test(t)})}},optional:S8};function hp(n){return function(e){return Array.isArray(e)&&n==="array"||e===null&&n==="null"||typeof e===n}}function M8(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n}function E8(n){return{simple:function(e){var t=[];if(Object.keys(n).forEach(function(i){var r=n[i];try{r.check((e||{})[i])}catch(s){s.target=i,t.push(s)}}),t.length>0)throw t;return!0},async:function(e){var t=[],i=Object.keys(n).map(function(r){var s=n[r];return s.testAsync((e||{})[r]).catch(function(l){l.target=r,t.push(l)})});return Promise.all(i).then(function(){if(t.length>0)throw t;return!0})}}}var bi="colors",Ga="sizes",Ft="space",T8={gap:Ft,gridGap:Ft,columnGap:Ft,gridColumnGap:Ft,rowGap:Ft,gridRowGap:Ft,inset:Ft,insetBlock:Ft,insetBlockEnd:Ft,insetBlockStart:Ft,insetInline:Ft,insetInlineEnd:Ft,insetInlineStart:Ft,margin:Ft,marginTop:Ft,marginRight:Ft,marginBottom:Ft,marginLeft:Ft,marginBlock:Ft,marginBlockEnd:Ft,marginBlockStart:Ft,marginInline:Ft,marginInlineEnd:Ft,marginInlineStart:Ft,padding:Ft,paddingTop:Ft,paddingRight:Ft,paddingBottom:Ft,paddingLeft:Ft,paddingBlock:Ft,paddingBlockEnd:Ft,paddingBlockStart:Ft,paddingInline:Ft,paddingInlineEnd:Ft,paddingInlineStart:Ft,top:Ft,right:Ft,bottom:Ft,left:Ft,scrollMargin:Ft,scrollMarginTop:Ft,scrollMarginRight:Ft,scrollMarginBottom:Ft,scrollMarginLeft:Ft,scrollMarginX:Ft,scrollMarginY:Ft,scrollMarginBlock:Ft,scrollMarginBlockEnd:Ft,scrollMarginBlockStart:Ft,scrollMarginInline:Ft,scrollMarginInlineEnd:Ft,scrollMarginInlineStart:Ft,scrollPadding:Ft,scrollPaddingTop:Ft,scrollPaddingRight:Ft,scrollPaddingBottom:Ft,scrollPaddingLeft:Ft,scrollPaddingX:Ft,scrollPaddingY:Ft,scrollPaddingBlock:Ft,scrollPaddingBlockEnd:Ft,scrollPaddingBlockStart:Ft,scrollPaddingInline:Ft,scrollPaddingInlineEnd:Ft,scrollPaddingInlineStart:Ft,fontSize:"fontSizes",background:bi,backgroundColor:bi,backgroundImage:bi,borderImage:bi,border:bi,borderBlock:bi,borderBlockEnd:bi,borderBlockStart:bi,borderBottom:bi,borderBottomColor:bi,borderColor:bi,borderInline:bi,borderInlineEnd:bi,borderInlineStart:bi,borderLeft:bi,borderLeftColor:bi,borderRight:bi,borderRightColor:bi,borderTop:bi,borderTopColor:bi,caretColor:bi,color:bi,columnRuleColor:bi,fill:bi,outline:bi,outlineColor:bi,stroke:bi,textDecorationColor:bi,fontFamily:"fonts",fontWeight:"fontWeights",lineHeight:"lineHeights",letterSpacing:"letterSpacings",blockSize:Ga,minBlockSize:Ga,maxBlockSize:Ga,inlineSize:Ga,minInlineSize:Ga,maxInlineSize:Ga,width:Ga,minWidth:Ga,maxWidth:Ga,height:Ga,minHeight:Ga,maxHeight:Ga,flexBasis:Ga,gridTemplateColumns:Ga,gridTemplateRows:Ga,borderWidth:"borderWidths",borderTopWidth:"borderWidths",borderRightWidth:"borderWidths",borderBottomWidth:"borderWidths",borderLeftWidth:"borderWidths",borderStyle:"borderStyles",borderTopStyle:"borderStyles",borderRightStyle:"borderStyles",borderBottomStyle:"borderStyles",borderLeftStyle:"borderStyles",borderRadius:"radii",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",borderBottomRightRadius:"radii",borderBottomLeftRadius:"radii",boxShadow:"shadows",textShadow:"shadows",transition:"transitions",zIndex:"zIndices"},w8=(n,e)=>typeof e=="function"?{"()":Function.prototype.toString.call(e)}:e,Vp=()=>{const n=Object.create(null);return(e,t,...i)=>{const r=(s=>JSON.stringify(s,w8))(e);return r in n?n[r]:n[r]=t(e,...i)}},bd=Symbol.for("sxs.internal"),oT=(n,e)=>Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)),kC=n=>{for(const e in n)return!0;return!1},{hasOwnProperty:A8}=Object.prototype,kM=n=>n.includes("-")?n:n.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase())),C8=/\s+(?![^()]*\))/,pp=n=>e=>n(...typeof e=="string"?String(e).split(C8):[e]),HC={appearance:n=>({WebkitAppearance:n,appearance:n}),backfaceVisibility:n=>({WebkitBackfaceVisibility:n,backfaceVisibility:n}),backdropFilter:n=>({WebkitBackdropFilter:n,backdropFilter:n}),backgroundClip:n=>({WebkitBackgroundClip:n,backgroundClip:n}),boxDecorationBreak:n=>({WebkitBoxDecorationBreak:n,boxDecorationBreak:n}),clipPath:n=>({WebkitClipPath:n,clipPath:n}),content:n=>({content:n.includes('"')||n.includes("'")||/^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(n)?n:`"${n}"`}),hyphens:n=>({WebkitHyphens:n,hyphens:n}),maskImage:n=>({WebkitMaskImage:n,maskImage:n}),maskSize:n=>({WebkitMaskSize:n,maskSize:n}),tabSize:n=>({MozTabSize:n,tabSize:n}),textSizeAdjust:n=>({WebkitTextSizeAdjust:n,textSizeAdjust:n}),userSelect:n=>({WebkitUserSelect:n,userSelect:n}),marginBlock:pp(((n,e)=>({marginBlockStart:n,marginBlockEnd:e||n}))),marginInline:pp(((n,e)=>({marginInlineStart:n,marginInlineEnd:e||n}))),maxSize:pp(((n,e)=>({maxBlockSize:n,maxInlineSize:e||n}))),minSize:pp(((n,e)=>({minBlockSize:n,minInlineSize:e||n}))),paddingBlock:pp(((n,e)=>({paddingBlockStart:n,paddingBlockEnd:e||n}))),paddingInline:pp(((n,e)=>({paddingInlineStart:n,paddingInlineEnd:e||n})))},z1=/([\d.]+)([^]*)/,R8=(n,e)=>n.length?n.reduce(((t,i)=>(t.push(...e.map((r=>r.includes("&")?r.replace(/&/g,/[ +>|~]/.test(i)&&/&.*&/.test(r)?`:is(${i})`:i):i+" "+r))),t)),[]):e,D8=(n,e)=>n in O8&&typeof e=="string"?e.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/,((t,i,r,s)=>i+(r==="stretch"?`-moz-available${s};${kM(n)}:${i}-webkit-fill-available`:`-moz-fit-content${s};${kM(n)}:${i}fit-content`)+s)):String(e),O8={blockSize:1,height:1,inlineSize:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,width:1},Nc=n=>n?n+"-":"",kO=(n,e,t)=>n.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g,((i,r,s,l,u)=>l=="$"==!!s?i:(r||l=="--"?"calc(":"")+"var(--"+(l==="$"?Nc(e)+(u.includes("$")?"":Nc(t))+u.replace(/\$/g,"-"):u)+")"+(r||l=="--"?"*"+(r||"")+(s||"1")+")":""))),I8=/\s*,\s*(?![^()]*\))/,P8=Object.prototype.toString,xp=(n,e,t,i,r)=>{let s,l,u;const h=(p,g,y)=>{let b,x;const E=A=>{for(b in A){const R=b.charCodeAt(0)===64,O=R&&Array.isArray(A[b])?A[b]:[A[b]];for(x of O){const D=/[A-Z]/.test(M=b)?M:M.replace(/-[^]/g,(U=>U[1].toUpperCase())),F=typeof x=="object"&&x&&x.toString===P8&&(!i.utils[D]||!g.length);if(D in i.utils&&!F){const U=i.utils[D];if(U!==l){l=U,E(U(x)),l=null;continue}}else if(D in HC){const U=HC[D];if(U!==u){u=U,E(U(x)),u=null;continue}}if(R&&(T=b.slice(1)in i.media?"@media "+i.media[b.slice(1)]:b,b=T.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g,((U,k,H,L,z,W)=>{const J=z1.test(k),$=.0625*(J?-1:1),[oe,ne]=J?[L,k]:[k,L];return"("+(H[0]==="="?"":H[0]===">"===J?"max-":"min-")+oe+":"+(H[0]!=="="&&H.length===1?ne.replace(z1,((Y,K,ie)=>Number(K)+$*(H===">"?1:-1)+ie)):ne)+(z?") and ("+(z[0]===">"?"min-":"max-")+oe+":"+(z.length===1?W.replace(z1,((Y,K,ie)=>Number(K)+$*(z===">"?-1:1)+ie)):W):"")+")"}))),F){const U=R?y.concat(b):[...y],k=R?[...g]:R8(g,b.split(I8));s!==void 0&&r(VC(...s)),s=void 0,h(x,k,U)}else s===void 0&&(s=[[],g,y]),b=R||b.charCodeAt(0)!==36?b:`--${Nc(i.prefix)}${b.slice(1).replace(/\$/g,"-")}`,x=F?x:typeof x=="number"?x&&D in L8?String(x)+"px":String(x):kO(D8(D,x??""),i.prefix,i.themeMap[D]),s[0].push(`${R?`${b} `:`${kM(b)}:`}${x}`)}}var T,M};E(p),s!==void 0&&r(VC(...s)),s=void 0};h(n,e,t)},VC=(n,e,t)=>`${t.map((i=>`${i}{`)).join("")}${e.length?`${e.join(",")}{`:""}${n.join(";")}${e.length?"}":""}${Array(t.length?t.length+1:0).join("}")}`,L8={animationDelay:1,animationDuration:1,backgroundSize:1,blockSize:1,border:1,borderBlock:1,borderBlockEnd:1,borderBlockEndWidth:1,borderBlockStart:1,borderBlockStartWidth:1,borderBlockWidth:1,borderBottom:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,borderBottomWidth:1,borderEndEndRadius:1,borderEndStartRadius:1,borderInlineEnd:1,borderInlineEndWidth:1,borderInlineStart:1,borderInlineStartWidth:1,borderInlineWidth:1,borderLeft:1,borderLeftWidth:1,borderRadius:1,borderRight:1,borderRightWidth:1,borderSpacing:1,borderStartEndRadius:1,borderStartStartRadius:1,borderTop:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderTopWidth:1,borderWidth:1,bottom:1,columnGap:1,columnRule:1,columnRuleWidth:1,columnWidth:1,containIntrinsicSize:1,flexBasis:1,fontSize:1,gap:1,gridAutoColumns:1,gridAutoRows:1,gridTemplateColumns:1,gridTemplateRows:1,height:1,inlineSize:1,inset:1,insetBlock:1,insetBlockEnd:1,insetBlockStart:1,insetInline:1,insetInlineEnd:1,insetInlineStart:1,left:1,letterSpacing:1,margin:1,marginBlock:1,marginBlockEnd:1,marginBlockStart:1,marginBottom:1,marginInline:1,marginInlineEnd:1,marginInlineStart:1,marginLeft:1,marginRight:1,marginTop:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,offsetDistance:1,offsetRotate:1,outline:1,outlineOffset:1,outlineWidth:1,overflowClipMargin:1,padding:1,paddingBlock:1,paddingBlockEnd:1,paddingBlockStart:1,paddingBottom:1,paddingInline:1,paddingInlineEnd:1,paddingInlineStart:1,paddingLeft:1,paddingRight:1,paddingTop:1,perspective:1,right:1,rowGap:1,scrollMargin:1,scrollMarginBlock:1,scrollMarginBlockEnd:1,scrollMarginBlockStart:1,scrollMarginBottom:1,scrollMarginInline:1,scrollMarginInlineEnd:1,scrollMarginInlineStart:1,scrollMarginLeft:1,scrollMarginRight:1,scrollMarginTop:1,scrollPadding:1,scrollPaddingBlock:1,scrollPaddingBlockEnd:1,scrollPaddingBlockStart:1,scrollPaddingBottom:1,scrollPaddingInline:1,scrollPaddingInlineEnd:1,scrollPaddingInlineStart:1,scrollPaddingLeft:1,scrollPaddingRight:1,scrollPaddingTop:1,shapeMargin:1,textDecoration:1,textDecorationThickness:1,textIndent:1,textUnderlineOffset:1,top:1,transitionDelay:1,transitionDuration:1,verticalAlign:1,width:1,wordSpacing:1},GC=n=>String.fromCharCode(n+(n>25?39:97)),xd=n=>(e=>{let t,i="";for(t=Math.abs(e);t>52;t=t/52|0)i=GC(t%52)+i;return GC(t%52)+i})(((e,t)=>{let i=t.length;for(;i;)e=33*e^t.charCodeAt(--i);return e})(5381,JSON.stringify(n))>>>0),Wg=["themed","global","styled","onevar","resonevar","allvar","inline"],N8=n=>{if(n.href&&!n.href.startsWith(location.origin))return!1;try{return!!n.cssRules}catch{return!1}},U8=n=>{let e;const t=()=>{const{cssRules:r}=e.sheet;return[].map.call(r,((s,l)=>{const{cssText:u}=s;let h="";if(u.startsWith("--sxs"))return"";if(r[l-1]&&(h=r[l-1].cssText).startsWith("--sxs")){if(!s.cssRules.length)return"";for(const p in e.rules)if(e.rules[p].group===s)return`--sxs{--sxs:${[...e.rules[p].cache].join(" ")}}${u}`;return s.cssRules.length?`${h}${u}`:""}return u})).join("")},i=()=>{if(e){const{rules:u,sheet:h}=e;if(!h.deleteRule){for(;Object(Object(h.cssRules)[0]).type===3;)h.cssRules.splice(0,1);h.cssRules=[]}for(const p in u)delete u[p]}const r=Object(n).styleSheets||[];for(const u of r)if(N8(u)){for(let h=0,p=u.cssRules;p[h];++h){const g=Object(p[h]);if(g.type!==1)continue;const y=Object(p[h+1]);if(y.type!==4)continue;++h;const{cssText:b}=g;if(!b.startsWith("--sxs"))continue;const x=b.slice(14,-3).trim().split(/\s+/),E=Wg[x[0]];E&&(e||(e={sheet:u,reset:i,rules:{},toString:t}),e.rules[E]={group:y,index:h,cache:new Set(x)})}if(e)break}if(!e){const u=(h,p)=>({type:p,cssRules:[],insertRule(g,y){this.cssRules.splice(y,0,u(g,{import:3,undefined:1}[(g.toLowerCase().match(/^@([a-z]+)/)||[])[1]]||4))},get cssText(){return h==="@media{}"?`@media{${[].map.call(this.cssRules,(g=>g.cssText)).join("")}}`:h}});e={sheet:n?(n.head||n).appendChild(document.createElement("style")).sheet:u("","text/css"),rules:{},reset:i,toString:t}}const{sheet:s,rules:l}=e;for(let u=Wg.length-1;u>=0;--u){const h=Wg[u];if(!l[h]){const p=Wg[u+1],g=l[p]?l[p].index:s.cssRules.length;s.insertRule("@media{}",g),s.insertRule(`--sxs{--sxs:${u}}`,g),l[h]={group:s.cssRules[g+1],index:g,cache:new Set([u])}}z8(l[h])}};return i(),e},z8=n=>{const e=n.group;let t=e.cssRules.length;n.apply=i=>{try{e.insertRule(i,t),++t}catch{}}},Lg=Symbol(),F8=Vp(),WC=(n,e)=>F8(n,(()=>(...t)=>{let i={type:null,composers:new Set};for(const r of t)if(r!=null)if(r[bd]){i.type==null&&(i.type=r[bd].type);for(const s of r[bd].composers)i.composers.add(s)}else r.constructor!==Object||r.$$typeof?i.type==null&&(i.type=r):i.composers.add(B8(r,n));return i.type==null&&(i.type="span"),i.composers.size||i.composers.add(["PJLV",{},[],[],{},[]]),k8(n,i,e)})),B8=({variants:n,compoundVariants:e,defaultVariants:t,...i},r)=>{const s=`${Nc(r.prefix)}c-${xd(i)}`,l=[],u=[],h=Object.create(null),p=[];for(const b in t)h[b]=String(t[b]);if(typeof n=="object"&&n)for(const b in n){g=h,y=b,A8.call(g,y)||(h[b]="undefined");const x=n[b];for(const E in x){const A={[b]:String(E)};String(E)==="undefined"&&p.push(b);const T=x[E],M=[A,T,!kC(T)];l.push(M)}}var g,y;if(typeof e=="object"&&e)for(const b of e){let{css:x,...E}=b;x=typeof x=="object"&&x||{};for(const T in E)E[T]=String(E[T]);const A=[E,x,!kC(x)];u.push(A)}return[s,i,l,u,h,p]},k8=(n,e,t)=>{const[i,r,s,l]=H8(e.composers),u=typeof e.type=="function"||e.type.$$typeof?(y=>{function b(){for(let x=0;xb.rules[x]={apply:E=>b[Lg].push([x,E])})),b})(t):null,h=(u||t).rules,p=`.${i}${r.length>1?`:where(.${r.slice(1).join(".")})`:""}`,g=y=>{y=typeof y=="object"&&y||V8;const{css:b,...x}=y,E={};for(const M in s)if(delete x[M],M in y){let R=y[M];typeof R=="object"&&R?E[M]={"@initial":s[M],...R}:(R=String(R),E[M]=R!=="undefined"||l.has(M)?R:s[M])}else E[M]=s[M];const A=new Set([...r]);for(const[M,R,O,D]of e.composers){t.rules.styled.cache.has(M)||(t.rules.styled.cache.add(M),xp(R,[`.${M}`],[],n,(k=>{h.styled.apply(k)})));const F=XC(O,E,n.media),U=XC(D,E,n.media,!0);for(const k of F)if(k!==void 0)for(const[H,L,z]of k){const W=`${M}-${xd(L)}-${H}`;A.add(W);const J=(z?t.rules.resonevar:t.rules.onevar).cache,$=z?h.resonevar:h.onevar;J.has(W)||(J.add(W),xp(L,[`.${W}`],[],n,(oe=>{$.apply(oe)})))}for(const k of U)if(k!==void 0)for(const[H,L]of k){const z=`${M}-${xd(L)}-${H}`;A.add(z),t.rules.allvar.cache.has(z)||(t.rules.allvar.cache.add(z),xp(L,[`.${z}`],[],n,(W=>{h.allvar.apply(W)})))}}if(typeof b=="object"&&b){const M=`${i}-i${xd(b)}-css`;A.add(M),t.rules.inline.cache.has(M)||(t.rules.inline.cache.add(M),xp(b,[`.${M}`],[],n,(R=>{h.inline.apply(R)})))}for(const M of String(y.className||"").trim().split(/\s+/))M&&A.add(M);const T=x.className=[...A].join(" ");return{type:e.type,className:T,selector:p,props:x,toString:()=>T,deferredInjector:u}};return oT(g,{className:i,selector:p,[bd]:e,toString:()=>(t.rules.styled.cache.has(i)||g(),i)})},H8=n=>{let e="";const t=[],i={},r=[];for(const[s,,,,l,u]of n){e===""&&(e=s),t.push(s),r.push(...u);for(const h in l){const p=l[h];(i[h]===void 0||p!=="undefined"||u.includes(p))&&(i[h]=p)}}return[e,t,i,new Set(r)]},XC=(n,e,t,i)=>{const r=[];e:for(let[s,l,u]of n){if(u)continue;let h,p=0,g=!1;for(h in s){const y=s[h];let b=e[h];if(b!==y){if(typeof b!="object"||!b)continue e;{let x,E,A=0;for(const T in b){if(y===String(b[T])){if(T!=="@initial"){const M=T.slice(1);(E=E||[]).push(M in t?t[M]:T.replace(/^@media ?/,"")),g=!0}p+=A,x=!0}++A}if(E&&E.length&&(l={["@media "+E.join(", ")]:l}),!x)continue e}}}(r[p]=r[p]||[]).push([i?"cv":`${h}-${s[h]}`,l,g])}return r},V8={},G8=Vp(),W8=(n,e)=>G8(n,(()=>(...t)=>{const i=()=>{for(let r of t){r=typeof r=="object"&&r||{};let s=xd(r);if(!e.rules.global.cache.has(s)){if(e.rules.global.cache.add(s),"@import"in r){let l=[].indexOf.call(e.sheet.cssRules,e.rules.themed.group)-1;for(let u of[].concat(r["@import"]))u=u.includes('"')||u.includes("'")?u:`"${u}"`,e.sheet.insertRule(`@import ${u};`,l++);delete r["@import"]}xp(r,[],[],n,(l=>{e.rules.global.apply(l)}))}}return""};return oT(i,{toString:i})})),X8=Vp(),$8=(n,e)=>X8(n,(()=>t=>{const i=`${Nc(n.prefix)}k-${xd(t)}`,r=()=>{if(!e.rules.global.cache.has(i)){e.rules.global.cache.add(i);const s=[];xp(t,[],[],n,(u=>s.push(u)));const l=`@keyframes ${i}{${s.join("")}}`;e.rules.global.apply(l)}return i};return oT(r,{get name(){return r()},toString:r})})),j8=class{constructor(n,e,t,i){this.token=n==null?"":String(n),this.value=e==null?"":String(e),this.scale=t==null?"":String(t),this.prefix=i==null?"":String(i)}get computedValue(){return"var("+this.variable+")"}get variable(){return"--"+Nc(this.prefix)+Nc(this.scale)+this.token}toString(){return this.computedValue}},q8=Vp(),Y8=(n,e)=>q8(n,(()=>(t,i)=>{i=typeof t=="object"&&t||Object(i);const r=`.${t=(t=typeof t=="string"?t:"")||`${Nc(n.prefix)}t-${xd(i)}`}`,s={},l=[];for(const h in i){s[h]={};for(const p in i[h]){const g=`--${Nc(n.prefix)}${h}-${p}`,y=kO(String(i[h][p]),n.prefix,h);s[h][p]=new j8(p,y,h,n.prefix),l.push(`${g}:${y}`)}}const u=()=>{if(l.length&&!e.rules.themed.cache.has(t)){e.rules.themed.cache.add(t);const h=`${i===n.theme?":root,":""}.${t}{${l.join(";")}}`;e.rules.themed.apply(h)}return t};return{...s,get className(){return u()},selector:r,toString:u}})),Z8=Vp(),K8=Vp(),Q8=n=>{const e=(t=>{let i=!1;const r=Z8(t,(s=>{i=!0;const l="prefix"in(s=typeof s=="object"&&s||{})?String(s.prefix):"",u=typeof s.media=="object"&&s.media||{},h=typeof s.root=="object"?s.root||null:globalThis.document||null,p=typeof s.theme=="object"&&s.theme||{},g={prefix:l,media:u,theme:p,themeMap:typeof s.themeMap=="object"&&s.themeMap||{...T8},utils:typeof s.utils=="object"&&s.utils||{}},y=U8(h),b={css:WC(g,y),globalCss:W8(g,y),keyframes:$8(g,y),createTheme:Y8(g,y),reset(){y.reset(),b.theme.toString()},theme:{},sheet:y,config:g,prefix:l,getCssText:y.toString,toString:y.toString};return String(b.theme=b.createTheme(p)),b}));return i||r.reset(),r})(n);return e.styled=(({config:t,sheet:i})=>K8(t,(()=>{const r=WC(t,i);return(...s)=>{const l=r(...s),u=l[bd].type,h=ae.forwardRef(((p,g)=>{const y=p&&p.as||u,{props:b,deferredInjector:x}=l(p);return delete b.as,b.ref=g,x?ae.createElement(ae.Fragment,null,ae.createElement(y,b),ae.createElement(x,null)):ae.createElement(y,b)}));return h.className=l.className,h.displayName=`Styled.${u.displayName||u.name||u}`,h.selector=l.selector,h.toString=()=>l.selector,h[bd]=l[bd],h}})))(e),e};function wc(n,e,{checkForDefaultPrevented:t=!0}={}){return function(r){if(n?.(r),t===!1||!r.defaultPrevented)return e?.(r)}}function HO(n,e=[]){let t=[];function i(s,l){const u=P.createContext(l),h=t.length;t=[...t,l];const p=y=>{const{scope:b,children:x,...E}=y,A=b?.[n]?.[h]||u,T=P.useMemo(()=>E,Object.values(E));return xt.jsx(A.Provider,{value:T,children:x})};p.displayName=s+"Provider";function g(y,b){const x=b?.[n]?.[h]||u,E=P.useContext(x);if(E)return E;if(l!==void 0)return l;throw new Error(`\`${y}\` must be used within \`${s}\``)}return[p,g]}const r=()=>{const s=t.map(l=>P.createContext(l));return function(u){const h=u?.[n]||s;return P.useMemo(()=>({[`__scope${n}`]:{...u,[n]:h}}),[u,h])}};return r.scopeName=n,[i,J8(r,...e)]}function J8(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const i=n.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){const l=i.reduce((u,{useScope:h,scopeName:p})=>{const y=h(s)[`__scope${p}`];return{...u,...y}},{});return P.useMemo(()=>({[`__scope${e.scopeName}`]:l}),[l])}};return t.scopeName=e.scopeName,t}function eG(n){const e=tG(n),t=P.forwardRef((i,r)=>{const{children:s,...l}=i,u=P.Children.toArray(s),h=u.find(iG);if(h){const p=h.props.children,g=u.map(y=>y===h?P.Children.count(p)>1?P.Children.only(null):P.isValidElement(p)?p.props.children:null:y);return xt.jsx(e,{...l,ref:r,children:P.isValidElement(p)?P.cloneElement(p,void 0,g):null})}return xt.jsx(e,{...l,ref:r,children:s})});return t.displayName=`${n}.Slot`,t}function tG(n){const e=P.forwardRef((t,i)=>{const{children:r,...s}=t;if(P.isValidElement(r)){const l=aG(r),u=rG(s,r.props);return r.type!==P.Fragment&&(u.ref=i?Ld(i,l):l),P.cloneElement(r,u)}return P.Children.count(r)>1?P.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var nG=Symbol("radix.slottable");function iG(n){return P.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===nG}function rG(n,e){const t={...e};for(const i in e){const r=n[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?t[i]=(...u)=>{const h=s(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...s}:i==="className"&&(t[i]=[r,s].filter(Boolean).join(" "))}return{...n,...t}}function aG(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var sG=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],VO=sG.reduce((n,e)=>{const t=eG(`Primitive.${e}`),i=P.forwardRef((r,s)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),xt.jsx(h,{...u,ref:s})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function oG(n,e){n&&Jx.flushSync(()=>n.dispatchEvent(e))}function k_(n){const e=P.useRef(n);return P.useEffect(()=>{e.current=n}),P.useMemo(()=>(...t)=>e.current?.(...t),[])}function lG(n,e=globalThis?.document){const t=k_(n);P.useEffect(()=>{const i=r=>{r.key==="Escape"&&t(r)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[t,e])}var cG="DismissableLayer",HM="dismissableLayer.update",uG="dismissableLayer.pointerDownOutside",fG="dismissableLayer.focusOutside",$C,GO=P.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),WO=P.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:r,onFocusOutside:s,onInteractOutside:l,onDismiss:u,...h}=n,p=P.useContext(GO),[g,y]=P.useState(null),b=g?.ownerDocument??globalThis?.document,[,x]=P.useState({}),E=Nd(e,k=>y(k)),A=Array.from(p.layers),[T]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),M=A.indexOf(T),R=g?A.indexOf(g):-1,O=p.layersWithOutsidePointerEventsDisabled.size>0,D=R>=M,F=pG(k=>{const H=k.target,L=[...p.branches].some(z=>z.contains(H));!D||L||(r?.(k),l?.(k),k.defaultPrevented||u?.())},b),U=mG(k=>{const H=k.target;[...p.branches].some(z=>z.contains(H))||(s?.(k),l?.(k),k.defaultPrevented||u?.())},b);return lG(k=>{R===p.layers.size-1&&(i?.(k),!k.defaultPrevented&&u&&(k.preventDefault(),u()))},b),P.useEffect(()=>{if(g)return t&&(p.layersWithOutsidePointerEventsDisabled.size===0&&($C=b.body.style.pointerEvents,b.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(g)),p.layers.add(g),jC(),()=>{t&&p.layersWithOutsidePointerEventsDisabled.size===1&&(b.body.style.pointerEvents=$C)}},[g,b,t,p]),P.useEffect(()=>()=>{g&&(p.layers.delete(g),p.layersWithOutsidePointerEventsDisabled.delete(g),jC())},[g,p]),P.useEffect(()=>{const k=()=>x({});return document.addEventListener(HM,k),()=>document.removeEventListener(HM,k)},[]),xt.jsx(VO.div,{...h,ref:E,style:{pointerEvents:O?D?"auto":"none":void 0,...n.style},onFocusCapture:wc(n.onFocusCapture,U.onFocusCapture),onBlurCapture:wc(n.onBlurCapture,U.onBlurCapture),onPointerDownCapture:wc(n.onPointerDownCapture,F.onPointerDownCapture)})});WO.displayName=cG;var dG="DismissableLayerBranch",hG=P.forwardRef((n,e)=>{const t=P.useContext(GO),i=P.useRef(null),r=Nd(e,i);return P.useEffect(()=>{const s=i.current;if(s)return t.branches.add(s),()=>{t.branches.delete(s)}},[t.branches]),xt.jsx(VO.div,{...n,ref:r})});hG.displayName=dG;function pG(n,e=globalThis?.document){const t=k_(n),i=P.useRef(!1),r=P.useRef(()=>{});return P.useEffect(()=>{const s=u=>{if(u.target&&!i.current){let h=function(){XO(uG,t,p,{discrete:!0})};const p={originalEvent:u};u.pointerType==="touch"?(e.removeEventListener("click",r.current),r.current=h,e.addEventListener("click",r.current,{once:!0})):h()}else e.removeEventListener("click",r.current);i.current=!1},l=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(l),e.removeEventListener("pointerdown",s),e.removeEventListener("click",r.current)}},[e,t]),{onPointerDownCapture:()=>i.current=!0}}function mG(n,e=globalThis?.document){const t=k_(n),i=P.useRef(!1);return P.useEffect(()=>{const r=s=>{s.target&&!i.current&&XO(fG,t,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,t]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function jC(){const n=new CustomEvent(HM);document.dispatchEvent(n)}function XO(n,e,t,{discrete:i}){const r=t.originalEvent.target,s=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&r.addEventListener(n,e,{once:!0}),i?oG(r,s):r.dispatchEvent(s)}var gG=sE[" useId ".trim().toString()]||(()=>{}),vG=0;function yG(n){const[e,t]=P.useState(gG());return Zu(()=>{t(i=>i??String(vG++))},[n]),e?`radix-${e}`:""}const bG=["top","right","bottom","left"],Ku=Math.min,Ls=Math.max,Bx=Math.round,Tb=Math.floor,Ll=n=>({x:n,y:n}),xG={left:"right",right:"left",bottom:"top",top:"bottom"},_G={start:"end",end:"start"};function VM(n,e,t){return Ls(n,Ku(e,t))}function Uc(n,e){return typeof n=="function"?n(e):n}function zc(n){return n.split("-")[0]}function Gp(n){return n.split("-")[1]}function lT(n){return n==="x"?"y":"x"}function cT(n){return n==="y"?"height":"width"}const SG=new Set(["top","bottom"]);function Pl(n){return SG.has(zc(n))?"y":"x"}function uT(n){return lT(Pl(n))}function MG(n,e,t){t===void 0&&(t=!1);const i=Gp(n),r=uT(n),s=cT(r);let l=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(l=kx(l)),[l,kx(l)]}function EG(n){const e=kx(n);return[GM(n),e,GM(e)]}function GM(n){return n.replace(/start|end/g,e=>_G[e])}const qC=["left","right"],YC=["right","left"],TG=["top","bottom"],wG=["bottom","top"];function AG(n,e,t){switch(n){case"top":case"bottom":return t?e?YC:qC:e?qC:YC;case"left":case"right":return e?TG:wG;default:return[]}}function CG(n,e,t,i){const r=Gp(n);let s=AG(zc(n),t==="start",i);return r&&(s=s.map(l=>l+"-"+r),e&&(s=s.concat(s.map(GM)))),s}function kx(n){return n.replace(/left|right|bottom|top/g,e=>xG[e])}function RG(n){return{top:0,right:0,bottom:0,left:0,...n}}function $O(n){return typeof n!="number"?RG(n):{top:n,right:n,bottom:n,left:n}}function Hx(n){const{x:e,y:t,width:i,height:r}=n;return{width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function ZC(n,e,t){let{reference:i,floating:r}=n;const s=Pl(e),l=uT(e),u=cT(l),h=zc(e),p=s==="y",g=i.x+i.width/2-r.width/2,y=i.y+i.height/2-r.height/2,b=i[u]/2-r[u]/2;let x;switch(h){case"top":x={x:g,y:i.y-r.height};break;case"bottom":x={x:g,y:i.y+i.height};break;case"right":x={x:i.x+i.width,y};break;case"left":x={x:i.x-r.width,y};break;default:x={x:i.x,y:i.y}}switch(Gp(e)){case"start":x[l]-=b*(t&&p?-1:1);break;case"end":x[l]+=b*(t&&p?-1:1);break}return x}async function DG(n,e){var t;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:l,elements:u,strategy:h}=n,{boundary:p="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:b=!1,padding:x=0}=Uc(e,n),E=$O(x),T=u[b?y==="floating"?"reference":"floating":y],M=Hx(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(T)))==null||t?T:T.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(u.floating)),boundary:p,rootBoundary:g,strategy:h})),R=y==="floating"?{x:i,y:r,width:l.floating.width,height:l.floating.height}:l.reference,O=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u.floating)),D=await(s.isElement==null?void 0:s.isElement(O))?await(s.getScale==null?void 0:s.getScale(O))||{x:1,y:1}:{x:1,y:1},F=Hx(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:R,offsetParent:O,strategy:h}):R);return{top:(M.top-F.top+E.top)/D.y,bottom:(F.bottom-M.bottom+E.bottom)/D.y,left:(M.left-F.left+E.left)/D.x,right:(F.right-M.right+E.right)/D.x}}const OG=async(n,e,t)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:l}=t,u=s.filter(Boolean),h=await(l.isRTL==null?void 0:l.isRTL(e));let p=await l.getElementRects({reference:n,floating:e,strategy:r}),{x:g,y}=ZC(p,i,h),b=i,x={},E=0;for(let T=0;T({name:"arrow",options:n,async fn(e){const{x:t,y:i,placement:r,rects:s,platform:l,elements:u,middlewareData:h}=e,{element:p,padding:g=0}=Uc(n,e)||{};if(p==null)return{};const y=$O(g),b={x:t,y:i},x=uT(r),E=cT(x),A=await l.getDimensions(p),T=x==="y",M=T?"top":"left",R=T?"bottom":"right",O=T?"clientHeight":"clientWidth",D=s.reference[E]+s.reference[x]-b[x]-s.floating[E],F=b[x]-s.reference[x],U=await(l.getOffsetParent==null?void 0:l.getOffsetParent(p));let k=U?U[O]:0;(!k||!await(l.isElement==null?void 0:l.isElement(U)))&&(k=u.floating[O]||s.floating[E]);const H=D/2-F/2,L=k/2-A[E]/2-1,z=Ku(y[M],L),W=Ku(y[R],L),J=z,$=k-A[E]-W,oe=k/2-A[E]/2+H,ne=VM(J,oe,$),Y=!h.arrow&&Gp(r)!=null&&oe!==ne&&s.reference[E]/2-(oeoe<=0)){var W,J;const oe=(((W=s.flip)==null?void 0:W.index)||0)+1,ne=k[oe];if(ne&&(!(y==="alignment"?R!==Pl(ne):!1)||z.every(ie=>Pl(ie.placement)===R?ie.overflows[0]>0:!0)))return{data:{index:oe,overflows:z},reset:{placement:ne}};let Y=(J=z.filter(K=>K.overflows[0]<=0).sort((K,ie)=>K.overflows[1]-ie.overflows[1])[0])==null?void 0:J.placement;if(!Y)switch(x){case"bestFit":{var $;const K=($=z.filter(ie=>{if(U){const ge=Pl(ie.placement);return ge===R||ge==="y"}return!0}).map(ie=>[ie.placement,ie.overflows.filter(ge=>ge>0).reduce((ge,xe)=>ge+xe,0)]).sort((ie,ge)=>ie[1]-ge[1])[0])==null?void 0:$[0];K&&(Y=K);break}case"initialPlacement":Y=u;break}if(r!==Y)return{reset:{placement:Y}}}return{}}}};function KC(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function QC(n){return bG.some(e=>n[e]>=0)}const LG=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t,platform:i}=e,{strategy:r="referenceHidden",...s}=Uc(n,e);switch(r){case"referenceHidden":{const l=await i.detectOverflow(e,{...s,elementContext:"reference"}),u=KC(l,t.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:QC(u)}}}case"escaped":{const l=await i.detectOverflow(e,{...s,altBoundary:!0}),u=KC(l,t.floating);return{data:{escapedOffsets:u,escaped:QC(u)}}}default:return{}}}}},jO=new Set(["left","top"]);async function NG(n,e){const{placement:t,platform:i,elements:r}=n,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),l=zc(t),u=Gp(t),h=Pl(t)==="y",p=jO.has(l)?-1:1,g=s&&h?-1:1,y=Uc(e,n);let{mainAxis:b,crossAxis:x,alignmentAxis:E}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return u&&typeof E=="number"&&(x=u==="end"?E*-1:E),h?{x:x*g,y:b*p}:{x:b*p,y:x*g}}const UG=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;const{x:r,y:s,placement:l,middlewareData:u}=e,h=await NG(e,n);return l===((t=u.offset)==null?void 0:t.placement)&&(i=u.arrow)!=null&&i.alignmentOffset?{}:{x:r+h.x,y:s+h.y,data:{...h,placement:l}}}}},zG=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:r,platform:s}=e,{mainAxis:l=!0,crossAxis:u=!1,limiter:h={fn:M=>{let{x:R,y:O}=M;return{x:R,y:O}}},...p}=Uc(n,e),g={x:t,y:i},y=await s.detectOverflow(e,p),b=Pl(zc(r)),x=lT(b);let E=g[x],A=g[b];if(l){const M=x==="y"?"top":"left",R=x==="y"?"bottom":"right",O=E+y[M],D=E-y[R];E=VM(O,E,D)}if(u){const M=b==="y"?"top":"left",R=b==="y"?"bottom":"right",O=A+y[M],D=A-y[R];A=VM(O,A,D)}const T=h.fn({...e,[x]:E,[b]:A});return{...T,data:{x:T.x-t,y:T.y-i,enabled:{[x]:l,[b]:u}}}}}},FG=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:i,placement:r,rects:s,middlewareData:l}=e,{offset:u=0,mainAxis:h=!0,crossAxis:p=!0}=Uc(n,e),g={x:t,y:i},y=Pl(r),b=lT(y);let x=g[b],E=g[y];const A=Uc(u,e),T=typeof A=="number"?{mainAxis:A,crossAxis:0}:{mainAxis:0,crossAxis:0,...A};if(h){const O=b==="y"?"height":"width",D=s.reference[b]-s.floating[O]+T.mainAxis,F=s.reference[b]+s.reference[O]-T.mainAxis;xF&&(x=F)}if(p){var M,R;const O=b==="y"?"width":"height",D=jO.has(zc(r)),F=s.reference[y]-s.floating[O]+(D&&((M=l.offset)==null?void 0:M[y])||0)+(D?0:T.crossAxis),U=s.reference[y]+s.reference[O]+(D?0:((R=l.offset)==null?void 0:R[y])||0)-(D?T.crossAxis:0);EU&&(E=U)}return{[b]:x,[y]:E}}}},BG=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,i;const{placement:r,rects:s,platform:l,elements:u}=e,{apply:h=()=>{},...p}=Uc(n,e),g=await l.detectOverflow(e,p),y=zc(r),b=Gp(r),x=Pl(r)==="y",{width:E,height:A}=s.floating;let T,M;y==="top"||y==="bottom"?(T=y,M=b===(await(l.isRTL==null?void 0:l.isRTL(u.floating))?"start":"end")?"left":"right"):(M=y,T=b==="end"?"top":"bottom");const R=A-g.top-g.bottom,O=E-g.left-g.right,D=Ku(A-g[T],R),F=Ku(E-g[M],O),U=!e.middlewareData.shift;let k=D,H=F;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(H=O),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(k=R),U&&!b){const z=Ls(g.left,0),W=Ls(g.right,0),J=Ls(g.top,0),$=Ls(g.bottom,0);x?H=E-2*(z!==0||W!==0?z+W:Ls(g.left,g.right)):k=A-2*(J!==0||$!==0?J+$:Ls(g.top,g.bottom))}await h({...e,availableWidth:H,availableHeight:k});const L=await l.getDimensions(u.floating);return E!==L.width||A!==L.height?{reset:{rects:!0}}:{}}}};function H_(){return typeof window<"u"}function Wp(n){return qO(n)?(n.nodeName||"").toLowerCase():"#document"}function Fs(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Vl(n){var e;return(e=(qO(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function qO(n){return H_()?n instanceof Node||n instanceof Fs(n).Node:!1}function Zo(n){return H_()?n instanceof Element||n instanceof Fs(n).Element:!1}function kl(n){return H_()?n instanceof HTMLElement||n instanceof Fs(n).HTMLElement:!1}function JC(n){return!H_()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Fs(n).ShadowRoot}const kG=new Set(["inline","contents"]);function V0(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=Ko(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!kG.has(r)}const HG=new Set(["table","td","th"]);function VG(n){return HG.has(Wp(n))}const GG=[":popover-open",":modal"];function V_(n){return GG.some(e=>{try{return n.matches(e)}catch{return!1}})}const WG=["transform","translate","scale","rotate","perspective"],XG=["transform","translate","scale","rotate","perspective","filter"],$G=["paint","layout","strict","content"];function fT(n){const e=dT(),t=Zo(n)?Ko(n):n;return WG.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||XG.some(i=>(t.willChange||"").includes(i))||$G.some(i=>(t.contain||"").includes(i))}function jG(n){let e=Qu(n);for(;kl(e)&&!Np(e);){if(fT(e))return e;if(V_(e))return null;e=Qu(e)}return null}function dT(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const qG=new Set(["html","body","#document"]);function Np(n){return qG.has(Wp(n))}function Ko(n){return Fs(n).getComputedStyle(n)}function G_(n){return Zo(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Qu(n){if(Wp(n)==="html")return n;const e=n.assignedSlot||n.parentNode||JC(n)&&n.host||Vl(n);return JC(e)?e.host:e}function YO(n){const e=Qu(n);return Np(e)?n.ownerDocument?n.ownerDocument.body:n.body:kl(e)&&V0(e)?e:YO(e)}function w0(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=YO(n),s=r===((i=n.ownerDocument)==null?void 0:i.body),l=Fs(r);if(s){const u=WM(l);return e.concat(l,l.visualViewport||[],V0(r)?r:[],u&&t?w0(u):[])}return e.concat(r,w0(r,[],t))}function WM(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function ZO(n){const e=Ko(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=kl(n),s=r?n.offsetWidth:t,l=r?n.offsetHeight:i,u=Bx(t)!==s||Bx(i)!==l;return u&&(t=s,i=l),{width:t,height:i,$:u}}function hT(n){return Zo(n)?n:n.contextElement}function Ep(n){const e=hT(n);if(!kl(e))return Ll(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:s}=ZO(e);let l=(s?Bx(t.width):t.width)/i,u=(s?Bx(t.height):t.height)/r;return(!l||!Number.isFinite(l))&&(l=1),(!u||!Number.isFinite(u))&&(u=1),{x:l,y:u}}const YG=Ll(0);function KO(n){const e=Fs(n);return!dT()||!e.visualViewport?YG:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ZG(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Fs(n)?!1:e}function Ad(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=hT(n);let l=Ll(1);e&&(i?Zo(i)&&(l=Ep(i)):l=Ep(n));const u=ZG(s,t,i)?KO(s):Ll(0);let h=(r.left+u.x)/l.x,p=(r.top+u.y)/l.y,g=r.width/l.x,y=r.height/l.y;if(s){const b=Fs(s),x=i&&Zo(i)?Fs(i):i;let E=b,A=WM(E);for(;A&&i&&x!==E;){const T=Ep(A),M=A.getBoundingClientRect(),R=Ko(A),O=M.left+(A.clientLeft+parseFloat(R.paddingLeft))*T.x,D=M.top+(A.clientTop+parseFloat(R.paddingTop))*T.y;h*=T.x,p*=T.y,g*=T.x,y*=T.y,h+=O,p+=D,E=Fs(A),A=WM(E)}}return Hx({width:g,height:y,x:h,y:p})}function W_(n,e){const t=G_(n).scrollLeft;return e?e.left+t:Ad(Vl(n)).left+t}function QO(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-W_(n,t),r=t.top+e.scrollTop;return{x:i,y:r}}function KG(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const s=r==="fixed",l=Vl(i),u=e?V_(e.floating):!1;if(i===l||u&&s)return t;let h={scrollLeft:0,scrollTop:0},p=Ll(1);const g=Ll(0),y=kl(i);if((y||!y&&!s)&&((Wp(i)!=="body"||V0(l))&&(h=G_(i)),kl(i))){const x=Ad(i);p=Ep(i),g.x=x.x+i.clientLeft,g.y=x.y+i.clientTop}const b=l&&!y&&!s?QO(l,h):Ll(0);return{width:t.width*p.x,height:t.height*p.y,x:t.x*p.x-h.scrollLeft*p.x+g.x+b.x,y:t.y*p.y-h.scrollTop*p.y+g.y+b.y}}function QG(n){return Array.from(n.getClientRects())}function JG(n){const e=Vl(n),t=G_(n),i=n.ownerDocument.body,r=Ls(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=Ls(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-t.scrollLeft+W_(n);const u=-t.scrollTop;return Ko(i).direction==="rtl"&&(l+=Ls(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:l,y:u}}const eR=25;function e9(n,e){const t=Fs(n),i=Vl(n),r=t.visualViewport;let s=i.clientWidth,l=i.clientHeight,u=0,h=0;if(r){s=r.width,l=r.height;const g=dT();(!g||g&&e==="fixed")&&(u=r.offsetLeft,h=r.offsetTop)}const p=W_(i);if(p<=0){const g=i.ownerDocument,y=g.body,b=getComputedStyle(y),x=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,E=Math.abs(i.clientWidth-y.clientWidth-x);E<=eR&&(s-=E)}else p<=eR&&(s+=p);return{width:s,height:l,x:u,y:h}}const t9=new Set(["absolute","fixed"]);function n9(n,e){const t=Ad(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,s=kl(n)?Ep(n):Ll(1),l=n.clientWidth*s.x,u=n.clientHeight*s.y,h=r*s.x,p=i*s.y;return{width:l,height:u,x:h,y:p}}function tR(n,e,t){let i;if(e==="viewport")i=e9(n,t);else if(e==="document")i=JG(Vl(n));else if(Zo(e))i=n9(e,t);else{const r=KO(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Hx(i)}function JO(n,e){const t=Qu(n);return t===e||!Zo(t)||Np(t)?!1:Ko(t).position==="fixed"||JO(t,e)}function i9(n,e){const t=e.get(n);if(t)return t;let i=w0(n,[],!1).filter(u=>Zo(u)&&Wp(u)!=="body"),r=null;const s=Ko(n).position==="fixed";let l=s?Qu(n):n;for(;Zo(l)&&!Np(l);){const u=Ko(l),h=fT(l);!h&&u.position==="fixed"&&(r=null),(s?!h&&!r:!h&&u.position==="static"&&!!r&&t9.has(r.position)||V0(l)&&!h&&JO(n,l))?i=i.filter(g=>g!==l):r=u,l=Qu(l)}return e.set(n,i),i}function r9(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const l=[...t==="clippingAncestors"?V_(e)?[]:i9(e,this._c):[].concat(t),i],u=l[0],h=l.reduce((p,g)=>{const y=tR(e,g,r);return p.top=Ls(y.top,p.top),p.right=Ku(y.right,p.right),p.bottom=Ku(y.bottom,p.bottom),p.left=Ls(y.left,p.left),p},tR(e,u,r));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}}function a9(n){const{width:e,height:t}=ZO(n);return{width:e,height:t}}function s9(n,e,t){const i=kl(e),r=Vl(e),s=t==="fixed",l=Ad(n,!0,s,e);let u={scrollLeft:0,scrollTop:0};const h=Ll(0);function p(){h.x=W_(r)}if(i||!i&&!s)if((Wp(e)!=="body"||V0(r))&&(u=G_(e)),i){const x=Ad(e,!0,s,e);h.x=x.x+e.clientLeft,h.y=x.y+e.clientTop}else r&&p();s&&!i&&r&&p();const g=r&&!i&&!s?QO(r,u):Ll(0),y=l.left+u.scrollLeft-h.x-g.x,b=l.top+u.scrollTop-h.y-g.y;return{x:y,y:b,width:l.width,height:l.height}}function F1(n){return Ko(n).position==="static"}function nR(n,e){if(!kl(n)||Ko(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Vl(n)===t&&(t=t.ownerDocument.body),t}function eI(n,e){const t=Fs(n);if(V_(n))return t;if(!kl(n)){let r=Qu(n);for(;r&&!Np(r);){if(Zo(r)&&!F1(r))return r;r=Qu(r)}return t}let i=nR(n,e);for(;i&&VG(i)&&F1(i);)i=nR(i,e);return i&&Np(i)&&F1(i)&&!fT(i)?t:i||jG(n)||t}const o9=async function(n){const e=this.getOffsetParent||eI,t=this.getDimensions,i=await t(n.floating);return{reference:s9(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function l9(n){return Ko(n).direction==="rtl"}const c9={convertOffsetParentRelativeRectToViewportRelativeRect:KG,getDocumentElement:Vl,getClippingRect:r9,getOffsetParent:eI,getElementRects:o9,getClientRects:QG,getDimensions:a9,getScale:Ep,isElement:Zo,isRTL:l9};function tI(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function u9(n,e){let t=null,i;const r=Vl(n);function s(){var u;clearTimeout(i),(u=t)==null||u.disconnect(),t=null}function l(u,h){u===void 0&&(u=!1),h===void 0&&(h=1),s();const p=n.getBoundingClientRect(),{left:g,top:y,width:b,height:x}=p;if(u||e(),!b||!x)return;const E=Tb(y),A=Tb(r.clientWidth-(g+b)),T=Tb(r.clientHeight-(y+x)),M=Tb(g),O={rootMargin:-E+"px "+-A+"px "+-T+"px "+-M+"px",threshold:Ls(0,Ku(1,h))||1};let D=!0;function F(U){const k=U[0].intersectionRatio;if(k!==h){if(!D)return l();k?l(!1,k):i=setTimeout(()=>{l(!1,1e-7)},1e3)}k===1&&!tI(p,n.getBoundingClientRect())&&l(),D=!1}try{t=new IntersectionObserver(F,{...O,root:r.ownerDocument})}catch{t=new IntersectionObserver(F,O)}t.observe(n)}return l(!0),s}function f9(n,e,t,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:h=!1}=i,p=hT(n),g=r||s?[...p?w0(p):[],...w0(e)]:[];g.forEach(M=>{r&&M.addEventListener("scroll",t,{passive:!0}),s&&M.addEventListener("resize",t)});const y=p&&u?u9(p,t):null;let b=-1,x=null;l&&(x=new ResizeObserver(M=>{let[R]=M;R&&R.target===p&&x&&(x.unobserve(e),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var O;(O=x)==null||O.observe(e)})),t()}),p&&!h&&x.observe(p),x.observe(e));let E,A=h?Ad(n):null;h&&T();function T(){const M=Ad(n);A&&!tI(A,M)&&t(),A=M,E=requestAnimationFrame(T)}return t(),()=>{var M;g.forEach(R=>{r&&R.removeEventListener("scroll",t),s&&R.removeEventListener("resize",t)}),y?.(),(M=x)==null||M.disconnect(),x=null,h&&cancelAnimationFrame(E)}}const d9=UG,h9=zG,p9=PG,m9=BG,g9=LG,iR=IG,v9=FG,y9=(n,e,t)=>{const i=new Map,r={platform:c9,...t},s={...r.platform,_c:i};return OG(n,e,{...r,platform:s})};var b9=typeof document<"u",x9=function(){},Bb=b9?P.useLayoutEffect:x9;function Vx(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,i,r;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!Vx(n[i],e[i]))return!1;return!0}if(r=Object.keys(n),t=r.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=t;i--!==0;){const s=r[i];if(!(s==="_owner"&&n.$$typeof)&&!Vx(n[s],e[s]))return!1}return!0}return n!==n&&e!==e}function nI(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function rR(n,e){const t=nI(n);return Math.round(e*t)/t}function B1(n){const e=P.useRef(n);return Bb(()=>{e.current=n}),e}function _9(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:i=[],platform:r,elements:{reference:s,floating:l}={},transform:u=!0,whileElementsMounted:h,open:p}=n,[g,y]=P.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[b,x]=P.useState(i);Vx(b,i)||x(i);const[E,A]=P.useState(null),[T,M]=P.useState(null),R=P.useCallback(ie=>{ie!==U.current&&(U.current=ie,A(ie))},[]),O=P.useCallback(ie=>{ie!==k.current&&(k.current=ie,M(ie))},[]),D=s||E,F=l||T,U=P.useRef(null),k=P.useRef(null),H=P.useRef(g),L=h!=null,z=B1(h),W=B1(r),J=B1(p),$=P.useCallback(()=>{if(!U.current||!k.current)return;const ie={placement:e,strategy:t,middleware:b};W.current&&(ie.platform=W.current),y9(U.current,k.current,ie).then(ge=>{const xe={...ge,isPositioned:J.current!==!1};oe.current&&!Vx(H.current,xe)&&(H.current=xe,Jx.flushSync(()=>{y(xe)}))})},[b,e,t,W,J]);Bb(()=>{p===!1&&H.current.isPositioned&&(H.current.isPositioned=!1,y(ie=>({...ie,isPositioned:!1})))},[p]);const oe=P.useRef(!1);Bb(()=>(oe.current=!0,()=>{oe.current=!1}),[]),Bb(()=>{if(D&&(U.current=D),F&&(k.current=F),D&&F){if(z.current)return z.current(D,F,$);$()}},[D,F,$,z,L]);const ne=P.useMemo(()=>({reference:U,floating:k,setReference:R,setFloating:O}),[R,O]),Y=P.useMemo(()=>({reference:D,floating:F}),[D,F]),K=P.useMemo(()=>{const ie={position:t,left:0,top:0};if(!Y.floating)return ie;const ge=rR(Y.floating,g.x),xe=rR(Y.floating,g.y);return u?{...ie,transform:"translate("+ge+"px, "+xe+"px)",...nI(Y.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:ge,top:xe}},[t,u,Y.floating,g.x,g.y]);return P.useMemo(()=>({...g,update:$,refs:ne,elements:Y,floatingStyles:K}),[g,$,ne,Y,K])}const S9=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:i,padding:r}=typeof n=="function"?n(t):n;return i&&e(i)?i.current!=null?iR({element:i.current,padding:r}).fn(t):{}:i?iR({element:i,padding:r}).fn(t):{}}}},M9=(n,e)=>({...d9(n),options:[n,e]}),E9=(n,e)=>({...h9(n),options:[n,e]}),T9=(n,e)=>({...v9(n),options:[n,e]}),w9=(n,e)=>({...p9(n),options:[n,e]}),A9=(n,e)=>({...m9(n),options:[n,e]}),C9=(n,e)=>({...g9(n),options:[n,e]}),R9=(n,e)=>({...S9(n),options:[n,e]});function D9(n){const e=O9(n),t=P.forwardRef((i,r)=>{const{children:s,...l}=i,u=P.Children.toArray(s),h=u.find(P9);if(h){const p=h.props.children,g=u.map(y=>y===h?P.Children.count(p)>1?P.Children.only(null):P.isValidElement(p)?p.props.children:null:y);return xt.jsx(e,{...l,ref:r,children:P.isValidElement(p)?P.cloneElement(p,void 0,g):null})}return xt.jsx(e,{...l,ref:r,children:s})});return t.displayName=`${n}.Slot`,t}function O9(n){const e=P.forwardRef((t,i)=>{const{children:r,...s}=t;if(P.isValidElement(r)){const l=N9(r),u=L9(s,r.props);return r.type!==P.Fragment&&(u.ref=i?Ld(i,l):l),P.cloneElement(r,u)}return P.Children.count(r)>1?P.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var I9=Symbol("radix.slottable");function P9(n){return P.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===I9}function L9(n,e){const t={...e};for(const i in e){const r=n[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?t[i]=(...u)=>{const h=s(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...s}:i==="className"&&(t[i]=[r,s].filter(Boolean).join(" "))}return{...n,...t}}function N9(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var U9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],z9=U9.reduce((n,e)=>{const t=D9(`Primitive.${e}`),i=P.forwardRef((r,s)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),xt.jsx(h,{...u,ref:s})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),F9="Arrow",iI=P.forwardRef((n,e)=>{const{children:t,width:i=10,height:r=5,...s}=n;return xt.jsx(z9.svg,{...s,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:xt.jsx("polygon",{points:"0,0 30,0 15,10"})})});iI.displayName=F9;var B9=iI;function k9(n){const e=H9(n),t=P.forwardRef((i,r)=>{const{children:s,...l}=i,u=P.Children.toArray(s),h=u.find(G9);if(h){const p=h.props.children,g=u.map(y=>y===h?P.Children.count(p)>1?P.Children.only(null):P.isValidElement(p)?p.props.children:null:y);return xt.jsx(e,{...l,ref:r,children:P.isValidElement(p)?P.cloneElement(p,void 0,g):null})}return xt.jsx(e,{...l,ref:r,children:s})});return t.displayName=`${n}.Slot`,t}function H9(n){const e=P.forwardRef((t,i)=>{const{children:r,...s}=t;if(P.isValidElement(r)){const l=X9(r),u=W9(s,r.props);return r.type!==P.Fragment&&(u.ref=i?Ld(i,l):l),P.cloneElement(r,u)}return P.Children.count(r)>1?P.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var V9=Symbol("radix.slottable");function G9(n){return P.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===V9}function W9(n,e){const t={...e};for(const i in e){const r=n[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?t[i]=(...u)=>{const h=s(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...s}:i==="className"&&(t[i]=[r,s].filter(Boolean).join(" "))}return{...n,...t}}function X9(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var $9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],rI=$9.reduce((n,e)=>{const t=k9(`Primitive.${e}`),i=P.forwardRef((r,s)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),xt.jsx(h,{...u,ref:s})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function j9(n){const[e,t]=P.useState(void 0);return Zu(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const s=r[0];let l,u;if("borderBoxSize"in s){const h=s.borderBoxSize,p=Array.isArray(h)?h[0]:h;l=p.inlineSize,u=p.blockSize}else l=n.offsetWidth,u=n.offsetHeight;t({width:l,height:u})});return i.observe(n,{box:"border-box"}),()=>i.unobserve(n)}else t(void 0)},[n]),e}var pT="Popper",[aI,sI]=HO(pT),[q9,oI]=aI(pT),lI=n=>{const{__scopePopper:e,children:t}=n,[i,r]=P.useState(null);return xt.jsx(q9,{scope:e,anchor:i,onAnchorChange:r,children:t})};lI.displayName=pT;var cI="PopperAnchor",uI=P.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:i,...r}=n,s=oI(cI,t),l=P.useRef(null),u=Nd(e,l),h=P.useRef(null);return P.useEffect(()=>{const p=h.current;h.current=i?.current||l.current,p!==h.current&&s.onAnchorChange(h.current)}),i?null:xt.jsx(rI.div,{...r,ref:u})});uI.displayName=cI;var mT="PopperContent",[Y9,Z9]=aI(mT),fI=P.forwardRef((n,e)=>{const{__scopePopper:t,side:i="bottom",sideOffset:r=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:h=!0,collisionBoundary:p=[],collisionPadding:g=0,sticky:y="partial",hideWhenDetached:b=!1,updatePositionStrategy:x="optimized",onPlaced:E,...A}=n,T=oI(mT,t),[M,R]=P.useState(null),O=Nd(e,Oe=>R(Oe)),[D,F]=P.useState(null),U=j9(D),k=U?.width??0,H=U?.height??0,L=i+(s!=="center"?"-"+s:""),z=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},W=Array.isArray(p)?p:[p],J=W.length>0,$={padding:z,boundary:W.filter(Q9),altBoundary:J},{refs:oe,floatingStyles:ne,placement:Y,isPositioned:K,middlewareData:ie}=_9({strategy:"fixed",placement:L,whileElementsMounted:(...Oe)=>f9(...Oe,{animationFrame:x==="always"}),elements:{reference:T.anchor},middleware:[M9({mainAxis:r+H,alignmentAxis:l}),h&&E9({mainAxis:!0,crossAxis:!1,limiter:y==="partial"?T9():void 0,...$}),h&&w9({...$}),A9({...$,apply:({elements:Oe,rects:it,availableWidth:gt,availableHeight:_t})=>{const{width:jt,height:pt}=it.reference,mt=Oe.floating.style;mt.setProperty("--radix-popper-available-width",`${gt}px`),mt.setProperty("--radix-popper-available-height",`${_t}px`),mt.setProperty("--radix-popper-anchor-width",`${jt}px`),mt.setProperty("--radix-popper-anchor-height",`${pt}px`)}}),D&&R9({element:D,padding:u}),J9({arrowWidth:k,arrowHeight:H}),b&&C9({strategy:"referenceHidden",...$})]}),[ge,xe]=pI(Y),q=k_(E);Zu(()=>{K&&q?.()},[K,q]);const ce=ie.arrow?.x,Se=ie.arrow?.y,Ge=ie.arrow?.centerOffset!==0,[Ye,ve]=P.useState();return Zu(()=>{M&&ve(window.getComputedStyle(M).zIndex)},[M]),xt.jsx("div",{ref:oe.setFloating,"data-radix-popper-content-wrapper":"",style:{...ne,transform:K?ne.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ye,"--radix-popper-transform-origin":[ie.transformOrigin?.x,ie.transformOrigin?.y].join(" "),...ie.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:xt.jsx(Y9,{scope:t,placedSide:ge,onArrowChange:F,arrowX:ce,arrowY:Se,shouldHideArrow:Ge,children:xt.jsx(rI.div,{"data-side":ge,"data-align":xe,...A,ref:O,style:{...A.style,animation:K?void 0:"none"}})})})});fI.displayName=mT;var dI="PopperArrow",K9={top:"bottom",right:"left",bottom:"top",left:"right"},hI=P.forwardRef(function(e,t){const{__scopePopper:i,...r}=e,s=Z9(dI,i),l=K9[s.placedSide];return xt.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:xt.jsx(B9,{...r,ref:t,style:{...r.style,display:"block"}})})});hI.displayName=dI;function Q9(n){return n!==null}var J9=n=>({name:"transformOrigin",options:n,fn(e){const{placement:t,rects:i,middlewareData:r}=e,l=r.arrow?.centerOffset!==0,u=l?0:n.arrowWidth,h=l?0:n.arrowHeight,[p,g]=pI(t),y={start:"0%",center:"50%",end:"100%"}[g],b=(r.arrow?.x??0)+u/2,x=(r.arrow?.y??0)+h/2;let E="",A="";return p==="bottom"?(E=l?y:`${b}px`,A=`${-h}px`):p==="top"?(E=l?y:`${b}px`,A=`${i.floating.height+h}px`):p==="right"?(E=`${-h}px`,A=l?y:`${x}px`):p==="left"&&(E=`${i.floating.width+h}px`,A=l?y:`${x}px`),{data:{x:E,y:A}}}});function pI(n){const[e,t="center"]=n.split("-");return[e,t]}var e7=lI,t7=uI,n7=fI,i7=hI;function r7(n){const e=a7(n),t=P.forwardRef((i,r)=>{const{children:s,...l}=i,u=P.Children.toArray(s),h=u.find(o7);if(h){const p=h.props.children,g=u.map(y=>y===h?P.Children.count(p)>1?P.Children.only(null):P.isValidElement(p)?p.props.children:null:y);return xt.jsx(e,{...l,ref:r,children:P.isValidElement(p)?P.cloneElement(p,void 0,g):null})}return xt.jsx(e,{...l,ref:r,children:s})});return t.displayName=`${n}.Slot`,t}function a7(n){const e=P.forwardRef((t,i)=>{const{children:r,...s}=t;if(P.isValidElement(r)){const l=c7(r),u=l7(s,r.props);return r.type!==P.Fragment&&(u.ref=i?Ld(i,l):l),P.cloneElement(r,u)}return P.Children.count(r)>1?P.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var mI=Symbol("radix.slottable");function s7(n){const e=({children:t})=>xt.jsx(xt.Fragment,{children:t});return e.displayName=`${n}.Slottable`,e.__radixId=mI,e}function o7(n){return P.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===mI}function l7(n,e){const t={...e};for(const i in e){const r=n[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?t[i]=(...u)=>{const h=s(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...s}:i==="className"&&(t[i]=[r,s].filter(Boolean).join(" "))}return{...n,...t}}function c7(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var u7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],f7=u7.reduce((n,e)=>{const t=r7(`Primitive.${e}`),i=P.forwardRef((r,s)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),xt.jsx(h,{...u,ref:s})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function d7(n,e){return P.useReducer((t,i)=>e[t][i]??t,n)}var gI=n=>{const{present:e,children:t}=n,i=h7(e),r=typeof t=="function"?t({present:i.isPresent}):P.Children.only(t),s=Nd(i.ref,p7(r));return typeof t=="function"||i.isPresent?P.cloneElement(r,{ref:s}):null};gI.displayName="Presence";function h7(n){const[e,t]=P.useState(),i=P.useRef(null),r=P.useRef(n),s=P.useRef("none"),l=n?"mounted":"unmounted",[u,h]=d7(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return P.useEffect(()=>{const p=wb(i.current);s.current=u==="mounted"?p:"none"},[u]),Zu(()=>{const p=i.current,g=r.current;if(g!==n){const b=s.current,x=wb(p);n?h("MOUNT"):x==="none"||p?.display==="none"?h("UNMOUNT"):h(g&&b!==x?"ANIMATION_OUT":"UNMOUNT"),r.current=n}},[n,h]),Zu(()=>{if(e){let p;const g=e.ownerDocument.defaultView??window,y=x=>{const A=wb(i.current).includes(CSS.escape(x.animationName));if(x.target===e&&A&&(h("ANIMATION_END"),!r.current)){const T=e.style.animationFillMode;e.style.animationFillMode="forwards",p=g.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=T)})}},b=x=>{x.target===e&&(s.current=wb(i.current))};return e.addEventListener("animationstart",b),e.addEventListener("animationcancel",y),e.addEventListener("animationend",y),()=>{g.clearTimeout(p),e.removeEventListener("animationstart",b),e.removeEventListener("animationcancel",y),e.removeEventListener("animationend",y)}}else h("ANIMATION_END")},[e,h]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:P.useCallback(p=>{i.current=p?getComputedStyle(p):null,t(p)},[])}}function wb(n){return n?.animationName||"none"}function p7(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var m7=sE[" useInsertionEffect ".trim().toString()]||Zu;function g7({prop:n,defaultProp:e,onChange:t=()=>{},caller:i}){const[r,s,l]=v7({defaultProp:e,onChange:t}),u=n!==void 0,h=u?n:r;{const g=P.useRef(n!==void 0);P.useEffect(()=>{const y=g.current;y!==u&&console.warn(`${i} is changing from ${y?"controlled":"uncontrolled"} to ${u?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),g.current=u},[u,i])}const p=P.useCallback(g=>{if(u){const y=y7(g)?g(n):g;y!==n&&l.current?.(y)}else s(g)},[u,n,s,l]);return[h,p]}function v7({defaultProp:n,onChange:e}){const[t,i]=P.useState(n),r=P.useRef(t),s=P.useRef(e);return m7(()=>{s.current=e},[e]),P.useEffect(()=>{r.current!==t&&(s.current?.(t),r.current=t)},[t,r]),[t,i,s]}function y7(n){return typeof n=="function"}function b7(n){const e=x7(n),t=P.forwardRef((i,r)=>{const{children:s,...l}=i,u=P.Children.toArray(s),h=u.find(S7);if(h){const p=h.props.children,g=u.map(y=>y===h?P.Children.count(p)>1?P.Children.only(null):P.isValidElement(p)?p.props.children:null:y);return xt.jsx(e,{...l,ref:r,children:P.isValidElement(p)?P.cloneElement(p,void 0,g):null})}return xt.jsx(e,{...l,ref:r,children:s})});return t.displayName=`${n}.Slot`,t}function x7(n){const e=P.forwardRef((t,i)=>{const{children:r,...s}=t;if(P.isValidElement(r)){const l=E7(r),u=M7(s,r.props);return r.type!==P.Fragment&&(u.ref=i?Ld(i,l):l),P.cloneElement(r,u)}return P.Children.count(r)>1?P.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var _7=Symbol("radix.slottable");function S7(n){return P.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===_7}function M7(n,e){const t={...e};for(const i in e){const r=n[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?t[i]=(...u)=>{const h=s(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...s}:i==="className"&&(t[i]=[r,s].filter(Boolean).join(" "))}return{...n,...t}}function E7(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var T7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],w7=T7.reduce((n,e)=>{const t=b7(`Primitive.${e}`),i=P.forwardRef((r,s)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),xt.jsx(h,{...u,ref:s})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),A7=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),C7="VisuallyHidden",vI=P.forwardRef((n,e)=>xt.jsx(w7.span,{...n,ref:e,style:{...A7,...n.style}}));vI.displayName=C7;var R7=vI,[X_]=HO("Tooltip",[sI]),$_=sI(),yI="TooltipProvider",D7=700,XM="tooltip.open",[O7,gT]=X_(yI),bI=n=>{const{__scopeTooltip:e,delayDuration:t=D7,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=n,l=P.useRef(!0),u=P.useRef(!1),h=P.useRef(0);return P.useEffect(()=>{const p=h.current;return()=>window.clearTimeout(p)},[]),xt.jsx(O7,{scope:e,isOpenDelayedRef:l,delayDuration:t,onOpen:P.useCallback(()=>{window.clearTimeout(h.current),l.current=!1},[]),onClose:P.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>l.current=!0,i)},[i]),isPointerInTransitRef:u,onPointerInTransitChange:P.useCallback(p=>{u.current=p},[]),disableHoverableContent:r,children:s})};bI.displayName=yI;var A0="Tooltip",[I7,j_]=X_(A0),xI=n=>{const{__scopeTooltip:e,children:t,open:i,defaultOpen:r,onOpenChange:s,disableHoverableContent:l,delayDuration:u}=n,h=gT(A0,n.__scopeTooltip),p=$_(e),[g,y]=P.useState(null),b=yG(),x=P.useRef(0),E=l??h.disableHoverableContent,A=u??h.delayDuration,T=P.useRef(!1),[M,R]=g7({prop:i,defaultProp:r??!1,onChange:k=>{k?(h.onOpen(),document.dispatchEvent(new CustomEvent(XM))):h.onClose(),s?.(k)},caller:A0}),O=P.useMemo(()=>M?T.current?"delayed-open":"instant-open":"closed",[M]),D=P.useCallback(()=>{window.clearTimeout(x.current),x.current=0,T.current=!1,R(!0)},[R]),F=P.useCallback(()=>{window.clearTimeout(x.current),x.current=0,R(!1)},[R]),U=P.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{T.current=!0,R(!0),x.current=0},A)},[A,R]);return P.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),xt.jsx(e7,{...p,children:xt.jsx(I7,{scope:e,contentId:b,open:M,stateAttribute:O,trigger:g,onTriggerChange:y,onTriggerEnter:P.useCallback(()=>{h.isOpenDelayedRef.current?U():D()},[h.isOpenDelayedRef,U,D]),onTriggerLeave:P.useCallback(()=>{E?F():(window.clearTimeout(x.current),x.current=0)},[F,E]),onOpen:D,onClose:F,disableHoverableContent:E,children:t})})};xI.displayName=A0;var $M="TooltipTrigger",_I=P.forwardRef((n,e)=>{const{__scopeTooltip:t,...i}=n,r=j_($M,t),s=gT($M,t),l=$_(t),u=P.useRef(null),h=Nd(e,u,r.onTriggerChange),p=P.useRef(!1),g=P.useRef(!1),y=P.useCallback(()=>p.current=!1,[]);return P.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),xt.jsx(t7,{asChild:!0,...l,children:xt.jsx(f7.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...i,ref:h,onPointerMove:wc(n.onPointerMove,b=>{b.pointerType!=="touch"&&!g.current&&!s.isPointerInTransitRef.current&&(r.onTriggerEnter(),g.current=!0)}),onPointerLeave:wc(n.onPointerLeave,()=>{r.onTriggerLeave(),g.current=!1}),onPointerDown:wc(n.onPointerDown,()=>{r.open&&r.onClose(),p.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:wc(n.onFocus,()=>{p.current||r.onOpen()}),onBlur:wc(n.onBlur,r.onClose),onClick:wc(n.onClick,r.onClose)})})});_I.displayName=$M;var P7="TooltipPortal",[tZ,L7]=X_(P7,{forceMount:void 0}),Up="TooltipContent",SI=P.forwardRef((n,e)=>{const t=L7(Up,n.__scopeTooltip),{forceMount:i=t.forceMount,side:r="top",...s}=n,l=j_(Up,n.__scopeTooltip);return xt.jsx(gI,{present:i||l.open,children:l.disableHoverableContent?xt.jsx(MI,{side:r,...s,ref:e}):xt.jsx(N7,{side:r,...s,ref:e})})}),N7=P.forwardRef((n,e)=>{const t=j_(Up,n.__scopeTooltip),i=gT(Up,n.__scopeTooltip),r=P.useRef(null),s=Nd(e,r),[l,u]=P.useState(null),{trigger:h,onClose:p}=t,g=r.current,{onPointerInTransitChange:y}=i,b=P.useCallback(()=>{u(null),y(!1)},[y]),x=P.useCallback((E,A)=>{const T=E.currentTarget,M={x:E.clientX,y:E.clientY},R=B7(M,T.getBoundingClientRect()),O=k7(M,R),D=H7(A.getBoundingClientRect()),F=G7([...O,...D]);u(F),y(!0)},[y]);return P.useEffect(()=>()=>b(),[b]),P.useEffect(()=>{if(h&&g){const E=T=>x(T,g),A=T=>x(T,h);return h.addEventListener("pointerleave",E),g.addEventListener("pointerleave",A),()=>{h.removeEventListener("pointerleave",E),g.removeEventListener("pointerleave",A)}}},[h,g,x,b]),P.useEffect(()=>{if(l){const E=A=>{const T=A.target,M={x:A.clientX,y:A.clientY},R=h?.contains(T)||g?.contains(T),O=!V7(M,l);R?b():O&&(b(),p())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[h,g,l,p,b]),xt.jsx(MI,{...n,ref:s})}),[U7,z7]=X_(A0,{isInside:!1}),F7=s7("TooltipContent"),MI=P.forwardRef((n,e)=>{const{__scopeTooltip:t,children:i,"aria-label":r,onEscapeKeyDown:s,onPointerDownOutside:l,...u}=n,h=j_(Up,t),p=$_(t),{onClose:g}=h;return P.useEffect(()=>(document.addEventListener(XM,g),()=>document.removeEventListener(XM,g)),[g]),P.useEffect(()=>{if(h.trigger){const y=b=>{b.target?.contains(h.trigger)&&g()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[h.trigger,g]),xt.jsx(WO,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:y=>y.preventDefault(),onDismiss:g,children:xt.jsxs(n7,{"data-state":h.stateAttribute,...p,...u,ref:e,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[xt.jsx(F7,{children:i}),xt.jsx(U7,{scope:t,isInside:!0,children:xt.jsx(R7,{id:h.contentId,role:"tooltip",children:r||i})})]})})});SI.displayName=Up;var EI="TooltipArrow",TI=P.forwardRef((n,e)=>{const{__scopeTooltip:t,...i}=n,r=$_(t);return z7(EI,t).isInside?null:xt.jsx(i7,{...r,...i,ref:e})});TI.displayName=EI;function B7(n,e){const t=Math.abs(e.top-n.y),i=Math.abs(e.bottom-n.y),r=Math.abs(e.right-n.x),s=Math.abs(e.left-n.x);switch(Math.min(t,i,r,s)){case s:return"left";case r:return"right";case t:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function k7(n,e,t=5){const i=[];switch(e){case"top":i.push({x:n.x-t,y:n.y+t},{x:n.x+t,y:n.y+t});break;case"bottom":i.push({x:n.x-t,y:n.y-t},{x:n.x+t,y:n.y-t});break;case"left":i.push({x:n.x+t,y:n.y-t},{x:n.x+t,y:n.y+t});break;case"right":i.push({x:n.x-t,y:n.y-t},{x:n.x-t,y:n.y+t});break}return i}function H7(n){const{top:e,right:t,bottom:i,left:r}=n;return[{x:r,y:e},{x:t,y:e},{x:t,y:i},{x:r,y:i}]}function V7(n,e){const{x:t,y:i}=n;let r=!1;for(let s=0,l=e.length-1;si!=b>i&&t<(y-p)*(i-g)/(b-g)+p&&(r=!r)}return r}function G7(n){const e=n.slice();return e.sort((t,i)=>t.xi.x?1:t.yi.y?1:0),W7(e)}function W7(n){if(n.length<=1)return n.slice();const e=[];for(let i=0;i=2;){const s=e[e.length-1],l=e[e.length-2];if((s.x-l.x)*(r.y-l.y)>=(s.y-l.y)*(r.x-l.x))e.pop();else break}e.push(r)}e.pop();const t=[];for(let i=n.length-1;i>=0;i--){const r=n[i];for(;t.length>=2;){const s=t[t.length-1],l=t[t.length-2];if((s.x-l.x)*(r.y-l.y)>=(s.y-l.y)*(r.x-l.x))t.pop();else break}t.push(r)}return t.pop(),e.length===1&&t.length===1&&e[0].x===t[0].x&&e[0].y===t[0].y?e:e.concat(t)}var X7=bI,$7=xI,j7=_I,q7=SI,Y7=TI;function Z7(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}function xi(n,e){if(n==null)return{};var t,i,r=Z7(n,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i[`An input with type \`${n}\` input was found at path \`${e}\` but it's not supported yet.`],[Cr.NO_COMPONENT_FOR_TYPE]:(n,e)=>[`Type \`${n}\` found at path \`${e}\` can't be displayed in panel because no component supports it yet.`],[Cr.UNKNOWN_INPUT]:(n,e)=>[`input at path \`${n}\` is not recognized.`,e],[Cr.DUPLICATE_KEYS]:(n,e,t)=>[`Key \`${n}\` of path \`${e}\` already exists at path \`${t}\`. Even nested keys need to be unique. Rename one of the keys.`],[Cr.ALREADY_REGISTERED_TYPE]:n=>[`Type ${n} has already been registered. You can't register a component with the same type.`],[Cr.CLIPBOARD_ERROR]:n=>["Error copying the value",n],[Cr.THEME_ERROR]:(n,e)=>[`Error accessing the theme \`${n}.${e}\` value.`],[Cr.PATH_DOESNT_EXIST]:n=>[`Error getting the value at path \`${n}\`. There is probably an error in your \`render\` function.`],[Cr.INPUT_TYPE_OVERRIDE]:(n,e,t)=>[`Input at path \`${n}\` already exists with type: \`${e}\`. Its type cannot be overridden with type \`${t}\`.`],[Cr.EMPTY_KEY]:()=>["Keys can not be empty, if you want to hide a label use whitespace."]};function wI(n,e,...t){const i=K7[e],[r,...s]=i(...t);console[n]("LEVA: "+r,...s)}const Rc=wI.bind(null,"warn"),Q7=wI.bind(null,"log"),J7=["value"],eW=["schema"],tW=["value"],AI=[],Cd={};function aR(n){let{value:e}=n,t=xi(n,J7);for(let i of AI){const r=i(e,t);if(r)return r}}function Fc(n,e){let{schema:t}=e,i=xi(e,eW);if(n in Cd){Rc(Cr.ALREADY_REGISTERED_TYPE,n);return}AI.push((r,s)=>t(r,s)&&n),Cd[n]=i}function k1(n,e,t,i){const{normalize:r}=Cd[n];if(r)return r(e,t,i);if(typeof e!="object"||!("value"in e))return{value:e};const{value:s}=e,l=xi(e,tW);return{value:s,settings:l}}function nW(n,e,t,i,r,s){const{sanitize:l}=Cd[n];return l?l(e,t,i,r,s):e}function sR(n,e,t){const{format:i}=Cd[n];return i?i(e,t):e}function iW(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function rW(n){var e=iW(n,"string");return typeof e=="symbol"?e:e+""}function aW(n,e,t){return(e=rW(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function oR(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function Yt(n){for(var e=1;en>t?t:n{if(n===""||typeof n=="number")return n;try{const e=gp(n);if(!isNaN(e))return e}catch{}return parseFloat(n)},oW=Math.log(10);function lR(n){let e=Math.abs(+String(n).replace(".",""));if(e===0)return .01;for(;e!==0&&e%10===0;)e/=10;const t=Math.floor(Math.log(e)/oW)+1,i=Math.floor(Math.log10(Math.abs(n))),r=Math.pow(10,i-t);return Math.max(r,.001)}const Gx=(n,e,t)=>t===e?0:(Ju(n,e,t)-e)/(t-e),Wx=(n,e,t)=>n*(t-e)+e,lW=()=>"_"+Math.random().toString(36).substr(2,9),cR=/\(([^\(\)]+)\)/,uR=/(-?\d+(?:\.\d+)?)\s*\^\s*(-?\d+(?:\.\d+)?)/,fR=/(-?\d+(?:\.\d+)?)\s*([*/])\s*(-?\d+(?:\.\d+)?)/,dR=/(-?\d+(?:\.\d+)?)\s*([+-])\s*(-?\d+(?:\.\d+)?)/;function gp(n){return n=n.replace(/\s+/g,""),cR.test(n)?gp(n.replace(cR,(e,t)=>gp(t).toString())):uR.test(n)?gp(n.replace(uR,(e,t,i)=>Math.pow(Number(t),Number(i)).toString())):fR.test(n)?gp(n.replace(fR,(e,t,i,r)=>i==="*"?(Number(t)*Number(r)).toString():Number(r)===0?(()=>{throw new Error("Division by zero")})():(Number(t)/Number(r)).toString())):dR.test(n)?gp(n.replace(dR,(e,t,i,r)=>i==="+"?(Number(t)+Number(r)).toString():(Number(t)-Number(r)).toString())):Number(n)}function cW(n,e){return e.reduce((t,i)=>(n&&n.hasOwnProperty(i)&&(t[i]=n[i]),t),{})}function uW(n,e){const t=Yt({},n);return e.forEach(i=>i in n&&delete t[i]),t}function fW(n,e){return n.reduce((t,i,r)=>Object.assign(t,{[e[r]]:i}),{})}function CI(n){return Object.prototype.toString.call(n)==="[object Object]"}const dW=n=>CI(n)&&Object.keys(n).length===0;let Yo=(function(n){return n.BUTTON="BUTTON",n.BUTTON_GROUP="BUTTON_GROUP",n.MONITOR="MONITOR",n.FOLDER="FOLDER",n})({}),Bc=(function(n){return n.SELECT="SELECT",n.IMAGE="IMAGE",n.NUMBER="NUMBER",n.COLOR="COLOR",n.STRING="STRING",n.BOOLEAN="BOOLEAN",n.INTERVAL="INTERVAL",n.VECTOR3D="VECTOR3D",n.VECTOR2D="VECTOR2D",n})({});const hW=["type","__customInput"],pW=["render","label","optional","order","disabled","hint","onChange","onEditStart","onEditEnd","transient"],mW=["type"];function RI(n,e,t={},i){var r,s;if(typeof n!="object"||Array.isArray(n))return{type:i,input:n,options:Yt({key:e,label:e,optional:!1,disabled:!1,order:0},t)};if("__customInput"in n){const{type:F,__customInput:U}=n,k=xi(n,hW);return RI(U,e,k,F)}const{render:l,label:u,optional:h,order:p=0,disabled:g,hint:y,onChange:b,onEditStart:x,onEditEnd:E,transient:A}=n,T=xi(n,pW),M=Yt({render:l,key:e,label:u??e,hint:y,transient:A??!!b,onEditStart:x,onEditEnd:E,disabled:g,optional:h,order:p},t);let{type:R}=T,O=xi(T,mW);if(R=i??R,R in Yo)return{type:R,input:O,options:M};let D;return i&&CI(O)&&"value"in O?D=O.value:D=dW(O)?void 0:O,{type:R,input:D,options:Yt(Yt({},M),{},{onChange:b,optional:(r=M.optional)!==null&&r!==void 0?r:!1,disabled:(s=M.disabled)!==null&&s!==void 0?s:!1})}}function gW(n,e,t,i){const r=RI(n,e),{type:s,input:l,options:u}=r;if(s)return s in Yo?r:{type:s,input:k1(s,l,t,i),options:u};let h=aR(l);return h?{type:h,input:k1(h,l,t,i),options:u}:(h=aR({value:l}),h?{type:h,input:k1(h,{value:l},t,i),options:u}:!1)}function hR(n,e,t,i,r){const{value:s,type:l,settings:u}=n;n.value=DI({type:l,value:s,settings:u},e,t,i),n.fromPanel=r}const vW=function(e,t,i){this.type="LEVA_ERROR",this.message="LEVA: "+e,this.previousValue=t,this.error=i};function DI({type:n,value:e,settings:t},i,r,s){const l=n!=="SELECT"&&typeof i=="function"?i(e):i;let u;try{u=nW(n,l,t,e,r,s)}catch(h){throw new vW(`The value \`${i}\` did not result in a correct value.`,e,h)}return E0(u,e)?e:u}const OI=(n,e,t=!1)=>{let i=0;return function(){const r=arguments,s=t&&!i,l=()=>n.apply(this,r);window.clearTimeout(i),i=window.setTimeout(l,e),s&&l()}},II=n=>n.shiftKey?5:n.altKey?1/5:1,yW=["value"],bW=["min","max"],xW=n=>{if(typeof n=="number")return!0;if(typeof n=="string"){const e=parseFloat(n);return isNaN(e)?!1:n.substring((""+e).length).trim().length<4}return!1},PI=(n,{min:e=-1/0,max:t=1/0,suffix:i})=>{const r=parseFloat(n);if(n===""||isNaN(r))throw Error("Invalid number");const s=Ju(r,e,t);return i?s+i:s},_W=(n,{pad:e=0,suffix:t})=>{const i=parseFloat(n).toFixed(e);return t?i+t:i},LI=n=>{let{value:e}=n,t=xi(n,yW);const{min:i=-1/0,max:r=1/0}=t,s=xi(t,bW);let l=parseFloat(e);const u=typeof e=="string"?e.substring((""+l).length):void 0;l=Ju(l,i,r);let h=t.step;h||(Number.isFinite(i)?Number.isFinite(r)?h=+(Math.abs(r-i)/100).toPrecision(1):h=+(Math.abs(l-i)/100).toPrecision(1):Number.isFinite(r)&&(h=+(Math.abs(r-l)/100).toPrecision(1)));const p=h?lR(h)*10:lR(l);h=h||p/10;const g=Math.round(Ju(Math.log10(1/p),0,2));return{value:u?l+u:l,settings:Yt({initialValue:l,step:h,pad:g,min:i,max:r,suffix:u},s)}},NI=(n,{step:e,initialValue:t})=>{const i=Math.round((n-t)/e);return t+i*e};var UI=Object.freeze({__proto__:null,schema:xW,sanitize:PI,format:_W,normalize:LI,sanitizeStep:NI});function dr(){return dr=Object.assign?Object.assign.bind():function(n){for(var e=1;e({colors:{elevation1:"#292d39",elevation2:"#181c20",elevation3:"#373c4b",accent1:"#0066dc",accent2:"#007bff",accent3:"#3c93ff",highlight1:"#535760",highlight2:"#8c92a4",highlight3:"#fefefe",vivid1:"#ffcc00",folderWidgetColor:"$highlight2",folderTextColor:"$highlight3",toolTipBackground:"$highlight3",toolTipText:"$elevation2"},radii:{xs:"2px",sm:"3px",lg:"10px"},space:{xs:"3px",sm:"6px",md:"10px",rowGap:"7px",colGap:"7px"},fonts:{mono:"ui-monospace, SFMono-Regular, Menlo, 'Roboto Mono', monospace",sans:"system-ui, sans-serif"},fontSizes:{root:"11px",toolTip:"$root"},sizes:{rootWidth:"280px",controlWidth:"160px",numberInputMinWidth:"38px",scrubberWidth:"8px",scrubberHeight:"16px",rowHeight:"24px",folderTitleHeight:"20px",checkboxSize:"16px",joystickWidth:"100px",joystickHeight:"100px",colorPickerWidth:"$controlWidth",colorPickerHeight:"100px",imagePreviewWidth:"$controlWidth",imagePreviewHeight:"100px",monitorHeight:"60px",titleBarHeight:"39px"},shadows:{level1:"0 0 9px 0 #00000088",level2:"0 4px 14px #00000033"},borderWidths:{root:"0px",input:"1px",focus:"1px",hover:"1px",active:"1px",folder:"1px"},fontWeights:{label:"normal",folder:"normal",button:"normal"}});function Ab(n,e){const[t,i]=n.split(" "),r={};return t!=="none"&&(r.boxShadow=`${e.inset?"inset ":""}0 0 0 $borderWidths${[e.key]} $colors${t!=="default"&&t||e.borderColor}`),i&&(r.backgroundColor=i),r}const Ng={$inputStyle:()=>n=>Ab(n,{key:"$input",borderColor:"$highlight1",inset:!0}),$focusStyle:()=>n=>Ab(n,{key:"$focus",borderColor:"$accent2"}),$hoverStyle:()=>n=>Ab(n,{key:"$hover",borderColor:"$accent1",inset:!0}),$activeStyle:()=>n=>Ab(n,{key:"$active",borderColor:"$accent1",inset:!0})},W0=Q8({prefix:"leva",theme:kI(),utils:Yt(Yt({},Ng),{},{$flex:()=>({display:"flex",alignItems:"center"}),$flexCenter:()=>({display:"flex",alignItems:"center",justifyContent:"center"}),$reset:()=>({outline:"none",fontSize:"inherit",fontWeight:"inherit",color:"inherit",fontFamily:"inherit",border:"none",backgroundColor:"transparent",appearance:"none"}),$draggable:()=>({touchAction:"none",WebkitUserDrag:"none",userSelect:"none"}),$focus:n=>({"&:focus":Ng.$focusStyle()(n)}),$focusWithin:n=>({"&:focus-within":Ng.$focusStyle()(n)}),$hover:n=>({"&:hover":Ng.$hoverStyle()(n)}),$active:n=>({"&:active":Ng.$activeStyle()(n)})})}),Jt=W0.styled;W0.css;const MW=W0.createTheme,EW=W0.globalCss;W0.keyframes;const TW=EW({".leva__panel__dragged":{WebkitUserDrag:"none",userSelect:"none",input:{userSelect:"none"},"*":{cursor:"ew-resize !important"}}});function wW(n){const e=kI();if(!n)return{theme:e,className:""};Object.keys(n).forEach(i=>{Object.assign(e[i],n[i])});const t=MW(e);return{theme:e,className:t.className}}function Pc(n,e){const{theme:t}=P.useContext(vT);if(!(n in t)||!(e in t[n]))return Rc(Cr.THEME_ERROR,n,e),"";let i=e;for(;;){let r=t[n][i];if(typeof r=="string"&&r.charAt(0)==="$")i=r.substr(1);else return r}}const HI=Jt("input",{$reset:"",padding:"0 $sm",width:0,minWidth:0,flex:1,height:"100%",variants:{levaType:{number:{textAlign:"right"}},as:{textarea:{padding:"$sm"}}}}),VI=Jt("div",{$draggable:"",height:"100%",$flexCenter:"",position:"relative",padding:"0 $xs",fontSize:"0.8em",opacity:.8,cursor:"default",touchAction:"none",[`& + ${HI}`]:{paddingLeft:0}}),AW=Jt(VI,{cursor:"ew-resize",marginRight:"-$xs",textTransform:"uppercase",opacity:.3,"&:hover":{opacity:1},variants:{dragging:{true:{backgroundColor:"$accent2",opacity:1}}}}),CW=Jt("div",{$flex:"",position:"relative",borderRadius:"$sm",overflow:"hidden",color:"inherit",height:"$rowHeight",backgroundColor:"$elevation3",$inputStyle:"$elevation1",$hover:"",$focusWithin:"",variants:{textArea:{true:{height:"auto"}}}}),RW=["innerLabel","value","onUpdate","onChange","onKeyDown","type","id","inputType","rows"],DW=["onUpdate"];function yT(n){let{innerLabel:e,value:t,onUpdate:i,onChange:r,onKeyDown:s,type:l,id:u,inputType:h="text",rows:p=0}=n,g=xi(n,RW);const{id:y,emitOnEditStart:b,emitOnEditEnd:x,disabled:E}=Da(),A=u||y,T=P.useRef(null),M=p>0,R=M?"textarea":"input",O=P.useCallback(U=>k=>{const H=k.currentTarget.value;U(H)},[]);ae.useEffect(()=>{const U=T.current,k=O(H=>{i(H),x()});return U?.addEventListener("blur",k),()=>U?.removeEventListener("blur",k)},[O,i,x]);const D=P.useCallback(U=>{U.key==="Enter"&&O(i)(U)},[O,i]),F=Object.assign({as:R},M?{rows:p}:{},g);return ae.createElement(CW,{textArea:M},e&&typeof e=="string"?ae.createElement(VI,null,e):e,ae.createElement(HI,dr({levaType:l,ref:T,id:A,type:h,autoComplete:"off",spellCheck:"false",value:t,onChange:O(r),onFocus:()=>b(),onKeyPress:D,onKeyDown:s,disabled:E},F)))}function OW(n){let{onUpdate:e}=n,t=xi(n,DW);const i=P.useCallback(s=>e(sW(s)),[e]),r=P.useCallback(s=>{const l=s.key==="ArrowUp"?1:s.key==="ArrowDown"?-1:0;if(l){s.preventDefault();const u=s.altKey?.1:s.shiftKey?10:1;e(h=>parseFloat(h)+l*u)}},[e]);return ae.createElement(yT,dr({},t,{onUpdate:i,onKeyDown:r,type:"number"}))}const Xx=Jt("div",{}),jM=Jt("div",{position:"relative",background:"$elevation2",transition:"height 300ms ease",variants:{fill:{true:{},false:{}},flat:{false:{},true:{}},isRoot:{true:{},false:{paddingLeft:"$md","&::after":{content:'""',position:"absolute",left:0,top:0,width:"$borderWidths$folder",height:"100%",backgroundColor:"$folderWidgetColor",opacity:.4,transform:"translateX(-50%)"}}}},compoundVariants:[{isRoot:!0,fill:!1,css:{overflowY:"auto",maxHeight:"calc(100vh - 20px - $$titleBarHeight)"}},{isRoot:!0,flat:!1,css:{borderRadius:"$lg"}}]}),IW=Jt("div",{$flex:"",color:"$folderTextColor",userSelect:"none",cursor:"pointer",height:"$folderTitleHeight",fontWeight:"$folder","> svg":{marginLeft:-4,marginRight:4,cursor:"pointer",fill:"$folderWidgetColor",opacity:.6},"&:hover > svg":{fill:"$folderWidgetColor"},[`&:hover + ${jM}::after`]:{opacity:.6},[`${Xx}:hover > & + ${jM}::after`]:{opacity:.6},[`${Xx}:hover > & > svg`]:{opacity:1}}),GI=Jt("div",{position:"relative",display:"grid",gridTemplateColumns:"100%",rowGap:"$rowGap",transition:"opacity 250ms ease",variants:{toggled:{true:{opacity:1,transitionDelay:"250ms"},false:{opacity:0,transitionDelay:"0ms",pointerEvents:"none"}},isRoot:{true:{"& > div":{paddingLeft:"$md",paddingRight:"$md"},"& > div:first-of-type":{paddingTop:"$sm"},"& > div:last-of-type":{paddingBottom:"$sm"},[`> ${Xx}:not(:first-of-type)`]:{paddingTop:"$sm",marginTop:"$md",borderTop:"$borderWidths$folder solid $colors$elevation1"}}}}}),WI=Jt("div",{position:"relative",zIndex:100,display:"grid",rowGap:"$rowGap",gridTemplateRows:"minmax($sizes$rowHeight, max-content)",alignItems:"center",color:"$highlight2",[`${GI} > &`]:{"&:first-of-type":{marginTop:"$rowGap"},"&:last-of-type":{marginBottom:"$rowGap"}},variants:{disabled:{true:{pointerEvents:"none"},false:{"&:hover,&:focus-within":{color:"$highlight3"}}}}}),XI=Jt(WI,{gridTemplateColumns:"auto $sizes$controlWidth",columnGap:"$colGap"}),PW=Jt("div",{$flex:"",height:"100%",position:"relative",overflow:"hidden","& > div":{marginLeft:"$colGap",padding:"0 $xs",opacity:.4},"& > div:hover":{opacity:.8},"& > div > svg":{display:"none",cursor:"pointer",width:13,minWidth:13,height:13,backgroundColor:"$elevation2"},"&:hover > div > svg":{display:"block"},variants:{align:{top:{height:"100%",alignItems:"flex-start",paddingTop:"$sm"}}}}),LW=Jt("input",{$reset:"",height:0,width:0,opacity:0,margin:0,"& + label":{position:"relative",$flexCenter:"",height:"100%",userSelect:"none",cursor:"pointer",paddingLeft:2,paddingRight:"$sm",pointerEvents:"auto"},"& + label:after":{content:'""',width:6,height:6,backgroundColor:"$elevation3",borderRadius:"50%",$activeStyle:""},"&:focus + label:after":{$focusStyle:""},"& + label:active:after":{backgroundColor:"$accent1",$focusStyle:""},"&:checked + label:after":{backgroundColor:"$accent1"}}),qM=Jt("label",{fontWeight:"$label",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","& > svg":{display:"block"}}),NW=Jt("div",{opacity:1,variants:{disabled:{true:{opacity:.6,pointerEvents:"none",[`& ${qM}`]:{pointerEvents:"auto"}}}}}),$I=Jt("div",{position:"fixed",top:0,bottom:0,right:0,left:0,zIndex:1e3,userSelect:"none"}),UW=Jt("div",{background:"$toolTipBackground",fontFamily:"$sans",fontSize:"$toolTip",padding:"$xs $sm",color:"$toolTipText",borderRadius:"$xs",boxShadow:"$level2",maxWidth:260}),zW=Jt(Y7,{fill:"$toolTipBackground"});function bT({children:n,container:e=(t=>globalThis==null||(t=globalThis.document)===null||t===void 0?void 0:t.body)()}){const{className:t}=P.useContext(vT);return ae.createElement(x8,{className:t,container:e},n)}const FW=["align"];function BW(){const{id:n,disable:e,disabled:t}=Da();return ae.createElement(ae.Fragment,null,ae.createElement(LW,{id:n+"__disable",type:"checkbox",checked:!t,onChange:()=>e(!t)}),ae.createElement("label",{htmlFor:n+"__disable"}))}function kW(n){const{id:e,optional:t,hint:i}=Da(),r=n.htmlFor||e||void 0,s=!i&&typeof n.children=="string"?n.children:void 0;return ae.createElement(ae.Fragment,null,t&&ae.createElement(BW,null),i!==void 0?ae.createElement($7,null,ae.createElement(j7,{asChild:!0},ae.createElement(qM,dr({htmlFor:r},n))),ae.createElement(q7,{side:"top",sideOffset:2},ae.createElement(UW,null,i,ae.createElement(zW,null)))):ae.createElement(qM,dr({htmlFor:r,title:s},n)))}function Jo(n){let{align:e}=n,t=xi(n,FW);const{value:i,label:r,key:s,disabled:l}=Da(),{hideCopyButton:u}=SW(),h=!u&&s!==void 0,[p,g]=P.useState(!1),y=async()=>{try{await navigator.clipboard.writeText(JSON.stringify({[s]:i??""})),g(!0)}catch{Rc(Cr.CLIPBOARD_ERROR,{[s]:i})}};return ae.createElement(PW,{align:e,onPointerLeave:()=>g(!1)},ae.createElement(kW,t),h&&!l&&ae.createElement("div",{title:`Click to copy ${typeof r=="string"?r:s} value`},p?ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},ae.createElement("path",{d:"M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"}),ae.createElement("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm9.707 5.707a1 1 0 00-1.414-1.414L9 12.586l-1.293-1.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})):ae.createElement("svg",{onClick:y,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},ae.createElement("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),ae.createElement("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"}))))}const HW=["toggled"],VW=Jt("svg",{fill:"currentColor",transition:"transform 350ms ease, fill 250ms ease"});function xT(n){let{toggled:e}=n,t=xi(n,HW);return ae.createElement(VW,dr({width:"9",height:"5",viewBox:"0 0 9 5",xmlns:"http://www.w3.org/2000/svg",style:{transform:`rotate(${e?0:-90}deg)`}},t),ae.createElement("path",{d:"M3.8 4.4c.4.3 1 .3 1.4 0L8 1.7A1 1 0 007.4 0H1.6a1 1 0 00-.7 1.7l3 2.7z"}))}const GW=["input"];function bo(n){let{input:e}=n,t=xi(n,GW);return e?ae.createElement(XI,t):ae.createElement(WI,t)}function jI({value:n,type:e,settings:t,setValue:i}){const[r,s]=P.useState(sR(e,n,t)),l=P.useRef(n),u=P.useRef(t);u.current=t;const h=P.useCallback(g=>s(sR(e,g,u.current)),[e]),p=P.useCallback(g=>{try{i(g)}catch(y){const{type:b,previousValue:x}=y;if(b!=="LEVA_ERROR")throw y;h(x)}},[h,i]);return P.useEffect(()=>{E0(n,l.current)||h(n),l.current=n},[n,h]),{displayValue:r,onChange:s,onUpdate:p}}function X0(n,e){const{emitOnEditStart:t,emitOnEditEnd:i}=Da();return sH(r=>{r.first&&(document.body.classList.add("leva__panel__dragged"),t?.());const s=n(r);return r.last&&(document.body.classList.remove("leva__panel__dragged"),i?.()),s},e)}function WW(n){const e=P.useRef(null),t=P.useRef(null),i=P.useRef(!1);return P.useEffect(()=>{const r=OI(()=>{e.current.width=e.current.offsetWidth*window.devicePixelRatio,e.current.height=e.current.offsetHeight*window.devicePixelRatio,n(e.current,t.current)},250);return window.addEventListener("resize",r),i.current||(r(),i.current=!0),()=>window.removeEventListener("resize",r)},[n]),P.useEffect(()=>{t.current=e.current.getContext("2d")},[]),[e,t]}function qI(){const n=P.useRef(null),e=P.useRef({x:0,y:0}),t=P.useCallback(i=>{Object.assign(e.current,i),n.current&&(n.current.style.transform=`translate3d(${e.current.x}px, ${e.current.y}px, 0)`)},[]);return[n,t]}const XW=["__refCount"],H1=(n,e)=>{if(!n[e])return null;const t=n[e];return xi(t,XW)};function $W(n){const e=G0(),[t,i]=P.useState(H1(e.getData(),n)),r=P.useCallback(p=>e.setValueAtPath(n,p,!0),[n,e]),s=P.useCallback(p=>e.setSettingsAtPath(n,p),[n,e]),l=P.useCallback(p=>e.disableInputAtPath(n,p),[n,e]),u=P.useCallback(()=>e.emitOnEditStart(n),[n,e]),h=P.useCallback(()=>e.emitOnEditEnd(n),[n,e]);return P.useEffect(()=>{i(H1(e.getData(),n));const p=e.useStore.subscribe(g=>H1(g.data,n),i,{equalityFn:F_});return()=>p()},[e,n]),[t,{set:r,setSettings:s,disable:l,storeId:e.storeId,emitOnEditStart:u,emitOnEditEnd:h}]}const jW=Jt("div",{variants:{hasRange:{true:{position:"relative",display:"grid",gridTemplateColumns:"auto $sizes$numberInputMinWidth",columnGap:"$colGap",alignItems:"center"}}}}),YI=Jt("div",{position:"relative",width:"100%",height:2,borderRadius:"$xs",backgroundColor:"$elevation1"}),YM=Jt("div",{position:"absolute",width:"$scrubberWidth",height:"$scrubberHeight",borderRadius:"$xs",boxShadow:"0 0 0 2px $colors$elevation2",backgroundColor:"$accent2",cursor:"pointer",$active:"none $accent1",$hover:"none $accent3",variants:{position:{left:{borderTopRightRadius:0,borderBottomRightRadius:0,transform:"translateX(calc(-0.5 * ($sizes$scrubberWidth + 4px)))"},right:{borderTopLeftRadius:0,borderBottomLeftRadius:0,transform:"translateX(calc(0.5 * ($sizes$scrubberWidth + 4px)))"}}}}),ZI=Jt("div",{position:"relative",$flex:"",height:"100%",cursor:"pointer",touchAction:"none"}),KI=Jt("div",{position:"absolute",height:"100%",backgroundColor:"$accent2"});function qW({value:n,min:e,max:t,onDrag:i,step:r,initialValue:s}){const l=P.useRef(null),u=P.useRef(null),h=P.useRef(0),p=Pc("sizes","scrubberWidth"),g=X0(({event:b,first:x,xy:[E],movement:[A],memo:T})=>{if(x){const{width:R,left:O}=l.current.getBoundingClientRect();h.current=R-parseFloat(p),T=b?.target===u.current?n:Wx((E-O)/R,e,t)}const M=T+Wx(A/h.current,0,t-e);return i(NI(M,{step:r,initialValue:s})),T}),y=Gx(n,e,t);return ae.createElement(ZI,dr({ref:l},g()),ae.createElement(YI,null,ae.createElement(KI,{style:{left:0,right:`${(1-y)*100}%`}})),ae.createElement(YM,{ref:u,style:{left:`calc(${y} * (100% - ${p}))`}}))}const YW=ae.memo(({label:n,onUpdate:e,step:t,innerLabelTrim:i})=>{const[r,s]=P.useState(!1),l=X0(({active:u,delta:[h],event:p,memo:g=0,first:y,last:b,target:x})=>(y&&x.requestPointerLock(),b&&document.exitPointerLock(),s(u),g+=h/2,Math.abs(g)>=1&&(e(E=>parseFloat(E)+Math.floor(g)*t*II(p)),g=0),g));return ae.createElement(AW,dr({dragging:r,title:n.length>1?n:""},l()),n.slice(0,i))});function QI({label:n,id:e,displayValue:t,onUpdate:i,onChange:r,settings:s,innerLabelTrim:l=1}){const u=l>0&&ae.createElement(YW,{label:n,step:s.step,onUpdate:i,innerLabelTrim:l});return ae.createElement(OW,{id:e,value:String(t),onUpdate:i,onChange:r,innerLabel:u})}function ZW(){const n=Da(),{label:e,value:t,onUpdate:i,settings:r,id:s}=n,{min:l,max:u}=r,h=u!==1/0&&l!==-1/0;return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,e),ae.createElement(jW,{hasRange:h},h&&ae.createElement(qW,dr({value:parseFloat(t),onDrag:i},r)),ae.createElement(QI,dr({},n,{id:s,label:"value",innerLabelTrim:h?0:1}))))}const{sanitizeStep:KW}=UI,QW=xi(UI,["sanitizeStep"]);var JW=Yt({component:ZW},QW);const eX=(n,e)=>Ss().schema({options:Ss().passesAnyOf(Ss().object(),Ss().array())}).test(e),tX=(n,{values:e})=>{if(e.indexOf(n)<0)throw Error("Selected value doesn't match Select options");return n},nX=(n,{values:e})=>e.indexOf(n),iX=n=>{let{value:e,options:t}=n,i,r;return Array.isArray(t)?(r=t,i=t.map(s=>String(s))):(r=Object.values(t),i=Object.keys(t)),"value"in n?r.includes(e)||(i.unshift(String(e)),r.unshift(e)):e=r[0],Object.values(t).includes(e)||(t[String(e)]=e),{value:e,settings:{keys:i,values:r}}};var rX=Object.freeze({__proto__:null,schema:eX,sanitize:tX,format:nX,normalize:iX});const aX=Jt("div",{$flexCenter:"",position:"relative","> svg":{pointerEvents:"none",position:"absolute",right:"$md"}}),ZM=Jt("select",{position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0}),sX=Jt("div",{display:"flex",alignItems:"center",width:"100%",height:"$rowHeight",backgroundColor:"$elevation3",borderRadius:"$sm",padding:"0 $sm",cursor:"pointer",[`${ZM}:focus + &`]:{$focusStyle:""},[`${ZM}:hover + &`]:{$hoverStyle:""}});function oX({displayValue:n,value:e,onUpdate:t,id:i,settings:r,disabled:s}){const{keys:l,values:u}=r,h=P.useRef();return e===u[n]&&(h.current=l[n]),ae.createElement(aX,null,ae.createElement(ZM,{id:i,value:n,onChange:p=>t(u[Number(p.currentTarget.value)]),disabled:s},l.map((p,g)=>ae.createElement("option",{key:p,value:g},p))),ae.createElement(sX,null,h.current),ae.createElement(xT,{toggled:!0}))}function lX(){const{label:n,value:e,displayValue:t,onUpdate:i,id:r,disabled:s,settings:l}=Da();return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,n),ae.createElement(oX,{id:r,value:e,displayValue:t,onUpdate:i,settings:l,disabled:s}))}var cX=Yt({component:lX},rX);const uX=n=>Ss().string().test(n),fX=n=>{if(typeof n!="string")throw Error("Invalid string");return n},dX=({value:n,editable:e=!0,rows:t=!1})=>({value:n,settings:{editable:e,rows:typeof t=="number"?t:t?5:0}});var hX=Object.freeze({__proto__:null,schema:uX,sanitize:fX,normalize:dX});const pX=["displayValue","onUpdate","onChange","editable"],mX=Jt("div",{whiteSpace:"pre-wrap"});function gX(n){let{displayValue:e,onUpdate:t,onChange:i,editable:r=!0}=n,s=xi(n,pX);return r?ae.createElement(yT,dr({value:e,onUpdate:t,onChange:i},s)):ae.createElement(mX,null,e)}function vX(){const{label:n,settings:e,displayValue:t,onUpdate:i,onChange:r}=Da();return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,n),ae.createElement(gX,dr({displayValue:t,onUpdate:i,onChange:r},e)))}var yX=Yt({component:vX},hX);const bX=n=>Ss().boolean().test(n),xX=n=>{if(typeof n!="boolean")throw Error("Invalid boolean");return n};var _X=Object.freeze({__proto__:null,schema:bX,sanitize:xX});const SX=Jt("div",{position:"relative",$flex:"",height:"$rowHeight",input:{$reset:"",height:0,width:0,opacity:0,margin:0},label:{position:"relative",$flexCenter:"",userSelect:"none",cursor:"pointer",height:"$checkboxSize",width:"$checkboxSize",backgroundColor:"$elevation3",borderRadius:"$sm",$hover:""},"input:focus + label":{$focusStyle:""},"input:focus:checked + label, input:checked + label:hover":{$hoverStyle:"$accent3"},"input + label:active":{backgroundColor:"$accent1"},"input:checked + label:active":{backgroundColor:"$accent1"},"label > svg":{display:"none",width:"90%",height:"90%",stroke:"$highlight3"},"input:checked + label":{backgroundColor:"$accent2"},"input:checked + label > svg":{display:"block"}});function MX({value:n,onUpdate:e,id:t,disabled:i}){return ae.createElement(SX,null,ae.createElement("input",{id:t,type:"checkbox",checked:n,onChange:r=>e(r.currentTarget.checked),disabled:i}),ae.createElement("label",{htmlFor:t},ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},ae.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}))))}function EX(){const{label:n,value:e,onUpdate:t,disabled:i,id:r}=Da();return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,n),ae.createElement(MX,{value:e,onUpdate:t,id:r,disabled:i}))}var TX=Yt({component:EX},_X);const wX=["locked"];function AX({value:n,id:e,valueKey:t,settings:i,onUpdate:r,innerLabelTrim:s}){const l=P.useRef(n[t]);l.current=n[t];const u=P.useCallback(p=>r({[t]:DI({type:"NUMBER",value:l.current,settings:i},p)}),[r,i,t]),h=jI({type:"NUMBER",value:n[t],settings:i,setValue:u});return ae.createElement(QI,{id:e,label:t,value:n[t],displayValue:h.displayValue,onUpdate:h.onUpdate,onChange:h.onChange,settings:i,innerLabelTrim:s})}const CX=Jt("div",{display:"grid",columnGap:"$colGap",gridAutoFlow:"column dense",alignItems:"center",variants:{withLock:{true:{gridTemplateColumns:"10px auto","> svg":{cursor:"pointer"}}}}});function RX(n){let{locked:e}=n,t=xi(n,wX);return ae.createElement("svg",dr({width:"10",height:"10",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),e?ae.createElement("path",{d:"M5 4.63601C5 3.76031 5.24219 3.1054 5.64323 2.67357C6.03934 2.24705 6.64582 1.9783 7.5014 1.9783C8.35745 1.9783 8.96306 2.24652 9.35823 2.67208C9.75838 3.10299 10 3.75708 10 4.63325V5.99999H5V4.63601ZM4 5.99999V4.63601C4 3.58148 4.29339 2.65754 4.91049 1.99307C5.53252 1.32329 6.42675 0.978302 7.5014 0.978302C8.57583 0.978302 9.46952 1.32233 10.091 1.99162C10.7076 2.65557 11 3.57896 11 4.63325V5.99999H12C12.5523 5.99999 13 6.44771 13 6.99999V13C13 13.5523 12.5523 14 12 14H3C2.44772 14 2 13.5523 2 13V6.99999C2 6.44771 2.44772 5.99999 3 5.99999H4ZM3 6.99999H12V13H3V6.99999Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}):ae.createElement("path",{d:"M9 3.63601C9 2.76044 9.24207 2.11211 9.64154 1.68623C10.0366 1.26502 10.6432 1 11.5014 1C12.4485 1 13.0839 1.30552 13.4722 1.80636C13.8031 2.23312 14 2.84313 14 3.63325H15C15 2.68242 14.7626 1.83856 14.2625 1.19361C13.6389 0.38943 12.6743 0 11.5014 0C10.4294 0 9.53523 0.337871 8.91218 1.0021C8.29351 1.66167 8 2.58135 8 3.63601V6H1C0.447715 6 0 6.44772 0 7V13C0 13.5523 0.447715 14 1 14H10C10.5523 14 11 13.5523 11 13V7C11 6.44772 10.5523 6 10 6H9V3.63601ZM1 7H10V13H1V7Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}))}function _T({value:n,onUpdate:e,settings:t,innerLabelTrim:i}){const{id:r,setSettings:s}=Da(),{lock:l,locked:u}=t;return ae.createElement(CX,{withLock:l},l&&ae.createElement(RX,{locked:u,onClick:()=>s({locked:!u})}),Object.keys(n).map((h,p)=>ae.createElement(AX,{id:p===0?r:`${r}.${h}`,key:h,valueKey:h,value:n,settings:t[h],onUpdate:e,innerLabelTrim:i})))}const JI=(n,e)=>{const t={};let i=0,r=1/0;Object.entries(n).forEach(([s,l])=>{t[s]=LI(Yt({value:l},e[s])).settings,i=Math.max(i,t[s].step),r=Math.min(r,t[s].pad)});for(let s in t){const{step:l,min:u,max:h}=e[s]||{};!isFinite(l)&&(!isFinite(u)||!isFinite(h))&&(t[s].step=i,t[s].pad=r)}return t},DX=["lock"],OX=["value"];function IX(n){const e=Ss().array().length(n).every.number(),t=i=>{if(!i||typeof i!="object")return!1;const r=Object.values(i);return r.length===n&&r.every(s=>isFinite(s))};return i=>e.test(i)||t(i)}function PX(n){return Array.isArray(n)?"array":"object"}function n0(n,e,t){return PX(n)===e?n:e==="array"?Object.values(n):fW(n,t)}const LX=(n,e,t)=>{const i=n0(n,"object",e.keys);for(let l in i)i[l]=PI(i[l],e[l]);const r=Object.keys(i);let s={};if(r.length===e.keys.length)s=i;else{const l=n0(t,"object",e.keys);if(r.length===1&&e.locked){const u=r[0],h=i[u],p=l[u],g=p!==0?h/p:1;for(let y in l)y===u?s[u]=h:s[y]=l[y]*g}else s=Yt(Yt({},l),i)}return n0(s,e.format,e.keys)},NX=(n,e)=>n0(n,"object",e.keys),UX=n=>!!n&&("step"in n||"min"in n||"max"in n);function zX(n,e,t=[]){const{lock:i=!1}=e,r=xi(e,DX),s=Array.isArray(n)?"array":"object",l=s==="object"?Object.keys(n):t,u=n0(n,"object",l),h=UX(r)?l.reduce((g,y)=>Object.assign(g,{[y]:r}),{}):r,p=JI(u,h);return{value:s==="array"?n:u,settings:Yt(Yt({},p),{},{format:s,keys:l,lock:i,locked:!1})}}function eP(n){return{schema:IX(n.length),normalize:e=>{let{value:t}=e,i=xi(e,OX);return zX(t,i,n)},format:(e,t)=>NX(e,t),sanitize:(e,t,i)=>LX(e,t,i)}}var FX={grad:.9,turn:360,rad:360/(2*Math.PI)},Ec=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},Xr=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t+0},go=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n>e?n:e},tP=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},pR=function(n){return{r:go(n.r,0,255),g:go(n.g,0,255),b:go(n.b,0,255),a:go(n.a)}},V1=function(n){return{r:Xr(n.r),g:Xr(n.g),b:Xr(n.b),a:Xr(n.a,3)}},BX=/^#([0-9a-f]{3,8})$/i,Cb=function(n){var e=n.toString(16);return e.length<2?"0"+e:e},nP=function(n){var e=n.r,t=n.g,i=n.b,r=n.a,s=Math.max(e,t,i),l=s-Math.min(e,t,i),u=l?s===e?(t-i)/l:s===t?2+(i-e)/l:4+(e-t)/l:0;return{h:60*(u<0?u+6:u),s:s?l/s*100:0,v:s/255*100,a:r}},iP=function(n){var e=n.h,t=n.s,i=n.v,r=n.a;e=e/360*6,t/=100,i/=100;var s=Math.floor(e),l=i*(1-t),u=i*(1-(e-s)*t),h=i*(1-(1-e+s)*t),p=s%6;return{r:255*[i,u,l,l,h,i][p],g:255*[h,i,i,u,l,l][p],b:255*[l,l,h,i,i,u][p],a:r}},mR=function(n){return{h:tP(n.h),s:go(n.s,0,100),l:go(n.l,0,100),a:go(n.a)}},gR=function(n){return{h:Xr(n.h),s:Xr(n.s),l:Xr(n.l),a:Xr(n.a,3)}},vR=function(n){return iP((t=(e=n).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},i0=function(n){return{h:(e=nP(n)).h,s:(r=(200-(t=e.s))*(i=e.v)/100)>0&&r<200?t*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,t,i,r},kX=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,HX=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,VX=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,GX=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,KM={string:[[function(n){var e=BX.exec(n);return e?(n=e[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?Xr(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?Xr(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var e=VX.exec(n)||GX.exec(n);return e?e[2]!==e[4]||e[4]!==e[6]?null:pR({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(n){var e=kX.exec(n)||HX.exec(n);if(!e)return null;var t,i,r=mR({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(FX[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return vR(r)},"hsl"]],object:[[function(n){var e=n.r,t=n.g,i=n.b,r=n.a,s=r===void 0?1:r;return Ec(e)&&Ec(t)&&Ec(i)?pR({r:Number(e),g:Number(t),b:Number(i),a:Number(s)}):null},"rgb"],[function(n){var e=n.h,t=n.s,i=n.l,r=n.a,s=r===void 0?1:r;if(!Ec(e)||!Ec(t)||!Ec(i))return null;var l=mR({h:Number(e),s:Number(t),l:Number(i),a:Number(s)});return vR(l)},"hsl"],[function(n){var e=n.h,t=n.s,i=n.v,r=n.a,s=r===void 0?1:r;if(!Ec(e)||!Ec(t)||!Ec(i))return null;var l=(function(u){return{h:tP(u.h),s:go(u.s,0,100),v:go(u.v,0,100),a:go(u.a)}})({h:Number(e),s:Number(t),v:Number(i),a:Number(s)});return iP(l)},"hsv"]]},yR=function(n,e){for(var t=0;t=.5},n.prototype.toHex=function(){return e=V1(this.rgba),t=e.r,i=e.g,r=e.b,l=(s=e.a)<1?Cb(Xr(255*s)):"","#"+Cb(t)+Cb(i)+Cb(r)+l;var e,t,i,r,s,l},n.prototype.toRgb=function(){return V1(this.rgba)},n.prototype.toRgbString=function(){return e=V1(this.rgba),t=e.r,i=e.g,r=e.b,(s=e.a)<1?"rgba("+t+", "+i+", "+r+", "+s+")":"rgb("+t+", "+i+", "+r+")";var e,t,i,r,s},n.prototype.toHsl=function(){return gR(i0(this.rgba))},n.prototype.toHslString=function(){return e=gR(i0(this.rgba)),t=e.h,i=e.s,r=e.l,(s=e.a)<1?"hsla("+t+", "+i+"%, "+r+"%, "+s+")":"hsl("+t+", "+i+"%, "+r+"%)";var e,t,i,r,s},n.prototype.toHsv=function(){return e=nP(this.rgba),{h:Xr(e.h),s:Xr(e.s),v:Xr(e.v),a:Xr(e.a,3)};var e},n.prototype.invert=function(){return $a({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},n.prototype.saturate=function(e){return e===void 0&&(e=.1),$a(G1(this.rgba,e))},n.prototype.desaturate=function(e){return e===void 0&&(e=.1),$a(G1(this.rgba,-e))},n.prototype.grayscale=function(){return $a(G1(this.rgba,-1))},n.prototype.lighten=function(e){return e===void 0&&(e=.1),$a(bR(this.rgba,e))},n.prototype.darken=function(e){return e===void 0&&(e=.1),$a(bR(this.rgba,-e))},n.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},n.prototype.alpha=function(e){return typeof e=="number"?$a({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Xr(this.rgba.a,3);var t},n.prototype.hue=function(e){var t=i0(this.rgba);return typeof e=="number"?$a({h:e,s:t.s,l:t.l,a:t.a}):Xr(t.h)},n.prototype.isEqual=function(e){return this.toHex()===$a(e).toHex()},n})(),$a=function(n){return n instanceof QM?n:new QM(n)},xR=[],XX=function(n){n.forEach(function(e){xR.indexOf(e)<0&&(e(QM,KM),xR.push(e))})};function $X(n,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in t)i[t[r]]=r;var s={};n.prototype.toName=function(l){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var u,h,p=i[this.toHex()];if(p)return p;if(l?.closest){var g=this.toRgb(),y=1/0,b="black";if(!s.length)for(var x in t)s[x]=new n(t[x]).toRgb();for(var E in t){var A=(u=g,h=s[E],Math.pow(u.r-h.r,2)+Math.pow(u.g-h.g,2)+Math.pow(u.b-h.b,2));A=0||(r[t]=n[t]);return r}function JM(n){var e=P.useRef(n),t=P.useRef(function(i){e.current&&e.current(i)});return e.current=n,t.current}var zp=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n0:T.buttons>0)&&r.current?s(_R(r.current,T,u.current)):A(!1)},E=function(){return A(!1)};function A(T){var M=h.current,R=eE(r.current),O=T?R.addEventListener:R.removeEventListener;O(M?"touchmove":"mousemove",x),O(M?"touchend":"mouseup",E)}return[function(T){var M=T.nativeEvent,R=r.current;if(R&&(SR(M),!(function(D,F){return F&&!r0(D)})(M,h.current)&&R)){if(r0(M)){h.current=!0;var O=M.changedTouches||[];O.length&&(u.current=O[0].identifier)}R.focus(),s(_R(R,M,u.current)),A(!0)}},function(T){var M=T.which||T.keyCode;M<37||M>40||(T.preventDefault(),l({left:M===39?.05:M===37?-.05:0,top:M===40?.05:M===38?-.05:0}))},A]},[l,s]),g=p[0],y=p[1],b=p[2];return P.useEffect(function(){return b},[b]),ae.createElement("div",Xp({},i,{onTouchStart:g,onMouseDown:g,className:"react-colorful__interactive",ref:r,onKeyDown:y,tabIndex:0,role:"slider"}))}),$0=function(n){return n.filter(Boolean).join(" ")},ET=function(n){var e=n.color,t=n.left,i=n.top,r=i===void 0?.5:i,s=$0(["react-colorful__pointer",n.className]);return ae.createElement("div",{className:s,style:{top:100*r+"%",left:100*t+"%"}},ae.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},qa=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t},aP=function(n){var e=n.s,t=n.v,i=n.a,r=(200-e)*t/100;return{h:qa(n.h),s:qa(r>0&&r<200?e*t/100/(r<=100?r:200-r)*100:0),l:qa(r/2),a:qa(i,2)}},tE=function(n){var e=aP(n);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},X1=function(n){var e=aP(n);return"hsla("+e.h+", "+e.s+"%, "+e.l+"%, "+e.a+")"},sP=function(n){var e=n.h,t=n.s,i=n.v,r=n.a;e=e/360*6,t/=100,i/=100;var s=Math.floor(e),l=i*(1-t),u=i*(1-(e-s)*t),h=i*(1-(1-e+s)*t),p=s%6;return{r:qa(255*[i,u,l,l,h,i][p]),g:qa(255*[h,i,i,u,l,l][p]),b:qa(255*[l,l,h,i,i,u][p]),a:qa(r,2)}},oP=function(n){var e=n.r,t=n.g,i=n.b,r=n.a,s=Math.max(e,t,i),l=s-Math.min(e,t,i),u=l?s===e?(t-i)/l:s===t?2+(i-e)/l:4+(e-t)/l:0;return{h:qa(60*(u<0?u+6:u)),s:qa(s?l/s*100:0),v:qa(s/255*100),a:r}},lP=ae.memo(function(n){var e=n.hue,t=n.onChange,i=$0(["react-colorful__hue",n.className]);return ae.createElement("div",{className:i},ae.createElement(MT,{onMove:function(r){t({h:360*r.left})},onKey:function(r){t({h:zp(e+360*r.left,0,360)})},"aria-label":"Hue","aria-valuenow":qa(e),"aria-valuemax":"360","aria-valuemin":"0"},ae.createElement(ET,{className:"react-colorful__hue-pointer",left:e/360,color:tE({h:e,s:100,v:100,a:1})})))}),cP=ae.memo(function(n){var e=n.hsva,t=n.onChange,i={backgroundColor:tE({h:e.h,s:100,v:100,a:1})};return ae.createElement("div",{className:"react-colorful__saturation",style:i},ae.createElement(MT,{onMove:function(r){t({s:100*r.left,v:100-100*r.top})},onKey:function(r){t({s:zp(e.s+100*r.left,0,100),v:zp(e.v-100*r.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+qa(e.s)+"%, Brightness "+qa(e.v)+"%"},ae.createElement(ET,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:tE(e)})))}),TT=function(n,e){if(n===e)return!0;for(var t in n)if(n[t]!==e[t])return!1;return!0};function uP(n,e,t){var i=JM(t),r=P.useState(function(){return n.toHsva(e)}),s=r[0],l=r[1],u=P.useRef({color:e,hsva:s});P.useEffect(function(){if(!n.equal(e,u.current.color)){var p=n.toHsva(e);u.current={hsva:p,color:e},l(p)}},[e,n]),P.useEffect(function(){var p;TT(s,u.current.hsva)||n.equal(p=n.fromHsva(s),u.current.color)||(u.current={hsva:s,color:p},i(p))},[s,n,i]);var h=P.useCallback(function(p){l(function(g){return Object.assign({},g,p)})},[]);return[s,h]}var jX=typeof window<"u"?P.useLayoutEffect:P.useEffect,qX=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},MR=new Map,fP=function(n){jX(function(){var e=n.current?n.current.ownerDocument:document;if(e!==void 0&&!MR.has(e)){var t=e.createElement("style");t.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,MR.set(e,t);var i=qX();i&&t.setAttribute("nonce",i),e.head.appendChild(t)}},[])},YX=function(n){var e=n.className,t=n.colorModel,i=n.color,r=i===void 0?t.defaultColor:i,s=n.onChange,l=ST(n,["className","colorModel","color","onChange"]),u=P.useRef(null);fP(u);var h=uP(t,r,s),p=h[0],g=h[1],y=$0(["react-colorful",e]);return ae.createElement("div",Xp({},l,{ref:u,className:y}),ae.createElement(cP,{hsva:p,onChange:g}),ae.createElement(lP,{hue:p.h,onChange:g,className:"react-colorful__last-control"}))},ZX=function(n){var e=n.className,t=n.hsva,i=n.onChange,r={backgroundImage:"linear-gradient(90deg, "+X1(Object.assign({},t,{a:0}))+", "+X1(Object.assign({},t,{a:1}))+")"},s=$0(["react-colorful__alpha",e]),l=qa(100*t.a);return ae.createElement("div",{className:s},ae.createElement("div",{className:"react-colorful__alpha-gradient",style:r}),ae.createElement(MT,{onMove:function(u){i({a:u.left})},onKey:function(u){i({a:zp(t.a+u.left)})},"aria-label":"Alpha","aria-valuetext":l+"%","aria-valuenow":l,"aria-valuemin":"0","aria-valuemax":"100"},ae.createElement(ET,{className:"react-colorful__alpha-pointer",left:t.a,color:X1(t)})))},KX=function(n){var e=n.className,t=n.colorModel,i=n.color,r=i===void 0?t.defaultColor:i,s=n.onChange,l=ST(n,["className","colorModel","color","onChange"]),u=P.useRef(null);fP(u);var h=uP(t,r,s),p=h[0],g=h[1],y=$0(["react-colorful",e]);return ae.createElement("div",Xp({},l,{ref:u,className:y}),ae.createElement(cP,{hsva:p,onChange:g}),ae.createElement(lP,{hue:p.h,onChange:g}),ae.createElement(ZX,{hsva:p,onChange:g,className:"react-colorful__last-control"}))},QX={defaultColor:{r:0,g:0,b:0,a:1},toHsva:oP,fromHsva:sP,equal:TT},JX=function(n){return ae.createElement(KX,Xp({},n,{colorModel:QX}))},e$={defaultColor:{r:0,g:0,b:0},toHsva:function(n){return oP({r:n.r,g:n.g,b:n.b,a:1})},fromHsva:function(n){return{r:(e=sP(n)).r,g:e.g,b:e.b};var e},equal:TT},t$=function(n){return ae.createElement(YX,Xp({},n,{colorModel:e$}))},$1={exports:{}},j1,ER;function n$(){if(ER)return j1;ER=1;var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return j1=n,j1}var q1,TR;function i$(){if(TR)return q1;TR=1;var n=n$();function e(){}function t(){}return t.resetWarningCache=e,q1=function(){function i(l,u,h,p,g,y){if(y!==n){var b=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw b.name="Invariant Violation",b}}i.isRequired=i;function r(){return i}var s={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:r,element:i,elementType:i,instanceOf:r,node:i,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:t,resetWarningCache:e};return s.PropTypes=s,s},q1}var wR;function r$(){return wR||(wR=1,$1.exports=i$()()),$1.exports}var a$=r$();const Ri=ef(a$);function $p(n,e,t,i){function r(s){return s instanceof t?s:new t(function(l){l(s)})}return new(t||(t=Promise))(function(s,l){function u(g){try{p(i.next(g))}catch(y){l(y)}}function h(g){try{p(i.throw(g))}catch(y){l(y)}}function p(g){g.done?s(g.value):r(g.value).then(u,h)}p((i=i.apply(n,e||[])).next())})}function jp(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,l=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return l.next=u(0),l.throw=u(1),l.return=u(2),typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function u(p){return function(g){return h([p,g])}}function h(p){if(i)throw new TypeError("Generator is already executing.");for(;l&&(l=0,p[0]&&(t=0)),t;)try{if(i=1,r&&(s=p[0]&2?r.return:p[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,p[1])).done)return s;switch(r=0,s&&(p=[p[0]&2,s.value]),p[0]){case 0:case 1:s=p;break;case 4:return t.label++,{value:p[1],done:!1};case 5:t.label++,r=p[1],p=[0];continue;case 7:p=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(p[0]===6||p[0]===2)){t=0;continue}if(p[0]===3&&(!s||p[1]>s[0]&&p[1]0)&&!(r=i.next()).done;)s.push(r.value)}catch(u){l={error:u}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(l)throw l.error}}return s}function o$(){for(var n=[],e=0;e0?i:n.name,writable:!1,configurable:!1,enumerable:!0})}return t}function c$(n){var e=n.name,t=e&&e.lastIndexOf(".")!==-1;if(t&&!n.type){var i=e.split(".").pop().toLowerCase(),r=l$.get(i);r&&Object.defineProperty(n,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return n}var u$=[".DS_Store","Thumbs.db"];function f$(n){return $p(this,void 0,void 0,function(){return jp(this,function(e){return $x(n)&&d$(n)?[2,g$(n.dataTransfer,n.type)]:h$(n)?[2,p$(n)]:Array.isArray(n)&&n.every(function(t){return"getFile"in t&&typeof t.getFile=="function"})?[2,m$(n)]:[2,[]]})})}function d$(n){return $x(n.dataTransfer)}function h$(n){return $x(n)&&$x(n.target)}function $x(n){return typeof n=="object"&&n!==null}function p$(n){return nE(n.target.files).map(function(e){return j0(e)})}function m$(n){return $p(this,void 0,void 0,function(){var e;return jp(this,function(t){switch(t.label){case 0:return[4,Promise.all(n.map(function(i){return i.getFile()}))];case 1:return e=t.sent(),[2,e.map(function(i){return j0(i)})]}})})}function g$(n,e){return $p(this,void 0,void 0,function(){var t,i;return jp(this,function(r){switch(r.label){case 0:return n===null?[2,[]]:n.items?(t=nE(n.items).filter(function(s){return s.kind==="file"}),e!=="drop"?[2,t]:[4,Promise.all(t.map(v$))]):[3,2];case 1:return i=r.sent(),[2,AR(dP(i))];case 2:return[2,AR(nE(n.files).map(function(s){return j0(s)}))]}})})}function AR(n){return n.filter(function(e){return u$.indexOf(e.name)===-1})}function nE(n){if(n===null)return[];for(var e=[],t=0;tn.length)&&(e=n.length);for(var t=0,i=new Array(e);tt)return[!1,LR(t)];if(n.sizet)return[!1,LR(t)]}return[!0,null]}function Ug(n){return n!=null}function P$(n){var e=n.files,t=n.accept,i=n.minSize,r=n.maxSize,s=n.multiple,l=n.maxFiles;return!s&&e.length>1||s&&l>=1&&e.length>l?!1:e.every(function(u){var h=mP(u,t),p=IR(h,1),g=p[0],y=gP(u,i,r),b=IR(y,1),x=b[0];return g&&x})}function jx(n){return typeof n.isPropagationStopped=="function"?n.isPropagationStopped():typeof n.cancelBubble<"u"?n.cancelBubble:!1}function Db(n){return n.dataTransfer?Array.prototype.some.call(n.dataTransfer.types,function(e){return e==="Files"||e==="application/x-moz-file"}):!!n.target&&!!n.target.files}function UR(n){n.preventDefault()}function L$(n){return n.indexOf("MSIE")!==-1||n.indexOf("Trident/")!==-1}function N$(n){return n.indexOf("Edge/")!==-1}function U$(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return L$(n)||N$(n)}function Ol(){for(var n=arguments.length,e=new Array(n),t=0;t1?r-1:0),l=1;ln.length)&&(e=n.length);for(var t=0,i=new Array(e);t=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function Q$(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,s;for(s=0;s=0)&&(t[r]=n[r]);return t}var wT=P.forwardRef(function(n,e){var t=n.children,i=qx(n,H$),r=bP(i),s=r.open,l=qx(r,V$);return P.useImperativeHandle(e,function(){return{open:s}},[s]),ae.createElement(P.Fragment,null,t(er(er({},l),{},{open:s})))});wT.displayName="Dropzone";var yP={disabled:!1,getFilesFromEvent:f$,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0};wT.defaultProps=yP;wT.propTypes={children:Ri.func,accept:Ri.oneOfType([Ri.string,Ri.arrayOf(Ri.string)]),multiple:Ri.bool,preventDropOnDocument:Ri.bool,noClick:Ri.bool,noKeyboard:Ri.bool,noDrag:Ri.bool,noDragEventsBubbling:Ri.bool,minSize:Ri.number,maxSize:Ri.number,maxFiles:Ri.number,disabled:Ri.bool,getFilesFromEvent:Ri.func,onFileDialogCancel:Ri.func,onFileDialogOpen:Ri.func,useFsAccessApi:Ri.bool,onDragEnter:Ri.func,onDragLeave:Ri.func,onDragOver:Ri.func,onDrop:Ri.func,onDropAccepted:Ri.func,onDropRejected:Ri.func,validator:Ri.func};var aE={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,draggedFiles:[],acceptedFiles:[],fileRejections:[]};function bP(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=er(er({},yP),n),t=e.accept,i=e.disabled,r=e.getFilesFromEvent,s=e.maxSize,l=e.minSize,u=e.multiple,h=e.maxFiles,p=e.onDragEnter,g=e.onDragLeave,y=e.onDragOver,b=e.onDrop,x=e.onDropAccepted,E=e.onDropRejected,A=e.onFileDialogCancel,T=e.onFileDialogOpen,M=e.useFsAccessApi,R=e.preventDropOnDocument,O=e.noClick,D=e.noKeyboard,F=e.noDrag,U=e.noDragEventsBubbling,k=e.validator,H=P.useMemo(function(){return typeof T=="function"?T:FR},[T]),L=P.useMemo(function(){return typeof A=="function"?A:FR},[A]),z=P.useRef(null),W=P.useRef(null),J=P.useReducer(J$,aE),$=Y1(J,2),oe=$[0],ne=$[1],Y=oe.isFocused,K=oe.isFileDialogActive,ie=oe.draggedFiles,ge=P.useRef(typeof window<"u"&&window.isSecureContext&&M&&z$()),xe=function(){!ge.current&&K&&setTimeout(function(){if(W.current){var N=W.current.files;N.length||(ne({type:"closeDialog"}),L())}},300)};P.useEffect(function(){return window.addEventListener("focus",xe,!1),function(){window.removeEventListener("focus",xe,!1)}},[W,K,L,ge]);var q=P.useRef([]),ce=function(N){z.current&&z.current.contains(N.target)||(N.preventDefault(),q.current=[])};P.useEffect(function(){return R&&(document.addEventListener("dragover",UR,!1),document.addEventListener("drop",ce,!1)),function(){R&&(document.removeEventListener("dragover",UR),document.removeEventListener("drop",ce))}},[z,R]);var Se=P.useCallback(function(V){V.preventDefault(),V.persist(),Re(V),q.current=[].concat(X$(q.current),[V.target]),Db(V)&&Promise.resolve(r(V)).then(function(N){jx(V)&&!U||(ne({draggedFiles:N,isDragActive:!0,type:"setDraggedFiles"}),p&&p(V))})},[r,p,U]),Ge=P.useCallback(function(V){V.preventDefault(),V.persist(),Re(V);var N=Db(V);if(N&&V.dataTransfer)try{V.dataTransfer.dropEffect="copy"}catch{}return N&&y&&y(V),!1},[y,U]),Ye=P.useCallback(function(V){V.preventDefault(),V.persist(),Re(V);var N=q.current.filter(function(Ee){return z.current&&z.current.contains(Ee)}),ee=N.indexOf(V.target);ee!==-1&&N.splice(ee,1),q.current=N,!(N.length>0)&&(ne({isDragActive:!1,type:"setDraggedFiles",draggedFiles:[]}),Db(V)&&g&&g(V))},[z,g,U]),ve=P.useCallback(function(V,N){var ee=[],Ee=[];V.forEach(function(Te){var pe=mP(Te,t),Et=Y1(pe,2),$e=Et[0],lt=Et[1],Lt=gP(Te,l,s),Ze=Y1(Lt,2),rt=Ze[0],vt=Ze[1],te=k?k(Te):null;if($e&&rt&&!te)ee.push(Te);else{var be=[lt,vt];te&&(be=be.concat(te)),Ee.push({file:Te,errors:be.filter(function(ct){return ct})})}}),(!u&&ee.length>1||u&&h>=1&&ee.length>h)&&(ee.forEach(function(Te){Ee.push({file:Te,errors:[I$]})}),ee.splice(0)),ne({acceptedFiles:ee,fileRejections:Ee,type:"setFiles"}),b&&b(ee,Ee,N),Ee.length>0&&E&&E(Ee,N),ee.length>0&&x&&x(ee,N)},[ne,u,t,l,s,h,b,x,E,k]),Oe=P.useCallback(function(V){V.preventDefault(),V.persist(),Re(V),q.current=[],Db(V)&&Promise.resolve(r(V)).then(function(N){jx(V)&&!U||ve(N,V)}),ne({type:"reset"})},[r,ve,U]),it=P.useCallback(function(){if(ge.current){ne({type:"openDialog"}),H();var V={multiple:u,types:F$(t)};window.showOpenFilePicker(V).then(function(N){return r(N)}).then(function(N){ve(N,null),ne({type:"closeDialog"})}).catch(function(N){B$(N)?(L(N),ne({type:"closeDialog"})):k$(N)&&(ge.current=!1,W.current&&(W.current.value=null,W.current.click()))});return}W.current&&(ne({type:"openDialog"}),H(),W.current.value=null,W.current.click())},[ne,H,L,M,ve,t,u]),gt=P.useCallback(function(V){!z.current||!z.current.isEqualNode(V.target)||(V.key===" "||V.key==="Enter"||V.keyCode===32||V.keyCode===13)&&(V.preventDefault(),it())},[z,it]),_t=P.useCallback(function(){ne({type:"focus"})},[]),jt=P.useCallback(function(){ne({type:"blur"})},[]),pt=P.useCallback(function(){O||(U$()?setTimeout(it,0):it())},[O,it]),mt=function(N){return i?null:N},He=function(N){return D?null:mt(N)},Ue=function(N){return F?null:mt(N)},Re=function(N){U&&N.stopPropagation()},ft=P.useMemo(function(){return function(){var V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},N=V.refKey,ee=N===void 0?"ref":N,Ee=V.role,Te=V.onKeyDown,pe=V.onFocus,Et=V.onBlur,$e=V.onClick,lt=V.onDragEnter,Lt=V.onDragOver,Ze=V.onDragLeave,rt=V.onDrop,vt=qx(V,G$);return er(er(rE({onKeyDown:He(Ol(Te,gt)),onFocus:He(Ol(pe,_t)),onBlur:He(Ol(Et,jt)),onClick:mt(Ol($e,pt)),onDragEnter:Ue(Ol(lt,Se)),onDragOver:Ue(Ol(Lt,Ge)),onDragLeave:Ue(Ol(Ze,Ye)),onDrop:Ue(Ol(rt,Oe)),role:typeof Ee=="string"&&Ee!==""?Ee:"button"},ee,z),!i&&!D?{tabIndex:0}:{}),vt)}},[z,gt,_t,jt,pt,Se,Ge,Ye,Oe,D,F,i]),Z=P.useCallback(function(V){V.stopPropagation()},[]),At=P.useMemo(function(){return function(){var V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},N=V.refKey,ee=N===void 0?"ref":N,Ee=V.onChange,Te=V.onClick,pe=qx(V,W$),Et=rE({accept:t,multiple:u,type:"file",style:{display:"none"},onChange:mt(Ol(Ee,Oe)),onClick:mt(Ol(Te,Z)),tabIndex:-1},ee,W);return er(er({},Et),pe)}},[W,t,u,Oe,i]),dt=ie.length,Ct=dt>0&&P$({files:ie,accept:t,minSize:l,maxSize:s,multiple:u,maxFiles:h}),tt=dt>0&&!Ct;return er(er({},oe),{},{isDragAccept:Ct,isDragReject:tt,isFocused:Y&&!i,getRootProps:ft,getInputProps:At,rootRef:z,inputRef:W,open:mt(it)})}function J$(n,e){switch(e.type){case"focus":return er(er({},n),{},{isFocused:!0});case"blur":return er(er({},n),{},{isFocused:!1});case"openDialog":return er(er({},aE),{},{isFileDialogActive:!0});case"closeDialog":return er(er({},n),{},{isFileDialogActive:!1});case"setDraggedFiles":var t=e.isDragActive,i=e.draggedFiles;return er(er({},n),{},{draggedFiles:i,isDragActive:t});case"setFiles":return er(er({},n),{},{acceptedFiles:e.acceptedFiles,fileRejections:e.fileRejections});case"reset":return er({},aE);default:return n}}function FR(){}function ej(n){let e;const t=new Set,i=(p,g)=>{const y=typeof p=="function"?p(e):p;if(y!==e){const b=e;e=g?y:Object.assign({},e,y),t.forEach(x=>x(e,b))}},r=()=>e,s=(p,g=r,y=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let b=g(e);function x(){const E=g(e);if(!y(b,E)){const A=b;p(b=E,A)}}return t.add(x),()=>t.delete(x)},h={setState:i,getState:r,subscribe:(p,g,y)=>g||y?s(p,g,y):(t.add(p),()=>t.delete(p)),destroy:()=>t.clear()};return e=n(i,r,h),h}const tj=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),BR=tj?P.useEffect:P.useLayoutEffect;function nj(n){const e=typeof n=="function"?ej(n):n,t=(i=e.getState,r=Object.is)=>{const[,s]=P.useReducer(T=>T+1,0),l=e.getState(),u=P.useRef(l),h=P.useRef(i),p=P.useRef(r),g=P.useRef(!1),y=P.useRef();y.current===void 0&&(y.current=i(l));let b,x=!1;(u.current!==l||h.current!==i||p.current!==r||g.current)&&(b=i(l),x=!r(y.current,b)),BR(()=>{x&&(y.current=b),u.current=l,h.current=i,p.current=r,g.current=!1});const E=P.useRef(l);BR(()=>{const T=()=>{try{const R=e.getState(),O=h.current(R);p.current(y.current,O)||(u.current=R,y.current=O,s())}catch{g.current=!0,s()}},M=e.subscribe(T);return e.getState()!==E.current&&T(),M},[]);const A=x?b:y.current;return P.useDebugValue(A),A};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const i=[t,e];return{next(){const r=i.length<=0;return{value:i.shift(),done:r}}}},t}const ij=n=>(e,t,i)=>{const r=i.subscribe;return i.subscribe=(l,u,h)=>{let p=l;if(u){const g=h?.equalityFn||Object.is;let y=l(i.getState());p=b=>{const x=l(b);if(!g(y,x)){const E=y;u(y=x,E)}},h?.fireImmediately&&u(y,y)}return r(p)},n(e,t,i)};var Z1,kR;function rj(){return kR||(kR=1,Z1=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}),Z1}var K1,HR;function xP(){if(HR)return K1;HR=1;var n=rj();function e(t){return n(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}return K1=function(i){var r,s;return!(e(i)===!1||(r=i.constructor,typeof r!="function")||(s=r.prototype,e(s)===!1)||s.hasOwnProperty("isPrototypeOf")===!1)},K1}var Q1,VR;function AT(){if(VR)return Q1;VR=1;var n=xP();return Q1=function(t){return n(t)||typeof t=="function"||Array.isArray(t)},Q1}var J1,GR;function aj(){return GR||(GR=1,J1=function(e,t,i){for(var r in e)if(t.call(i,e[r],r,e)===!1)break}),J1}var eM,WR;function sj(){if(WR)return eM;WR=1;var n=AT(),e=aj();function t(l,u){for(var h=arguments.length,p=0;++p"u")throw new TypeError("expected first argument to be an object.");if(typeof e>"u"||typeof Symbol>"u"||typeof Object.getOwnPropertySymbols!="function")return n;for(var t=Object.prototype.propertyIsEnumerable,i=Object(n),r=arguments.length,s=0;++s"u")throw new TypeError("Cannot convert undefined or null to object");s(u)||(u={});for(var h=1;h","(":")","[":"]","{":"}"}:u.brackets&&(p=u.brackets);var g=[],y=[],b=[""],x=u.sep,E=r.length,A=-1,T;function M(){if(p&&y.length)return p[y[y.length-1]]}for(;++An.filter(Boolean).join(".");function yj(n){const e=n.split(".");return[e.pop(),e.join(".")||void 0]}function bj(n,e){return Object.entries(cW(n,e)).reduce((t,[,{value:i,disabled:r,key:s}])=>(t[s]=r?void 0:i,t),{})}function xj(n,e){const t=P.useRef();return E0(n,t.current)||(t.current=n),t.current}function _P(n,e){var t;return P.useMemo(n,(t=xj(e))!==null&&t!==void 0?t:[])}function _j(n){const e=P.useRef(null),t=P.useRef(null),i=P.useRef(!0);return P.useLayoutEffect(()=>{n||(e.current.style.height="0px",e.current.style.overflow="hidden")},[]),P.useEffect(()=>{if(i.current){i.current=!1;return}let r;const s=e.current,l=()=>{n&&(s.style.removeProperty("height"),s.style.removeProperty("overflow"),t.current.scrollIntoView({behavior:"smooth",block:"nearest"}))};s.addEventListener("transitionend",l,{once:!0});const{height:u}=t.current.getBoundingClientRect();return s.style.height=u+"px",n||(s.style.overflow="hidden",r=window.setTimeout(()=>s.style.height="0px",50)),()=>{s.removeEventListener("transitionend",l),clearTimeout(r)}},[n]),{wrapperRef:e,contentRef:t}}const Sj=n=>{const[e,t]=P.useState(n.getVisiblePaths());return P.useEffect(()=>{t(n.getVisiblePaths());const i=n.useStore.subscribe(n.getVisiblePaths,t,{equalityFn:F_});return()=>i()},[n]),e};function Mj(n,e,t){return n.useStore(r=>{const s=Yt(Yt({},t),r.data);return bj(s,e)},F_)}function SP(n=3){const e=P.useRef(null),t=P.useRef(null),[i,r]=P.useState(!1),s=P.useCallback(()=>r(!0),[]),l=P.useCallback(()=>r(!1),[]);return P.useLayoutEffect(()=>{if(i){const{bottom:u,top:h,left:p}=e.current.getBoundingClientRect(),{height:g}=t.current.getBoundingClientRect(),y=u+g>window.innerHeight-40?"up":"down";t.current.style.position="fixed",t.current.style.zIndex="10000",t.current.style.left=p+"px",y==="down"?t.current.style.top=u+n+"px":t.current.style.bottom=window.innerHeight-h+n+"px"}},[n,i]),{popinRef:e,wrapperRef:t,shown:i,show:s,hide:l}}XX([$X]);const Ej={rgb:"toRgb",hsl:"toHsl",hsv:"toHsv",hex:"toHex"};Ss.extend({color:()=>n=>$a(n).isValid()});const Tj=n=>Ss().color().test(n);function MP(n,{format:e,hasAlpha:t,isString:i}){const r=Ej[e]+(i&&e!=="hex"?"String":""),s=n[r]();return typeof s=="object"&&!t?uW(s,["a"]):s}const EP=(n,e)=>{const t=$a(n);if(!t.isValid())throw Error("Invalid color");return MP(t,e)},wj=(n,e)=>MP($a(n),Yt(Yt({},e),{},{isString:!0,format:"hex"})),Aj=({value:n})=>{const e=WX(n),t=e==="name"?"hex":e,i=typeof n=="object"?"a"in n:e==="hex"&&n.length===8||/^(rgba)|(hsla)|(hsva)/.test(n),r={format:t,hasAlpha:i,isString:typeof n=="string"};return{value:EP(n,r),settings:r}};var Cj=Object.freeze({__proto__:null,schema:Tj,sanitize:EP,format:wj,normalize:Aj});const Rj=Jt("div",{position:"relative",boxSizing:"border-box",borderRadius:"$sm",overflow:"hidden",cursor:"pointer",height:"$rowHeight",width:"$rowHeight",backgroundColor:"#fff",backgroundImage:`url('data:image/svg+xml;charset=utf-8,')`,$inputStyle:"",$hover:"",zIndex:1,variants:{active:{true:{$inputStyle:"$accent1"}}},"&::before":{content:'""',position:"absolute",top:0,bottom:0,right:0,left:0,backgroundColor:"currentColor",zIndex:1}}),Dj=Jt("div",{position:"relative",display:"grid",gridTemplateColumns:"$sizes$rowHeight auto",columnGap:"$colGap",alignItems:"center"}),Oj=Jt("div",{width:"$colorPickerWidth",height:"$colorPickerHeight",".react-colorful":{width:"100%",height:"100%",boxShadow:"$level2",cursor:"crosshair"},".react-colorful__saturation":{borderRadius:"$sm $sm 0 0"},".react-colorful__alpha, .react-colorful__hue":{height:10},".react-colorful__last-control":{borderRadius:"0 0 $sm $sm"},".react-colorful__pointer":{height:12,width:12}});function e3(n,e){return e!=="rgb"?$a(n).toRgb():n}function Ij({value:n,displayValue:e,settings:t,onUpdate:i}){const{emitOnEditStart:r,emitOnEditEnd:s}=Da(),{format:l,hasAlpha:u}=t,{popinRef:h,wrapperRef:p,shown:g,show:y,hide:b}=SP(),x=P.useRef(0),[E,A]=P.useState(()=>e3(n,l)),T=u?JX:t$,M=()=>{A(e3(n,l)),y(),r()},R=()=>{b(),s(),window.clearTimeout(x.current)},O=()=>{x.current=window.setTimeout(R,500)};return P.useEffect(()=>()=>window.clearTimeout(x.current),[]),ae.createElement(ae.Fragment,null,ae.createElement(Rj,{ref:h,active:g,onClick:()=>M(),style:{color:e}}),g&&ae.createElement(bT,null,ae.createElement($I,{onPointerUp:R}),ae.createElement(Oj,{ref:p,onMouseEnter:()=>window.clearTimeout(x.current),onMouseLeave:D=>D.buttons===0&&O()},ae.createElement(T,{color:E,onChange:i}))))}function Pj(){const{value:n,displayValue:e,label:t,onChange:i,onUpdate:r,settings:s}=Da();return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,t),ae.createElement(Dj,null,ae.createElement(Ij,{value:n,displayValue:e,onChange:i,onUpdate:r,settings:s}),ae.createElement(yT,{value:e,onChange:i,onUpdate:r})))}var Lj=Yt({component:Pj},Cj);function Nj(){const{label:n,displayValue:e,onUpdate:t,settings:i}=Da();return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,n),ae.createElement(_T,{value:e,settings:i,onUpdate:t}))}var Uj=Yt({component:Nj},eP(["x","y","z"]));const zj=Jt("div",{$flexCenter:"",position:"relative",backgroundColor:"$elevation3",borderRadius:"$sm",cursor:"pointer",height:"$rowHeight",width:"$rowHeight",touchAction:"none",$draggable:"",$hover:"","&:active":{cursor:"none"},"&::after":{content:'""',backgroundColor:"$accent2",height:4,width:4,borderRadius:2}}),Fj=Jt("div",{$flexCenter:"",width:"$joystickWidth",height:"$joystickHeight",borderRadius:"$sm",boxShadow:"$level2",position:"fixed",zIndex:1e4,overflow:"hidden",$draggable:"",transform:"translate(-50%, -50%)",variants:{isOutOfBounds:{true:{backgroundColor:"$elevation1"},false:{backgroundColor:"$elevation3"}}},"> div":{position:"absolute",$flexCenter:"",borderStyle:"solid",borderWidth:1,borderColor:"$highlight1",backgroundColor:"$elevation3",width:"80%",height:"80%","&::after,&::before":{content:'""',position:"absolute",zindex:10,backgroundColor:"$highlight1"},"&::before":{width:"100%",height:1},"&::after":{height:"100%",width:1}},"> span":{position:"relative",zindex:100,width:10,height:10,backgroundColor:"$accent2",borderRadius:"50%"}});function Bj({value:n,settings:e,onUpdate:t}){const i=P.useRef(),r=P.useRef(0),s=P.useRef(0),l=P.useRef(1),[u,h]=P.useState(!1),[p,g]=P.useState(!1),[y,b]=qI(),x=P.useRef(null),E=P.useRef(null);P.useLayoutEffect(()=>{if(u){const{top:J,left:$,width:oe,height:ne}=x.current.getBoundingClientRect();E.current.style.left=$+oe/2+"px",E.current.style.top=J+ne/2+"px"}},[u]);const{keys:[A,T],joystick:M}=e,R=M==="invertY"?1:-1,{[A]:{step:O},[T]:{step:D}}=e,F=Pc("sizes","joystickWidth"),U=Pc("sizes","joystickHeight"),k=parseFloat(F)*.8/2,H=parseFloat(U)*.8/2,L=P.useCallback(()=>{i.current||(g(!0),r.current&&b({x:r.current*k}),s.current&&b({y:s.current*-H}),i.current=window.setInterval(()=>{t(J=>{const $=O*r.current*l.current,oe=R*D*s.current*l.current;return Array.isArray(J)?{[A]:J[0]+$,[T]:J[1]+oe}:{[A]:J[A]+$,[T]:J[T]+oe}})},16))},[k,H,t,b,O,D,A,T,R]),z=P.useCallback(()=>{window.clearTimeout(i.current),i.current=void 0,g(!1)},[]);P.useEffect(()=>{function J($){l.current=II($)}return window.addEventListener("keydown",J),window.addEventListener("keyup",J),()=>{window.clearTimeout(i.current),window.removeEventListener("keydown",J),window.removeEventListener("keyup",J)}},[]);const W=X0(({first:J,active:$,delta:[oe,ne],movement:[Y,K]})=>{J&&h(!0);const ie=Ju(Y,-k,k),ge=Ju(K,-H,H);r.current=Math.abs(Y)>Math.abs(ie)?Math.sign(Y-ie):0,s.current=Math.abs(K)>Math.abs(ge)?Math.sign(ge-K):0;let xe=n[A],q=n[T];$?(r.current||(xe+=oe*O*l.current,b({x:ie})),s.current||(q-=R*ne*D*l.current,b({y:ge})),r.current||s.current?L():z(),t({[A]:xe,[T]:q})):(h(!1),r.current=0,s.current=0,b({x:0,y:0}),z())});return ae.createElement(zj,dr({ref:x},W()),u&&ae.createElement(bT,null,ae.createElement(Fj,{ref:E,isOutOfBounds:p},ae.createElement("div",null),ae.createElement("span",{ref:y}))))}const kj=Jt("div",{display:"grid",columnGap:"$colGap",variants:{withJoystick:{true:{gridTemplateColumns:"$sizes$rowHeight auto"},false:{gridTemplateColumns:"auto"}}}});function Hj(){const{label:n,displayValue:e,onUpdate:t,settings:i}=Da();return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,n),ae.createElement(kj,{withJoystick:!!i.joystick},i.joystick&&ae.createElement(Bj,{value:e,settings:i,onUpdate:t}),ae.createElement(_T,{value:e,settings:i,onUpdate:t})))}const Vj=["joystick"],TP=eP(["x","y"]),Gj=n=>{let{joystick:e=!0}=n,t=xi(n,Vj);const{value:i,settings:r}=TP.normalize(t);return{value:i,settings:Yt(Yt({},r),{},{joystick:e})}};var Wj=Yt(Yt({component:Hj},TP),{},{normalize:Gj});const Xj=n=>{if(n!==void 0){if(n instanceof File)try{return URL.createObjectURL(n)}catch{return}if(typeof n=="string"&&n.indexOf("blob:")===0)return n;throw Error("Invalid image format [undefined | blob | File].")}},$j=(n,e)=>typeof e=="object"&&"image"in e,jj=({image:n})=>({value:n});var qj=Object.freeze({__proto__:null,sanitize:Xj,schema:$j,normalize:jj});const Yj=Jt("div",{position:"relative",display:"grid",gridTemplateColumns:"$sizes$rowHeight auto 20px",columnGap:"$colGap",alignItems:"center"}),Zj=Jt("div",{$flexCenter:"",overflow:"hidden",height:"$rowHeight",background:"$elevation3",textAlign:"center",color:"inherit",borderRadius:"$sm",outline:"none",userSelect:"none",cursor:"pointer",$inputStyle:"",$hover:"",$focusWithin:"",$active:"$accent1 $elevation1",variants:{isDragAccept:{true:{$inputStyle:"$accent1",backgroundColor:"$elevation1"}}}}),Kj=Jt("div",{boxSizing:"border-box",borderRadius:"$sm",height:"$rowHeight",width:"$rowHeight",$inputStyle:"",backgroundSize:"cover",backgroundPosition:"center",variants:{hasImage:{true:{cursor:"pointer",$hover:"",$active:""}}}}),Qj=Jt("div",{$flexCenter:"",width:"$imagePreviewWidth",height:"$imagePreviewHeight",borderRadius:"$sm",boxShadow:"$level2",pointerEvents:"none",$inputStyle:"",backgroundSize:"cover",backgroundPosition:"center"}),Jj=Jt("div",{fontSize:"0.8em",height:"100%",padding:"$rowGap $md"}),eq=Jt("div",{$flexCenter:"",top:"0",right:"0",marginRight:"$sm",height:"100%",cursor:"pointer",variants:{disabled:{true:{color:"$elevation3",cursor:"default"}}},"&::after,&::before":{content:'""',position:"absolute",height:2,width:10,borderRadius:1,backgroundColor:"currentColor"},"&::after":{transform:"rotate(45deg)"},"&::before":{transform:"rotate(-45deg)"}});function tq(){const{label:n,value:e,onUpdate:t,disabled:i}=Da(),{popinRef:r,wrapperRef:s,shown:l,show:u,hide:h}=SP(),p=P.useCallback(E=>{E.length&&t(E[0])},[t]),g=P.useCallback(E=>{E.stopPropagation(),t(void 0)},[t]),{getRootProps:y,getInputProps:b,isDragAccept:x}=bP({maxFiles:1,accept:"image/*",onDrop:p,disabled:i});return ae.createElement(bo,{input:!0},ae.createElement(Jo,null,n),ae.createElement(Yj,null,ae.createElement(Kj,{ref:r,hasImage:!!e,onPointerDown:()=>!!e&&u(),onPointerUp:h,style:{backgroundImage:e?`url(${e})`:"none"}}),l&&!!e&&ae.createElement(bT,null,ae.createElement($I,{onPointerUp:h,style:{cursor:"pointer"}}),ae.createElement(Qj,{ref:s,style:{backgroundImage:`url(${e})`}})),ae.createElement(Zj,y({isDragAccept:x}),ae.createElement("input",b()),ae.createElement(Jj,null,x?"drop image":"click or drop")),ae.createElement(eq,{onClick:g,disabled:!e})))}var nq=Yt({component:tq},qj);const t3=Ss().number(),iq=(n,e)=>Ss().array().length(2).every.number().test(n)&&Ss().schema({min:t3,max:t3}).test(e),Yx=n=>({min:n[0],max:n[1]}),wP=(n,{bounds:[e,t]},i)=>{const r=Array.isArray(n)?Yx(n):n,s={min:i[0],max:i[1]},{min:l,max:u}=Yt(Yt({},s),r);return[Ju(Number(l),e,Math.max(e,u)),Ju(Number(u),Math.min(t,l),t)]},rq=({value:n,min:e,max:t})=>{const i={min:e,max:t},r=JI(Yx(n),{min:i,max:i}),s=[e,t],l=Yt(Yt({},r),{},{bounds:s});return{value:wP(Yx(n),l,n),settings:l}};var aq=Object.freeze({__proto__:null,schema:iq,format:Yx,sanitize:wP,normalize:rq});const sq=["value","bounds","onDrag"],oq=["bounds"],lq=Jt("div",{display:"grid",columnGap:"$colGap",gridTemplateColumns:"auto calc($sizes$numberInputMinWidth * 2 + $space$rowGap)"});function cq(n){let{value:e,bounds:[t,i],onDrag:r}=n,s=xi(n,sq);const l=P.useRef(null),u=P.useRef(null),h=P.useRef(null),p=P.useRef(0),g=Pc("sizes","scrubberWidth"),y=X0(({event:E,first:A,xy:[T],movement:[M],memo:R={}})=>{if(A){const{width:D,left:F}=l.current.getBoundingClientRect();p.current=D-parseFloat(g);const U=E?.target===u.current||E?.target===h.current;R.pos=Wx((T-F)/D,t,i);const k=Math.abs(R.pos-e.min)-Math.abs(R.pos-e.max);R.key=k<0||k===0&&R.pos<=e.min?"min":"max",U&&(R.pos=e[R.key])}const O=R.pos+Wx(M/p.current,0,i-t);return r({[R.key]:KW(O,s[R.key])}),R}),b=`calc(${Gx(e.min,t,i)} * (100% - ${g} - 8px) + 4px)`,x=`calc(${1-Gx(e.max,t,i)} * (100% - ${g} - 8px) + 4px)`;return ae.createElement(ZI,dr({ref:l},y()),ae.createElement(YI,null,ae.createElement(KI,{style:{left:b,right:x}})),ae.createElement(YM,{position:"left",ref:u,style:{left:b}}),ae.createElement(YM,{position:"right",ref:h,style:{right:x}}))}function uq(){const{label:n,displayValue:e,onUpdate:t,settings:i}=Da(),r=xi(i,oq);return ae.createElement(ae.Fragment,null,ae.createElement(bo,{input:!0},ae.createElement(Jo,null,n),ae.createElement(lq,null,ae.createElement(cq,dr({value:e},i,{onDrag:t})),ae.createElement(_T,{value:e,settings:r,onUpdate:t,innerLabelTrim:0}))))}var fq=Yt({component:uq},aq);const dq=()=>{const n=new Map;return{on:(e,t)=>{let i=n.get(e);i===void 0&&(i=new Set,n.set(e,i)),i.add(t)},off:(e,t)=>{const i=n.get(e);i!==void 0&&(i.delete(t),i.size===0&&n.delete(e))},emit:(e,...t)=>{const i=n.get(e);if(i!==void 0)for(const r of i)r(...t)}}},hq=["type","value"],pq=["onChange","transient","onEditStart","onEditEnd"],mq=function(){const e=nj(ij(()=>({data:{}}))),t=dq();this.storeId=lW(),this.useStore=e;const i={},r=new Set;this.getVisiblePaths=()=>{const l=this.getData(),u=Object.keys(l),h=[];Object.entries(i).forEach(([g,y])=>{y.render&&u.some(b=>b.indexOf(g)===0)&&!y.render(this.get)&&h.push(g+".")});const p=[];return r.forEach(g=>{g in l&&l[g].__refCount>0&&h.every(y=>g.indexOf(y)===-1)&&(!l[g].render||l[g].render(this.get))&&p.push(g)}),p},this.setOrderedPaths=l=>{l.forEach(u=>r.add(u))},this.orderPaths=l=>(this.setOrderedPaths(l),l),this.disposePaths=l=>{e.setState(u=>{const h=u.data;return l.forEach(p=>{if(p in h){const g=h[p];g.__refCount--,g.__refCount===0&&g.type in Yo&&delete h[p]}}),{data:h}})},this.dispose=()=>{e.setState(()=>({data:{}}))},this.getFolderSettings=l=>i[l]||{},this.getData=()=>e.getState().data,this.addData=(l,u)=>{e.setState(h=>{const p=h.data;return Object.entries(l).forEach(([g,y])=>{let b=p[g];if(b){const{type:x,value:E}=y,A=xi(y,hq);x!==b.type?Rc(Cr.INPUT_TYPE_OVERRIDE,g,b.type,x):((b.__refCount===0||u)&&Object.assign(b,A),b.__refCount++)}else p[g]=Yt(Yt({},y),{},{__refCount:1})}),{data:p}})},this.setValueAtPath=(l,u,h)=>{e.setState(p=>{const g=p.data;return hR(g[l],u,l,this,h),{data:g}})},this.setSettingsAtPath=(l,u)=>{e.setState(h=>{const p=h.data;return p[l].settings=Yt(Yt({},p[l].settings),u),{data:p}})},this.disableInputAtPath=(l,u)=>{e.setState(h=>{const p=h.data;return p[l].disabled=u,{data:p}})},this.set=(l,u)=>{e.setState(h=>{const p=h.data;return Object.entries(l).forEach(([g,y])=>{try{hR(p[g],y,void 0,void 0,u)}catch{}}),{data:p}})},this.getInput=l=>{try{return this.getData()[l]}catch{Rc(Cr.PATH_DOESNT_EXIST,l)}},this.get=l=>{var u;return(u=this.getInput(l))===null||u===void 0?void 0:u.value},this.emitOnEditStart=l=>{t.emit(`onEditStart:${l}`,this.get(l),l,Yt(Yt({},this.getInput(l)),{},{get:this.get}))},this.emitOnEditEnd=l=>{t.emit(`onEditEnd:${l}`,this.get(l),l,Yt(Yt({},this.getInput(l)),{},{get:this.get}))},this.subscribeToEditStart=(l,u)=>{const h=`onEditStart:${l}`;return t.on(h,u),()=>t.off(h,u)},this.subscribeToEditEnd=(l,u)=>{const h=`onEditEnd:${l}`;return t.on(h,u),()=>t.off(h,u)};const s=(l,u,h)=>{const p={};return Object.entries(l).forEach(([g,y])=>{if(g==="")return Rc(Cr.EMPTY_KEY);let b=CT(u,g);if(y.type===Yo.FOLDER){const x=s(y.schema,b,h);Object.assign(p,x),b in i||(i[b]=y.settings)}else if(g in h)Rc(Cr.DUPLICATE_KEYS,g,b,h[g].path);else{const x=gW(y,g,b,p);if(x){const{type:E,options:A,input:T}=x,{onChange:M,transient:R,onEditStart:O,onEditEnd:D}=A,F=xi(A,pq);p[b]=Yt(Yt(Yt({type:E},F),T),{},{fromPanel:!0}),h[g]={path:b,onChange:M,transient:R,onEditStart:O,onEditEnd:D}}else Rc(Cr.UNKNOWN_INPUT,b,y)}}),p};this.getDataFromSchema=l=>{const u={};return[s(l,"",u),u]}},Zx=new mq,gq={collapsed:!1};function Xn(n,e){return{type:Yo.FOLDER,schema:n,settings:Yt(Yt({},gq),e)}}const vq={disabled:!1};function sd(n,e){return{type:Yo.BUTTON,onClick:n,settings:Yt(Yt({},vq),e)}}const yq={graph:!1,interval:100};function bq(n,e){return{type:Yo.MONITOR,objectOrFn:n,settings:Yt(Yt({},yq),e)}}const n3=n=>"__levaInput"in n,xq=(n,e)=>{const t={},i=e?e.toLowerCase():null;return n.forEach(r=>{const[s,l]=yj(r);(!i||s.toLowerCase().indexOf(i)>-1)&&vj(t,l,{[s]:{__levaInput:!0,path:r}})}),t},_q=["type","label","path","valueKey","value","settings","setValue","disabled"];function Sq(n){let{type:e,label:t,path:i,valueKey:r,value:s,settings:l,setValue:u,disabled:h}=n,p=xi(n,_q);const{displayValue:g,onChange:y,onUpdate:b}=jI({type:e,value:s,settings:l,setValue:u}),x=Cd[e].component;return x?ae.createElement(zI.Provider,{value:Yt({key:r,path:i,id:""+i,label:t,displayValue:g,value:s,onChange:y,onUpdate:b,settings:l,setValue:u,disabled:h},p)},ae.createElement(NW,{disabled:h},ae.createElement(x,null))):(Rc(Cr.NO_COMPONENT_FOR_TYPE,e,i),null)}const Mq=Jt("button",{display:"block",$reset:"",fontWeight:"$button",height:"$rowHeight",borderStyle:"none",borderRadius:"$sm",backgroundColor:"$elevation1",color:"$highlight1","&:not(:disabled)":{color:"$highlight3",backgroundColor:"$accent2",cursor:"pointer",$hover:"$accent3",$active:"$accent3 $accent1",$focus:""}});function Eq({onClick:n,settings:e,label:t}){const i=G0();return ae.createElement(bo,null,ae.createElement(Mq,{disabled:e.disabled,onClick:()=>n(i.get)},t))}const Tq=Jt("div",{$flex:"",justifyContent:"flex-end",gap:"$colGap"}),wq=Jt("button",{$reset:"",cursor:"pointer",borderRadius:"$xs","&:hover":{backgroundColor:"$elevation3"}}),Aq=({label:n,opts:e})=>{let t=typeof n=="string"&&n.trim()===""?null:n,i=e;return typeof e.opts=="object"&&(i.label!==void 0&&(t=e.label),i=e.opts),{label:t,opts:i}};function Cq(n){const{label:e,opts:t}=Aq(n),i=G0();return ae.createElement(bo,{input:!!e},e&&ae.createElement(Jo,null,e),ae.createElement(Tq,null,Object.entries(t).map(([r,s])=>ae.createElement(wq,{key:r,onClick:()=>s(i.get)},r))))}const Rq=Jt("canvas",{height:"$monitorHeight",width:"100%",display:"block",borderRadius:"$sm"}),AP=100;function Dq(n,e){n.push(e),n.length>AP&&n.shift()}const Oq=P.forwardRef(function({initialValue:n},e){const t=Pc("colors","highlight3"),i=Pc("colors","elevation2"),r=Pc("colors","highlight1"),[s,l]=P.useMemo(()=>[$a(r).alpha(.4).toRgbString(),$a(r).alpha(.1).toRgbString()],[r]),u=P.useRef([n]),h=P.useRef(n),p=P.useRef(n),g=P.useRef(),y=P.useCallback((E,A)=>{if(!E)return;const{width:T,height:M}=E,R=new Path2D,O=T/AP,D=M*.05;for(let k=0;k({frame:E=>{(h.current===void 0||Ep.current)&&(p.current=E),Dq(u.current,E),g.current=requestAnimationFrame(()=>y(b.current,x.current))}}),[b,x,y]),P.useEffect(()=>()=>cancelAnimationFrame(g.current),[]),ae.createElement(Rq,{ref:b})}),i3=n=>Number.isFinite(n)?n.toPrecision(2):n.toString(),Iq=P.forwardRef(function({initialValue:n},e){const[t,i]=P.useState(i3(n));return P.useImperativeHandle(e,()=>({frame:r=>i(i3(r))}),[]),ae.createElement("div",null,t)});function r3(n){return typeof n=="function"?n():n.current}function Pq({label:n,objectOrFn:e,settings:t}){const i=P.useRef(),r=P.useRef(r3(e));return P.useEffect(()=>{const s=window.setInterval(()=>{var l;document.hidden||(l=i.current)===null||l===void 0||l.frame(r3(e))},t.interval);return()=>window.clearInterval(s)},[e,t.interval]),ae.createElement(bo,{input:!0},ae.createElement(Jo,{align:"top"},n),t.graph?ae.createElement(Oq,{ref:i,initialValue:r.current}):ae.createElement(Iq,{ref:i,initialValue:r.current}))}const Lq=["type","label","key"],Nq={[Yo.BUTTON]:Eq,[Yo.BUTTON_GROUP]:Cq,[Yo.MONITOR]:Pq},Uq=ae.memo(({path:n})=>{const[e,{set:t,setSettings:i,disable:r,storeId:s,emitOnEditStart:l,emitOnEditEnd:u}]=$W(n);if(!e)return null;const{type:h,label:p,key:g}=e,y=xi(e,Lq);if(h in Yo){const b=Nq[h];return ae.createElement(b,dr({label:p,path:n},y))}return h in Cd?ae.createElement(Sq,dr({key:s+n,type:h,label:p,storeId:s,path:n,valueKey:g,setValue:t,setSettings:i,disable:r,emitOnEditStart:l,emitOnEditEnd:u},y)):(Q7(Cr.UNSUPPORTED_INPUT,h,n),null)});function zq({toggle:n,toggled:e,name:t}){return ae.createElement(IW,{onClick:()=>n()},ae.createElement(xT,{toggled:e}),ae.createElement("div",null,t))}const Fq=({name:n,path:e,tree:t})=>{const i=G0(),r=CT(e,n),{collapsed:s,color:l}=i.getFolderSettings(r),[u,h]=P.useState(!s),p=P.useRef(null),g=Pc("colors","folderWidgetColor"),y=Pc("colors","folderTextColor");return P.useLayoutEffect(()=>{p.current.style.setProperty("--leva-colors-folderWidgetColor",l||g),p.current.style.setProperty("--leva-colors-folderTextColor",l||y)},[l,g,y]),ae.createElement(Xx,{ref:p},ae.createElement(zq,{name:n,toggled:u,toggle:()=>h(b=>!b)}),ae.createElement(CP,{parent:r,tree:t,toggled:u}))},CP=ae.memo(({isRoot:n=!1,fill:e=!1,flat:t=!1,parent:i,tree:r,toggled:s})=>{const{wrapperRef:l,contentRef:u}=_j(s),h=G0(),p=([y,b])=>{var x;return(n3(b)?(x=h.getInput(b.path))===null||x===void 0?void 0:x.order:h.getFolderSettings(CT(i,y)).order)||0},g=Object.entries(r).sort((y,b)=>p(y)-p(b));return ae.createElement(jM,{ref:l,isRoot:n,fill:e,flat:t},ae.createElement(GI,{ref:u,isRoot:n,toggled:s},g.map(([y,b])=>n3(b)?ae.createElement(Uq,{key:b.path,valueKey:b.valueKey,path:b.path}):ae.createElement(Fq,{key:y,name:y,path:i,tree:b}))))}),Bq=Jt("div",{position:"relative",fontFamily:"$mono",fontSize:"$root",color:"$rootText",backgroundColor:"$elevation1",variants:{fill:{false:{position:"fixed",top:"10px",right:"10px",zIndex:1e3,width:"$rootWidth"},true:{position:"relative",width:"100%"}},flat:{false:{borderRadius:"$lg",boxShadow:"$level1"}},oneLineLabels:{true:{[`${XI}`]:{gridTemplateColumns:"auto",gridAutoColumns:"minmax(max-content, 1fr)",gridAutoRows:"minmax($sizes$rowHeight), auto)",rowGap:0,columnGap:0,marginTop:"$rowGap"}}},hideTitleBar:{true:{$$titleBarHeight:"0px"},false:{$$titleBarHeight:"$sizes$titleBarHeight"}}},"&,*,*:after,*:before":{boxSizing:"border-box"},"*::selection":{backgroundColor:"$accent2"}}),RP=40,Kx=Jt("i",{$flexCenter:"",width:RP,userSelect:"none",cursor:"pointer","> svg":{fill:"$highlight1",transition:"transform 350ms ease, fill 250ms ease"},"&:hover > svg":{fill:"$highlight3"},variants:{active:{true:{"> svg":{fill:"$highlight2"}}}}}),kq=Jt("div",{display:"flex",alignItems:"stretch",justifyContent:"space-between",height:"$titleBarHeight",variants:{mode:{drag:{cursor:"grab"}}}}),Hq=Jt("div",{$flex:"",position:"relative",width:"100%",overflow:"hidden",transition:"height 250ms ease",color:"$highlight3",paddingLeft:"$md",[`> ${Kx}`]:{height:30},variants:{toggled:{true:{height:30},false:{height:0}}}}),Vq=Jt("input",{$reset:"",flex:1,position:"relative",height:30,width:"100%",backgroundColor:"transparent",fontSize:"10px",borderRadius:"$root","&:focus":{},"&::placeholder":{color:"$highlight2"}}),Gq=Jt("div",{touchAction:"none",$flexCenter:"",flex:1,"> svg":{fill:"$highlight1"},color:"$highlight1",variants:{drag:{true:{$draggable:"","> svg":{transition:"fill 250ms ease"},"&:hover":{color:"$highlight3"},"&:hover > svg":{fill:"$highlight3"}}},filterEnabled:{false:{paddingRight:RP}}}}),Wq=ae.forwardRef(({setFilter:n,toggle:e},t)=>{const[i,r]=P.useState(""),s=P.useMemo(()=>OI(n,250),[n]),l=()=>{n(""),r("")},u=h=>{const p=h.currentTarget.value;e(!0),r(p)};return P.useEffect(()=>{s(i)},[i,s]),ae.createElement(ae.Fragment,null,ae.createElement(Vq,{ref:t,value:i,placeholder:"[Open filter with CMD+SHIFT+L]",onPointerDown:h=>h.stopPropagation(),onChange:u}),ae.createElement(Kx,{onClick:()=>l(),style:{visibility:i?"visible":"hidden"}},ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"14",width:"14",viewBox:"0 0 20 20",fill:"currentColor"},ae.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"}))))});function Xq({setFilter:n,onDrag:e,onDragStart:t,onDragEnd:i,toggle:r,toggled:s,title:l,drag:u,filterEnabled:h,from:p}){const[g,y]=P.useState(!1),b=P.useRef(null);P.useEffect(()=>{var E,A;g?(E=b.current)===null||E===void 0||E.focus():(A=b.current)===null||A===void 0||A.blur()},[g]);const x=X0(({offset:[E,A],first:T,last:M})=>{e({x:E,y:A}),T&&t({x:E,y:A}),M&&i({x:E,y:A})},{filterTaps:!0,from:({offset:[E,A]})=>[p?.x||E,p?.y||A]});return P.useEffect(()=>{const E=A=>{A.key==="L"&&A.shiftKey&&A.metaKey&&y(T=>!T)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[]),ae.createElement(ae.Fragment,null,ae.createElement(kq,{mode:u?"drag":void 0},ae.createElement(Kx,{active:!s,onClick:()=>r()},ae.createElement(xT,{toggled:s,width:12,height:8})),ae.createElement(Gq,dr({},u?x():{},{drag:u,filterEnabled:h}),l===void 0&&u?ae.createElement("svg",{width:"20",height:"10",viewBox:"0 0 28 14",xmlns:"http://www.w3.org/2000/svg"},ae.createElement("circle",{cx:"2",cy:"2",r:"2"}),ae.createElement("circle",{cx:"14",cy:"2",r:"2"}),ae.createElement("circle",{cx:"26",cy:"2",r:"2"}),ae.createElement("circle",{cx:"2",cy:"12",r:"2"}),ae.createElement("circle",{cx:"14",cy:"12",r:"2"}),ae.createElement("circle",{cx:"26",cy:"12",r:"2"})):l),h&&ae.createElement(Kx,{active:g,onClick:()=>y(E=>!E)},ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20",viewBox:"0 0 20 20"},ae.createElement("path",{d:"M9 9a2 2 0 114 0 2 2 0 01-4 0z"}),ae.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-13a4 4 0 00-3.446 6.032l-2.261 2.26a1 1 0 101.414 1.415l2.261-2.261A4 4 0 1011 5z",clipRule:"evenodd"})))),ae.createElement(Hq,{toggled:g},ae.createElement(Wq,{ref:b,setFilter:n,toggle:r})))}const $q=["store","hidden","theme","collapsed"];function jq(n){let{store:e,hidden:t=!1,theme:i,collapsed:r=!1}=n,s=xi(n,$q);const l=_P(()=>wW(i),[i]),[u,h]=P.useState(!r),p=typeof r=="object"?!r.collapsed:u,g=P.useMemo(()=>typeof r=="object"?y=>{typeof y=="function"?r.onChange(!y(!r.collapsed)):r.onChange(!y)}:h,[r]);return!e||t?null:ae.createElement(vT.Provider,{value:l},ae.createElement(qq,dr({store:e},s,{toggled:p,setToggle:g,rootClass:l.className})))}const qq=ae.memo(({store:n,rootClass:e,fill:t=!1,flat:i=!1,neverHide:r=!1,oneLineLabels:s=!1,titleBar:l={title:void 0,drag:!0,filter:!0,position:void 0,onDrag:void 0,onDragStart:void 0,onDragEnd:void 0},hideCopyButton:u=!1,toggled:h,setToggle:p})=>{var g,y;const b=Sj(n),[x,E]=P.useState(""),A=P.useMemo(()=>xq(b,x),[b,x]),[T,M]=qI(),R=r||b.length>0,O=typeof l=="object"&&l.title||void 0,D=typeof l=="object"&&(g=l.drag)!==null&&g!==void 0?g:!0,F=typeof l=="object"&&(y=l.filter)!==null&&y!==void 0?y:!0,U=typeof l=="object"&&l.position||void 0,k=typeof l=="object"&&l.onDrag||void 0,H=typeof l=="object"&&l.onDragStart||void 0,L=typeof l=="object"&&l.onDragEnd||void 0;return ae.useEffect(()=>{M({x:U?.x,y:U?.y})},[U,M]),TW(),ae.createElement(X7,null,ae.createElement(BI.Provider,{value:{hideCopyButton:u}},ae.createElement(Bq,{ref:T,className:e,fill:t,flat:i,oneLineLabels:s,hideTitleBar:!l,style:{display:R?"block":"none"}},l&&ae.createElement(Xq,{onDrag:z=>{M(z),k?.(z)},onDragStart:z=>H?.(z),onDragEnd:z=>L?.(z),setFilter:E,toggle:z=>p(W=>z??!W),toggled:h,title:O,drag:D,filterEnabled:F,from:U}),R&&ae.createElement(FI.Provider,{value:n},ae.createElement(CP,{isRoot:!0,fill:t,flat:i,tree:A,toggled:h})))))}),Yq=["isRoot"];let Qx=!1,md=null;function DP(n){let{isRoot:e=!1}=n,t=xi(n,Yq);return P.useEffect(()=>(Qx=!0,!e&&md&&(md.remove(),md=null),()=>{e||(Qx=!1)}),[e]),ae.createElement(jq,dr({store:Zx},t))}function Zq(n){P.useEffect(()=>{n&&!Qx&&(md||(md=document.getElementById("leva__root")||Object.assign(document.createElement("div"),{id:"leva__root"}),document.body&&(document.body.appendChild(md),h3.createRoot(md).render(ae.createElement(DP,{isRoot:!0})))),Qx=!0)},[n])}function Kq(n,e,t,i,r){let s,l,u,h,p;return typeof n=="string"?(l=n,s=e,Array.isArray(t)?p=t:t&&("store"in t?(h=t,p=i):(u=t,Array.isArray(i)?p=i:(h=i,p=r)))):(s=n,Array.isArray(e)?p=e:(h=e,p=t)),{schema:s,folderName:l,folderSettings:u,hookSettings:h,deps:p||[]}}function la(n,e,t,i,r){const{folderName:s,schema:l,folderSettings:u,hookSettings:h,deps:p}=Kq(n,e,t,i,r),g=typeof l=="function",y=P.useRef(!1),b=P.useRef(!0),x=_P(()=>{y.current=!0;const W=typeof l=="function"?l():l;return s?{[s]:Xn(W,u)}:W},p),E=!(h!=null&&h.store);Zq(E);const[A]=P.useState(()=>h?.store||Zx),[T,M]=P.useMemo(()=>A.getDataFromSchema(x),[A,x]),[R,O,D,F,U]=P.useMemo(()=>{const W=[],J=[],$={},oe={},ne={};return Object.values(M).forEach(({path:Y,onChange:K,onEditStart:ie,onEditEnd:ge,transient:xe})=>{W.push(Y),K?($[Y]=K,xe||J.push(Y)):J.push(Y),ie&&(oe[Y]=ie),ge&&(ne[Y]=ge)}),[W,J,$,oe,ne]},[M]),k=P.useMemo(()=>A.orderPaths(R),[R,A]),H=Mj(A,O,T),L=P.useCallback(W=>{const J=Object.entries(W).reduce(($,[oe,ne])=>Object.assign($,{[M[oe].path]:ne}),{});A.set(J,!1)},[A,M]),z=P.useCallback(W=>A.get(M[W].path),[A,M]);return P.useEffect(()=>{const W=!b.current&&y.current;return A.addData(T,W),b.current=!1,y.current=!1,()=>A.disposePaths(k)},[A,k,T]),P.useEffect(()=>{const W=[];return Object.entries(D).forEach(([J,$])=>{$(A.get(J),J,Yt({initial:!0,get:A.get},A.getInput(J)));const oe=A.useStore.subscribe(ne=>{const Y=ne.data[J];return[Y.disabled?void 0:Y.value,Y]},([ne,Y])=>$(ne,J,Yt({initial:!1,get:A.get},Y)),{equalityFn:F_});W.push(oe)}),()=>W.forEach(J=>J())},[A,D]),P.useEffect(()=>{const W=[];return Object.entries(F).forEach(([J,$])=>W.push(A.subscribeToEditStart(J,$))),Object.entries(U).forEach(([J,$])=>W.push(A.subscribeToEditEnd(J,$))),()=>W.forEach(J=>J())},[F,U,A]),g?[H,L,z]:H}Fc(Bc.SELECT,cX);Fc(Bc.IMAGE,nq);Fc(Bc.NUMBER,JW);Fc(Bc.COLOR,Lj);Fc(Bc.STRING,yX);Fc(Bc.BOOLEAN,TX);Fc(Bc.INTERVAL,fq);Fc(Bc.VECTOR3D,Uj);Fc(Bc.VECTOR2D,Wj);const mp=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,0,1,0,-1]),Qq=.5*(Math.sqrt(3)-1),zg=(3-Math.sqrt(3))/6;function Jq(n){let e=Math.floor(n)|0;return()=>{e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function eY(n){const e=new Uint8Array(512),t=new Uint8Array(256);for(let r=0;r<256;r++)t[r]=r;const i=Jq(n);for(let r=255;r>0;r--){const s=Math.floor(i()*(r+1)),l=t[r];t[r]=t[s],t[s]=l}for(let r=0;r<512;r++)e[r]=t[r&255];return(r,s)=>{const l=(r+s)*Qq,u=Math.floor(r+l),h=Math.floor(s+l),p=(u+h)*zg,g=r-(u-p),y=s-(h-p),b=g>y?1:0,x=g>y?0:1,E=g-b+zg,A=y-x+zg,T=g-1+2*zg,M=y-1+2*zg,R=u&255,O=h&255;let D=0,F=.5-g*g-y*y;if(F>=0){const z=(e[R+e[O]]&7)*2;F*=F,D=F*F*(mp[z]*g+mp[z+1]*y)}let U=0,k=.5-E*E-A*A;if(k>=0){const z=(e[R+b+e[O+x]]&7)*2;k*=k,U=k*k*(mp[z]*E+mp[z+1]*A)}let H=0,L=.5-T*T-M*M;if(L>=0){const z=(e[R+1+e[O+1]]&7)*2;L*=L,H=L*L*(mp[z]*T+mp[z+1]*M)}return 70*(D+U+H)}}function tY(n,e,t,i,r,s){const l=eY(e),u=(n+1)*(n+1),h=new Float32Array(u);let p=1/0,g=-1/0;for(let b=0;b<=n;b++)for(let x=0;x<=n;x++){const E=b*(n+1)+x,A=x/n,T=b/n;let M=1,R=t,O=0,D=0;for(let U=0;Ug&&(g=F)}const y=g-p||1;for(let b=0;bnew rY,[]);return g.uniforms.get("threshold").value=t,g.uniforms.get("pixelScale").value=i,g.uniforms.get("mix_amount").value=e?r:0,g.uniforms.get("patternSize").value=s,g.uniforms.get("ditherColor").value.set(l),g.uniforms.get("ditherBgColor").value.set(u),g.uniforms.get("blendMode").value=iY[h]??0,xt.jsx("primitive",{ref:p,object:g,dispose:null})}),sY={normal:0,multiply:1,screen:2,overlay:3,add:4,softLight:5},oY=` attribute float aNormHeight; varying float vNormHeight; varying vec2 vUv; varying vec3 vWorldPos; varying float vViewDist; void main() { vNormHeight = aNormHeight; vUv = uv; vec4 wp = modelMatrix * vec4(position, 1.0); vWorldPos = wp.xyz; vec4 mvPosition = viewMatrix * wp; vViewDist = -mvPosition.z; gl_Position = projectionMatrix * mvPosition; } `,lY=` precision highp float; #define MAX_PEAK_LIGHTS 10 uniform sampler2D uGradientMap; uniform float uShadingStrength; uniform bool uFogEnabled; uniform vec3 uFogColor; uniform float uFogNear; uniform float uFogFar; uniform bool uGridInScene; uniform vec3 uGridColor; uniform float uGridOpacity; uniform float uGridThickness; uniform float uSubdivisions; // Real point lights driven from active peaks. Each slot is independent; // unused slots have intensity = 0 so they contribute nothing. uniform int uPointLightCount; uniform vec3 uPointLightPositions[MAX_PEAK_LIGHTS]; uniform vec3 uPointLightColors[MAX_PEAK_LIGHTS]; uniform float uPointLightIntensities[MAX_PEAK_LIGHTS]; uniform float uPointLightRanges[MAX_PEAK_LIGHTS]; varying float vNormHeight; varying vec2 vUv; varying vec3 vWorldPos; varying float vViewDist; void main() { vec3 surfaceColor = texture2D(uGradientMap, vec2(clamp(vNormHeight, 0.0, 1.0), 0.5)).rgb; vec3 dx = dFdx(vWorldPos); vec3 dy = dFdy(vWorldPos); vec3 normal = normalize(cross(dx, dy)); vec3 lightDir = normalize(vec3(0.5, 1.0, 0.3)); float NdotL = max(dot(normal, lightDir), 0.0); float lighting = 0.5 + 0.5 * NdotL; surfaceColor *= mix(1.0, lighting, uShadingStrength); // Point-light accumulation — lambertian × quadratic attenuation, summed // over all active peak lights. The if-guard inside a constant-bounded // loop is the portable WebGL1 idiom (avoids non-uniform continue/break). vec3 lightContribution = vec3(0.0); for (int i = 0; i < MAX_PEAK_LIGHTS; i++) { if (i < uPointLightCount) { vec3 toLight = uPointLightPositions[i] - vWorldPos; float dist = length(toLight); float invRange = 1.0 / max(uPointLightRanges[i], 0.001); float att = max(0.0, 1.0 - dist * invRange); att = att * att; vec3 ld = toLight / max(dist, 0.001); float lambert = max(0.0, dot(normal, ld)); lightContribution += uPointLightColors[i] * (uPointLightIntensities[i] * lambert * att); } } surfaceColor += lightContribution; if (uGridInScene) { vec2 coord = vUv * uSubdivisions; vec2 grid = abs(fract(coord - 0.5) - 0.5); vec2 fw = fwidth(coord); vec2 lines = smoothstep(fw * uGridThickness, fw * (uGridThickness + 1.0), grid); float gridMask = 1.0 - min(lines.x, lines.y); surfaceColor = mix(surfaceColor, uGridColor, gridMask * uGridOpacity); } vec3 finalColor = surfaceColor; if (uFogEnabled) { float fogFactor = smoothstep(uFogNear, uFogFar, vViewDist); finalColor = mix(finalColor, uFogColor, fogFactor); } gl_FragColor = vec4(finalColor, 1.0); } `,Is=` varying vec2 vUv; varying float vViewDist; void main() { vUv = uv; vec4 mvPosition = modelViewMatrix * vec4(position, 1.0); vViewDist = -mvPosition.z; gl_Position = projectionMatrix * mvPosition; } `,cY=` precision highp float; uniform vec3 uGridColor; uniform float uGridOpacity; uniform float uGridThickness; uniform float uSubdivisions; uniform bool uFogEnabled; uniform vec3 uFogColor; uniform float uFogNear; uniform float uFogFar; varying vec2 vUv; varying float vViewDist; void main() { vec2 coord = vUv * uSubdivisions; vec2 grid = abs(fract(coord - 0.5) - 0.5); vec2 fw = fwidth(coord); vec2 lines = smoothstep(fw * uGridThickness, fw * (uGridThickness + 1.0), grid); float gridMask = 1.0 - min(lines.x, lines.y); float alpha = gridMask * uGridOpacity; if (uFogEnabled) { float fogFactor = smoothstep(uFogNear, uFogFar, vViewDist); alpha *= (1.0 - fogFactor); } if (alpha < 0.001) discard; gl_FragColor = vec4(uGridColor * alpha, alpha); } `,Ob=` precision highp float; uniform sampler2D uPixelBrightness; uniform vec3 uPixelColor; uniform float uPixelOpacity; uniform bool uFogEnabled; uniform float uFogNear; uniform float uFogFar; varying vec2 vUv; varying float vViewDist; void main() { float brightness = texture2D(uPixelBrightness, vUv).r; if (uFogEnabled) { float fogFactor = smoothstep(uFogNear, uFogFar, vViewDist); brightness *= (1.0 - fogFactor); } float alpha = brightness * uPixelOpacity; gl_FragColor = vec4(uPixelColor * alpha, alpha); } `,Fg=` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `,uY=` precision highp float; uniform sampler2D tInput; uniform float threshold; uniform float pixelScale; uniform float mixAmount; uniform int patternSize; uniform vec3 ditherColor; uniform int blendMode; uniform vec2 res; varying vec2 vUv; const int bayer8x8[64] = int[64]( 0, 32, 8, 40, 2, 34, 10, 42, 48, 16, 56, 24, 50, 18, 58, 26, 12, 44, 4, 36, 14, 46, 6, 38, 60, 28, 52, 20, 62, 30, 54, 22, 3, 35, 11, 43, 1, 33, 9, 41, 51, 19, 59, 27, 49, 17, 57, 25, 15, 47, 7, 39, 13, 45, 5, 37, 63, 31, 55, 23, 61, 29, 53, 21 ); float getBayerValue(ivec2 coord, int size) { if (size <= 2) { int lut[4] = int[4](0, 2, 3, 1); return float(lut[(coord.y % 2) * 2 + (coord.x % 2)]) / 4.0; } else if (size <= 4) { int bayer4x4[16] = int[16](0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5); return float(bayer4x4[(coord.y % 4) * 4 + (coord.x % 4)]) / 16.0; } else { return float(bayer8x8[(coord.y % 8) * 8 + (coord.x % 8)]) / 64.0; } } vec3 blendMultiply(vec3 b, vec3 t) { return b * t; } vec3 blendScreen(vec3 b, vec3 t) { return 1.0 - (1.0 - b) * (1.0 - t); } vec3 blendOverlay(vec3 b, vec3 t) { return vec3( b.r < 0.5 ? 2.0*b.r*t.r : 1.0-2.0*(1.0-b.r)*(1.0-t.r), b.g < 0.5 ? 2.0*b.g*t.g : 1.0-2.0*(1.0-b.g)*(1.0-t.g), b.b < 0.5 ? 2.0*b.b*t.b : 1.0-2.0*(1.0-b.b)*(1.0-t.b) ); } vec3 blendAdd(vec3 b, vec3 t) { return min(b + t, 1.0); } vec3 blendSoftLight(vec3 b, vec3 t) { return vec3( t.r < 0.5 ? b.r-(1.0-2.0*t.r)*b.r*(1.0-b.r) : b.r+(2.0*t.r-1.0)*(sqrt(b.r)-b.r), t.g < 0.5 ? b.g-(1.0-2.0*t.g)*b.g*(1.0-b.g) : b.g+(2.0*t.g-1.0)*(sqrt(b.g)-b.g), t.b < 0.5 ? b.b-(1.0-2.0*t.b)*b.b*(1.0-b.b) : b.b+(2.0*t.b-1.0)*(sqrt(b.b)-b.b) ); } vec3 applyBlend(vec3 b, vec3 t, int mode) { if (mode == 1) return blendMultiply(b, t); if (mode == 2) return blendScreen(b, t); if (mode == 3) return blendOverlay(b, t); if (mode == 4) return blendAdd(b, t); if (mode == 5) return blendSoftLight(b, t); return t; } void main() { vec2 cellIndex = floor(gl_FragCoord.xy / max(pixelScale, 1.0)); vec2 snappedUV = (cellIndex + 0.5) * max(pixelScale, 1.0) / res; vec4 cellColor = texture2D(tInput, clamp(snappedUV, 0.0, 1.0)); float lum = dot(cellColor.rgb, vec3(0.2126, 0.7152, 0.0722)); float patternVal = getBayerValue(ivec2(cellIndex), patternSize); float dithered = step(patternVal, lum + threshold - 0.5); vec3 blended = applyBlend(cellColor.rgb, ditherColor, blendMode); vec3 onColor = mix(cellColor.rgb, blended, mixAmount); // off pixels → black / transparent (works with any composite blend mode) gl_FragColor = vec4(onColor * dithered, dithered * mixAmount); } `,fY=` precision highp float; uniform sampler2D tInput; uniform bool caEnabled; uniform float caStrength; uniform int caSamples; varying vec2 vUv; void main() { vec3 color; if (caEnabled) { float rAcc = 0.0, gAcc = 0.0, bAcc = 0.0; // Unroll up to 8 samples; iterations beyond caSamples are skipped via weight. for (int i = 0; i < 8; i++) { if (i >= caSamples) break; float t = (caSamples == 1) ? 1.0 : float(i) / float(caSamples - 1); vec2 dir = (vUv - 0.5) * t * caStrength; rAcc += texture2D(tInput, clamp(vUv + dir, 0.0, 1.0)).r; gAcc += texture2D(tInput, vUv).g; bAcc += texture2D(tInput, clamp(vUv - dir, 0.0, 1.0)).b; } float n = float(caSamples); color = vec3(rAcc / n, gAcc / n, bAcc / n); } else { color = texture2D(tInput, vUv).rgb; } // Preserve premultiplied alpha from the input so compositing works correctly // regardless of which blend mode is used in the final composite pass. float alpha = texture2D(tInput, vUv).a; gl_FragColor = vec4(color, alpha); } `,dY=` precision highp float; uniform sampler2D tInput; uniform vec2 resolution; uniform vec2 direction; uniform float radius; varying vec2 vUv; void main() { vec2 step = direction * radius / resolution; vec4 sum = vec4(0.0); sum += texture2D(tInput, vUv + step * -4.0) * 0.0625; sum += texture2D(tInput, vUv + step * -3.0) * 0.125; sum += texture2D(tInput, vUv + step * -2.0) * 0.25; sum += texture2D(tInput, vUv + step * -1.0) * 0.5; sum += texture2D(tInput, vUv ) * 1.0; sum += texture2D(tInput, vUv + step * 1.0) * 0.5; sum += texture2D(tInput, vUv + step * 2.0) * 0.25; sum += texture2D(tInput, vUv + step * 3.0) * 0.125; sum += texture2D(tInput, vUv + step * 4.0) * 0.0625; gl_FragColor = sum / 2.8125; } `,hY=` precision highp float; uniform sampler2D tInput; varying vec2 vUv; void main() { gl_FragColor = texture2D(tInput, vUv); } `,pY=` precision highp float; uniform sampler2D tInput; uniform float bloomStrength; varying vec2 vUv; void main() { gl_FragColor = texture2D(tInput, vUv) * bloomStrength; } `,mY=` precision highp float; varying vec2 vUv; uniform vec3 uRingColor; uniform vec3 uFillColor; uniform float uRingThickness; // fraction of radius (0..0.5) uniform float uRingOpacity; uniform float uFillOpacity; uniform float uAlpha; // per-peak fade-in / fade-out multiplier void main() { vec2 p = (vUv - 0.5) * 2.0; float d = length(p); float aa = fwidth(d); float ringInner = 1.0 - uRingThickness; float outerEdge = 1.0 - smoothstep(1.0 - aa, 1.0, d); float innerEdge = smoothstep(ringInner - aa, ringInner, d); float ringMask = outerEdge * innerEdge; float fillMask = 1.0 - innerEdge; vec3 color = mix(uFillColor, uRingColor, ringMask); float alpha = mix(fillMask * uFillOpacity, uRingOpacity, ringMask) * uAlpha; if (alpha < 0.001) discard; gl_FragColor = vec4(color, alpha); } `,gY=` precision highp float; varying vec2 vUv; uniform vec3 uColor; uniform float uOpacity; uniform float uAlpha; // global line-layer alpha (fade-out on peak retire) uniform float uProgress; // 0..1, how much of the segment is drawn uniform float uHalfThickness; // px — half the visible (opaque) line thickness uniform float uQuadHeight; // px — total quad height (= 2*halfThickness + 2*aaMargin) void main() { // Length-wise AA at the draw head — soften the leading edge while the // segment animates in. fwidth(vUv.x) ≈ 1 / segmentLengthPx. float headDist = uProgress - vUv.x; if (headDist < 0.0) discard; float headAA = smoothstep(0.0, fwidth(vUv.x), headDist); // Perpendicular AA — the quad is inflated by aaMargin on each side beyond // the visible line thickness; we compute pixel distance from the line's // center axis and fade across the margin. float pixelDist = abs(vUv.y - 0.5) * uQuadHeight; float aaMargin = max((uQuadHeight - 2.0 * uHalfThickness) * 0.5, 0.5); float perpAA = 1.0 - smoothstep(uHalfThickness, uHalfThickness + aaMargin, pixelDist); if (perpAA <= 0.0) discard; gl_FragColor = vec4(uColor, uOpacity * uAlpha * headAA * perpAA); } `;function vY(n){const e=parseInt(n.slice(1,3),16)/255,t=parseInt(n.slice(3,5),16)/255,i=parseInt(n.slice(5,7),16)/255;return[e,t,i]}function yY(n){const t=new Uint8Array(2048),i=n.length,r=n.map(vY);for(let l=0;l<512;l++){const h=l/511*(i-1),p=Math.min(Math.floor(h),i-2),g=h-p,y=r[p],b=r[p+1];t[l*4+0]=Math.round((y[0]+(b[0]-y[0])*g)*255),t[l*4+1]=Math.round((y[1]+(b[1]-y[1])*g)*255),t[l*4+2]=Math.round((y[2]+(b[2]-y[2])*g)*255),t[l*4+3]=255}const s=new Ta(t,512,1,ca);return s.minFilter=Kn,s.magFilter=Kn,s.needsUpdate=!0,s}function OP(n){return n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2}function bY(n){return n<.5?2*n*n:1-Math.pow(-2*n+2,2)/2}function xY(n){return-(Math.cos(Math.PI*n)-1)/2}function _Y(n){return n*n*n}function SY(n){return 1-Math.pow(1-n,3)}function MY(n){return n===0?0:n===1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2}function EY(n){return n===1?1:1-Math.pow(2,-10*n)}const Vo={linear:n=>n,easeInOutCubic:OP,easeInOutQuad:bY,easeInOutSine:xY,easeInCubic:_Y,easeOutCubic:SY,easeOutExpo:EY,easeInOutExpo:MY};function uM(n,e){const t=Math.floor(n),i=t+1,r=n-t,s=(p,g)=>{let y=Math.imul(p|0,374761393)+Math.imul(g|0,668265263)|0;return y=Math.imul(y^y>>>13,1274126177)|0,y=y^y>>>16,(y>>>0)/4294967295},l=s(t,e),u=s(i,e),h=r*r*(3-2*r);return l+(u-l)*h}function TY(n,e){return uM(n*1,e)*.5+uM(n*2.3,e+1)*.3+uM(n*4.7,e+2)*.2}function Bg(n,e){switch(n.blending=e_,n.blendEquation=Ac,e){case"add":n.blendSrc=Bu,n.blendDst=Bu;break;case"screen":n.blendSrc=Bu,n.blendDst=lE;break;case"multiply":n.blendSrc=cE,n.blendDst=Tp;break;case"lighten":n.blendEquation=oE,n.blendSrc=Bu,n.blendDst=Bu;break;default:n.blendSrc=Bu,n.blendDst=Tp;break}}const a3=24,wY=` precision highp float; varying vec2 vUv; uniform sampler2D uMap; uniform float uOpacity; void main() { vec4 tex = texture2D(uMap, vUv); float coverage = min(uOpacity, 1.0); float intensity = max(uOpacity, 1.0); float a = tex.a * coverage; if (a < 0.001) discard; gl_FragColor = vec4(tex.rgb * intensity * a, a); } `;function AY(n){return{pixels:[],spawnAccumulator:0,brightnessData:new Float32Array(n*n)}}function s3(n,e,t,i,r,s,l,u,h){const p=u!==void 0?Math.max(0,Math.min(1,u)):Math.random(),g=h!==void 0?Math.max(0,Math.min(1,h)):Math.random(),y=Math.min(t,e),x=(y+Math.random()*Math.max(0,e-y))/n,E=Math.random()*Math.PI*2,A=Math.max(0,Math.min(1,p+Math.cos(E)*x)),T=Math.max(0,Math.min(1,g+Math.sin(E)*x)),M=i+Math.random()*Math.max(0,r-i),R=Math.floor(p*n),O=Math.floor(g*n),D=(A-p)/Math.max(M,.001),F=(T-g)/Math.max(M,.001);return{x:p,y:g,targetX:A,targetY:T,startX:p,startY:g,lifetime:M,age:0,trail:[{x:R,y:O,age:0}],lastCellX:R,lastCellY:O,easingType:s,easingStrength:l,gravityActive:!1,vx:D,vy:F,arrived:!1,skipFadeIn:!1}}function CY(n){const e=Math.max(n.lifetime,.001),t=Math.min(n.age/e,1),i=Vo[n.easingType]??Vo.easeInOutCubic,r=.001,s=Math.min(t+r,1),l=Math.max(t-r,0),u=s+(i(s)-s)*n.easingStrength,h=l+(i(l)-l)*n.easingStrength,g=(u-h)/Math.max(s-l,1e-6)/e;return{vx:(n.targetX-n.startX)*g,vy:(n.targetY-n.startY)*g}}function RY(n,e,t,i,r,s,l,u,h,p){if(!i.enabled){n.pixels=[],n.brightnessData.fill(0),r&&(r.length=0);return}if(r&&r.length>0){if(s?.enabled){const D=s.easingType??i.easingType,F=s.easingStrength??i.easingStrength;for(const U of r){const k=Math.max(1,Math.floor(s.count));for(let H=0;H=1;)n.spawnAccumulator-=1,n.pixels.length0){let k=null,H=1/0;for(const L of l.peaks){const z=L.cellX-D.lastCellX,W=L.cellY-D.lastCellY,J=z*z+W*W;J<=l.gravityRadiusCells*l.gravityRadiusCells&&J1e-6&&T>0){const ne=J/oe,K=-($/oe),ie=ne,xe=D.vx*K+D.vy*ie>=0?1:-1;D.vx+=K*T*xe,D.vy+=ie*T*xe}}}if(D.gravityActive){let k=0,H=0,L=!1,z=null,W=1/0;if(l)for(const ne of l.peaks){const Y=(ne.cellX+.5)/t,K=(ne.cellY+.5)/t,ie=Y-D.x,ge=K-D.y,xe=ie*ie+ge*ge;if(xey)continue;L=!0;const q=Math.sqrt(xe),ce=Math.max(q,E),Se=A/(ce*ce);k+=ie/q*Se,H+=ge/q*Se}if(M&&h){if(h.thrust>0){const ne=Math.sqrt(D.vx*D.vx+D.vy*D.vy);if(ne>1e-6){const Y=h.thrustAngle*Math.PI/180,K=Math.cos(Y),ie=Math.sin(Y),ge=D.vx/ne,xe=D.vy/ne,q=ge*K-xe*ie,ce=ge*ie+xe*K,Se=h.thrust/t;k+=q*Se,H+=ce*Se}}if(p&&h.surfaceGravity!==0){const ne=D.lastCellX,Y=D.lastCellY,K=Math.max(0,Math.min(t,ne)),ie=Math.max(0,Math.min(t,t-Y)),ge=Math.max(0,Math.min(t,ne+1)),xe=Math.max(0,Math.min(t,t-(Y+1))),q=p[(ie*R+K)*3+1],ce=p[(ie*R+ge)*3+1],Se=p[(xe*R+K)*3+1],Ge=ce-q,Ye=Se-q;k-=Ge*h.surfaceGravity,H-=Ye*h.surfaceGravity}}const J=Math.max(h?.mass??1,.01);if(D.vx+=k/J*e,D.vy+=H/J*e,M&&h&&h.damping>0){const ne=Math.exp(-h.damping*e);D.vx*=ne,D.vy*=ne}else if(!M&&L&&l&&l.gravityDamping>0){const ne=Math.exp(-l.gravityDamping*e);D.vx*=ne,D.vy*=ne}const $=Math.max(h?.maxSpeed??2,.01),oe=D.vx*D.vx+D.vy*D.vy;if(oe>$*$){const ne=$/Math.sqrt(oe);D.vx*=ne,D.vy*=ne}D.x+=D.vx*e,D.y+=D.vy*e,D.x=Math.max(0,Math.min(1,D.x)),D.y=Math.max(0,Math.min(1,D.y)),l&&z&&W<=x&&(D.arrived=!0,D.arrivedPeakIdx=z.vertexIdx,D.age=D.lifetime)}else{const k=Math.min(D.age/D.lifetime,1),L=(Vo[D.easingType]??Vo.easeInOutCubic)(k),z=k+(L-k)*D.easingStrength;D.x=D.startX+(D.targetX-D.startX)*z,D.y=D.startY+(D.targetY-D.startY)*z}const F=Math.max(0,Math.min(t-1,Math.floor(D.x*t))),U=Math.max(0,Math.min(t-1,Math.floor(D.y*t)));(F!==D.lastCellX||U!==D.lastCellY)&&(D.trail.unshift({x:F,y:U,age:0}),D.lastCellX=F,D.lastCellY=U);for(const k of D.trail)k.age+=e;D.trail=D.trail.filter((k,H)=>H0?Math.min(D.age/i.fadeInTime,1):1;const U=D.lifetime-D.age;i.fadeOutTime>0&&U=0&&L=i.trailLength){const J=(k-i.trailLength)/Math.max(i.trailFadeCount,1),$=Math.min(H.age/i.trailFadeTime,1);z=Math.max(0,1-Math.max(J,$))}n.brightnessData[L]=Math.min(1,n.brightnessData[L]+z*F)}}}const O=[];for(const D of n.pixels)D.ageh0?Math.min(n.enteredAge/i.fadeInTime,1):1,s=n.active?1:i.fadeOutTime>0?Math.max(0,1-n.leftAge/i.fadeOutTime):0,l=Math.min(r,s);if(n.brightnessData.fill(0),!(l<=0))for(let u=0;u=n.brightnessData.length)continue;let g=1;if(u>=i.trailLength){const b=(u-i.trailLength)/Math.max(i.trailFadeCount,1),x=Math.min(h.age/i.trailFadeTime,1);g=Math.max(0,1-Math.max(b,x))}n.brightnessData[p]=Math.min(1,n.brightnessData[p]+g*l)}}const zu=10;function IY(n,e,t,i,r,s,l,u){if(i<=n.length)return n;const h=t+1,p=e.length/3,g=new Array(p);for(let M=0;MR.y-M.y);const y=[...n],b=r*r,x=t/2,E=t/2,A=(1-Math.max(0,Math.min(1,s)))*E,T=Math.max(0,Math.min(1,l))*E;for(const M of g){if(y.length>=i)break;if(y.some(L=>L.vertexIdx===M.idx))continue;const R=M.idx%h,O=Math.floor(M.idx/h),D=Math.max(0,Math.min(t-1,R)),F=Math.max(0,Math.min(t-1,t-O)),U=Math.abs(D-x),k=Math.abs(F-x);if(U>A||k>A||Unew Q,[]),gt=P.useMemo(()=>new rn,[]),_t=P.useRef({width:0,height:0}),jt=P.useMemo(()=>new Mt,[]),pt=P.useMemo(()=>{const Ie=new Ic(u,u,l,l);Ie.rotateX(-Math.PI/2);const Ke=(l+1)**2;return Ie.setAttribute("aNormHeight",new si(new Float32Array(Ke),1)),Ie},[l,u]);P.useEffect(()=>()=>pt.dispose(),[pt]);const mt=P.useMemo(()=>yY(A),[A]);P.useEffect(()=>()=>mt.dispose(),[mt]);const He=P.useMemo(()=>{const Ie=new Float32Array(l*l),Ke=new Ta(Ie,l,l,Hu,xr);return Ke.minFilter=jn,Ke.magFilter=jn,Ke.needsUpdate=!0,Ke},[l]);P.useEffect(()=>()=>He.dispose(),[He]);const Ue=P.useMemo(()=>{const Ie=new Float32Array(l*l),Ke=new Ta(Ie,l,l,Hu,xr);return Ke.minFilter=jn,Ke.magFilter=jn,Ke.needsUpdate=!0,Ke},[l]);P.useEffect(()=>()=>Ue.dispose(),[Ue]);const Re=P.useMemo(()=>{const Ie=new Float32Array(l*l),Ke=new Ta(Ie,l,l,Hu,xr);return Ke.minFilter=jn,Ke.magFilter=jn,Ke.needsUpdate=!0,Ke},[l]);P.useEffect(()=>()=>Re.dispose(),[Re]);const ft=P.useMemo(()=>{const Ie=new Float32Array(l*l),Ke=new Ta(Ie,l,l,Hu,xr);return Ke.minFilter=jn,Ke.magFilter=jn,Ke.needsUpdate=!0,Ke},[l]);P.useEffect(()=>()=>ft.dispose(),[ft]),P.useEffect(()=>{ge.current=AY(l),xe.current=DY(l),q.current.length=0,ce.current=null,Ye.current=[]},[l]);const Z=P.useRef({uGradientMap:{value:mt},uShadingStrength:{value:T},uFogEnabled:{value:M},uFogColor:{value:new Mt(R)},uFogNear:{value:O},uFogFar:{value:D},uGridInScene:{value:!1},uGridColor:{value:new Mt(g)},uGridOpacity:{value:0},uGridThickness:{value:b},uSubdivisions:{value:l},uPointLightCount:{value:0},uPointLightPositions:{value:Array.from({length:zu},()=>new Q)},uPointLightColors:{value:Array.from({length:zu},()=>new Mt(1,1,1))},uPointLightIntensities:{value:new Array(zu).fill(0)},uPointLightRanges:{value:new Array(zu).fill(1)}}).current,At=P.useMemo(()=>new Ps,[]),dt=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:cY,transparent:!0,depthTest:!0,depthWrite:!1,side:Bi,uniforms:{uGridColor:{value:new Mt(g)},uGridOpacity:{value:p?y:0},uGridThickness:{value:b},uSubdivisions:{value:l},uFogEnabled:{value:M},uFogColor:{value:new Mt(R)},uFogNear:{value:O},uFogFar:{value:D}}}),[]),Ct=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:"void main() { gl_FragColor = vec4(0.0); }",colorWrite:!1,depthTest:!0,depthWrite:!0,side:Bi}),[]);P.useEffect(()=>{const Ie=new $n(pt,Ct);Ie.renderOrder=-1;const Ke=new $n(pt,dt);return At.add(Ie,Ke),()=>{At.remove(Ie,Ke)}},[pt,dt,Ct,At]);const tt=P.useMemo(()=>new Ps,[]),V=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:"void main() {}",colorWrite:!1,depthWrite:!0,depthTest:!0,side:Bi,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),[]),N=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:Ob,transparent:!0,depthTest:!0,depthWrite:!1,side:Bi,uniforms:{uPixelBrightness:{value:He},uPixelColor:{value:new Mt("#ffffff")},uPixelOpacity:{value:1},uFogEnabled:{value:M},uFogNear:{value:O},uFogFar:{value:D}}}),[]);P.useEffect(()=>{const Ie=new $n(pt,V);Ie.renderOrder=-1;const Ke=new $n(pt,N);return tt.add(Ie,Ke),()=>{tt.remove(Ie,Ke)}},[pt,V,N,tt]);const ee=P.useMemo(()=>new Ps,[]),Ee=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:"void main() {}",colorWrite:!1,depthWrite:!0,depthTest:!0,side:Bi,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),[]),Te=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:Ob,transparent:!0,depthTest:!0,depthWrite:!1,side:Bi,uniforms:{uPixelBrightness:{value:Ue},uPixelColor:{value:new Mt("#ffffff")},uPixelOpacity:{value:1},uFogEnabled:{value:M},uFogNear:{value:O},uFogFar:{value:D}}}),[Ue]);P.useEffect(()=>{const Ie=new $n(pt,Ee);Ie.renderOrder=-1;const Ke=new $n(pt,Te);return ee.add(Ie,Ke),()=>{ee.remove(Ie,Ke)}},[pt,Ee,Te,ee]);const pe=P.useMemo(()=>new Ps,[]),Et=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:"void main() {}",colorWrite:!1,depthWrite:!0,depthTest:!0,side:Bi,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),[]),$e=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:Ob,transparent:!0,depthTest:!0,depthWrite:!1,side:Bi,uniforms:{uPixelBrightness:{value:Re},uPixelColor:{value:new Mt("#ffffff")},uPixelOpacity:{value:1},uFogEnabled:{value:M},uFogNear:{value:O},uFogFar:{value:D}}}),[Re]);P.useEffect(()=>{const Ie=new $n(pt,Et);Ie.renderOrder=-1;const Ke=new $n(pt,$e);return pe.add(Ie,Ke),()=>{pe.remove(Ie,Ke)}},[pt,Et,$e,pe]);const lt=P.useMemo(()=>new Ps,[]),Lt=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:"void main() {}",colorWrite:!1,depthWrite:!0,depthTest:!0,side:Bi,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),[]),Ze=P.useMemo(()=>new Ln({vertexShader:Is,fragmentShader:Ob,transparent:!0,depthTest:!0,depthWrite:!1,side:Bi,uniforms:{uPixelBrightness:{value:ft},uPixelColor:{value:new Mt("#ff0000")},uPixelOpacity:{value:1},uFogEnabled:{value:!1},uFogNear:{value:0},uFogFar:{value:1}}}),[ft]);P.useEffect(()=>{const Ie=new $n(pt,Lt);Ie.renderOrder=-1;const Ke=new $n(pt,Ze);return lt.add(Ie,Ke),()=>{lt.remove(Ie,Ke)}},[pt,Lt,Ze,lt]);const rt=P.useMemo(()=>new Ps,[]),vt=P.useMemo(()=>new Ic(1,1),[]);P.useEffect(()=>()=>vt.dispose(),[vt]);const te=P.useMemo(()=>({mid:new Q,dir:new Q,view:new Q,up:new Q,rotMat:new rn}),[]),be=P.useMemo(()=>{const Ie=[];for(let Ke=0;Ke{const Ie=[];for(let Ke=0;Ke{for(const Ie of be)rt.add(Ie.mesh);for(const Ie of ct)rt.add(Ie.mesh);return()=>{for(const Ie of be)rt.remove(Ie.mesh);for(const Ie of ct)rt.remove(Ie.mesh)}},[rt,be,ct]);const re=P.useMemo(()=>new Ps,[]),Pe=($?.hitImageUrls??[]).join(` `),ze=P.useMemo(()=>{const Ie=new DD;return Ie.crossOrigin="anonymous",(Pe?Pe.split(` `):[]).map(yt=>{const Pt=Ie.load(yt);return Pt.colorSpace=Zn,Pt})},[Pe]);P.useEffect(()=>()=>{for(const Ie of ze)Ie.dispose()},[ze]);const at=P.useMemo(()=>{const Ie=[];for(let Ke=0;Ke{for(const Ie of at)re.add(Ie.mesh);return()=>{for(const Ie of at)re.remove(Ie.mesh),Ie.mat.dispose()}},[re,at]);const je=P.useRef([]),Ve=P.useMemo(()=>new ai(1,1,{depthBuffer:!0}),[]),nt=P.useMemo(()=>new ai(1,1,{depthBuffer:!1}),[]),It=P.useMemo(()=>new ai(1,1,{depthBuffer:!1}),[]),an=P.useMemo(()=>new ai(1,1,{depthBuffer:!1}),[]),sn=P.useMemo(()=>new ai(1,1,{depthBuffer:!1}),[]);P.useEffect(()=>()=>{Ve.dispose(),nt.dispose(),It.dispose(),an.dispose(),sn.dispose()},[Ve,nt,It,an,sn]);const Vn=P.useMemo(()=>new Ln({vertexShader:Fg,fragmentShader:uY,depthTest:!1,depthWrite:!1,uniforms:{tInput:{value:null},threshold:{value:.14},pixelScale:{value:2},mixAmount:{value:1},patternSize:{value:8},ditherColor:{value:new Mt("#ffffff")},blendMode:{value:0},res:{value:new Be(1,1)}}}),[]),_i=P.useMemo(()=>new Ln({vertexShader:Fg,fragmentShader:fY,depthTest:!1,depthWrite:!1,uniforms:{tInput:{value:null},caEnabled:{value:!1},caStrength:{value:.005},caSamples:{value:1}}}),[]),zr=P.useMemo(()=>new Ln({vertexShader:Fg,fragmentShader:dY,depthTest:!1,depthWrite:!1,uniforms:{tInput:{value:null},resolution:{value:new Be(1,1)},direction:{value:new Be(1,0)},radius:{value:3}}}),[]),Ka=P.useMemo(()=>new Ln({vertexShader:Fg,fragmentShader:hY,transparent:!0,depthTest:!1,depthWrite:!1,blending:e_,uniforms:{tInput:{value:null}}}),[]),Es=P.useMemo(()=>new Ln({vertexShader:Fg,fragmentShader:pY,transparent:!0,depthTest:!1,depthWrite:!1,blending:kb,uniforms:{tInput:{value:null},bloomStrength:{value:1}}}),[]),{passCam:qr,passScene:Fr,passQuad:Oa}=P.useMemo(()=>{const Ie=new qo(-1,1,1,-1,0,1),Ke=new Ps,yt=new $n(new Ic(2,2),void 0);return Ke.add(yt),{passCam:Ie,passScene:Ke,passQuad:yt}},[]);P.useEffect(()=>{const Ie=(l+1)**2,Ke=tY(l,i,e,t,r,s),yt=ie.current;yt.target=Ke,yt.current.length!==Ie?(yt.start=new Float32Array(Ke),yt.current=new Float32Array(Ke),yt.progress=1):(yt.start=new Float32Array(yt.current),yt.progress=0),yt.dirty=!0},[l,i,e,t,r,s]);const hr=P.useRef(h);P.useEffect(()=>{hr.current!==h&&(hr.current=h,ie.current.dirty=!0)},[h]),P.useEffect(()=>{ie.current.dirty=!0},[ne,Y,K]),Wo(({camera:Ie},Ke)=>{const yt=ie.current;if(yt.progress<1){yt.progress=Math.min(yt.progress+Ke/Math.max(F,.01),1);const Ae=(Vo[k]??OP)(yt.progress);for(let Qe=0;Qe=1&&U&&H&&H()}if(yt.dirty){yt.dirty=!1;const Ae=pt.attributes.position.array,Qe=pt.attributes.aNormHeight.array,he=l+1,Xe=K/Math.max(1,l),ot=-Y,wt=Math.max(0,Math.min(1,ot/Math.max(h,.001)+.5));for(let Je=0;Je0&&(he.impactCooldownRemaining=Math.max(0,he.impactCooldownRemaining-Ke));for(const Xe of he.ripples)Xe.age+=Ke;he.ripples=he.ripples.filter(Xe=>Xe.age<$.rippleDuration);for(const Xe of he.flashes)Xe.age+=Ke;he.flashes=he.flashes.filter(Xe=>Xe.age<$.flashDuration)}Ye.current=Ye.current.filter(he=>!he.retired||he.ripples.length>0||he.flashes.length>0||he.lightCycles.length>0);const Ae=ve.current;if(Ae.peakCount!==$.peakCount||Ae.minSeparation!==$.minSeparation||Ae.outerExclusion!==$.outerExclusion||Ae.innerExclusion!==$.innerExclusion||Ae.viewportOnly!==$.viewportOnly){for(const he of Ye.current)he.retired||(he.retired=!0);Ae.peakCount=$.peakCount,Ae.minSeparation=$.minSeparation,Ae.outerExclusion=$.outerExclusion,Ae.innerExclusion=$.innerExclusion,Ae.viewportOnly=$.viewportOnly}if(yt.progress>=1&&Pt.length>0){const he=Math.max(0,Math.floor($.peakCount)),Xe=Ye.current.filter(wt=>!wt.retired),ot=Ye.current.filter(wt=>wt.retired);if(Xe.length(it.set(Pt[ut*3],Pt[ut*3+1],Pt[ut*3+2]).applyMatrix4(gt),it.x>=-1&&it.x<=1&&it.y>=-1&&it.y<=1&&it.z>=-1&&it.z<=1));const Je=IY(Xe,Pt,l,he,Math.max(0,$.minSeparation),$.outerExclusion,$.innerExclusion,wt);Ye.current=[...Je,...ot]}else Xe.length>he&&(Ye.current=[...Xe.slice(0,he),...ot])}}else Ye.current=[];const Dn=$?.enabled?Ye.current.filter(Ae=>!Ae.retired):[],Gn=Dn.length>0?{peaks:Dn.map(Ae=>({vertexIdx:Ae.vertexIdx,cellX:Ae.cellX,cellY:Ae.cellY})),gravityRadiusCells:$.peakRadius,gravityStrength:$.gravityStrength,gravityDamping:$.gravityDamping,tangentialBoostCells:$.gravityTangentialBoost,arrivalRadiusCells:$.arrivalRadius}:void 0,un=Ae=>{const Qe=Ye.current.find(he=>he.vertexIdx===Ae);!Qe||Qe.retired||Qe.impactCooldownRemaining>0||(Qe.ripples.push({age:0}),Qe.flashes.push({age:0}),$?.realLightEnabled&&Qe.lightCycles.push({age:0,seed:Math.random()*16777215|0}),$?.hitImageEnabled&&ze.length>0&&je.current.length0){const Ae=Vo[$.rippleEasing]??Vo.easeOutCubic,Qe=Math.max($.rippleThickness*.5,.5),he=Math.max($.rippleDuration,.001),Xe=Math.max($.flashDuration,.001);for(const ot of Ye.current){for(const wt of ot.ripples){const Je=Math.min(wt.age/he,1),ut=$.rippleMaxRadius*Ae(Je),Bt=(1-Je)*$.rippleOpacity;if(Bt<=0||ut<=0)continue;const on=Math.max(0,ut-Qe),en=ut+Qe,kt=on*on,St=en*en,Zt=Math.ceil(en),Ut=Math.max(0,ot.cellX-Zt),Sn=Math.min(l-1,ot.cellX+Zt),di=Math.max(0,ot.cellY-Zt),Tn=Math.min(l-1,ot.cellY+Zt);for(let oi=di;oi<=Tn;oi++)for(let wn=Ut;wn<=Sn;wn++){const hi=wn-ot.cellX,Oi=oi-ot.cellY,Hi=hi*hi+Oi*Oi;if(HiSt)continue;const ar=Math.sqrt(Hi),xo=Math.max(0,1-Math.abs(ar-ut)/Qe),Kr=oi*l+wn;Ei[Kr]=Math.min(1,Ei[Kr]+xo*Bt)}}for(const wt of ot.flashes){const ut=(1-Math.min(wt.age/Xe,1))*$.flashIntensity;if(ut<=0)continue;const Bt=ot.cellY*l+ot.cellX;Ei[Bt]=Math.min(1,Ei[Bt]+ut)}if(ot.realLightInstant=0,$.realLightEnabled&&ot.lightCycles.length>0){const wt=Math.max(0,$.realLightFadeInDuration),Je=Math.max(0,$.realLightHoldDuration),ut=Math.max(0,$.realLightFadeOutDuration),Bt=wt+Je,on=Bt+ut;for(const Sn of ot.lightCycles)Sn.age+=Ke;ot.lightCycles=ot.lightCycles.filter(Sn=>Sn.age0?Sn.age/wt:1;di=en(oi)}else if(Sn.age0?(Sn.age-Bt)/ut:1;di=1-kt(oi)}let Tn=1;if(St>0&&Zt>0){const oi=TY(Sn.age*Zt,Sn.seed);Tn=Math.max(0,1-oi*St)}Ut+=di*Tn}ot.realLightInstant=Ut}}}Re.needsUpdate=!0;const ki=Z.uPointLightPositions.value,G=Z.uPointLightColors.value,ue=Z.uPointLightIntensities.value,Me=Z.uPointLightRanges.value;let me=0;if($?.enabled&&$.realLightEnabled){const Ae=pt.attributes.position.array;for(const Qe of Ye.current){if(me>=zu)break;if(Qe.realLightInstant<=0)continue;const he=Qe.vertexIdx;ki[me].set(Ae[he*3],Ae[he*3+1]+$.realLightElevation,Ae[he*3+2]),G[me].set($.rippleColor),ue[me]=Qe.realLightInstant*$.realLightIntensity,Me[me]=$.realLightRange,me++}}for(let Ae=me;Aeut&&(Je.circleFade=Math.max(ut,Je.circleFade-on))}const he=Oe.current,Xe=Ye.current.filter(Je=>!Je.retired),ot=$.peakCount;if(Xe.length===ot&&Xe.every(Je=>Je.circleFade>=.99)){const Je=Xe.map(en=>en.vertexIdx);he.snapshotPeakIds.length===Je.length&&he.snapshotPeakIds.every((en,kt)=>en===Je[kt])||(he.snapshotPeakIds=Je.slice(),he.drawProgress=0,he.lineAlpha=0);const Bt=Math.max($.connectionsLineDrawDuration,.001),on=Math.max($.connectionsLineFadeInDuration,.001);he.drawProgress0){const Je=Math.max($.connectionsLineFadeOutDuration,.001),ut=he.snapshotPeakIds.length/Je;he.drawProgress=Math.max(0,he.drawProgress-Ke*ut),he.drawProgress<=0&&(he.drawProgress=0,he.snapshotPeakIds=[],he.lineAlpha=0)}}else{const Ae=Oe.current;Ae.snapshotPeakIds=[],Ae.drawProgress=0,Ae.lineAlpha=0;for(const Qe of Ye.current)Qe.circleFade=0}const de=ft.image.data;if(de.fill(0),$?.debugPeakOverlay){const Ae=Math.max(0,$.peakRadius),Qe=Ae*Ae;for(const he of Ye.current){if(he.retired)continue;const Xe=Math.max(0,he.cellX-Ae),ot=Math.min(l-1,he.cellX+Ae),wt=Math.max(0,he.cellY-Ae),Je=Math.min(l-1,he.cellY+Ae);for(let ut=wt;ut<=Je;ut++)for(let Bt=Xe;Bt<=ot;Bt++){const on=Bt-he.cellX,en=ut-he.cellY;on*on+en*en<=Qe&&(de[ut*l+Bt]=.5)}de[he.cellY*l+he.cellX]=1}}ft.needsUpdate=!0,Z.uGradientMap.value=mt,Z.uShadingStrength.value=T,Z.uFogEnabled.value=M,Z.uFogColor.value.set(R),Z.uFogNear.value=O,Z.uFogFar.value=D,Z.uGridInScene.value=p&&E,Z.uGridColor.value.set(g),Z.uGridOpacity.value=p&&E?y:0,Z.uGridThickness.value=b,Z.uSubdivisions.value=l,dt.uniforms.uGridColor.value.set(g),dt.uniforms.uGridOpacity.value=p&&!E?y:0,dt.uniforms.uGridThickness.value=b,dt.uniforms.uSubdivisions.value=l,dt.uniforms.uFogEnabled.value=M,dt.uniforms.uFogColor.value.set(R),dt.uniforms.uFogNear.value=O,dt.uniforms.uFogFar.value=D,Bg(dt,x),N.uniforms.uPixelBrightness.value=He,N.uniforms.uPixelColor.value.set(L?.color??"#ffffff"),N.uniforms.uPixelOpacity.value=L?.opacity??1,N.uniforms.uFogEnabled.value=M,N.uniforms.uFogNear.value=O,N.uniforms.uFogFar.value=D,Te.uniforms.uPixelBrightness.value=Ue,Te.uniforms.uPixelColor.value.set(W?.color??"#ffffff"),Te.uniforms.uPixelOpacity.value=W?.opacity??1,Te.uniforms.uFogEnabled.value=M,Te.uniforms.uFogNear.value=O,Te.uniforms.uFogFar.value=D,$e.uniforms.uPixelBrightness.value=Re,$e.uniforms.uPixelColor.value.set($?.rippleColor??"#ffffff"),$e.uniforms.uPixelOpacity.value=1,$e.uniforms.uFogEnabled.value=M,$e.uniforms.uFogNear.value=O,$e.uniforms.uFogFar.value=D}),Wo(({gl:Ie,camera:Ke,size:yt})=>{(yt.width!==_t.current.width||yt.height!==_t.current.height)&&(_t.current={width:yt.width,height:yt.height},Ve.setSize(yt.width,yt.height),nt.setSize(yt.width,yt.height),It.setSize(yt.width,yt.height),an.setSize(yt.width,yt.height),sn.setSize(yt.width,yt.height),Vn.uniforms.res.value.set(yt.width,yt.height),zr.uniforms.resolution.value.set(yt.width,yt.height));const Pt=!!L?.enabled,Dn=!!W?.enabled,Gn=!!$?.enabled&&!!$.rippleUseTracerEffects&&Ye.current.some(ki=>ki.ripples.length>0||ki.flashes.length>0);if(!Pt&&!Dn&&!Gn)return;const un=z,Ei=(ki,G)=>{const ue=Ie.getClearAlpha();Ie.getClearColor(jt),Ie.setClearColor(0,0),Ie.setRenderTarget(Ve),Ie.clear(!0,!0,!0),Ie.render(ki,Ke),Ie.setClearColor(jt,ue),Ie.setRenderTarget(null);let Me=Ve;if(un?.ditherEnabled&&(Vn.uniforms.tInput.value=Me.texture,Vn.uniforms.threshold.value=un.ditherThreshold,Vn.uniforms.pixelScale.value=un.ditherPixelScale,Vn.uniforms.mixAmount.value=un.ditherMix,Vn.uniforms.patternSize.value=un.ditherPattern,Vn.uniforms.ditherColor.value.set(un.ditherColor),Vn.uniforms.blendMode.value=sY[un.ditherBlend]??0,Oa.material=Vn,Ie.setRenderTarget(nt),Ie.clear(!0,!1,!1),Ie.render(Fr,qr),Ie.setRenderTarget(null),Me=nt),un?.caEnabled&&(_i.uniforms.tInput.value=Me.texture,_i.uniforms.caEnabled.value=un.caEnabled,_i.uniforms.caStrength.value=un.chromaticAberration,_i.uniforms.caSamples.value=Math.max(1,Math.round(un.caSamples)),Oa.material=_i,Ie.setRenderTarget(It),Ie.clear(!0,!1,!1),Ie.render(Fr,qr),Ie.setRenderTarget(null),Me=It),un?.bloomEnabled){const de=Math.max(1,Math.round(un.bloomIterations??1));zr.uniforms.radius.value=un.bloomRadius,Oa.material=zr;let Ae=Me.texture;for(let Qe=0;Qe{if(!p)return;const yt=Ie.autoClear;Ie.autoClear=!1,Ie.clearDepth(),Ie.render(At,Ke),Ie.autoClear=yt},3),Wo(({gl:Ie,camera:Ke})=>{const yt=Ye.current.length>0,Pt=!!$?.enabled&&yt&&Ye.current.some(un=>un.ripples.length>0||un.flashes.length>0),Dn=!!$?.debugPeakOverlay&&yt;if(!Pt&&!Dn)return;const Gn=Ie.autoClear;if(Ie.autoClear=!1,Pt){const un=$;un.rippleUseTracerEffects||(Bg($e,un.rippleBlendMode),Ie.render(pe,Ke))}Dn&&(Ze.uniforms.uPixelOpacity.value=$.debugPeakOverlayOpacity,Bg(Ze,"normal"),Ie.render(lt,Ke)),Ie.autoClear=Gn},4),Wo(({gl:Ie,camera:Ke,size:yt})=>{if(!$?.connectionsEnabled){for(const he of be)he.mesh.visible=!1;for(const he of ct)he.mesh.visible=!1;return}const Pt=$,Dn=Ye.current,Gn=pt.attributes.position.array,Ei=Math.tan(Ke.fov*Math.PI/360),ki=yt.height*.5,G=te;for(let he=0;he=2&&ue.lineAlpha>0)for(let he=0;he=me){Xe.mesh.visible=!1;continue}const ot=Math.max(0,Math.min(1,ue.drawProgress-he));if(ot<=0){Xe.mesh.visible=!1;continue}const wt=Dn.find(hi=>hi.vertexIdx===Me[he]),Je=Dn.find(hi=>hi.vertexIdx===Me[(he+1)%me]);if(!wt||!Je){Xe.mesh.visible=!1;continue}const ut=wt.vertexIdx,Bt=Je.vertexIdx,on=Gn[ut*3],en=Gn[ut*3+1],kt=Gn[ut*3+2],St=Gn[Bt*3],Zt=Gn[Bt*3+1],Ut=Gn[Bt*3+2];G.mid.set((on+St)*.5,(en+Zt)*.5,(kt+Ut)*.5),G.dir.set(St-on,Zt-en,Ut-kt);const Sn=G.dir.length();if(Sn<.001){Xe.mesh.visible=!1;continue}G.dir.divideScalar(Sn),G.view.set(Ke.position.x-G.mid.x,Ke.position.y-G.mid.y,Ke.position.z-G.mid.z);const di=G.view.length();if(di<1e-6){Xe.mesh.visible=!1;continue}G.view.divideScalar(di),G.up.copy(G.view).cross(G.dir);const Tn=G.up.length();if(Tn<1e-6){Xe.mesh.visible=!1;continue}G.up.divideScalar(Tn),G.view.copy(G.dir).cross(G.up),G.rotMat.makeBasis(G.dir,G.up,G.view);const oi=di*Ei/ki,wn=Ae*oi;Xe.mesh.position.copy(G.mid),Xe.mesh.quaternion.setFromRotationMatrix(G.rotMat),Xe.mesh.scale.set(Sn,wn,1),Xe.mat.uniforms.uColor.value.set(Pt.connectionsLineColor),Xe.mat.uniforms.uOpacity.value=Pt.connectionsLineOpacity,Xe.mat.uniforms.uAlpha.value=ue.lineAlpha,Xe.mat.uniforms.uProgress.value=ot,Xe.mat.uniforms.uHalfThickness.value=Pt.connectionsLineThickness*.5,Xe.mat.uniforms.uQuadHeight.value=Ae,Xe.mesh.visible=!0}else for(const he of ct)he.mesh.visible=!1;const Qe=Ie.autoClear;Ie.autoClear=!1,Ie.render(rt,Ke),Ie.autoClear=Qe},5),Wo(({gl:Ie,camera:Ke},yt)=>{const Pt=je.current;if(!$?.hitImageEnabled||Pt.length===0){Pt.length>0&&(je.current=[]);for(const Me of at)Me.mesh.visible=!1;return}const Dn=$,Gn=pt.attributes.position.array,un=Math.max(Dn.hitImageFadeInDuration,.001),Ei=Math.max(Dn.hitImageFadeOutDuration,.001),ki=un+Ei;for(const Me of Pt)Me.age+=yt;je.current=Pt.filter(Me=>Me.age=Gn.length){me.mesh.visible=!1;continue}const Qe=ze[de.imageIndex],he=Qe?.image;if(!he||!he.width){me.mesh.visible=!1;continue}let Xe;if(de.age=1?Je=Dn.hitImageSize/ot:wt=Dn.hitImageSize*ot,me.mesh.position.set(Gn[Ae*3],Gn[Ae*3+1],Gn[Ae*3+2]),me.mesh.quaternion.copy(Ke.quaternion),me.mesh.scale.set(wt,Je,1),me.mat.uniforms.uMap.value=Qe,me.mat.uniforms.uOpacity.value=Xe*Dn.hitImageOpacity,Bg(me.mat,Dn.hitImageBlendMode),me.mesh.visible=!0,ue=!0}if(ue){const Me=Ie.autoClear;Ie.autoClear=!1,Ie.render(re,Ke),Ie.autoClear=Me}},6);const Br=Ie=>{if(!Ie.uv)return null;const Ke=Math.max(0,Math.min(l-1,Math.floor(Ie.uv.x*l))),yt=Math.max(0,Math.min(l-1,Math.floor(Ie.uv.y*l)));return{cellX:Ke,cellY:yt}},Si=Ie=>{if(Ie.pointerType!=="mouse")return;const Ke=Br(Ie),yt=xe.current;Ke&&yt&&(yt.active=!0,yt.cellX=Ke.cellX,yt.cellY=Ke.cellY)},ji=Ie=>{if(Ie.pointerType!=="mouse")return;const Ke=xe.current;Ke&&(Ke.active=!0,Ke.leftAge=0)},Yr=Ie=>{if(Ie.pointerType!=="mouse")return;const Ke=xe.current;Ke&&(Ke.active=!1)},Zr=Ie=>{if(Ie.pointerType!=="mouse"||Ie.button!==void 0&&Ie.button!==0)return;const Ke=Br(Ie);Ke&&(ce.current={cellX:Ke.cellX,cellY:Ke.cellY,x:Ie.clientX,y:Ie.clientY,invalidated:!1})};return P.useEffect(()=>{Ge.current=J}),P.useEffect(()=>{const Ie=yt=>{if(yt.pointerType!=="mouse")return;const Pt=ce.current;if(Pt&&!Pt.invalidated&&Math.hypot(yt.clientX-Pt.x,yt.clientY-Pt.y)>6){Pt.invalidated=!0;const Dn=xe.current;Dn&&(Dn.drag=!0)}},Ke=yt=>{if(yt.pointerType!=="mouse")return;const Pt=ce.current;ce.current=null;const Dn=xe.current;if(Dn&&(Dn.drag=!1),!Pt||Pt.invalidated)return;const Gn=Math.max(0,(Ge.current?.cooldown??0)*1e3),un=performance.now();un-Se.current{window.removeEventListener("pointermove",Ie),window.removeEventListener("pointerup",Ke)}},[]),xt.jsx("mesh",{geometry:pt,onPointerMove:Si,onPointerOver:ji,onPointerOut:Yr,onPointerDown:Zr,children:xt.jsx("shaderMaterial",{vertexShader:oY,fragmentShader:lY,uniforms:Z,side:Bi})})}const kg={performance:{showStats:!1,maxPixels:8e6},surface:{noiseScale:4,noiseDetail:7,heightScale:1.8,surfaceSize:17.5,subdivisions:128,lacunarity:4,persistence:.3,animationDuration:7.5,easingType:"easeInOutCubic",loop:!1,pinEdges:!0,pinDepth:1,pinSmoothTiles:20},animation:{autoRegenerate:!0,matchAnimDuration:!1,regenInterval:22.5},grid:{showGrid:!0,gridColor:"#ffffff",gridOpacity:.8,gridThickness:.2,gridBlendMode:"lighten",gridDithered:!1},gradient:{color1:"#000000",color2:"#140d21",color3:"#101045",color4:"#313131",color5:"#5c7aff",color6:"#d2c7ff"},background:{color:"#fceded"},shading:{shadingStrength:1},fog:{fogEnabled:!0,fogColor:"#ffffff",fogNear:9,fogFar:50},camera:{fov:15,posX:-11.74,posY:2.801,posZ:-4.648,targetX:.7,targetY:0,targetZ:0,autoRotate:!0,autoRotateSpeed:.1,rotateHorizontal:!0,rotateVertical:!1,scrollRotate:!1,scrollRotateFactor:1,scrollRotateDamping:2,enablePan:!1,enableZoom:!1,minPolarAngle:0,maxPolarAngle:90,minAzimuthAngle:-360,maxAzimuthAngle:360},tracerPhysics:{enabled:!1,mass:2.55,thrust:18,thrustAngle:0,surfaceGravity:8.1,damping:.6,maxSpeed:2},pixelTrails:{enabled:!0,spawnRate:10,maxTracers:100,range:160,minDistance:100,lifeMin:10,lifeMax:20,easingType:"easeInOutSine",easingStrength:1,trailLength:1,trailFadeCount:10,trailFadeTime:10,color:"#e1f0ff",blendMode:"normal",opacity:1,fadeInTime:1.5,fadeOutTime:1.5,clickSpawnEnabled:!0,clickSpawnCount:3,clickSpawnOriginRadius:0,clickSpawnCooldown:.25,clickSpawnEasingType:"easeOutCubic",clickSpawnEasingStrength:1},hoverHighlight:{enabled:!0,trailLength:1,trailFadeCount:10,trailFadeTime:.6,color:"#ffffff",blendMode:"screen",opacity:1,fadeInTime:.15,fadeOutTime:.4},peakBeam:{enabled:!0,peakRadius:8,peakImpactCooldown:1.5,gravityStrength:1.9,gravityDamping:1.2,gravityTangentialBoost:7.5,arrivalRadius:1,peakCount:3,minSeparation:18,outerExclusion:.5,innerExclusion:.2,viewportOnly:!0,rippleMaxRadius:8,rippleDuration:1.95,rippleThickness:3,rippleEasing:"easeOutCubic",rippleColor:"#ffffff",rippleOpacity:1.5,rippleBlendMode:"normal",rippleUseTracerEffects:!0,flashDuration:.12,flashIntensity:2,realLightEnabled:!0,realLightIntensity:6,realLightRange:3.5,realLightElevation:2.4,realLightFadeInDuration:.25,realLightFadeInEasing:"easeOutCubic",realLightHoldDuration:0,realLightFadeOutDuration:2,realLightFadeOutEasing:"linear",realLightFlickerMax:.25,realLightFlickerFreq:25,hitImageEnabled:!0,hitImageUrls:`/texture1.jpg /texture2.jpg /texture3.jpg /texture4.jpg /texture5.jpg /texture6.jpg /texture7.jpg /texture8.jpg`,hitImageSize:3,hitImageOpacity:4,hitImageFadeInDuration:.2,hitImageFadeOutDuration:.8,hitImageBlendMode:"screen",debugPeakOverlay:!1,debugPeakOverlayOpacity:.47,connectionsEnabled:!0,connectionsCircleRadius:22,connectionsCircleRingColor:"#ffffff",connectionsCircleRingThickness:.15,connectionsCircleRingOpacity:1,connectionsCircleFillColor:"#ffffff",connectionsCircleFillOpacity:0,connectionsCircleFadeInDuration:.6,connectionsCircleFadeOutDuration:1.2,connectionsLineColor:"#ffffff",connectionsLineThickness:1.5,connectionsLineOpacity:.85,connectionsLineDrawDuration:.4,connectionsLineFadeInDuration:.5,connectionsLineFadeOutDuration:1.5},surfaceEffects:{bloomEnabled:!0,bloom:1.15,bloomThreshold:0,vignetteEnabled:!1,vignetteDarkness:.5,caEnabled:!1,chromaticAberration:0,noiseEnabled:!0,noise:.23,ditherEnabled:!0,ditherThreshold:.3,ditherPixelScale:1,ditherMix:1,ditherPattern:8,ditherBlend:"normal",ditherColor:"#ffecec",ditherBgColor:"#0020eb",tmEnabled:!1,toneMapping:"ACES_FILMIC"},tracerEffects:{ditherEnabled:!0,useSurfaceDither:!0,ditherThreshold:.14,ditherPixelScale:2,ditherMix:1,ditherPattern:8,ditherBlend:"screen",ditherColor:"#e1f0ff",bloomEnabled:!0,bloom:2.8,bloomRadius:3,bloomIterations:1,caEnabled:!0,chromaticAberration:.03,caSamples:1},intro:{enabled:!0,duration:5,easing:"easeOutExpo",fromJson:'{"fog":{"fogNear":0,"fogFar":1}}'}},Ib={portrait:480,landscape:768,tablet:992,desktop:1440},LY={portrait:{performance:{maxPixels:2e6},surface:{subdivisions:64},camera:{scrollRotate:!0,fov:25},peakBeam:{connectionsCircleRadius:12,connectionsCircleRingThickness:.1,connectionsLineThickness:1}},landscape:{performance:{maxPixels:4e6},surface:{subdivisions:64},camera:{scrollRotate:!0,fov:20},peakBeam:{connectionsCircleRadius:16,connectionsCircleRingThickness:.12,connectionsLineThickness:1}},tablet:{performance:{maxPixels:4e6},surface:{subdivisions:96},camera:{scrollRotate:!0,fov:20}},desktop:{performance:{maxPixels:4e6},surface:{subdivisions:96}}};function NY(n){return nn,easeOutCubic:n=>1-Math.pow(1-n,3),easeOutQuart:n=>1-Math.pow(1-n,4),easeOutExpo:n=>n===0?0:1-Math.pow(2,-10*n),easeInOutSine:n=>-(Math.cos(Math.PI*n)-1)/2,easeInOutCubic:n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2};function Fu(n,e,t,i,r){const s=n?.[e]?.[t];return typeof s=="number"?s+(i-s)*r:i}function UY({desired:n,introFrom:e,introProgress:t,rotateHorizontal:i,rotateVertical:r,controlsRef:s,scrollRotate:l,scrollRotateDamping:u,scrollVelocityRef:h,scrollDirectionRef:p,autoRotate:g,autoRotateSpeed:y}){const{camera:b}=Di();return Wo((x,E)=>{const A=Fu(e,"camera","targetX",n.targetX,t),T=Fu(e,"camera","targetY",n.targetY,t),M=Fu(e,"camera","targetZ",n.targetZ,t),R=Fu(e,"camera","posX",n.posX,t),O=Fu(e,"camera","posY",n.posY,t),D=Fu(e,"camera","posZ",n.posZ,t),F=R-A,U=O-T,k=D-M,H=Math.sqrt(F*F+U*U+k*k)||1,L=Math.acos(Math.max(-1,Math.min(1,U/H))),z=Math.atan2(F,k),W=s.current?.target,J=W?W.x:A,$=W?W.y:T,oe=W?W.z:M,ne=b.position.x-J,Y=b.position.y-$,K=b.position.z-oe,ie=Math.sqrt(ne*ne+Y*Y+K*K)||1,ge=Math.acos(Math.max(-1,Math.min(1,Y/ie))),xe=Math.atan2(ne,K);let q=i?xe:z;const ce=r?ge:L;if(l){const Ye=Math.PI/30*y,ve=g?-p.current*Ye:0;q+=(ve+h.current)*E,h.current*=Math.exp(-u*E)}b.position.set(A+H*Math.sin(ce)*Math.sin(q),T+H*Math.cos(ce),M+H*Math.sin(ce)*Math.cos(q)),s.current&&s.current.target.set(A,T,M),b.lookAt(A,T,M);const Se=Fu(e,"camera","fov",n.fov,t),Ge=b;Ge.fov!==Se&&(Ge.fov=Se,Ge.updateProjectionMatrix())},10),null}const fM="gradient-ascent-settings",zY=["tracerEffects.Dither.ditherThreshold","tracerEffects.Dither.ditherPixelScale","tracerEffects.Dither.ditherMix","tracerEffects.Dither.ditherPattern","tracerEffects.Dither.ditherBlend","tracerEffects.Dither.ditherColor"],FY=["Peak Goals.Gravity.gravityDamping","Peak Goals.Gravity.gravityTangentialBoost"];function c3(n){return(Array.isArray(n)?n.join(` `):String(n??"")).split(/[\n,]+/).map(t=>t.trim()).filter(Boolean).slice(0,8)}function BY({color:n}){const{gl:e}=Di();return P.useEffect(()=>{e.setClearColor(new Mt(n),1)},[e,n]),null}function kY({maxPixels:n,renderedMpRef:e}){const{size:t,setDpr:i}=Di();return P.useEffect(()=>{const r=window.devicePixelRatio,s=t.width*t.height,l=s>0?Math.sqrt(n/s):r,u=Math.min(.5,r),h=Math.min(r,Math.max(u,l));i(h),e&&(e.current=Math.round(s*h*h/1e3)/1e3)},[t.width,t.height,n,i,e]),null}const HY=.001;function VY(n,e){const t=P.useRef(0),i=P.useRef(1);return P.useEffect(()=>{if(!n){t.current=0,i.current=1;return}let r=window.scrollY;const s=()=>{const l=window.scrollY-r;r=window.scrollY,l>0?i.current=1:l<0&&(i.current=-1),t.current-=l*e*HY};return r=window.scrollY,window.addEventListener("scroll",s,{passive:!0}),()=>window.removeEventListener("scroll",s)},[n,e]),{velocityRef:t,directionRef:i}}function GY(n){const[e,t]=P.useState(()=>typeof document<"u"?document.visibilityState==="visible":!0),[i,r]=P.useState(!0);return P.useEffect(()=>{const s=()=>t(document.visibilityState==="visible");return document.addEventListener("visibilitychange",s),window.addEventListener("pageshow",s),window.addEventListener("pagehide",s),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("pageshow",s),window.removeEventListener("pagehide",s)}},[]),P.useEffect(()=>{const s=n.current;if(!s||typeof IntersectionObserver>"u")return;const l=new IntersectionObserver(u=>{const h=u[0];h&&r(h.isIntersecting)},{rootMargin:"100px"});return l.observe(s),()=>l.disconnect()},[n]),e&&i?"always":"never"}function WY({active:n}){const e=Di(l=>l.gl),t=Di(l=>l.camera),i=Di(l=>l.setSize),r=Di(l=>l.invalidate),s=P.useRef(n);return P.useEffect(()=>{const l=n&&!s.current;if(s.current=n,!l)return;let u=0;const h=requestAnimationFrame(()=>{u=requestAnimationFrame(()=>{const g=(e.domElement.parentElement??e.domElement).getBoundingClientRect(),y=Math.round(g.width),b=Math.round(g.height);y<=0||b<=0||(e.setSize(y,b,!1),t instanceof nr&&(t.aspect=y/b,t.updateProjectionMatrix()),i(y,b),r())})});return()=>{cancelAnimationFrame(h),cancelAnimationFrame(u)}},[n,e,t,i,r]),P.useEffect(()=>{const l=e.domElement,u=p=>{p.preventDefault(),console.warn("[gradient-ascent] WebGL context lost")},h=()=>{console.info("[gradient-ascent] WebGL context restored"),e.resetState?.()};return l.addEventListener("webglcontextlost",u),l.addEventListener("webglcontextrestored",h),()=>{l.removeEventListener("webglcontextlost",u),l.removeEventListener("webglcontextrestored",h)}},[e]),null}function XY({onReady:n}){const e=Di(l=>l.gl),t=Di(l=>l.scene),i=Di(l=>l.camera),r=P.useRef(0),s=P.useRef(!1);return P.useEffect(()=>{e.compile(t,i)},[e,t,i]),Wo(()=>{s.current||(r.current+=1,r.current>=2&&(s.current=!0,n()))}),null}function $Y(n){const e=Math.PI/180,t=P.useRef(null);t.current===null&&(t.current={pos:[n.desired.posX,n.desired.posY,n.desired.posZ],target:[n.desired.targetX,n.desired.targetY,n.desired.targetZ],fov:n.desired.fov});const i=t.current,r=i.pos[0]-i.target[0],s=i.pos[1]-i.target[1],l=i.pos[2]-i.target[2],u=Math.sqrt(r*r+s*s+l*l)||1,h=Math.acos(Math.min(Math.max(s/u,-1),1)),p=Math.atan2(r,l),g=n.rotateVertical?n.minPolarAngle*e:h,y=n.rotateVertical?n.maxPolarAngle*e:h,b=n.rotateHorizontal?n.minAzimuthAngle<=-360?-1/0:n.minAzimuthAngle*e:p,x=n.rotateHorizontal?n.maxAzimuthAngle>=360?1/0:n.maxAzimuthAngle*e:p,{camera:E}=Di(),A=P.useRef(null),T=P.useRef(n.onCameraChange);T.current=n.onCameraChange;const M=P.useCallback(()=>{const R=T.current;if(!R)return;const O=U=>Math.round(U*1e3)/1e3,D=E.position,F=A.current?.target??new Q;R({posX:O(D.x),posY:O(D.y),posZ:O(D.z),targetX:O(F.x),targetY:O(F.y),targetZ:O(F.z)})},[E]);return xt.jsxs(xt.Fragment,{children:[xt.jsx(vH,{makeDefault:!0,fov:i.fov,position:i.pos}),xt.jsx(yH,{ref:A,target:i.target,autoRotate:n.autoRotate&&!n.scrollRotate,autoRotateSpeed:n.autoRotateSpeed,enableRotate:n.rotateHorizontal||n.rotateVertical,enablePan:n.enablePan,enableZoom:n.enableZoom,enableDamping:!0,dampingFactor:.08,minPolarAngle:g,maxPolarAngle:y,minAzimuthAngle:b,maxAzimuthAngle:x,touches:{ONE:0,TWO:0},onEnd:M}),xt.jsx(UY,{desired:n.desired,introFrom:n.introFrom,introProgress:n.introProgress,rotateHorizontal:n.rotateHorizontal,rotateVertical:n.rotateVertical,controlsRef:A,scrollRotate:n.scrollRotate,scrollRotateDamping:n.scrollRotateDamping,scrollVelocityRef:n.scrollVelocityRef,scrollDirectionRef:n.scrollDirectionRef,autoRotate:n.autoRotate,autoRotateSpeed:n.autoRotateSpeed})]})}function jY({configOverrides:n,showPanel:e=!0}){const t=P.useMemo(()=>{if(!n)return kg;const Pe={};for(const ze of Object.keys(kg))Pe[ze]={...kg[ze],...n[ze]};return Pe},[]),[i,r]=P.useState(()=>Math.floor(Math.random()*65536)),s=P.useRef(new Be(0,0)),l=n?.responsive??LY,[u,h]=P.useState(()=>o3(l,window.innerWidth));P.useEffect(()=>{const Pe=()=>h(o3(l,window.innerWidth));return window.addEventListener("resize",Pe),()=>window.removeEventListener("resize",Pe)},[l]);const p=P.useRef(null),g=GY(p),y=g==="always",b=P.useCallback(()=>{p.current&&(p.current.dataset.ready="true")},[]),x=P.useRef({}),E=P.useRef(structuredClone(kg)),A=()=>{const Pe={};for(const[ze,at]of Object.entries(E.current))Pe[ze]={...at};return Pe},T=()=>{const Pe=E.current,ze={};for(const[at,je]of Object.entries(Pe)){const Ve=kg[at];for(const[nt,It]of Object.entries(je))JSON.stringify(It)!==JSON.stringify(Ve?.[nt])&&(ze[at]||(ze[at]={}),ze[at][nt]=It)}for(const at of Object.keys(ze))Object.keys(ze[at]).length===0&&delete ze[at];return ze},M=Pe=>{for(const[ze,at]of Object.entries(Pe)){const je=x.current[ze];je&&je(at)}},[R,O]=P.useState(0),D=t.intro,[F,U]=la("intro",()=>({enabled:{value:D.enabled,label:"Enabled"},duration:{value:D.duration,min:.5,max:30,step:.5,label:"Duration (s)"},easing:{value:D.easing,options:["linear","easeOutCubic","easeOutQuart","easeOutExpo","easeInOutSine","easeInOutCubic"],label:"Easing"},fromJson:{value:D.fromJson,label:"From (JSON)"},"▶ Replay Intro":sd(()=>{H(0),O(Pe=>Pe+1)})})),[k,H]=P.useState(()=>F.enabled?0:1);P.useEffect(()=>{if(!F.enabled)return;const Pe=l3[F.easing]??l3.easeOutExpo,ze=F.duration*1e3,at=performance.now();let je;const Ve=()=>{const nt=Math.min((performance.now()-at)/ze,1),It=nt>=1?1:Pe(nt);H(It),nt<1&&(je=requestAnimationFrame(Ve))};return je=requestAnimationFrame(Ve),()=>cancelAnimationFrame(je)},[R,F.enabled]);const[L,z]=P.useState(()=>localStorage.getItem(fM)!==null),[W,J]=P.useState(!1);la("presets",()=>({"💾 Save Settings Locally":sd(()=>{localStorage.setItem(fM,JSON.stringify(A())),z(!0)}),"📂 Load Local Settings":sd(()=>{const Pe=localStorage.getItem(fM);if(Pe)try{M(JSON.parse(Pe))}catch{alert("Failed to parse saved settings.")}},{disabled:!L}),"📋 Copy All Settings":sd(()=>{const Pe=JSON.stringify(A(),null,2);navigator.clipboard.writeText(Pe).then(()=>alert("All settings copied to clipboard."),()=>{window.prompt("Copy the settings below:",Pe)})}),"✂️ Copy Modified Settings":sd(()=>{const Pe=T(),ze=JSON.stringify(Pe,null,2);navigator.clipboard.writeText(ze).then(()=>alert("Modified settings copied to clipboard."),()=>{window.prompt("Copy the settings below:",ze)})},{disabled:!W}),"📥 Import Settings":sd(()=>{const Pe=window.prompt("Paste settings JSON:");if(Pe)try{M(JSON.parse(Pe))}catch{alert("Invalid JSON. Could not import settings.")}})}),[L,W]);const $=P.useRef(0),[oe,ne]=la("performance",()=>({showStats:{value:t.performance.showStats,label:"Show FPS Monitor"},maxPixels:{value:t.performance.maxPixels,options:{"1 MP":1e6,"2 MP":2e6,"4 MP":4e6,"8 MP":8e6,"16 MP":16e6},label:"Pixel Budget"},"Rendered (MP)":bq($,{graph:!1,interval:250})})),[Y,K]=la("surface",()=>({Regenerate:sd(()=>r(Math.floor(Math.random()*65536))),noiseScale:{value:t.surface.noiseScale,min:.5,max:10,step:.1,label:"Noise Scale"},noiseDetail:{value:t.surface.noiseDetail,min:1,max:8,step:1,label:"Detail"},heightScale:{value:t.surface.heightScale,min:0,max:5,step:.05,label:"Height"},surfaceSize:{value:t.surface.surfaceSize,min:1,max:100,step:.5,label:"Size"},subdivisions:{value:t.surface.subdivisions,min:16,max:256,step:1,label:"Subdivisions"},lacunarity:{value:t.surface.lacunarity,min:1.5,max:4,step:.1,label:"Lacunarity"},persistence:{value:t.surface.persistence,min:.1,max:.9,step:.05,label:"Persistence"},animationDuration:{value:t.surface.animationDuration,min:.3,max:20,step:.1,label:"Anim Duration"},loop:{value:t.surface.loop,label:"Loop"},easingType:{value:t.surface.easingType,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic","easeOutExpo","easeInOutExpo"],label:"Easing"},"Edge Pinning":Xn({pinEdges:{value:t.surface.pinEdges,label:"Enabled"},pinDepth:{value:t.surface.pinDepth,min:0,max:5,step:.05,label:"Depth"},pinSmoothTiles:{value:t.surface.pinSmoothTiles,min:1,max:60,step:1,label:"Radius (tiles)"}})})),[ie,ge]=la("animation",()=>({autoRegenerate:{value:t.animation.autoRegenerate,label:"Auto Regenerate"},matchAnimDuration:{value:t.animation.matchAnimDuration,label:"Match Anim Duration"},regenInterval:{value:t.animation.regenInterval,min:2,max:30,step:.5,label:"Interval (s)",render:Pe=>!Pe("animation.matchAnimDuration")}})),xe=ie.matchAnimDuration?Y.animationDuration:ie.regenInterval;P.useEffect(()=>{if(!ie.autoRegenerate)return;const Pe=setInterval(()=>r(Math.floor(Math.random()*65536)),xe*1e3);return()=>clearInterval(Pe)},[ie.autoRegenerate,xe]);const[q,ce]=la("grid",()=>({showGrid:{value:t.grid.showGrid,label:"Show"},gridColor:{value:t.grid.gridColor,label:"Color"},gridOpacity:{value:t.grid.gridOpacity,min:0,max:1,step:.01,label:"Opacity"},gridThickness:{value:t.grid.gridThickness,min:.2,max:5,step:.1,label:"Thickness"},gridBlendMode:{value:t.grid.gridBlendMode,options:["normal","add","screen","multiply","lighten"],label:"Blend Mode"},gridDithered:{value:t.grid.gridDithered,label:"Dithered"}})),[Se,Ge]=la("gradient",()=>({color1:{value:t.gradient.color1,label:"Low"},color2:{value:t.gradient.color2,label:"Mid-Low"},color3:{value:t.gradient.color3,label:"Mid"},color4:{value:t.gradient.color4,label:"Mid-High"},color5:{value:t.gradient.color5,label:"High"},color6:{value:t.gradient.color6,label:"Peak"}})),Ye=P.useMemo(()=>[Se.color1,Se.color2,Se.color3,Se.color4,Se.color5,Se.color6],[Se.color1,Se.color2,Se.color3,Se.color4,Se.color5,Se.color6]),[ve,Oe]=la("background",()=>({color:{value:t.background.color,label:"Color"}})),[it,gt]=la("shading",()=>({shadingStrength:{value:t.shading.shadingStrength,min:0,max:1,step:.01,label:"Strength"}})),[_t,jt]=la("fog",()=>({fogEnabled:{value:t.fog.fogEnabled,label:"Enabled"},fogColor:{value:t.fog.fogColor,label:"Color"},fogNear:{value:t.fog.fogNear,min:0,max:30,step:.5,label:"Near"},fogFar:{value:t.fog.fogFar,min:1,max:50,step:.5,label:"Far"}})),pt=t.camera,[mt,He]=la("camera",()=>({fov:{value:pt.fov,min:5,max:120,step:1,label:"FOV"},Position:Xn({posX:{value:pt.posX,min:-20,max:20,step:.1,label:"X"},posY:{value:pt.posY,min:.5,max:20,step:.1,label:"Y"},posZ:{value:pt.posZ,min:-20,max:20,step:.1,label:"Z"}}),Target:Xn({targetX:{value:pt.targetX,min:-20,max:20,step:.1,label:"X"},targetY:{value:pt.targetY,min:-20,max:20,step:.1,label:"Y"},targetZ:{value:pt.targetZ,min:-20,max:20,step:.1,label:"Z"}}),Rotation:Xn({autoRotate:{value:pt.autoRotate,label:"Auto Rotate"},autoRotateSpeed:{value:pt.autoRotateSpeed,min:0,max:5,step:.1,label:"Speed"},scrollRotate:{value:pt.scrollRotate,label:"Scroll Rotate"},scrollRotateFactor:{value:pt.scrollRotateFactor,min:0,max:5,step:.05,label:"Scroll Factor",render:Pe=>Pe("camera.Rotation.scrollRotate")},scrollRotateDamping:{value:pt.scrollRotateDamping,min:.1,max:10,step:.1,label:"Scroll Damping",render:Pe=>Pe("camera.Rotation.scrollRotate")}}),Interaction:Xn({rotateHorizontal:{value:pt.rotateHorizontal,label:"Rotate Horizontal"},rotateVertical:{value:pt.rotateVertical,label:"Rotate Vertical"},enablePan:{value:pt.enablePan,label:"Enable Pan"},enableZoom:{value:pt.enableZoom,label:"Enable Zoom"}}),Constraints:Xn({minPolarAngle:{value:pt.minPolarAngle,min:0,max:180,step:1,label:"Min Polar (°)"},maxPolarAngle:{value:pt.maxPolarAngle,min:0,max:180,step:1,label:"Max Polar (°)"},minAzimuthAngle:{value:pt.minAzimuthAngle,min:-360,max:360,step:1,label:"Min Azimuth (°)"},maxAzimuthAngle:{value:pt.maxAzimuthAngle,min:-360,max:360,step:1,label:"Max Azimuth (°)"}})})),Ue=t.pixelTrails,[Re,ft]=la("pixelTrails",()=>({enabled:{value:Ue.enabled,label:"Enabled"},Behavior:Xn({spawnRate:{value:Ue.spawnRate,min:.1,max:50,step:.1,label:"Spawn Rate (/s)"},maxTracers:{value:Ue.maxTracers,min:10,max:1e3,step:10,label:"Max Tracers"},range:{value:Ue.range,min:1,max:200,step:1,label:"Range (cells)"},minDistance:{value:Ue.minDistance,min:0,max:200,step:1,label:"Min Distance (cells)"},lifeMin:{value:Ue.lifeMin,min:.5,max:30,step:.5,label:"Life Min (s)"},lifeMax:{value:Ue.lifeMax,min:.5,max:30,step:.5,label:"Life Max (s)"},easingType:{value:Ue.easingType,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic","easeOutExpo","easeInOutExpo"],label:"Easing"},easingStrength:{value:Ue.easingStrength,min:0,max:1,step:.01,label:"Easing Strength"}}),Trail:Xn({trailLength:{value:Ue.trailLength,min:1,max:20,step:1,label:"Fully Lit Cells"},trailFadeCount:{value:Ue.trailFadeCount,min:0,max:30,step:1,label:"Fade Cells"},trailFadeTime:{value:Ue.trailFadeTime,min:.1,max:10,step:.1,label:"Fade Time (s)"}}),Visual:Xn({color:{value:Ue.color,label:"Color"},blendMode:{value:Ue.blendMode,options:["normal","add","screen","multiply","lighten"],label:"Blend Mode"},opacity:{value:Ue.opacity,min:0,max:1,step:.01,label:"Opacity"}}),"Fade In":Xn({fadeInTime:{value:Ue.fadeInTime,min:0,max:10,step:.1,label:"Duration (s)"}}),"Fade Out":Xn({fadeOutTime:{value:Ue.fadeOutTime,min:0,max:10,step:.1,label:"Duration (s)"}}),"Click Spawn":Xn({clickSpawnEnabled:{value:Ue.clickSpawnEnabled,label:"Enabled"},clickSpawnCount:{value:Ue.clickSpawnCount,min:1,max:100,step:1,label:"Tracers per Click"},clickSpawnOriginRadius:{value:Ue.clickSpawnOriginRadius,min:0,max:10,step:.5,label:"Origin Jitter (cells)"},clickSpawnCooldown:{value:Ue.clickSpawnCooldown,min:0,max:5,step:.05,label:"Min Interval (s)"},clickSpawnEasingType:{value:Ue.clickSpawnEasingType,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic","easeOutExpo","easeInOutExpo"],label:"Burst Easing"},clickSpawnEasingStrength:{value:Ue.clickSpawnEasingStrength,min:0,max:1,step:.01,label:"Burst Strength"}})})),Z=t.tracerPhysics,[At,dt]=la("tracerPhysics",()=>({enabled:{value:Z.enabled,label:"Enabled"},mass:{value:Z.mass,min:.1,max:10,step:.05,label:"Mass"},thrust:{value:Z.thrust,min:0,max:100,step:.5,label:"Thrust (cells/s²)"},thrustAngle:{value:Z.thrustAngle,min:-90,max:90,step:1,label:"Thrust Angle (°)"},surfaceGravity:{value:Z.surfaceGravity,min:-20,max:20,step:.1,label:"Surface Gravity"},damping:{value:Z.damping,min:0,max:5,step:.05,label:"Damping (/s)"},maxSpeed:{value:Z.maxSpeed,min:.1,max:10,step:.1,label:"Max Speed (UV/s)"}})),Ct=t.hoverHighlight,[tt,V]=la("hoverHighlight",()=>({enabled:{value:Ct.enabled,label:"Enabled"},Trail:Xn({trailLength:{value:Ct.trailLength,min:1,max:20,step:1,label:"Fully Lit Cells"},trailFadeCount:{value:Ct.trailFadeCount,min:0,max:30,step:1,label:"Fade Cells"},trailFadeTime:{value:Ct.trailFadeTime,min:.1,max:10,step:.1,label:"Fade Time (s)"}}),Visual:Xn({color:{value:Ct.color,label:"Color"},blendMode:{value:Ct.blendMode,options:["normal","add","screen","multiply","lighten"],label:"Blend Mode"},opacity:{value:Ct.opacity,min:0,max:1,step:.01,label:"Opacity"}}),"Fade In":Xn({fadeInTime:{value:Ct.fadeInTime,min:0,max:10,step:.05,label:"Duration (s)"}}),"Fade Out":Xn({fadeOutTime:{value:Ct.fadeOutTime,min:0,max:10,step:.05,label:"Duration (s)"}})})),N=t.peakBeam,[ee,Ee]=la("Peak Goals",()=>({enabled:{value:N.enabled,label:"Enabled"},Selection:Xn({peakCount:{value:N.peakCount,min:1,max:10,step:1,label:"Active Peaks"},minSeparation:{value:N.minSeparation,min:1,max:60,step:1,label:"Min Spacing Between Peaks (cells)"},outerExclusion:{value:N.outerExclusion,min:0,max:1,step:.01,label:"Outer Rim Exclusion"},innerExclusion:{value:N.innerExclusion,min:0,max:1,step:.01,label:"Inner Core Exclusion"},viewportOnly:{value:N.viewportOnly,label:"On-Screen Only"}}),Gravity:Xn({peakRadius:{value:N.peakRadius,min:1,max:40,step:1,label:"Field Radius (cells)"},arrivalRadius:{value:N.arrivalRadius,min:.1,max:5,step:.1,label:"Absorption Radius (cells)"},gravityStrength:{value:N.gravityStrength,min:0,max:10,step:.05,label:"Attraction Strength"},gravityDamping:{value:N.gravityDamping,min:0,max:10,step:.05,label:"In-Field Damping (/s)"},gravityTangentialBoost:{value:N.gravityTangentialBoost,min:0,max:50,step:.5,label:"Orbit Kick (cells/s)"}}),Impact:Xn({peakImpactCooldown:{value:N.peakImpactCooldown,min:0,max:10,step:.05,label:"Per-Peak Cooldown (s)"},Ripple:Xn({rippleMaxRadius:{value:N.rippleMaxRadius,min:1,max:40,step:1,label:"Max Radius (cells)"},rippleDuration:{value:N.rippleDuration,min:.05,max:5,step:.05,label:"Duration (s)"},rippleThickness:{value:N.rippleThickness,min:.5,max:6,step:.1,label:"Ring Thickness"},rippleEasing:{value:N.rippleEasing,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic","easeOutExpo","easeInOutExpo"],label:"Growth Easing"},rippleColor:{value:N.rippleColor,label:"Color"},rippleOpacity:{value:N.rippleOpacity,min:0,max:2,step:.05,label:"Opacity"},rippleBlendMode:{value:N.rippleBlendMode,options:["normal","add","screen","multiply","lighten"],label:"Blend Mode"},rippleUseTracerEffects:{value:N.rippleUseTracerEffects,label:"Use Tracer FX"}}),Flash:Xn({flashDuration:{value:N.flashDuration,min:.02,max:1,step:.01,label:"Duration (s)"},flashIntensity:{value:N.flashIntensity,min:0,max:5,step:.05,label:"Intensity"}}),Light:Xn({realLightEnabled:{value:N.realLightEnabled,label:"Enabled"},realLightIntensity:{value:N.realLightIntensity,min:0,max:10,step:.05,label:"Intensity"},realLightRange:{value:N.realLightRange,min:.1,max:20,step:.1,label:"Range (world)"},realLightElevation:{value:N.realLightElevation,min:0,max:10,step:.05,label:"Height Above Peak"},realLightFadeInDuration:{value:N.realLightFadeInDuration,min:0,max:10,step:.05,label:"Fade In (s)"},realLightFadeInEasing:{value:N.realLightFadeInEasing,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic","easeOutExpo","easeInOutExpo"],label:"Fade In Easing"},realLightHoldDuration:{value:N.realLightHoldDuration,min:0,max:30,step:.1,label:"Hold at Peak (s)"},realLightFadeOutDuration:{value:N.realLightFadeOutDuration,min:0,max:10,step:.05,label:"Fade Out (s)"},realLightFadeOutEasing:{value:N.realLightFadeOutEasing,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic","easeOutExpo","easeInOutExpo"],label:"Fade Out Easing"},realLightFlickerMax:{value:N.realLightFlickerMax,min:0,max:1,step:.01,label:"Flicker Depth"},realLightFlickerFreq:{value:N.realLightFlickerFreq,min:0,max:30,step:.5,label:"Flicker Speed (Hz)"}}),"Hit Image":Xn({hitImageEnabled:{value:N.hitImageEnabled,label:"Enabled"},hitImageUrls:{value:c3(N.hitImageUrls).join(` `),rows:4,label:"Image URLs (one per line)"},hitImageSize:{value:N.hitImageSize,min:.1,max:15,step:.1,label:"Size (world)"},hitImageOpacity:{value:N.hitImageOpacity,min:0,max:4,step:.01,label:"Opacity / Intensity"},hitImageFadeInDuration:{value:N.hitImageFadeInDuration,min:.02,max:5,step:.02,label:"Fade In (s)"},hitImageFadeOutDuration:{value:N.hitImageFadeOutDuration,min:.02,max:5,step:.02,label:"Fade Out (s)"},hitImageBlendMode:{value:N.hitImageBlendMode,options:["normal","add","screen","multiply","lighten"],label:"Blend Mode"}})}),"Peak Connections":Xn({connectionsEnabled:{value:N.connectionsEnabled,label:"Enabled"},connectionsCircleRadius:{value:N.connectionsCircleRadius,min:4,max:100,step:.5,label:"Circle Radius (px)"},connectionsCircleRingColor:{value:N.connectionsCircleRingColor,label:"Ring Color"},connectionsCircleRingThickness:{value:N.connectionsCircleRingThickness,min:.01,max:.5,step:.01,label:"Ring Thickness"},connectionsCircleRingOpacity:{value:N.connectionsCircleRingOpacity,min:0,max:1,step:.01,label:"Ring Opacity"},connectionsCircleFillColor:{value:N.connectionsCircleFillColor,label:"Fill Color"},connectionsCircleFillOpacity:{value:N.connectionsCircleFillOpacity,min:0,max:1,step:.01,label:"Fill Opacity"},connectionsCircleFadeInDuration:{value:N.connectionsCircleFadeInDuration,min:.05,max:5,step:.05,label:"Circle Fade In (s)"},connectionsCircleFadeOutDuration:{value:N.connectionsCircleFadeOutDuration,min:.05,max:5,step:.05,label:"Circle Fade Out (s)"},connectionsLineColor:{value:N.connectionsLineColor,label:"Line Color"},connectionsLineThickness:{value:N.connectionsLineThickness,min:.5,max:20,step:.5,label:"Line Thickness (px)"},connectionsLineOpacity:{value:N.connectionsLineOpacity,min:0,max:1,step:.01,label:"Line Opacity"},connectionsLineDrawDuration:{value:N.connectionsLineDrawDuration,min:.05,max:5,step:.05,label:"Line Draw Speed (s/segment)"},connectionsLineFadeInDuration:{value:N.connectionsLineFadeInDuration,min:.05,max:5,step:.05,label:"Line Fade In (s)"},connectionsLineFadeOutDuration:{value:N.connectionsLineFadeOutDuration,min:.05,max:5,step:.05,label:"Line Retract Duration (s)"}}),Debug:Xn({debugPeakOverlay:{value:N.debugPeakOverlay,label:"Show Peak Overlay"},debugPeakOverlayOpacity:{value:N.debugPeakOverlayOpacity,min:0,max:1,step:.01,label:"Overlay Opacity"}},{collapsed:!1})})),Te=t.surfaceEffects,[pe,Et]=la("surfaceEffects",()=>({Bloom:Xn({bloomEnabled:{value:Te.bloomEnabled,label:"Enabled"},bloom:{value:Te.bloom,min:0,max:3,step:.05,label:"Intensity"},bloomThreshold:{value:Te.bloomThreshold,min:0,max:1,step:.05,label:"Threshold"}}),Vignette:Xn({vignetteEnabled:{value:Te.vignetteEnabled,label:"Enabled"},vignetteDarkness:{value:Te.vignetteDarkness,min:0,max:1.5,step:.05,label:"Darkness"}}),"Chromatic Aberration":Xn({caEnabled:{value:Te.caEnabled,label:"Enabled"},chromaticAberration:{value:Te.chromaticAberration,min:0,max:.02,step:5e-4,label:"Offset"}}),Noise:Xn({noiseEnabled:{value:Te.noiseEnabled,label:"Enabled"},noise:{value:Te.noise,min:0,max:.5,step:.01,label:"Opacity"}}),Dither:Xn({ditherEnabled:{value:Te.ditherEnabled,label:"Enabled"},ditherThreshold:{value:Te.ditherThreshold,min:0,max:1,step:.01,label:"Threshold"},ditherPixelScale:{value:Te.ditherPixelScale,min:1,max:8,step:1,label:"Pixel Scale"},ditherMix:{value:Te.ditherMix,min:0,max:1,step:.01,label:"Mix"},ditherPattern:{value:Te.ditherPattern,options:[2,4,8],label:"Pattern Size"},ditherBlend:{value:Te.ditherBlend,options:["normal","multiply","screen","overlay","add","softLight"],label:"Blend Mode"},ditherColor:{value:Te.ditherColor,label:"Color"},ditherBgColor:{value:Te.ditherBgColor,label:"BG Color"}}),"Tone Mapping":Xn({tmEnabled:{value:Te.tmEnabled,label:"Enabled"},toneMapping:{value:Te.toneMapping,options:["LINEAR","REINHARD","REINHARD2","OPTIMIZED_CINEON","ACES_FILMIC","AGX"],label:"Mode"}})})),$e=t.tracerEffects,[lt,Lt]=la("tracerEffects",()=>({Dither:Xn({ditherEnabled:{value:$e.ditherEnabled,label:"Enabled"},useSurfaceDither:{value:$e.useSurfaceDither,label:"Use Surface Settings"},ditherThreshold:{value:$e.ditherThreshold,min:0,max:1,step:.01,label:"Threshold"},ditherPixelScale:{value:$e.ditherPixelScale,min:1,max:8,step:1,label:"Pixel Scale"},ditherMix:{value:$e.ditherMix,min:0,max:1,step:.01,label:"Mix"},ditherPattern:{value:$e.ditherPattern,options:[2,4,8],label:"Pattern Size"},ditherBlend:{value:$e.ditherBlend,options:["normal","multiply","screen","overlay","add","softLight"],label:"Blend Mode"},ditherColor:{value:$e.ditherColor,label:"Color"}}),Bloom:Xn({bloomEnabled:{value:$e.bloomEnabled,label:"Enabled"},bloom:{value:$e.bloom,min:0,max:20,step:.05,label:"Strength"},bloomRadius:{value:$e.bloomRadius,min:1,max:20,step:.5,label:"Radius"},bloomIterations:{value:$e.bloomIterations,min:1,max:5,step:1,label:"Iterations"}}),"Chromatic Aberration":Xn({caEnabled:{value:$e.caEnabled,label:"Enabled"},chromaticAberration:{value:$e.chromaticAberration,min:0,max:.2,step:.001,label:"Strength"},caSamples:{value:$e.caSamples,min:1,max:8,step:1,label:"Samples"}})}));P.useEffect(()=>{const Pe=lt.useSurfaceDither;zY.forEach(ze=>Zx.disableInputAtPath(ze,Pe))},[lt.useSurfaceDither]),P.useEffect(()=>{const Pe=At.enabled;FY.forEach(ze=>Zx.disableInputAtPath(ze,Pe))},[At.enabled]);const Ze={ditherEnabled:lt.ditherEnabled,ditherThreshold:lt.useSurfaceDither?pe.ditherThreshold:lt.ditherThreshold,ditherPixelScale:lt.useSurfaceDither?pe.ditherPixelScale:lt.ditherPixelScale,ditherMix:lt.useSurfaceDither?pe.ditherMix:lt.ditherMix,ditherPattern:lt.useSurfaceDither?pe.ditherPattern:lt.ditherPattern,ditherBlend:lt.useSurfaceDither?pe.ditherBlend:lt.ditherBlend,ditherColor:lt.useSurfaceDither?pe.ditherColor:lt.ditherColor,bloomEnabled:lt.bloomEnabled,bloom:lt.bloom,bloomRadius:lt.bloomRadius,bloomIterations:lt.bloomIterations,caEnabled:lt.caEnabled,chromaticAberration:lt.chromaticAberration,caSamples:lt.caSamples};x.current={performance:ne,surface:K,animation:ge,grid:ce,gradient:Ge,background:Oe,shading:gt,fog:jt,camera:He,pixelTrails:ft,tracerPhysics:dt,hoverHighlight:V,peakBeam:Ee,surfaceEffects:Et,tracerEffects:Lt,intro:U},E.current={performance:{...oe},surface:{...Y},animation:{...ie},grid:{...q},gradient:{...Se},background:{...ve},shading:{...it},fog:{..._t},camera:{...mt},pixelTrails:{...Re},tracerPhysics:{...At},hoverHighlight:{...tt},peakBeam:{...ee},surfaceEffects:{...pe},tracerEffects:{...lt},intro:{...F}},P.useEffect(()=>{const Pe=Object.keys(T()).length>0;J(ze=>ze!==Pe?Pe:ze)});const rt=k,vt=P.useMemo(()=>{try{return JSON.parse(F.fromJson)}catch{return}},[F.fromJson]),te=(Pe,ze,at)=>Fu(vt,Pe,ze,at,rt),be=u.camera?.scrollRotate??mt.scrollRotate,{velocityRef:ct,directionRef:re}=VY(be,mt.scrollRotateFactor);return xt.jsxs("div",{ref:p,className:"ga-canvas",style:{width:"100%",height:"100%",touchAction:"pan-y"},children:[Jx.createPortal(xt.jsx(DP,{hidden:!e,theme:{sizes:{rootWidth:"340px"}}}),document.body),xt.jsxs(h6,{frameloop:g,gl:{antialias:!1,alpha:!1,powerPreference:"high-performance"},children:[xt.jsx(WY,{active:y}),xt.jsx(XY,{onReady:b}),xt.jsx(BY,{color:ve.color}),xt.jsx(kY,{maxPixels:u.performance?.maxPixels??oe.maxPixels,renderedMpRef:$}),xt.jsx($Y,{desired:{posX:mt.posX,posY:mt.posY,posZ:mt.posZ,targetX:mt.targetX,targetY:mt.targetY,targetZ:mt.targetZ,fov:u.camera?.fov??mt.fov},introFrom:F.enabled?vt:void 0,introProgress:F.enabled?k:1,autoRotate:mt.autoRotate,autoRotateSpeed:mt.autoRotateSpeed,rotateHorizontal:mt.rotateHorizontal,rotateVertical:mt.rotateVertical,scrollRotate:be,scrollRotateDamping:mt.scrollRotateDamping,scrollVelocityRef:ct,scrollDirectionRef:re,enablePan:mt.enablePan,enableZoom:mt.enableZoom,minPolarAngle:mt.minPolarAngle,maxPolarAngle:mt.maxPolarAngle,minAzimuthAngle:mt.minAzimuthAngle,maxAzimuthAngle:mt.maxAzimuthAngle,onCameraChange:Pe=>He(Pe)}),xt.jsx(PY,{seed:i,noiseScale:Y.noiseScale,noiseDetail:Y.noiseDetail,heightScale:Y.heightScale,surfaceSize:Y.surfaceSize,subdivisions:u.surface?.subdivisions??Y.subdivisions,lacunarity:Y.lacunarity,persistence:Y.persistence,animationDuration:Y.animationDuration,loop:Y.loop,easingType:Y.easingType,onAnimationComplete:()=>r(Math.floor(Math.random()*65536)),showGrid:q.showGrid,gridColor:q.gridColor,gridOpacity:q.gridOpacity,gridThickness:q.gridThickness,gridBlendMode:q.gridBlendMode,gridDithered:q.gridDithered,colors:Ye,shadingStrength:te("shading","shadingStrength",it.shadingStrength),fogEnabled:_t.fogEnabled,fogColor:_t.fogColor,fogNear:te("fog","fogNear",_t.fogNear),fogFar:te("fog","fogFar",_t.fogFar),pixelTrails:{enabled:Re.enabled,spawnRate:Re.spawnRate,maxTracers:Re.maxTracers,range:Re.range,minDistance:Re.minDistance,lifeMin:Re.lifeMin,lifeMax:Re.lifeMax,easingType:Re.easingType,easingStrength:Re.easingStrength,trailLength:Re.trailLength,trailFadeCount:Re.trailFadeCount,trailFadeTime:Re.trailFadeTime,color:Re.color,blendMode:Re.blendMode,opacity:Re.opacity,fadeInTime:Re.fadeInTime,fadeOutTime:Re.fadeOutTime},tracerEffects:Ze,hoverHighlight:{enabled:tt.enabled,trailLength:tt.trailLength,trailFadeCount:tt.trailFadeCount,trailFadeTime:tt.trailFadeTime,color:tt.color,blendMode:tt.blendMode,opacity:tt.opacity,fadeInTime:tt.fadeInTime,fadeOutTime:tt.fadeOutTime},clickSpawn:{enabled:Re.clickSpawnEnabled,count:Re.clickSpawnCount,originRadius:Re.clickSpawnOriginRadius,cooldown:Re.clickSpawnCooldown,easingType:Re.clickSpawnEasingType,easingStrength:Re.clickSpawnEasingStrength},tracerPhysics:{enabled:At.enabled,mass:At.mass,thrust:At.thrust,thrustAngle:At.thrustAngle,surfaceGravity:At.surfaceGravity,damping:At.damping,maxSpeed:At.maxSpeed},peakBeam:{enabled:ee.enabled,peakRadius:ee.peakRadius,peakImpactCooldown:ee.peakImpactCooldown,gravityStrength:ee.gravityStrength,gravityDamping:ee.gravityDamping,gravityTangentialBoost:ee.gravityTangentialBoost,arrivalRadius:ee.arrivalRadius,peakCount:ee.peakCount,minSeparation:ee.minSeparation,outerExclusion:ee.outerExclusion,innerExclusion:ee.innerExclusion,viewportOnly:ee.viewportOnly,rippleMaxRadius:ee.rippleMaxRadius,rippleDuration:ee.rippleDuration,rippleThickness:ee.rippleThickness,rippleEasing:ee.rippleEasing,rippleColor:ee.rippleColor,rippleOpacity:ee.rippleOpacity,rippleBlendMode:ee.rippleBlendMode,rippleUseTracerEffects:ee.rippleUseTracerEffects,flashDuration:ee.flashDuration,flashIntensity:ee.flashIntensity,realLightEnabled:ee.realLightEnabled,realLightIntensity:ee.realLightIntensity,realLightRange:ee.realLightRange,realLightElevation:ee.realLightElevation,realLightFadeInDuration:ee.realLightFadeInDuration,realLightFadeInEasing:ee.realLightFadeInEasing,realLightHoldDuration:ee.realLightHoldDuration,realLightFadeOutDuration:ee.realLightFadeOutDuration,realLightFadeOutEasing:ee.realLightFadeOutEasing,realLightFlickerMax:ee.realLightFlickerMax,realLightFlickerFreq:ee.realLightFlickerFreq,hitImageEnabled:ee.hitImageEnabled,hitImageUrls:c3(ee.hitImageUrls),hitImageSize:ee.hitImageSize,hitImageOpacity:ee.hitImageOpacity,hitImageFadeInDuration:ee.hitImageFadeInDuration,hitImageFadeOutDuration:ee.hitImageFadeOutDuration,hitImageBlendMode:ee.hitImageBlendMode,debugPeakOverlay:ee.debugPeakOverlay,debugPeakOverlayOpacity:ee.debugPeakOverlayOpacity,connectionsEnabled:ee.connectionsEnabled,connectionsCircleRadius:u.peakBeam?.connectionsCircleRadius??ee.connectionsCircleRadius,connectionsCircleRingColor:ee.connectionsCircleRingColor,connectionsCircleRingThickness:u.peakBeam?.connectionsCircleRingThickness??ee.connectionsCircleRingThickness,connectionsCircleRingOpacity:ee.connectionsCircleRingOpacity,connectionsCircleFillColor:ee.connectionsCircleFillColor,connectionsCircleFillOpacity:ee.connectionsCircleFillOpacity,connectionsCircleFadeInDuration:ee.connectionsCircleFadeInDuration,connectionsCircleFadeOutDuration:ee.connectionsCircleFadeOutDuration,connectionsLineColor:ee.connectionsLineColor,connectionsLineThickness:u.peakBeam?.connectionsLineThickness??ee.connectionsLineThickness,connectionsLineOpacity:ee.connectionsLineOpacity,connectionsLineDrawDuration:ee.connectionsLineDrawDuration,connectionsLineFadeInDuration:ee.connectionsLineFadeInDuration,connectionsLineFadeOutDuration:ee.connectionsLineFadeOutDuration},pinEdges:Y.pinEdges,pinDepth:Y.pinDepth,pinSmoothTiles:Y.pinSmoothTiles}),oe.showStats&&xt.jsx(EH,{className:"stats"}),xt.jsxs(n8,{multisampling:8,children:[xt.jsx(r8,{intensity:pe.bloomEnabled?te("surfaceEffects","bloom",pe.bloom):0,luminanceThreshold:pe.bloomThreshold,luminanceSmoothing:.9,mipmapBlur:!0}),xt.jsx(a8,{offset:(()=>{const Pe=pe.caEnabled?pe.chromaticAberration:0;return s.current.set(Pe,Pe),s.current})(),radialModulation:!1,modulationOffset:.5}),xt.jsx(s8,{opacity:pe.noiseEnabled?te("surfaceEffects","noise",pe.noise):0,blendFunction:Rn.OVERLAY}),xt.jsx(aY,{enabled:pe.ditherEnabled,threshold:pe.ditherThreshold,pixelScale:pe.ditherPixelScale,mixAmount:te("surfaceEffects","ditherMix",pe.ditherMix),patternSize:pe.ditherPattern,blendMode:pe.ditherBlend,color:pe.ditherColor,bgColor:pe.ditherBgColor}),xt.jsx(o8,{mode:pe.tmEnabled?Xa[pe.toneMapping]:Xa.LINEAR}),xt.jsx(l8,{darkness:pe.vignetteEnabled?te("surfaceEffects","vignetteDarkness",pe.vignetteDarkness):0,offset:.5})]})]})]})}function u3(){const n=document.querySelectorAll("[data-gradient]");n.forEach(e=>{getComputedStyle(e).position==="static"&&(e.style.position="relative");let t;const i=e.getAttribute("data-gradient-config");if(i)try{t=JSON.parse(i)}catch(s){console.error("[gradient-ascent] Invalid JSON in data-gradient-config:",s)}if(t?.intro){const s=t.intro;s.from!==void 0&&s.fromJson===void 0&&(s.fromJson=JSON.stringify(s.from),delete s.from)}h3.createRoot(e).render(xt.jsx(P.StrictMode,{children:xt.jsx(jY,{configOverrides:t,showPanel:e.hasAttribute("data-gradient-panel")})}))}),n.length===0&&console.warn("[gradient-ascent] No [data-gradient] elements found.")}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u3):u3();