(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(r){if(r.ep)return;r.ep=!0;const o=t(r);fetch(r.href,o)}})();function tE(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var xv={exports:{}},Zh={},Sv={exports:{}},rn={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var CS;function pR(){if(CS)return rn;CS=1;var i=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.iterator;function v(G){return G===null||typeof G!="object"?null:(G=g&&G[g]||G["@@iterator"],typeof G=="function"?G:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,A={};function E(G,ee,De){this.props=G,this.context=ee,this.refs=A,this.updater=De||x}E.prototype.isReactComponent={},E.prototype.setState=function(G,ee){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,ee,"setState")},E.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function S(){}S.prototype=E.prototype;function b(G,ee,De){this.props=G,this.context=ee,this.refs=A,this.updater=De||x}var P=b.prototype=new S;P.constructor=b,w(P,E.prototype),P.isPureReactComponent=!0;var I=Array.isArray,B=Object.prototype.hasOwnProperty,F={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function H(G,ee,De){var le,xe={},be=null,Te=null;if(ee!=null)for(le in ee.ref!==void 0&&(Te=ee.ref),ee.key!==void 0&&(be=""+ee.key),ee)B.call(ee,le)&&!V.hasOwnProperty(le)&&(xe[le]=ee[le]);var We=arguments.length-2;if(We===1)xe.children=De;else if(1>>1,ee=O[G];if(0>>1;Gr(xe,K))ber(Te,xe)?(O[G]=Te,O[be]=K,G=be):(O[G]=xe,O[le]=K,G=le);else if(ber(Te,K))O[G]=Te,O[be]=K,G=be;else break e}}return J}function r(O,J){var K=O.sortIndex-J.sortIndex;return K!==0?K:O.id-J.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;i.unstable_now=function(){return o.now()}}else{var a=Date,u=a.now();i.unstable_now=function(){return a.now()-u}}var h=[],p=[],m=1,g=null,v=3,x=!1,w=!1,A=!1,E=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(O){for(var J=t(p);J!==null;){if(J.callback===null)n(p);else if(J.startTime<=O)n(p),J.sortIndex=J.expirationTime,e(h,J);else break;J=t(p)}}function I(O){if(A=!1,P(O),!w)if(t(h)!==null)w=!0,ue(B);else{var J=t(p);J!==null&&ye(I,J.startTime-O)}}function B(O,J){w=!1,A&&(A=!1,S(H),H=-1),x=!0;var K=v;try{for(P(J),g=t(h);g!==null&&(!(g.expirationTime>J)||O&&!W());){var G=g.callback;if(typeof G=="function"){g.callback=null,v=g.priorityLevel;var ee=G(g.expirationTime<=J);J=i.unstable_now(),typeof ee=="function"?g.callback=ee:g===t(h)&&n(h),P(J)}else n(h);g=t(h)}if(g!==null)var De=!0;else{var le=t(p);le!==null&&ye(I,le.startTime-J),De=!1}return De}finally{g=null,v=K,x=!1}}var F=!1,V=null,H=-1,U=5,D=-1;function W(){return!(i.unstable_now()-DO||125G?(O.sortIndex=K,e(p,O),t(h)===null&&O===t(p)&&(A?(S(H),H=-1):A=!0,ye(I,K-G))):(O.sortIndex=ee,e(h,O),w||x||(w=!0,ue(B))),O},i.unstable_shouldYield=W,i.unstable_wrapCallback=function(O){var J=v;return function(){var K=v;v=J;try{return O.apply(this,arguments)}finally{v=K}}}}(Ev)),Ev}var LS;function yR(){return LS||(LS=1,wv.exports=vR()),wv.exports}/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var DS;function _R(){if(DS)return Ur;DS=1;var i=a0(),e=yR();function t(s){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+s,d=1;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},g={};function v(s){return h.call(g,s)?!0:h.call(m,s)?!1:p.test(s)?g[s]=!0:(m[s]=!0,!1)}function x(s,l,d,_){if(d!==null&&d.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return _?!1:d!==null?!d.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function w(s,l,d,_){if(l===null||typeof l>"u"||x(s,l,d,_))return!0;if(_)return!1;if(d!==null)switch(d.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function A(s,l,d,_,T,R,N){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=_,this.attributeNamespace=T,this.mustUseProperty=d,this.propertyName=s,this.type=l,this.sanitizeURL=R,this.removeEmptyString=N}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){E[s]=new A(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var l=s[0];E[l]=new A(l,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){E[s]=new A(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){E[s]=new A(s,2,!1,s,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s){E[s]=new A(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){E[s]=new A(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){E[s]=new A(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){E[s]=new A(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){E[s]=new A(s,5,!1,s.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function b(s){return s[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(s){var l=s.replace(S,b);E[l]=new A(l,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var l=s.replace(S,b);E[l]=new A(l,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var l=s.replace(S,b);E[l]=new A(l,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){E[s]=new A(s,1,!1,s.toLowerCase(),null,!1,!1)}),E.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){E[s]=new A(s,1,!1,s.toLowerCase(),null,!0,!0)});function P(s,l,d,_){var T=E.hasOwnProperty(l)?E[l]:null;(T!==null?T.type!==0:_||!(2Z||T[N]!==R[Z]){var Q=` `+T[N].replace(" at new "," at ");return s.displayName&&Q.includes("")&&(Q=Q.replace("",s.displayName)),Q}while(1<=N&&0<=Z);break}}}finally{De=!1,Error.prepareStackTrace=d}return(s=s?s.displayName||s.name:"")?ee(s):""}function xe(s){switch(s.tag){case 5:return ee(s.type);case 16:return ee("Lazy");case 13:return ee("Suspense");case 19:return ee("SuspenseList");case 0:case 2:case 15:return s=le(s.type,!1),s;case 11:return s=le(s.type.render,!1),s;case 1:return s=le(s.type,!0),s;default:return""}}function be(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case V:return"Fragment";case F:return"Portal";case U:return"Profiler";case H:return"StrictMode";case ie:return"Suspense";case fe:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case W:return(s.displayName||"Context")+".Consumer";case D:return(s._context.displayName||"Context")+".Provider";case se:var l=s.render;return s=s.displayName,s||(s=l.displayName||l.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case Me:return l=s.displayName||null,l!==null?l:be(s.type)||"Memo";case ue:l=s._payload,s=s._init;try{return be(s(l))}catch{}}return null}function Te(s){var l=s.type;switch(s.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=l.render,s=s.displayName||s.name||"",l.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return be(l);case 8:return l===H?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function We(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function tt(s){var l=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function ht(s){var l=tt(s)?"checked":"value",d=Object.getOwnPropertyDescriptor(s.constructor.prototype,l),_=""+s[l];if(!s.hasOwnProperty(l)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var T=d.get,R=d.set;return Object.defineProperty(s,l,{configurable:!0,get:function(){return T.call(this)},set:function(N){_=""+N,R.call(this,N)}}),Object.defineProperty(s,l,{enumerable:d.enumerable}),{getValue:function(){return _},setValue:function(N){_=""+N},stopTracking:function(){s._valueTracker=null,delete s[l]}}}}function It(s){s._valueTracker||(s._valueTracker=ht(s))}function Pe(s){if(!s)return!1;var l=s._valueTracker;if(!l)return!0;var d=l.getValue(),_="";return s&&(_=tt(s)?s.checked?"true":"false":s.value),s=_,s!==d?(l.setValue(s),!0):!1}function Ne(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function Y(s,l){var d=l.checked;return K({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??s._wrapperState.initialChecked})}function yt(s,l){var d=l.defaultValue==null?"":l.defaultValue,_=l.checked!=null?l.checked:l.defaultChecked;d=We(l.value!=null?l.value:d),s._wrapperState={initialChecked:_,initialValue:d,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function ke(s,l){l=l.checked,l!=null&&P(s,"checked",l,!1)}function rt(s,l){ke(s,l);var d=We(l.value),_=l.type;if(d!=null)_==="number"?(d===0&&s.value===""||s.value!=d)&&(s.value=""+d):s.value!==""+d&&(s.value=""+d);else if(_==="submit"||_==="reset"){s.removeAttribute("value");return}l.hasOwnProperty("value")?Et(s,l.type,d):l.hasOwnProperty("defaultValue")&&Et(s,l.type,We(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(s.defaultChecked=!!l.defaultChecked)}function Ge(s,l,d){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var _=l.type;if(!(_!=="submit"&&_!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+s._wrapperState.initialValue,d||l===s.value||(s.value=l),s.defaultValue=l}d=s.name,d!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,d!==""&&(s.name=d)}function Et(s,l,d){(l!=="number"||Ne(s.ownerDocument)!==s)&&(d==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+d&&(s.defaultValue=""+d))}var je=Array.isArray;function X(s,l,d,_){if(s=s.options,l){l={};for(var T=0;T"+l.valueOf().toString()+"",l=Ye.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;l.firstChild;)s.appendChild(l.firstChild)}});function Ht(s,l){if(l){var d=s.firstChild;if(d&&d===s.lastChild&&d.nodeType===3){d.nodeValue=l;return}}s.textContent=l}var Be={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ct=["Webkit","ms","Moz","O"];Object.keys(Be).forEach(function(s){ct.forEach(function(l){l=l+s.charAt(0).toUpperCase()+s.substring(1),Be[l]=Be[s]})});function Tt(s,l,d){return l==null||typeof l=="boolean"||l===""?"":d||typeof l!="number"||l===0||Be.hasOwnProperty(s)&&Be[s]?(""+l).trim():l+"px"}function Lt(s,l){s=s.style;for(var d in l)if(l.hasOwnProperty(d)){var _=d.indexOf("--")===0,T=Tt(d,l[d],_);d==="float"&&(d="cssFloat"),_?s.setProperty(d,T):s[d]=T}}var ft=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function nn(s,l){if(l){if(ft[s]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(t(137,s));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(t(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(t(61))}if(l.style!=null&&typeof l.style!="object")throw Error(t(62))}}function Ot(s,l){if(s.indexOf("-")===-1)return typeof l.is=="string";switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var pn=null;function re(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Ze=null,Se=null,Re=null;function $e(s){if(s=Ds(s)){if(typeof Ze!="function")throw Error(t(280));var l=s.stateNode;l&&(l=Oc(l),Ze(s.stateNode,s.type,l))}}function Ke(s){Se?Re?Re.push(s):Re=[s]:Se=s}function kt(){if(Se){var s=Se,l=Re;if(Re=Se=null,$e(s),l)for(s=0;s>>=0,s===0?32:31-(Qt(s)/Ut|0)|0}var xn=64,Dt=4194304;function jn(s){switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function wr(s,l){var d=s.pendingLanes;if(d===0)return 0;var _=0,T=s.suspendedLanes,R=s.pingedLanes,N=d&268435455;if(N!==0){var Z=N&~T;Z!==0?_=jn(Z):(R&=N,R!==0&&(_=jn(R)))}else N=d&~T,N!==0?_=jn(N):R!==0&&(_=jn(R));if(_===0)return 0;if(l!==0&&l!==_&&!(l&T)&&(T=_&-_,R=l&-l,T>=R||T===16&&(R&4194240)!==0))return l;if(_&4&&(_|=d&16),l=s.entangledLanes,l!==0)for(s=s.entanglements,l&=_;0d;d++)l.push(s);return l}function Bn(s,l,d){s.pendingLanes|=l,l!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,l=31-Jt(l),s[l]=d}function wi(s,l){var d=s.pendingLanes&~l;s.pendingLanes=l,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=l,s.mutableReadLanes&=l,s.entangledLanes&=l,l=s.entanglements;var _=s.eventTimes;for(s=s.expirationTimes;0=fi),br=" ",ch=!1;function fh(s,l){switch(s){case"keyup":return uh.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xc(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var lo=!1;function Ep(s,l){switch(s){case"compositionend":return xc(l);case"keypress":return l.which!==32?null:(ch=!0,br);case"textInput":return s=l.data,s===br&&ch?null:s;default:return null}}function Ll(s,l){if(lo)return s==="compositionend"||!Fi&&fh(s,l)?(s=Pl(),ji=ih=Xr=null,lo=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:d,offset:l-s};s=_}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Dl(d)}}function Go(s,l){return s&&l?s===l?!0:s&&s.nodeType===3?!1:l&&l.nodeType===3?Go(s,l.parentNode):"contains"in s?s.contains(l):s.compareDocumentPosition?!!(s.compareDocumentPosition(l)&16):!1:!1}function Dn(){for(var s=window,l=Ne();l instanceof s.HTMLIFrameElement;){try{var d=typeof l.contentWindow.location.href=="string"}catch{d=!1}if(d)s=l.contentWindow;else break;l=Ne(s.document)}return l}function ri(s){var l=s&&s.nodeName&&s.nodeName.toLowerCase();return l&&(l==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||l==="textarea"||s.contentEditable==="true")}function si(s){var l=Dn(),d=s.focusedElem,_=s.selectionRange;if(l!==d&&d&&d.ownerDocument&&Go(d.ownerDocument.documentElement,d)){if(_!==null&&ri(d)){if(l=_.start,s=_.end,s===void 0&&(s=l),"selectionStart"in d)d.selectionStart=l,d.selectionEnd=Math.min(s,d.value.length);else if(s=(l=d.ownerDocument||document)&&l.defaultView||window,s.getSelection){s=s.getSelection();var T=d.textContent.length,R=Math.min(_.start,T);_=_.end===void 0?R:Math.min(_.end,T),!s.extend&&R>_&&(T=_,_=R,R=T),T=lr(d,R);var N=lr(d,_);T&&N&&(s.rangeCount!==1||s.anchorNode!==T.node||s.anchorOffset!==T.offset||s.focusNode!==N.node||s.focusOffset!==N.offset)&&(l=l.createRange(),l.setStart(T.node,T.offset),s.removeAllRanges(),R>_?(s.addRange(l),s.extend(N.node,N.offset)):(l.setEnd(N.node,N.offset),s.addRange(l)))}}for(l=[],s=d;s=s.parentNode;)s.nodeType===1&&l.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d=document.documentMode,ds=null,Wo=null,Nl=null,oi=!1;function Tc(s,l,d){var _=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;oi||ds==null||ds!==Ne(_)||(_=ds,"selectionStart"in _&&ri(_)?_={start:_.selectionStart,end:_.selectionEnd}:(_=(_.ownerDocument&&_.ownerDocument.defaultView||window).getSelection(),_={anchorNode:_.anchorNode,anchorOffset:_.anchorOffset,focusNode:_.focusNode,focusOffset:_.focusOffset}),Nl&&Ho(Nl,_)||(Nl=_,_=Lc(Wo,"onSelect"),0<_.length&&(l=new Il("onSelect","select",null,l,d),s.push({event:l,listeners:_}),l.target=ds)))}function Va(s,l){var d={};return d[s.toLowerCase()]=l.toLowerCase(),d["Webkit"+s]="webkit"+l,d["Moz"+s]="moz"+l,d}var co={animationend:Va("Animation","AnimationEnd"),animationiteration:Va("Animation","AnimationIteration"),animationstart:Va("Animation","AnimationStart"),transitionend:Va("Transition","TransitionEnd")},Yr={},qr={};u&&(qr=document.createElement("div").style,"AnimationEvent"in window||(delete co.animationend.animation,delete co.animationiteration.animation,delete co.animationstart.animation),"TransitionEvent"in window||delete co.transitionend.transition);function ps(s){if(Yr[s])return Yr[s];if(!co[s])return s;var l=co[s],d;for(d in l)if(l.hasOwnProperty(d)&&d in qr)return Yr[s]=l[d];return s}var Ul=ps("animationend"),Fl=ps("animationiteration"),dh=ps("animationstart"),ph=ps("transitionend"),mh=new Map,gh="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Is(s,l){mh.set(s,l),o(l,[s])}for(var Ac=0;Acai||(s.current=wh[ai],wh[ai]=null,ai--)}function Sn(s,l){ai++,wh[ai]=s.current,s.current=l}var Ns={},hi=Fn(Ns),Oi=Fn(!1),Us=Ns;function qo(s,l){var d=s.type.contextTypes;if(!d)return Ns;var _=s.stateNode;if(_&&_.__reactInternalMemoizedUnmaskedChildContext===l)return _.__reactInternalMemoizedMaskedChildContext;var T={},R;for(R in d)T[R]=l[R];return _&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=l,s.__reactInternalMemoizedMaskedChildContext=T),T}function Ei(s){return s=s.childContextTypes,s!=null}function Hl(){wn(Oi),wn(hi)}function Eh(s,l,d){if(hi.current!==Ns)throw Error(t(168));Sn(hi,l),Sn(Oi,d)}function Gl(s,l,d){var _=s.stateNode;if(l=l.childContextTypes,typeof _.getChildContext!="function")return d;_=_.getChildContext();for(var T in _)if(!(T in l))throw Error(t(108,Te(s)||"Unknown",T));return K({},d,_)}function Zo(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Ns,Us=hi.current,Sn(hi,s),Sn(Oi,Oi.current),!0}function Th(s,l,d){var _=s.stateNode;if(!_)throw Error(t(169));d?(s=Gl(s,l,Us),_.__reactInternalMemoizedMergedChildContext=s,wn(Oi),wn(hi),Sn(hi,s)):wn(Oi),Sn(Oi,d)}var Zr=null,Wl=!1,kc=!1;function Xl(s){Zr===null?Zr=[s]:Zr.push(s)}function Lp(s){Wl=!0,Xl(s)}function ms(){if(!kc&&Zr!==null){kc=!0;var s=0,l=qt;try{var d=Zr;for(qt=1;s>=N,T-=N,Xe=1<<32-Jt(l)+T|d<Bt?(Ri=bt,bt=null):Ri=bt.sibling;var mn=Ue(ce,bt,de[Bt],He);if(mn===null){bt===null&&(bt=Ri);break}s&&bt&&mn.alternate===null&&l(ce,bt),te=R(mn,te,Bt),Rt===null?Mt=mn:Rt.sibling=mn,Rt=mn,bt=Ri}if(Bt===de.length)return d(ce,bt),Rn&&Fs(ce,Bt),Mt;if(bt===null){for(;BtBt?(Ri=bt,bt=null):Ri=bt.sibling;var ol=Ue(ce,bt,mn.value,He);if(ol===null){bt===null&&(bt=Ri);break}s&&bt&&ol.alternate===null&&l(ce,bt),te=R(ol,te,Bt),Rt===null?Mt=ol:Rt.sibling=ol,Rt=ol,bt=Ri}if(mn.done)return d(ce,bt),Rn&&Fs(ce,Bt),Mt;if(bt===null){for(;!mn.done;Bt++,mn=de.next())mn=ze(ce,mn.value,He),mn!==null&&(te=R(mn,te,Bt),Rt===null?Mt=mn:Rt.sibling=mn,Rt=mn);return Rn&&Fs(ce,Bt),Mt}for(bt=_(ce,bt);!mn.done;Bt++,mn=de.next())mn=at(bt,ce,Bt,mn.value,He),mn!==null&&(s&&mn.alternate!==null&&bt.delete(mn.key===null?Bt:mn.key),te=R(mn,te,Bt),Rt===null?Mt=mn:Rt.sibling=mn,Rt=mn);return s&&bt.forEach(function(dR){return l(ce,dR)}),Rn&&Fs(ce,Bt),Mt}function ti(ce,te,de,He){if(typeof de=="object"&&de!==null&&de.type===V&&de.key===null&&(de=de.props.children),typeof de=="object"&&de!==null){switch(de.$$typeof){case B:e:{for(var Mt=de.key,Rt=te;Rt!==null;){if(Rt.key===Mt){if(Mt=de.type,Mt===V){if(Rt.tag===7){d(ce,Rt.sibling),te=T(Rt,de.props.children),te.return=ce,ce=te;break e}}else if(Rt.elementType===Mt||typeof Mt=="object"&&Mt!==null&&Mt.$$typeof===ue&&Ih(Mt)===Rt.type){d(ce,Rt.sibling),te=T(Rt,de.props),te.ref=jl(ce,Rt,de),te.return=ce,ce=te;break e}d(ce,Rt);break}else l(ce,Rt);Rt=Rt.sibling}de.type===V?(te=cu(de.props.children,ce.mode,He,de.key),te.return=ce,ce=te):(He=tm(de.type,de.key,de.props,null,ce.mode,He),He.ref=jl(ce,te,de),He.return=ce,ce=He)}return N(ce);case F:e:{for(Rt=de.key;te!==null;){if(te.key===Rt)if(te.tag===4&&te.stateNode.containerInfo===de.containerInfo&&te.stateNode.implementation===de.implementation){d(ce,te.sibling),te=T(te,de.children||[]),te.return=ce,ce=te;break e}else{d(ce,te);break}else l(ce,te);te=te.sibling}te=mv(de,ce.mode,He),te.return=ce,ce=te}return N(ce);case ue:return Rt=de._init,ti(ce,te,Rt(de._payload),He)}if(je(de))return gt(ce,te,de,He);if(J(de))return _t(ce,te,de,He);Yl(ce,de)}return typeof de=="string"&&de!==""||typeof de=="number"?(de=""+de,te!==null&&te.tag===6?(d(ce,te.sibling),te=T(te,de),te.return=ce,ce=te):(d(ce,te),te=pv(de,ce.mode,He),te.return=ce,ce=te),N(ce)):d(ce,te)}return ti}var Qo=Lh(!0),ql=Lh(!1),$o=Fn(null),ea=null,ks=null,Za=null;function ta(){Za=ks=ea=null}function Zl(s){var l=$o.current;wn($o),s._currentValue=l}function Kl(s,l,d){for(;s!==null;){var _=s.alternate;if((s.childLanes&l)!==l?(s.childLanes|=l,_!==null&&(_.childLanes|=l)):_!==null&&(_.childLanes&l)!==l&&(_.childLanes|=l),s===d)break;s=s.return}}function mo(s,l){ea=s,Za=ks=null,s=s.dependencies,s!==null&&s.firstContext!==null&&(s.lanes&l&&(Zt=!0),s.firstContext=null)}function cr(s){var l=s._currentValue;if(Za!==s)if(s={context:s,memoizedValue:l,next:null},ks===null){if(ea===null)throw Error(t(308));ks=s,ea.dependencies={lanes:0,firstContext:s}}else ks=ks.next=s;return l}var Bs=null;function Dh(s){Bs===null?Bs=[s]:Bs.push(s)}function Jl(s,l,d,_){var T=l.interleaved;return T===null?(d.next=d,Dh(l)):(d.next=T.next,T.next=d),l.interleaved=d,Kr(s,_)}function Kr(s,l){s.lanes|=l;var d=s.alternate;for(d!==null&&(d.lanes|=l),d=s,s=s.return;s!==null;)s.childLanes|=l,d=s.alternate,d!==null&&(d.childLanes|=l),d=s,s=s.return;return d.tag===3?d.stateNode:null}var vn=!1;function Xt(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Vn(s,l){s=s.updateQueue,l.updateQueue===s&&(l.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function yn(s,l){return{eventTime:s,lane:l,tag:0,payload:null,callback:null,next:null}}function In(s,l,d){var _=s.updateQueue;if(_===null)return null;if(_=_.shared,cn&2){var T=_.pending;return T===null?l.next=l:(l.next=T.next,T.next=l),_.pending=l,Kr(s,d)}return T=_.interleaved,T===null?(l.next=l,Dh(_)):(l.next=T.next,T.next=l),_.interleaved=l,Kr(s,d)}function Ti(s,l,d){if(l=l.updateQueue,l!==null&&(l=l.shared,(d&4194240)!==0)){var _=l.lanes;_&=s.pendingLanes,d|=_,l.lanes=d,cs(s,d)}}function na(s,l){var d=s.updateQueue,_=s.alternate;if(_!==null&&(_=_.updateQueue,d===_)){var T=null,R=null;if(d=d.firstBaseUpdate,d!==null){do{var N={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};R===null?T=R=N:R=R.next=N,d=d.next}while(d!==null);R===null?T=R=l:R=R.next=l}else T=R=l;d={baseState:_.baseState,firstBaseUpdate:T,lastBaseUpdate:R,shared:_.shared,effects:_.effects},s.updateQueue=d;return}s=d.lastBaseUpdate,s===null?d.firstBaseUpdate=l:s.next=l,d.lastBaseUpdate=l}function On(s,l,d,_){var T=s.updateQueue;vn=!1;var R=T.firstBaseUpdate,N=T.lastBaseUpdate,Z=T.shared.pending;if(Z!==null){T.shared.pending=null;var Q=Z,ge=Q.next;Q.next=null,N===null?R=ge:N.next=ge,N=Q;var Fe=s.alternate;Fe!==null&&(Fe=Fe.updateQueue,Z=Fe.lastBaseUpdate,Z!==N&&(Z===null?Fe.firstBaseUpdate=ge:Z.next=ge,Fe.lastBaseUpdate=Q))}if(R!==null){var ze=T.baseState;N=0,Fe=ge=Q=null,Z=R;do{var Ue=Z.lane,at=Z.eventTime;if((_&Ue)===Ue){Fe!==null&&(Fe=Fe.next={eventTime:at,lane:0,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null});e:{var gt=s,_t=Z;switch(Ue=l,at=d,_t.tag){case 1:if(gt=_t.payload,typeof gt=="function"){ze=gt.call(at,ze,Ue);break e}ze=gt;break e;case 3:gt.flags=gt.flags&-65537|128;case 0:if(gt=_t.payload,Ue=typeof gt=="function"?gt.call(at,ze,Ue):gt,Ue==null)break e;ze=K({},ze,Ue);break e;case 2:vn=!0}}Z.callback!==null&&Z.lane!==0&&(s.flags|=64,Ue=T.effects,Ue===null?T.effects=[Z]:Ue.push(Z))}else at={eventTime:at,lane:Ue,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null},Fe===null?(ge=Fe=at,Q=ze):Fe=Fe.next=at,N|=Ue;if(Z=Z.next,Z===null){if(Z=T.shared.pending,Z===null)break;Ue=Z,Z=Ue.next,Ue.next=null,T.lastBaseUpdate=Ue,T.shared.pending=null}}while(!0);if(Fe===null&&(Q=ze),T.baseState=Q,T.firstBaseUpdate=ge,T.lastBaseUpdate=Fe,l=T.shared.interleaved,l!==null){T=l;do N|=T.lane,T=T.next;while(T!==l)}else R===null&&(T.shared.lanes=0);ou|=N,s.lanes=N,s.memoizedState=ze}}function Ka(s,l,d){if(s=l.effects,l.effects=null,s!==null)for(l=0;ld?d:4,s(!0);var _=oa.transition;oa.transition={};try{s(!1),l()}finally{qt=d,oa.transition=_}}function Gs(){return hr().memoizedState}function Yc(s,l,d){var _=il(s);if(d={lane:_,action:d,hasEagerState:!1,eagerState:null,next:null},ru(s))qc(l,d);else if(d=Jl(s,l,d,_),d!==null){var T=mr();Ys(d,s,_,T),Zc(d,l,_)}}function aa(s,l,d){var _=il(s),T={lane:_,action:d,hasEagerState:!1,eagerState:null,next:null};if(ru(s))qc(l,T);else{var R=s.alternate;if(s.lanes===0&&(R===null||R.lanes===0)&&(R=l.lastRenderedReducer,R!==null))try{var N=l.lastRenderedState,Z=R(N,d);if(T.hasEagerState=!0,T.eagerState=Z,ar(Z,N)){var Q=l.interleaved;Q===null?(T.next=T,Dh(l)):(T.next=Q.next,Q.next=T),l.interleaved=T;return}}catch{}finally{}d=Jl(s,l,T,_),d!==null&&(T=mr(),Ys(d,s,_,T),Zc(d,l,_))}}function ru(s){var l=s.alternate;return s===En||l!==null&&l===En}function qc(s,l){Ai=Qr=!0;var d=s.pending;d===null?l.next=l:(l.next=d.next,d.next=l),s.pending=l}function Zc(s,l,d){if(d&4194240){var _=l.lanes;_&=s.pendingLanes,d|=_,l.lanes=d,cs(s,d)}}var Kc={readContext:cr,useCallback:pi,useContext:pi,useEffect:pi,useImperativeHandle:pi,useInsertionEffect:pi,useLayoutEffect:pi,useMemo:pi,useReducer:pi,useRef:pi,useState:pi,useDebugValue:pi,useDeferredValue:pi,useTransition:pi,useMutableSource:pi,useSyncExternalStore:pi,useId:pi,unstable_isNewReconciler:!1},Bp={readContext:cr,useCallback:function(s,l){return mi().memoizedState=[s,l===void 0?null:l],s},useContext:cr,useEffect:zi,useImperativeHandle:function(s,l,d){return d=d!=null?d.concat([s]):null,ys(4194308,4,Op.bind(null,l,s),d)},useLayoutEffect:function(s,l){return ys(4194308,4,s,l)},useInsertionEffect:function(s,l){return ys(4,2,s,l)},useMemo:function(s,l){var d=mi();return l=l===void 0?null:l,s=s(),d.memoizedState=[s,l],s},useReducer:function(s,l,d){var _=mi();return l=d!==void 0?d(l):l,_.memoizedState=_.baseState=l,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:l},_.queue=s,s=s.dispatch=Yc.bind(null,En,s),[_.memoizedState,s]},useRef:function(s){var l=mi();return s={current:s},l.memoizedState=s},useState:kh,useDebugValue:Xc,useDeferredValue:function(s){return mi().memoizedState=s},useTransition:function(){var s=kh(!1),l=s[0];return s=K0.bind(null,s[1]),mi().memoizedState=s,[l,s]},useMutableSource:function(){},useSyncExternalStore:function(s,l,d){var _=En,T=mi();if(Rn){if(d===void 0)throw Error(t(407));d=d()}else{if(d=l(),Ci===null)throw Error(t(349));Vs&30||Wc(_,l,d)}T.memoizedState=d;var R={value:d,getSnapshot:l};return T.queue=R,zi(Dp.bind(null,_,R,s),[s]),_.flags|=2048,$r(9,nu.bind(null,_,R,d,l),void 0,null),d},useId:function(){var s=mi(),l=Ci.identifierPrefix;if(Rn){var d=Pr,_=Xe;d=(_&~(1<<32-Jt(_)-1)).toString(32)+d,l=":"+l+"R"+d,d=vo++,0<\/script>",s=s.removeChild(s.firstChild)):typeof _.is=="string"?s=N.createElement(d,{is:_.is}):(s=N.createElement(d),d==="select"&&(N=s,_.multiple?N.multiple=!0:_.size&&(N.size=_.size))):s=N.createElementNS(s,d),s[ei]=l,s[ja]=_,Qx(s,l,!1,!1),l.stateNode=s;e:{switch(N=Ot(d,_),d){case"dialog":Mn("cancel",s),Mn("close",s),T=_;break;case"iframe":case"object":case"embed":Mn("load",s),T=_;break;case"video":case"audio":for(T=0;Tef&&(l.flags|=128,_=!0,Gh(R,!1),l.lanes=4194304)}else{if(!_)if(s=Jr(N),s!==null){if(l.flags|=128,_=!0,d=s.updateQueue,d!==null&&(l.updateQueue=d,l.flags|=4),Gh(R,!0),R.tail===null&&R.tailMode==="hidden"&&!N.alternate&&!Rn)return Ji(l),null}else 2*$()-R.renderingStartTime>ef&&d!==1073741824&&(l.flags|=128,_=!0,Gh(R,!1),l.lanes=4194304);R.isBackwards?(N.sibling=l.child,l.child=N):(d=R.last,d!==null?d.sibling=N:l.child=N,R.last=N)}return R.tail!==null?(l=R.tail,R.rendering=l,R.tail=l.sibling,R.renderingStartTime=$(),l.sibling=null,d=bn.current,Sn(bn,_?d&1|2:d&1),l):(Ji(l),null);case 22:case 23:return fv(),_=l.memoizedState!==null,s!==null&&s.memoizedState!==null!==_&&(l.flags|=8192),_&&l.mode&1?es&1073741824&&(Ji(l),l.subtreeFlags&6&&(l.flags|=8192)):Ji(l),null;case 24:return null;case 25:return null}throw Error(t(156,l.tag))}function YC(s,l){switch(Os(l),l.tag){case 1:return Ei(l.type)&&Hl(),s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 3:return go(),wn(Oi),wn(hi),vs(),s=l.flags,s&65536&&!(s&128)?(l.flags=s&-65537|128,l):null;case 5:return Ja(l),null;case 13:if(wn(bn),s=l.memoizedState,s!==null&&s.dehydrated!==null){if(l.alternate===null)throw Error(t(340));po()}return s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 19:return wn(bn),null;case 4:return go(),null;case 10:return Zl(l.type._context),null;case 22:case 23:return fv(),null;case 24:return null;default:return null}}var Xp=!1,Qi=!1,qC=typeof WeakSet=="function"?WeakSet:Set,pt=null;function Qc(s,l){var d=s.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(_){Zn(s,l,_)}else d.current=null}function $0(s,l,d){try{d()}catch(_){Zn(s,l,_)}}var tS=!1;function ZC(s,l){if(Xa=Er,s=Dn(),ri(s)){if("selectionStart"in s)var d={start:s.selectionStart,end:s.selectionEnd};else e:{d=(d=s.ownerDocument)&&d.defaultView||window;var _=d.getSelection&&d.getSelection();if(_&&_.rangeCount!==0){d=_.anchorNode;var T=_.anchorOffset,R=_.focusNode;_=_.focusOffset;try{d.nodeType,R.nodeType}catch{d=null;break e}var N=0,Z=-1,Q=-1,ge=0,Fe=0,ze=s,Ue=null;t:for(;;){for(var at;ze!==d||T!==0&&ze.nodeType!==3||(Z=N+T),ze!==R||_!==0&&ze.nodeType!==3||(Q=N+_),ze.nodeType===3&&(N+=ze.nodeValue.length),(at=ze.firstChild)!==null;)Ue=ze,ze=at;for(;;){if(ze===s)break t;if(Ue===d&&++ge===T&&(Z=N),Ue===R&&++Fe===_&&(Q=N),(at=ze.nextSibling)!==null)break;ze=Ue,Ue=ze.parentNode}ze=at}d=Z===-1||Q===-1?null:{start:Z,end:Q}}else d=null}d=d||{start:0,end:0}}else d=null;for(yh={focusedElem:s,selectionRange:d},Er=!1,pt=l;pt!==null;)if(l=pt,s=l.child,(l.subtreeFlags&1028)!==0&&s!==null)s.return=l,pt=s;else for(;pt!==null;){l=pt;try{var gt=l.alternate;if(l.flags&1024)switch(l.tag){case 0:case 11:case 15:break;case 1:if(gt!==null){var _t=gt.memoizedProps,ti=gt.memoizedState,ce=l.stateNode,te=ce.getSnapshotBeforeUpdate(l.elementType===l.type?_t:Lr(l.type,_t),ti);ce.__reactInternalSnapshotBeforeUpdate=te}break;case 3:var de=l.stateNode.containerInfo;de.nodeType===1?de.textContent="":de.nodeType===9&&de.documentElement&&de.removeChild(de.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(He){Zn(l,l.return,He)}if(s=l.sibling,s!==null){s.return=l.return,pt=s;break}pt=l.return}return gt=tS,tS=!1,gt}function Wh(s,l,d){var _=l.updateQueue;if(_=_!==null?_.lastEffect:null,_!==null){var T=_=_.next;do{if((T.tag&s)===s){var R=T.destroy;T.destroy=void 0,R!==void 0&&$0(l,d,R)}T=T.next}while(T!==_)}}function jp(s,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&s)===s){var _=d.create;d.destroy=_()}d=d.next}while(d!==l)}}function ev(s){var l=s.ref;if(l!==null){var d=s.stateNode;switch(s.tag){case 5:s=d;break;default:s=d}typeof l=="function"?l(s):l.current=s}}function nS(s){var l=s.alternate;l!==null&&(s.alternate=null,nS(l)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(l=s.stateNode,l!==null&&(delete l[ei],delete l[ja],delete l[Yo],delete l[Uc],delete l[Fc])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function iS(s){return s.tag===5||s.tag===3||s.tag===4}function rS(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||iS(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function tv(s,l,d){var _=s.tag;if(_===5||_===6)s=s.stateNode,l?d.nodeType===8?d.parentNode.insertBefore(s,l):d.insertBefore(s,l):(d.nodeType===8?(l=d.parentNode,l.insertBefore(s,d)):(l=d,l.appendChild(s)),d=d._reactRootContainer,d!=null||l.onclick!==null||(l.onclick=Vl));else if(_!==4&&(s=s.child,s!==null))for(tv(s,l,d),s=s.sibling;s!==null;)tv(s,l,d),s=s.sibling}function nv(s,l,d){var _=s.tag;if(_===5||_===6)s=s.stateNode,l?d.insertBefore(s,l):d.appendChild(s);else if(_!==4&&(s=s.child,s!==null))for(nv(s,l,d),s=s.sibling;s!==null;)nv(s,l,d),s=s.sibling}var Vi=null,Xs=!1;function el(s,l,d){for(d=d.child;d!==null;)sS(s,l,d),d=d.sibling}function sS(s,l,d){if(ot&&typeof ot.onCommitFiberUnmount=="function")try{ot.onCommitFiberUnmount(dt,d)}catch{}switch(d.tag){case 5:Qi||Qc(d,l);case 6:var _=Vi,T=Xs;Vi=null,el(s,l,d),Vi=_,Xs=T,Vi!==null&&(Xs?(s=Vi,d=d.stateNode,s.nodeType===8?s.parentNode.removeChild(d):s.removeChild(d)):Vi.removeChild(d.stateNode));break;case 18:Vi!==null&&(Xs?(s=Vi,d=d.stateNode,s.nodeType===8?Nc(s.parentNode,d):s.nodeType===1&&Nc(s,d),bl(s)):Nc(Vi,d.stateNode));break;case 4:_=Vi,T=Xs,Vi=d.stateNode.containerInfo,Xs=!0,el(s,l,d),Vi=_,Xs=T;break;case 0:case 11:case 14:case 15:if(!Qi&&(_=d.updateQueue,_!==null&&(_=_.lastEffect,_!==null))){T=_=_.next;do{var R=T,N=R.destroy;R=R.tag,N!==void 0&&(R&2||R&4)&&$0(d,l,N),T=T.next}while(T!==_)}el(s,l,d);break;case 1:if(!Qi&&(Qc(d,l),_=d.stateNode,typeof _.componentWillUnmount=="function"))try{_.props=d.memoizedProps,_.state=d.memoizedState,_.componentWillUnmount()}catch(Z){Zn(d,l,Z)}el(s,l,d);break;case 21:el(s,l,d);break;case 22:d.mode&1?(Qi=(_=Qi)||d.memoizedState!==null,el(s,l,d),Qi=_):el(s,l,d);break;default:el(s,l,d)}}function oS(s){var l=s.updateQueue;if(l!==null){s.updateQueue=null;var d=s.stateNode;d===null&&(d=s.stateNode=new qC),l.forEach(function(_){var T=rR.bind(null,s,_);d.has(_)||(d.add(_),_.then(T,T))})}}function js(s,l){var d=l.deletions;if(d!==null)for(var _=0;_T&&(T=N),_&=~R}if(_=T,_=$()-_,_=(120>_?120:480>_?480:1080>_?1080:1920>_?1920:3e3>_?3e3:4320>_?4320:1960*JC(_/1960))-_,10<_){s.timeoutHandle=xh(uu.bind(null,s,Dr,ua),_);break}uu(s,Dr,ua);break;case 5:uu(s,Dr,ua);break;default:throw Error(t(329))}}}return Nr(s,$()),s.callbackNode===d?hS.bind(null,s):null}function lv(s,l){var d=jh;return s.current.memoizedState.isDehydrated&&(lu(s,l).flags|=256),s=em(s,l),s!==2&&(l=Dr,Dr=d,l!==null&&uv(l)),s}function uv(s){Dr===null?Dr=s:Dr.push.apply(Dr,s)}function QC(s){for(var l=s;;){if(l.flags&16384){var d=l.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var _=0;_s?16:s,nl===null)var _=!1;else{if(s=nl,nl=null,Jp=0,cn&6)throw Error(t(331));var T=cn;for(cn|=4,pt=s.current;pt!==null;){var R=pt,N=R.child;if(pt.flags&16){var Z=R.deletions;if(Z!==null){for(var Q=0;Q$()-sv?lu(s,0):rv|=d),Nr(s,l)}function _S(s,l){l===0&&(s.mode&1?(l=Dt,Dt<<=1,!(Dt&130023424)&&(Dt=4194304)):l=1);var d=mr();s=Kr(s,l),s!==null&&(Bn(s,l,d),Nr(s,d))}function iR(s){var l=s.memoizedState,d=0;l!==null&&(d=l.retryLane),_S(s,d)}function rR(s,l){var d=0;switch(s.tag){case 13:var _=s.stateNode,T=s.memoizedState;T!==null&&(d=T.retryLane);break;case 19:_=s.stateNode;break;default:throw Error(t(314))}_!==null&&_.delete(l),_S(s,d)}var xS;xS=function(s,l,d){if(s!==null)if(s.memoizedProps!==l.pendingProps||Oi.current)Zt=!0;else{if(!(s.lanes&d)&&!(l.flags&128))return Zt=!1,XC(s,l,d);Zt=!!(s.flags&131072)}else Zt=!1,Rn&&l.flags&1048576&&Ah(l,zc,l.index);switch(l.lanes=0,l.tag){case 2:var _=l.type;Wp(s,l),s=l.pendingProps;var T=qo(l,hi.current);mo(l,d),T=eu(null,l,_,s,T,d);var R=Nh();return l.flags|=1,typeof T=="object"&&T!==null&&typeof T.render=="function"&&T.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,Ei(_)?(R=!0,Zo(l)):R=!1,l.memoizedState=T.state!==null&&T.state!==void 0?T.state:null,Xt(l),T.updater=Jc,l.stateNode=T,T._reactInternals=l,y(l,_,s,d),l=Gt(null,l,_,!0,R,d)):(l.tag=0,Rn&&R&&Ch(l),nt(null,l,T,d),l=l.child),l;case 16:_=l.elementType;e:{switch(Wp(s,l),s=l.pendingProps,T=_._init,_=T(_._payload),l.type=_,T=l.tag=oR(_),s=Lr(_,s),T){case 0:l=Je(null,l,_,s,d);break e;case 1:l=St(null,l,_,s,d);break e;case 11:l=gi(null,l,_,s,d);break e;case 14:l=pr(null,l,_,Lr(_.type,s),d);break e}throw Error(t(306,_,""))}return l;case 0:return _=l.type,T=l.pendingProps,T=l.elementType===_?T:Lr(_,T),Je(s,l,_,T,d);case 1:return _=l.type,T=l.pendingProps,T=l.elementType===_?T:Lr(_,T),St(s,l,_,T,d);case 3:e:{if(Vt(l),s===null)throw Error(t(387));_=l.pendingProps,R=l.memoizedState,T=R.element,Vn(s,l),On(l,_,null,d);var N=l.memoizedState;if(_=N.element,R.isDehydrated)if(R={element:_,isDehydrated:!1,cache:N.cache,pendingSuspenseBoundaries:N.pendingSuspenseBoundaries,transitions:N.transitions},l.updateQueue.baseState=R,l.memoizedState=R,l.flags&256){T=M(Error(t(423)),l),l=an(s,l,_,d,T);break e}else if(_!==T){T=M(Error(t(424)),l),l=an(s,l,_,d,T);break e}else for(Bi=Ls(l.stateNode.containerInfo.firstChild),di=l,Rn=!0,Ir=null,d=ql(l,null,_,d),l.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(po(),_===T){l=la(s,l,d);break e}nt(s,l,_,d)}l=l.child}return l;case 5:return ra(l),s===null&&Hc(l),_=l.type,T=l.pendingProps,R=s!==null?s.memoizedProps:null,N=T.children,_h(_,T)?N=null:R!==null&&_h(_,R)&&(l.flags|=32),_e(s,l),nt(s,l,N,d),l.child;case 6:return s===null&&Hc(l),null;case 13:return Ws(s,l,d);case 4:return Ql(l,l.stateNode.containerInfo),_=l.pendingProps,s===null?l.child=Qo(l,null,_,d):nt(s,l,_,d),l.child;case 11:return _=l.type,T=l.pendingProps,T=l.elementType===_?T:Lr(_,T),gi(s,l,_,T,d);case 7:return nt(s,l,l.pendingProps,d),l.child;case 8:return nt(s,l,l.pendingProps.children,d),l.child;case 12:return nt(s,l,l.pendingProps.children,d),l.child;case 10:e:{if(_=l.type._context,T=l.pendingProps,R=l.memoizedProps,N=T.value,Sn($o,_._currentValue),_._currentValue=N,R!==null)if(ar(R.value,N)){if(R.children===T.children&&!Oi.current){l=la(s,l,d);break e}}else for(R=l.child,R!==null&&(R.return=l);R!==null;){var Z=R.dependencies;if(Z!==null){N=R.child;for(var Q=Z.firstContext;Q!==null;){if(Q.context===_){if(R.tag===1){Q=yn(-1,d&-d),Q.tag=2;var ge=R.updateQueue;if(ge!==null){ge=ge.shared;var Fe=ge.pending;Fe===null?Q.next=Q:(Q.next=Fe.next,Fe.next=Q),ge.pending=Q}}R.lanes|=d,Q=R.alternate,Q!==null&&(Q.lanes|=d),Kl(R.return,d,l),Z.lanes|=d;break}Q=Q.next}}else if(R.tag===10)N=R.type===l.type?null:R.child;else if(R.tag===18){if(N=R.return,N===null)throw Error(t(341));N.lanes|=d,Z=N.alternate,Z!==null&&(Z.lanes|=d),Kl(N,d,l),N=R.sibling}else N=R.child;if(N!==null)N.return=R;else for(N=R;N!==null;){if(N===l){N=null;break}if(R=N.sibling,R!==null){R.return=N.return,N=R;break}N=N.return}R=N}nt(s,l,T.children,d),l=l.child}return l;case 9:return T=l.type,_=l.pendingProps.children,mo(l,d),T=cr(T),_=_(T),l.flags|=1,nt(s,l,_,d),l.child;case 14:return _=l.type,T=Lr(_,l.pendingProps),T=Lr(_.type,T),pr(s,l,_,T,d);case 15:return pe(s,l,l.type,l.pendingProps,d);case 17:return _=l.type,T=l.pendingProps,T=l.elementType===_?T:Lr(_,T),Wp(s,l),l.tag=1,Ei(_)?(s=!0,Zo(l)):s=!1,mo(l,d),c(l,_,T),y(l,_,T,d),Gt(null,l,_,!0,s,d);case 19:return Jx(s,l,d);case 22:return ae(s,l,d)}throw Error(t(156,l.tag))};function SS(s,l){return z(s,l)}function sR(s,l,d,_){this.tag=s,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,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 xs(s,l,d,_){return new sR(s,l,d,_)}function dv(s){return s=s.prototype,!(!s||!s.isReactComponent)}function oR(s){if(typeof s=="function")return dv(s)?1:0;if(s!=null){if(s=s.$$typeof,s===se)return 11;if(s===Me)return 14}return 2}function sl(s,l){var d=s.alternate;return d===null?(d=xs(s.tag,l,s.key,s.mode),d.elementType=s.elementType,d.type=s.type,d.stateNode=s.stateNode,d.alternate=s,s.alternate=d):(d.pendingProps=l,d.type=s.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=s.flags&14680064,d.childLanes=s.childLanes,d.lanes=s.lanes,d.child=s.child,d.memoizedProps=s.memoizedProps,d.memoizedState=s.memoizedState,d.updateQueue=s.updateQueue,l=s.dependencies,d.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},d.sibling=s.sibling,d.index=s.index,d.ref=s.ref,d}function tm(s,l,d,_,T,R){var N=2;if(_=s,typeof s=="function")dv(s)&&(N=1);else if(typeof s=="string")N=5;else e:switch(s){case V:return cu(d.children,T,R,l);case H:N=8,T|=8;break;case U:return s=xs(12,d,l,T|2),s.elementType=U,s.lanes=R,s;case ie:return s=xs(13,d,l,T),s.elementType=ie,s.lanes=R,s;case fe:return s=xs(19,d,l,T),s.elementType=fe,s.lanes=R,s;case ye:return nm(d,T,R,l);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case D:N=10;break e;case W:N=9;break e;case se:N=11;break e;case Me:N=14;break e;case ue:N=16,_=null;break e}throw Error(t(130,s==null?s:typeof s,""))}return l=xs(N,d,l,T),l.elementType=s,l.type=_,l.lanes=R,l}function cu(s,l,d,_){return s=xs(7,s,_,l),s.lanes=d,s}function nm(s,l,d,_){return s=xs(22,s,_,l),s.elementType=ye,s.lanes=d,s.stateNode={isHidden:!1},s}function pv(s,l,d){return s=xs(6,s,null,l),s.lanes=d,s}function mv(s,l,d){return l=xs(4,s.children!==null?s.children:[],s.key,l),l.lanes=d,l.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},l}function aR(s,l,d,_,T){this.tag=l,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mi(0),this.expirationTimes=Mi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mi(0),this.identifierPrefix=_,this.onRecoverableError=T,this.mutableSourceEagerHydrationData=null}function gv(s,l,d,_,T,R,N,Z,Q){return s=new aR(s,l,d,Z,Q),l===1?(l=1,R===!0&&(l|=8)):l=0,R=xs(3,null,null,l),s.current=R,R.stateNode=s,R.memoizedState={element:_,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xt(R),s}function lR(s,l,d){var _=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Mv.exports=_R(),Mv.exports}var US;function SR(){if(US)return um;US=1;var i=xR();return um.createRoot=i.createRoot,um.hydrateRoot=i.hydrateRoot,um}var MR=SR();/** * @license * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT */const l0="171",wR={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ER={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},nE=0,Gy=1,iE=2,TR=3,rE=0,u0=1,gd=2,Qs=3,Ma=0,_r=1,_o=2,Mo=0,Uu=1,hg=2,Wy=3,Xy=4,sE=5,vl=100,oE=101,aE=102,lE=103,uE=104,cE=200,fE=201,hE=202,dE=203,dg=204,pg=205,pE=206,mE=207,gE=208,vE=209,yE=210,_E=211,xE=212,SE=213,ME=214,mg=0,gg=1,vg=2,Vu=3,yg=4,_g=5,xg=6,Sg=7,$d=0,wE=1,EE=2,wo=0,w_=1,E_=2,T_=3,c0=4,TE=5,A_=6,C_=7,jy="attached",AE="detached",f0=300,wa=301,yl=302,Pd=303,Id=304,Yf=306,Ld=1e3,Es=1001,Dd=1002,Wi=1003,R_=1004,AR=1004,Af=1005,CR=1005,yi=1006,vd=1007,RR=1007,xo=1008,bR=1008,eo=1009,b_=1010,P_=1011,kf=1012,h0=1013,Ea=1014,zr=1015,Eo=1016,d0=1017,p0=1018,Hu=1020,I_=35902,L_=1021,D_=1022,ir=1023,N_=1024,U_=1025,Fu=1026,Gu=1027,m0=1028,ep=1029,F_=1030,g0=1031,PR=1032,v0=1033,yd=33776,_d=33777,xd=33778,Sd=33779,Mg=35840,wg=35841,Eg=35842,Tg=35843,Ag=36196,Cg=37492,Rg=37496,bg=37808,Pg=37809,Ig=37810,Lg=37811,Dg=37812,Ng=37813,Ug=37814,Fg=37815,Og=37816,kg=37817,Bg=37818,zg=37819,Vg=37820,Hg=37821,Md=36492,Gg=36494,Wg=36495,O_=36283,Xg=36284,jg=36285,Yg=36286,CE=2200,RE=2201,bE=2202,Nd=2300,qg=2301,og=2302,Pu=2400,Iu=2401,Ud=2402,y0=2500,k_=2501,IR=0,LR=1,DR=2,PE=3200,IE=3201,NR=3202,UR=3203,Ml=0,LE=1,ga="",kr="srgb",Wu="srgb-linear",Fd="linear",_n="srgb",FR=0,Tu=7680,OR=7681,kR=7682,BR=7683,zR=34055,VR=34056,HR=5386,GR=512,WR=513,XR=514,jR=515,YR=516,qR=517,ZR=518,Yy=519,DE=512,NE=513,UE=514,B_=515,FE=516,OE=517,kE=518,BE=519,Od=35044,KR=35048,JR=35040,QR=35045,$R=35049,eb=35041,tb=35046,nb=35050,ib=35042,rb="100",qy="300 es",So=2e3,kd=2001;class bo{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let o=0,a=r.length;o>8&255]+$i[i>>16&255]+$i[i>>24&255]+"-"+$i[e&255]+$i[e>>8&255]+"-"+$i[e>>16&15|64]+$i[e>>24&255]+"-"+$i[t&63|128]+$i[t>>8&255]+"-"+$i[t>>16&255]+$i[t>>24&255]+$i[n&255]+$i[n>>8&255]+$i[n>>16&255]+$i[n>>24&255]).toLowerCase()}function Wt(i,e,t){return Math.max(e,Math.min(t,i))}function z_(i,e){return(i%e+e)%e}function sb(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function ob(i,e,t){return i!==e?(t-i)/(e-i):0}function wd(i,e,t){return(1-t)*i+t*e}function ab(i,e,t,n){return wd(i,e,1-Math.exp(-t*n))}function lb(i,e=1){return e-Math.abs(z_(i,e*2)-e)}function ub(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function cb(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function fb(i,e){return i+Math.floor(Math.random()*(e-i+1))}function hb(i,e){return i+Math.random()*(e-i)}function db(i){return i*(.5-Math.random())}function pb(i){i!==void 0&&(FS=i);let e=FS+=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 mb(i){return i*Ou}function gb(i){return i*Bf}function vb(i){return(i&i-1)===0&&i!==0}function yb(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function _b(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function xb(i,e,t,n,r){const o=Math.cos,a=Math.sin,u=o(t/2),h=a(t/2),p=o((e+n)/2),m=a((e+n)/2),g=o((e-n)/2),v=a((e-n)/2),x=o((n-e)/2),w=a((n-e)/2);switch(r){case"XYX":i.set(u*m,h*g,h*v,u*p);break;case"YZY":i.set(h*v,u*m,h*g,u*p);break;case"ZXZ":i.set(h*g,h*v,u*m,u*p);break;case"XZX":i.set(u*m,h*w,h*x,u*p);break;case"YXY":i.set(h*x,u*m,h*w,u*p);break;case"ZYZ":i.set(h*w,h*x,u*m,u*p);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function yr(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Kt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Sb={DEG2RAD:Ou,RAD2DEG:Bf,generateUUID:is,clamp:Wt,euclideanModulo:z_,mapLinear:sb,inverseLerp:ob,lerp:wd,damp:ab,pingpong:lb,smoothstep:ub,smootherstep:cb,randInt:fb,randFloat:hb,randFloatSpread:db,seededRandom:pb,degToRad:mb,radToDeg:gb,isPowerOfTwo:vb,ceilPowerOfTwo:yb,floorPowerOfTwo:_b,setQuaternionFromProperEuler:xb,normalize:Kt,denormalize:yr};class Ce{constructor(e=0,t=0){Ce.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,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+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=Wt(this.x,e.x,t.x),this.y=Wt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Wt(this.x,e,t),this.y=Wt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Wt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Wt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*r+e.x,this.y=o*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class jt{constructor(e,t,n,r,o,a,u,h,p){jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,o,a,u,h,p)}set(e,t,n,r,o,a,u,h,p){const m=this.elements;return m[0]=e,m[1]=r,m[2]=u,m[3]=t,m[4]=o,m[5]=h,m[6]=n,m[7]=a,m[8]=p,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,a=n[0],u=n[3],h=n[6],p=n[1],m=n[4],g=n[7],v=n[2],x=n[5],w=n[8],A=r[0],E=r[3],S=r[6],b=r[1],P=r[4],I=r[7],B=r[2],F=r[5],V=r[8];return o[0]=a*A+u*b+h*B,o[3]=a*E+u*P+h*F,o[6]=a*S+u*I+h*V,o[1]=p*A+m*b+g*B,o[4]=p*E+m*P+g*F,o[7]=p*S+m*I+g*V,o[2]=v*A+x*b+w*B,o[5]=v*E+x*P+w*F,o[8]=v*S+x*I+w*V,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],u=e[5],h=e[6],p=e[7],m=e[8];return t*a*m-t*u*p-n*o*m+n*u*h+r*o*p-r*a*h}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],u=e[5],h=e[6],p=e[7],m=e[8],g=m*a-u*p,v=u*h-m*o,x=p*o-a*h,w=t*g+n*v+r*x;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const A=1/w;return e[0]=g*A,e[1]=(r*p-m*n)*A,e[2]=(u*n-r*a)*A,e[3]=v*A,e[4]=(m*t-r*h)*A,e[5]=(r*o-u*t)*A,e[6]=x*A,e[7]=(n*h-p*t)*A,e[8]=(a*t-n*o)*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,n,r,o,a,u){const h=Math.cos(o),p=Math.sin(o);return this.set(n*h,n*p,-n*(h*a+p*u)+a+e,-r*p,r*h,-r*(-p*a+h*u)+u+t,0,0,1),this}scale(e,t){return this.premultiply(Tv.makeScale(e,t)),this}rotate(e){return this.premultiply(Tv.makeRotation(-e)),this}translate(e,t){return this.premultiply(Tv.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Tv=new jt;function zE(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}const Mb={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Cf(i,e){return new Mb[i](e)}function Bd(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function VE(){const i=Bd("canvas");return i.style.display="block",i}const OS={};function wf(i){i in OS||(OS[i]=!0,console.warn(i))}function wb(i,e,t){return new Promise(function(n,r){function o(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}function Eb(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Tb(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const kS=new jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),BS=new jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ab(){const i={enabled:!0,workingColorSpace:Wu,spaces:{},convert:function(r,o,a){return this.enabled===!1||o===a||!o||!a||(this.spaces[o].transfer===_n&&(r.r=_a(r.r),r.g=_a(r.g),r.b=_a(r.b)),this.spaces[o].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[o].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===_n&&(r.r=Of(r.r),r.g=Of(r.g),r.b=Of(r.b))),r},fromWorkingColorSpace:function(r,o){return this.convert(r,this.workingColorSpace,o)},toWorkingColorSpace:function(r,o){return this.convert(r,o,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===ga?Fd:this.spaces[r].transfer},getLuminanceCoefficients:function(r,o=this.workingColorSpace){return r.fromArray(this.spaces[o].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,o,a){return r.copy(this.spaces[o].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Wu]:{primaries:e,whitePoint:n,transfer:Fd,toXYZ:kS,fromXYZ:BS,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:kr},outputColorSpaceConfig:{drawingBufferColorSpace:kr}},[kr]:{primaries:e,whitePoint:n,transfer:_n,toXYZ:kS,fromXYZ:BS,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:kr}}}),i}const ln=Ab();function _a(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Of(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let nf;class HE{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{nf===void 0&&(nf=Bd("canvas")),nf.width=e.width,nf.height=e.height;const n=nf.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=nf}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Bd("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),o=r.data;for(let a=0;a0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==f0)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ld:e.x=e.x-Math.floor(e.x);break;case Es:e.x=e.x<0?0:1;break;case Dd: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 Ld:e.y=e.y-Math.floor(e.y);break;case Es:e.y=e.y<0?0:1;break;case Dd: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++}}Wn.DEFAULT_IMAGE=null;Wn.DEFAULT_MAPPING=f0;Wn.DEFAULT_ANISOTROPY=1;class hn{constructor(e=0,t=0,n=0,r=1){hn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,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,n,r){return this.x=e,this.y=t,this.z=n,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,n=this.y,r=this.z,o=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*o,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*o,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*o,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*o,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,o;const h=e.elements,p=h[0],m=h[4],g=h[8],v=h[1],x=h[5],w=h[9],A=h[2],E=h[6],S=h[10];if(Math.abs(m-v)<.01&&Math.abs(g-A)<.01&&Math.abs(w-E)<.01){if(Math.abs(m+v)<.1&&Math.abs(g+A)<.1&&Math.abs(w+E)<.1&&Math.abs(p+x+S-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const P=(p+1)/2,I=(x+1)/2,B=(S+1)/2,F=(m+v)/4,V=(g+A)/4,H=(w+E)/4;return P>I&&P>B?P<.01?(n=0,r=.707106781,o=.707106781):(n=Math.sqrt(P),r=F/n,o=V/n):I>B?I<.01?(n=.707106781,r=0,o=.707106781):(r=Math.sqrt(I),n=F/r,o=H/r):B<.01?(n=.707106781,r=.707106781,o=0):(o=Math.sqrt(B),n=V/o,r=H/o),this.set(n,r,o,t),this}let b=Math.sqrt((E-w)*(E-w)+(g-A)*(g-A)+(v-m)*(v-m));return Math.abs(b)<.001&&(b=1),this.x=(E-w)/b,this.y=(g-A)/b,this.z=(v-m)/b,this.w=Math.acos((p+x+S-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=Wt(this.x,e.x,t.x),this.y=Wt(this.y,e.y,t.y),this.z=Wt(this.z,e.z,t.z),this.w=Wt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Wt(this.x,e,t),this.y=Wt(this.y,e,t),this.z=Wt(this.z,e,t),this.w=Wt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Wt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class GE extends bo{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new hn(0,0,e,t),this.scissorTest=!1,this.viewport=new hn(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const o=new Wn(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);o.flipY=!1,o.generateMipmaps=n.generateMipmaps,o.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let u=0;u=0?1:-1,P=1-S*S;if(P>Number.EPSILON){const B=Math.sqrt(P),F=Math.atan2(B,S*b);E=Math.sin(E*F)/B,u=Math.sin(u*F)/B}const I=u*b;if(h=h*E+v*I,p=p*E+x*I,m=m*E+w*I,g=g*E+A*I,E===1-u){const B=1/Math.sqrt(h*h+p*p+m*m+g*g);h*=B,p*=B,m*=B,g*=B}}e[t]=h,e[t+1]=p,e[t+2]=m,e[t+3]=g}static multiplyQuaternionsFlat(e,t,n,r,o,a){const u=n[r],h=n[r+1],p=n[r+2],m=n[r+3],g=o[a],v=o[a+1],x=o[a+2],w=o[a+3];return e[t]=u*w+m*g+h*x-p*v,e[t+1]=h*w+m*v+p*g-u*x,e[t+2]=p*w+m*x+u*v-h*g,e[t+3]=m*w-u*g-h*v-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,n,r){return this._x=e,this._y=t,this._z=n,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 n=e._x,r=e._y,o=e._z,a=e._order,u=Math.cos,h=Math.sin,p=u(n/2),m=u(r/2),g=u(o/2),v=h(n/2),x=h(r/2),w=h(o/2);switch(a){case"XYZ":this._x=v*m*g+p*x*w,this._y=p*x*g-v*m*w,this._z=p*m*w+v*x*g,this._w=p*m*g-v*x*w;break;case"YXZ":this._x=v*m*g+p*x*w,this._y=p*x*g-v*m*w,this._z=p*m*w-v*x*g,this._w=p*m*g+v*x*w;break;case"ZXY":this._x=v*m*g-p*x*w,this._y=p*x*g+v*m*w,this._z=p*m*w+v*x*g,this._w=p*m*g-v*x*w;break;case"ZYX":this._x=v*m*g-p*x*w,this._y=p*x*g+v*m*w,this._z=p*m*w-v*x*g,this._w=p*m*g+v*x*w;break;case"YZX":this._x=v*m*g+p*x*w,this._y=p*x*g+v*m*w,this._z=p*m*w-v*x*g,this._w=p*m*g-v*x*w;break;case"XZY":this._x=v*m*g-p*x*w,this._y=p*x*g-v*m*w,this._z=p*m*w+v*x*g,this._w=p*m*g+v*x*w;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],o=t[8],a=t[1],u=t[5],h=t[9],p=t[2],m=t[6],g=t[10],v=n+u+g;if(v>0){const x=.5/Math.sqrt(v+1);this._w=.25/x,this._x=(m-h)*x,this._y=(o-p)*x,this._z=(a-r)*x}else if(n>u&&n>g){const x=2*Math.sqrt(1+n-u-g);this._w=(m-h)/x,this._x=.25*x,this._y=(r+a)/x,this._z=(o+p)/x}else if(u>g){const x=2*Math.sqrt(1+u-n-g);this._w=(o-p)/x,this._x=(r+a)/x,this._y=.25*x,this._z=(h+m)/x}else{const x=2*Math.sqrt(1+g-n-u);this._w=(a-r)/x,this._x=(o+p)/x,this._y=(h+m)/x,this._z=.25*x}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Wt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);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 n=e._x,r=e._y,o=e._z,a=e._w,u=t._x,h=t._y,p=t._z,m=t._w;return this._x=n*m+a*u+r*p-o*h,this._y=r*m+a*h+o*u-n*p,this._z=o*m+a*p+n*h-r*u,this._w=a*m-n*u-r*h-o*p,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,o=this._z,a=this._w;let u=a*e._w+n*e._x+r*e._y+o*e._z;if(u<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,u=-u):this.copy(e),u>=1)return this._w=a,this._x=n,this._y=r,this._z=o,this;const h=1-u*u;if(h<=Number.EPSILON){const x=1-t;return this._w=x*a+t*this._w,this._x=x*n+t*this._x,this._y=x*r+t*this._y,this._z=x*o+t*this._z,this.normalize(),this}const p=Math.sqrt(h),m=Math.atan2(p,u),g=Math.sin((1-t)*m)/p,v=Math.sin(t*m)/p;return this._w=a*g+this._w*v,this._x=n*g+this._x*v,this._y=r*g+this._y*v,this._z=o*g+this._z*v,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),o*Math.sin(t),o*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 j{constructor(e=0,t=0,n=0){j.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("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(zS.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(zS.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*r,this.y=o[1]*t+o[4]*n+o[7]*r,this.z=o[2]*t+o[5]*n+o[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*r+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*r+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*r+o[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,o=e.x,a=e.y,u=e.z,h=e.w,p=2*(a*r-u*n),m=2*(u*t-o*r),g=2*(o*n-a*t);return this.x=t+h*p+a*g-u*m,this.y=n+h*m+u*p-o*g,this.z=r+h*g+o*m-a*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,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r,this.y=o[1]*t+o[5]*n+o[9]*r,this.z=o[2]*t+o[6]*n+o[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=Wt(this.x,e.x,t.x),this.y=Wt(this.y,e.y,t.y),this.z=Wt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Wt(this.x,e,t),this.y=Wt(this.y,e,t),this.z=Wt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Wt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,o=e.z,a=t.x,u=t.y,h=t.z;return this.x=r*h-o*u,this.y=o*a-n*h,this.z=n*u-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Cv.copy(this).projectOnVector(e),this.sub(Cv)}reflect(e){return this.sub(Cv.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 n=this.dot(e)/t;return Math.acos(Wt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+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,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Cv=new j,zS=new Vr;class Sr{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=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,qs),qs.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Kh),fm.subVectors(this.max,Kh),rf.subVectors(e.a,Kh),sf.subVectors(e.b,Kh),of.subVectors(e.c,Kh),al.subVectors(sf,rf),ll.subVectors(of,sf),fu.subVectors(rf,of);let t=[0,-al.z,al.y,0,-ll.z,ll.y,0,-fu.z,fu.y,al.z,0,-al.x,ll.z,0,-ll.x,fu.z,0,-fu.x,-al.y,al.x,0,-ll.y,ll.x,0,-fu.y,fu.x,0];return!Rv(t,rf,sf,of,fm)||(t=[1,0,0,0,1,0,0,0,1],!Rv(t,rf,sf,of,fm))?!1:(hm.crossVectors(al,ll),t=[hm.x,hm.y,hm.z],Rv(t,rf,sf,of,fm))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qs).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qs).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:(ca[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ca[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ca[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ca[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ca[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ca[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ca[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ca[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ca),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 ca=[new j,new j,new j,new j,new j,new j,new j,new j],qs=new j,cm=new Sr,rf=new j,sf=new j,of=new j,al=new j,ll=new j,fu=new j,Kh=new j,fm=new j,hm=new j,hu=new j;function Rv(i,e,t,n,r){for(let o=0,a=i.length-3;o<=a;o+=3){hu.fromArray(i,o);const u=r.x*Math.abs(hu.x)+r.y*Math.abs(hu.y)+r.z*Math.abs(hu.z),h=e.dot(hu),p=t.dot(hu),m=n.dot(hu);if(Math.max(-Math.max(h,p,m),Math.min(h,p,m))>u)return!1}return!0}const Ib=new Sr,Jh=new j,bv=new j;class sr{constructor(e=new j,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ib.setFromPoints(e).getCenter(n);let r=0;for(let o=0,a=e.length;othis.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;Jh.subVectors(e,this.center);const t=Jh.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Jh,r/n),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):(bv.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Jh.copy(e.center).add(bv)),this.expandByPoint(Jh.copy(e.center).sub(bv))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const fa=new j,Pv=new j,dm=new j,ul=new j,Iv=new j,pm=new j,Lv=new j;class qf{constructor(e=new j,t=new j(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,fa)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=fa.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(fa.copy(this.origin).addScaledVector(this.direction,t),fa.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Pv.copy(e).add(t).multiplyScalar(.5),dm.copy(t).sub(e).normalize(),ul.copy(this.origin).sub(Pv);const o=e.distanceTo(t)*.5,a=-this.direction.dot(dm),u=ul.dot(this.direction),h=-ul.dot(dm),p=ul.lengthSq(),m=Math.abs(1-a*a);let g,v,x,w;if(m>0)if(g=a*h-u,v=a*u-h,w=o*m,g>=0)if(v>=-w)if(v<=w){const A=1/m;g*=A,v*=A,x=g*(g+a*v+2*u)+v*(a*g+v+2*h)+p}else v=o,g=Math.max(0,-(a*v+u)),x=-g*g+v*(v+2*h)+p;else v=-o,g=Math.max(0,-(a*v+u)),x=-g*g+v*(v+2*h)+p;else v<=-w?(g=Math.max(0,-(-a*o+u)),v=g>0?-o:Math.min(Math.max(-o,-h),o),x=-g*g+v*(v+2*h)+p):v<=w?(g=0,v=Math.min(Math.max(-o,-h),o),x=v*(v+2*h)+p):(g=Math.max(0,-(a*o+u)),v=g>0?o:Math.min(Math.max(-o,-h),o),x=-g*g+v*(v+2*h)+p);else v=a>0?-o:o,g=Math.max(0,-(a*v+u)),x=-g*g+v*(v+2*h)+p;return n&&n.copy(this.origin).addScaledVector(this.direction,g),r&&r.copy(Pv).addScaledVector(dm,v),x}intersectSphere(e,t){fa.subVectors(e.center,this.origin);const n=fa.dot(this.direction),r=fa.dot(fa)-n*n,o=e.radius*e.radius;if(r>o)return null;const a=Math.sqrt(o-r),u=n-a,h=n+a;return h<0?null:u<0?this.at(h,t):this.at(u,t)}intersectsSphere(e){return 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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,o,a,u,h;const p=1/this.direction.x,m=1/this.direction.y,g=1/this.direction.z,v=this.origin;return p>=0?(n=(e.min.x-v.x)*p,r=(e.max.x-v.x)*p):(n=(e.max.x-v.x)*p,r=(e.min.x-v.x)*p),m>=0?(o=(e.min.y-v.y)*m,a=(e.max.y-v.y)*m):(o=(e.max.y-v.y)*m,a=(e.min.y-v.y)*m),n>a||o>r||((o>n||isNaN(n))&&(n=o),(a=0?(u=(e.min.z-v.z)*g,h=(e.max.z-v.z)*g):(u=(e.max.z-v.z)*g,h=(e.min.z-v.z)*g),n>h||u>r)||((u>n||n!==n)&&(n=u),(h=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,fa)!==null}intersectTriangle(e,t,n,r,o){Iv.subVectors(t,e),pm.subVectors(n,e),Lv.crossVectors(Iv,pm);let a=this.direction.dot(Lv),u;if(a>0){if(r)return null;u=1}else if(a<0)u=-1,a=-a;else return null;ul.subVectors(this.origin,e);const h=u*this.direction.dot(pm.crossVectors(ul,pm));if(h<0)return null;const p=u*this.direction.dot(Iv.cross(ul));if(p<0||h+p>a)return null;const m=-u*ul.dot(Lv);return m<0?null:this.at(m/a,o)}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 Ft{constructor(e,t,n,r,o,a,u,h,p,m,g,v,x,w,A,E){Ft.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,n,r,o,a,u,h,p,m,g,v,x,w,A,E)}set(e,t,n,r,o,a,u,h,p,m,g,v,x,w,A,E){const S=this.elements;return S[0]=e,S[4]=t,S[8]=n,S[12]=r,S[1]=o,S[5]=a,S[9]=u,S[13]=h,S[2]=p,S[6]=m,S[10]=g,S[14]=v,S[3]=x,S[7]=w,S[11]=A,S[15]=E,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 Ft().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/af.setFromMatrixColumn(e,0).length(),o=1/af.setFromMatrixColumn(e,1).length(),a=1/af.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,o=e.z,a=Math.cos(n),u=Math.sin(n),h=Math.cos(r),p=Math.sin(r),m=Math.cos(o),g=Math.sin(o);if(e.order==="XYZ"){const v=a*m,x=a*g,w=u*m,A=u*g;t[0]=h*m,t[4]=-h*g,t[8]=p,t[1]=x+w*p,t[5]=v-A*p,t[9]=-u*h,t[2]=A-v*p,t[6]=w+x*p,t[10]=a*h}else if(e.order==="YXZ"){const v=h*m,x=h*g,w=p*m,A=p*g;t[0]=v+A*u,t[4]=w*u-x,t[8]=a*p,t[1]=a*g,t[5]=a*m,t[9]=-u,t[2]=x*u-w,t[6]=A+v*u,t[10]=a*h}else if(e.order==="ZXY"){const v=h*m,x=h*g,w=p*m,A=p*g;t[0]=v-A*u,t[4]=-a*g,t[8]=w+x*u,t[1]=x+w*u,t[5]=a*m,t[9]=A-v*u,t[2]=-a*p,t[6]=u,t[10]=a*h}else if(e.order==="ZYX"){const v=a*m,x=a*g,w=u*m,A=u*g;t[0]=h*m,t[4]=w*p-x,t[8]=v*p+A,t[1]=h*g,t[5]=A*p+v,t[9]=x*p-w,t[2]=-p,t[6]=u*h,t[10]=a*h}else if(e.order==="YZX"){const v=a*h,x=a*p,w=u*h,A=u*p;t[0]=h*m,t[4]=A-v*g,t[8]=w*g+x,t[1]=g,t[5]=a*m,t[9]=-u*m,t[2]=-p*m,t[6]=x*g+w,t[10]=v-A*g}else if(e.order==="XZY"){const v=a*h,x=a*p,w=u*h,A=u*p;t[0]=h*m,t[4]=-g,t[8]=p*m,t[1]=v*g+A,t[5]=a*m,t[9]=x*g-w,t[2]=w*g-x,t[6]=u*m,t[10]=A*g+v}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(Lb,e,Db)}lookAt(e,t,n){const r=this.elements;return ts.subVectors(e,t),ts.lengthSq()===0&&(ts.z=1),ts.normalize(),cl.crossVectors(n,ts),cl.lengthSq()===0&&(Math.abs(n.z)===1?ts.x+=1e-4:ts.z+=1e-4,ts.normalize(),cl.crossVectors(n,ts)),cl.normalize(),mm.crossVectors(ts,cl),r[0]=cl.x,r[4]=mm.x,r[8]=ts.x,r[1]=cl.y,r[5]=mm.y,r[9]=ts.y,r[2]=cl.z,r[6]=mm.z,r[10]=ts.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,a=n[0],u=n[4],h=n[8],p=n[12],m=n[1],g=n[5],v=n[9],x=n[13],w=n[2],A=n[6],E=n[10],S=n[14],b=n[3],P=n[7],I=n[11],B=n[15],F=r[0],V=r[4],H=r[8],U=r[12],D=r[1],W=r[5],se=r[9],ie=r[13],fe=r[2],Me=r[6],ue=r[10],ye=r[14],O=r[3],J=r[7],K=r[11],G=r[15];return o[0]=a*F+u*D+h*fe+p*O,o[4]=a*V+u*W+h*Me+p*J,o[8]=a*H+u*se+h*ue+p*K,o[12]=a*U+u*ie+h*ye+p*G,o[1]=m*F+g*D+v*fe+x*O,o[5]=m*V+g*W+v*Me+x*J,o[9]=m*H+g*se+v*ue+x*K,o[13]=m*U+g*ie+v*ye+x*G,o[2]=w*F+A*D+E*fe+S*O,o[6]=w*V+A*W+E*Me+S*J,o[10]=w*H+A*se+E*ue+S*K,o[14]=w*U+A*ie+E*ye+S*G,o[3]=b*F+P*D+I*fe+B*O,o[7]=b*V+P*W+I*Me+B*J,o[11]=b*H+P*se+I*ue+B*K,o[15]=b*U+P*ie+I*ye+B*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],o=e[12],a=e[1],u=e[5],h=e[9],p=e[13],m=e[2],g=e[6],v=e[10],x=e[14],w=e[3],A=e[7],E=e[11],S=e[15];return w*(+o*h*g-r*p*g-o*u*v+n*p*v+r*u*x-n*h*x)+A*(+t*h*x-t*p*v+o*a*v-r*a*x+r*p*m-o*h*m)+E*(+t*p*g-t*u*x-o*a*g+n*a*x+o*u*m-n*p*m)+S*(-r*u*m-t*h*g+t*u*v+r*a*g-n*a*v+n*h*m)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const 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]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],u=e[5],h=e[6],p=e[7],m=e[8],g=e[9],v=e[10],x=e[11],w=e[12],A=e[13],E=e[14],S=e[15],b=g*E*p-A*v*p+A*h*x-u*E*x-g*h*S+u*v*S,P=w*v*p-m*E*p-w*h*x+a*E*x+m*h*S-a*v*S,I=m*A*p-w*g*p+w*u*x-a*A*x-m*u*S+a*g*S,B=w*g*h-m*A*h-w*u*v+a*A*v+m*u*E-a*g*E,F=t*b+n*P+r*I+o*B;if(F===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const V=1/F;return e[0]=b*V,e[1]=(A*v*o-g*E*o-A*r*x+n*E*x+g*r*S-n*v*S)*V,e[2]=(u*E*o-A*h*o+A*r*p-n*E*p-u*r*S+n*h*S)*V,e[3]=(g*h*o-u*v*o-g*r*p+n*v*p+u*r*x-n*h*x)*V,e[4]=P*V,e[5]=(m*E*o-w*v*o+w*r*x-t*E*x-m*r*S+t*v*S)*V,e[6]=(w*h*o-a*E*o-w*r*p+t*E*p+a*r*S-t*h*S)*V,e[7]=(a*v*o-m*h*o+m*r*p-t*v*p-a*r*x+t*h*x)*V,e[8]=I*V,e[9]=(w*g*o-m*A*o-w*n*x+t*A*x+m*n*S-t*g*S)*V,e[10]=(a*A*o-w*u*o+w*n*p-t*A*p-a*n*S+t*u*S)*V,e[11]=(m*u*o-a*g*o-m*n*p+t*g*p+a*n*x-t*u*x)*V,e[12]=B*V,e[13]=(m*A*r-w*g*r+w*n*v-t*A*v-m*n*E+t*g*E)*V,e[14]=(w*u*r-a*A*r-w*n*h+t*A*h+a*n*E-t*u*E)*V,e[15]=(a*g*r-m*u*r+m*n*h-t*g*h-a*n*v+t*u*v)*V,this}scale(e){const t=this.elements,n=e.x,r=e.y,o=e.z;return t[0]*=n,t[4]*=r,t[8]*=o,t[1]*=n,t[5]*=r,t[9]*=o,t[2]*=n,t[6]*=r,t[10]*=o,t[3]*=n,t[7]*=r,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),o=1-n,a=e.x,u=e.y,h=e.z,p=o*a,m=o*u;return this.set(p*a+n,p*u-r*h,p*h+r*u,0,p*u+r*h,m*u+n,m*h-r*a,0,p*h-r*u,m*h+r*a,o*h*h+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,o,a){return this.set(1,n,o,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,o=t._x,a=t._y,u=t._z,h=t._w,p=o+o,m=a+a,g=u+u,v=o*p,x=o*m,w=o*g,A=a*m,E=a*g,S=u*g,b=h*p,P=h*m,I=h*g,B=n.x,F=n.y,V=n.z;return r[0]=(1-(A+S))*B,r[1]=(x+I)*B,r[2]=(w-P)*B,r[3]=0,r[4]=(x-I)*F,r[5]=(1-(v+S))*F,r[6]=(E+b)*F,r[7]=0,r[8]=(w+P)*V,r[9]=(E-b)*V,r[10]=(1-(v+A))*V,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let o=af.set(r[0],r[1],r[2]).length();const a=af.set(r[4],r[5],r[6]).length(),u=af.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),e.x=r[12],e.y=r[13],e.z=r[14],Zs.copy(this);const p=1/o,m=1/a,g=1/u;return Zs.elements[0]*=p,Zs.elements[1]*=p,Zs.elements[2]*=p,Zs.elements[4]*=m,Zs.elements[5]*=m,Zs.elements[6]*=m,Zs.elements[8]*=g,Zs.elements[9]*=g,Zs.elements[10]*=g,t.setFromRotationMatrix(Zs),n.x=o,n.y=a,n.z=u,this}makePerspective(e,t,n,r,o,a,u=So){const h=this.elements,p=2*o/(t-e),m=2*o/(n-r),g=(t+e)/(t-e),v=(n+r)/(n-r);let x,w;if(u===So)x=-(a+o)/(a-o),w=-2*a*o/(a-o);else if(u===kd)x=-a/(a-o),w=-a*o/(a-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+u);return h[0]=p,h[4]=0,h[8]=g,h[12]=0,h[1]=0,h[5]=m,h[9]=v,h[13]=0,h[2]=0,h[6]=0,h[10]=x,h[14]=w,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,n,r,o,a,u=So){const h=this.elements,p=1/(t-e),m=1/(n-r),g=1/(a-o),v=(t+e)*p,x=(n+r)*m;let w,A;if(u===So)w=(a+o)*g,A=-2*g;else if(u===kd)w=o*g,A=-1*g;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+u);return h[0]=2*p,h[4]=0,h[8]=0,h[12]=-v,h[1]=0,h[5]=2*m,h[9]=0,h[13]=-x,h[2]=0,h[6]=0,h[10]=A,h[14]=-w,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const af=new j,Zs=new Ft,Lb=new j(0,0,0),Db=new j(1,1,1),cl=new j,mm=new j,ts=new j,VS=new Ft,HS=new Vr;class ss{constructor(e=0,t=0,n=0,r=ss.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,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,n,r=this._order){return this._x=e,this._y=t,this._z=n,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,n=!0){const r=e.elements,o=r[0],a=r[4],u=r[8],h=r[1],p=r[5],m=r[9],g=r[2],v=r[6],x=r[10];switch(t){case"XYZ":this._y=Math.asin(Wt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-m,x),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(v,p),this._z=0);break;case"YXZ":this._x=Math.asin(-Wt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(u,x),this._z=Math.atan2(h,p)):(this._y=Math.atan2(-g,o),this._z=0);break;case"ZXY":this._x=Math.asin(Wt(v,-1,1)),Math.abs(v)<.9999999?(this._y=Math.atan2(-g,x),this._z=Math.atan2(-a,p)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-Wt(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(v,x),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-a,p));break;case"YZX":this._z=Math.asin(Wt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-m,p),this._y=Math.atan2(-g,o)):(this._x=0,this._y=Math.atan2(u,x));break;case"XZY":this._z=Math.asin(-Wt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(v,p),this._y=Math.atan2(u,o)):(this._x=Math.atan2(-m,x),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return VS.makeRotationFromQuaternion(e),this.setFromRotationMatrix(VS,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return HS.setFromEuler(this),this.setFromQuaternion(HS,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}}ss.DEFAULT_ORDER="XYZ";class ku{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(u=>({boxInitialized:u.boxInitialized,boxMin:u.box.min.toArray(),boxMax:u.box.max.toArray(),sphereInitialized:u.sphereInitialized,sphereRadius:u.sphere.radius,sphereCenter:u.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function o(u,h){return u[h.uuid]===void 0&&(u[h.uuid]=h.toJSON(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=o(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,m=h.length;p0){r.children=[];for(let u=0;u0){r.animations=[];for(let u=0;u0&&(n.geometries=u),h.length>0&&(n.materials=h),p.length>0&&(n.textures=p),m.length>0&&(n.images=m),g.length>0&&(n.shapes=g),v.length>0&&(n.skeletons=v),x.length>0&&(n.animations=x),w.length>0&&(n.nodes=w)}return n.object=r,n;function a(u){const h=[];for(const p in u){const m=u[p];delete m.metadata,h.push(m)}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 n=0;n0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(e,t,n,r,o){Ks.subVectors(r,t),da.subVectors(n,t),Nv.subVectors(e,t);const a=Ks.dot(Ks),u=Ks.dot(da),h=Ks.dot(Nv),p=da.dot(da),m=da.dot(Nv),g=a*p-u*u;if(g===0)return o.set(0,0,0),null;const v=1/g,x=(p*h-u*m)*v,w=(a*m-u*h)*v;return o.set(1-x-w,w,x)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,pa)===null?!1:pa.x>=0&&pa.y>=0&&pa.x+pa.y<=1}static getInterpolation(e,t,n,r,o,a,u,h){return this.getBarycoord(e,t,n,r,pa)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(o,pa.x),h.addScaledVector(a,pa.y),h.addScaledVector(u,pa.z),h)}static getInterpolatedAttribute(e,t,n,r,o,a){return kv.setScalar(0),Bv.setScalar(0),zv.setScalar(0),kv.fromBufferAttribute(e,t),Bv.fromBufferAttribute(e,n),zv.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(kv,o.x),a.addScaledVector(Bv,o.y),a.addScaledVector(zv,o.z),a}static isFrontFacing(e,t,n,r){return Ks.subVectors(n,t),da.subVectors(e,t),Ks.cross(da).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 Ks.subVectors(this.c,this.b),da.subVectors(this.a,this.b),Ks.cross(da).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Br.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Br.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,o){return Br.getInterpolation(e,this.a,this.b,this.c,t,n,r,o)}containsPoint(e){return Br.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Br.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,o=this.c;let a,u;cf.subVectors(r,n),ff.subVectors(o,n),Uv.subVectors(e,n);const h=cf.dot(Uv),p=ff.dot(Uv);if(h<=0&&p<=0)return t.copy(n);Fv.subVectors(e,r);const m=cf.dot(Fv),g=ff.dot(Fv);if(m>=0&&g<=m)return t.copy(r);const v=h*g-m*p;if(v<=0&&h>=0&&m<=0)return a=h/(h-m),t.copy(n).addScaledVector(cf,a);Ov.subVectors(e,o);const x=cf.dot(Ov),w=ff.dot(Ov);if(w>=0&&x<=w)return t.copy(o);const A=x*p-h*w;if(A<=0&&p>=0&&w<=0)return u=p/(p-w),t.copy(n).addScaledVector(ff,u);const E=m*w-x*g;if(E<=0&&g-m>=0&&x-w>=0)return qS.subVectors(o,r),u=(g-m)/(g-m+(x-w)),t.copy(r).addScaledVector(qS,u);const S=1/(E+A+v);return a=A*S,u=v*S,t.copy(n).addScaledVector(cf,a).addScaledVector(ff,u)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const WE={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},fl={h:0,s:0,l:0},vm={h:0,s:0,l:0};function Vv(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class et{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=kr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ln.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=ln.workingColorSpace){return this.r=e,this.g=t,this.b=n,ln.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=ln.workingColorSpace){if(e=z_(e,1),t=Wt(t,0,1),n=Wt(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,a=2*n-o;this.r=Vv(a,o,e+1/3),this.g=Vv(a,o,e),this.b=Vv(a,o,e-1/3)}return ln.toWorkingColorSpace(this,r),this}setStyle(e,t=kr){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const a=r[1],u=r[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=r[1],a=o.length;if(a===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(o,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=kr){const n=WE[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.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=_a(e.r),this.g=_a(e.g),this.b=_a(e.b),this}copyLinearToSRGB(e){return this.r=Of(e.r),this.g=Of(e.g),this.b=Of(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=kr){return ln.fromWorkingColorSpace(er.copy(this),e),Math.round(Wt(er.r*255,0,255))*65536+Math.round(Wt(er.g*255,0,255))*256+Math.round(Wt(er.b*255,0,255))}getHexString(e=kr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ln.workingColorSpace){ln.fromWorkingColorSpace(er.copy(this),t);const n=er.r,r=er.g,o=er.b,a=Math.max(n,r,o),u=Math.min(n,r,o);let h,p;const m=(u+a)/2;if(u===a)h=0,p=0;else{const g=a-u;switch(p=m<=.5?g/(a+u):g/(2-a-u),a){case n:h=(r-o)/g+(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 n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Uu&&(n.blending=this.blending),this.side!==Ma&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==dg&&(n.blendSrc=this.blendSrc),this.blendDst!==pg&&(n.blendDst=this.blendDst),this.blendEquation!==vl&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Vu&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Yy&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Tu&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Tu&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Tu&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(o){const a=[];for(const u in o){const h=o[u];delete h.metadata,a.push(h)}return a}if(t){const o=r(e.textures),a=r(e.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let o=0;o!==r;++o)n[o]=t[o].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.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++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Ca extends Xi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new et(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 ss,this.combine=$d,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 va=Bb();function Bb(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let h=0;h<256;++h){const p=h-127;p<-27?(n[h]=0,n[h|256]=32768,r[h]=24,r[h|256]=24):p<-14?(n[h]=1024>>-p-14,n[h|256]=1024>>-p-14|32768,r[h]=-p-1,r[h|256]=-p-1):p<=15?(n[h]=p+15<<10,n[h|256]=p+15<<10|32768,r[h]=13,r[h|256]=13):p<128?(n[h]=31744,n[h|256]=64512,r[h]=24,r[h|256]=24):(n[h]=31744,n[h|256]=64512,r[h]=13,r[h|256]=13)}const o=new Uint32Array(2048),a=new Uint32Array(64),u=new Uint32Array(64);for(let h=1;h<1024;++h){let p=h<<13,m=0;for(;!(p&8388608);)p<<=1,m-=8388608;p&=-8388609,m+=947912704,o[h]=p|m}for(let h=1024;h<2048;++h)o[h]=939524096+(h-1024<<13);for(let h=1;h<31;++h)a[h]=h<<23;a[31]=1199570944,a[32]=2147483648;for(let h=33;h<63;++h)a[h]=2147483648+(h-32<<23);a[63]=3347054592;for(let h=1;h<64;++h)h!==32&&(u[h]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:o,exponentTable:a,offsetTable:u}}function Or(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=Wt(i,-65504,65504),va.floatView[0]=i;const e=va.uint32View[0],t=e>>23&511;return va.baseTable[t]+((e&8388607)>>va.shiftTable[t])}function fd(i){const e=i>>10;return va.uint32View[0]=va.mantissaTable[va.offsetTable[e]+(i&1023)]+va.exponentTable[e],va.floatView[0]}const zb={toHalfFloat:Or,fromHalfFloat:fd},ci=new j,ym=new Ce;class Tn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Od,this.updateRanges=[],this.gpuType=zr,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,o=this.itemSize;rt.count&&console.warn("THREE.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 Sr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(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 n=this.attributes;for(const h in n){const p=n[h];e.data.attributes[h]=p.toJSON(e.data)}const r={};let o=!1;for(const h in this.morphAttributes){const p=this.morphAttributes[h],m=[];for(let g=0,v=p.length;g0&&(r[h]=m,o=!0)}o&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const u=this.boundingSphere;return u!==null&&(e.data.boundingSphere={center:u.center.toArray(),radius:u.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const p in r){const m=r[p];this.setAttribute(p,m.clone(t))}const o=e.morphAttributes;for(const p in o){const m=[],g=o[p];for(let v=0,x=g.length;v0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o(e.far-e.near)**2))&&(ZS.copy(o).invert(),du.copy(e.ray).applyMatrix4(ZS),!(n.boundingBox!==null&&du.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,du)))}_computeIntersections(e,t,n){let r;const o=this.geometry,a=this.material,u=o.index,h=o.attributes.position,p=o.attributes.uv,m=o.attributes.uv1,g=o.attributes.normal,v=o.groups,x=o.drawRange;if(u!==null)if(Array.isArray(a))for(let w=0,A=v.length;wt.far?null:{distance:p,point:Em.clone(),object:i}}function Tm(i,e,t,n,r,o,a,u,h,p){i.getVertexPosition(u,xm),i.getVertexPosition(h,Sm),i.getVertexPosition(p,Mm);const m=qb(i,e,t,n,xm,Sm,Mm,JS);if(m){const g=new j;Br.getBarycoord(JS,xm,Sm,Mm,g),r&&(m.uv=Br.getInterpolatedAttribute(r,u,h,p,g,new Ce)),o&&(m.uv1=Br.getInterpolatedAttribute(o,u,h,p,g,new Ce)),a&&(m.normal=Br.getInterpolatedAttribute(a,u,h,p,g,new j),m.normal.dot(n.direction)>0&&m.normal.multiplyScalar(-1));const v={a:u,b:h,c:p,normal:new j,materialIndex:0};Br.getNormal(xm,Sm,Mm,v.normal),m.face=v,m.barycoord=g}return m}class qu extends Yt{constructor(e=1,t=1,n=1,r=1,o=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:o,depthSegments:a};const u=this;r=Math.floor(r),o=Math.floor(o),a=Math.floor(a);const h=[],p=[],m=[],g=[];let v=0,x=0;w("z","y","x",-1,-1,n,t,e,a,o,0),w("z","y","x",1,-1,n,t,-e,a,o,1),w("x","z","y",1,1,e,n,t,r,a,2),w("x","z","y",1,-1,e,n,-t,r,a,3),w("x","y","z",1,-1,e,t,n,r,o,4),w("x","y","z",-1,-1,e,t,-n,r,o,5),this.setIndex(h),this.setAttribute("position",new vt(p,3)),this.setAttribute("normal",new vt(m,3)),this.setAttribute("uv",new vt(g,2));function w(A,E,S,b,P,I,B,F,V,H,U){const D=I/V,W=B/H,se=I/2,ie=B/2,fe=F/2,Me=V+1,ue=H+1;let ye=0,O=0;const J=new j;for(let K=0;K0?1:-1,m.push(J.x,J.y,J.z),g.push(ee/V),g.push(1-K/H),ye+=1}}for(let K=0;K0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class tp extends dn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ft,this.projectionMatrix=new Ft,this.projectionMatrixInverse=new Ft,this.coordinateSystem=So}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 hl=new j,QS=new Ce,$S=new Ce;class Pi extends tp{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,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=Bf*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ou*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Bf*2*Math.atan(Math.tan(Ou*.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,n){hl.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(hl.x,hl.y).multiplyScalar(-e/hl.z),hl.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(hl.x,hl.y).multiplyScalar(-e/hl.z)}getViewSize(e,t){return this.getViewBounds(e,QS,$S),t.subVectors($S,QS)}setViewOffset(e,t,n,r,o,a){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=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ou*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,o=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const h=a.fullWidth,p=a.fullHeight;o+=a.offsetX*r/h,t-=a.offsetY*n/p,r*=a.width/h,n*=a.height/p}const u=this.filmOffset;u!==0&&(o+=e*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+r,t,t-n,e,this.far,this.coordinateSystem),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 df=-90,pf=1;class jE extends dn{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Pi(df,pf,e,t);r.layers=this.layers,this.add(r);const o=new Pi(df,pf,e,t);o.layers=this.layers,this.add(o);const a=new Pi(df,pf,e,t);a.layers=this.layers,this.add(a);const u=new Pi(df,pf,e,t);u.layers=this.layers,this.add(u);const h=new Pi(df,pf,e,t);h.layers=this.layers,this.add(h);const p=new Pi(df,pf,e,t);p.layers=this.layers,this.add(p)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,o,a,u,h]=t;for(const p of t)this.remove(p);if(e===So)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),a.up.set(0,0,1),a.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===kd)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),a.up.set(0,0,-1),a.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:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,a,u,h,p,m]=this.children,g=e.getRenderTarget(),v=e.getActiveCubeFace(),x=e.getActiveMipmapLevel(),w=e.xr.enabled;e.xr.enabled=!1;const A=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,o),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,u),e.setRenderTarget(n,3,r),e.render(t,h),e.setRenderTarget(n,4,r),e.render(t,p),n.texture.generateMipmaps=A,e.setRenderTarget(n,5,r),e.render(t,m),e.setRenderTarget(g,v,x),e.xr.enabled=w,n.texture.needsPMREMUpdate=!0}}class np extends Wn{constructor(e,t,n,r,o,a,u,h,p,m){e=e!==void 0?e:[],t=t!==void 0?t:wa,super(e,t,n,r,o,a,u,h,p,m),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class YE extends xr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new np(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:yi}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` 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 qu(5,5,5),o=new Ii({name:"CubemapFromEquirect",uniforms:zf(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:_r,blending:Mo});o.uniforms.tEquirect.value=t;const a=new Qn(r,o),u=t.minFilter;return t.minFilter===xo&&(t.minFilter=yi),new jE(1,10,this).update(e,a),t.minFilter=u,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const o=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(o)}}class x0{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new et(e),this.density=t}clone(){return new x0(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class S0{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new et(e),this.near=t,this.far=n}clone(){return new S0(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Zg extends dn{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 ss,this.environmentIntensity=1,this.environmentRotation=new ss,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 M0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Od,this.updateRanges=[],this.version=0,this.uuid=is()}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,n){e*=this.stride,n*=t.stride;for(let r=0,o=this.stride;re.far||t.push({distance:h,point:ed.clone(),uv:Br.getInterpolation(ed,Am,nd,Cm,e1,Wv,t1,new Ce),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 Rm(i,e,t,n,r,o){yf.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(td.x=o*yf.x-r*yf.y,td.y=r*yf.x+o*yf.y):td.copy(yf),i.copy(e),i.x+=td.x,i.y+=td.y,i.applyMatrix4(qE)}const bm=new j,n1=new j;class KE extends dn{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,r=t.length;n0){let n,r;for(n=1,r=t.length;n0){bm.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(bm);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){bm.setFromMatrixPosition(e.matrixWorld),n1.setFromMatrixPosition(this.matrixWorld);const n=bm.distanceTo(n1)/e.zoom;t[0].object.visible=!0;let r,o;for(r=1,o=t.length;r=a)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(n,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||nP.getNormalMatrix(e),r=this.coplanarPoint(Yv).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),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 pu=new sr,Lm=new j;class ip{constructor(e=new gl,t=new gl,n=new gl,r=new gl,o=new gl,a=new gl){this.planes=[e,t,n,r,o,a]}set(e,t,n,r,o,a){const u=this.planes;return u[0].copy(e),u[1].copy(t),u[2].copy(n),u[3].copy(r),u[4].copy(o),u[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=So){const n=this.planes,r=e.elements,o=r[0],a=r[1],u=r[2],h=r[3],p=r[4],m=r[5],g=r[6],v=r[7],x=r[8],w=r[9],A=r[10],E=r[11],S=r[12],b=r[13],P=r[14],I=r[15];if(n[0].setComponents(h-o,v-p,E-x,I-S).normalize(),n[1].setComponents(h+o,v+p,E+x,I+S).normalize(),n[2].setComponents(h+a,v+m,E+w,I+b).normalize(),n[3].setComponents(h-a,v-m,E-w,I-b).normalize(),n[4].setComponents(h-u,v-g,E-A,I-P).normalize(),t===So)n[5].setComponents(h+u,v+g,E+A,I+P).normalize();else if(t===kd)n[5].setComponents(u,g,A,P).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(),pu.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),pu.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(pu)}intersectsSprite(e){return pu.center.set(0,0,0),pu.radius=.7071067811865476,pu.applyMatrix4(e.matrixWorld),this.intersectsSphere(pu)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(n)0?e.max.x:e.min.x,Lm.y=r.normal.y>0?e.max.y:e.min.y,Lm.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Lm)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function qv(i,e){return i-e}function iP(i,e){return i.z-e.z}function rP(i,e){return e.z-i.z}class sP{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){const o=this.pool,a=this.list;this.index>=o.length&&o.push({start:-1,count:-1,z:-1,index:-1});const u=o[this.index];a.push(u),this.index++,u.start=e,u.count=t,u.z=n,u.index=r}reset(){this.list.length=0,this.index=0}}const Fr=new Ft,oP=new et(1,1,1),Zv=new ip,Dm=new Sr,mu=new sr,sd=new j,f1=new j,aP=new j,Kv=new sP,tr=new Qn,Nm=[];function lP(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let o=0;o65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new Tn(o,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 n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),o=t.getAttribute(n);if(r.itemSize!==o.itemSize||r.normalized!==o.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 Sr);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(qv),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;Fr.identity().toArray(o.image.data,r*16),o.needsUpdate=!0;const a=this._colorsTexture;return a&&(oP.toArray(a.image.data,r*4),a.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-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},o=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),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(qv),h=this._availableGeometryIds.shift(),o[h]=r):(h=this._geometryCount,this._geometryCount++,o.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 n=this.geometry,r=n.getIndex()!==null,o=n.getIndex(),a=t.getIndex(),u=this._geometryInfo[e];if(r&&a.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 m in n.attributes){const g=t.getAttribute(m),v=n.getAttribute(m);lP(g,v,h);const x=g.itemSize;for(let w=g.count,A=p;w=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let r=0,o=n.length;ru).sort((a,u)=>n[a].vertexStart-n[u].vertexStart),o=this.geometry;for(let a=0,u=n.length;a=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const o=new Sr,a=n.index,u=n.attributes.position;for(let h=r.start,p=r.start+r.count;h=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const o=new sr;this.getBoundingBoxAt(e,Dm),Dm.getCenter(o.center);const a=n.index,u=n.attributes.position;let h=0;for(let p=r.start,m=r.start+r.count;pu.active);if(Math.max(...n.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(...n.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 o=this.geometry;o.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Yt,this._initializeGeometry(o));const a=this.geometry;o.index&&gu(o.index.array,a.index.array);for(const u in o.attributes)gu(o.attributes[u].array,a.attributes[u].array)}raycast(e,t){const n=this._instanceInfo,r=this._geometryInfo,o=this.matrixWorld,a=this.geometry;tr.material=this.material,tr.geometry.index=a.index,tr.geometry.attributes=a.attributes,tr.geometry.boundingBox===null&&(tr.geometry.boundingBox=new Sr),tr.geometry.boundingSphere===null&&(tr.geometry.boundingSphere=new sr);for(let u=0,h=n.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._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.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(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,o){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),u=a===null?1:a.array.BYTES_PER_ELEMENT,h=this._instanceInfo,p=this._multiDrawStarts,m=this._multiDrawCounts,g=this._geometryInfo,v=this.perObjectFrustumCulled,x=this._indirectTexture,w=x.image.data;v&&(Fr.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Zv.setFromProjectionMatrix(Fr,e.coordinateSystem));let A=0;if(this.sortObjects){Fr.copy(this.matrixWorld).invert(),sd.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Fr),f1.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Fr);for(let b=0,P=h.length;b0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;on)return;Jv.applyMatrix4(i.matrixWorld);const h=e.ray.origin.distanceTo(Jv);if(!(he.far))return{distance:h,point:d1.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const p1=new j,m1=new j;class Po extends _l{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,n=[];for(let r=0,o=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;or.far)return;o.push({distance:p,distanceToRay:Math.sqrt(u),point:h,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Rf extends dn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class uP extends Wn{constructor(e,t,n,r,o,a,u,h,p){super(e,t,n,r,o,a,u,h,p),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:yi,this.magFilter=o!==void 0?o:yi,this.generateMipmaps=!1;const m=this;function g(){m.needsUpdate=!0,e.requestVideoFrameCallback(g)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(g)}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)}}class cP extends Wn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Wi,this.minFilter=Wi,this.generateMipmaps=!1,this.needsUpdate=!0}}class E0 extends Wn{constructor(e,t,n,r,o,a,u,h,p,m,g,v){super(null,a,u,h,p,m,r,o,g,v),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class fP extends E0{constructor(e,t,n,r,o,a){super(e,t,n,o,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Es,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class hP extends E0{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,wa),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class dP extends Wn{constructor(e,t,n,r,o,a,u,h,p){super(e,t,n,r,o,a,u,h,p),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Y_ extends Wn{constructor(e,t,n,r,o,a,u,h,p,m=Fu){if(m!==Fu&&m!==Gu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&m===Fu&&(n=Ea),n===void 0&&m===Gu&&(n=Hu),super(null,r,o,a,u,h,m,n,p),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=u!==void 0?u:Wi,this.minFilter=h!==void 0?h:Wi,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class to{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),o=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),o+=n.distanceTo(r),t.push(o),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const o=n.length;let a;t?a=t:a=e*n[o-1];let u=0,h=o-1,p;for(;u<=h;)if(r=Math.floor(u+(h-u)/2),p=n[r]-a,p<0)u=r+1;else if(p>0)h=r-1;else{h=r;break}if(r=h,n[r]===a)return r/(o-1);const m=n[r],v=n[r+1]-m,x=(a-m)/v;return(r+x)/(o-1)}getTangent(e,t){let r=e-1e-4,o=e+1e-4;r<0&&(r=0),o>1&&(o=1);const a=this.getPoint(r),u=this.getPoint(o),h=t||(a.isVector2?new Ce:new j);return h.copy(u).sub(a).normalize(),h}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new j,r=[],o=[],a=[],u=new j,h=new Ft;for(let x=0;x<=e;x++){const w=x/e;r[x]=this.getTangentAt(w,new j)}o[0]=new j,a[0]=new j;let p=Number.MAX_VALUE;const m=Math.abs(r[0].x),g=Math.abs(r[0].y),v=Math.abs(r[0].z);m<=p&&(p=m,n.set(1,0,0)),g<=p&&(p=g,n.set(0,1,0)),v<=p&&n.set(0,0,1),u.crossVectors(r[0],n).normalize(),o[0].crossVectors(r[0],u),a[0].crossVectors(r[0],o[0]);for(let x=1;x<=e;x++){if(o[x]=o[x-1].clone(),a[x]=a[x-1].clone(),u.crossVectors(r[x-1],r[x]),u.length()>Number.EPSILON){u.normalize();const w=Math.acos(Wt(r[x-1].dot(r[x]),-1,1));o[x].applyMatrix4(h.makeRotationAxis(u,w))}a[x].crossVectors(r[x],o[x])}if(t===!0){let x=Math.acos(Wt(o[0].dot(o[e]),-1,1));x/=e,r[0].dot(u.crossVectors(o[0],o[e]))>0&&(x=-x);for(let w=1;w<=e;w++)o[w].applyMatrix4(h.makeRotationAxis(r[w],x*w)),a[w].crossVectors(r[w],o[w])}return{tangents:r,normals:o,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class T0 extends to{constructor(e=0,t=0,n=1,r=1,o=0,a=Math.PI*2,u=!1,h=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=o,this.aEndAngle=a,this.aClockwise=u,this.aRotation=h}getPoint(e,t=new Ce){const n=t,r=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const a=Math.abs(o)r;)o-=r;o0?0:(Math.floor(Math.abs(u)/o)+1)*o:h===0&&u===o-1&&(u=o-2,h=1);let p,m;this.closed||u>0?p=r[(u-1)%o]:(Bm.subVectors(r[0],r[1]).add(r[0]),p=Bm);const g=r[u%o],v=r[(u+1)%o];if(this.closed||u+2r.length-2?r.length-1:a+1],g=r[a>r.length-3?r.length-1:a+2];return n.set(y1(u,h.x,p.x,m.x,g.x),y1(u,h.y,p.y,m.y,g.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[o]-n,u=this.curves[o],h=u.getLength(),p=h===0?0:1-a/h;return u.getPointAt(p,t)}o++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const g=p.getPoint(0);g.equals(this.currentPoint)||this.lineTo(g.x,g.y)}this.curves.push(p);const m=p.getPoint(1);return this.currentPoint.copy(m),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 rp extends Yt{constructor(e=[new Ce(0,-.5),new Ce(.5,0),new Ce(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Wt(r,0,Math.PI*2);const o=[],a=[],u=[],h=[],p=[],m=1/t,g=new j,v=new Ce,x=new j,w=new j,A=new j;let E=0,S=0;for(let b=0;b<=e.length-1;b++)switch(b){case 0:E=e[b+1].x-e[b].x,S=e[b+1].y-e[b].y,x.x=S*1,x.y=-E,x.z=S*0,A.copy(x),x.normalize(),h.push(x.x,x.y,x.z);break;case e.length-1:h.push(A.x,A.y,A.z);break;default:E=e[b+1].x-e[b].x,S=e[b+1].y-e[b].y,x.x=S*1,x.y=-E,x.z=S*0,w.copy(x),x.x+=A.x,x.y+=A.y,x.z+=A.z,x.normalize(),h.push(x.x,x.y,x.z),A.copy(w)}for(let b=0;b<=t;b++){const P=n+b*m*r,I=Math.sin(P),B=Math.cos(P);for(let F=0;F<=e.length-1;F++){g.x=e[F].x*I,g.y=e[F].y,g.z=e[F].x*B,a.push(g.x,g.y,g.z),v.x=b/t,v.y=F/(e.length-1),u.push(v.x,v.y);const V=h[3*F+0]*I,H=h[3*F+1],U=h[3*F+0]*B;p.push(V,H,U)}}for(let b=0;b0&&P(!0),t>0&&P(!1)),this.setIndex(m),this.setAttribute("position",new vt(g,3)),this.setAttribute("normal",new vt(v,3)),this.setAttribute("uv",new vt(x,2));function b(){const I=new j,B=new j;let F=0;const V=(t-e)/n;for(let H=0;H<=o;H++){const U=[],D=H/o,W=D*(t-e)+e;for(let se=0;se<=r;se++){const ie=se/r,fe=ie*h+u,Me=Math.sin(fe),ue=Math.cos(fe);B.x=W*Me,B.y=-D*n+E,B.z=W*ue,g.push(B.x,B.y,B.z),I.set(Me,V,ue).normalize(),v.push(I.x,I.y,I.z),x.push(ie,1-D),U.push(w++)}A.push(U)}for(let H=0;H0||U!==0)&&(m.push(D,W,ie),F+=3),(t>0||U!==o-1)&&(m.push(W,se,ie),F+=3)}p.addGroup(S,F,0),S+=F}function P(I){const B=w,F=new Ce,V=new j;let H=0;const U=I===!0?e:t,D=I===!0?1:-1;for(let se=1;se<=r;se++)g.push(0,E*D,0),v.push(0,D,0),x.push(.5,.5),w++;const W=w;for(let se=0;se<=r;se++){const fe=se/r*h+u,Me=Math.cos(fe),ue=Math.sin(fe);V.x=U*ue,V.y=E*D,V.z=U*Me,g.push(V.x,V.y,V.z),v.push(0,D,0),F.x=Me*.5+.5,F.y=ue*.5*D+.5,x.push(F.x,F.y),w++}for(let se=0;se.9&&V<.1&&(P<.2&&(a[b+0]+=1),I<.2&&(a[b+2]+=1),B<.2&&(a[b+4]+=1))}}function v(b){o.push(b.x,b.y,b.z)}function x(b,P){const I=b*3;P.x=e[I+0],P.y=e[I+1],P.z=e[I+2]}function w(){const b=new j,P=new j,I=new j,B=new j,F=new Ce,V=new Ce,H=new Ce;for(let U=0,D=0;U80*t){u=p=i[0],h=m=i[1];for(let w=t;wp&&(p=g),v>m&&(m=v);x=Math.max(p-u,m-h),x=x!==0?32767/x:0}return Vd(o,a,t,u,h,x,0),a}};function lT(i,e,t,n,r){let o,a;if(r===OP(i,e,t,n)>0)for(o=e;o=e;o-=n)a=_1(o,i[o],i[o+1],a);return a&&P0(a,a.next)&&(Gd(a),a=a.next),a}function ju(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(P0(t,t.next)||Hn(t.prev,t,t.next)===0)){if(Gd(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Vd(i,e,t,n,r,o,a){if(!i)return;!a&&o&&IP(i,n,r,o);let u=i,h,p;for(;i.prev!==i.next;){if(h=i.prev,p=i.next,o?wP(i,n,r,o):MP(i)){e.push(h.i/t|0),e.push(i.i/t|0),e.push(p.i/t|0),Gd(i),i=p.next,u=p.next;continue}if(i=p,i===u){a?a===1?(i=EP(ju(i),e,t),Vd(i,e,t,n,r,o,2)):a===2&&TP(i,e,t,n,r,o):Vd(ju(i),e,t,n,r,o,1);break}}}function MP(i){const e=i.prev,t=i,n=i.next;if(Hn(e,t,n)>=0)return!1;const r=e.x,o=t.x,a=n.x,u=e.y,h=t.y,p=n.y,m=ro?r>a?r:a:o>a?o:a,x=u>h?u>p?u:p:h>p?h:p;let w=n.next;for(;w!==e;){if(w.x>=m&&w.x<=v&&w.y>=g&&w.y<=x&&bf(r,u,o,h,a,p,w.x,w.y)&&Hn(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function wP(i,e,t,n){const r=i.prev,o=i,a=i.next;if(Hn(r,o,a)>=0)return!1;const u=r.x,h=o.x,p=a.x,m=r.y,g=o.y,v=a.y,x=uh?u>p?u:p:h>p?h:p,E=m>g?m>v?m:v:g>v?g:v,S=Ky(x,w,e,t,n),b=Ky(A,E,e,t,n);let P=i.prevZ,I=i.nextZ;for(;P&&P.z>=S&&I&&I.z<=b;){if(P.x>=x&&P.x<=A&&P.y>=w&&P.y<=E&&P!==r&&P!==a&&bf(u,m,h,g,p,v,P.x,P.y)&&Hn(P.prev,P,P.next)>=0||(P=P.prevZ,I.x>=x&&I.x<=A&&I.y>=w&&I.y<=E&&I!==r&&I!==a&&bf(u,m,h,g,p,v,I.x,I.y)&&Hn(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;P&&P.z>=S;){if(P.x>=x&&P.x<=A&&P.y>=w&&P.y<=E&&P!==r&&P!==a&&bf(u,m,h,g,p,v,P.x,P.y)&&Hn(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;I&&I.z<=b;){if(I.x>=x&&I.x<=A&&I.y>=w&&I.y<=E&&I!==r&&I!==a&&bf(u,m,h,g,p,v,I.x,I.y)&&Hn(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function EP(i,e,t){let n=i;do{const r=n.prev,o=n.next.next;!P0(r,o)&&uT(r,n,n.next,o)&&Hd(r,o)&&Hd(o,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(o.i/t|0),Gd(n),Gd(n.next),n=i=o),n=n.next}while(n!==i);return ju(n)}function TP(i,e,t,n,r,o){let a=i;do{let u=a.next.next;for(;u!==a.prev;){if(a.i!==u.i&&NP(a,u)){let h=cT(a,u);a=ju(a,a.next),h=ju(h,h.next),Vd(a,e,t,n,r,o,0),Vd(h,e,t,n,r,o,0);return}u=u.next}a=a.next}while(a!==i)}function AP(i,e,t,n){const r=[];let o,a,u,h,p;for(o=0,a=e.length;o=t.next.y&&t.next.y!==t.y){const v=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=o&&v>n&&(n=v,r=t.x=t.x&&t.x>=h&&o!==t.x&&bf(ar.x||t.x===r.x&&PP(r,t)))&&(r=t,m=g)),t=t.next;while(t!==u);return r}function PP(i,e){return Hn(i.prev,i,e.prev)<0&&Hn(e.next,i,i.next)<0}function IP(i,e,t,n){let r=i;do r.z===0&&(r.z=Ky(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,LP(r)}function LP(i){let e,t,n,r,o,a,u,h,p=1;do{for(t=i,i=null,o=null,a=0;t;){for(a++,n=t,u=0,e=0;e0||h>0&&n;)u!==0&&(h===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,u--):(r=n,n=n.nextZ,h--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;t=n}o.nextZ=null,p*=2}while(a>1);return i}function Ky(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function DP(i){let e=i,t=i;do(e.x=(i-a)*(o-u)&&(i-a)*(n-u)>=(t-a)*(e-u)&&(t-a)*(o-u)>=(r-a)*(n-u)}function NP(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!UP(i,e)&&(Hd(i,e)&&Hd(e,i)&&FP(i,e)&&(Hn(i.prev,i,e.prev)||Hn(i,e.prev,e))||P0(i,e)&&Hn(i.prev,i,i.next)>0&&Hn(e.prev,e,e.next)>0)}function Hn(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function P0(i,e){return i.x===e.x&&i.y===e.y}function uT(i,e,t,n){const r=Wm(Hn(i,e,t)),o=Wm(Hn(i,e,n)),a=Wm(Hn(t,n,i)),u=Wm(Hn(t,n,e));return!!(r!==o&&a!==u||r===0&&Gm(i,t,e)||o===0&&Gm(i,n,e)||a===0&&Gm(t,i,n)||u===0&&Gm(t,e,n))}function Gm(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Wm(i){return i>0?1:i<0?-1:0}function UP(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&uT(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Hd(i,e){return Hn(i.prev,i,i.next)<0?Hn(i,e,i.next)>=0&&Hn(i,i.prev,e)>=0:Hn(i,e,i.prev)<0||Hn(i,i.next,e)<0}function FP(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function cT(i,e){const t=new Jy(i.i,i.x,i.y),n=new Jy(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function _1(i,e,t,n){const r=new Jy(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Gd(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Jy(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function OP(i,e,t,n){let r=0;for(let o=e,a=t-n;o2&&i[e-1].equals(i[0])&&i.pop()}function S1(i,e){for(let t=0;tNumber.EPSILON){const Ee=Math.sqrt(k),Le=Math.sqrt(je*je+X*X),Ae=Ne.x-Et/Ee,mt=Ne.y+Ge/Ee,Ye=Y.x-X/Le,st=Y.y+je/Le,Ht=((Ye-Ae)*X-(st-mt)*je)/(Ge*X-Et*je);yt=Ae+Ge*Ht-Pe.x,ke=mt+Et*Ht-Pe.y;const Be=yt*yt+ke*ke;if(Be<=2)return new Ce(yt,ke);rt=Math.sqrt(Be/2)}else{let Ee=!1;Ge>Number.EPSILON?je>Number.EPSILON&&(Ee=!0):Ge<-Number.EPSILON?je<-Number.EPSILON&&(Ee=!0):Math.sign(Et)===Math.sign(X)&&(Ee=!0),Ee?(yt=-Et,ke=Ge,rt=Math.sqrt(k)):(yt=Ge,ke=Et,rt=Math.sqrt(k/2))}return new Ce(yt/rt,ke/rt)}const J=[];for(let Pe=0,Ne=fe.length,Y=Ne-1,yt=Pe+1;Pe=0;Pe--){const Ne=Pe/E,Y=x*Math.cos(Ne*Math.PI/2),yt=w*Math.sin(Ne*Math.PI/2)+A;for(let ke=0,rt=fe.length;ke=0;){const yt=Y;let ke=Y-1;ke<0&&(ke=Pe.length-1);for(let rt=0,Ge=m+E*2;rt0)&&x.push(P,I,F),(S!==n-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 pT extends Xi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new et(16777215),this.specular=new et(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ss,this.combine=$d,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 mT extends Xi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new et(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new Ce(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 gT extends Xi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new Ce(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 vT extends Xi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new et(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ss,this.combine=$d,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 nx extends Xi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=PE,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 ix extends Xi{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 yT extends Xi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new et(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.flatShading=e.flatShading,this.fog=e.fog,this}}class _T extends Mr{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 Du(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function xT(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ST(i){function e(r,o){return i[r]-i[o]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Qy(i,e,t){const n=i.length,r=new i.constructor(n);for(let o=0,a=0;a!==n;++o){const u=t[o]*e;for(let h=0;h!==e;++h)r[a++]=i[u+h]}return r}function rx(i,e,t,n){let r=1,o=i[0];for(;o!==void 0&&o[n]===void 0;)o=i[r++];if(o===void 0)return;let a=o[n];if(a!==void 0)if(Array.isArray(a))do a=o[n],a!==void 0&&(e.push(o.time),t.push.apply(t,a)),o=i[r++];while(o!==void 0);else if(a.toArray!==void 0)do a=o[n],a!==void 0&&(e.push(o.time),a.toArray(t,t.length)),o=i[r++];while(o!==void 0);else do a=o[n],a!==void 0&&(e.push(o.time),t.push(a)),o=i[r++];while(o!==void 0)}function VP(i,e,t,n,r=30){const o=i.clone();o.name=e;const a=[];for(let h=0;h=n)){g.push(p.times[x]);for(let A=0;Ao.tracks[h].times[0]&&(u=o.tracks[h].times[0]);for(let h=0;h=u.times[w]){const S=w*g+m,b=S+g-m;A=u.values.slice(S,b)}else{const S=u.createInterpolant(),b=m,P=g-m;S.evaluate(o),A=S.resultBuffer.slice(b,P)}h==="quaternion"&&new Vr().fromArray(A).normalize().conjugate().toArray(A);const E=p.times.length;for(let S=0;S=o)){const u=t[1];e=o)break t}a=n,n=0;break n}break e}for(;n>>1;et;)--a;if(++a,o!==0||a!==r){o>=a&&(a=Math.max(a,1),o=a-1);const u=this.getValueSize();this.times=n.slice(o,a),this.values=this.values.slice(o*u,a*u)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,o=n.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let u=0;u!==o;u++){const h=n[u];if(typeof h=="number"&&isNaN(h)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,u,h),e=!1;break}if(a!==null&&a>h){console.error("THREE.KeyframeTrack: Out of order keys.",this,u,h,a),e=!1;break}a=h}if(r!==void 0&&xT(r))for(let u=0,h=r.length;u!==h;++u){const p=r[u];if(isNaN(p)){console.error("THREE.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(),n=this.getValueSize(),r=this.getInterpolation()===og,o=e.length-1;let a=1;for(let u=1;u0){e[a]=e[o];for(let u=o*n,h=a*n,p=0;p!==n;++p)t[h+p]=t[u+p];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}no.prototype.TimeBufferType=Float32Array;no.prototype.ValueBufferType=Float32Array;no.prototype.DefaultInterpolation=qg;class Zu extends no{constructor(e,t,n){super(e,t,n)}}Zu.prototype.ValueTypeName="bool";Zu.prototype.ValueBufferType=Array;Zu.prototype.DefaultInterpolation=Nd;Zu.prototype.InterpolantFactoryMethodLinear=void 0;Zu.prototype.InterpolantFactoryMethodSmooth=void 0;class ox extends no{}ox.prototype.ValueTypeName="color";class Wd extends no{}Wd.prototype.ValueTypeName="number";class ET extends lp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,u=this.valueSize,h=(n-t)/(r-t);let p=e*u;for(let m=p+u;p!==m;p+=4)Vr.slerpFlat(o,0,a,p-u,a,p,h);return o}}class up extends no{InterpolantFactoryMethodLinear(e){return new ET(this.times,this.values,this.getValueSize(),e)}}up.prototype.ValueTypeName="quaternion";up.prototype.InterpolantFactoryMethodSmooth=void 0;class Ku extends no{constructor(e,t,n){super(e,t,n)}}Ku.prototype.ValueTypeName="string";Ku.prototype.ValueBufferType=Array;Ku.prototype.DefaultInterpolation=Nd;Ku.prototype.InterpolantFactoryMethodLinear=void 0;Ku.prototype.InterpolantFactoryMethodSmooth=void 0;class Xd extends no{}Xd.prototype.ValueTypeName="vector";class jd{constructor(e="",t=-1,n=[],r=y0){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=is(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,u=n.length;a!==u;++a)t.push(XP(n[a]).scale(r));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let o=0,a=n.length;o!==a;++o)t.push(no.toJSON(n[o]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const o=t.length,a=[];for(let u=0;u1){const g=m[1];let v=r[g];v||(r[g]=v=[]),v.push(p)}}const a=[];for(const u in r)a.push(this.CreateFromMorphTargetSequence(u,r[u],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(g,v,x,w,A){if(x.length!==0){const E=[],S=[];rx(x,E,S,w),E.length!==0&&A.push(new g(v,E,S))}},r=[],o=e.name||"default",a=e.fps||30,u=e.blendMode;let h=e.length||-1;const p=e.hierarchy||[];for(let g=0;g{t&&t(o),this.manager.itemEnd(e)},0),o;if(ma[e]!==void 0){ma[e].push({onLoad:t,onProgress:n,onError:r});return}ma[e]=[],ma[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),u=this.mimeType,h=this.responseType;fetch(a).then(p=>{if(p.status===200||p.status===0){if(p.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||p.body===void 0||p.body.getReader===void 0)return p;const m=ma[e],g=p.body.getReader(),v=p.headers.get("X-File-Size")||p.headers.get("Content-Length"),x=v?parseInt(v):0,w=x!==0;let A=0;const E=new ReadableStream({start(S){b();function b(){g.read().then(({done:P,value:I})=>{if(P)S.close();else{A+=I.byteLength;const B=new ProgressEvent("progress",{lengthComputable:w,loaded:A,total:x});for(let F=0,V=m.length;F{S.error(P)})}}});return new Response(E)}else throw new jP(`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(m=>new DOMParser().parseFromString(m,u));case"json":return p.json();default:if(u===void 0)return p.text();{const g=/charset="?([^;"\s]*)"?/i.exec(u),v=g&&g[1]?g[1].toLowerCase():void 0,x=new TextDecoder(v);return p.arrayBuffer().then(w=>x.decode(w))}}}).then(p=>{ya.add(e,p);const m=ma[e];delete ma[e];for(let g=0,v=m.length;g{const m=ma[e];if(m===void 0)throw this.manager.itemError(e),p;delete ma[e];for(let g=0,v=m.length;g{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class YP extends Hr{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new Ta(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(u){try{t(o.parse(JSON.parse(u)))}catch(h){r?r(h):console.error(h),o.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const o in e.uniforms){const a=e.uniforms[o];switch(r.uniforms[o]={},a.type){case"t":r.uniforms[o].value=n(a.value);break;case"c":r.uniforms[o].value=new et().setHex(a.value);break;case"v2":r.uniforms[o].value=new Ce().fromArray(a.value);break;case"v3":r.uniforms[o].value=new j().fromArray(a.value);break;case"v4":r.uniforms[o].value=new hn().fromArray(a.value);break;case"m3":r.uniforms[o].value=new jt().fromArray(a.value);break;case"m4":r.uniforms[o].value=new Ft().fromArray(a.value);break;default:r.uniforms[o].value=a.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 o in e.extensions)r.extensions[o]=e.extensions[o];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=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let o=e.normalScale;Array.isArray(o)===!1&&(o=[o,o]),r.normalScale=new Ce().fromArray(o)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(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=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Ce().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return k0.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:hT,SpriteMaterial:W_,RawShaderMaterial:ex,ShaderMaterial:Ii,PointsMaterial:j_,MeshPhysicalMaterial:dT,MeshStandardMaterial:tx,MeshPhongMaterial:pT,MeshToonMaterial:mT,MeshNormalMaterial:gT,MeshLambertMaterial:vT,MeshDepthMaterial:nx,MeshDistanceMaterial:ix,MeshBasicMaterial:Ca,MeshMatcapMaterial:yT,LineDashedMaterial:_T,LineBasicMaterial:Mr,Material:Xi};return new t[e]}}class $y{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n0){const h=new ax(t);o=new Yd(h),o.setCrossOrigin(this.crossOrigin);for(let p=0,m=e.length;p0){r=new Yd(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,u=e.length;a{const E=new Sr;E.min.fromArray(A.boxMin),E.max.fromArray(A.boxMax);const S=new sr;return S.radius=A.sphereRadius,S.center.fromArray(A.sphereCenter),{boxInitialized:A.boxInitialized,box:E,sphereInitialized:A.sphereInitialized,sphere:S}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=p(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=p(e.colorsTexture.uuid));break;case"LOD":a=new KE;break;case"Line":a=new _l(u(e.geometry),h(e.material));break;case"LineLoop":a=new eT(u(e.geometry),h(e.material));break;case"LineSegments":a=new Po(u(e.geometry),h(e.material));break;case"PointCloud":case"Points":a=new tT(u(e.geometry),h(e.material));break;case"Sprite":a=new ZE(h(e.material));break;case"Group":a=new Rf;break;case"Bone":a=new X_;break;default:a=new dn}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const v=e.children;for(let x=0;x"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=ya.get(e);if(a!==void 0){if(o.manager.itemStart(e),a.then){a.then(p=>{t&&t(p),o.manager.itemEnd(e)}).catch(p=>{r&&r(p)});return}return setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a}const u={};u.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",u.headers=this.requestHeader;const h=fetch(e,u).then(function(p){return p.blob()}).then(function(p){return createImageBitmap(p,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(p){return ya.add(e,p),t&&t(p),o.manager.itemEnd(e),p}).catch(function(p){r&&r(p),ya.remove(e),o.manager.itemError(e),o.manager.itemEnd(e)});ya.add(e,h),o.manager.itemStart(e)}}let Xm;class ux{static getContext(){return Xm===void 0&&(Xm=new(window.AudioContext||window.webkitAudioContext)),Xm}static setContext(e){Xm=e}}class r2 extends Hr{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new Ta(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(h){try{const p=h.slice(0);ux.getContext().decodeAudioData(p,function(g){t(g)}).catch(u)}catch(p){u(p)}},n,r);function u(h){r?r(h):console.error(h),o.manager.itemError(e)}}}const b1=new Ft,P1=new Ft,vu=new Ft;class s2{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Pi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Pi,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,vu.copy(e.projectionMatrix);const r=t.eyeSep/2,o=r*t.near/t.focus,a=t.near*Math.tan(Ou*t.fov*.5)/t.zoom;let u,h;P1.elements[12]=-r,b1.elements[12]=r,u=-a*t.aspect+o,h=a*t.aspect+o,vu.elements[0]=2*t.near/(h-u),vu.elements[8]=(h+u)/(h-u),this.cameraL.projectionMatrix.copy(vu),u=-a*t.aspect-o,h=a*t.aspect-o,vu.elements[0]=2*t.near/(h-u),vu.elements[8]=(h+u)/(h-u),this.cameraR.projectionMatrix.copy(vu)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(P1),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(b1)}}class FT extends Pi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class cp{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=I1(),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=I1();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function I1(){return performance.now()}const yu=new j,L1=new Vr,o2=new j,_u=new j;class a2 extends dn{constructor(){super(),this.type="AudioListener",this.context=ux.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new cp}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,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(yu,L1,o2),_u.set(0,0,-1).applyQuaternion(L1),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(yu.x,r),t.positionY.linearRampToValueAtTime(yu.y,r),t.positionZ.linearRampToValueAtTime(yu.z,r),t.forwardX.linearRampToValueAtTime(_u.x,r),t.forwardY.linearRampToValueAtTime(_u.y,r),t.forwardZ.linearRampToValueAtTime(_u.z,r),t.upX.linearRampToValueAtTime(n.x,r),t.upY.linearRampToValueAtTime(n.y,r),t.upZ.linearRampToValueAtTime(n.z,r)}else t.setPosition(yu.x,yu.y,yu.z),t.setOrientation(_u.x,_u.y,_u.z,n.x,n.y,n.z)}}class OT extends dn{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){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.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){console.warn("THREE.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){console.warn("THREE.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(n,r,this._addIndex*t,1,t);for(let h=t,p=t+t;h!==p;++h)if(n[h]!==n[h+t]){u.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let o=n,a=r;o!==a;++o)t[o]=t[r+o%n];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 n=e;n=.5)for(let a=0;a!==o;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){Vr.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,o){const a=this._workIndex*o;Vr.multiplyQuaternionsFlat(e,a,e,t,e,n),Vr.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,o){const a=1-r;for(let u=0;u!==o;++u){const h=t+u;e[h]=e[h]*a+e[n+u]*r}}_lerpAdditive(e,t,n,r,o){for(let a=0;a!==o;++a){const u=t+a;e[u]=e[u]+e[n+a]*r}}}const cx="\\[\\]\\.:\\/",f2=new RegExp("["+cx+"]","g"),fx="[^"+cx+"]",h2="[^"+cx.replace("\\.","")+"]",d2=/((?:WC+[\/:])*)/.source.replace("WC",fx),p2=/(WCOD+)?/.source.replace("WCOD",h2),m2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fx),g2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fx),v2=new RegExp("^"+d2+p2+m2+g2+"$"),y2=["material","materials","bones","map"];class _2{constructor(e,t,n){const r=n||fn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=n.length;r!==o;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class fn{constructor(e,t,n){this.path=t,this.parsedPath=n||fn.parseTrackName(t),this.node=fn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new fn.Composite(e,t,n):new fn(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(f2,"")}static parseTrackName(e){const t=v2.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const o=n.nodeName.substring(r+1);y2.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(o){for(let a=0;a=o){const g=o++,v=e[g];t[v.uuid]=m,e[m]=v,t[p]=g,e[g]=h;for(let x=0,w=r;x!==w;++x){const A=n[x],E=A[g],S=A[m];A[m]=E,A[g]=S}}}this.nCachedObjects_=o}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let o=this.nCachedObjects_,a=e.length;for(let u=0,h=arguments.length;u!==h;++u){const p=arguments[u],m=p.uuid,g=t[m];if(g!==void 0)if(delete t[m],g0&&(t[x.uuid]=g),e[g]=x,e.pop();for(let w=0,A=r;w!==A;++w){const E=n[w];E[g]=E[v],E.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const o=this._bindings;if(r!==void 0)return o[r];const a=this._paths,u=this._parsedPaths,h=this._objects,p=h.length,m=this.nCachedObjects_,g=new Array(p);r=o.length,n[e]=r,a.push(e),u.push(t),o.push(g);for(let v=m,x=h.length;v!==x;++v){const w=h[v];g[v]=new fn(w,e,t)}return g}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,o=this._parsedPaths,a=this._bindings,u=a.length-1,h=a[u],p=e[u];t[p]=n,a[n]=h,a.pop(),o[n]=o[u],o.pop(),r[n]=r[u],r.pop()}}}class BT{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const o=t.tracks,a=o.length,u=new Array(a),h={endingStart:Pu,endingEnd:Pu};for(let p=0;p!==a;++p){const m=o[p].createInterpolant(null);u[p]=m,m.settings=h}this._interpolantSettings=h,this._interpolants=u,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=RE,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,n){if(e.fadeOut(t),this.fadeIn(t),n){const r=this._clip.duration,o=e._clip.duration,a=o/r,u=r/o;e.warp(1,a,t),this.warp(u,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}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,n){const r=this._mixer,o=r.time,a=this.timeScale;let u=this._timeScaleInterpolant;u===null&&(u=r._lendControlInterpolant(),this._timeScaleInterpolant=u);const h=u.parameterPositions,p=u.sampleValues;return h[0]=o,h[1]=o+n,p[0]=e/a,p[1]=t/a,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,n,r){if(!this.enabled){this._updateWeight(e);return}const o=this._startTime;if(o!==null){const h=(e-o)*n;h<0||n===0?t=0:(this._startTime=null,t=n*h)}t*=this._updateTimeScale(e);const a=this._updateTime(t),u=this._updateWeight(e);if(u>0){const h=this._interpolants,p=this._propertyBindings;switch(this.blendMode){case k_:for(let m=0,g=h.length;m!==g;++m)h[m].evaluate(a),p[m].accumulateAdditive(u);break;case y0:default:for(let m=0,g=h.length;m!==g;++m)h[m].evaluate(a),p[m].accumulate(r,u)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.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 n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,o=this._loopCount;const a=n===bE;if(e===0)return o===-1?r:a&&(o&1)===1?t-r:r;if(n===CE){o===-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(o===-1&&(e>=0?(o=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const u=Math.floor(r/t);r-=t*u,o+=Math.abs(u);const h=this.repetitions-o;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,a)}else this._setEndings(!1,!1,a);this._loopCount=o,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:u})}}else this.time=r;if(a&&(o&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=Iu,r.endingEnd=Iu):(e?r.endingStart=this.zeroSlopeAtStart?Iu:Pu:r.endingStart=Ud,t?r.endingEnd=this.zeroSlopeAtEnd?Iu:Pu:r.endingEnd=Ud)}_scheduleFading(e,t,n){const r=this._mixer,o=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const u=a.parameterPositions,h=a.sampleValues;return u[0]=o,h[0]=t,u[1]=o+e,h[1]=n,this}}const S2=new Float32Array(1);class M2 extends bo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,o=r.length,a=e._propertyBindings,u=e._interpolants,h=n.uuid,p=this._bindingsByRootAndName;let m=p[h];m===void 0&&(m={},p[h]=m);for(let g=0;g!==o;++g){const v=r[g],x=v.name;let w=m[x];if(w!==void 0)++w.referenceCount,a[g]=w;else{if(w=a[g],w!==void 0){w._cacheIndex===null&&(++w.referenceCount,this._addInactiveBinding(w,h,x));continue}const A=t&&t._propertyBindings[g].binding.parsedPath;w=new kT(fn.create(n,x,A),v.ValueTypeName,v.getValueSize()),++w.referenceCount,this._addInactiveBinding(w,h,x),a[g]=w}u[g].resultBuffer=w.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,o=this._actionsByClip[r];this._bindAction(e,o&&o.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const o=t[n];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const o=t[n];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}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;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,o=Math.sign(e),a=this._accuIndex^=1;for(let p=0;p!==n;++p)t[p]._update(r,e,o,a);const u=this._bindings,h=this._nActiveBindings;for(let p=0;p!==h;++p)u[p].apply(a);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,F1).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 O1=new j,jm=new j;class P2{constructor(e=new j,t=new j){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){O1.subVectors(e,this.start),jm.subVectors(this.end,this.start);const n=jm.dot(jm);let o=jm.dot(O1)/n;return t&&(o=Wt(o,0,1)),o}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}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 k1=new j;class I2 extends dn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Yt,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 a=0,u=1,h=32;a1)for(let g=0;g.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{G1.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(G1,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class W2 extends Po{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Yt;r.setAttribute("position",new vt(t,3)),r.setAttribute("color",new vt(n,3));const o=new Mr({vertexColors:!0,toneMapped:!1});super(r,o),this.type="AxesHelper"}setColors(e,t,n){const r=new et,o=this.geometry.attributes.color.array;return r.set(e),r.toArray(o,0),r.toArray(o,3),r.set(t),r.toArray(o,6),r.toArray(o,9),r.set(n),r.toArray(o,12),r.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class X2{constructor(){this.type="ShapePath",this.color=new et,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new zd,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,o,a){return this.currentPath.bezierCurveTo(e,t,n,r,o,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(S){const b=[];for(let P=0,I=S.length;PNumber.EPSILON){if(D<0&&(V=b[F],U=-U,H=b[B],D=-D),S.yH.y)continue;if(S.y===V.y){if(S.x===V.x)return!0}else{const W=D*(S.x-V.x)-U*(S.y-V.y);if(W===0)return!0;if(W<0)continue;I=!I}}else{if(S.y!==V.y)continue;if(H.x<=S.x&&S.x<=V.x||V.x<=S.x&&S.x<=H.x)return!0}}return I}const r=Ao.isClockWise,o=this.subPaths;if(o.length===0)return[];let a,u,h;const p=[];if(o.length===1)return u=o[0],h=new Bu,h.curves=u.curves,p.push(h),p;let m=!r(o[0].getPoints());m=e?!m:m;const g=[],v=[];let x=[],w=0,A;v[w]=void 0,x[w]=[];for(let S=0,b=o.length;S1){let S=!1,b=0;for(let P=0,I=v.length;P0&&S===!1&&(x=g)}let E;for(let S=0,b=v.length;Se?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function q2(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function Z2(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function t_(i,e,t,n){const r=K2(n);switch(t){case L_:return i*e;case N_:return i*e;case U_:return i*e*2;case m0:return i*e/r.components*r.byteLength;case ep:return i*e/r.components*r.byteLength;case F_:return i*e*2/r.components*r.byteLength;case g0:return i*e*2/r.components*r.byteLength;case D_:return i*e*3/r.components*r.byteLength;case ir:return i*e*4/r.components*r.byteLength;case v0:return i*e*4/r.components*r.byteLength;case yd:case _d:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case xd:case Sd:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case wg:case Tg:return Math.max(i,16)*Math.max(e,8)/4;case Mg:case Eg:return Math.max(i,8)*Math.max(e,8)/2;case Ag:case Cg:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Rg:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case bg:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Pg:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Ig:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Lg:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Dg:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Ng:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Ug:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Fg:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Og:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case kg:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Bg:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case zg:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Vg:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Hg:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Md:case Gg:case Wg:return Math.ceil(i/4)*Math.ceil(e/4)*16;case O_:case Xg:return Math.ceil(i/4)*Math.ceil(e/4)*8;case jg:case Yg:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function K2(i){switch(i){case eo:case b_:return{byteLength:1,components:1};case kf:case P_:case Eo:return{byteLength:2,components:1};case d0:case p0:return{byteLength:2,components:4};case Ea:case h0:case zr:return{byteLength:4,components:1};case I_:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}const J2={contain:Y2,cover:q2,fill:Z2,getByteLength:t_};class Q2 extends xr{constructor(e=1,t=1,n=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:l0}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=l0);/** * @license * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT */function HT(){let i=null,e=!1,t=null,n=null;function r(o,a){t(o,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){i=o}}}function $2(i){const e=new WeakMap;function t(u,h){const p=u.array,m=u.usage,g=p.byteLength,v=i.createBuffer();i.bindBuffer(h,v),i.bufferData(h,p,m),u.onUploadCallback();let x;if(p instanceof Float32Array)x=i.FLOAT;else if(p instanceof Uint16Array)u.isFloat16BufferAttribute?x=i.HALF_FLOAT:x=i.UNSIGNED_SHORT;else if(p instanceof Int16Array)x=i.SHORT;else if(p instanceof Uint32Array)x=i.UNSIGNED_INT;else if(p instanceof Int32Array)x=i.INT;else if(p instanceof Int8Array)x=i.BYTE;else if(p instanceof Uint8Array)x=i.UNSIGNED_BYTE;else if(p instanceof Uint8ClampedArray)x=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+p);return{buffer:v,type:x,bytesPerElement:p.BYTES_PER_ELEMENT,version:u.version,size:g}}function n(u,h,p){const m=h.array,g=h.updateRanges;if(i.bindBuffer(p,u),g.length===0)i.bufferSubData(p,0,m);else{g.sort((x,w)=>x.start-w.start);let v=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`,gI=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,vI=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,yI=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,_I=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,xI=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,SI=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,MI=`#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`,wI=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,EI=`#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`,TI=`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`,AI=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,CI=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,RI=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,bI=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,PI="gl_FragColor = linearToOutputTexel( gl_FragColor );",II=`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 ); }`,LI=`#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`,DI=`#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`,NI=`#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`,UI=`#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`,FI=`#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`,OI=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,kI=`#ifdef USE_FOG varying float vFogDepth; #endif`,BI=`#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`,zI=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,VI=`#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 }`,HI=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,GI=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,WI=`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`,XI=`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`,jI=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,YI=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,qI=`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`,ZI=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,KI=`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`,JI=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,QI=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,$I=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,eL=`#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`,tL=`#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`,nL=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,iL=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,rL=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,sL=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,oL=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,aL=`#ifdef USE_MAP uniform sampler2D map; #endif`,lL=`#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`,uL=`#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`,cL=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,fL=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,hL=`#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`,dL=`#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`,pL=`#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`,mL=`#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`,gL=`#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`,vL=`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;`,yL=`#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`,_L=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,xL=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,SL=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,ML=`#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`,wL=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,EL=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,TL=`#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`,AL=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,CL=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,RL=`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 ); }`,bL=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,PL=`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;`,IL=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,LL=`#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`,DL=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,NL=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,UL=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,FL=`#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`,OL=`#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`,kL=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,BL=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,zL=`#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`,VL=`#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`,HL=`#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`,GL=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,WL=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,XL=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,jL=`#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; }`,YL=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,qL=`#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`,ZL=`#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`,KL=`#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`,JL=`#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`,QL=`#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 $L=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,e3=`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 }`,t3=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,n3=`#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 }`,i3=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,r3=`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 }`,s3=`#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; }`,o3=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,a3=`#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; }`,l3=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,u3=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,c3=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,f3=`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 }`,h3=`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 }`,d3=`#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 }`,p3=`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 }`,m3=`#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 }`,g3=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,v3=`#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; }`,y3=`#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 }`,_3=`#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 }`,x3=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,S3=`#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 }`,M3=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,w3=`#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 }`,E3=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,T3=`#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 }`,A3=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,C3=`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 }`,R3=`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 }`,b3=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,P3=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,I3=`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 }`,L3=`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:eI,alphahash_pars_fragment:tI,alphamap_fragment:nI,alphamap_pars_fragment:iI,alphatest_fragment:rI,alphatest_pars_fragment:sI,aomap_fragment:oI,aomap_pars_fragment:aI,batching_pars_vertex:lI,batching_vertex:uI,begin_vertex:cI,beginnormal_vertex:fI,bsdfs:hI,iridescence_fragment:dI,bumpmap_pars_fragment:pI,clipping_planes_fragment:mI,clipping_planes_pars_fragment:gI,clipping_planes_pars_vertex:vI,clipping_planes_vertex:yI,color_fragment:_I,color_pars_fragment:xI,color_pars_vertex:SI,color_vertex:MI,common:wI,cube_uv_reflection_fragment:EI,defaultnormal_vertex:TI,displacementmap_pars_vertex:AI,displacementmap_vertex:CI,emissivemap_fragment:RI,emissivemap_pars_fragment:bI,colorspace_fragment:PI,colorspace_pars_fragment:II,envmap_fragment:LI,envmap_common_pars_fragment:DI,envmap_pars_fragment:NI,envmap_pars_vertex:UI,envmap_physical_pars_fragment:jI,envmap_vertex:FI,fog_vertex:OI,fog_pars_vertex:kI,fog_fragment:BI,fog_pars_fragment:zI,gradientmap_pars_fragment:VI,lightmap_pars_fragment:HI,lights_lambert_fragment:GI,lights_lambert_pars_fragment:WI,lights_pars_begin:XI,lights_toon_fragment:YI,lights_toon_pars_fragment:qI,lights_phong_fragment:ZI,lights_phong_pars_fragment:KI,lights_physical_fragment:JI,lights_physical_pars_fragment:QI,lights_fragment_begin:$I,lights_fragment_maps:eL,lights_fragment_end:tL,logdepthbuf_fragment:nL,logdepthbuf_pars_fragment:iL,logdepthbuf_pars_vertex:rL,logdepthbuf_vertex:sL,map_fragment:oL,map_pars_fragment:aL,map_particle_fragment:lL,map_particle_pars_fragment:uL,metalnessmap_fragment:cL,metalnessmap_pars_fragment:fL,morphinstance_vertex:hL,morphcolor_vertex:dL,morphnormal_vertex:pL,morphtarget_pars_vertex:mL,morphtarget_vertex:gL,normal_fragment_begin:vL,normal_fragment_maps:yL,normal_pars_fragment:_L,normal_pars_vertex:xL,normal_vertex:SL,normalmap_pars_fragment:ML,clearcoat_normal_fragment_begin:wL,clearcoat_normal_fragment_maps:EL,clearcoat_pars_fragment:TL,iridescence_pars_fragment:AL,opaque_fragment:CL,packing:RL,premultiplied_alpha_fragment:bL,project_vertex:PL,dithering_fragment:IL,dithering_pars_fragment:LL,roughnessmap_fragment:DL,roughnessmap_pars_fragment:NL,shadowmap_pars_fragment:UL,shadowmap_pars_vertex:FL,shadowmap_vertex:OL,shadowmask_pars_fragment:kL,skinbase_vertex:BL,skinning_pars_vertex:zL,skinning_vertex:VL,skinnormal_vertex:HL,specularmap_fragment:GL,specularmap_pars_fragment:WL,tonemapping_fragment:XL,tonemapping_pars_fragment:jL,transmission_fragment:YL,transmission_pars_fragment:qL,uv_pars_fragment:ZL,uv_pars_vertex:KL,uv_vertex:JL,worldpos_vertex:QL,background_vert:$L,background_frag:e3,backgroundCube_vert:t3,backgroundCube_frag:n3,cube_vert:i3,cube_frag:r3,depth_vert:s3,depth_frag:o3,distanceRGBA_vert:a3,distanceRGBA_frag:l3,equirect_vert:u3,equirect_frag:c3,linedashed_vert:f3,linedashed_frag:h3,meshbasic_vert:d3,meshbasic_frag:p3,meshlambert_vert:m3,meshlambert_frag:g3,meshmatcap_vert:v3,meshmatcap_frag:y3,meshnormal_vert:_3,meshnormal_frag:x3,meshphong_vert:S3,meshphong_frag:M3,meshphysical_vert:w3,meshphysical_frag:E3,meshtoon_vert:T3,meshtoon_frag:A3,points_vert:C3,points_frag:R3,shadow_vert:b3,shadow_frag:P3,sprite_vert:I3,sprite_frag:L3},Qe={common:{diffuse:{value:new et(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new jt},alphaMap:{value:null},alphaMapTransform:{value:new jt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new jt}},envmap:{envMap:{value:null},envMapRotation:{value:new jt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new jt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new jt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new jt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new jt},normalScale:{value:new Ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new jt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new jt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new jt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new jt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new et(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 et(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new jt},alphaTest:{value:0},uvTransform:{value:new jt}},sprite:{diffuse:{value:new et(16777215)},opacity:{value:1},center:{value:new Ce(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new jt},alphaMap:{value:null},alphaMapTransform:{value:new jt},alphaTest:{value:0}}},$s={basic:{uniforms:vr([Qe.common,Qe.specularmap,Qe.envmap,Qe.aomap,Qe.lightmap,Qe.fog]),vertexShader:en.meshbasic_vert,fragmentShader:en.meshbasic_frag},lambert:{uniforms:vr([Qe.common,Qe.specularmap,Qe.envmap,Qe.aomap,Qe.lightmap,Qe.emissivemap,Qe.bumpmap,Qe.normalmap,Qe.displacementmap,Qe.fog,Qe.lights,{emissive:{value:new et(0)}}]),vertexShader:en.meshlambert_vert,fragmentShader:en.meshlambert_frag},phong:{uniforms:vr([Qe.common,Qe.specularmap,Qe.envmap,Qe.aomap,Qe.lightmap,Qe.emissivemap,Qe.bumpmap,Qe.normalmap,Qe.displacementmap,Qe.fog,Qe.lights,{emissive:{value:new et(0)},specular:{value:new et(1118481)},shininess:{value:30}}]),vertexShader:en.meshphong_vert,fragmentShader:en.meshphong_frag},standard:{uniforms:vr([Qe.common,Qe.envmap,Qe.aomap,Qe.lightmap,Qe.emissivemap,Qe.bumpmap,Qe.normalmap,Qe.displacementmap,Qe.roughnessmap,Qe.metalnessmap,Qe.fog,Qe.lights,{emissive:{value:new et(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:en.meshphysical_vert,fragmentShader:en.meshphysical_frag},toon:{uniforms:vr([Qe.common,Qe.aomap,Qe.lightmap,Qe.emissivemap,Qe.bumpmap,Qe.normalmap,Qe.displacementmap,Qe.gradientmap,Qe.fog,Qe.lights,{emissive:{value:new et(0)}}]),vertexShader:en.meshtoon_vert,fragmentShader:en.meshtoon_frag},matcap:{uniforms:vr([Qe.common,Qe.bumpmap,Qe.normalmap,Qe.displacementmap,Qe.fog,{matcap:{value:null}}]),vertexShader:en.meshmatcap_vert,fragmentShader:en.meshmatcap_frag},points:{uniforms:vr([Qe.points,Qe.fog]),vertexShader:en.points_vert,fragmentShader:en.points_frag},dashed:{uniforms:vr([Qe.common,Qe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:en.linedashed_vert,fragmentShader:en.linedashed_frag},depth:{uniforms:vr([Qe.common,Qe.displacementmap]),vertexShader:en.depth_vert,fragmentShader:en.depth_frag},normal:{uniforms:vr([Qe.common,Qe.bumpmap,Qe.normalmap,Qe.displacementmap,{opacity:{value:1}}]),vertexShader:en.meshnormal_vert,fragmentShader:en.meshnormal_frag},sprite:{uniforms:vr([Qe.sprite,Qe.fog]),vertexShader:en.sprite_vert,fragmentShader:en.sprite_frag},background:{uniforms:{uvTransform:{value:new jt},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 jt}},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},distanceRGBA:{uniforms:vr([Qe.common,Qe.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:en.distanceRGBA_vert,fragmentShader:en.distanceRGBA_frag},shadow:{uniforms:vr([Qe.lights,Qe.fog,{color:{value:new et(0)},opacity:{value:1}}]),vertexShader:en.shadow_vert,fragmentShader:en.shadow_frag}};$s.physical={uniforms:vr([$s.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new jt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new jt},clearcoatNormalScale:{value:new Ce(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new jt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new jt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new jt},sheen:{value:0},sheenColor:{value:new et(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new jt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new jt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new jt},transmissionSamplerSize:{value:new Ce},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new jt},attenuationDistance:{value:0},attenuationColor:{value:new et(0)},specularColor:{value:new et(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new jt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new jt},anisotropyVector:{value:new Ce},anisotropyMap:{value:null},anisotropyMapTransform:{value:new jt}}]),vertexShader:en.meshphysical_vert,fragmentShader:en.meshphysical_frag};const Qm={r:0,b:0,g:0},Mu=new ss,D3=new Ft;function N3(i,e,t,n,r,o,a){const u=new et(0);let h=o===!0?0:1,p,m,g=null,v=0,x=null;function w(P){let I=P.isScene===!0?P.background:null;return I&&I.isTexture&&(I=(P.backgroundBlurriness>0?t:e).get(I)),I}function A(P){let I=!1;const B=w(P);B===null?S(u,h):B&&B.isColor&&(S(B,1),I=!0);const F=i.xr.getEnvironmentBlendMode();F==="additive"?n.buffers.color.setClear(0,0,0,1,a):F==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function E(P,I){const B=w(I);B&&(B.isCubeTexture||B.mapping===Yf)?(m===void 0&&(m=new Qn(new qu(1,1,1),new Ii({name:"BackgroundCubeMaterial",uniforms:zf($s.backgroundCube.uniforms),vertexShader:$s.backgroundCube.vertexShader,fragmentShader:$s.backgroundCube.fragmentShader,side:_r,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(F,V,H){this.matrixWorld.copyPosition(H.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),Mu.copy(I.backgroundRotation),Mu.x*=-1,Mu.y*=-1,Mu.z*=-1,B.isCubeTexture&&B.isRenderTargetTexture===!1&&(Mu.y*=-1,Mu.z*=-1),m.material.uniforms.envMap.value=B,m.material.uniforms.flipEnvMap.value=B.isCubeTexture&&B.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(D3.makeRotationFromEuler(Mu)),m.material.toneMapped=ln.getTransfer(B.colorSpace)!==_n,(g!==B||v!==B.version||x!==i.toneMapping)&&(m.material.needsUpdate=!0,g=B,v=B.version,x=i.toneMapping),m.layers.enableAll(),P.unshift(m,m.geometry,m.material,0,0,null)):B&&B.isTexture&&(p===void 0&&(p=new Qn(new Kf(2,2),new Ii({name:"BackgroundMaterial",uniforms:zf($s.background.uniforms),vertexShader:$s.background.vertexShader,fragmentShader:$s.background.fragmentShader,side:Ma,depthTest:!1,depthWrite:!1,fog:!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=B,p.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,p.material.toneMapped=ln.getTransfer(B.colorSpace)!==_n,B.matrixAutoUpdate===!0&&B.updateMatrix(),p.material.uniforms.uvTransform.value.copy(B.matrix),(g!==B||v!==B.version||x!==i.toneMapping)&&(p.material.needsUpdate=!0,g=B,v=B.version,x=i.toneMapping),p.layers.enableAll(),P.unshift(p,p.geometry,p.material,0,0,null))}function S(P,I){P.getRGB(Qm,XE(i)),n.buffers.color.setClear(Qm.r,Qm.g,Qm.b,I,a)}function b(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),p!==void 0&&(p.geometry.dispose(),p.material.dispose())}return{getClearColor:function(){return u},setClearColor:function(P,I=1){u.set(P),h=I,S(u,h)},getClearAlpha:function(){return h},setClearAlpha:function(P){h=P,S(u,h)},render:A,addToRenderList:E,dispose:b}}function U3(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=v(null);let o=r,a=!1;function u(D,W,se,ie,fe){let Me=!1;const ue=g(ie,se,W);o!==ue&&(o=ue,p(o.object)),Me=x(D,ie,se,fe),Me&&w(D,ie,se,fe),fe!==null&&e.update(fe,i.ELEMENT_ARRAY_BUFFER),(Me||a)&&(a=!1,I(D,W,se,ie),fe!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(fe).buffer))}function h(){return i.createVertexArray()}function p(D){return i.bindVertexArray(D)}function m(D){return i.deleteVertexArray(D)}function g(D,W,se){const ie=se.wireframe===!0;let fe=n[D.id];fe===void 0&&(fe={},n[D.id]=fe);let Me=fe[W.id];Me===void 0&&(Me={},fe[W.id]=Me);let ue=Me[ie];return ue===void 0&&(ue=v(h()),Me[ie]=ue),ue}function v(D){const W=[],se=[],ie=[];for(let fe=0;fe=0){const K=fe[O];let G=Me[O];if(G===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(G=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(G=D.instanceColor)),K===void 0||K.attribute!==G||G&&K.data!==G.data)return!0;ue++}return o.attributesNum!==ue||o.index!==ie}function w(D,W,se,ie){const fe={},Me=W.attributes;let ue=0;const ye=se.getAttributes();for(const O in ye)if(ye[O].location>=0){let K=Me[O];K===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(K=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(K=D.instanceColor));const G={};G.attribute=K,K&&K.data&&(G.data=K.data),fe[O]=G,ue++}o.attributes=fe,o.attributesNum=ue,o.index=ie}function A(){const D=o.newAttributes;for(let W=0,se=D.length;W=0){let J=fe[ye];if(J===void 0&&(ye==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),ye==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const K=J.normalized,G=J.itemSize,ee=e.get(J);if(ee===void 0)continue;const De=ee.buffer,le=ee.type,xe=ee.bytesPerElement,be=le===i.INT||le===i.UNSIGNED_INT||J.gpuType===h0;if(J.isInterleavedBufferAttribute){const Te=J.data,We=Te.stride,tt=J.offset;if(Te.isInstancedInterleavedBuffer){for(let ht=0;ht0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";V="mediump"}return V==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let p=t.precision!==void 0?t.precision:"highp";const m=h(p);m!==p&&(console.warn("THREE.WebGLRenderer:",p,"not supported, using",m,"instead."),p=m);const g=t.logarithmicDepthBuffer===!0,v=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),x=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),w=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),A=i.getParameter(i.MAX_TEXTURE_SIZE),E=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),S=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),P=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),B=w>0,F=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:h,textureFormatReadable:a,textureTypeReadable:u,precision:p,logarithmicDepthBuffer:g,reverseDepthBuffer:v,maxTextures:x,maxVertexTextures:w,maxTextureSize:A,maxCubemapSize:E,maxAttributes:S,maxVertexUniforms:b,maxVaryings:P,maxFragmentUniforms:I,vertexTextures:B,maxSamples:F}}function k3(i){const e=this;let t=null,n=0,r=!1,o=!1;const a=new gl,u=new jt,h={value:null,needsUpdate:!1};this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(g,v){const x=g.length!==0||v||n!==0||r;return r=v,n=g.length,x},this.beginShadows=function(){o=!0,m(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(g,v){t=m(g,v,0)},this.setState=function(g,v,x){const w=g.clippingPlanes,A=g.clipIntersection,E=g.clipShadows,S=i.get(g);if(!r||w===null||w.length===0||o&&!E)o?m(null):p();else{const b=o?0:n,P=b*4;let I=S.clippingState||null;h.value=I,I=m(w,v,P,x);for(let B=0;B!==P;++B)I[B]=t[B];S.clippingState=I,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=b}};function p(){h.value!==t&&(h.value=t,h.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function m(g,v,x,w){const A=g!==null?g.length:0;let E=null;if(A!==0){if(E=h.value,w!==!0||E===null){const S=x+A*4,b=v.matrixWorldInverse;u.getNormalMatrix(b),(E===null||E.length0){const p=new YE(h.height);return p.fromEquirectangularTexture(i,a),e.set(a,p),a.addEventListener("dispose",r),t(p.texture,a.mapping)}else return null}}return a}function r(a){const u=a.target;u.removeEventListener("dispose",r);const h=e.get(u);h!==void 0&&(e.delete(u),h.dispose())}function o(){e=new WeakMap}return{get:n,dispose:o}}const Pf=4,W1=[.125,.215,.35,.446,.526,.582],bu=20,oy=new Jf,X1=new et;let ay=null,ly=0,uy=0,cy=!1;const Au=(1+Math.sqrt(5))/2,xf=1/Au,j1=[new j(-Au,xf,0),new j(Au,xf,0),new j(-xf,0,Au),new j(xf,0,Au),new j(0,Au,-xf),new j(0,Au,xf),new j(-1,1,-1),new j(1,1,-1),new j(-1,1,1),new j(1,1,1)];class n_{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){ay=this._renderer.getRenderTarget(),ly=this._renderer.getActiveCubeFace(),uy=this._renderer.getActiveMipmapLevel(),cy=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,r,o),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Z1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=q1(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?P:0,P,P),m.setRenderTarget(r),A&&m.render(w,u),m.render(e,u)}w.geometry.dispose(),w.material.dispose(),m.toneMapping=v,m.autoClear=g,e.background=E}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===wa||e.mapping===yl;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Z1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=q1());const o=r?this._cubemapMaterial:this._equirectMaterial,a=new Qn(this._lodPlanes[0],o),u=o.uniforms;u.envMap.value=e;const h=this._cubeSize;$m(t,0,0,3*h,2*h),n.setRenderTarget(t),n.render(a,oy)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let o=1;obu&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${E} samples when the maximum is set to ${bu}`);const S=[];let b=0;for(let V=0;VP-Pf?r-P+Pf:0),F=4*(this._cubeSize-I);$m(t,B,F,3*I,2*I),h.setRenderTarget(t),h.render(g,oy)}}function z3(i){const e=[],t=[],n=[];let r=i;const o=i-Pf+1+W1.length;for(let a=0;ai-Pf?h=W1[a-i+Pf-1]:a===0&&(h=0),n.push(h);const p=1/(u-2),m=-p,g=1+p,v=[m,m,g,m,g,g,m,m,g,g,m,g],x=6,w=6,A=3,E=2,S=1,b=new Float32Array(A*w*x),P=new Float32Array(E*w*x),I=new Float32Array(S*w*x);for(let F=0;F2?0:-1,U=[V,H,0,V+2/3,H,0,V+2/3,H+1,0,V,H,0,V+2/3,H+1,0,V,H+1,0];b.set(U,A*w*F),P.set(v,E*w*F);const D=[F,F,F,F,F,F];I.set(D,S*w*F)}const B=new Yt;B.setAttribute("position",new Tn(b,A)),B.setAttribute("uv",new Tn(P,E)),B.setAttribute("faceIndex",new Tn(I,S)),e.push(B),r>Pf&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Y1(i,e,t){const n=new xr(i,e,t);return n.texture.mapping=Yf,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function $m(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function V3(i,e,t){const n=new Float32Array(bu),r=new j(0,1,0);return new Ii({name:"SphericalGaussianBlur",defines:{n:bu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:px(),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:Mo,depthTest:!1,depthWrite:!1})}function q1(){return new Ii({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:px(),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:Mo,depthTest:!1,depthWrite:!1})}function Z1(){return new Ii({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:px(),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:Mo,depthTest:!1,depthWrite:!1})}function px(){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 H3(i){let e=new WeakMap,t=null;function n(u){if(u&&u.isTexture){const h=u.mapping,p=h===Pd||h===Id,m=h===wa||h===yl;if(p||m){let g=e.get(u);const v=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==v)return t===null&&(t=new n_(i)),g=p?t.fromEquirectangular(u,g):t.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,e.set(u,g),g.texture;if(g!==void 0)return g.texture;{const x=u.image;return p&&x&&x.height>0||m&&x&&r(x)?(t===null&&(t=new n_(i)),g=p?t.fromEquirectangular(u):t.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,e.set(u,g),u.addEventListener("dispose",o),g.texture):null}}}return u}function r(u){let h=0;const p=6;for(let m=0;me.maxTextureSize&&(B=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const F=new Float32Array(I*B*4*g),V=new _0(F,I,B,g);V.type=zr,V.needsUpdate=!0;const H=P*4;for(let D=0;D0)return i;const r=e*t;let o=J1[r];if(o===void 0&&(o=new Float32Array(r),J1[r]=o),e!==0){n.toArray(o,0);for(let a=1,u=0;a!==e;++a)u+=t,i[a].toArray(o,u)}return o}function _i(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t":" "} ${u}: ${t[a]}`)}return n.join(` `)}const rM=new jt;function HD(i){ln._getMatrix(rM,ln.workingColorSpace,i);const e=`mat3( ${rM.elements.map(t=>t.toFixed(4))} )`;switch(ln.getTransfer(i)){case Fd:return[e,"LinearTransferOETF"];case _n:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function sM(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const a=parseInt(o[1]);return t.toUpperCase()+` `+r+` `+VD(i.getShaderSource(e),a)}else return r}function GD(i,e){const t=HD(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}function WD(i,e){let t;switch(e){case w_:t="Linear";break;case E_:t="Reinhard";break;case T_:t="Cineon";break;case c0:t="ACESFilmic";break;case A_:t="AgX";break;case C_:t="Neutral";break;case TE:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const eg=new j;function XD(){ln.getLuminanceCoefficients(eg);const i=eg.x.toFixed(4),e=eg.y.toFixed(4),t=eg.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function jD(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(hd).join(` `)}function YD(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function qD(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function i_(i){return i.replace(ZD,JD)}const KD=new Map;function JD(i,e){let t=en[e];if(t===void 0){const n=KD.get(e);if(n!==void 0)t=en[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return i_(t)}const QD=/#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 lM(i){return i.replace(QD,$D)}function $D(i,e,t,n){let r="";for(let o=parseInt(e);o0&&(E+=` `),S=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(hd).join(` `),S.length>0&&(S+=` `)):(E=[uM(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,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 "+m:"",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_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(hd).join(` `),S=[uM(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,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 "+m:"",t.envMap?"#define "+g:"",v?"#define CUBEUV_TEXEL_WIDTH "+v.texelWidth:"",v?"#define CUBEUV_TEXEL_HEIGHT "+v.texelHeight:"",v?"#define CUBEUV_MAX_MIP "+v.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_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==wo?"#define TONE_MAPPING":"",t.toneMapping!==wo?en.tonemapping_pars_fragment:"",t.toneMapping!==wo?WD("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",en.colorspace_pars_fragment,GD("linearToOutputTexel",t.outputColorSpace),XD(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(hd).join(` `)),a=i_(a),a=oM(a,t),a=aM(a,t),u=i_(u),u=oM(u,t),u=aM(u,t),a=lM(a),u=lM(u),t.isRawShaderMaterial!==!0&&(b=`#version 300 es `,E=[x,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+E,S=["#define varying in",t.glslVersion===qy?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===qy?"":"#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(` `)+` `+S);const P=b+E+a,I=b+S+u,B=iM(r,r.VERTEX_SHADER,P),F=iM(r,r.FRAGMENT_SHADER,I);r.attachShader(A,B),r.attachShader(A,F),t.index0AttributeName!==void 0?r.bindAttribLocation(A,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(A,0,"position"),r.linkProgram(A);function V(W){if(i.debug.checkShaderErrors){const se=r.getProgramInfoLog(A).trim(),ie=r.getShaderInfoLog(B).trim(),fe=r.getShaderInfoLog(F).trim();let Me=!0,ue=!0;if(r.getProgramParameter(A,r.LINK_STATUS)===!1)if(Me=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,A,B,F);else{const ye=sM(r,B,"vertex"),O=sM(r,F,"fragment");console.error("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: `+se+` `+ye+` `+O)}else se!==""?console.warn("THREE.WebGLProgram: Program Info Log:",se):(ie===""||fe==="")&&(ue=!1);ue&&(W.diagnostics={runnable:Me,programLog:se,vertexShader:{log:ie,prefix:E},fragmentShader:{log:fe,prefix:S}})}r.deleteShader(B),r.deleteShader(F),H=new ag(r,A),U=qD(r,A)}let H;this.getUniforms=function(){return H===void 0&&V(this),H};let U;this.getAttributes=function(){return U===void 0&&V(this),U};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=r.getProgramParameter(A,BD)),D},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(A),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=zD++,this.cacheKey=e,this.usedTimes=1,this.program=A,this.vertexShader=B,this.fragmentShader=F,this}let oN=0;class aN{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),o=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(o)===!1&&(a.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new lN(e),t.set(e,n)),n}}class lN{constructor(e){this.id=oN++,this.code=e,this.usedTimes=0}}function uN(i,e,t,n,r,o,a){const u=new ku,h=new aN,p=new Set,m=[],g=r.logarithmicDepthBuffer,v=r.vertexTextures;let x=r.precision;const w={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function A(U){return p.add(U),U===0?"uv":`uv${U}`}function E(U,D,W,se,ie){const fe=se.fog,Me=ie.geometry,ue=U.isMeshStandardMaterial?se.environment:null,ye=(U.isMeshStandardMaterial?t:e).get(U.envMap||ue),O=ye&&ye.mapping===Yf?ye.image.height:null,J=w[U.type];U.precision!==null&&(x=r.getMaxPrecision(U.precision),x!==U.precision&&console.warn("THREE.WebGLProgram.getParameters:",U.precision,"not supported, using",x,"instead."));const K=Me.morphAttributes.position||Me.morphAttributes.normal||Me.morphAttributes.color,G=K!==void 0?K.length:0;let ee=0;Me.morphAttributes.position!==void 0&&(ee=1),Me.morphAttributes.normal!==void 0&&(ee=2),Me.morphAttributes.color!==void 0&&(ee=3);let De,le,xe,be;if(J){const sn=$s[J];De=sn.vertexShader,le=sn.fragmentShader}else De=U.vertexShader,le=U.fragmentShader,h.update(U),xe=h.getVertexShaderID(U),be=h.getFragmentShaderID(U);const Te=i.getRenderTarget(),We=i.state.buffers.depth.getReversed(),tt=ie.isInstancedMesh===!0,ht=ie.isBatchedMesh===!0,It=!!U.map,Pe=!!U.matcap,Ne=!!ye,Y=!!U.aoMap,yt=!!U.lightMap,ke=!!U.bumpMap,rt=!!U.normalMap,Ge=!!U.displacementMap,Et=!!U.emissiveMap,je=!!U.metalnessMap,X=!!U.roughnessMap,k=U.anisotropy>0,he=U.clearcoat>0,Ee=U.dispersion>0,Le=U.iridescence>0,Ae=U.sheen>0,mt=U.transmission>0,Ye=k&&!!U.anisotropyMap,st=he&&!!U.clearcoatMap,Ht=he&&!!U.clearcoatNormalMap,Be=he&&!!U.clearcoatRoughnessMap,ct=Le&&!!U.iridescenceMap,Tt=Le&&!!U.iridescenceThicknessMap,Lt=Ae&&!!U.sheenColorMap,ft=Ae&&!!U.sheenRoughnessMap,nn=!!U.specularMap,Ot=!!U.specularColorMap,pn=!!U.specularIntensityMap,re=mt&&!!U.transmissionMap,Ze=mt&&!!U.thicknessMap,Se=!!U.gradientMap,Re=!!U.alphaMap,$e=U.alphaTest>0,Ke=!!U.alphaHash,kt=!!U.extensions;let An=wo;U.toneMapped&&(Te===null||Te.isXRRenderTarget===!0)&&(An=i.toneMapping);const Xn={shaderID:J,shaderType:U.type,shaderName:U.name,vertexShader:De,fragmentShader:le,defines:U.defines,customVertexShaderID:xe,customFragmentShaderID:be,isRawShaderMaterial:U.isRawShaderMaterial===!0,glslVersion:U.glslVersion,precision:x,batching:ht,batchingColor:ht&&ie._colorsTexture!==null,instancing:tt,instancingColor:tt&&ie.instanceColor!==null,instancingMorph:tt&&ie.morphTexture!==null,supportsVertexTextures:v,outputColorSpace:Te===null?i.outputColorSpace:Te.isXRRenderTarget===!0?Te.texture.colorSpace:Wu,alphaToCoverage:!!U.alphaToCoverage,map:It,matcap:Pe,envMap:Ne,envMapMode:Ne&&ye.mapping,envMapCubeUVHeight:O,aoMap:Y,lightMap:yt,bumpMap:ke,normalMap:rt,displacementMap:v&&Ge,emissiveMap:Et,normalMapObjectSpace:rt&&U.normalMapType===LE,normalMapTangentSpace:rt&&U.normalMapType===Ml,metalnessMap:je,roughnessMap:X,anisotropy:k,anisotropyMap:Ye,clearcoat:he,clearcoatMap:st,clearcoatNormalMap:Ht,clearcoatRoughnessMap:Be,dispersion:Ee,iridescence:Le,iridescenceMap:ct,iridescenceThicknessMap:Tt,sheen:Ae,sheenColorMap:Lt,sheenRoughnessMap:ft,specularMap:nn,specularColorMap:Ot,specularIntensityMap:pn,transmission:mt,transmissionMap:re,thicknessMap:Ze,gradientMap:Se,opaque:U.transparent===!1&&U.blending===Uu&&U.alphaToCoverage===!1,alphaMap:Re,alphaTest:$e,alphaHash:Ke,combine:U.combine,mapUv:It&&A(U.map.channel),aoMapUv:Y&&A(U.aoMap.channel),lightMapUv:yt&&A(U.lightMap.channel),bumpMapUv:ke&&A(U.bumpMap.channel),normalMapUv:rt&&A(U.normalMap.channel),displacementMapUv:Ge&&A(U.displacementMap.channel),emissiveMapUv:Et&&A(U.emissiveMap.channel),metalnessMapUv:je&&A(U.metalnessMap.channel),roughnessMapUv:X&&A(U.roughnessMap.channel),anisotropyMapUv:Ye&&A(U.anisotropyMap.channel),clearcoatMapUv:st&&A(U.clearcoatMap.channel),clearcoatNormalMapUv:Ht&&A(U.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Be&&A(U.clearcoatRoughnessMap.channel),iridescenceMapUv:ct&&A(U.iridescenceMap.channel),iridescenceThicknessMapUv:Tt&&A(U.iridescenceThicknessMap.channel),sheenColorMapUv:Lt&&A(U.sheenColorMap.channel),sheenRoughnessMapUv:ft&&A(U.sheenRoughnessMap.channel),specularMapUv:nn&&A(U.specularMap.channel),specularColorMapUv:Ot&&A(U.specularColorMap.channel),specularIntensityMapUv:pn&&A(U.specularIntensityMap.channel),transmissionMapUv:re&&A(U.transmissionMap.channel),thicknessMapUv:Ze&&A(U.thicknessMap.channel),alphaMapUv:Re&&A(U.alphaMap.channel),vertexTangents:!!Me.attributes.tangent&&(rt||k),vertexColors:U.vertexColors,vertexAlphas:U.vertexColors===!0&&!!Me.attributes.color&&Me.attributes.color.itemSize===4,pointsUvs:ie.isPoints===!0&&!!Me.attributes.uv&&(It||Re),fog:!!fe,useFog:U.fog===!0,fogExp2:!!fe&&fe.isFogExp2,flatShading:U.flatShading===!0,sizeAttenuation:U.sizeAttenuation===!0,logarithmicDepthBuffer:g,reverseDepthBuffer:We,skinning:ie.isSkinnedMesh===!0,morphTargets:Me.morphAttributes.position!==void 0,morphNormals:Me.morphAttributes.normal!==void 0,morphColors:Me.morphAttributes.color!==void 0,morphTargetsCount:G,morphTextureStride:ee,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:U.dithering,shadowMapEnabled:i.shadowMap.enabled&&W.length>0,shadowMapType:i.shadowMap.type,toneMapping:An,decodeVideoTexture:It&&U.map.isVideoTexture===!0&&ln.getTransfer(U.map.colorSpace)===_n,decodeVideoTextureEmissive:Et&&U.emissiveMap.isVideoTexture===!0&&ln.getTransfer(U.emissiveMap.colorSpace)===_n,premultipliedAlpha:U.premultipliedAlpha,doubleSided:U.side===_o,flipSided:U.side===_r,useDepthPacking:U.depthPacking>=0,depthPacking:U.depthPacking||0,index0AttributeName:U.index0AttributeName,extensionClipCullDistance:kt&&U.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(kt&&U.extensions.multiDraw===!0||ht)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:U.customProgramCacheKey()};return Xn.vertexUv1s=p.has(1),Xn.vertexUv2s=p.has(2),Xn.vertexUv3s=p.has(3),p.clear(),Xn}function S(U){const D=[];if(U.shaderID?D.push(U.shaderID):(D.push(U.customVertexShaderID),D.push(U.customFragmentShaderID)),U.defines!==void 0)for(const W in U.defines)D.push(W),D.push(U.defines[W]);return U.isRawShaderMaterial===!1&&(b(D,U),P(D,U),D.push(i.outputColorSpace)),D.push(U.customProgramCacheKey),D.join()}function b(U,D){U.push(D.precision),U.push(D.outputColorSpace),U.push(D.envMapMode),U.push(D.envMapCubeUVHeight),U.push(D.mapUv),U.push(D.alphaMapUv),U.push(D.lightMapUv),U.push(D.aoMapUv),U.push(D.bumpMapUv),U.push(D.normalMapUv),U.push(D.displacementMapUv),U.push(D.emissiveMapUv),U.push(D.metalnessMapUv),U.push(D.roughnessMapUv),U.push(D.anisotropyMapUv),U.push(D.clearcoatMapUv),U.push(D.clearcoatNormalMapUv),U.push(D.clearcoatRoughnessMapUv),U.push(D.iridescenceMapUv),U.push(D.iridescenceThicknessMapUv),U.push(D.sheenColorMapUv),U.push(D.sheenRoughnessMapUv),U.push(D.specularMapUv),U.push(D.specularColorMapUv),U.push(D.specularIntensityMapUv),U.push(D.transmissionMapUv),U.push(D.thicknessMapUv),U.push(D.combine),U.push(D.fogExp2),U.push(D.sizeAttenuation),U.push(D.morphTargetsCount),U.push(D.morphAttributeCount),U.push(D.numDirLights),U.push(D.numPointLights),U.push(D.numSpotLights),U.push(D.numSpotLightMaps),U.push(D.numHemiLights),U.push(D.numRectAreaLights),U.push(D.numDirLightShadows),U.push(D.numPointLightShadows),U.push(D.numSpotLightShadows),U.push(D.numSpotLightShadowsWithMaps),U.push(D.numLightProbes),U.push(D.shadowMapType),U.push(D.toneMapping),U.push(D.numClippingPlanes),U.push(D.numClipIntersection),U.push(D.depthPacking)}function P(U,D){u.disableAll(),D.supportsVertexTextures&&u.enable(0),D.instancing&&u.enable(1),D.instancingColor&&u.enable(2),D.instancingMorph&&u.enable(3),D.matcap&&u.enable(4),D.envMap&&u.enable(5),D.normalMapObjectSpace&&u.enable(6),D.normalMapTangentSpace&&u.enable(7),D.clearcoat&&u.enable(8),D.iridescence&&u.enable(9),D.alphaTest&&u.enable(10),D.vertexColors&&u.enable(11),D.vertexAlphas&&u.enable(12),D.vertexUv1s&&u.enable(13),D.vertexUv2s&&u.enable(14),D.vertexUv3s&&u.enable(15),D.vertexTangents&&u.enable(16),D.anisotropy&&u.enable(17),D.alphaHash&&u.enable(18),D.batching&&u.enable(19),D.dispersion&&u.enable(20),D.batchingColor&&u.enable(21),U.push(u.mask),u.disableAll(),D.fog&&u.enable(0),D.useFog&&u.enable(1),D.flatShading&&u.enable(2),D.logarithmicDepthBuffer&&u.enable(3),D.reverseDepthBuffer&&u.enable(4),D.skinning&&u.enable(5),D.morphTargets&&u.enable(6),D.morphNormals&&u.enable(7),D.morphColors&&u.enable(8),D.premultipliedAlpha&&u.enable(9),D.shadowMapEnabled&&u.enable(10),D.doubleSided&&u.enable(11),D.flipSided&&u.enable(12),D.useDepthPacking&&u.enable(13),D.dithering&&u.enable(14),D.transmission&&u.enable(15),D.sheen&&u.enable(16),D.opaque&&u.enable(17),D.pointsUvs&&u.enable(18),D.decodeVideoTexture&&u.enable(19),D.decodeVideoTextureEmissive&&u.enable(20),D.alphaToCoverage&&u.enable(21),U.push(u.mask)}function I(U){const D=w[U.type];let W;if(D){const se=$s[D];W=Vf.clone(se.uniforms)}else W=U.uniforms;return W}function B(U,D){let W;for(let se=0,ie=m.length;se0?n.push(S):x.transparent===!0?r.push(S):t.push(S)}function h(g,v,x,w,A,E){const S=a(g,v,x,w,A,E);x.transmission>0?n.unshift(S):x.transparent===!0?r.unshift(S):t.unshift(S)}function p(g,v){t.length>1&&t.sort(g||fN),n.length>1&&n.sort(v||cM),r.length>1&&r.sort(v||cM)}function m(){for(let g=e,v=i.length;g=o.length?(a=new fM,o.push(a)):a=o[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function dN(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new j,color:new et};break;case"SpotLight":t={position:new j,direction:new j,color:new et,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new j,color:new et,distance:0,decay:0};break;case"HemisphereLight":t={direction:new j,skyColor:new et,groundColor:new et};break;case"RectAreaLight":t={color:new et,position:new j,halfWidth:new j,halfHeight:new j};break}return i[e.id]=t,t}}}function pN(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let mN=0;function gN(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function vN(i){const e=new dN,t=pN(),n={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++)n.probe.push(new j);const r=new j,o=new Ft,a=new Ft;function u(p){let m=0,g=0,v=0;for(let U=0;U<9;U++)n.probe[U].set(0,0,0);let x=0,w=0,A=0,E=0,S=0,b=0,P=0,I=0,B=0,F=0,V=0;p.sort(gN);for(let U=0,D=p.length;U0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Qe.LTC_FLOAT_1,n.rectAreaLTC2=Qe.LTC_FLOAT_2):(n.rectAreaLTC1=Qe.LTC_HALF_1,n.rectAreaLTC2=Qe.LTC_HALF_2)),n.ambient[0]=m,n.ambient[1]=g,n.ambient[2]=v;const H=n.hash;(H.directionalLength!==x||H.pointLength!==w||H.spotLength!==A||H.rectAreaLength!==E||H.hemiLength!==S||H.numDirectionalShadows!==b||H.numPointShadows!==P||H.numSpotShadows!==I||H.numSpotMaps!==B||H.numLightProbes!==V)&&(n.directional.length=x,n.spot.length=A,n.rectArea.length=E,n.point.length=w,n.hemi.length=S,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=P,n.pointShadowMap.length=P,n.spotShadow.length=I,n.spotShadowMap.length=I,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=P,n.spotLightMatrix.length=I+B-F,n.spotLightMap.length=B,n.numSpotLightShadowsWithMaps=F,n.numLightProbes=V,H.directionalLength=x,H.pointLength=w,H.spotLength=A,H.rectAreaLength=E,H.hemiLength=S,H.numDirectionalShadows=b,H.numPointShadows=P,H.numSpotShadows=I,H.numSpotMaps=B,H.numLightProbes=V,n.version=mN++)}function h(p,m){let g=0,v=0,x=0,w=0,A=0;const E=m.matrixWorldInverse;for(let S=0,b=p.length;S=a.length?(u=new hM(i),a.push(u)):u=a[o],u}function n(){e=new WeakMap}return{get:t,dispose:n}}const _N=`void main() { gl_Position = vec4( position, 1.0 ); }`,xN=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function SN(i,e,t){let n=new ip;const r=new Ce,o=new Ce,a=new hn,u=new nx({depthPacking:IE}),h=new ix,p={},m=t.maxTextureSize,g={[Ma]:_r,[_r]:Ma,[_o]:_o},v=new Ii({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ce},radius:{value:4}},vertexShader:_N,fragmentShader:xN}),x=v.clone();x.defines.HORIZONTAL_PASS=1;const w=new Yt;w.setAttribute("position",new Tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A=new Qn(w,v),E=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=u0;let S=this.type;this.render=function(F,V,H){if(E.enabled===!1||E.autoUpdate===!1&&E.needsUpdate===!1||F.length===0)return;const U=i.getRenderTarget(),D=i.getActiveCubeFace(),W=i.getActiveMipmapLevel(),se=i.state;se.setBlending(Mo),se.buffers.color.setClear(1,1,1,1),se.buffers.depth.setTest(!0),se.setScissorTest(!1);const ie=S!==Qs&&this.type===Qs,fe=S===Qs&&this.type!==Qs;for(let Me=0,ue=F.length;Mem||r.y>m)&&(r.x>m&&(o.x=Math.floor(m/J.x),r.x=o.x*J.x,O.mapSize.x=o.x),r.y>m&&(o.y=Math.floor(m/J.y),r.y=o.y*J.y,O.mapSize.y=o.y)),O.map===null||ie===!0||fe===!0){const G=this.type!==Qs?{minFilter:Wi,magFilter:Wi}:{};O.map!==null&&O.map.dispose(),O.map=new xr(r.x,r.y,G),O.map.texture.name=ye.name+".shadowMap",O.camera.updateProjectionMatrix()}i.setRenderTarget(O.map),i.clear();const K=O.getViewportCount();for(let G=0;G0||V.map&&V.alphaTest>0){const se=D.uuid,ie=V.uuid;let fe=p[se];fe===void 0&&(fe={},p[se]=fe);let Me=fe[ie];Me===void 0&&(Me=D.clone(),fe[ie]=Me,V.addEventListener("dispose",B)),D=Me}if(D.visible=V.visible,D.wireframe=V.wireframe,U===Qs?D.side=V.shadowSide!==null?V.shadowSide:V.side:D.side=V.shadowSide!==null?V.shadowSide:g[V.side],D.alphaMap=V.alphaMap,D.alphaTest=V.alphaTest,D.map=V.map,D.clipShadows=V.clipShadows,D.clippingPlanes=V.clippingPlanes,D.clipIntersection=V.clipIntersection,D.displacementMap=V.displacementMap,D.displacementScale=V.displacementScale,D.displacementBias=V.displacementBias,D.wireframeLinewidth=V.wireframeLinewidth,D.linewidth=V.linewidth,H.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const se=i.properties.get(D);se.light=H}return D}function I(F,V,H,U,D){if(F.visible===!1)return;if(F.layers.test(V.layers)&&(F.isMesh||F.isLine||F.isPoints)&&(F.castShadow||F.receiveShadow&&D===Qs)&&(!F.frustumCulled||n.intersectsObject(F))){F.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,F.matrixWorld);const ie=e.update(F),fe=F.material;if(Array.isArray(fe)){const Me=ie.groups;for(let ue=0,ye=Me.length;ue=1):O.indexOf("OpenGL ES")!==-1&&(ye=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),ue=ye>=2);let J=null,K={};const G=i.getParameter(i.SCISSOR_BOX),ee=i.getParameter(i.VIEWPORT),De=new hn().fromArray(G),le=new hn().fromArray(ee);function xe(re,Ze,Se,Re){const $e=new Uint8Array(4),Ke=i.createTexture();i.bindTexture(re,Ke),i.texParameteri(re,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(re,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let kt=0;kt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new Ce,m=new WeakMap;let g;const v=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function w(X,k){return x?new OffscreenCanvas(X,k):Bd("canvas")}function A(X,k,he){let Ee=1;const Le=je(X);if((Le.width>he||Le.height>he)&&(Ee=he/Math.max(Le.width,Le.height)),Ee<1)if(typeof HTMLImageElement<"u"&&X instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&X instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&X instanceof ImageBitmap||typeof VideoFrame<"u"&&X instanceof VideoFrame){const Ae=Math.floor(Ee*Le.width),mt=Math.floor(Ee*Le.height);g===void 0&&(g=w(Ae,mt));const Ye=k?w(Ae,mt):g;return Ye.width=Ae,Ye.height=mt,Ye.getContext("2d").drawImage(X,0,0,Ae,mt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Le.width+"x"+Le.height+") to ("+Ae+"x"+mt+")."),Ye}else return"data"in X&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Le.width+"x"+Le.height+")."),X;return X}function E(X){return X.generateMipmaps}function S(X){i.generateMipmap(X)}function b(X){return X.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:X.isWebGL3DRenderTarget?i.TEXTURE_3D:X.isWebGLArrayRenderTarget||X.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function P(X,k,he,Ee,Le=!1){if(X!==null){if(i[X]!==void 0)return i[X];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+X+"'")}let Ae=k;if(k===i.RED&&(he===i.FLOAT&&(Ae=i.R32F),he===i.HALF_FLOAT&&(Ae=i.R16F),he===i.UNSIGNED_BYTE&&(Ae=i.R8)),k===i.RED_INTEGER&&(he===i.UNSIGNED_BYTE&&(Ae=i.R8UI),he===i.UNSIGNED_SHORT&&(Ae=i.R16UI),he===i.UNSIGNED_INT&&(Ae=i.R32UI),he===i.BYTE&&(Ae=i.R8I),he===i.SHORT&&(Ae=i.R16I),he===i.INT&&(Ae=i.R32I)),k===i.RG&&(he===i.FLOAT&&(Ae=i.RG32F),he===i.HALF_FLOAT&&(Ae=i.RG16F),he===i.UNSIGNED_BYTE&&(Ae=i.RG8)),k===i.RG_INTEGER&&(he===i.UNSIGNED_BYTE&&(Ae=i.RG8UI),he===i.UNSIGNED_SHORT&&(Ae=i.RG16UI),he===i.UNSIGNED_INT&&(Ae=i.RG32UI),he===i.BYTE&&(Ae=i.RG8I),he===i.SHORT&&(Ae=i.RG16I),he===i.INT&&(Ae=i.RG32I)),k===i.RGB_INTEGER&&(he===i.UNSIGNED_BYTE&&(Ae=i.RGB8UI),he===i.UNSIGNED_SHORT&&(Ae=i.RGB16UI),he===i.UNSIGNED_INT&&(Ae=i.RGB32UI),he===i.BYTE&&(Ae=i.RGB8I),he===i.SHORT&&(Ae=i.RGB16I),he===i.INT&&(Ae=i.RGB32I)),k===i.RGBA_INTEGER&&(he===i.UNSIGNED_BYTE&&(Ae=i.RGBA8UI),he===i.UNSIGNED_SHORT&&(Ae=i.RGBA16UI),he===i.UNSIGNED_INT&&(Ae=i.RGBA32UI),he===i.BYTE&&(Ae=i.RGBA8I),he===i.SHORT&&(Ae=i.RGBA16I),he===i.INT&&(Ae=i.RGBA32I)),k===i.RGB&&he===i.UNSIGNED_INT_5_9_9_9_REV&&(Ae=i.RGB9_E5),k===i.RGBA){const mt=Le?Fd:ln.getTransfer(Ee);he===i.FLOAT&&(Ae=i.RGBA32F),he===i.HALF_FLOAT&&(Ae=i.RGBA16F),he===i.UNSIGNED_BYTE&&(Ae=mt===_n?i.SRGB8_ALPHA8:i.RGBA8),he===i.UNSIGNED_SHORT_4_4_4_4&&(Ae=i.RGBA4),he===i.UNSIGNED_SHORT_5_5_5_1&&(Ae=i.RGB5_A1)}return(Ae===i.R16F||Ae===i.R32F||Ae===i.RG16F||Ae===i.RG32F||Ae===i.RGBA16F||Ae===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Ae}function I(X,k){let he;return X?k===null||k===Ea||k===Hu?he=i.DEPTH24_STENCIL8:k===zr?he=i.DEPTH32F_STENCIL8:k===kf&&(he=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):k===null||k===Ea||k===Hu?he=i.DEPTH_COMPONENT24:k===zr?he=i.DEPTH_COMPONENT32F:k===kf&&(he=i.DEPTH_COMPONENT16),he}function B(X,k){return E(X)===!0||X.isFramebufferTexture&&X.minFilter!==Wi&&X.minFilter!==yi?Math.log2(Math.max(k.width,k.height))+1:X.mipmaps!==void 0&&X.mipmaps.length>0?X.mipmaps.length:X.isCompressedTexture&&Array.isArray(X.image)?k.mipmaps.length:1}function F(X){const k=X.target;k.removeEventListener("dispose",F),H(k),k.isVideoTexture&&m.delete(k)}function V(X){const k=X.target;k.removeEventListener("dispose",V),D(k)}function H(X){const k=n.get(X);if(k.__webglInit===void 0)return;const he=X.source,Ee=v.get(he);if(Ee){const Le=Ee[k.__cacheKey];Le.usedTimes--,Le.usedTimes===0&&U(X),Object.keys(Ee).length===0&&v.delete(he)}n.remove(X)}function U(X){const k=n.get(X);i.deleteTexture(k.__webglTexture);const he=X.source,Ee=v.get(he);delete Ee[k.__cacheKey],a.memory.textures--}function D(X){const k=n.get(X);if(X.depthTexture&&(X.depthTexture.dispose(),n.remove(X.depthTexture)),X.isWebGLCubeRenderTarget)for(let Ee=0;Ee<6;Ee++){if(Array.isArray(k.__webglFramebuffer[Ee]))for(let Le=0;Le=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+X+" texture units while this GPU supports only "+r.maxTextures),W+=1,X}function fe(X){const k=[];return k.push(X.wrapS),k.push(X.wrapT),k.push(X.wrapR||0),k.push(X.magFilter),k.push(X.minFilter),k.push(X.anisotropy),k.push(X.internalFormat),k.push(X.format),k.push(X.type),k.push(X.generateMipmaps),k.push(X.premultiplyAlpha),k.push(X.flipY),k.push(X.unpackAlignment),k.push(X.colorSpace),k.join()}function Me(X,k){const he=n.get(X);if(X.isVideoTexture&&Ge(X),X.isRenderTargetTexture===!1&&X.version>0&&he.__version!==X.version){const Ee=X.image;if(Ee===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Ee.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{le(he,X,k);return}}t.bindTexture(i.TEXTURE_2D,he.__webglTexture,i.TEXTURE0+k)}function ue(X,k){const he=n.get(X);if(X.version>0&&he.__version!==X.version){le(he,X,k);return}t.bindTexture(i.TEXTURE_2D_ARRAY,he.__webglTexture,i.TEXTURE0+k)}function ye(X,k){const he=n.get(X);if(X.version>0&&he.__version!==X.version){le(he,X,k);return}t.bindTexture(i.TEXTURE_3D,he.__webglTexture,i.TEXTURE0+k)}function O(X,k){const he=n.get(X);if(X.version>0&&he.__version!==X.version){xe(he,X,k);return}t.bindTexture(i.TEXTURE_CUBE_MAP,he.__webglTexture,i.TEXTURE0+k)}const J={[Ld]:i.REPEAT,[Es]:i.CLAMP_TO_EDGE,[Dd]:i.MIRRORED_REPEAT},K={[Wi]:i.NEAREST,[R_]:i.NEAREST_MIPMAP_NEAREST,[Af]:i.NEAREST_MIPMAP_LINEAR,[yi]:i.LINEAR,[vd]:i.LINEAR_MIPMAP_NEAREST,[xo]:i.LINEAR_MIPMAP_LINEAR},G={[DE]:i.NEVER,[BE]:i.ALWAYS,[NE]:i.LESS,[B_]:i.LEQUAL,[UE]:i.EQUAL,[kE]:i.GEQUAL,[FE]:i.GREATER,[OE]:i.NOTEQUAL};function ee(X,k){if(k.type===zr&&e.has("OES_texture_float_linear")===!1&&(k.magFilter===yi||k.magFilter===vd||k.magFilter===Af||k.magFilter===xo||k.minFilter===yi||k.minFilter===vd||k.minFilter===Af||k.minFilter===xo)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(X,i.TEXTURE_WRAP_S,J[k.wrapS]),i.texParameteri(X,i.TEXTURE_WRAP_T,J[k.wrapT]),(X===i.TEXTURE_3D||X===i.TEXTURE_2D_ARRAY)&&i.texParameteri(X,i.TEXTURE_WRAP_R,J[k.wrapR]),i.texParameteri(X,i.TEXTURE_MAG_FILTER,K[k.magFilter]),i.texParameteri(X,i.TEXTURE_MIN_FILTER,K[k.minFilter]),k.compareFunction&&(i.texParameteri(X,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(X,i.TEXTURE_COMPARE_FUNC,G[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(k.magFilter===Wi||k.minFilter!==Af&&k.minFilter!==xo||k.type===zr&&e.has("OES_texture_float_linear")===!1)return;if(k.anisotropy>1||n.get(k).__currentAnisotropy){const he=e.get("EXT_texture_filter_anisotropic");i.texParameterf(X,he.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),n.get(k).__currentAnisotropy=k.anisotropy}}}function De(X,k){let he=!1;X.__webglInit===void 0&&(X.__webglInit=!0,k.addEventListener("dispose",F));const Ee=k.source;let Le=v.get(Ee);Le===void 0&&(Le={},v.set(Ee,Le));const Ae=fe(k);if(Ae!==X.__cacheKey){Le[Ae]===void 0&&(Le[Ae]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,he=!0),Le[Ae].usedTimes++;const mt=Le[X.__cacheKey];mt!==void 0&&(Le[X.__cacheKey].usedTimes--,mt.usedTimes===0&&U(k)),X.__cacheKey=Ae,X.__webglTexture=Le[Ae].texture}return he}function le(X,k,he){let Ee=i.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(Ee=i.TEXTURE_2D_ARRAY),k.isData3DTexture&&(Ee=i.TEXTURE_3D);const Le=De(X,k),Ae=k.source;t.bindTexture(Ee,X.__webglTexture,i.TEXTURE0+he);const mt=n.get(Ae);if(Ae.version!==mt.__version||Le===!0){t.activeTexture(i.TEXTURE0+he);const Ye=ln.getPrimaries(ln.workingColorSpace),st=k.colorSpace===ga?null:ln.getPrimaries(k.colorSpace),Ht=k.colorSpace===ga||Ye===st?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,k.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,k.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ht);let Be=A(k.image,!1,r.maxTextureSize);Be=Et(k,Be);const ct=o.convert(k.format,k.colorSpace),Tt=o.convert(k.type);let Lt=P(k.internalFormat,ct,Tt,k.colorSpace,k.isVideoTexture);ee(Ee,k);let ft;const nn=k.mipmaps,Ot=k.isVideoTexture!==!0,pn=mt.__version===void 0||Le===!0,re=Ae.dataReady,Ze=B(k,Be);if(k.isDepthTexture)Lt=I(k.format===Gu,k.type),pn&&(Ot?t.texStorage2D(i.TEXTURE_2D,1,Lt,Be.width,Be.height):t.texImage2D(i.TEXTURE_2D,0,Lt,Be.width,Be.height,0,ct,Tt,null));else if(k.isDataTexture)if(nn.length>0){Ot&&pn&&t.texStorage2D(i.TEXTURE_2D,Ze,Lt,nn[0].width,nn[0].height);for(let Se=0,Re=nn.length;Se0){const $e=t_(ft.width,ft.height,k.format,k.type);for(const Ke of k.layerUpdates){const kt=ft.data.subarray(Ke*$e/ft.data.BYTES_PER_ELEMENT,(Ke+1)*$e/ft.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Se,0,0,Ke,ft.width,ft.height,1,ct,kt)}k.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Se,0,0,0,ft.width,ft.height,Be.depth,ct,ft.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Se,Lt,ft.width,ft.height,Be.depth,0,ft.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ot?re&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Se,0,0,0,ft.width,ft.height,Be.depth,ct,Tt,ft.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Se,Lt,ft.width,ft.height,Be.depth,0,ct,Tt,ft.data)}else{Ot&&pn&&t.texStorage2D(i.TEXTURE_2D,Ze,Lt,nn[0].width,nn[0].height);for(let Se=0,Re=nn.length;Se0){const Se=t_(Be.width,Be.height,k.format,k.type);for(const Re of k.layerUpdates){const $e=Be.data.subarray(Re*Se/Be.data.BYTES_PER_ELEMENT,(Re+1)*Se/Be.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Re,Be.width,Be.height,1,ct,Tt,$e)}k.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Be.width,Be.height,Be.depth,ct,Tt,Be.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Lt,Be.width,Be.height,Be.depth,0,ct,Tt,Be.data);else if(k.isData3DTexture)Ot?(pn&&t.texStorage3D(i.TEXTURE_3D,Ze,Lt,Be.width,Be.height,Be.depth),re&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Be.width,Be.height,Be.depth,ct,Tt,Be.data)):t.texImage3D(i.TEXTURE_3D,0,Lt,Be.width,Be.height,Be.depth,0,ct,Tt,Be.data);else if(k.isFramebufferTexture){if(pn)if(Ot)t.texStorage2D(i.TEXTURE_2D,Ze,Lt,Be.width,Be.height);else{let Se=Be.width,Re=Be.height;for(let $e=0;$e>=1,Re>>=1}}else if(nn.length>0){if(Ot&&pn){const Se=je(nn[0]);t.texStorage2D(i.TEXTURE_2D,Ze,Lt,Se.width,Se.height)}for(let Se=0,Re=nn.length;Se0&&Ze++;const Re=je(ct[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Ze,nn,Re.width,Re.height)}for(let Re=0;Re<6;Re++)if(Be){Ot?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,ct[Re].width,ct[Re].height,Lt,ft,ct[Re].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,nn,ct[Re].width,ct[Re].height,0,Lt,ft,ct[Re].data);for(let $e=0;$e>Ae),Tt=Math.max(1,k.height>>Ae);Le===i.TEXTURE_3D||Le===i.TEXTURE_2D_ARRAY?t.texImage3D(Le,Ae,st,ct,Tt,k.depth,0,mt,Ye,null):t.texImage2D(Le,Ae,st,ct,Tt,0,mt,Ye,null)}t.bindFramebuffer(i.FRAMEBUFFER,X),rt(k)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Ee,Le,Be.__webglTexture,0,ke(k)):(Le===i.TEXTURE_2D||Le>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Le<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Ee,Le,Be.__webglTexture,Ae),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Te(X,k,he){if(i.bindRenderbuffer(i.RENDERBUFFER,X),k.depthBuffer){const Ee=k.depthTexture,Le=Ee&&Ee.isDepthTexture?Ee.type:null,Ae=I(k.stencilBuffer,Le),mt=k.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ye=ke(k);rt(k)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ye,Ae,k.width,k.height):he?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ye,Ae,k.width,k.height):i.renderbufferStorage(i.RENDERBUFFER,Ae,k.width,k.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,mt,i.RENDERBUFFER,X)}else{const Ee=k.textures;for(let Le=0;Le{delete k.__boundDepthTexture,delete k.__depthDisposeCallback,Ee.removeEventListener("dispose",Le)};Ee.addEventListener("dispose",Le),k.__depthDisposeCallback=Le}k.__boundDepthTexture=Ee}if(X.depthTexture&&!k.__autoAllocateDepthBuffer){if(he)throw new Error("target.depthTexture not supported in Cube render targets");We(k.__webglFramebuffer,X)}else if(he){k.__webglDepthbuffer=[];for(let Ee=0;Ee<6;Ee++)if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer[Ee]),k.__webglDepthbuffer[Ee]===void 0)k.__webglDepthbuffer[Ee]=i.createRenderbuffer(),Te(k.__webglDepthbuffer[Ee],X,!1);else{const Le=X.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ae=k.__webglDepthbuffer[Ee];i.bindRenderbuffer(i.RENDERBUFFER,Ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,Le,i.RENDERBUFFER,Ae)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer===void 0)k.__webglDepthbuffer=i.createRenderbuffer(),Te(k.__webglDepthbuffer,X,!1);else{const Ee=X.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Le=k.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Le),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ee,i.RENDERBUFFER,Le)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function ht(X,k,he){const Ee=n.get(X);k!==void 0&&be(Ee.__webglFramebuffer,X,X.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),he!==void 0&&tt(X)}function It(X){const k=X.texture,he=n.get(X),Ee=n.get(k);X.addEventListener("dispose",V);const Le=X.textures,Ae=X.isWebGLCubeRenderTarget===!0,mt=Le.length>1;if(mt||(Ee.__webglTexture===void 0&&(Ee.__webglTexture=i.createTexture()),Ee.__version=k.version,a.memory.textures++),Ae){he.__webglFramebuffer=[];for(let Ye=0;Ye<6;Ye++)if(k.mipmaps&&k.mipmaps.length>0){he.__webglFramebuffer[Ye]=[];for(let st=0;st0){he.__webglFramebuffer=[];for(let Ye=0;Ye0&&rt(X)===!1){he.__webglMultisampledFramebuffer=i.createFramebuffer(),he.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,he.__webglMultisampledFramebuffer);for(let Ye=0;Ye0)for(let st=0;st0)for(let st=0;st0){if(rt(X)===!1){const k=X.textures,he=X.width,Ee=X.height;let Le=i.COLOR_BUFFER_BIT;const Ae=X.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=n.get(X),Ye=k.length>1;if(Ye)for(let st=0;st0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function Ge(X){const k=a.render.frame;m.get(X)!==k&&(m.set(X,k),X.update())}function Et(X,k){const he=X.colorSpace,Ee=X.format,Le=X.type;return X.isCompressedTexture===!0||X.isVideoTexture===!0||he!==Wu&&he!==ga&&(ln.getTransfer(he)===_n?(Ee!==ir||Le!==eo)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",he)),k}function je(X){return typeof HTMLImageElement<"u"&&X instanceof HTMLImageElement?(p.width=X.naturalWidth||X.width,p.height=X.naturalHeight||X.height):typeof VideoFrame<"u"&&X instanceof VideoFrame?(p.width=X.displayWidth,p.height=X.displayHeight):(p.width=X.width,p.height=X.height),p}this.allocateTextureUnit=ie,this.resetTextureUnits=se,this.setTexture2D=Me,this.setTexture2DArray=ue,this.setTexture3D=ye,this.setTextureCube=O,this.rebindTextures=ht,this.setupRenderTarget=It,this.updateRenderTargetMipmap=Pe,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=tt,this.setupFrameBufferTexture=be,this.useMultisampledRTT=rt}function YT(i,e){function t(n,r=ga){let o;const a=ln.getTransfer(r);if(n===eo)return i.UNSIGNED_BYTE;if(n===d0)return i.UNSIGNED_SHORT_4_4_4_4;if(n===p0)return i.UNSIGNED_SHORT_5_5_5_1;if(n===I_)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===b_)return i.BYTE;if(n===P_)return i.SHORT;if(n===kf)return i.UNSIGNED_SHORT;if(n===h0)return i.INT;if(n===Ea)return i.UNSIGNED_INT;if(n===zr)return i.FLOAT;if(n===Eo)return i.HALF_FLOAT;if(n===L_)return i.ALPHA;if(n===D_)return i.RGB;if(n===ir)return i.RGBA;if(n===N_)return i.LUMINANCE;if(n===U_)return i.LUMINANCE_ALPHA;if(n===Fu)return i.DEPTH_COMPONENT;if(n===Gu)return i.DEPTH_STENCIL;if(n===m0)return i.RED;if(n===ep)return i.RED_INTEGER;if(n===F_)return i.RG;if(n===g0)return i.RG_INTEGER;if(n===v0)return i.RGBA_INTEGER;if(n===yd||n===_d||n===xd||n===Sd)if(a===_n)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===yd)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===_d)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===xd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Sd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===yd)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===_d)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===xd)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Sd)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Mg||n===wg||n===Eg||n===Tg)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===Mg)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===wg)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Eg)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Tg)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ag||n===Cg||n===Rg)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(n===Ag||n===Cg)return a===_n?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Rg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===bg||n===Pg||n===Ig||n===Lg||n===Dg||n===Ng||n===Ug||n===Fg||n===Og||n===kg||n===Bg||n===zg||n===Vg||n===Hg)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(n===bg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Pg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ig)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Lg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Dg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ng)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ug)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Fg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Og)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===kg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Bg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===zg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Vg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Hg)return a===_n?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Md||n===Gg||n===Wg)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===Md)return a===_n?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Gg)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Wg)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===O_||n===Xg||n===jg||n===Yg)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===Md)return o.COMPRESSED_RED_RGTC1_EXT;if(n===Xg)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===jg)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Yg)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Hu?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const TN={type:"move"};class hy{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Rf,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 Rf,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Rf,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j),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 n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),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,n){let r=null,o=null,a=null;const u=this._targetRay,h=this._grip,p=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(p&&e.hand){a=!0;for(const A of e.hand.values()){const E=t.getJointPose(A,n),S=this._getHandJoint(p,A);E!==null&&(S.matrix.fromArray(E.transform.matrix),S.matrix.decompose(S.position,S.rotation,S.scale),S.matrixWorldNeedsUpdate=!0,S.jointRadius=E.radius),S.visible=E!==null}const m=p.joints["index-finger-tip"],g=p.joints["thumb-tip"],v=m.position.distanceTo(g.position),x=.02,w=.005;p.inputState.pinching&&v>x+w?(p.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!p.inputState.pinching&&v<=x-w&&(p.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else h!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));u!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&o!==null&&(r=o),r!==null&&(u.matrix.fromArray(r.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,r.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(r.linearVelocity)):u.hasLinearVelocity=!1,r.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(r.angularVelocity)):u.hasAngularVelocity=!1,this.dispatchEvent(TN)))}return u!==null&&(u.visible=r!==null),h!==null&&(h.visible=o!==null),p!==null&&(p.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Rf;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const AN=` void main() { gl_Position = vec4( position, 1.0 ); }`,CN=` 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 RN{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Wn,o=e.properties.get(r);o.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Ii({vertexShader:AN,fragmentShader:CN,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Qn(new Kf(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class bN extends bo{constructor(e,t){super();const n=this;let r=null,o=1,a=null,u="local-floor",h=1,p=null,m=null,g=null,v=null,x=null,w=null;const A=new RN,E=t.getContextAttributes();let S=null,b=null;const P=[],I=[],B=new Ce;let F=null;const V=new Pi;V.viewport=new hn;const H=new Pi;H.viewport=new hn;const U=[V,H],D=new FT;let W=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(le){let xe=P[le];return xe===void 0&&(xe=new hy,P[le]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(le){let xe=P[le];return xe===void 0&&(xe=new hy,P[le]=xe),xe.getGripSpace()},this.getHand=function(le){let xe=P[le];return xe===void 0&&(xe=new hy,P[le]=xe),xe.getHandSpace()};function ie(le){const xe=I.indexOf(le.inputSource);if(xe===-1)return;const be=P[xe];be!==void 0&&(be.update(le.inputSource,le.frame,p||a),be.dispatchEvent({type:le.type,data:le.inputSource}))}function fe(){r.removeEventListener("select",ie),r.removeEventListener("selectstart",ie),r.removeEventListener("selectend",ie),r.removeEventListener("squeeze",ie),r.removeEventListener("squeezestart",ie),r.removeEventListener("squeezeend",ie),r.removeEventListener("end",fe),r.removeEventListener("inputsourceschange",Me);for(let le=0;le=0&&(I[Te]=null,P[Te].disconnect(be))}for(let xe=0;xe=I.length){I.push(be),Te=tt;break}else if(I[tt]===null){I[tt]=be,Te=tt;break}if(Te===-1)break}const We=P[Te];We&&We.connect(be)}}const ue=new j,ye=new j;function O(le,xe,be){ue.setFromMatrixPosition(xe.matrixWorld),ye.setFromMatrixPosition(be.matrixWorld);const Te=ue.distanceTo(ye),We=xe.projectionMatrix.elements,tt=be.projectionMatrix.elements,ht=We[14]/(We[10]-1),It=We[14]/(We[10]+1),Pe=(We[9]+1)/We[5],Ne=(We[9]-1)/We[5],Y=(We[8]-1)/We[0],yt=(tt[8]+1)/tt[0],ke=ht*Y,rt=ht*yt,Ge=Te/(-Y+yt),Et=Ge*-Y;if(xe.matrixWorld.decompose(le.position,le.quaternion,le.scale),le.translateX(Et),le.translateZ(Ge),le.matrixWorld.compose(le.position,le.quaternion,le.scale),le.matrixWorldInverse.copy(le.matrixWorld).invert(),We[10]===-1)le.projectionMatrix.copy(xe.projectionMatrix),le.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const je=ht+Ge,X=It+Ge,k=ke-Et,he=rt+(Te-Et),Ee=Pe*It/X*je,Le=Ne*It/X*je;le.projectionMatrix.makePerspective(k,he,Ee,Le,je,X),le.projectionMatrixInverse.copy(le.projectionMatrix).invert()}}function J(le,xe){xe===null?le.matrixWorld.copy(le.matrix):le.matrixWorld.multiplyMatrices(xe.matrixWorld,le.matrix),le.matrixWorldInverse.copy(le.matrixWorld).invert()}this.updateCamera=function(le){if(r===null)return;let xe=le.near,be=le.far;A.texture!==null&&(A.depthNear>0&&(xe=A.depthNear),A.depthFar>0&&(be=A.depthFar)),D.near=H.near=V.near=xe,D.far=H.far=V.far=be,(W!==D.near||se!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),W=D.near,se=D.far),V.layers.mask=le.layers.mask|2,H.layers.mask=le.layers.mask|4,D.layers.mask=V.layers.mask|H.layers.mask;const Te=le.parent,We=D.cameras;J(D,Te);for(let tt=0;tt0&&(E.alphaTest.value=S.alphaTest);const b=e.get(S),P=b.envMap,I=b.envMapRotation;P&&(E.envMap.value=P,wu.copy(I),wu.x*=-1,wu.y*=-1,wu.z*=-1,P.isCubeTexture&&P.isRenderTargetTexture===!1&&(wu.y*=-1,wu.z*=-1),E.envMapRotation.value.setFromMatrix4(PN.makeRotationFromEuler(wu)),E.flipEnvMap.value=P.isCubeTexture&&P.isRenderTargetTexture===!1?-1:1,E.reflectivity.value=S.reflectivity,E.ior.value=S.ior,E.refractionRatio.value=S.refractionRatio),S.lightMap&&(E.lightMap.value=S.lightMap,E.lightMapIntensity.value=S.lightMapIntensity,t(S.lightMap,E.lightMapTransform)),S.aoMap&&(E.aoMap.value=S.aoMap,E.aoMapIntensity.value=S.aoMapIntensity,t(S.aoMap,E.aoMapTransform))}function a(E,S){E.diffuse.value.copy(S.color),E.opacity.value=S.opacity,S.map&&(E.map.value=S.map,t(S.map,E.mapTransform))}function u(E,S){E.dashSize.value=S.dashSize,E.totalSize.value=S.dashSize+S.gapSize,E.scale.value=S.scale}function h(E,S,b,P){E.diffuse.value.copy(S.color),E.opacity.value=S.opacity,E.size.value=S.size*b,E.scale.value=P*.5,S.map&&(E.map.value=S.map,t(S.map,E.uvTransform)),S.alphaMap&&(E.alphaMap.value=S.alphaMap,t(S.alphaMap,E.alphaMapTransform)),S.alphaTest>0&&(E.alphaTest.value=S.alphaTest)}function p(E,S){E.diffuse.value.copy(S.color),E.opacity.value=S.opacity,E.rotation.value=S.rotation,S.map&&(E.map.value=S.map,t(S.map,E.mapTransform)),S.alphaMap&&(E.alphaMap.value=S.alphaMap,t(S.alphaMap,E.alphaMapTransform)),S.alphaTest>0&&(E.alphaTest.value=S.alphaTest)}function m(E,S){E.specular.value.copy(S.specular),E.shininess.value=Math.max(S.shininess,1e-4)}function g(E,S){S.gradientMap&&(E.gradientMap.value=S.gradientMap)}function v(E,S){E.metalness.value=S.metalness,S.metalnessMap&&(E.metalnessMap.value=S.metalnessMap,t(S.metalnessMap,E.metalnessMapTransform)),E.roughness.value=S.roughness,S.roughnessMap&&(E.roughnessMap.value=S.roughnessMap,t(S.roughnessMap,E.roughnessMapTransform)),S.envMap&&(E.envMapIntensity.value=S.envMapIntensity)}function x(E,S,b){E.ior.value=S.ior,S.sheen>0&&(E.sheenColor.value.copy(S.sheenColor).multiplyScalar(S.sheen),E.sheenRoughness.value=S.sheenRoughness,S.sheenColorMap&&(E.sheenColorMap.value=S.sheenColorMap,t(S.sheenColorMap,E.sheenColorMapTransform)),S.sheenRoughnessMap&&(E.sheenRoughnessMap.value=S.sheenRoughnessMap,t(S.sheenRoughnessMap,E.sheenRoughnessMapTransform))),S.clearcoat>0&&(E.clearcoat.value=S.clearcoat,E.clearcoatRoughness.value=S.clearcoatRoughness,S.clearcoatMap&&(E.clearcoatMap.value=S.clearcoatMap,t(S.clearcoatMap,E.clearcoatMapTransform)),S.clearcoatRoughnessMap&&(E.clearcoatRoughnessMap.value=S.clearcoatRoughnessMap,t(S.clearcoatRoughnessMap,E.clearcoatRoughnessMapTransform)),S.clearcoatNormalMap&&(E.clearcoatNormalMap.value=S.clearcoatNormalMap,t(S.clearcoatNormalMap,E.clearcoatNormalMapTransform),E.clearcoatNormalScale.value.copy(S.clearcoatNormalScale),S.side===_r&&E.clearcoatNormalScale.value.negate())),S.dispersion>0&&(E.dispersion.value=S.dispersion),S.iridescence>0&&(E.iridescence.value=S.iridescence,E.iridescenceIOR.value=S.iridescenceIOR,E.iridescenceThicknessMinimum.value=S.iridescenceThicknessRange[0],E.iridescenceThicknessMaximum.value=S.iridescenceThicknessRange[1],S.iridescenceMap&&(E.iridescenceMap.value=S.iridescenceMap,t(S.iridescenceMap,E.iridescenceMapTransform)),S.iridescenceThicknessMap&&(E.iridescenceThicknessMap.value=S.iridescenceThicknessMap,t(S.iridescenceThicknessMap,E.iridescenceThicknessMapTransform))),S.transmission>0&&(E.transmission.value=S.transmission,E.transmissionSamplerMap.value=b.texture,E.transmissionSamplerSize.value.set(b.width,b.height),S.transmissionMap&&(E.transmissionMap.value=S.transmissionMap,t(S.transmissionMap,E.transmissionMapTransform)),E.thickness.value=S.thickness,S.thicknessMap&&(E.thicknessMap.value=S.thicknessMap,t(S.thicknessMap,E.thicknessMapTransform)),E.attenuationDistance.value=S.attenuationDistance,E.attenuationColor.value.copy(S.attenuationColor)),S.anisotropy>0&&(E.anisotropyVector.value.set(S.anisotropy*Math.cos(S.anisotropyRotation),S.anisotropy*Math.sin(S.anisotropyRotation)),S.anisotropyMap&&(E.anisotropyMap.value=S.anisotropyMap,t(S.anisotropyMap,E.anisotropyMapTransform))),E.specularIntensity.value=S.specularIntensity,E.specularColor.value.copy(S.specularColor),S.specularColorMap&&(E.specularColorMap.value=S.specularColorMap,t(S.specularColorMap,E.specularColorMapTransform)),S.specularIntensityMap&&(E.specularIntensityMap.value=S.specularIntensityMap,t(S.specularIntensityMap,E.specularIntensityMapTransform))}function w(E,S){S.matcap&&(E.matcap.value=S.matcap)}function A(E,S){const b=e.get(S).light;E.referencePosition.value.setFromMatrixPosition(b.matrixWorld),E.nearDistance.value=b.shadow.camera.near,E.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function LN(i,e,t,n){let r={},o={},a=[];const u=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function h(b,P){const I=P.program;n.uniformBlockBinding(b,I)}function p(b,P){let I=r[b.id];I===void 0&&(w(b),I=m(b),r[b.id]=I,b.addEventListener("dispose",E));const B=P.program;n.updateUBOMapping(b,B);const F=e.render.frame;o[b.id]!==F&&(v(b),o[b.id]=F)}function m(b){const P=g();b.__bindingPointIndex=P;const I=i.createBuffer(),B=b.__size,F=b.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,B,F),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,P,I),I}function g(){for(let b=0;b0&&(I+=B-F),b.__size=I,b.__cache={},this}function A(b){const P={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(P.boundary=4,P.storage=4):b.isVector2?(P.boundary=8,P.storage=8):b.isVector3||b.isColor?(P.boundary=16,P.storage=12):b.isVector4?(P.boundary=16,P.storage=16):b.isMatrix3?(P.boundary=48,P.storage=48):b.isMatrix4?(P.boundary=64,P.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),P}function E(b){const P=b.target;P.removeEventListener("dispose",E);const I=a.indexOf(P.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[P.id]),delete r[P.id],delete o[P.id]}function S(){for(const b in r)i.deleteBuffer(r[b]);a=[],r={},o={}}return{bind:h,update:p,dispose:S}}class qT{constructor(e={}){const{canvas:t=VE(),context:n=null,depth:r=!0,stencil:o=!1,alpha:a=!1,antialias:u=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:p=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:g=!1,reverseDepthBuffer:v=!1}=e;this.isWebGLRenderer=!0;let x;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");x=n.getContextAttributes().alpha}else x=a;const w=new Uint32Array(4),A=new Int32Array(4);let E=null,S=null;const b=[],P=[];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._outputColorSpace=kr,this.toneMapping=wo,this.toneMappingExposure=1;const I=this;let B=!1,F=0,V=0,H=null,U=-1,D=null;const W=new hn,se=new hn;let ie=null;const fe=new et(0);let Me=0,ue=t.width,ye=t.height,O=1,J=null,K=null;const G=new hn(0,0,ue,ye),ee=new hn(0,0,ue,ye);let De=!1;const le=new ip;let xe=!1,be=!1;const Te=new Ft,We=new Ft,tt=new j,ht=new hn,It={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Pe=!1;function Ne(){return H===null?O:1}let Y=n;function yt(z,oe){return t.getContext(z,oe)}try{const z={alpha:!0,depth:r,stencil:o,antialias:u,premultipliedAlpha:h,preserveDrawingBuffer:p,powerPreference:m,failIfMajorPerformanceCaveat:g};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${l0}`),t.addEventListener("webglcontextlost",Re,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",Ke,!1),Y===null){const oe="webgl2";if(Y=yt(oe,z),Y===null)throw yt(oe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(z){throw console.error("THREE.WebGLRenderer: "+z.message),z}let ke,rt,Ge,Et,je,X,k,he,Ee,Le,Ae,mt,Ye,st,Ht,Be,ct,Tt,Lt,ft,nn,Ot,pn,re;function Ze(){ke=new G3(Y),ke.init(),Ot=new YT(Y,ke),rt=new O3(Y,ke,e,Ot),Ge=new wN(Y,ke),rt.reverseDepthBuffer&&v&&Ge.buffers.depth.setReversed(!0),Et=new j3(Y),je=new cN,X=new EN(Y,ke,Ge,je,rt,Ot,Et),k=new B3(I),he=new H3(I),Ee=new $2(Y),pn=new U3(Y,Ee),Le=new W3(Y,Ee,Et,pn),Ae=new q3(Y,Le,Ee,Et),Lt=new Y3(Y,rt,X),Be=new k3(je),mt=new uN(I,k,he,ke,rt,pn,Be),Ye=new IN(I,je),st=new hN,Ht=new yN(ke),Tt=new N3(I,k,he,Ge,Ae,x,h),ct=new SN(I,Ae,rt),re=new LN(Y,Et,rt,Ge),ft=new F3(Y,ke,Et),nn=new X3(Y,ke,Et),Et.programs=mt.programs,I.capabilities=rt,I.extensions=ke,I.properties=je,I.renderLists=st,I.shadowMap=ct,I.state=Ge,I.info=Et}Ze();const Se=new bN(I,Y);this.xr=Se,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const z=ke.get("WEBGL_lose_context");z&&z.loseContext()},this.forceContextRestore=function(){const z=ke.get("WEBGL_lose_context");z&&z.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(z){z!==void 0&&(O=z,this.setSize(ue,ye,!1))},this.getSize=function(z){return z.set(ue,ye)},this.setSize=function(z,oe,me=!0){if(Se.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ue=z,ye=oe,t.width=Math.floor(z*O),t.height=Math.floor(oe*O),me===!0&&(t.style.width=z+"px",t.style.height=oe+"px"),this.setViewport(0,0,z,oe)},this.getDrawingBufferSize=function(z){return z.set(ue*O,ye*O).floor()},this.setDrawingBufferSize=function(z,oe,me){ue=z,ye=oe,O=me,t.width=Math.floor(z*me),t.height=Math.floor(oe*me),this.setViewport(0,0,z,oe)},this.getCurrentViewport=function(z){return z.copy(W)},this.getViewport=function(z){return z.copy(G)},this.setViewport=function(z,oe,me,ve){z.isVector4?G.set(z.x,z.y,z.z,z.w):G.set(z,oe,me,ve),Ge.viewport(W.copy(G).multiplyScalar(O).round())},this.getScissor=function(z){return z.copy(ee)},this.setScissor=function(z,oe,me,ve){z.isVector4?ee.set(z.x,z.y,z.z,z.w):ee.set(z,oe,me,ve),Ge.scissor(se.copy(ee).multiplyScalar(O).round())},this.getScissorTest=function(){return De},this.setScissorTest=function(z){Ge.setScissorTest(De=z)},this.setOpaqueSort=function(z){J=z},this.setTransparentSort=function(z){K=z},this.getClearColor=function(z){return z.copy(Tt.getClearColor())},this.setClearColor=function(){Tt.setClearColor.apply(Tt,arguments)},this.getClearAlpha=function(){return Tt.getClearAlpha()},this.setClearAlpha=function(){Tt.setClearAlpha.apply(Tt,arguments)},this.clear=function(z=!0,oe=!0,me=!0){let ve=0;if(z){let $=!1;if(H!==null){const Oe=H.texture.format;$=Oe===v0||Oe===g0||Oe===ep}if($){const Oe=H.texture.type,qe=Oe===eo||Oe===Ea||Oe===kf||Oe===Hu||Oe===d0||Oe===p0,it=Tt.getClearColor(),lt=Tt.getClearAlpha(),Pt=it.r,At=it.g,dt=it.b;qe?(w[0]=Pt,w[1]=At,w[2]=dt,w[3]=lt,Y.clearBufferuiv(Y.COLOR,0,w)):(A[0]=Pt,A[1]=At,A[2]=dt,A[3]=lt,Y.clearBufferiv(Y.COLOR,0,A))}else ve|=Y.COLOR_BUFFER_BIT}oe&&(ve|=Y.DEPTH_BUFFER_BIT),me&&(ve|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(ve)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Re,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",Ke,!1),Tt.dispose(),st.dispose(),Ht.dispose(),je.dispose(),k.dispose(),he.dispose(),Ae.dispose(),pn.dispose(),re.dispose(),mt.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",Ra),Se.removeEventListener("sessionend",io),as.stop()};function Re(z){z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),B=!0}function $e(){console.log("THREE.WebGLRenderer: Context Restored."),B=!1;const z=Et.autoReset,oe=ct.enabled,me=ct.autoUpdate,ve=ct.needsUpdate,$=ct.type;Ze(),Et.autoReset=z,ct.enabled=oe,ct.autoUpdate=me,ct.needsUpdate=ve,ct.type=$}function Ke(z){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",z.statusMessage)}function kt(z){const oe=z.target;oe.removeEventListener("dispose",kt),An(oe)}function An(z){Xn(z),je.remove(z)}function Xn(z){const oe=je.get(z).programs;oe!==void 0&&(oe.forEach(function(me){mt.releaseProgram(me)}),z.isShaderMaterial&&mt.releaseShaderCache(z))}this.renderBufferDirect=function(z,oe,me,ve,$,Oe){oe===null&&(oe=It);const qe=$.isMesh&&$.matrixWorld.determinant()<0,it=ec(z,oe,me,ve,$);Ge.setMaterial(ve,qe);let lt=me.index,Pt=1;if(ve.wireframe===!0){if(lt=Le.getWireframeAttribute(me),lt===void 0)return;Pt=2}const At=me.drawRange,dt=me.attributes.position;let ot=At.start*Pt,wt=(At.start+At.count)*Pt;Oe!==null&&(ot=Math.max(ot,Oe.start*Pt),wt=Math.min(wt,(Oe.start+Oe.count)*Pt)),lt!==null?(ot=Math.max(ot,0),wt=Math.min(wt,lt.count)):dt!=null&&(ot=Math.max(ot,0),wt=Math.min(wt,dt.count));const Jt=wt-ot;if(Jt<0||Jt===1/0)return;pn.setup($,ve,it,me,lt);let Qt,Ut=ft;if(lt!==null&&(Qt=Ee.get(lt),Ut=nn,Ut.setIndex(Qt)),$.isMesh)ve.wireframe===!0?(Ge.setLineWidth(ve.wireframeLinewidth*Ne()),Ut.setMode(Y.LINES)):Ut.setMode(Y.TRIANGLES);else if($.isLine){let xt=ve.linewidth;xt===void 0&&(xt=1),Ge.setLineWidth(xt*Ne()),$.isLineSegments?Ut.setMode(Y.LINES):$.isLineLoop?Ut.setMode(Y.LINE_LOOP):Ut.setMode(Y.LINE_STRIP)}else $.isPoints?Ut.setMode(Y.POINTS):$.isSprite&&Ut.setMode(Y.TRIANGLES);if($.isBatchedMesh)if($._multiDrawInstances!==null)Ut.renderMultiDrawInstances($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount,$._multiDrawInstances);else if(ke.get("WEBGL_multi_draw"))Ut.renderMultiDraw($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount);else{const xt=$._multiDrawStarts,xn=$._multiDrawCounts,Dt=$._multiDrawCount,jn=lt?Ee.get(lt).bytesPerElement:1,wr=je.get(ve).currentProgram.getUniforms();for(let Si=0;Si{function Oe(){if(ve.forEach(function(qe){je.get(qe).currentProgram.isReady()&&ve.delete(qe)}),ve.size===0){$(z);return}setTimeout(Oe,10)}ke.get("KHR_parallel_shader_compile")!==null?Oe():setTimeout(Oe,10)})};let Li=null;function Di(z){Li&&Li(z)}function Ra(){as.stop()}function io(){as.start()}const as=new HT;as.setAnimationLoop(Di),typeof self<"u"&&as.setContext(self),this.setAnimationLoop=function(z){Li=z,Se.setAnimationLoop(z),z===null?as.stop():as.start()},Se.addEventListener("sessionstart",Ra),Se.addEventListener("sessionend",io),this.render=function(z,oe){if(oe!==void 0&&oe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(B===!0)return;if(z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),oe.parent===null&&oe.matrixWorldAutoUpdate===!0&&oe.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(oe),oe=Se.getCamera()),z.isScene===!0&&z.onBeforeRender(I,z,oe,H),S=Ht.get(z,P.length),S.init(oe),P.push(S),We.multiplyMatrices(oe.projectionMatrix,oe.matrixWorldInverse),le.setFromProjectionMatrix(We),be=this.localClippingEnabled,xe=Be.init(this.clippingPlanes,be),E=st.get(z,b.length),E.init(),b.push(E),Se.enabled===!0&&Se.isPresenting===!0){const Oe=I.xr.getDepthSensingMesh();Oe!==null&&Gr(Oe,oe,-1/0,I.sortObjects)}Gr(z,oe,0,I.sortObjects),E.finish(),I.sortObjects===!0&&E.sort(J,K),Pe=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Pe&&Tt.addToRenderList(E,z),this.info.render.frame++,xe===!0&&Be.beginShadows();const me=S.state.shadowsArray;ct.render(me,z,oe),xe===!0&&Be.endShadows(),this.info.autoReset===!0&&this.info.reset();const ve=E.opaque,$=E.transmissive;if(S.setupLights(),oe.isArrayCamera){const Oe=oe.cameras;if($.length>0)for(let qe=0,it=Oe.length;qe0&&Wr(ve,$,z,oe),Pe&&Tt.render(z),Io(E,z,oe);H!==null&&(X.updateMultisampleRenderTarget(H),X.updateRenderTargetMipmap(H)),z.isScene===!0&&z.onAfterRender(I,z,oe),pn.resetDefaultState(),U=-1,D=null,P.pop(),P.length>0?(S=P[P.length-1],xe===!0&&Be.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,b.pop(),b.length>0?E=b[b.length-1]:E=null};function Gr(z,oe,me,ve){if(z.visible===!1)return;if(z.layers.test(oe.layers)){if(z.isGroup)me=z.renderOrder;else if(z.isLOD)z.autoUpdate===!0&&z.update(oe);else if(z.isLight)S.pushLight(z),z.castShadow&&S.pushShadow(z);else if(z.isSprite){if(!z.frustumCulled||le.intersectsSprite(z)){ve&&ht.setFromMatrixPosition(z.matrixWorld).applyMatrix4(We);const qe=Ae.update(z),it=z.material;it.visible&&E.push(z,qe,it,me,ht.z,null)}}else if((z.isMesh||z.isLine||z.isPoints)&&(!z.frustumCulled||le.intersectsObject(z))){const qe=Ae.update(z),it=z.material;if(ve&&(z.boundingSphere!==void 0?(z.boundingSphere===null&&z.computeBoundingSphere(),ht.copy(z.boundingSphere.center)):(qe.boundingSphere===null&&qe.computeBoundingSphere(),ht.copy(qe.boundingSphere.center)),ht.applyMatrix4(z.matrixWorld).applyMatrix4(We)),Array.isArray(it)){const lt=qe.groups;for(let Pt=0,At=lt.length;Pt0&&ro($,oe,me),Oe.length>0&&ro(Oe,oe,me),qe.length>0&&ro(qe,oe,me),Ge.buffers.depth.setTest(!0),Ge.buffers.depth.setMask(!0),Ge.buffers.color.setMask(!0),Ge.setPolygonOffset(!1)}function Wr(z,oe,me,ve){if((me.isScene===!0?me.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[ve.id]===void 0&&(S.state.transmissionRenderTarget[ve.id]=new xr(1,1,{generateMipmaps:!0,type:ke.has("EXT_color_buffer_half_float")||ke.has("EXT_color_buffer_float")?Eo:eo,minFilter:xo,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ln.workingColorSpace}));const Oe=S.state.transmissionRenderTarget[ve.id],qe=ve.viewport||W;Oe.setSize(qe.z,qe.w);const it=I.getRenderTarget();I.setRenderTarget(Oe),I.getClearColor(fe),Me=I.getClearAlpha(),Me<1&&I.setClearColor(16777215,.5),I.clear(),Pe&&Tt.render(me);const lt=I.toneMapping;I.toneMapping=wo;const Pt=ve.viewport;if(ve.viewport!==void 0&&(ve.viewport=void 0),S.setupLightsView(ve),xe===!0&&Be.setGlobalState(I.clippingPlanes,ve),ro(z,me,ve),X.updateMultisampleRenderTarget(Oe),X.updateRenderTargetMipmap(Oe),ke.has("WEBGL_multisampled_render_to_texture")===!1){let At=!1;for(let dt=0,ot=oe.length;dt0),dt=!!me.morphAttributes.position,ot=!!me.morphAttributes.normal,wt=!!me.morphAttributes.color;let Jt=wo;ve.toneMapped&&(H===null||H.isXRRenderTarget===!0)&&(Jt=I.toneMapping);const Qt=me.morphAttributes.position||me.morphAttributes.normal||me.morphAttributes.color,Ut=Qt!==void 0?Qt.length:0,xt=je.get(ve),xn=S.state.lights;if(xe===!0&&(be===!0||z!==D)){const Bn=z===D&&ve.id===U;Be.setState(ve,z,Bn)}let Dt=!1;ve.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==xn.state.version||xt.outputColorSpace!==it||$.isBatchedMesh&&xt.batching===!1||!$.isBatchedMesh&&xt.batching===!0||$.isBatchedMesh&&xt.batchingColor===!0&&$.colorTexture===null||$.isBatchedMesh&&xt.batchingColor===!1&&$.colorTexture!==null||$.isInstancedMesh&&xt.instancing===!1||!$.isInstancedMesh&&xt.instancing===!0||$.isSkinnedMesh&&xt.skinning===!1||!$.isSkinnedMesh&&xt.skinning===!0||$.isInstancedMesh&&xt.instancingColor===!0&&$.instanceColor===null||$.isInstancedMesh&&xt.instancingColor===!1&&$.instanceColor!==null||$.isInstancedMesh&&xt.instancingMorph===!0&&$.morphTexture===null||$.isInstancedMesh&&xt.instancingMorph===!1&&$.morphTexture!==null||xt.envMap!==lt||ve.fog===!0&&xt.fog!==Oe||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==Be.numPlanes||xt.numIntersection!==Be.numIntersection)||xt.vertexAlphas!==Pt||xt.vertexTangents!==At||xt.morphTargets!==dt||xt.morphNormals!==ot||xt.morphColors!==wt||xt.toneMapping!==Jt||xt.morphTargetsCount!==Ut)&&(Dt=!0):(Dt=!0,xt.__version=ve.version);let jn=xt.currentProgram;Dt===!0&&(jn=ba(ve,oe,$));let wr=!1,Si=!1,us=!1;const gn=jn.getUniforms(),Cn=xt.uniforms;if(Ge.useProgram(jn.program)&&(wr=!0,Si=!0,us=!0),ve.id!==U&&(U=ve.id,Si=!0),wr||D!==z){Ge.buffers.depth.getReversed()?(Te.copy(z.projectionMatrix),Eb(Te),Tb(Te),gn.setValue(Y,"projectionMatrix",Te)):gn.setValue(Y,"projectionMatrix",z.projectionMatrix),gn.setValue(Y,"viewMatrix",z.matrixWorldInverse);const wi=gn.map.cameraPosition;wi!==void 0&&wi.setValue(Y,tt.setFromMatrixPosition(z.matrixWorld)),rt.logarithmicDepthBuffer&&gn.setValue(Y,"logDepthBufFC",2/(Math.log(z.far+1)/Math.LN2)),(ve.isMeshPhongMaterial||ve.isMeshToonMaterial||ve.isMeshLambertMaterial||ve.isMeshBasicMaterial||ve.isMeshStandardMaterial||ve.isShaderMaterial)&&gn.setValue(Y,"isOrthographic",z.isOrthographicCamera===!0),D!==z&&(D=z,Si=!0,us=!0)}if($.isSkinnedMesh){gn.setOptional(Y,$,"bindMatrix"),gn.setOptional(Y,$,"bindMatrixInverse");const Bn=$.skeleton;Bn&&(Bn.boneTexture===null&&Bn.computeBoneTexture(),gn.setValue(Y,"boneTexture",Bn.boneTexture,X))}$.isBatchedMesh&&(gn.setOptional(Y,$,"batchingTexture"),gn.setValue(Y,"batchingTexture",$._matricesTexture,X),gn.setOptional(Y,$,"batchingIdTexture"),gn.setValue(Y,"batchingIdTexture",$._indirectTexture,X),gn.setOptional(Y,$,"batchingColorTexture"),$._colorsTexture!==null&&gn.setValue(Y,"batchingColorTexture",$._colorsTexture,X));const Mi=me.morphAttributes;if((Mi.position!==void 0||Mi.normal!==void 0||Mi.color!==void 0)&&Lt.update($,me,jn),(Si||xt.receiveShadow!==$.receiveShadow)&&(xt.receiveShadow=$.receiveShadow,gn.setValue(Y,"receiveShadow",$.receiveShadow)),ve.isMeshGouraudMaterial&&ve.envMap!==null&&(Cn.envMap.value=lt,Cn.flipEnvMap.value=lt.isCubeTexture&<.isRenderTargetTexture===!1?-1:1),ve.isMeshStandardMaterial&&ve.envMap===null&&oe.environment!==null&&(Cn.envMapIntensity.value=oe.environmentIntensity),Si&&(gn.setValue(Y,"toneMappingExposure",I.toneMappingExposure),xt.needsLights&&tc(Cn,us),Oe&&ve.fog===!0&&Ye.refreshFogUniforms(Cn,Oe),Ye.refreshMaterialUniforms(Cn,ve,O,ye,S.state.transmissionRenderTarget[z.id]),ag.upload(Y,$u(xt),Cn,X)),ve.isShaderMaterial&&ve.uniformsNeedUpdate===!0&&(ag.upload(Y,$u(xt),Cn,X),ve.uniformsNeedUpdate=!1),ve.isSpriteMaterial&&gn.setValue(Y,"center",$.center),gn.setValue(Y,"modelViewMatrix",$.modelViewMatrix),gn.setValue(Y,"normalMatrix",$.normalMatrix),gn.setValue(Y,"modelMatrix",$.matrixWorld),ve.isShaderMaterial||ve.isRawShaderMaterial){const Bn=ve.uniformsGroups;for(let wi=0,cs=Bn.length;wi0&&X.useMultisampledRTT(z)===!1?$=je.get(z).__webglMultisampledFramebuffer:Array.isArray(At)?$=At[me]:$=At,W.copy(z.viewport),se.copy(z.scissor),ie=z.scissorTest}else W.copy(G).multiplyScalar(O).floor(),se.copy(ee).multiplyScalar(O).floor(),ie=De;if(Ge.bindFramebuffer(Y.FRAMEBUFFER,$)&&ve&&Ge.drawBuffers(z,$),Ge.viewport(W),Ge.scissor(se),Ge.setScissorTest(ie),Oe){const lt=je.get(z.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+oe,lt.__webglTexture,me)}else if(qe){const lt=je.get(z.texture),Pt=oe||0;Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,lt.__webglTexture,me||0,Pt)}U=-1},this.readRenderTargetPixels=function(z,oe,me,ve,$,Oe,qe){if(!(z&&z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let it=je.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&qe!==void 0&&(it=it[qe]),it){Ge.bindFramebuffer(Y.FRAMEBUFFER,it);try{const lt=z.texture,Pt=lt.format,At=lt.type;if(!rt.textureFormatReadable(Pt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!rt.textureTypeReadable(At)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}oe>=0&&oe<=z.width-ve&&me>=0&&me<=z.height-$&&Y.readPixels(oe,me,ve,$,Ot.convert(Pt),Ot.convert(At),Oe)}finally{const lt=H!==null?je.get(H).__webglFramebuffer:null;Ge.bindFramebuffer(Y.FRAMEBUFFER,lt)}}},this.readRenderTargetPixelsAsync=async function(z,oe,me,ve,$,Oe,qe){if(!(z&&z.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let it=je.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&qe!==void 0&&(it=it[qe]),it){const lt=z.texture,Pt=lt.format,At=lt.type;if(!rt.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!rt.textureTypeReadable(At))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(oe>=0&&oe<=z.width-ve&&me>=0&&me<=z.height-$){Ge.bindFramebuffer(Y.FRAMEBUFFER,it);const dt=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,dt),Y.bufferData(Y.PIXEL_PACK_BUFFER,Oe.byteLength,Y.STREAM_READ),Y.readPixels(oe,me,ve,$,Ot.convert(Pt),Ot.convert(At),0);const ot=H!==null?je.get(H).__webglFramebuffer:null;Ge.bindFramebuffer(Y.FRAMEBUFFER,ot);const wt=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await wb(Y,wt,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,dt),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,Oe),Y.deleteBuffer(dt),Y.deleteSync(wt),Oe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(z,oe=null,me=0){z.isTexture!==!0&&(wf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),oe=arguments[0]||null,z=arguments[1]);const ve=Math.pow(2,-me),$=Math.floor(z.image.width*ve),Oe=Math.floor(z.image.height*ve),qe=oe!==null?oe.x:0,it=oe!==null?oe.y:0;X.setTexture2D(z,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,me,0,0,qe,it,$,Oe),Ge.unbindTexture()};const ic=Y.createFramebuffer(),rc=Y.createFramebuffer();this.copyTextureToTexture=function(z,oe,me=null,ve=null,$=0,Oe=null){z.isTexture!==!0&&(wf("WebGLRenderer: copyTextureToTexture function signature has changed."),ve=arguments[0]||null,z=arguments[1],oe=arguments[2],Oe=arguments[3]||0,me=null),Oe===null&&($!==0?(wf("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Oe=$,$=0):Oe=0);let qe,it,lt,Pt,At,dt,ot,wt,Jt;const Qt=z.isCompressedTexture?z.mipmaps[Oe]:z.image;if(me!==null)qe=me.max.x-me.min.x,it=me.max.y-me.min.y,lt=me.isBox3?me.max.z-me.min.z:1,Pt=me.min.x,At=me.min.y,dt=me.isBox3?me.min.z:0;else{const Mi=Math.pow(2,-$);qe=Math.floor(Qt.width*Mi),it=Math.floor(Qt.height*Mi),z.isDataArrayTexture?lt=Qt.depth:z.isData3DTexture?lt=Math.floor(Qt.depth*Mi):lt=1,Pt=0,At=0,dt=0}ve!==null?(ot=ve.x,wt=ve.y,Jt=ve.z):(ot=0,wt=0,Jt=0);const Ut=Ot.convert(oe.format),xt=Ot.convert(oe.type);let xn;oe.isData3DTexture?(X.setTexture3D(oe,0),xn=Y.TEXTURE_3D):oe.isDataArrayTexture||oe.isCompressedArrayTexture?(X.setTexture2DArray(oe,0),xn=Y.TEXTURE_2D_ARRAY):(X.setTexture2D(oe,0),xn=Y.TEXTURE_2D),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,oe.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,oe.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,oe.unpackAlignment);const Dt=Y.getParameter(Y.UNPACK_ROW_LENGTH),jn=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),wr=Y.getParameter(Y.UNPACK_SKIP_PIXELS),Si=Y.getParameter(Y.UNPACK_SKIP_ROWS),us=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Qt.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Qt.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Pt),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,At),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,dt);const gn=z.isDataArrayTexture||z.isData3DTexture,Cn=oe.isDataArrayTexture||oe.isData3DTexture;if(z.isDepthTexture){const Mi=je.get(z),Bn=je.get(oe),wi=je.get(Mi.__renderTarget),cs=je.get(Bn.__renderTarget);Ge.bindFramebuffer(Y.READ_FRAMEBUFFER,wi.__webglFramebuffer),Ge.bindFramebuffer(Y.DRAW_FRAMEBUFFER,cs.__webglFramebuffer);for(let qt=0;qt{const g=typeof p=="function"?p(e):p;if(g!==e){const v=e;e=m?g:Object.assign({},e,g),t.forEach(x=>x(e,v))}},r=()=>e,o=(p,m=r,g=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let v=m(e);function x(){const w=m(e);if(!g(v,w)){const A=v;p(v=w,A)}}return t.add(x),()=>t.delete(x)},h={setState:n,getState:r,subscribe:(p,m,g)=>m||g?o(p,m,g):(t.add(p),()=>t.delete(p)),destroy:()=>t.clear()};return e=i(n,r,h),h}const ON=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),mM=ON?Ie.useEffect:Ie.useLayoutEffect;function kN(i){const e=typeof i=="function"?FN(i):i,t=(n=e.getState,r=Object.is)=>{const[,o]=Ie.useReducer(E=>E+1,0),a=e.getState(),u=Ie.useRef(a),h=Ie.useRef(n),p=Ie.useRef(r),m=Ie.useRef(!1),g=Ie.useRef();g.current===void 0&&(g.current=n(a));let v,x=!1;(u.current!==a||h.current!==n||p.current!==r||m.current)&&(v=n(a),x=!r(g.current,v)),mM(()=>{x&&(g.current=v),u.current=a,h.current=n,p.current=r,m.current=!1});const w=Ie.useRef(a);mM(()=>{const E=()=>{try{const b=e.getState(),P=h.current(b);p.current(g.current,P)||(u.current=b,g.current=P,o())}catch{m.current=!0,o()}},S=e.subscribe(E);return e.getState()!==w.current&&E(),S},[]);const A=x?v:g.current;return Ie.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 n=[t,e];return{next(){const r=n.length<=0;return{value:n.shift(),done:r}}}},t}var py={exports:{}},my={exports:{}},gy={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var gM;function BN(){return gM||(gM=1,function(i){function e(O,J){var K=O.length;O.push(J);e:for(;0>>1,ee=O[G];if(0>>1;Gr(xe,K))ber(Te,xe)?(O[G]=Te,O[be]=K,G=be):(O[G]=xe,O[le]=K,G=le);else if(ber(Te,K))O[G]=Te,O[be]=K,G=be;else break e}}return J}function r(O,J){var K=O.sortIndex-J.sortIndex;return K!==0?K:O.id-J.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;i.unstable_now=function(){return o.now()}}else{var a=Date,u=a.now();i.unstable_now=function(){return a.now()-u}}var h=[],p=[],m=1,g=null,v=3,x=!1,w=!1,A=!1,E=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(O){for(var J=t(p);J!==null;){if(J.callback===null)n(p);else if(J.startTime<=O)n(p),J.sortIndex=J.expirationTime,e(h,J);else break;J=t(p)}}function I(O){if(A=!1,P(O),!w)if(t(h)!==null)w=!0,ue(B);else{var J=t(p);J!==null&&ye(I,J.startTime-O)}}function B(O,J){w=!1,A&&(A=!1,S(H),H=-1),x=!0;var K=v;try{for(P(J),g=t(h);g!==null&&(!(g.expirationTime>J)||O&&!W());){var G=g.callback;if(typeof G=="function"){g.callback=null,v=g.priorityLevel;var ee=G(g.expirationTime<=J);J=i.unstable_now(),typeof ee=="function"?g.callback=ee:g===t(h)&&n(h),P(J)}else n(h);g=t(h)}if(g!==null)var De=!0;else{var le=t(p);le!==null&&ye(I,le.startTime-J),De=!1}return De}finally{g=null,v=K,x=!1}}var F=!1,V=null,H=-1,U=5,D=-1;function W(){return!(i.unstable_now()-DO||125G?(O.sortIndex=K,e(p,O),t(h)===null&&O===t(p)&&(A?(S(H),H=-1):A=!0,ye(I,K-G))):(O.sortIndex=ee,e(h,O),w||x||(w=!0,ue(B))),O},i.unstable_shouldYield=W,i.unstable_wrapCallback=function(O){var J=v;return function(){var K=v;v=J;try{return O.apply(this,arguments)}finally{v=K}}}}(gy)),gy}var vM;function zN(){return vM||(vM=1,my.exports=BN()),my.exports}/** * @license React * react-reconciler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var vy,yM;function VN(){return yM||(yM=1,vy=function(e){var t={},n=a0(),r=zN(),o=Object.assign;function a(c){for(var f="https://reactjs.org/docs/error-decoder.html?invariant="+c,y=1;yne||C[q]!==L[ne]){var we=` `+C[q].replace(" at new "," at ");return c.displayName&&we.includes("")&&(we=we.replace("",c.displayName)),we}while(1<=q&&0<=ne);break}}}finally{qe=!1,Error.prepareStackTrace=y}return(c=c?c.displayName||c.name:"")?Oe(c):""}var lt=Object.prototype.hasOwnProperty,Pt=[],At=-1;function dt(c){return{current:c}}function ot(c){0>At||(c.current=Pt[At],Pt[At]=null,At--)}function wt(c,f){At++,Pt[At]=c.current,c.current=f}var Jt={},Qt=dt(Jt),Ut=dt(!1),xt=Jt;function xn(c,f){var y=c.type.contextTypes;if(!y)return Jt;var M=c.stateNode;if(M&&M.__reactInternalMemoizedUnmaskedChildContext===f)return M.__reactInternalMemoizedMaskedChildContext;var C={},L;for(L in y)C[L]=f[L];return M&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=f,c.__reactInternalMemoizedMaskedChildContext=C),C}function Dt(c){return c=c.childContextTypes,c!=null}function jn(){ot(Ut),ot(Qt)}function wr(c,f,y){if(Qt.current!==Jt)throw Error(a(168));wt(Qt,f),wt(Ut,y)}function Si(c,f,y){var M=c.stateNode;if(f=f.childContextTypes,typeof M.getChildContext!="function")return y;M=M.getChildContext();for(var C in M)if(!(C in f))throw Error(a(108,H(c)||"Unknown",C));return o({},y,M)}function us(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||Jt,xt=Qt.current,wt(Qt,c),wt(Ut,Ut.current),!0}function gn(c,f,y){var M=c.stateNode;if(!M)throw Error(a(169));y?(c=Si(c,f,xt),M.__reactInternalMemoizedMergedChildContext=c,ot(Ut),ot(Qt),wt(Qt,c)):ot(Ut),wt(Ut,y)}var Cn=Math.clz32?Math.clz32:wi,Mi=Math.log,Bn=Math.LN2;function wi(c){return c>>>=0,c===0?32:31-(Mi(c)/Bn|0)|0}var cs=64,qt=4194304;function Pa(c){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: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 c&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return c&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return c}}function Al(c,f){var y=c.pendingLanes;if(y===0)return 0;var M=0,C=c.suspendedLanes,L=c.pingedLanes,q=y&268435455;if(q!==0){var ne=q&~C;ne!==0?M=Pa(ne):(L&=q,L!==0&&(M=Pa(L)))}else q=y&~C,q!==0?M=Pa(q):L!==0&&(M=Pa(L));if(M===0)return 0;if(f!==0&&f!==M&&!(f&C)&&(C=M&-M,L=f&-f,C>=L||C===16&&(L&4194240)!==0))return f;if(M&4&&(M|=y&16),f=c.entangledLanes,f!==0)for(c=c.entanglements,f&=M;0y;y++)f.push(c);return f}function Lo(c,f,y){c.pendingLanes|=f,f!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,f=31-Cn(f),c[f]=y}function ac(c,f){var y=c.pendingLanes&~f;c.pendingLanes=f,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=f,c.mutableReadLanes&=f,c.entangledLanes&=f,f=c.entanglements;var M=c.eventTimes;for(c=c.expirationTimes;0>=q,C-=q,Rs=1<<32-Cn(f)+C|y<an?(qn=Vt,Vt=null):qn=Vt.sibling;var on=Ct(pe,Vt,_e[an],Je);if(on===null){Vt===null&&(Vt=qn);break}c&&Vt&&on.alternate===null&&f(pe,Vt),ae=L(on,ae,an),Gt===null?St=on:Gt.sibling=on,Gt=on,Vt=qn}if(an===_e.length)return y(pe,Vt),Pn&&Bo(pe,an),St;if(Vt===null){for(;an<_e.length;an++)Vt=zt(pe,_e[an],Je),Vt!==null&&(ae=L(Vt,ae,an),Gt===null?St=Vt:Gt.sibling=Vt,Gt=Vt);return Pn&&Bo(pe,an),St}for(Vt=M(pe,Vt);an<_e.length;an++)qn=Zt(Vt,pe,an,_e[an],Je),qn!==null&&(c&&qn.alternate!==null&&Vt.delete(qn.key===null?an:qn.key),ae=L(qn,ae,an),Gt===null?St=qn:Gt.sibling=qn,Gt=qn);return c&&Vt.forEach(function(Ws){return f(pe,Ws)}),Pn&&Bo(pe,an),St}function gi(pe,ae,_e,Je){var St=F(_e);if(typeof St!="function")throw Error(a(150));if(_e=St.call(_e),_e==null)throw Error(a(151));for(var Gt=St=null,Vt=ae,an=ae=0,qn=null,on=_e.next();Vt!==null&&!on.done;an++,on=_e.next()){Vt.index>an?(qn=Vt,Vt=null):qn=Vt.sibling;var Ws=Ct(pe,Vt,on.value,Je);if(Ws===null){Vt===null&&(Vt=qn);break}c&&Vt&&Ws.alternate===null&&f(pe,Vt),ae=L(Ws,ae,an),Gt===null?St=Ws:Gt.sibling=Ws,Gt=Ws,Vt=qn}if(on.done)return y(pe,Vt),Pn&&Bo(pe,an),St;if(Vt===null){for(;!on.done;an++,on=_e.next())on=zt(pe,on.value,Je),on!==null&&(ae=L(on,ae,an),Gt===null?St=on:Gt.sibling=on,Gt=on);return Pn&&Bo(pe,an),St}for(Vt=M(pe,Vt);!on.done;an++,on=_e.next())on=Zt(Vt,pe,an,on.value,Je),on!==null&&(c&&on.alternate!==null&&Vt.delete(on.key===null?an:on.key),ae=L(on,ae,an),Gt===null?St=on:Gt.sibling=on,Gt=on);return c&&Vt.forEach(function(Hh){return f(pe,Hh)}),Pn&&Bo(pe,an),St}function pr(pe,ae,_e,Je){if(typeof _e=="object"&&_e!==null&&_e.type===m&&_e.key===null&&(_e=_e.props.children),typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case h:e:{for(var St=_e.key,Gt=ae;Gt!==null;){if(Gt.key===St){if(St=_e.type,St===m){if(Gt.tag===7){y(pe,Gt.sibling),ae=C(Gt,_e.props.children),ae.return=pe,pe=ae;break e}}else if(Gt.elementType===St||typeof St=="object"&&St!==null&&St.$$typeof===P&&ka(St)===Gt.type){y(pe,Gt.sibling),ae=C(Gt,_e.props),ae.ref=Oa(pe,Gt,_e),ae.return=pe,pe=ae;break e}y(pe,Gt);break}else f(pe,Gt);Gt=Gt.sibling}_e.type===m?(ae=aa(_e.props.children,pe.mode,Je,_e.key),ae.return=pe,pe=ae):(Je=Yc(_e.type,_e.key,_e.props,null,pe.mode,Je),Je.ref=Oa(pe,ae,_e),Je.return=pe,pe=Je)}return q(pe);case p:e:{for(Gt=_e.key;ae!==null;){if(ae.key===Gt)if(ae.tag===4&&ae.stateNode.containerInfo===_e.containerInfo&&ae.stateNode.implementation===_e.implementation){y(pe,ae.sibling),ae=C(ae,_e.children||[]),ae.return=pe,pe=ae;break e}else{y(pe,ae);break}else f(pe,ae);ae=ae.sibling}ae=Zc(_e,pe.mode,Je),ae.return=pe,pe=ae}return q(pe);case P:return Gt=_e._init,pr(pe,ae,Gt(_e._payload),Je)}if(Me(_e))return nt(pe,ae,_e,Je);if(F(_e))return gi(pe,ae,_e,Je);uo(pe,_e)}return typeof _e=="string"&&_e!==""||typeof _e=="number"?(_e=""+_e,ae!==null&&ae.tag===6?(y(pe,ae.sibling),ae=C(ae,_e),ae.return=pe,pe=ae):(y(pe,ae),ae=qc(_e,pe.mode,Je),ae.return=pe,pe=ae),q(pe)):y(pe,ae)}return pr}var Ps=Tp(!0),Ap=Tp(!1),Ba={},qi=dt(Ba),zo=dt(Ba),Vo=dt(Ba);function jr(c){if(c===Ba)throw Error(a(174));return c}function Mc(c,f){wt(Vo,f),wt(zo,c),wt(qi,Ba),c=ye(f),ot(qi),wt(qi,c)}function za(){ot(qi),ot(zo),ot(Vo)}function Cp(c){var f=jr(Vo.current),y=jr(qi.current);f=O(y,c.type,f),y!==f&&(wt(zo,c),wt(qi,f))}function hh(c){zo.current===c&&(ot(qi),ot(zo))}var Ln=dt(0);function wc(c){for(var f=c;f!==null;){if(f.tag===13){var y=f.memoizedState;if(y!==null&&(y=y.dehydrated,y===null||as(y)||Gr(y)))return f}else if(f.tag===19&&f.memoizedProps.revealOrder!==void 0){if(f.flags&128)return f}else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===c)break;for(;f.sibling===null;){if(f.return===null||f.return===c)return null;f=f.return}f.sibling.return=f.return,f=f.sibling}return null}var ar=[];function Ho(){for(var c=0;cy?y:4,c(!0);var M=lr.transition;lr.transition={};try{c(!1),f()}finally{$t=y,lr.transition=M}}function Xo(){return qr().memoizedState}function bp(c,f,y){var M=Qr(c);y={lane:M,action:y,hasEagerState:!1,eagerState:null,next:null},Pp(c)?vh(f,y):(zl(c,f,y),y=un(),c=Ai(c,M,y),c!==null&&Vl(c,f,M))}function Y0(c,f,y){var M=Qr(c),C={lane:M,action:y,hasEagerState:!1,eagerState:null,next:null};if(Pp(c))vh(f,C);else{zl(c,f,C);var L=c.alternate;if(c.lanes===0&&(L===null||L.lanes===0)&&(L=f.lastRenderedReducer,L!==null))try{var q=f.lastRenderedState,ne=L(q,y);if(C.hasEagerState=!0,C.eagerState=ne,Ni(ne,q))return}catch{}finally{}y=un(),c=Ai(c,M,y),c!==null&&Vl(c,f,M)}}function Pp(c){var f=c.alternate;return c===Dn||f!==null&&f===Dn}function vh(c,f){ds=Ec=!0;var y=c.pending;y===null?f.next=f:(f.next=y.next,y.next=f),c.pending=f}function zl(c,f,y){Vn!==null&&c.mode&1&&!(Xt&2)?(c=f.interleaved,c===null?(y.next=y,Ar===null?Ar=[f]:Ar.push(f)):(y.next=c.next,c.next=y),f.interleaved=y):(c=f.pending,c===null?y.next=y:(y.next=c.next,c.next=y),f.pending=y)}function Vl(c,f,y){if(y&4194240){var M=f.lanes;M&=c.pendingLanes,y|=M,f.lanes=y,fs(c,y)}}var Xa={readContext:Yi,useCallback:oi,useContext:oi,useEffect:oi,useImperativeHandle:oi,useInsertionEffect:oi,useLayoutEffect:oi,useMemo:oi,useReducer:oi,useRef:oi,useState:oi,useDebugValue:oi,useDeferredValue:oi,useTransition:oi,useMutableSource:oi,useSyncExternalStore:oi,useId:oi,unstable_isNewReconciler:!1},yh={readContext:Yi,useCallback:function(c,f){return Yr().memoizedState=[c,f===void 0?null:f],c},useContext:Yi,useEffect:Rc,useImperativeHandle:function(c,f,y){return y=y!=null?y.concat([c]):null,fo(4194308,4,Bl.bind(null,f,c),y)},useLayoutEffect:function(c,f){return fo(4194308,4,c,f)},useInsertionEffect:function(c,f){return fo(4,2,c,f)},useMemo:function(c,f){var y=Yr();return f=f===void 0?null:f,c=c(),y.memoizedState=[c,f],c},useReducer:function(c,f,y){var M=Yr();return f=y!==void 0?y(f):f,M.memoizedState=M.baseState=f,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:f},M.queue=c,c=c.dispatch=bp.bind(null,Dn,c),[M.memoizedState,c]},useRef:function(c){var f=Yr();return c={current:c},f.memoizedState=c},useState:Ol,useDebugValue:Pc,useDeferredValue:function(c){var f=Ol(c),y=f[0],M=f[1];return Rc(function(){var C=lr.transition;lr.transition={};try{M(c)}finally{lr.transition=C}},[c]),y},useTransition:function(){var c=Ol(!1),f=c[0];return c=Lc.bind(null,c[1]),Yr().memoizedState=c,[f,c]},useMutableSource:function(){},useSyncExternalStore:function(c,f,y){var M=Dn,C=Yr();if(Pn){if(y===void 0)throw Error(a(407));y=y()}else{if(y=f(),Vn===null)throw Error(a(349));Go&30||mh(M,f,y)}C.memoizedState=y;var L={value:y,getSnapshot:f};return C.queue=L,Rc(Is.bind(null,M,L,c),[c]),M.flags|=2048,kl(9,gh.bind(null,M,L,y,f),void 0,null),y},useId:function(){var c=Yr(),f=Vn.identifierPrefix;if(Pn){var y=bs,M=Rs;y=(M&~(1<<32-Cn(M)-1)).toString(32)+y,f=":"+f+"R"+y,y=Wo++,0go&&(f.flags|=128,M=!0,Ds(C,!1),f.lanes=4194304)}else{if(!M)if(c=wc(L),c!==null){if(f.flags|=128,M=!0,c=c.updateQueue,c!==null&&(f.updateQueue=c,f.flags|=4),Ds(C,!0),C.tail===null&&C.tailMode==="hidden"&&!L.alternate&&!Pn)return zn(f),null}else 2*$n()-C.renderingStartTime>go&&y!==1073741824&&(f.flags|=128,M=!0,Ds(C,!1),f.lanes=4194304);C.isBackwards?(L.sibling=f.child,f.child=L):(c=C.last,c!==null?c.sibling=L:f.child=L,C.last=L)}return C.tail!==null?(f=C.tail,C.rendering=f,C.tail=f.sibling,C.renderingStartTime=$n(),f.sibling=null,c=Ln.current,wt(Ln,M?c&1|2:c&1),f):(zn(f),null);case 22:case 23:return tu(),M=f.memoizedState!==null,c!==null&&c.memoizedState!==null!==M&&(f.flags|=8192),M&&f.mode&1?Ti&1073741824&&(zn(f),It&&f.subtreeFlags&6&&(f.flags|=8192)):zn(f),null;case 24:return null;case 25:return null}throw Error(a(156,f.tag))}var wh=u.ReactCurrentOwner,ai=!1;function Fn(c,f,y,M){f.child=c===null?Ap(f,null,y,M):Ps(f,c.child,y,M)}function wn(c,f,y,M,C){y=y.render;var L=f.ref;return La(f,C),M=Va(c,f,y,M,L,C),y=co(),c!==null&&!ai?(f.updateQueue=c.updateQueue,f.flags&=-2053,c.lanes&=~C,Zi(c,f,C)):(Pn&&y&&lh(f),f.flags|=1,Fn(c,f,M,C),f.child)}function Sn(c,f,y,M,C){if(c===null){var L=y.type;return typeof L=="function"&&!jc(L)&&L.defaultProps===void 0&&y.compare===null&&y.defaultProps===void 0?(f.tag=15,f.type=L,Ns(c,f,L,M,C)):(c=Yc(y.type,null,M,f,f.mode,C),c.ref=f.ref,c.return=f,f.child=c)}if(L=c.child,!(c.lanes&C)){var q=L.memoizedProps;if(y=y.compare,y=y!==null?y:Xr,y(q,M)&&c.ref===f.ref)return Zi(c,f,C)}return f.flags|=1,c=Gs(L,M),c.ref=f.ref,c.return=f,f.child=c}function Ns(c,f,y,M,C){if(c!==null&&Xr(c.memoizedProps,M)&&c.ref===f.ref)if(ai=!1,(c.lanes&C)!==0)c.flags&131072&&(ai=!0);else return f.lanes=c.lanes,Zi(c,f,C);return Us(c,f,y,M,C)}function hi(c,f,y){var M=f.pendingProps,C=M.children,L=c!==null?c.memoizedState:null;if(M.mode==="hidden")if(!(f.mode&1))f.memoizedState={baseLanes:0,cachePool:null},wt(na,Ti),Ti|=y;else if(y&1073741824)f.memoizedState={baseLanes:0,cachePool:null},M=L!==null?L.baseLanes:y,wt(na,Ti),Ti|=M;else return c=L!==null?L.baseLanes|y:y,f.lanes=f.childLanes=1073741824,f.memoizedState={baseLanes:c,cachePool:null},f.updateQueue=null,wt(na,Ti),Ti|=c,null;else L!==null?(M=L.baseLanes|y,f.memoizedState=null):M=y,wt(na,Ti),Ti|=M;return Fn(c,f,C,y),f.child}function Oi(c,f){var y=f.ref;(c===null&&y!==null||c!==null&&c.ref!==y)&&(f.flags|=512,f.flags|=2097152)}function Us(c,f,y,M,C){var L=Dt(y)?xt:Qt.current;return L=xn(f,L),La(f,C),y=Va(c,f,y,M,L,C),M=co(),c!==null&&!ai?(f.updateQueue=c.updateQueue,f.flags&=-2053,c.lanes&=~C,Zi(c,f,C)):(Pn&&M&&lh(f),f.flags|=1,Fn(c,f,y,C),f.child)}function qo(c,f,y,M,C){if(Dt(y)){var L=!0;us(f)}else L=!1;if(La(f,C),f.stateNode===null)c!==null&&(c.alternate=null,f.alternate=null,f.flags|=2),Sp(f,y,M),ah(f,y,M,C),M=!0;else if(c===null){var q=f.stateNode,ne=f.memoizedProps;q.props=ne;var we=q.context,Ve=y.contextType;typeof Ve=="object"&&Ve!==null?Ve=Yi(Ve):(Ve=Dt(y)?xt:Qt.current,Ve=xn(f,Ve));var ut=y.getDerivedStateFromProps,zt=typeof ut=="function"||typeof q.getSnapshotBeforeUpdate=="function";zt||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(ne!==M||we!==Ve)&&Mp(f,q,M,Ve),Cr=!1;var Ct=f.memoizedState;q.state=Ct,gc(f,M,q,C),we=f.memoizedState,ne!==M||Ct!==we||Ut.current||Cr?(typeof ut=="function"&&(sh(f,y,ut,M),we=f.memoizedState),(ne=Cr||oh(f,y,ne,M,Ct,we,Ve))?(zt||typeof q.UNSAFE_componentWillMount!="function"&&typeof q.componentWillMount!="function"||(typeof q.componentWillMount=="function"&&q.componentWillMount(),typeof q.UNSAFE_componentWillMount=="function"&&q.UNSAFE_componentWillMount()),typeof q.componentDidMount=="function"&&(f.flags|=4194308)):(typeof q.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=M,f.memoizedState=we),q.props=M,q.state=we,q.context=Ve,M=ne):(typeof q.componentDidMount=="function"&&(f.flags|=4194308),M=!1)}else{q=f.stateNode,rh(c,f),ne=f.memoizedProps,Ve=f.type===f.elementType?ne:ji(f.type,ne),q.props=Ve,zt=f.pendingProps,Ct=q.context,we=y.contextType,typeof we=="object"&&we!==null?we=Yi(we):(we=Dt(y)?xt:Qt.current,we=xn(f,we));var Zt=y.getDerivedStateFromProps;(ut=typeof Zt=="function"||typeof q.getSnapshotBeforeUpdate=="function")||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(ne!==zt||Ct!==we)&&Mp(f,q,M,we),Cr=!1,Ct=f.memoizedState,q.state=Ct,gc(f,M,q,C);var nt=f.memoizedState;ne!==zt||Ct!==nt||Ut.current||Cr?(typeof Zt=="function"&&(sh(f,y,Zt,M),nt=f.memoizedState),(Ve=Cr||oh(f,y,Ve,M,Ct,nt,we)||!1)?(ut||typeof q.UNSAFE_componentWillUpdate!="function"&&typeof q.componentWillUpdate!="function"||(typeof q.componentWillUpdate=="function"&&q.componentWillUpdate(M,nt,we),typeof q.UNSAFE_componentWillUpdate=="function"&&q.UNSAFE_componentWillUpdate(M,nt,we)),typeof q.componentDidUpdate=="function"&&(f.flags|=4),typeof q.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof q.componentDidUpdate!="function"||ne===c.memoizedProps&&Ct===c.memoizedState||(f.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||ne===c.memoizedProps&&Ct===c.memoizedState||(f.flags|=1024),f.memoizedProps=M,f.memoizedState=nt),q.props=M,q.state=nt,q.context=we,M=Ve):(typeof q.componentDidUpdate!="function"||ne===c.memoizedProps&&Ct===c.memoizedState||(f.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||ne===c.memoizedProps&&Ct===c.memoizedState||(f.flags|=1024),M=!1)}return Ei(c,f,y,M,L,C)}function Ei(c,f,y,M,C,L){Oi(c,f);var q=(f.flags&128)!==0;if(!M&&!q)return C&&gn(f,y,!1),Zi(c,f,L);M=f.stateNode,wh.current=f;var ne=q&&typeof y.getDerivedStateFromError!="function"?null:M.render();return f.flags|=1,c!==null&&q?(f.child=Ps(f,c.child,null,L),f.child=Ps(f,null,ne,L)):Fn(c,f,ne,L),f.memoizedState=M.state,C&&gn(f,y,!0),f.child}function Hl(c){var f=c.stateNode;f.pendingContext?wr(c,f.pendingContext,f.pendingContext!==f.context):f.context&&wr(c,f.context,!1),Mc(c,f.containerInfo)}function Eh(c,f,y,M,C){return Fa(),Sc(C),f.flags|=256,Fn(c,f,y,M),f.child}var Gl={dehydrated:null,treeContext:null,retryLane:0};function Zo(c){return{baseLanes:c,cachePool:null}}function Th(c,f,y){var M=f.pendingProps,C=Ln.current,L=!1,q=(f.flags&128)!==0,ne;if((ne=q)||(ne=c!==null&&c.memoizedState===null?!1:(C&2)!==0),ne?(L=!0,f.flags&=-129):(c===null||c.memoizedState!==null)&&(C|=1),wt(Ln,C&1),c===null)return lo(f),c=f.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?(f.mode&1?Gr(c)?f.lanes=8:f.lanes=1073741824:f.lanes=1,null):(C=M.children,c=M.fallback,L?(M=f.mode,L=f.child,C={mode:"hidden",children:C},!(M&1)&&L!==null?(L.childLanes=0,L.pendingProps=C):L=ru(C,M,0,null),c=aa(c,M,y,null),L.return=f,c.return=f,L.sibling=c,f.child=L,f.child.memoizedState=Zo(y),f.memoizedState=Gl,c):Zr(f,C));if(C=c.memoizedState,C!==null){if(ne=C.dehydrated,ne!==null){if(q)return f.flags&256?(f.flags&=-257,Xl(c,f,y,Error(a(422)))):f.memoizedState!==null?(f.child=c.child,f.flags|=128,null):(L=M.fallback,C=f.mode,M=ru({mode:"visible",children:M.children},C,0,null),L=aa(L,C,y,null),L.flags|=2,M.return=f,L.return=f,M.sibling=L,f.child=M,f.mode&1&&Ps(f,c.child,null,y),f.child.memoizedState=Zo(y),f.memoizedState=Gl,L);if(!(f.mode&1))f=Xl(c,f,y,null);else if(Gr(ne))f=Xl(c,f,y,Error(a(419)));else if(M=(y&c.childLanes)!==0,ai||M){if(M=Vn,M!==null){switch(y&-y){case 4:L=2;break;case 16:L=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:L=32;break;case 536870912:L=268435456;break;default:L=0}M=L&(M.suspendedLanes|y)?0:L,M!==0&&M!==C.retryLane&&(C.retryLane=M,Ai(c,M,-1))}Wc(),f=Xl(c,f,y,Error(a(421)))}else as(ne)?(f.flags|=128,f.child=c.child,f=Fp.bind(null,c),Io(ne,f),f=null):(y=C.treeContext,Ne&&(fi=ba(ne),Fi=f,Pn=!0,br=null,Ua=!1,y!==null&&(Rr[or++]=Rs,Rr[or++]=bs,Rr[or++]=ko,Rs=y.id,bs=y.overflow,ko=f)),f=Zr(f,f.pendingProps.children),f.flags|=4096);return f}return L?(M=kc(c,f,M.children,M.fallback,y),L=f.child,C=c.child.memoizedState,L.memoizedState=C===null?Zo(y):{baseLanes:C.baseLanes|y,cachePool:null},L.childLanes=c.childLanes&~y,f.memoizedState=Gl,M):(y=Wl(c,f,M.children,y),f.memoizedState=null,y)}return L?(M=kc(c,f,M.children,M.fallback,y),L=f.child,C=c.child.memoizedState,L.memoizedState=C===null?Zo(y):{baseLanes:C.baseLanes|y,cachePool:null},L.childLanes=c.childLanes&~y,f.memoizedState=Gl,M):(y=Wl(c,f,M.children,y),f.memoizedState=null,y)}function Zr(c,f){return f=ru({mode:"visible",children:f},c.mode,0,null),f.return=c,c.child=f}function Wl(c,f,y,M){var C=c.child;return c=C.sibling,y=Gs(C,{mode:"visible",children:y}),!(f.mode&1)&&(y.lanes=M),y.return=f,y.sibling=null,c!==null&&(M=f.deletions,M===null?(f.deletions=[c],f.flags|=16):M.push(c)),f.child=y}function kc(c,f,y,M,C){var L=f.mode;c=c.child;var q=c.sibling,ne={mode:"hidden",children:y};return!(L&1)&&f.child!==c?(y=f.child,y.childLanes=0,y.pendingProps=ne,f.deletions=null):(y=Gs(c,ne),y.subtreeFlags=c.subtreeFlags&14680064),q!==null?M=Gs(q,M):(M=aa(M,L,C,null),M.flags|=2),M.return=f,y.return=f,y.sibling=M,f.child=y,M}function Xl(c,f,y,M){return M!==null&&Sc(M),Ps(f,c.child,null,y),c=Zr(f,f.pendingProps.children),c.flags|=2,f.memoizedState=null,c}function Lp(c,f,y){c.lanes|=f;var M=c.alternate;M!==null&&(M.lanes|=f),Oo(c.return,f,y)}function ms(c,f,y,M,C){var L=c.memoizedState;L===null?c.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:M,tail:y,tailMode:C}:(L.isBackwards=f,L.rendering=null,L.renderingStartTime=0,L.last=M,L.tail=y,L.tailMode=C)}function Ko(c,f,y){var M=f.pendingProps,C=M.revealOrder,L=M.tail;if(Fn(c,f,M.children,y),M=Ln.current,M&2)M=M&1|2,f.flags|=128;else{if(c!==null&&c.flags&128)e:for(c=f.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&Lp(c,y,f);else if(c.tag===19)Lp(c,y,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}M&=1}if(wt(Ln,M),!(f.mode&1))f.memoizedState=null;else switch(C){case"forwards":for(y=f.child,C=null;y!==null;)c=y.alternate,c!==null&&wc(c)===null&&(C=y),y=y.sibling;y=C,y===null?(C=f.child,f.child=null):(C=y.sibling,y.sibling=null),ms(f,!1,C,y,L);break;case"backwards":for(y=null,C=f.child,f.child=null;C!==null;){if(c=C.alternate,c!==null&&wc(c)===null){f.child=C;break}c=C.sibling,C.sibling=y,y=C,C=c}ms(f,!0,y,null,L);break;case"together":ms(f,!1,null,null,void 0);break;default:f.memoizedState=null}return f.child}function Zi(c,f,y){if(c!==null&&(f.dependencies=c.dependencies),gs|=f.lanes,!(y&f.childLanes))return null;if(c!==null&&f.child!==c.child)throw Error(a(153));if(f.child!==null){for(c=f.child,y=Gs(c,c.pendingProps),f.child=y,y.return=f;c.sibling!==null;)c=c.sibling,y=y.sibling=Gs(c,c.pendingProps),y.return=f;y.sibling=null}return f.child}function Bc(c,f,y){switch(f.tag){case 3:Hl(f),Fa();break;case 5:Cp(f);break;case 1:Dt(f.type)&&us(f);break;case 4:Mc(f,f.stateNode.containerInfo);break;case 10:Fo(f,f.type._context,f.memoizedProps.value);break;case 13:var M=f.memoizedState;if(M!==null)return M.dehydrated!==null?(wt(Ln,Ln.current&1),f.flags|=128,null):y&f.child.childLanes?Th(c,f,y):(wt(Ln,Ln.current&1),c=Zi(c,f,y),c!==null?c.sibling:null);wt(Ln,Ln.current&1);break;case 19:if(M=(y&f.childLanes)!==0,c.flags&128){if(M)return Ko(c,f,y);f.flags|=128}var C=f.memoizedState;if(C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),wt(Ln,Ln.current),M)break;return null;case 22:case 23:return f.lanes=0,hi(c,f,y)}return Zi(c,f,y)}function zc(c,f){switch(uh(f),f.tag){case 1:return Dt(f.type)&&jn(),c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 3:return za(),ot(Ut),ot(Qt),Ho(),c=f.flags,c&65536&&!(c&128)?(f.flags=c&-65537|128,f):null;case 5:return hh(f),null;case 13:if(ot(Ln),c=f.memoizedState,c!==null&&c.dehydrated!==null){if(f.alternate===null)throw Error(a(340));Fa()}return c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 19:return ot(Ln),null;case 4:return za(),null;case 10:return Il(f.type._context),null;case 22:case 23:return tu(),null;case 24:return null;default:return null}}var ki=!1,li=!1,Jo=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function Pr(c,f){var y=c.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(M){zi(c,f,M)}else y.current=null}function Fs(c,f,y){try{y()}catch(M){zi(c,f,M)}}var Ah=!1;function Ch(c,f){for(J(c.containerInfo),Xe=f;Xe!==null;)if(c=Xe,f=c.child,(c.subtreeFlags&1028)!==0&&f!==null)f.return=c,Xe=f;else for(;Xe!==null;){c=Xe;try{var y=c.alternate;if(c.flags&1024)switch(c.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var M=y.memoizedProps,C=y.memoizedState,L=c.stateNode,q=L.getSnapshotBeforeUpdate(c.elementType===c.type?M:ji(c.type,M),C);L.__reactInternalSnapshotBeforeUpdate=q}break;case 3:It&&Re(c.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(ne){zi(c,c.return,ne)}if(f=c.sibling,f!==null){f.return=c.return,Xe=f;break}Xe=c.return}return y=Ah,Ah=!1,y}function Os(c,f,y){var M=f.updateQueue;if(M=M!==null?M.lastEffect:null,M!==null){var C=M=M.next;do{if((C.tag&c)===c){var L=C.destroy;C.destroy=void 0,L!==void 0&&Fs(f,y,L)}C=C.next}while(C!==M)}}function di(c,f){if(f=f.updateQueue,f=f!==null?f.lastEffect:null,f!==null){var y=f=f.next;do{if((y.tag&c)===c){var M=y.create;y.destroy=M()}y=y.next}while(y!==f)}}function Bi(c){var f=c.ref;if(f!==null){var y=c.stateNode;switch(c.tag){case 5:c=ue(y);break;default:c=y}typeof f=="function"?f(c):f.current=c}}function Rn(c,f,y){if(hs&&typeof hs.onCommitFiberUnmount=="function")try{hs.onCommitFiberUnmount(Cl,f)}catch{}switch(f.tag){case 0:case 11:case 14:case 15:if(c=f.updateQueue,c!==null&&(c=c.lastEffect,c!==null)){var M=c=c.next;do{var C=M,L=C.destroy;C=C.tag,L!==void 0&&(C&2||C&4)&&Fs(f,y,L),M=M.next}while(M!==c)}break;case 1:if(Pr(f,y),c=f.stateNode,typeof c.componentWillUnmount=="function")try{c.props=f.memoizedProps,c.state=f.memoizedState,c.componentWillUnmount()}catch(q){zi(f,y,q)}break;case 5:Pr(f,y);break;case 4:It?Ph(c,f,y):Pe&&Pe&&(f=f.stateNode.containerInfo,y=Ke(f),Xn(f,y))}}function Ir(c,f,y){for(var M=f;;)if(Rn(c,M,y),M.child===null||It&&M.tag===4){if(M===f)break;for(;M.sibling===null;){if(M.return===null||M.return===f)return;M=M.return}M.sibling.return=M.return,M=M.sibling}else M.child.return=M,M=M.child}function Rh(c){var f=c.alternate;f!==null&&(c.alternate=null,Rh(f)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(f=c.stateNode,f!==null&&rt(f)),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function bh(c){return c.tag===5||c.tag===3||c.tag===4}function Vc(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||bh(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(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 Hc(c){if(It){e:{for(var f=c.return;f!==null;){if(bh(f))break e;f=f.return}throw Error(a(160))}var y=f;switch(y.tag){case 5:f=y.stateNode,y.flags&32&&(Ot(f),y.flags&=-33),y=Vc(c),Ya(c,y,f);break;case 3:case 4:f=y.stateNode.containerInfo,y=Vc(c),Gc(c,y,f);break;default:throw Error(a(161))}}}function Gc(c,f,y){var M=c.tag;if(M===5||M===6)c=c.stateNode,f?Lt(y,c,f):st(y,c);else if(M!==4&&(c=c.child,c!==null))for(Gc(c,f,y),c=c.sibling;c!==null;)Gc(c,f,y),c=c.sibling}function Ya(c,f,y){var M=c.tag;if(M===5||M===6)c=c.stateNode,f?Tt(y,c,f):Ye(y,c);else if(M!==4&&(c=c.child,c!==null))for(Ya(c,f,y),c=c.sibling;c!==null;)Ya(c,f,y),c=c.sibling}function Ph(c,f,y){for(var M=f,C=!1,L,q;;){if(!C){C=M.return;e:for(;;){if(C===null)throw Error(a(160));switch(L=C.stateNode,C.tag){case 5:q=!1;break e;case 3:L=L.containerInfo,q=!0;break e;case 4:L=L.containerInfo,q=!0;break e}C=C.return}C=!0}if(M.tag===5||M.tag===6)Ir(c,M,y),q?nn(L,M.stateNode):ft(L,M.stateNode);else if(M.tag===18)q?z(L,M.stateNode):rc(L,M.stateNode);else if(M.tag===4){if(M.child!==null){L=M.stateNode.containerInfo,q=!0,M.child.return=M,M=M.child;continue}}else if(Rn(c,M,y),M.child!==null){M.child.return=M,M=M.child;continue}if(M===f)break;for(;M.sibling===null;){if(M.return===null||M.return===f)return;M=M.return,M.tag===4&&(C=!1)}M.sibling.return=M.return,M=M.sibling}}function po(c,f){if(It){switch(f.tag){case 0:case 11:case 14:case 15:Os(3,f,f.return),di(3,f),Os(5,f,f.return);return;case 1:return;case 5:var y=f.stateNode;if(y!=null){var M=f.memoizedProps;c=c!==null?c.memoizedProps:M;var C=f.type,L=f.updateQueue;f.updateQueue=null,L!==null&&ct(y,L,C,c,M,f)}return;case 6:if(f.stateNode===null)throw Error(a(162));y=f.memoizedProps,Ht(f.stateNode,c!==null?c.memoizedProps:y,y);return;case 3:Ne&&c!==null&&c.memoizedState.isDehydrated&&nc(f.stateNode.containerInfo);return;case 12:return;case 13:qa(f);return;case 19:qa(f);return;case 17:return}throw Error(a(163))}switch(f.tag){case 0:case 11:case 14:case 15:Os(3,f,f.return),di(3,f),Os(5,f,f.return);return;case 12:return;case 13:qa(f);return;case 19:qa(f);return;case 3:Ne&&c!==null&&c.memoizedState.isDehydrated&&nc(f.stateNode.containerInfo);break;case 22:case 23:return}e:if(Pe){switch(f.tag){case 1:case 5:case 6:break e;case 3:case 4:f=f.stateNode,Xn(f.containerInfo,f.pendingChildren);break e}throw Error(a(163))}}function qa(c){var f=c.updateQueue;if(f!==null){c.updateQueue=null;var y=c.stateNode;y===null&&(y=c.stateNode=new Jo),f.forEach(function(M){var C=Op.bind(null,c,M);y.has(M)||(y.add(M),M.then(C,C))})}}function Z0(c,f){for(Xe=f;Xe!==null;){f=Xe;var y=f.deletions;if(y!==null)for(var M=0;M";case $o:return":has("+(mo(c)||"")+")";case ea:return'[role="'+c.value+'"]';case Za:return'"'+c.value+'"';case ks:return'[data-testname="'+c.value+'"]';default:throw Error(a(365))}}function cr(c,f){var y=[];c=[c,0];for(var M=0;MC&&(C=q),M&=~L}if(M=C,M=$n()-M,M=(120>M?120:480>M?480:1080>M?1080:1920>M?1920:3e3>M?3e3:4320>M?4320:1960*Dh(M/1960))-M,10c?16:c,vs===null)var M=!1;else{if(c=vs,vs=null,sa=0,Xt&6)throw Error(a(331));var C=Xt;for(Xt|=4,Xe=c.current;Xe!==null;){var L=Xe,q=L.child;if(Xe.flags&16){var ne=L.deletions;if(ne!==null){for(var we=0;we$n()-Ql?Hs(c,0):ia|=y),Ki(c,f)}function zh(c,f){f===0&&(c.mode&1?(f=qt,qt<<=1,!(qt&130023424)&&(qt=4194304)):f=1);var y=un();c=vo(c,f),c!==null&&(Lo(c,f,y),Ki(c,y))}function Fp(c){var f=c.memoizedState,y=0;f!==null&&(y=f.retryLane),zh(c,y)}function Op(c,f){var y=0;switch(c.tag){case 13:var M=c.stateNode,C=c.memoizedState;C!==null&&(y=C.retryLane);break;case 19:M=c.stateNode;break;default:throw Error(a(314))}M!==null&&M.delete(f),zh(c,y)}var Vh;Vh=function(c,f,y){if(c!==null)if(c.memoizedProps!==f.pendingProps||Ut.current)ai=!0;else{if(!(c.lanes&y)&&!(f.flags&128))return ai=!1,Bc(c,f,y);ai=!!(c.flags&131072)}else ai=!1,Pn&&f.flags&1048576&&wp(f,_c,f.index);switch(f.lanes=0,f.tag){case 2:var M=f.type;c!==null&&(c.alternate=null,f.alternate=null,f.flags|=2),c=f.pendingProps;var C=xn(f,Qt.current);La(f,y),C=Va(null,f,M,c,C,y);var L=co();return f.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(f.tag=1,f.memoizedState=null,f.updateQueue=null,Dt(M)?(L=!0,us(f)):L=!1,f.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,Da(f),C.updater=vc,f.stateNode=C,C._reactInternals=f,ah(f,M,c,y),f=Ei(null,f,M,!0,L,y)):(f.tag=0,Pn&&L&&lh(f),Fn(null,f,C,y),f=f.child),f;case 16:M=f.elementType;e:{switch(c!==null&&(c.alternate=null,f.alternate=null,f.flags|=2),c=f.pendingProps,C=M._init,M=C(M._payload),f.type=M,C=f.tag=K0(M),c=ji(M,c),C){case 0:f=Us(null,f,M,c,y);break e;case 1:f=qo(null,f,M,c,y);break e;case 11:f=wn(null,f,M,c,y);break e;case 14:f=Sn(null,f,M,ji(M.type,c),y);break e}throw Error(a(306,M,""))}return f;case 0:return M=f.type,C=f.pendingProps,C=f.elementType===M?C:ji(M,C),Us(c,f,M,C,y);case 1:return M=f.type,C=f.pendingProps,C=f.elementType===M?C:ji(M,C),qo(c,f,M,C,y);case 3:e:{if(Hl(f),c===null)throw Error(a(387));M=f.pendingProps,L=f.memoizedState,C=L.element,rh(c,f),gc(f,M,null,y);var q=f.memoizedState;if(M=q.element,Ne&&L.isDehydrated)if(L={element:M,isDehydrated:!1,cache:q.cache,transitions:q.transitions},f.updateQueue.baseState=L,f.memoizedState=L,f.flags&256){C=Error(a(423)),f=Eh(c,f,M,y,C);break e}else if(M!==C){C=Error(a(424)),f=Eh(c,f,M,y,C);break e}else for(Ne&&(fi=Qu(f.stateNode.containerInfo),Fi=f,Pn=!0,br=null,Ua=!1),y=Ap(f,null,M,y),f.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Fa(),M===C){f=Zi(c,f,y);break e}Fn(c,f,M,y)}f=f.child}return f;case 5:return Cp(f),c===null&&lo(f),M=f.type,C=f.pendingProps,L=c!==null?c.memoizedProps:null,q=C.children,xe(M,C)?q=null:L!==null&&xe(M,L)&&(f.flags|=32),Oi(c,f),Fn(c,f,q,y),f.child;case 6:return c===null&&lo(f),null;case 13:return Th(c,f,y);case 4:return Mc(f,f.stateNode.containerInfo),M=f.pendingProps,c===null?f.child=Ps(f,null,M,y):Fn(c,f,M,y),f.child;case 11:return M=f.type,C=f.pendingProps,C=f.elementType===M?C:ji(M,C),wn(c,f,M,C,y);case 7:return Fn(c,f,f.pendingProps,y),f.child;case 8:return Fn(c,f,f.pendingProps.children,y),f.child;case 12:return Fn(c,f,f.pendingProps.children,y),f.child;case 10:e:{if(M=f.type._context,C=f.pendingProps,L=f.memoizedProps,q=C.value,Fo(f,M,q),L!==null)if(Ni(L.value,q)){if(L.children===C.children&&!Ut.current){f=Zi(c,f,y);break e}}else for(L=f.child,L!==null&&(L.return=f);L!==null;){var ne=L.dependencies;if(ne!==null){q=L.child;for(var we=ne.firstContext;we!==null;){if(we.context===M){if(L.tag===1){we=Cs(-1,y&-y),we.tag=2;var Ve=L.updateQueue;if(Ve!==null){Ve=Ve.shared;var ut=Ve.pending;ut===null?we.next=we:(we.next=ut.next,ut.next=we),Ve.pending=we}}L.lanes|=y,we=L.alternate,we!==null&&(we.lanes|=y),Oo(L.return,y,f),ne.lanes|=y;break}we=we.next}}else if(L.tag===10)q=L.type===f.type?null:L.child;else if(L.tag===18){if(q=L.return,q===null)throw Error(a(341));q.lanes|=y,ne=q.alternate,ne!==null&&(ne.lanes|=y),Oo(q,y,f),q=L.sibling}else q=L.child;if(q!==null)q.return=L;else for(q=L;q!==null;){if(q===f){q=null;break}if(L=q.sibling,L!==null){L.return=q.return,q=L;break}q=q.return}L=q}Fn(c,f,C.children,y),f=f.child}return f;case 9:return C=f.type,M=f.pendingProps.children,La(f,y),C=Yi(C),M=M(C),f.flags|=1,Fn(c,f,M,y),f.child;case 14:return M=f.type,C=ji(M,f.pendingProps),C=ji(M.type,C),Sn(c,f,M,C,y);case 15:return Ns(c,f,f.type,f.pendingProps,y);case 17:return M=f.type,C=f.pendingProps,C=f.elementType===M?C:ji(M,C),c!==null&&(c.alternate=null,f.alternate=null,f.flags|=2),f.tag=1,Dt(M)?(c=!0,us(f)):c=!1,La(f,y),Sp(f,M,C),ah(f,M,C,y),Ei(null,f,M,!0,c,y);case 19:return Ko(c,f,y);case 22:return hi(c,f,y)}throw Error(a(156,f.tag))};function Xc(c,f){return Do(c,f)}function kp(c,f,y,M){this.tag=c,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dr(c,f,y,M){return new kp(c,f,y,M)}function jc(c){return c=c.prototype,!(!c||!c.isReactComponent)}function K0(c){if(typeof c=="function")return jc(c)?1:0;if(c!=null){if(c=c.$$typeof,c===A)return 11;if(c===b)return 14}return 2}function Gs(c,f){var y=c.alternate;return y===null?(y=dr(c.tag,f,c.key,c.mode),y.elementType=c.elementType,y.type=c.type,y.stateNode=c.stateNode,y.alternate=c,c.alternate=y):(y.pendingProps=f,y.type=c.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=c.flags&14680064,y.childLanes=c.childLanes,y.lanes=c.lanes,y.child=c.child,y.memoizedProps=c.memoizedProps,y.memoizedState=c.memoizedState,y.updateQueue=c.updateQueue,f=c.dependencies,y.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},y.sibling=c.sibling,y.index=c.index,y.ref=c.ref,y}function Yc(c,f,y,M,C,L){var q=2;if(M=c,typeof c=="function")jc(c)&&(q=1);else if(typeof c=="string")q=5;else e:switch(c){case m:return aa(y.children,C,L,f);case g:q=8,C|=8;break;case v:return c=dr(12,y,f,C|2),c.elementType=v,c.lanes=L,c;case E:return c=dr(13,y,f,C),c.elementType=E,c.lanes=L,c;case S:return c=dr(19,y,f,C),c.elementType=S,c.lanes=L,c;case I:return ru(y,C,L,f);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case x:q=10;break e;case w:q=9;break e;case A:q=11;break e;case b:q=14;break e;case P:q=16,M=null;break e}throw Error(a(130,c==null?c:typeof c,""))}return f=dr(q,y,f,C),f.elementType=c,f.type=M,f.lanes=L,f}function aa(c,f,y,M){return c=dr(7,c,M,f),c.lanes=y,c}function ru(c,f,y,M){return c=dr(22,c,M,f),c.elementType=I,c.lanes=y,c.stateNode={},c}function qc(c,f,y){return c=dr(6,c,null,f),c.lanes=y,c}function Zc(c,f,y){return f=dr(4,c.children!==null?c.children:[],c.key,f),f.lanes=y,f.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},f}function Kc(c,f,y,M,C){this.tag=f,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=tt,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=oc(0),this.expirationTimes=oc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=oc(0),this.identifierPrefix=M,this.onRecoverableError=C,Ne&&(this.mutableSourceEagerHydrationData=null)}function Bp(c,f,y,M,C,L,q,ne,we){return c=new Kc(c,f,y,ne,we),f===1?(f=1,L===!0&&(f|=8)):f=0,L=dr(3,null,null,f),c.current=L,L.stateNode=c,L.memoizedState={element:M,isDehydrated:y,cache:null,transitions:null},Da(L),c}function zp(c){if(!c)return Jt;c=c._reactInternals;e:{if(U(c)!==c||c.tag!==1)throw Error(a(170));var f=c;do{switch(f.tag){case 3:f=f.stateNode.context;break e;case 1:if(Dt(f.type)){f=f.stateNode.__reactInternalMemoizedMergedChildContext;break e}}f=f.return}while(f!==null);throw Error(a(171))}if(c.tag===1){var y=c.type;if(Dt(y))return Si(c,y,f)}return f}function Vp(c){var f=c._reactInternals;if(f===void 0)throw typeof c.render=="function"?Error(a(188)):(c=Object.keys(c).join(","),Error(a(268,c)));return c=se(f),c===null?null:c.stateNode}function Lr(c,f){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var y=c.retryLane;c.retryLane=y!==0&&y=Ve&&L>=zt&&C<=ut&&q<=Ct){c.splice(f,1);break}else if(M!==Ve||y.width!==we.width||Ctq){if(!(L!==zt||y.height!==we.height||utC)){Ve>M&&(we.width+=Ve-M,we.x=M),utL&&(we.height+=zt-L,we.y=L),Cty&&(y=q)),q ")+` No matching component was found for: `)+c.join(" > ")}return null},t.getPublicRootInstance=function(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 5:return ue(c.child.stateNode);default:return c.child.stateNode}},t.injectIntoDevTools=function(c){if(c={bundleType:c.bundleType,version:c.version,rendererPackageName:c.rendererPackageName,rendererConfig:c.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:u.ReactCurrentDispatcher,findHostInstanceByFiber:Jc,findFiberByHostInstance:c.findFiberByHostInstance||Hp,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")c=!1;else{var f=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(f.isDisabled||!f.supportsFiber)c=!0;else{try{Cl=f.inject(c),hs=f}catch{}c=!!f.checkDCE}}return c},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(c,f,y,M){if(!je)throw Error(a(363));c=Bs(c,f);var C=mt(c,y,M).disconnect;return{disconnect:function(){C()}}},t.registerMutableSourceForHydration=function(c,f){var y=f._getVersion;y=y(f._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[f,y]:c.mutableSourceEagerHydrationData.push(f,y)},t.runWithPriority=function(c,f){var y=$t;try{return $t=c,f()}finally{$t=y}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(c,f,y,M){var C=f.current,L=un(),q=Qr(C);return y=zp(y),f.context===null?f.context=y:f.pendingContext=y,f=Cs(L,q),f.payload={element:c},M=M===void 0?null:M,M!==null&&(f.callback=M),oo(C,f),c=Ai(C,q,L),c!==null&&pc(c,C,q),q},t}),vy}var _M;function HN(){return _M||(_M=1,py.exports=VN()),py.exports}var GN=HN();const WN=tE(GN);var yy={exports:{}},_y={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var xM;function XN(){return xM||(xM=1,function(i){function e(O,J){var K=O.length;O.push(J);e:for(;0>>1,ee=O[G];if(0>>1;Gr(xe,K))ber(Te,xe)?(O[G]=Te,O[be]=K,G=be):(O[G]=xe,O[le]=K,G=le);else if(ber(Te,K))O[G]=Te,O[be]=K,G=be;else break e}}return J}function r(O,J){var K=O.sortIndex-J.sortIndex;return K!==0?K:O.id-J.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;i.unstable_now=function(){return o.now()}}else{var a=Date,u=a.now();i.unstable_now=function(){return a.now()-u}}var h=[],p=[],m=1,g=null,v=3,x=!1,w=!1,A=!1,E=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(O){for(var J=t(p);J!==null;){if(J.callback===null)n(p);else if(J.startTime<=O)n(p),J.sortIndex=J.expirationTime,e(h,J);else break;J=t(p)}}function I(O){if(A=!1,P(O),!w)if(t(h)!==null)w=!0,ue(B);else{var J=t(p);J!==null&&ye(I,J.startTime-O)}}function B(O,J){w=!1,A&&(A=!1,S(H),H=-1),x=!0;var K=v;try{for(P(J),g=t(h);g!==null&&(!(g.expirationTime>J)||O&&!W());){var G=g.callback;if(typeof G=="function"){g.callback=null,v=g.priorityLevel;var ee=G(g.expirationTime<=J);J=i.unstable_now(),typeof ee=="function"?g.callback=ee:g===t(h)&&n(h),P(J)}else n(h);g=t(h)}if(g!==null)var De=!0;else{var le=t(p);le!==null&&ye(I,le.startTime-J),De=!1}return De}finally{g=null,v=K,x=!1}}var F=!1,V=null,H=-1,U=5,D=-1;function W(){return!(i.unstable_now()-DO||125G?(O.sortIndex=K,e(p,O),t(h)===null&&O===t(p)&&(A?(S(H),H=-1):A=!0,ye(I,K-G))):(O.sortIndex=ee,e(h,O),w||x||(w=!0,ue(B))),O},i.unstable_shouldYield=W,i.unstable_wrapCallback=function(O){var J=v;return function(){var K=v;v=J;try{return O.apply(this,arguments)}finally{v=K}}}}(_y)),_y}var SM;function jN(){return SM||(SM=1,yy.exports=XN()),yy.exports}var MM=jN();const mx={},ZT=i=>void Object.assign(mx,i);function YN(i,e){function t(m,{args:g=[],attach:v,...x},w){let A=`${m[0].toUpperCase()}${m.slice(1)}`,E;if(m==="primitive"){if(x.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const S=x.object;E=Ef(S,{type:m,root:w,attach:v,primitive:!0})}else{const S=mx[A];if(!S)throw new Error(`R3F: ${A} 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(!Array.isArray(g))throw new Error("R3F: The args prop must be an array!");E=Ef(new S(...g),{type:m,root:w,attach:v,memoizedProps:{args:g}})}return E.__r3f.attach===void 0&&(E instanceof Yt?E.__r3f.attach="geometry":E instanceof Xi&&(E.__r3f.attach="material")),A!=="inject"&&My(E,x),E}function n(m,g){let v=!1;if(g){var x,w;(x=g.__r3f)!=null&&x.attach?Sy(m,g,g.__r3f.attach):g.isObject3D&&m.isObject3D&&(m.add(g),v=!0),v||(w=m.__r3f)==null||w.objects.push(g),g.__r3f||Ef(g,{}),g.__r3f.parent=m,s_(g),Tf(g)}}function r(m,g,v){let x=!1;if(g){var w,A;if((w=g.__r3f)!=null&&w.attach)Sy(m,g,g.__r3f.attach);else if(g.isObject3D&&m.isObject3D){g.parent=m,g.dispatchEvent({type:"added"}),m.dispatchEvent({type:"childadded",child:g});const E=m.children.filter(b=>b!==g),S=E.indexOf(v);m.children=[...E.slice(0,S),g,...E.slice(S)],x=!0}x||(A=m.__r3f)==null||A.objects.push(g),g.__r3f||Ef(g,{}),g.__r3f.parent=m,s_(g),Tf(g)}}function o(m,g,v=!1){m&&[...m].forEach(x=>a(g,x,v))}function a(m,g,v){if(g){var x,w,A;if(g.__r3f&&(g.__r3f.parent=null),(x=m.__r3f)!=null&&x.objects&&(m.__r3f.objects=m.__r3f.objects.filter(I=>I!==g)),(w=g.__r3f)!=null&&w.attach)CM(m,g,g.__r3f.attach);else if(g.isObject3D&&m.isObject3D){var E;m.remove(g),(E=g.__r3f)!=null&&E.root&&tU(lg(g),g)}const b=(A=g.__r3f)==null?void 0:A.primitive,P=!b&&(v===void 0?g.dispose!==null:v);if(!b){var S;o((S=g.__r3f)==null?void 0:S.objects,g,P),o(g.children,g,P)}if(delete g.__r3f,P&&g.dispose&&g.type!=="Scene"){const I=()=>{try{g.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?MM.unstable_scheduleCallback(MM.unstable_IdlePriority,I):I()}Tf(m)}}function u(m,g,v,x){var w;const A=(w=m.__r3f)==null?void 0:w.parent;if(!A)return;const E=t(g,v,m.__r3f.root);if(m.children){for(const S of m.children)S.__r3f&&n(E,S);m.children=m.children.filter(S=>!S.__r3f)}m.__r3f.objects.forEach(S=>n(E,S)),m.__r3f.objects=[],m.__r3f.autoRemovedBeforeAppend||a(A,m),E.parent&&(E.__r3f.autoRemovedBeforeAppend=!0),n(A,E),E.raycast&&E.__r3f.eventCount&&lg(E).getState().internal.interaction.push(E),[x,x.alternate].forEach(S=>{S!==null&&(S.stateNode=E,S.ref&&(typeof S.ref=="function"?S.ref(E):S.ref.current=E))})}const h=()=>{};return{reconciler:WN({createInstance:t,removeChild:a,appendChild:n,appendInitialChild:n,insertBefore:r,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(m,g)=>{if(!g)return;const v=m.getState().scene;v.__r3f&&(v.__r3f.root=m,n(v,g))},removeChildFromContainer:(m,g)=>{g&&a(m.getState().scene,g)},insertInContainerBefore:(m,g,v)=>{if(!g||!v)return;const x=m.getState().scene;x.__r3f&&r(x,g,v)},getRootHostContext:()=>null,getChildHostContext:m=>m,finalizeInitialChildren(m){var g;return!!((g=m?.__r3f)!=null?g:{}).handlers},prepareUpdate(m,g,v,x){var w;if(((w=m?.__r3f)!=null?w:{}).primitive&&x.object&&x.object!==m)return[!0];{const{args:E=[],children:S,...b}=x,{args:P=[],children:I,...B}=v;if(!Array.isArray(E))throw new Error("R3F: the args prop must be an array!");if(E.some((V,H)=>V!==P[H]))return[!0];const F=nA(m,b,B,!0);return F.changes.length?[!1,F]:null}},commitUpdate(m,[g,v],x,w,A,E){g?u(m,x,A,E):My(m,v)},commitMount(m,g,v,x){var w;const A=(w=m.__r3f)!=null?w:{};m.raycast&&A.handlers&&A.eventCount&&lg(m).getState().internal.interaction.push(m)},getPublicInstance:m=>m,prepareForCommit:()=>null,preparePortalMount:m=>Ef(m.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(m){var g;const{attach:v,parent:x}=(g=m.__r3f)!=null?g:{};v&&x&&CM(x,m,v),m.isObject3D&&(m.visible=!1),Tf(m)},unhideInstance(m,g){var v;const{attach:x,parent:w}=(v=m.__r3f)!=null?v:{};x&&w&&Sy(w,m,x),(m.isObject3D&&g.visible==null||g.visible)&&(m.visible=!0),Tf(m)},createTextInstance:h,hideTextInstance:h,unhideTextInstance:h,getCurrentEventPriority:()=>e?e():If.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&Nn.fun(performance.now)?performance.now:Nn.fun(Date.now)?Date.now:()=>0,scheduleTimeout:Nn.fun(setTimeout)?setTimeout:void 0,cancelTimeout:Nn.fun(clearTimeout)?clearTimeout:void 0}),applyProps:My}}var wM,EM;const xy=i=>"colorSpace"in i||"outputColorSpace"in i,KT=()=>{var i;return(i=mx.ColorManagement)!=null?i:null},JT=i=>i&&i.isOrthographicCamera,qN=i=>i&&i.hasOwnProperty("current"),fp=typeof window<"u"&&((wM=window.document)!=null&&wM.createElement||((EM=window.navigator)==null?void 0:EM.product)==="ReactNative")?Ie.useLayoutEffect:Ie.useEffect;function QT(i){const e=Ie.useRef(i);return fp(()=>void(e.current=i),[i]),e}function ZN({set:i}){return fp(()=>(i(new Promise(()=>null)),()=>i(!1)),[i]),null}class $T extends Ie.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}$T.getDerivedStateFromError=()=>({error:!0});const eA="__default",TM=new Map,KN=i=>i&&!!i.memoized&&!!i.changes;function tA(i){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(i)?Math.min(Math.max(i[0],t),i[1]):i}const ld=i=>{var e;return(e=i.__r3f)==null?void 0:e.root.getState()};function lg(i){let e=i.__r3f.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const Nn={obj:i=>i===Object(i)&&!Nn.arr(i)&&typeof i!="function",fun:i=>typeof i=="function",str:i=>typeof i=="string",num:i=>typeof i=="number",boo:i=>typeof i=="boolean",und:i=>i===void 0,arr:i=>Array.isArray(i),equ(i,e,{arrays:t="shallow",objects:n="reference",strict:r=!0}={}){if(typeof i!=typeof e||!!i!=!!e)return!1;if(Nn.str(i)||Nn.num(i)||Nn.boo(i))return i===e;const o=Nn.obj(i);if(o&&n==="reference")return i===e;const a=Nn.arr(i);if(a&&t==="reference")return i===e;if((a||o)&&i===e)return!0;let u;for(u in i)if(!(u in e))return!1;if(o&&t==="shallow"&&n==="shallow"){for(u in r?e:i)if(!Nn.equ(i[u],e[u],{strict:r,objects:"reference"}))return!1}else for(u in r?e:i)if(i[u]!==e[u])return!1;if(Nn.und(u)){if(a&&i.length===0&&e.length===0||o&&Object.keys(i).length===0&&Object.keys(e).length===0)return!0;if(i!==e)return!1}return!0}};function JN(i){i.dispose&&i.type!=="Scene"&&i.dispose();for(const e in i)e.dispose==null||e.dispose(),delete i[e]}function Ef(i,e){const t=i;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},i}function r_(i,e){let t=i;if(e.includes("-")){const n=e.split("-"),r=n.pop();return t=n.reduce((o,a)=>o[a],i),{target:t,key:r}}else return{target:t,key:e}}const AM=/-\d+$/;function Sy(i,e,t){if(Nn.str(t)){if(AM.test(t)){const o=t.replace(AM,""),{target:a,key:u}=r_(i,o);Array.isArray(a[u])||(a[u]=[])}const{target:n,key:r}=r_(i,t);e.__r3f.previousAttach=n[r],n[r]=e}else e.__r3f.previousAttach=t(i,e)}function CM(i,e,t){var n,r;if(Nn.str(t)){const{target:o,key:a}=r_(i,t),u=e.__r3f.previousAttach;u===void 0?delete o[a]:o[a]=u}else(n=e.__r3f)==null||n.previousAttach==null||n.previousAttach(i,e);(r=e.__r3f)==null||delete r.previousAttach}function nA(i,{children:e,key:t,ref:n,...r},{children:o,key:a,ref:u,...h}={},p=!1){const m=i.__r3f,g=Object.entries(r),v=[];if(p){const w=Object.keys(h);for(let A=0;A{var E;if((E=i.__r3f)!=null&&E.primitive&&w==="object"||Nn.equ(A,h[w]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(w))return v.push([w,A,!0,[]]);let S=[];w.includes("-")&&(S=w.split("-")),v.push([w,A,!1,S]);for(const b in r){const P=r[b];b.startsWith(`${w}-`)&&v.push([b,P,!1,b.split("-")])}});const x={...r};return m!=null&&m.memoizedProps&&m!=null&&m.memoizedProps.args&&(x.args=m.memoizedProps.args),m!=null&&m.memoizedProps&&m!=null&&m.memoizedProps.attach&&(x.attach=m.memoizedProps.attach),{memoized:x,changes:v}}const QN=typeof process<"u"&&!1;function My(i,e){var t;const n=i.__r3f,r=n?.root,o=r==null||r.getState==null?void 0:r.getState(),{memoized:a,changes:u}=KN(e)?e:nA(i,e),h=n?.eventCount;i.__r3f&&(i.__r3f.memoizedProps=a);for(let m=0;mS[b],i),!(E&&E.set))){const[S,...b]=w.reverse();A=b.reverse().reduce((P,I)=>P[I],i),g=S}if(v===eA+"remove")if(A.constructor){let S=TM.get(A.constructor);S||(S=new A.constructor,TM.set(A.constructor,S)),v=S[g]}else v=0;if(x&&n)v?n.handlers[g]=v:delete n.handlers[g],n.eventCount=Object.keys(n.handlers).length;else if(E&&E.set&&(E.copy||E instanceof ku)){if(Array.isArray(v))E.fromArray?E.fromArray(v):E.set(...v);else if(E.copy&&v&&v.constructor&&(QN?E.constructor.name===v.constructor.name:E.constructor===v.constructor))E.copy(v);else if(v!==void 0){const S=E instanceof et;!S&&E.setScalar?E.setScalar(v):E instanceof ku&&v instanceof ku?E.mask=v.mask:E.set(v),!KT()&&o&&!o.linear&&S&&E.convertSRGBToLinear()}}else if(A[g]=v,A[g]instanceof Wn&&A[g].format===ir&&A[g].type===eo&&o){const S=A[g];xy(S)&&xy(o.gl)?S.colorSpace=o.gl.outputColorSpace:S.encoding=o.gl.outputEncoding}Tf(i)}if(n&&n.parent&&i.raycast&&h!==n.eventCount){const m=lg(i).getState().internal,g=m.interaction.indexOf(i);g>-1&&m.interaction.splice(g,1),n.eventCount&&m.interaction.push(i)}return!(u.length===1&&u[0][0]==="onUpdate")&&u.length&&(t=i.__r3f)!=null&&t.parent&&s_(i),i}function Tf(i){var e,t;const n=(e=i.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function s_(i){i.onUpdate==null||i.onUpdate(i)}function $N(i,e){i.manual||(JT(i)?(i.left=e.width/-2,i.right=e.width/2,i.top=e.height/2,i.bottom=e.height/-2):i.aspect=e.width/e.height,i.updateProjectionMatrix(),i.updateMatrixWorld())}function tg(i){return(i.eventObject||i.object).uuid+"/"+i.index+i.instanceId}function eU(){var i;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return If.DefaultEventPriority;switch((i=e.event)==null?void 0:i.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return If.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return If.ContinuousEventPriority;default:return If.DefaultEventPriority}}function iA(i,e,t,n){const r=t.get(e);r&&(t.delete(e),t.size===0&&(i.delete(n),r.target.releasePointerCapture(n)))}function tU(i,e){const{internal:t}=i.getState();t.interaction=t.interaction.filter(n=>n!==e),t.initialHits=t.initialHits.filter(n=>n!==e),t.hovered.forEach((n,r)=>{(n.eventObject===e||n.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((n,r)=>{iA(t.capturedMap,e,n,r)})}function nU(i){function e(h){const{internal:p}=i.getState(),m=h.offsetX-p.initialClick[0],g=h.offsetY-p.initialClick[1];return Math.round(Math.sqrt(m*m+g*g))}function t(h){return h.filter(p=>["Move","Over","Enter","Out","Leave"].some(m=>{var g;return(g=p.__r3f)==null?void 0:g.handlers["onPointer"+m]}))}function n(h,p){const m=i.getState(),g=new Set,v=[],x=p?p(m.internal.interaction):m.internal.interaction;for(let S=0;S{const P=ld(S.object),I=ld(b.object);return!P||!I?S.distance-b.distance:I.events.priority-P.events.priority||S.distance-b.distance}).filter(S=>{const b=tg(S);return g.has(b)?!1:(g.add(b),!0)});m.events.filter&&(A=m.events.filter(A,m));for(const S of A){let b=S.object;for(;b;){var E;(E=b.__r3f)!=null&&E.eventCount&&v.push({...S,eventObject:b}),b=b.parent}}if("pointerId"in h&&m.internal.capturedMap.has(h.pointerId))for(let S of m.internal.capturedMap.get(h.pointerId).values())g.has(tg(S.intersection))||v.push(S.intersection);return v}function r(h,p,m,g){const v=i.getState();if(h.length){const x={stopped:!1};for(const w of h){const A=ld(w.object)||v,{raycaster:E,pointer:S,camera:b,internal:P}=A,I=new j(S.x,S.y,0).unproject(b),B=D=>{var W,se;return(W=(se=P.capturedMap.get(D))==null?void 0:se.has(w.eventObject))!=null?W:!1},F=D=>{const W={intersection:w,target:p.target};P.capturedMap.has(D)?P.capturedMap.get(D).set(w.eventObject,W):P.capturedMap.set(D,new Map([[w.eventObject,W]])),p.target.setPointerCapture(D)},V=D=>{const W=P.capturedMap.get(D);W&&iA(P.capturedMap,w.eventObject,W,D)};let H={};for(let D in p){let W=p[D];typeof W!="function"&&(H[D]=W)}let U={...w,...H,pointer:S,intersections:h,stopped:x.stopped,delta:m,unprojectedPoint:I,ray:E.ray,camera:b,stopPropagation(){const D="pointerId"in p&&P.capturedMap.get(p.pointerId);if((!D||D.has(w.eventObject))&&(U.stopped=x.stopped=!0,P.hovered.size&&Array.from(P.hovered.values()).find(W=>W.eventObject===w.eventObject))){const W=h.slice(0,h.indexOf(w));o([...W,w])}},target:{hasPointerCapture:B,setPointerCapture:F,releasePointerCapture:V},currentTarget:{hasPointerCapture:B,setPointerCapture:F,releasePointerCapture:V},nativeEvent:p};if(g(U),x.stopped===!0)break}}return h}function o(h){const{internal:p}=i.getState();for(const m of p.hovered.values())if(!h.length||!h.find(g=>g.object===m.object&&g.index===m.index&&g.instanceId===m.instanceId)){const v=m.eventObject.__r3f,x=v?.handlers;if(p.hovered.delete(tg(m)),v!=null&&v.eventCount){const w={...m,intersections:h};x.onPointerOut==null||x.onPointerOut(w),x.onPointerLeave==null||x.onPointerLeave(w)}}}function a(h,p){for(let m=0;mo([]);case"onLostPointerCapture":return p=>{const{internal:m}=i.getState();"pointerId"in p&&m.capturedMap.has(p.pointerId)&&requestAnimationFrame(()=>{m.capturedMap.has(p.pointerId)&&(m.capturedMap.delete(p.pointerId),o([]))})}}return function(m){const{onPointerMissed:g,internal:v}=i.getState();v.lastEvent.current=m;const x=h==="onPointerMove",w=h==="onClick"||h==="onContextMenu"||h==="onDoubleClick",E=n(m,x?t:void 0),S=w?e(m):0;h==="onPointerDown"&&(v.initialClick=[m.offsetX,m.offsetY],v.initialHits=E.map(P=>P.eventObject)),w&&!E.length&&S<=2&&(a(m,v.interaction),g&&g(m)),x&&o(E);function b(P){const I=P.eventObject,B=I.__r3f,F=B?.handlers;if(B!=null&&B.eventCount)if(x){if(F.onPointerOver||F.onPointerEnter||F.onPointerOut||F.onPointerLeave){const V=tg(P),H=v.hovered.get(V);H?H.stopped&&P.stopPropagation():(v.hovered.set(V,P),F.onPointerOver==null||F.onPointerOver(P),F.onPointerEnter==null||F.onPointerEnter(P))}F.onPointerMove==null||F.onPointerMove(P)}else{const V=F[h];V?(!w||v.initialHits.includes(I))&&(a(m,v.interaction.filter(H=>!v.initialHits.includes(H))),V(P)):w&&v.initialHits.includes(I)&&a(m,v.interaction.filter(H=>!v.initialHits.includes(H)))}}r(E,m,S,b)}}return{handlePointer:u}}const rA=i=>!!(i!=null&&i.render),sA=Ie.createContext(null),iU=(i,e)=>{const t=kN((u,h)=>{const p=new j,m=new j,g=new j;function v(S=h().camera,b=m,P=h().size){const{width:I,height:B,top:F,left:V}=P,H=I/B;b instanceof j?g.copy(b):g.set(...b);const U=S.getWorldPosition(p).distanceTo(g);if(JT(S))return{width:I/S.zoom,height:B/S.zoom,top:F,left:V,factor:1,distance:U,aspect:H};{const D=S.fov*Math.PI/180,W=2*Math.tan(D/2)*U,se=W*(I/B);return{width:se,height:W,top:F,left:V,factor:I/se,distance:U,aspect:H}}}let x;const w=S=>u(b=>({performance:{...b.performance,current:S}})),A=new Ce;return{set:u,get:h,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(S=1)=>i(h(),S),advance:(S,b)=>e(S,b,h()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new cp,pointer:A,mouse:A,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const S=h();x&&clearTimeout(x),S.performance.current!==S.performance.min&&w(S.performance.min),x=setTimeout(()=>w(h().performance.max),S.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:v},setEvents:S=>u(b=>({...b,events:{...b.events,...S}})),setSize:(S,b,P,I,B)=>{const F=h().camera,V={width:S,height:b,top:I||0,left:B||0,updateStyle:P};u(H=>({size:V,viewport:{...H.viewport,...v(F,m,V)}}))},setDpr:S=>u(b=>{const P=tA(S);return{viewport:{...b.viewport,dpr:P,initialDpr:b.viewport.initialDpr||P}}}),setFrameloop:(S="always")=>{const b=h().clock;b.stop(),b.elapsedTime=0,S!=="never"&&(b.start(),b.elapsedTime=0),u(()=>({frameloop:S}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:Ie.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(S,b,P)=>{const I=h().internal;return I.priority=I.priority+(b>0?1:0),I.subscribers.push({ref:S,priority:b,store:P}),I.subscribers=I.subscribers.sort((B,F)=>B.priority-F.priority),()=>{const B=h().internal;B!=null&&B.subscribers&&(B.priority=B.priority-(b>0?1:0),B.subscribers=B.subscribers.filter(F=>F.ref!==S))}}}}}),n=t.getState();let r=n.size,o=n.viewport.dpr,a=n.camera;return t.subscribe(()=>{const{camera:u,size:h,viewport:p,gl:m,set:g}=t.getState();if(h.width!==r.width||h.height!==r.height||p.dpr!==o){var v;r=h,o=p.dpr,$N(u,h),m.setPixelRatio(p.dpr);const x=(v=h.updateStyle)!=null?v:typeof HTMLCanvasElement<"u"&&m.domElement instanceof HTMLCanvasElement;m.setSize(h.width,h.height,x)}u!==a&&(a=u,g(x=>({viewport:{...x.viewport,...x.viewport.getCurrentViewport(u)}})))}),t.subscribe(u=>i(u)),t};let ng,rU=new Set,sU=new Set,oU=new Set;function wy(i,e){if(i.size)for(const{callback:t}of i.values())t(e)}function ud(i,e){switch(i){case"before":return wy(rU,e);case"after":return wy(sU,e);case"tail":return wy(oU,e)}}let Ey,Ty;function Ay(i,e,t){let n=e.clock.getDelta();for(e.frameloop==="never"&&typeof i=="number"&&(n=i-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=i),Ey=e.internal.subscribers,ng=0;ng0)&&!((m=o.gl.xr)!=null&&m.isPresenting)&&(n+=Ay(p,o))}if(t=!1,ud("after",p),n===0)return ud("tail",p),e=!1,cancelAnimationFrame(r)}function u(p,m=1){var g;if(!p)return i.forEach(v=>u(v.store.getState(),m));(g=p.gl.xr)!=null&&g.isPresenting||!p.internal.active||p.frameloop==="never"||(m>1?p.internal.frames=Math.min(60,p.internal.frames+m):t?p.internal.frames=2:p.internal.frames=1,e||(e=!0,requestAnimationFrame(a)))}function h(p,m=!0,g,v){if(m&&ud("before",p),g)Ay(p,g,v);else for(const x of i.values())Ay(p,x.store.getState());m&&ud("after",p)}return{loop:a,invalidate:u,advance:h}}function oA(){const i=Ie.useContext(sA);if(!i)throw new Error("R3F: Hooks can only be used within the Canvas component!");return i}function lU(i=t=>t,e){return oA()(i,e)}function aA(i,e=0){const t=oA(),n=t.getState().internal.subscribe,r=QT(i);return fp(()=>n(r,e,t),[e,n,t]),null}const Gf=new Map,{invalidate:RM,advance:bM}=aU(Gf),{reconciler:$g,applyProps:Sf}=YN(Gf,eU),Mf={objects:"shallow",strict:!1},uU=(i,e)=>{const t=typeof i=="function"?i(e):i;return rA(t)?t:new qT({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...i})};function cU(i,e){const t=typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement;if(e){const{width:n,height:r,top:o,left:a,updateStyle:u=t}=e;return{width:n,height:r,top:o,left:a,updateStyle:u}}else if(typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement&&i.parentElement){const{width:n,height:r,top:o,left:a}=i.parentElement.getBoundingClientRect();return{width:n,height:r,top:o,left:a,updateStyle:t}}else if(typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas)return{width:i.width,height:i.height,top:0,left:0,updateStyle:t};return{width:0,height:0,top:0,left:0}}function fU(i){const e=Gf.get(i),t=e?.fiber,n=e?.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,o=n||iU(RM,bM),a=t||$g.createContainer(o,If.ConcurrentRoot,null,!1,null,"",r,null);e||Gf.set(i,{fiber:a,store:o});let u,h=!1,p;return{configure(m={}){let{gl:g,size:v,scene:x,events:w,onCreated:A,shadows:E=!1,linear:S=!1,flat:b=!1,legacy:P=!1,orthographic:I=!1,frameloop:B="always",dpr:F=[1,2],performance:V,raycaster:H,camera:U,onPointerMissed:D}=m,W=o.getState(),se=W.gl;W.gl||W.set({gl:se=uU(g,i)});let ie=W.raycaster;ie||W.set({raycaster:ie=new zT});const{params:fe,...Me}=H||{};if(Nn.equ(Me,ie,Mf)||Sf(ie,{...Me}),Nn.equ(fe,ie.params,Mf)||Sf(ie,{params:{...ie.params,...fe}}),!W.camera||W.camera===p&&!Nn.equ(p,U,Mf)){p=U;const K=U instanceof tp,G=K?U:I?new Jf(0,0,0,0,.1,1e3):new Pi(75,0,.1,1e3);K||(G.position.z=5,U&&(Sf(G,U),("aspect"in U||"left"in U||"right"in U||"bottom"in U||"top"in U)&&(G.manual=!0,G.updateProjectionMatrix())),!W.camera&&!(U!=null&&U.rotation)&&G.lookAt(0,0,0)),W.set({camera:G}),ie.camera=G}if(!W.scene){let K;x instanceof Zg?K=x:(K=new Zg,x&&Sf(K,x)),W.set({scene:Ef(K)})}if(!W.xr){var ue;const K=(De,le)=>{const xe=o.getState();xe.frameloop!=="never"&&bM(De,!0,xe,le)},G=()=>{const De=o.getState();De.gl.xr.enabled=De.gl.xr.isPresenting,De.gl.xr.setAnimationLoop(De.gl.xr.isPresenting?K:null),De.gl.xr.isPresenting||RM(De)},ee={connect(){const De=o.getState().gl;De.xr.addEventListener("sessionstart",G),De.xr.addEventListener("sessionend",G)},disconnect(){const De=o.getState().gl;De.xr.removeEventListener("sessionstart",G),De.xr.removeEventListener("sessionend",G)}};typeof((ue=se.xr)==null?void 0:ue.addEventListener)=="function"&&ee.connect(),W.set({xr:ee})}if(se.shadowMap){const K=se.shadowMap.enabled,G=se.shadowMap.type;if(se.shadowMap.enabled=!!E,Nn.boo(E))se.shadowMap.type=gd;else if(Nn.str(E)){var ye;const ee={basic:rE,percentage:u0,soft:gd,variance:Qs};se.shadowMap.type=(ye=ee[E])!=null?ye:gd}else Nn.obj(E)&&Object.assign(se.shadowMap,E);(K!==se.shadowMap.enabled||G!==se.shadowMap.type)&&(se.shadowMap.needsUpdate=!0)}const O=KT();O&&("enabled"in O?O.enabled=!P:"legacyMode"in O&&(O.legacyMode=P)),h||Sf(se,{outputEncoding:S?3e3:3001,toneMapping:b?wo:c0}),W.legacy!==P&&W.set(()=>({legacy:P})),W.linear!==S&&W.set(()=>({linear:S})),W.flat!==b&&W.set(()=>({flat:b})),g&&!Nn.fun(g)&&!rA(g)&&!Nn.equ(g,se,Mf)&&Sf(se,g),w&&!W.events.handlers&&W.set({events:w(o)});const J=cU(i,v);return Nn.equ(J,W.size,Mf)||W.setSize(J.width,J.height,J.updateStyle,J.top,J.left),F&&W.viewport.dpr!==tA(F)&&W.setDpr(F),W.frameloop!==B&&W.setFrameloop(B),W.onPointerMissed||W.set({onPointerMissed:D}),V&&!Nn.equ(V,W.performance,Mf)&&W.set(K=>({performance:{...K.performance,...V}})),u=A,h=!0,this},render(m){return h||this.configure(),$g.updateContainer(tn.jsx(hU,{store:o,children:m,onCreated:u,rootElement:i}),a,null,()=>{}),o},unmount(){lA(i)}}}function hU({store:i,children:e,onCreated:t,rootElement:n}){return fp(()=>{const r=i.getState();r.set(o=>({internal:{...o.internal,active:!0}})),t&&t(r),i.getState().events.connected||r.events.connect==null||r.events.connect(n)},[]),tn.jsx(sA.Provider,{value:i,children:e})}function lA(i,e){const t=Gf.get(i),n=t?.fiber;if(n){const r=t?.store.getState();r&&(r.internal.active=!1),$g.updateContainer(null,n,null,()=>{r&&setTimeout(()=>{try{var o,a,u,h;r.events.disconnect==null||r.events.disconnect(),(o=r.gl)==null||(a=o.renderLists)==null||a.dispose==null||a.dispose(),(u=r.gl)==null||u.forceContextLoss==null||u.forceContextLoss(),(h=r.gl)!=null&&h.xr&&r.xr.disconnect(),JN(r),Gf.delete(i)}catch{}},500)})}}$g.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:Ie.version});const Cy={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 dU(i){const{handlePointer:e}=nU(i);return{priority:1,enabled:!0,compute(t,n,r){n.pointer.set(t.offsetX/n.size.width*2-1,-(t.offsetY/n.size.height)*2+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(Cy).reduce((t,n)=>({...t,[n]:e(n)}),{}),update:()=>{var t;const{events:n,internal:r}=i.getState();(t=r.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{var n;const{set:r,events:o}=i.getState();o.disconnect==null||o.disconnect(),r(a=>({events:{...a.events,connected:t}})),Object.entries((n=o.handlers)!=null?n:[]).forEach(([a,u])=>{const[h,p]=Cy[a];t.addEventListener(h,u,{passive:p})})},disconnect:()=>{const{set:t,events:n}=i.getState();if(n.connected){var r;Object.entries((r=n.handlers)!=null?r:[]).forEach(([o,a])=>{if(n&&n.connected instanceof HTMLElement){const[u]=Cy[o];n.connected.removeEventListener(u,a)}}),t(o=>({events:{...o.events,connected:void 0}}))}}}}var Ry,PM;function pU(){if(PM)return Ry;PM=1;function i(e,t,n){var r,o,a,u,h;t==null&&(t=100);function p(){var g=Date.now()-u;g=0?r=setTimeout(p,t-g):(r=null,n||(h=e.apply(a,o),a=o=null))}var m=function(){a=this,o=arguments,u=Date.now();var g=n&&!r;return r||(r=setTimeout(p,t)),g&&(h=e.apply(a,o),a=o=null),h};return m.clear=function(){r&&(clearTimeout(r),r=null)},m.flush=function(){r&&(h=e.apply(a,o),a=o=null,clearTimeout(r),r=null)},m}return i.debounce=i,Ry=i,Ry}var mU=pU();const IM=tE(mU);var gU=Object.defineProperty,vU=Object.defineProperties,yU=Object.getOwnPropertyDescriptors,LM=Object.getOwnPropertySymbols,_U=Object.prototype.hasOwnProperty,xU=Object.prototype.propertyIsEnumerable,DM=(i,e,t)=>e in i?gU(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,NM=(i,e)=>{for(var t in e||(e={}))_U.call(e,t)&&DM(i,t,e[t]);if(LM)for(var t of LM(e))xU.call(e,t)&&DM(i,t,e[t]);return i},SU=(i,e)=>vU(i,yU(e)),UM,FM;typeof window<"u"&&((UM=window.document)!=null&&UM.createElement||((FM=window.navigator)==null?void 0:FM.product)==="ReactNative")?Ie.useLayoutEffect:Ie.useEffect;function uA(i,e,t){if(!i)return;if(t(i)===!0)return i;let n=i.child;for(;n;){const r=uA(n,e,t);if(r)return r;n=n.sibling}}function cA(i){try{return Object.defineProperties(i,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return i}}const OM=console.error;console.error=function(){const i=[...arguments].join("");if(i?.startsWith("Warning:")&&i.includes("useContext")){console.error=OM;return}return OM.apply(this,arguments)};const gx=cA(Ie.createContext(null));class fA extends Ie.Component{render(){return Ie.createElement(gx.Provider,{value:this._reactInternals},this.props.children)}}function MU(){const i=Ie.useContext(gx);if(i===null)throw new Error("its-fine: useFiber must be called within a !");const e=Ie.useId();return Ie.useMemo(()=>{for(const n of[i,i?.alternate]){if(!n)continue;const r=uA(n,!1,o=>{let a=o.memoizedState;for(;a;){if(a.memoizedState===e)return!0;a=a.next}});if(r)return r}},[i,e])}function wU(){const i=MU(),[e]=Ie.useState(()=>new Map);e.clear();let t=i;for(;t;){if(t.type&&typeof t.type=="object"){const r=t.type._context===void 0&&t.type.Provider===t.type?t.type:t.type._context;r&&r!==gx&&!e.has(r)&&e.set(r,Ie.useContext(cA(r)))}t=t.return}return e}function EU(){const i=wU();return Ie.useMemo(()=>Array.from(i.keys()).reduce((e,t)=>n=>Ie.createElement(e,null,Ie.createElement(t.Provider,SU(NM({},n),{value:i.get(t)}))),e=>Ie.createElement(fA,NM({},e))),[i])}function TU({debounce:i,scroll:e,polyfill:t,offsetSize:n}={debounce:0,scroll:!1,offsetSize:!1}){const r=t||typeof window<"u"&&window.ResizeObserver,[o,a]=Ie.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0});if(!r)return o.width=1280,o.height=800,[()=>{},o,()=>{}];const u=Ie.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o,orientationHandler:null}),h=i?typeof i=="number"?i:i.scroll:null,p=i?typeof i=="number"?i:i.resize:null,m=Ie.useRef(!1);Ie.useEffect(()=>(m.current=!0,()=>void(m.current=!1)));const[g,v,x]=Ie.useMemo(()=>{const S=()=>{if(!u.current.element)return;const{left:b,top:P,width:I,height:B,bottom:F,right:V,x:H,y:U}=u.current.element.getBoundingClientRect(),D={left:b,top:P,width:I,height:B,bottom:F,right:V,x:H,y:U};u.current.element instanceof HTMLElement&&n&&(D.height=u.current.element.offsetHeight,D.width=u.current.element.offsetWidth),Object.freeze(D),m.current&&!bU(u.current.lastBounds,D)&&a(u.current.lastBounds=D)};return[S,p?IM(S,p):S,h?IM(S,h):S]},[a,n,h,p]);function w(){u.current.scrollContainers&&(u.current.scrollContainers.forEach(S=>S.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(){var S;u.current.element&&(u.current.resizeObserver=new r(v),(S=u.current.resizeObserver)==null||S.observe(u.current.element),e&&u.current.scrollContainers&&u.current.scrollContainers.forEach(b=>b.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 E=S=>{!S||S===u.current.element||(w(),u.current.element=S,u.current.scrollContainers=hA(S),A())};return CU(x,!!e),AU(v),Ie.useEffect(()=>{w(),A()},[e,x,v]),Ie.useEffect(()=>w,[]),[E,o,g]}function AU(i){Ie.useEffect(()=>{const e=i;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[i])}function CU(i,e){Ie.useEffect(()=>{if(e){const t=i;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[i,e])}function hA(i){const e=[];if(!i||i===document.body)return e;const{overflow:t,overflowX:n,overflowY:r}=window.getComputedStyle(i);return[t,n,r].some(o=>o==="auto"||o==="scroll")&&e.push(i),[...e,...hA(i.parentElement)]}const RU=["x","y","top","bottom","left","right","width","height"],bU=(i,e)=>RU.every(t=>i[t]===e[t]),PU=Ie.forwardRef(function({children:e,fallback:t,resize:n,style:r,gl:o,events:a=dU,eventSource:u,eventPrefix:h,shadows:p,linear:m,flat:g,legacy:v,orthographic:x,frameloop:w,dpr:A,performance:E,raycaster:S,camera:b,scene:P,onPointerMissed:I,onCreated:B,...F},V){Ie.useMemo(()=>ZT(DN),[]);const H=EU(),[U,D]=TU({scroll:!0,debounce:{scroll:50,resize:0},...n}),W=Ie.useRef(null),se=Ie.useRef(null);Ie.useImperativeHandle(V,()=>W.current);const ie=QT(I),[fe,Me]=Ie.useState(!1),[ue,ye]=Ie.useState(!1);if(fe)throw fe;if(ue)throw ue;const O=Ie.useRef(null);fp(()=>{const K=W.current;D.width>0&&D.height>0&&K&&(O.current||(O.current=fU(K)),O.current.configure({gl:o,events:a,shadows:p,linear:m,flat:g,legacy:v,orthographic:x,frameloop:w,dpr:A,performance:E,raycaster:S,camera:b,scene:P,size:D,onPointerMissed:(...G)=>ie.current==null?void 0:ie.current(...G),onCreated:G=>{G.events.connect==null||G.events.connect(u?qN(u)?u.current:u:se.current),h&&G.setEvents({compute:(ee,De)=>{const le=ee[h+"X"],xe=ee[h+"Y"];De.pointer.set(le/De.size.width*2-1,-(xe/De.size.height)*2+1),De.raycaster.setFromCamera(De.pointer,De.camera)}}),B?.(G)}}),O.current.render(tn.jsx(H,{children:tn.jsx($T,{set:ye,children:tn.jsx(Ie.Suspense,{fallback:tn.jsx(ZN,{set:Me}),children:e})})})))}),Ie.useEffect(()=>{const K=W.current;if(K)return()=>lA(K)},[]);const J=u?"none":"auto";return tn.jsx("div",{ref:se,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:J,...r},...F,children:tn.jsx("div",{ref:U,style:{width:"100%",height:"100%"},children:tn.jsx("canvas",{ref:W,style:{display:"block"},children:t})})})}),IU=Ie.forwardRef(function(e,t){return tn.jsx(fA,{children:tn.jsx(PU,{...e,ref:t})})});function LU(i){if(typeof Proxy>"u")return i;const e=new Map,t=(...n)=>i(...n);return new Proxy(t,{get:(n,r)=>r==="create"?i:(e.has(r)||e.set(r,i(r)),e.get(r))})}function z0(i){return i!==null&&typeof i=="object"&&typeof i.start=="function"}const o_=i=>Array.isArray(i);function dA(i,e){if(!Array.isArray(e))return!1;const t=e.length;if(t!==i.length)return!1;for(let n=0;n{e[0][n]=t.get(),e[1][n]=t.getVelocity()}),e}function vx(i,e,t,n){if(typeof e=="function"){const[r,o]=kM(n);e=e(t!==void 0?t:i.custom,r,o)}if(typeof e=="string"&&(e=i.variants&&i.variants[e]),typeof e=="function"){const[r,o]=kM(n);e=e(t!==void 0?t:i.custom,r,o)}return e}function V0(i,e,t){const n=i.getProps();return vx(n,e,t!==void 0?t:n.custom,i)}const yx=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],_x=["initial",...yx],hp=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ju=new Set(hp),xa=i=>i*1e3,Sa=i=>i/1e3,DU={type:"spring",stiffness:500,damping:25,restSpeed:10},NU=i=>({type:"spring",stiffness:550,damping:i===0?2*Math.sqrt(550):30,restSpeed:10}),UU={type:"keyframes",duration:.8},FU={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},OU=(i,{keyframes:e})=>e.length>2?UU:Ju.has(i)?i.startsWith("scale")?NU(e[1]):DU:FU;function xx(i,e){return i?i[e]||i.default||i:void 0}const kU={skipAnimations:!1,useManualTiming:!1},BU=i=>i!==null;function H0(i,{repeat:e,repeatType:t="loop"},n){const r=i.filter(BU),o=e&&t!=="loop"&&e%2===1?0:r.length-1;return!o||n===void 0?r[o]:n}const rs=i=>i;let a_=rs;function zU(i){let e=new Set,t=new Set,n=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function u(p){o.has(p)&&(h.schedule(p),i()),p(a)}const h={schedule:(p,m=!1,g=!1)=>{const x=g&&n?e:t;return m&&o.add(p),x.has(p)||x.add(p),p},cancel:p=>{t.delete(p),o.delete(p)},process:p=>{if(a=p,n){r=!0;return}n=!0,[e,t]=[t,e],e.forEach(u),e.clear(),n=!1,r&&(r=!1,h.process(p))}};return h}const ig=["read","resolveKeyframes","update","preRender","render","postRender"],VU=40;function pA(i,e){let t=!1,n=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>t=!0,a=ig.reduce((S,b)=>(S[b]=zU(o),S),{}),{read:u,resolveKeyframes:h,update:p,preRender:m,render:g,postRender:v}=a,x=()=>{const S=performance.now();t=!1,r.delta=n?1e3/60:Math.max(Math.min(S-r.timestamp,VU),1),r.timestamp=S,r.isProcessing=!0,u.process(r),h.process(r),p.process(r),m.process(r),g.process(r),v.process(r),r.isProcessing=!1,t&&e&&(n=!1,i(x))},w=()=>{t=!0,n=!0,r.isProcessing||i(x)};return{schedule:ig.reduce((S,b)=>{const P=a[b];return S[b]=(I,B=!1,F=!1)=>(t||w(),P.schedule(I,B,F)),S},{}),cancel:S=>{for(let b=0;b(((1-3*t+3*e)*i+(3*t-6*e))*i+3*e)*i,HU=1e-7,GU=12;function WU(i,e,t,n,r){let o,a,u=0;do a=e+(t-e)/2,o=mA(a,n,r)-i,o>0?t=a:e=a;while(Math.abs(o)>HU&&++uWU(o,0,1,i,t);return o=>o===0||o===1?o:mA(r(o),e,n)}const gA=i=>e=>e<=.5?i(2*e)/2:(2-i(2*(1-e)))/2,vA=i=>e=>1-i(1-e),yA=dp(.33,1.53,.69,.99),Sx=vA(yA),_A=gA(Sx),xA=i=>(i*=2)<1?.5*Sx(i):.5*(2-Math.pow(2,-10*(i-1))),Mx=i=>1-Math.sin(Math.acos(i)),SA=vA(Mx),MA=gA(Mx),wA=i=>/^0[^.\s]+$/u.test(i);function XU(i){return typeof i=="number"?i===0:i!==null?i==="none"||i==="0"||wA(i):!0}const EA=i=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(i),TA=i=>e=>typeof e=="string"&&e.startsWith(i),AA=TA("--"),jU=TA("var(--"),wx=i=>jU(i)?YU.test(i.split("/*")[0].trim()):!1,YU=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,qU=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ZU(i){const e=qU.exec(i);if(!e)return[,];const[,t,n,r]=e;return[`--${t??n}`,r]}function CA(i,e,t=1){const[n,r]=ZU(i);if(!n)return;const o=window.getComputedStyle(e).getPropertyValue(n);if(o){const a=o.trim();return EA(a)?parseFloat(a):a}return wx(r)?CA(r,e,t+1):r}const Aa=(i,e,t)=>t>e?e:ttypeof i=="number",parse:parseFloat,transform:i=>i},Zd={...$f,transform:i=>Aa(0,1,i)},rg={...$f,default:1},pp=i=>({test:e=>typeof e=="string"&&e.endsWith(i)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${i}`}),ml=pp("deg"),Co=pp("%"),Nt=pp("px"),KU=pp("vh"),JU=pp("vw"),BM={...Co,parse:i=>Co.parse(i)/100,transform:i=>Co.transform(i*100)},QU=new Set(["width","height","top","left","right","bottom","x","y","translateX","translateY"]),zM=i=>i===$f||i===Nt,VM=(i,e)=>parseFloat(i.split(", ")[e]),HM=(i,e)=>(t,{transform:n})=>{if(n==="none"||!n)return 0;const r=n.match(/^matrix3d\((.+)\)$/u);if(r)return VM(r[1],e);{const o=n.match(/^matrix\((.+)\)$/u);return o?VM(o[1],i):0}},$U=new Set(["x","y","z"]),eF=hp.filter(i=>!$U.has(i));function tF(i){const e=[];return eF.forEach(t=>{const n=i.getValue(t);n!==void 0&&(e.push([t,n.get()]),n.set(t.startsWith("scale")?1:0))}),e}const Wf={width:({x:i},{paddingLeft:e="0",paddingRight:t="0"})=>i.max-i.min-parseFloat(e)-parseFloat(t),height:({y:i},{paddingTop:e="0",paddingBottom:t="0"})=>i.max-i.min-parseFloat(e)-parseFloat(t),top:(i,{top:e})=>parseFloat(e),left:(i,{left:e})=>parseFloat(e),bottom:({y:i},{top:e})=>parseFloat(e)+(i.max-i.min),right:({x:i},{left:e})=>parseFloat(e)+(i.max-i.min),x:HM(4,13),y:HM(5,14)};Wf.translateX=Wf.x;Wf.translateY=Wf.y;const RA=i=>e=>e.test(i),nF={test:i=>i==="auto",parse:i=>i},bA=[$f,Nt,Co,ml,JU,KU,nF],GM=i=>bA.find(RA(i)),zu=new Set;let l_=!1,u_=!1;function PA(){if(u_){const i=Array.from(zu).filter(n=>n.needsMeasurement),e=new Set(i.map(n=>n.element)),t=new Map;e.forEach(n=>{const r=tF(n);r.length&&(t.set(n,r),n.render())}),i.forEach(n=>n.measureInitialState()),e.forEach(n=>{n.render();const r=t.get(n);r&&r.forEach(([o,a])=>{var u;(u=n.getValue(o))===null||u===void 0||u.set(a)})}),i.forEach(n=>n.measureEndState()),i.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}u_=!1,l_=!1,zu.forEach(i=>i.complete()),zu.clear()}function IA(){zu.forEach(i=>{i.readKeyframes(),i.needsMeasurement&&(u_=!0)})}function iF(){IA(),PA()}class Ex{constructor(e,t,n,r,o,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=o,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(zu.add(this),l_||(l_=!0,Un.read(IA),Un.resolveKeyframes(PA))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;for(let o=0;oMath.round(i*1e5)/1e5,Tx=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function rF(i){return i==null}const sF=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ax=(i,e)=>t=>!!(typeof t=="string"&&sF.test(t)&&t.startsWith(i)||e&&!rF(t)&&Object.prototype.hasOwnProperty.call(t,e)),LA=(i,e,t)=>n=>{if(typeof n!="string")return n;const[r,o,a,u]=n.match(Tx);return{[i]:parseFloat(r),[e]:parseFloat(o),[t]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},oF=i=>Aa(0,255,i),Py={...$f,transform:i=>Math.round(oF(i))},Nu={test:Ax("rgb","red"),parse:LA("red","green","blue"),transform:({red:i,green:e,blue:t,alpha:n=1})=>"rgba("+Py.transform(i)+", "+Py.transform(e)+", "+Py.transform(t)+", "+Ad(Zd.transform(n))+")"};function aF(i){let e="",t="",n="",r="";return i.length>5?(e=i.substring(1,3),t=i.substring(3,5),n=i.substring(5,7),r=i.substring(7,9)):(e=i.substring(1,2),t=i.substring(2,3),n=i.substring(3,4),r=i.substring(4,5),e+=e,t+=t,n+=n,r+=r),{red:parseInt(e,16),green:parseInt(t,16),blue:parseInt(n,16),alpha:r?parseInt(r,16)/255:1}}const c_={test:Ax("#"),parse:aF,transform:Nu.transform},Lf={test:Ax("hsl","hue"),parse:LA("hue","saturation","lightness"),transform:({hue:i,saturation:e,lightness:t,alpha:n=1})=>"hsla("+Math.round(i)+", "+Co.transform(Ad(e))+", "+Co.transform(Ad(t))+", "+Ad(Zd.transform(n))+")"},nr={test:i=>Nu.test(i)||c_.test(i)||Lf.test(i),parse:i=>Nu.test(i)?Nu.parse(i):Lf.test(i)?Lf.parse(i):c_.parse(i),transform:i=>typeof i=="string"?i:i.hasOwnProperty("red")?Nu.transform(i):Lf.transform(i)},lF=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function uF(i){var e,t;return isNaN(i)&&typeof i=="string"&&(((e=i.match(Tx))===null||e===void 0?void 0:e.length)||0)+(((t=i.match(lF))===null||t===void 0?void 0:t.length)||0)>0}const DA="number",NA="color",cF="var",fF="var(",WM="${}",hF=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Kd(i){const e=i.toString(),t=[],n={color:[],number:[],var:[]},r=[];let o=0;const u=e.replace(hF,h=>(nr.test(h)?(n.color.push(o),r.push(NA),t.push(nr.parse(h))):h.startsWith(fF)?(n.var.push(o),r.push(cF),t.push(h)):(n.number.push(o),r.push(DA),t.push(parseFloat(h))),++o,WM)).split(WM);return{values:t,split:u,indexes:n,types:r}}function UA(i){return Kd(i).values}function FA(i){const{split:e,types:t}=Kd(i),n=e.length;return r=>{let o="";for(let a=0;atypeof i=="number"?0:i;function pF(i){const e=UA(i);return FA(i)(e.map(dF))}const Sl={test:uF,parse:UA,createTransformer:FA,getAnimatableNone:pF},mF=new Set(["brightness","contrast","saturate","opacity"]);function gF(i){const[e,t]=i.slice(0,-1).split("(");if(e==="drop-shadow")return i;const[n]=t.match(Tx)||[];if(!n)return i;const r=t.replace(n,"");let o=mF.has(e)?1:0;return n!==t&&(o*=100),e+"("+o+r+")"}const vF=/\b([a-z-]*)\(.*?\)/gu,f_={...Sl,getAnimatableNone:i=>{const e=i.match(vF);return e?e.map(gF).join(" "):i}},yF={borderWidth:Nt,borderTopWidth:Nt,borderRightWidth:Nt,borderBottomWidth:Nt,borderLeftWidth:Nt,borderRadius:Nt,radius:Nt,borderTopLeftRadius:Nt,borderTopRightRadius:Nt,borderBottomRightRadius:Nt,borderBottomLeftRadius:Nt,width:Nt,maxWidth:Nt,height:Nt,maxHeight:Nt,top:Nt,right:Nt,bottom:Nt,left:Nt,padding:Nt,paddingTop:Nt,paddingRight:Nt,paddingBottom:Nt,paddingLeft:Nt,margin:Nt,marginTop:Nt,marginRight:Nt,marginBottom:Nt,marginLeft:Nt,backgroundPositionX:Nt,backgroundPositionY:Nt},_F={rotate:ml,rotateX:ml,rotateY:ml,rotateZ:ml,scale:rg,scaleX:rg,scaleY:rg,scaleZ:rg,skew:ml,skewX:ml,skewY:ml,distance:Nt,translateX:Nt,translateY:Nt,translateZ:Nt,x:Nt,y:Nt,z:Nt,perspective:Nt,transformPerspective:Nt,opacity:Zd,originX:BM,originY:BM,originZ:Nt},XM={...$f,transform:Math.round},Cx={...yF,..._F,zIndex:XM,size:Nt,fillOpacity:Zd,strokeOpacity:Zd,numOctaves:XM},xF={...Cx,color:nr,backgroundColor:nr,outlineColor:nr,fill:nr,stroke:nr,borderColor:nr,borderTopColor:nr,borderRightColor:nr,borderBottomColor:nr,borderLeftColor:nr,filter:f_,WebkitFilter:f_},Rx=i=>xF[i];function OA(i,e){let t=Rx(i);return t!==f_&&(t=Sl),t.getAnimatableNone?t.getAnimatableNone(e):void 0}const SF=new Set(["auto","none","0"]);function MF(i,e,t){let n=0,r;for(;n{t.getValue(h).set(p)}),this.resolveNoneKeyframes()}}function bx(i){return typeof i=="function"}let ug;function wF(){ug=void 0}const Ro={now:()=>(ug===void 0&&Ro.set(Gi.isProcessing||kU.useManualTiming?Gi.timestamp:performance.now()),ug),set:i=>{ug=i,queueMicrotask(wF)}},jM=(i,e)=>e==="zIndex"?!1:!!(typeof i=="number"||Array.isArray(i)||typeof i=="string"&&(Sl.test(i)||i==="0")&&!i.startsWith("url("));function EF(i){const e=i[0];if(i.length===1)return!0;for(let t=0;tAF?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&iF(),this._resolved}onKeyframesResolved(e,t){this.resolvedAt=Ro.now(),this.hasAttemptedResolve=!0;const{name:n,type:r,velocity:o,delay:a,onComplete:u,onUpdate:h,isGenerator:p}=this.options;if(!p&&!TF(e,n,r,o))if(a)this.options.duration=0;else{h?.(H0(e,this.options,t)),u?.(),this.resolveFinishedPromise();return}const m=this.initPlayback(e,t);m!==!1&&(this._resolved={keyframes:e,finalKeyframe:t,...m},this.onPostResolved())}onPostResolved(){}then(e,t){return this.currentFinishedPromise.then(e,t)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(e=>{this.resolveFinishedPromise=e})}}const Xf=(i,e,t)=>{const n=e-i;return n===0?1:(t-i)/n},zA=(i,e,t=10)=>{let n="";const r=Math.max(Math.round(e/t),2);for(let o=0;o{const m=p*a,g=m*i,v=m-t,x=h_(p,a),w=Math.exp(-g);return Iy-v/x*w},o=p=>{const g=p*a*i,v=g*t+t,x=Math.pow(a,2)*Math.pow(p,2)*i,w=Math.exp(-g),A=h_(Math.pow(p,2),a);return(-r(p)+Iy>0?-1:1)*((v-x)*w)/A}):(r=p=>{const m=Math.exp(-p*i),g=(p-t)*i+1;return-Iy+m*g},o=p=>{const m=Math.exp(-p*i),g=(t-p)*(i*i);return m*g});const u=5/i,h=PF(r,o,u);if(i=xa(i),isNaN(h))return{stiffness:Jn.stiffness,damping:Jn.damping,duration:i};{const p=Math.pow(h,2)*n;return{stiffness:p,damping:a*2*Math.sqrt(n*p),duration:i}}}const bF=12;function PF(i,e,t){let n=t;for(let r=1;r=d_?1/0:e}const IF=["duration","bounce"],LF=["stiffness","damping","mass"];function YM(i,e){return e.some(t=>i[t]!==void 0)}function DF(i){let e={velocity:Jn.velocity,stiffness:Jn.stiffness,damping:Jn.damping,mass:Jn.mass,isResolvedFromDuration:!1,...i};if(!YM(i,LF)&&YM(i,IF))if(i.visualDuration){const t=i.visualDuration,n=2*Math.PI/(t*1.2),r=n*n,o=2*Aa(.05,1,1-i.bounce)*Math.sqrt(r);e={...e,mass:Jn.mass,stiffness:r,damping:o}}else{const t=RF(i);e={...e,...t,mass:Jn.mass},e.isResolvedFromDuration=!0}return e}function WA(i=Jn.visualDuration,e=Jn.bounce){const t=typeof i!="object"?{visualDuration:i,keyframes:[0,1],bounce:e}:i;let{restSpeed:n,restDelta:r}=t;const o=t.keyframes[0],a=t.keyframes[t.keyframes.length-1],u={done:!1,value:o},{stiffness:h,damping:p,mass:m,duration:g,velocity:v,isResolvedFromDuration:x}=DF({...t,velocity:-Sa(t.velocity||0)}),w=v||0,A=p/(2*Math.sqrt(h*m)),E=a-o,S=Sa(Math.sqrt(h/m)),b=Math.abs(E)<5;n||(n=b?Jn.restSpeed.granular:Jn.restSpeed.default),r||(r=b?Jn.restDelta.granular:Jn.restDelta.default);let P;if(A<1){const B=h_(S,A);P=F=>{const V=Math.exp(-A*S*F);return a-V*((w+A*S*E)/B*Math.sin(B*F)+E*Math.cos(B*F))}}else if(A===1)P=B=>a-Math.exp(-S*B)*(E+(w+S*E)*B);else{const B=S*Math.sqrt(A*A-1);P=F=>{const V=Math.exp(-A*S*F),H=Math.min(B*F,300);return a-V*((w+A*S*E)*Math.sinh(H)+B*E*Math.cosh(H))/B}}const I={calculatedDuration:x&&g||null,next:B=>{const F=P(B);if(x)u.done=B>=g;else{let V=0;A<1&&(V=B===0?xa(w):HA(P,B,F));const H=Math.abs(V)<=n,U=Math.abs(a-F)<=r;u.done=H&&U}return u.value=u.done?a:F,u},toString:()=>{const B=Math.min(GA(I),d_),F=zA(V=>I.next(B*V).value,B,30);return B+"ms "+F}};return I}function qM({keyframes:i,velocity:e=0,power:t=.8,timeConstant:n=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:a,min:u,max:h,restDelta:p=.5,restSpeed:m}){const g=i[0],v={done:!1,value:g},x=H=>u!==void 0&&Hh,w=H=>u===void 0?h:h===void 0||Math.abs(u-H)-A*Math.exp(-H/n),P=H=>S+b(H),I=H=>{const U=b(H),D=P(H);v.done=Math.abs(U)<=p,v.value=v.done?S:D};let B,F;const V=H=>{x(v.value)&&(B=H,F=WA({keyframes:[v.value,w(v.value)],velocity:HA(P,H,v.value),damping:r,stiffness:o,restDelta:p,restSpeed:m}))};return V(0),{calculatedDuration:null,next:H=>{let U=!1;return!F&&B===void 0&&(U=!0,I(H),V(H)),B!==void 0&&H>=B?F.next(H-B):(!U&&I(H),v)}}}const NF=dp(.42,0,1,1),UF=dp(0,0,.58,1),XA=dp(.42,0,.58,1),FF=i=>Array.isArray(i)&&typeof i[0]!="number",Px=i=>Array.isArray(i)&&typeof i[0]=="number",ZM={linear:rs,easeIn:NF,easeInOut:XA,easeOut:UF,circIn:Mx,circInOut:MA,circOut:SA,backIn:Sx,backInOut:_A,backOut:yA,anticipate:xA},KM=i=>{if(Px(i)){a_(i.length===4);const[e,t,n,r]=i;return dp(e,t,n,r)}else if(typeof i=="string")return a_(ZM[i]!==void 0),ZM[i];return i},OF=(i,e)=>t=>e(i(t)),mp=(...i)=>i.reduce(OF),Gn=(i,e,t)=>i+(e-i)*t;function Ly(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*(2/3-t)*6:i}function kF({hue:i,saturation:e,lightness:t,alpha:n}){i/=360,e/=100,t/=100;let r=0,o=0,a=0;if(!e)r=o=a=t;else{const u=t<.5?t*(1+e):t+e-t*e,h=2*t-u;r=Ly(h,u,i+1/3),o=Ly(h,u,i),a=Ly(h,u,i-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(a*255),alpha:n}}function e0(i,e){return t=>t>0?e:i}const Dy=(i,e,t)=>{const n=i*i,r=t*(e*e-n)+n;return r<0?0:Math.sqrt(r)},BF=[c_,Nu,Lf],zF=i=>BF.find(e=>e.test(i));function JM(i){const e=zF(i);if(!e)return!1;let t=e.parse(i);return e===Lf&&(t=kF(t)),t}const QM=(i,e)=>{const t=JM(i),n=JM(e);if(!t||!n)return e0(i,e);const r={...t};return o=>(r.red=Dy(t.red,n.red,o),r.green=Dy(t.green,n.green,o),r.blue=Dy(t.blue,n.blue,o),r.alpha=Gn(t.alpha,n.alpha,o),Nu.transform(r))},p_=new Set(["none","hidden"]);function VF(i,e){return p_.has(i)?t=>t<=0?i:e:t=>t>=1?e:i}function HF(i,e){return t=>Gn(i,e,t)}function Ix(i){return typeof i=="number"?HF:typeof i=="string"?wx(i)?e0:nr.test(i)?QM:XF:Array.isArray(i)?jA:typeof i=="object"?nr.test(i)?QM:GF:e0}function jA(i,e){const t=[...i],n=t.length,r=i.map((o,a)=>Ix(o)(o,e[a]));return o=>{for(let a=0;a{for(const o in n)t[o]=n[o](r);return t}}function WF(i,e){var t;const n=[],r={color:0,var:0,number:0};for(let o=0;o{const t=Sl.createTransformer(e),n=Kd(i),r=Kd(e);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?p_.has(i)&&!r.values.length||p_.has(e)&&!n.values.length?VF(i,e):mp(jA(WF(n,r),r.values),t):e0(i,e)};function YA(i,e,t){return typeof i=="number"&&typeof e=="number"&&typeof t=="number"?Gn(i,e,t):Ix(i)(i,e)}function jF(i,e,t){const n=[],r=t||YA,o=i.length-1;for(let a=0;ae[0];if(o===2&&i[0]===i[1])return()=>e[1];i[0]>i[o-1]&&(i=[...i].reverse(),e=[...e].reverse());const a=jF(e,n,r),u=a.length,h=p=>{let m=0;if(u>1)for(;mh(Aa(i[0],i[o-1],p)):h}function qF(i,e){const t=i[i.length-1];for(let n=1;n<=e;n++){const r=Xf(0,e,n);i.push(Gn(t,1,r))}}function ZF(i){const e=[0];return qF(e,i.length-1),e}function KF(i,e){return i.map(t=>t*e)}function JF(i,e){return i.map(()=>e||XA).splice(0,i.length-1)}function t0({duration:i=300,keyframes:e,times:t,ease:n="easeInOut"}){const r=FF(n)?n.map(KM):KM(n),o={done:!1,value:e[0]},a=KF(t&&t.length===e.length?t:ZF(e),i),u=YF(a,e,{ease:Array.isArray(r)?r:JF(e,r)});return{calculatedDuration:i,next:h=>(o.value=u(h),o.done=h>=i,o)}}const QF=i=>{const e=({timestamp:t})=>i(t);return{start:()=>Un.update(e,!0),stop:()=>xl(e),now:()=>Gi.isProcessing?Gi.timestamp:Ro.now()}},$F={decay:qM,inertia:qM,tween:t0,keyframes:t0,spring:WA},eO=i=>i/100;class Lx extends BA{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:h}=this.options;h&&h()};const{name:t,motionValue:n,element:r,keyframes:o}=this.options,a=r?.KeyframeResolver||Ex,u=(h,p)=>this.onKeyframesResolved(h,p);this.resolver=new a(o,u,t,n,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){const{type:t="keyframes",repeat:n=0,repeatDelay:r=0,repeatType:o,velocity:a=0}=this.options,u=bx(t)?t:$F[t]||t0;let h,p;u!==t0&&typeof e[0]!="number"&&(h=mp(eO,YA(e[0],e[1])),e=[0,100]);const m=u({...this.options,keyframes:e});o==="mirror"&&(p=u({...this.options,keyframes:[...e].reverse(),velocity:-a})),m.calculatedDuration===null&&(m.calculatedDuration=GA(m));const{calculatedDuration:g}=m,v=g+r,x=v*(n+1)-r;return{generator:m,mirroredGenerator:p,mapPercentToKeyframes:h,calculatedDuration:g,resolvedDuration:v,totalDuration:x}}onPostResolved(){const{autoplay:e=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!e?this.pause():this.state=this.pendingPlayState}tick(e,t=!1){const{resolved:n}=this;if(!n){const{keyframes:H}=this.options;return{done:!0,value:H[H.length-1]}}const{finalKeyframe:r,generator:o,mirroredGenerator:a,mapPercentToKeyframes:u,keyframes:h,calculatedDuration:p,totalDuration:m,resolvedDuration:g}=n;if(this.startTime===null)return o.next(0);const{delay:v,repeat:x,repeatType:w,repeatDelay:A,onUpdate:E}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-m/this.speed,this.startTime)),t?this.currentTime=e:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(e-this.startTime)*this.speed;const S=this.currentTime-v*(this.speed>=0?1:-1),b=this.speed>=0?S<0:S>m;this.currentTime=Math.max(S,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=m);let P=this.currentTime,I=o;if(x){const H=Math.min(this.currentTime,m)/g;let U=Math.floor(H),D=H%1;!D&&H>=1&&(D=1),D===1&&U--,U=Math.min(U,x+1),!!(U%2)&&(w==="reverse"?(D=1-D,A&&(D-=A/g)):w==="mirror"&&(I=a)),P=Aa(0,1,D)*g}const B=b?{done:!1,value:h[0]}:I.next(P);u&&(B.value=u(B.value));let{done:F}=B;!b&&p!==null&&(F=this.speed>=0?this.currentTime>=m:this.currentTime<=0);const V=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&F);return V&&r!==void 0&&(B.value=H0(h,this.options,r)),E&&E(B.value),V&&this.finish(),B}get duration(){const{resolved:e}=this;return e?Sa(e.calculatedDuration):0}get time(){return Sa(this.currentTime)}set time(e){e=xa(e),this.currentTime=e,this.holdTime!==null||this.speed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){const t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=Sa(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:e=QF,onPlay:t,startTime:n}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),t&&t();const r=this.driver.now();this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=r):this.startTime=n??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var e;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(e=this.currentTime)!==null&&e!==void 0?e:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:e}=this.options;e&&e()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}}const tO=new Set(["opacity","clipPath","filter","transform"]);function Dx(i){let e;return()=>(e===void 0&&(e=i()),e)}const nO={linearEasing:void 0};function iO(i,e){const t=Dx(i);return()=>{var n;return(n=nO[e])!==null&&n!==void 0?n:t()}}const n0=iO(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing");function qA(i){return!!(typeof i=="function"&&n0()||!i||typeof i=="string"&&(i in m_||n0())||Px(i)||Array.isArray(i)&&i.every(qA))}const dd=([i,e,t,n])=>`cubic-bezier(${i}, ${e}, ${t}, ${n})`,m_={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:dd([0,.65,.55,1]),circOut:dd([.55,0,1,.45]),backIn:dd([.31,.01,.66,-.59]),backOut:dd([.33,1.53,.69,.99])};function ZA(i,e){if(i)return typeof i=="function"&&n0()?zA(i,e):Px(i)?dd(i):Array.isArray(i)?i.map(t=>ZA(t,e)||m_.easeOut):m_[i]}function rO(i,e,t,{delay:n=0,duration:r=300,repeat:o=0,repeatType:a="loop",ease:u="easeInOut",times:h}={}){const p={[e]:t};h&&(p.offset=h);const m=ZA(u,r);return Array.isArray(m)&&(p.easing=m),i.animate(p,{delay:n,duration:r,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:o+1,direction:a==="reverse"?"alternate":"normal"})}function $M(i,e){i.timeline=e,i.onfinish=null}const sO=Dx(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),i0=10,oO=2e4;function aO(i){return bx(i.type)||i.type==="spring"||!qA(i.ease)}function lO(i,e){const t=new Lx({...e,keyframes:i,repeat:0,delay:0,isGenerator:!0});let n={done:!1,value:i[0]};const r=[];let o=0;for(;!n.done&&othis.onKeyframesResolved(a,u),t,n,r),this.resolver.scheduleResolve()}initPlayback(e,t){var n;let{duration:r=300,times:o,ease:a,type:u,motionValue:h,name:p,startTime:m}=this.options;if(!(!((n=h.owner)===null||n===void 0)&&n.current))return!1;if(typeof a=="string"&&n0()&&uO(a)&&(a=KA[a]),aO(this.options)){const{onComplete:v,onUpdate:x,motionValue:w,element:A,...E}=this.options,S=lO(e,E);e=S.keyframes,e.length===1&&(e[1]=e[0]),r=S.duration,o=S.times,a=S.ease,u="keyframes"}const g=rO(h.owner.current,p,e,{...this.options,duration:r,times:o,ease:a});return g.startTime=m??this.calcStartTime(),this.pendingTimeline?($M(g,this.pendingTimeline),this.pendingTimeline=void 0):g.onfinish=()=>{const{onComplete:v}=this.options;h.set(H0(e,this.options,t)),v&&v(),this.cancel(),this.resolveFinishedPromise()},{animation:g,duration:r,times:o,type:u,ease:a,keyframes:e}}get duration(){const{resolved:e}=this;if(!e)return 0;const{duration:t}=e;return Sa(t)}get time(){const{resolved:e}=this;if(!e)return 0;const{animation:t}=e;return Sa(t.currentTime||0)}set time(e){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.currentTime=xa(e)}get speed(){const{resolved:e}=this;if(!e)return 1;const{animation:t}=e;return t.playbackRate}set speed(e){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playbackRate=e}get state(){const{resolved:e}=this;if(!e)return"idle";const{animation:t}=e;return t.playState}get startTime(){const{resolved:e}=this;if(!e)return null;const{animation:t}=e;return t.startTime}attachTimeline(e){if(!this._resolved)this.pendingTimeline=e;else{const{resolved:t}=this;if(!t)return rs;const{animation:n}=t;$M(n,e)}return rs}play(){if(this.isStopped)return;const{resolved:e}=this;if(!e)return;const{animation:t}=e;t.playState==="finished"&&this.updateFinishedPromise(),t.play()}pause(){const{resolved:e}=this;if(!e)return;const{animation:t}=e;t.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:e}=this;if(!e)return;const{animation:t,keyframes:n,duration:r,type:o,ease:a,times:u}=e;if(t.playState==="idle"||t.playState==="finished")return;if(this.time){const{motionValue:p,onUpdate:m,onComplete:g,element:v,...x}=this.options,w=new Lx({...x,keyframes:n,duration:r,type:o,ease:a,times:u,isGenerator:!0}),A=xa(this.time);p.setWithVelocity(w.sample(A-i0).value,w.sample(A).value,i0)}const{onStop:h}=this.options;h&&h(),this.cancel()}complete(){const{resolved:e}=this;e&&e.animation.finish()}cancel(){const{resolved:e}=this;e&&e.animation.cancel()}static supports(e){const{motionValue:t,name:n,repeatDelay:r,repeatType:o,damping:a,type:u}=e;return sO()&&n&&tO.has(n)&&t&&t.owner&&t.owner.current instanceof HTMLElement&&!t.owner.getProps().onUpdate&&!r&&o!=="mirror"&&a!==0&&u!=="inertia"}}const cO=Dx(()=>window.ScrollTimeline!==void 0);class fO{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}then(e,t){return Promise.all(this.animations).then(e).catch(t)}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;ncO()&&r.attachTimeline?r.attachTimeline(e):t(r));return()=>{n.forEach((r,o)=>{r&&r(),this.animations[o].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let t=0;tt[e]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function hO({when:i,delay:e,delayChildren:t,staggerChildren:n,staggerDirection:r,repeat:o,repeatType:a,repeatDelay:u,from:h,elapsed:p,...m}){return!!Object.keys(m).length}const Nx=(i,e,t,n={},r,o)=>a=>{const u=xx(n,i)||{},h=u.delay||n.delay||0;let{elapsed:p=0}=n;p=p-xa(h);let m={keyframes:Array.isArray(t)?t:[null,t],ease:"easeOut",velocity:e.getVelocity(),...u,delay:-p,onUpdate:v=>{e.set(v),u.onUpdate&&u.onUpdate(v)},onComplete:()=>{a(),u.onComplete&&u.onComplete()},name:i,motionValue:e,element:o?void 0:r};hO(u)||(m={...m,...OU(i,m)}),m.duration&&(m.duration=xa(m.duration)),m.repeatDelay&&(m.repeatDelay=xa(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let g=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(m.duration=0,m.delay===0&&(g=!0)),g&&!o&&e.get()!==void 0){const v=H0(m.keyframes,u);if(v!==void 0)return Un.update(()=>{m.onUpdate(v),m.onComplete()}),new fO([])}return!o&&ew.supports(m)?new ew(m):new Lx(m)},dO=i=>!!(i&&typeof i=="object"&&i.mix&&i.toValue),pO=i=>o_(i)?i[i.length-1]||0:i;function Ux(i,e){i.indexOf(e)===-1&&i.push(e)}function Fx(i,e){const t=i.indexOf(e);t>-1&&i.splice(t,1)}class Ox{constructor(){this.subscriptions=[]}add(e){return Ux(this.subscriptions,e),()=>Fx(this.subscriptions,e)}notify(e,t,n){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let o=0;o!isNaN(parseFloat(i));class gO{constructor(e,t={}){this.version="11.15.0",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(n,r=!0)=>{const o=Ro.now();this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),r&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Ro.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=mO(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new Ox);const n=this.events[e].add(t);return e==="change"?()=>{n(),Un.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e,t=!0){!t||!this.passiveEffect?this.updateAndNotify(e,t):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Ro.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>tw)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,tw);return VA(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Jd(i,e){return new gO(i,e)}function vO(i,e,t){i.hasValue(e)?i.getValue(e).set(t):i.addValue(e,Jd(t))}function yO(i,e){const t=V0(i,e);let{transitionEnd:n={},transition:r={},...o}=t||{};o={...o,...n};for(const a in o){const u=pO(o[a]);vO(i,a,u)}}const kx=i=>i.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),_O="framerAppearId",JA="data-"+kx(_O);function QA(i){return i.props[JA]}const rr=i=>!!(i&&i.getVelocity);function xO(i){return!!(rr(i)&&i.add)}function g_(i,e){const t=i.getValue("willChange");if(xO(t))return t.add(e)}function SO({protectedKeys:i,needsAnimating:e},t){const n=i.hasOwnProperty(t)&&e[t]!==!0;return e[t]=!1,n}function $A(i,e,{delay:t=0,transitionOverride:n,type:r}={}){var o;let{transition:a=i.getDefaultTransition(),transitionEnd:u,...h}=e;n&&(a=n);const p=[],m=r&&i.animationState&&i.animationState.getState()[r];for(const g in h){const v=i.getValue(g,(o=i.latestValues[g])!==null&&o!==void 0?o:null),x=h[g];if(x===void 0||m&&SO(m,g))continue;const w={delay:t,...xx(a||{},g)};let A=!1;if(window.MotionHandoffAnimation){const S=QA(i);if(S){const b=window.MotionHandoffAnimation(S,g,Un);b!==null&&(w.startTime=b,A=!0)}}g_(i,g),v.start(Nx(g,v,x,i.shouldReduceMotion&&Ju.has(g)?{type:!1}:w,i,A));const E=v.animation;E&&p.push(E)}return u&&Promise.all(p).then(()=>{Un.update(()=>{u&&yO(i,u)})}),p}function v_(i,e,t={}){var n;const r=V0(i,e,t.type==="exit"?(n=i.presenceContext)===null||n===void 0?void 0:n.custom:void 0);let{transition:o=i.getDefaultTransition()||{}}=r||{};t.transitionOverride&&(o=t.transitionOverride);const a=r?()=>Promise.all($A(i,r,t)):()=>Promise.resolve(),u=i.variantChildren&&i.variantChildren.size?(p=0)=>{const{delayChildren:m=0,staggerChildren:g,staggerDirection:v}=o;return MO(i,e,m+p,g,v,t)}:()=>Promise.resolve(),{when:h}=o;if(h){const[p,m]=h==="beforeChildren"?[a,u]:[u,a];return p().then(()=>m())}else return Promise.all([a(),u(t.delay)])}function MO(i,e,t=0,n=0,r=1,o){const a=[],u=(i.variantChildren.size-1)*n,h=r===1?(p=0)=>p*n:(p=0)=>u-p*n;return Array.from(i.variantChildren).sort(wO).forEach((p,m)=>{p.notify("AnimationStart",e),a.push(v_(p,e,{...o,delay:t+h(m)}).then(()=>p.notify("AnimationComplete",e)))}),Promise.all(a)}function wO(i,e){return i.sortNodePosition(e)}function EO(i,e,t={}){i.notify("AnimationStart",e);let n;if(Array.isArray(e)){const r=e.map(o=>v_(i,o,t));n=Promise.all(r)}else if(typeof e=="string")n=v_(i,e,t);else{const r=typeof e=="function"?V0(i,e,t.custom):e;n=Promise.all($A(i,r,t))}return n.then(()=>{i.notify("AnimationComplete",e)})}const TO=_x.length;function eC(i){if(!i)return;if(!i.isControllingVariants){const t=i.parent?eC(i.parent)||{}:{};return i.props.initial!==void 0&&(t.initial=i.props.initial),t}const e={};for(let t=0;tPromise.all(e.map(({animation:t,options:n})=>EO(i,t,n)))}function bO(i){let e=RO(i),t=nw(),n=!0;const r=h=>(p,m)=>{var g;const v=V0(i,m,h==="exit"?(g=i.presenceContext)===null||g===void 0?void 0:g.custom:void 0);if(v){const{transition:x,transitionEnd:w,...A}=v;p={...p,...A,...w}}return p};function o(h){e=h(i)}function a(h){const{props:p}=i,m=eC(i.parent)||{},g=[],v=new Set;let x={},w=1/0;for(let E=0;Ew&&I,U=!1;const D=Array.isArray(P)?P:[P];let W=D.reduce(r(S),{});B===!1&&(W={});const{prevResolvedValues:se={}}=b,ie={...se,...W},fe=ye=>{H=!0,v.has(ye)&&(U=!0,v.delete(ye)),b.needsAnimating[ye]=!0;const O=i.getValue(ye);O&&(O.liveStyle=!1)};for(const ye in ie){const O=W[ye],J=se[ye];if(x.hasOwnProperty(ye))continue;let K=!1;o_(O)&&o_(J)?K=!dA(O,J):K=O!==J,K?O!=null?fe(ye):v.add(ye):O!==void 0&&v.has(ye)?fe(ye):b.protectedKeys[ye]=!0}b.prevProp=P,b.prevResolvedValues=W,b.isActive&&(x={...x,...W}),n&&i.blockInitialAnimation&&(H=!1),H&&(!(F&&V)||U)&&g.push(...D.map(ye=>({animation:ye,options:{type:S}})))}if(v.size){const E={};v.forEach(S=>{const b=i.getBaseTarget(S),P=i.getValue(S);P&&(P.liveStyle=!0),E[S]=b??null}),g.push({animation:E})}let A=!!g.length;return n&&(p.initial===!1||p.initial===p.animate)&&!i.manuallyAnimateOnMount&&(A=!1),n=!1,A?e(g):Promise.resolve()}function u(h,p){var m;if(t[h].isActive===p)return Promise.resolve();(m=i.variantChildren)===null||m===void 0||m.forEach(v=>{var x;return(x=v.animationState)===null||x===void 0?void 0:x.setActive(h,p)}),t[h].isActive=p;const g=a(h);for(const v in t)t[v].protectedKeys={};return g}return{animateChanges:a,setActive:u,setAnimateFunction:o,getState:()=>t,reset:()=>{t=nw(),n=!0}}}function PO(i,e){return typeof e=="string"?e!==i:Array.isArray(e)?!dA(e,i):!1}function Eu(i=!1){return{isActive:i,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function nw(){return{animate:Eu(!0),whileInView:Eu(),whileHover:Eu(),whileTap:Eu(),whileDrag:Eu(),whileFocus:Eu(),exit:Eu()}}class Tl{constructor(e){this.isMounted=!1,this.node=e}update(){}}class IO extends Tl{constructor(e){super(e),e.animationState||(e.animationState=bO(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();z0(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)===null||e===void 0||e.call(this)}}let LO=0;class DO extends Tl{constructor(){super(...arguments),this.id=LO++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;const r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>t(this.id))}mount(){const{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}const NO={animation:{Feature:IO},exit:{Feature:DO}},Js={x:!1,y:!1};function tC(){return Js.x||Js.y}function UO(i){return i==="x"||i==="y"?Js[i]?null:(Js[i]=!0,()=>{Js[i]=!1}):Js.x||Js.y?null:(Js.x=Js.y=!0,()=>{Js.x=Js.y=!1})}const Bx=i=>i.pointerType==="mouse"?typeof i.button!="number"||i.button<=0:i.isPrimary!==!1;function gp(i){return{point:{x:i.pageX,y:i.pageY}}}const FO=i=>e=>Bx(e)&&i(e,gp(e));function Qd(i,e,t,n={passive:!0}){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t)}function Cd(i,e,t,n){return Qd(i,e,FO(t),n)}const iw=(i,e)=>Math.abs(i-e);function OO(i,e){const t=iw(i.x,e.x),n=iw(i.y,e.y);return Math.sqrt(t**2+n**2)}class nC{constructor(e,t,{transformPagePoint:n,contextWindow:r,dragSnapToOrigin:o=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const g=Uy(this.lastMoveEventInfo,this.history),v=this.startEvent!==null,x=OO(g.offset,{x:0,y:0})>=3;if(!v&&!x)return;const{point:w}=g,{timestamp:A}=Gi;this.history.push({...w,timestamp:A});const{onStart:E,onMove:S}=this.handlers;v||(E&&E(this.lastMoveEvent,g),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,g)},this.handlePointerMove=(g,v)=>{this.lastMoveEvent=g,this.lastMoveEventInfo=Ny(v,this.transformPagePoint),Un.update(this.updatePoint,!0)},this.handlePointerUp=(g,v)=>{this.end();const{onEnd:x,onSessionEnd:w,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=Uy(g.type==="pointercancel"?this.lastMoveEventInfo:Ny(v,this.transformPagePoint),this.history);this.startEvent&&x&&x(g,E),w&&w(g,E)},!Bx(e))return;this.dragSnapToOrigin=o,this.handlers=t,this.transformPagePoint=n,this.contextWindow=r||window;const a=gp(e),u=Ny(a,this.transformPagePoint),{point:h}=u,{timestamp:p}=Gi;this.history=[{...h,timestamp:p}];const{onSessionStart:m}=t;m&&m(e,Uy(u,this.history)),this.removeListeners=mp(Cd(this.contextWindow,"pointermove",this.handlePointerMove),Cd(this.contextWindow,"pointerup",this.handlePointerUp),Cd(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),xl(this.updatePoint)}}function Ny(i,e){return e?{point:e(i.point)}:i}function rw(i,e){return{x:i.x-e.x,y:i.y-e.y}}function Uy({point:i},e){return{point:i,delta:rw(i,iC(e)),offset:rw(i,kO(e)),velocity:BO(e,.1)}}function kO(i){return i[0]}function iC(i){return i[i.length-1]}function BO(i,e){if(i.length<2)return{x:0,y:0};let t=i.length-1,n=null;const r=iC(i);for(;t>=0&&(n=i[t],!(r.timestamp-n.timestamp>xa(e)));)t--;if(!n)return{x:0,y:0};const o=Sa(r.timestamp-n.timestamp);if(o===0)return{x:0,y:0};const a={x:(r.x-n.x)/o,y:(r.y-n.y)/o};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function Df(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}const rC=1e-4,zO=1-rC,VO=1+rC,sC=.01,HO=0-sC,GO=0+sC;function os(i){return i.max-i.min}function WO(i,e,t){return Math.abs(i-e)<=t}function sw(i,e,t,n=.5){i.origin=n,i.originPoint=Gn(e.min,e.max,i.origin),i.scale=os(t)/os(e),i.translate=Gn(t.min,t.max,i.origin)-i.originPoint,(i.scale>=zO&&i.scale<=VO||isNaN(i.scale))&&(i.scale=1),(i.translate>=HO&&i.translate<=GO||isNaN(i.translate))&&(i.translate=0)}function Rd(i,e,t,n){sw(i.x,e.x,t.x,n?n.originX:void 0),sw(i.y,e.y,t.y,n?n.originY:void 0)}function ow(i,e,t){i.min=t.min+e.min,i.max=i.min+os(e)}function XO(i,e,t){ow(i.x,e.x,t.x),ow(i.y,e.y,t.y)}function aw(i,e,t){i.min=e.min-t.min,i.max=i.min+os(e)}function bd(i,e,t){aw(i.x,e.x,t.x),aw(i.y,e.y,t.y)}function jO(i,{min:e,max:t},n){return e!==void 0&&it&&(i=n?Gn(t,i,n.max):Math.min(i,t)),i}function lw(i,e,t){return{min:e!==void 0?i.min+e:void 0,max:t!==void 0?i.max+t-(i.max-i.min):void 0}}function YO(i,{top:e,left:t,bottom:n,right:r}){return{x:lw(i.x,t,r),y:lw(i.y,e,n)}}function uw(i,e){let t=e.min-i.min,n=e.max-i.max;return e.max-e.minn?t=Xf(e.min,e.max-n,i.min):n>r&&(t=Xf(i.min,i.max-r,e.min)),Aa(0,1,t)}function KO(i,e){const t={};return e.min!==void 0&&(t.min=e.min-i.min),e.max!==void 0&&(t.max=e.max-i.min),t}const y_=.35;function JO(i=y_){return i===!1?i=0:i===!0&&(i=y_),{x:cw(i,"left","right"),y:cw(i,"top","bottom")}}function cw(i,e,t){return{min:fw(i,e),max:fw(i,t)}}function fw(i,e){return typeof i=="number"?i:i[e]||0}const hw=()=>({translate:0,scale:1,origin:0,originPoint:0}),Nf=()=>({x:hw(),y:hw()}),dw=()=>({min:0,max:0}),ii=()=>({x:dw(),y:dw()});function ws(i){return[i("x"),i("y")]}function oC({top:i,left:e,right:t,bottom:n}){return{x:{min:e,max:t},y:{min:i,max:n}}}function QO({x:i,y:e}){return{top:e.min,right:i.max,bottom:e.max,left:i.min}}function $O(i,e){if(!e)return i;const t=e({x:i.left,y:i.top}),n=e({x:i.right,y:i.bottom});return{top:t.y,left:t.x,bottom:n.y,right:n.x}}function Fy(i){return i===void 0||i===1}function __({scale:i,scaleX:e,scaleY:t}){return!Fy(i)||!Fy(e)||!Fy(t)}function Cu(i){return __(i)||aC(i)||i.z||i.rotate||i.rotateX||i.rotateY||i.skewX||i.skewY}function aC(i){return pw(i.x)||pw(i.y)}function pw(i){return i&&i!=="0%"}function r0(i,e,t){const n=i-t,r=e*n;return t+r}function mw(i,e,t,n,r){return r!==void 0&&(i=r0(i,r,n)),r0(i,t,n)+e}function x_(i,e=0,t=1,n,r){i.min=mw(i.min,e,t,n,r),i.max=mw(i.max,e,t,n,r)}function lC(i,{x:e,y:t}){x_(i.x,e.translate,e.scale,e.originPoint),x_(i.y,t.translate,t.scale,t.originPoint)}const gw=.999999999999,vw=1.0000000000001;function ek(i,e,t,n=!1){const r=t.length;if(!r)return;e.x=e.y=1;let o,a;for(let u=0;ugw&&(e.x=1),e.ygw&&(e.y=1)}function Uf(i,e){i.min=i.min+e,i.max=i.max+e}function yw(i,e,t,n,r=.5){const o=Gn(i.min,i.max,r);x_(i,e,t,o,n)}function Ff(i,e){yw(i.x,e.x,e.scaleX,e.scale,e.originX),yw(i.y,e.y,e.scaleY,e.scale,e.originY)}function uC(i,e){return oC($O(i.getBoundingClientRect(),e))}function tk(i,e,t){const n=uC(i,t),{scroll:r}=e;return r&&(Uf(n.x,r.offset.x),Uf(n.y,r.offset.y)),n}const cC=({current:i})=>i?i.ownerDocument.defaultView:null,nk=new WeakMap;class ik{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ii(),this.visualElement=e}start(e,{snapToCursor:t=!1}={}){const{presenceContext:n}=this.visualElement;if(n&&n.isPresent===!1)return;const r=m=>{const{dragSnapToOrigin:g}=this.getProps();g?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor(gp(m).point)},o=(m,g)=>{const{drag:v,dragPropagation:x,onDragStart:w}=this.getProps();if(v&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=UO(v),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ws(E=>{let S=this.getAxisMotionValue(E).get()||0;if(Co.test(S)){const{projection:b}=this.visualElement;if(b&&b.layout){const P=b.layout.layoutBox[E];P&&(S=os(P)*(parseFloat(S)/100))}}this.originPoint[E]=S}),w&&Un.postRender(()=>w(m,g)),g_(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(m,g)=>{const{dragPropagation:v,dragDirectionLock:x,onDirectionLock:w,onDrag:A}=this.getProps();if(!v&&!this.openDragLock)return;const{offset:E}=g;if(x&&this.currentDirection===null){this.currentDirection=rk(E),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",g.point,E),this.updateAxis("y",g.point,E),this.visualElement.render(),A&&A(m,g)},u=(m,g)=>this.stop(m,g),h=()=>ws(m=>{var g;return this.getAnimationState(m)==="paused"&&((g=this.getAxisMotionValue(m).animation)===null||g===void 0?void 0:g.play())}),{dragSnapToOrigin:p}=this.getProps();this.panSession=new nC(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:u,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,contextWindow:cC(this.visualElement)})}stop(e,t){const n=this.isDragging;if(this.cancel(),!n)return;const{velocity:r}=t;this.startAnimation(r);const{onDragEnd:o}=this.getProps();o&&Un.postRender(()=>o(e,t))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,n){const{drag:r}=this.getProps();if(!n||!sg(e,r,this.currentDirection))return;const o=this.getAxisMotionValue(e);let a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=jO(a,this.constraints[e],this.elastic[e])),o.set(a)}resolveConstraints(){var e;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(e=this.visualElement.projection)===null||e===void 0?void 0:e.layout,o=this.constraints;t&&Df(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=YO(r.layoutBox,t):this.constraints=!1,this.elastic=JO(n),o!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&ws(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=KO(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Df(e))return!1;const n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=tk(n,r.root,this.visualElement.getTransformPagePoint());let a=qO(r.layout.layoutBox,o);if(t){const u=t(QO(a));this.hasMutatedConstraints=!!u,u&&(a=oC(u))}return a}startAnimation(e){const{drag:t,dragMomentum:n,dragElastic:r,dragTransition:o,dragSnapToOrigin:a,onDragTransitionEnd:u}=this.getProps(),h=this.constraints||{},p=ws(m=>{if(!sg(m,t,this.currentDirection))return;let g=h&&h[m]||{};a&&(g={min:0,max:0});const v=r?200:1e6,x=r?40:1e7,w={type:"inertia",velocity:n?e[m]:0,bounceStiffness:v,bounceDamping:x,timeConstant:750,restDelta:1,restSpeed:10,...o,...g};return this.startAxisValueAnimation(m,w)});return Promise.all(p).then(u)}startAxisValueAnimation(e,t){const n=this.getAxisMotionValue(e);return g_(this.visualElement,e),n.start(Nx(e,n,0,t,this.visualElement,!1))}stopAnimation(){ws(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){ws(e=>{var t;return(t=this.getAxisMotionValue(e).animation)===null||t===void 0?void 0:t.pause()})}getAnimationState(e){var t;return(t=this.getAxisMotionValue(e).animation)===null||t===void 0?void 0:t.state}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),r=n[t];return r||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){ws(t=>{const{drag:n}=this.getProps();if(!sg(t,n,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(t);if(r&&r.layout){const{min:a,max:u}=r.layout.layoutBox[t];o.set(e[t]-Gn(a,u,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Df(t)||!n||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};ws(a=>{const u=this.getAxisMotionValue(a);if(u&&this.constraints!==!1){const h=u.get();r[a]=ZO({min:h,max:h},this.constraints[a])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),ws(a=>{if(!sg(a,e,null))return;const u=this.getAxisMotionValue(a),{min:h,max:p}=this.constraints[a];u.set(Gn(h,p,r[a]))})}addListeners(){if(!this.visualElement.current)return;nk.set(this.visualElement,this);const e=this.visualElement.current,t=Cd(e,"pointerdown",h=>{const{drag:p,dragListener:m=!0}=this.getProps();p&&m&&this.start(h)}),n=()=>{const{dragConstraints:h}=this.getProps();Df(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",n);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Un.read(n);const a=Qd(window,"resize",()=>this.scalePositionWithinConstraints()),u=r.addEventListener("didUpdate",({delta:h,hasLayoutChanged:p})=>{this.isDragging&&p&&(ws(m=>{const g=this.getAxisMotionValue(m);g&&(this.originPoint[m]+=h[m].translate,g.set(g.get()+h[m].translate))}),this.visualElement.render())});return()=>{a(),t(),o(),u&&u()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:a=y_,dragMomentum:u=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:o,dragElastic:a,dragMomentum:u}}}function sg(i,e,t){return(e===!0||e===i)&&(t===null||t===i)}function rk(i,e=10){let t=null;return Math.abs(i.y)>e?t="y":Math.abs(i.x)>e&&(t="x"),t}class sk extends Tl{constructor(e){super(e),this.removeGroupControls=rs,this.removeListeners=rs,this.controls=new ik(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||rs}unmount(){this.removeGroupControls(),this.removeListeners()}}const _w=i=>(e,t)=>{i&&Un.postRender(()=>i(e,t))};class ok extends Tl{constructor(){super(...arguments),this.removePointerDownListener=rs}onPointerDown(e){this.session=new nC(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:cC(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:_w(e),onStart:_w(t),onMove:n,onEnd:(o,a)=>{delete this.session,r&&Un.postRender(()=>r(o,a))}}}mount(){this.removePointerDownListener=Cd(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const zx=Ie.createContext(null);function ak(){const i=Ie.useContext(zx);if(i===null)return[!0,null];const{isPresent:e,onExitComplete:t,register:n}=i,r=Ie.useId();Ie.useEffect(()=>n(r),[]);const o=Ie.useCallback(()=>t&&t(r),[r,t]);return!e&&t?[!1,o]:[!0]}const fC=Ie.createContext({}),hC=Ie.createContext({}),cg={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function xw(i,e){return e.max===e.min?0:i/(e.max-e.min)*100}const cd={correct:(i,e)=>{if(!e.target)return i;if(typeof i=="string")if(Nt.test(i))i=parseFloat(i);else return i;const t=xw(i,e.target.x),n=xw(i,e.target.y);return`${t}% ${n}%`}},lk={correct:(i,{treeScale:e,projectionDelta:t})=>{const n=i,r=Sl.parse(i);if(r.length>5)return n;const o=Sl.createTransformer(i),a=typeof r[0]!="number"?1:0,u=t.x.scale*e.x,h=t.y.scale*e.y;r[0+a]/=u,r[1+a]/=h;const p=Gn(u,h,.5);return typeof r[2+a]=="number"&&(r[2+a]/=p),typeof r[3+a]=="number"&&(r[3+a]/=p),o(r)}},s0={};function uk(i){Object.assign(s0,i)}const{schedule:Vx,cancel:mz}=pA(queueMicrotask,!1);class ck extends Ie.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:o}=e;uk(fk),o&&(t.group&&t.group.add(o),n&&n.register&&r&&n.register(o),o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),cg.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:n,drag:r,isPresent:o}=this.props,a=n.projection;return a&&(a.isPresent=o,r||e.layoutDependency!==t||t===void 0?a.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?a.promote():a.relegate()||Un.postRender(()=>{const u=a.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Vx.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function dC(i){const[e,t]=ak(),n=Ie.useContext(fC);return tn.jsx(ck,{...i,layoutGroup:n,switchLayoutGroup:Ie.useContext(hC),isPresent:e,safeToRemove:t})}const fk={borderRadius:{...cd,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:cd,borderTopRightRadius:cd,borderBottomLeftRadius:cd,borderBottomRightRadius:cd,boxShadow:lk},pC=["TopLeft","TopRight","BottomLeft","BottomRight"],hk=pC.length,Sw=i=>typeof i=="string"?parseFloat(i):i,Mw=i=>typeof i=="number"||Nt.test(i);function dk(i,e,t,n,r,o){r?(i.opacity=Gn(0,t.opacity!==void 0?t.opacity:1,pk(n)),i.opacityExit=Gn(e.opacity!==void 0?e.opacity:1,0,mk(n))):o&&(i.opacity=Gn(e.opacity!==void 0?e.opacity:1,t.opacity!==void 0?t.opacity:1,n));for(let a=0;ane?1:t(Xf(i,e,n))}function Ew(i,e){i.min=e.min,i.max=e.max}function Ms(i,e){Ew(i.x,e.x),Ew(i.y,e.y)}function Tw(i,e){i.translate=e.translate,i.scale=e.scale,i.originPoint=e.originPoint,i.origin=e.origin}function Aw(i,e,t,n,r){return i-=e,i=r0(i,1/t,n),r!==void 0&&(i=r0(i,1/r,n)),i}function gk(i,e=0,t=1,n=.5,r,o=i,a=i){if(Co.test(e)&&(e=parseFloat(e),e=Gn(a.min,a.max,e/100)-a.min),typeof e!="number")return;let u=Gn(o.min,o.max,n);i===o&&(u-=e),i.min=Aw(i.min,e,t,u,r),i.max=Aw(i.max,e,t,u,r)}function Cw(i,e,[t,n,r],o,a){gk(i,e[t],e[n],e[r],e.scale,o,a)}const vk=["x","scaleX","originX"],yk=["y","scaleY","originY"];function Rw(i,e,t,n){Cw(i.x,e,vk,t?t.x:void 0,n?n.x:void 0),Cw(i.y,e,yk,t?t.y:void 0,n?n.y:void 0)}function bw(i){return i.translate===0&&i.scale===1}function gC(i){return bw(i.x)&&bw(i.y)}function Pw(i,e){return i.min===e.min&&i.max===e.max}function _k(i,e){return Pw(i.x,e.x)&&Pw(i.y,e.y)}function Iw(i,e){return Math.round(i.min)===Math.round(e.min)&&Math.round(i.max)===Math.round(e.max)}function vC(i,e){return Iw(i.x,e.x)&&Iw(i.y,e.y)}function Lw(i){return os(i.x)/os(i.y)}function Dw(i,e){return i.translate===e.translate&&i.scale===e.scale&&i.originPoint===e.originPoint}class xk{constructor(){this.members=[]}add(e){Ux(this.members,e),e.scheduleRender()}remove(e){if(Fx(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(e){const t=this.members.findIndex(r=>e===r);if(t===0)return!1;let n;for(let r=t;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1){n=o;break}}return n?(this.promote(n),!0):!1}promote(e,t){const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,t&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:r}=e.options;r===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:t,resumingFrom:n}=e;t.onExitComplete&&t.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Sk(i,e,t){let n="";const r=i.x.translate/e.x,o=i.y.translate/e.y,a=t?.z||0;if((r||o||a)&&(n=`translate3d(${r}px, ${o}px, ${a}px) `),(e.x!==1||e.y!==1)&&(n+=`scale(${1/e.x}, ${1/e.y}) `),t){const{transformPerspective:p,rotate:m,rotateX:g,rotateY:v,skewX:x,skewY:w}=t;p&&(n=`perspective(${p}px) ${n}`),m&&(n+=`rotate(${m}deg) `),g&&(n+=`rotateX(${g}deg) `),v&&(n+=`rotateY(${v}deg) `),x&&(n+=`skewX(${x}deg) `),w&&(n+=`skewY(${w}deg) `)}const u=i.x.scale*e.x,h=i.y.scale*e.y;return(u!==1||h!==1)&&(n+=`scale(${u}, ${h})`),n||"none"}const Mk=(i,e)=>i.depth-e.depth;class wk{constructor(){this.children=[],this.isDirty=!1}add(e){Ux(this.children,e),this.isDirty=!0}remove(e){Fx(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Mk),this.isDirty=!1,this.children.forEach(e)}}function fg(i){const e=rr(i)?i.get():i;return dO(e)?e.toValue():e}function Ek(i,e){const t=Ro.now(),n=({timestamp:r})=>{const o=r-t;o>=e&&(xl(n),i(o-e))};return Un.read(n,!0),()=>xl(n)}function Tk(i){return i instanceof SVGElement&&i.tagName!=="svg"}function Ak(i,e,t){const n=rr(i)?i:Jd(i);return n.start(Nx("",n,e,t)),n.animation}const Ru={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},pd=typeof window<"u"&&window.MotionDebug!==void 0,Oy=["","X","Y","Z"],Ck={visibility:"hidden"},Nw=1e3;let Rk=0;function ky(i,e,t,n){const{latestValues:r}=e;r[i]&&(t[i]=r[i],e.setStaticValue(i,0),n&&(n[i]=0))}function yC(i){if(i.hasCheckedOptimisedAppear=!0,i.root===i)return;const{visualElement:e}=i.options;if(!e)return;const t=QA(e);if(window.MotionHasOptimisedAnimation(t,"transform")){const{layout:r,layoutId:o}=i.options;window.MotionCancelOptimisedAnimation(t,"transform",Un,!(r||o))}const{parent:n}=i;n&&!n.hasCheckedOptimisedAppear&&yC(n)}function _C({attachResizeListener:i,defaultParent:e,measureScroll:t,checkIsScrollRoot:n,resetTransform:r}){return class{constructor(a={},u=e?.()){this.id=Rk++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,pd&&(Ru.totalNodes=Ru.resolvedTargetDeltas=Ru.recalculatedProjection=0),this.nodes.forEach(Ik),this.nodes.forEach(Fk),this.nodes.forEach(Ok),this.nodes.forEach(Lk),pd&&window.MotionDebug.record(Ru)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let h=0;hthis.root.updateBlockedByResize=!1;i(a,()=>{this.root.updateBlockedByResize=!0,g&&g(),g=Ek(v,250),cg.hasAnimatedSinceResize&&(cg.hasAnimatedSinceResize=!1,this.nodes.forEach(Fw))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&m&&(h||p)&&this.addEventListener("didUpdate",({delta:g,hasLayoutChanged:v,hasRelativeTargetChanged:x,layout:w})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const A=this.options.transition||m.getDefaultTransition()||Hk,{onLayoutAnimationStart:E,onLayoutAnimationComplete:S}=m.getProps(),b=!this.targetLayout||!vC(this.targetLayout,w)||x,P=!v&&x;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||P||v&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(g,P);const I={...xx(A,"layout"),onPlay:E,onComplete:S};(m.shouldReduceMotion||this.options.layoutRoot)&&(I.delay=0,I.type=!1),this.startAnimation(I)}else v||Fw(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=w})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,xl(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(kk),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&yC(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h{const B=I/1e3;Ow(g.x,a.x,B),Ow(g.y,a.y,B),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(bd(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox),zk(this.relativeTarget,this.relativeTargetOrigin,v,B),P&&_k(this.relativeTarget,P)&&(this.isProjectionDirty=!1),P||(P=ii()),Ms(P,this.relativeTarget)),A&&(this.animationValues=m,dk(m,p,this.latestValues,B,b,S)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=B},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(xl(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Un.update(()=>{cg.hasAnimatedSinceResize=!0,this.currentAnimation=Ak(0,Nw,{...a,onUpdate:u=>{this.mixTargetDelta(u),a.onUpdate&&a.onUpdate(u)},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Nw),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:u,target:h,layout:p,latestValues:m}=a;if(!(!u||!h||!p)){if(this!==a&&this.layout&&p&&xC(this.options.animationType,this.layout.layoutBox,p.layoutBox)){h=this.target||ii();const g=os(this.layout.layoutBox.x);h.x.min=a.target.x.min,h.x.max=h.x.min+g;const v=os(this.layout.layoutBox.y);h.y.min=a.target.y.min,h.y.max=h.y.min+v}Ms(u,h),Ff(u,m),Rd(this.projectionDeltaWithTransform,this.layoutCorrected,u,m)}}registerSharedNode(a,u){this.sharedNodes.has(a)||this.sharedNodes.set(a,new xk),this.sharedNodes.get(a).add(u);const p=u.options.initialPromotionConfig;u.promote({transition:p?p.transition:void 0,preserveFollowOpacity:p&&p.shouldPreserveFollowOpacity?p.shouldPreserveFollowOpacity(u):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var a;const{layoutId:u}=this.options;return u?((a=this.getStack())===null||a===void 0?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:u}=this.options;return u?(a=this.getStack())===null||a===void 0?void 0:a.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:u,preserveFollowOpacity:h}={}){const p=this.getStack();p&&p.promote(this,h),a&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let u=!1;const{latestValues:h}=a;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(u=!0),!u)return;const p={};h.z&&ky("z",a,p,this.animationValues);for(let m=0;m{var u;return(u=a.currentAnimation)===null||u===void 0?void 0:u.stop()}),this.root.nodes.forEach(Uw),this.root.sharedNodes.clear()}}}function bk(i){i.updateLayout()}function Pk(i){var e;const t=((e=i.resumeFrom)===null||e===void 0?void 0:e.snapshot)||i.snapshot;if(i.isLead()&&i.layout&&t&&i.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=i.layout,{animationType:o}=i.options,a=t.source!==i.layout.source;o==="size"?ws(g=>{const v=a?t.measuredBox[g]:t.layoutBox[g],x=os(v);v.min=n[g].min,v.max=v.min+x}):xC(o,t.layoutBox,n)&&ws(g=>{const v=a?t.measuredBox[g]:t.layoutBox[g],x=os(n[g]);v.max=v.min+x,i.relativeTarget&&!i.currentAnimation&&(i.isProjectionDirty=!0,i.relativeTarget[g].max=i.relativeTarget[g].min+x)});const u=Nf();Rd(u,n,t.layoutBox);const h=Nf();a?Rd(h,i.applyTransform(r,!0),t.measuredBox):Rd(h,n,t.layoutBox);const p=!gC(u);let m=!1;if(!i.resumeFrom){const g=i.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:v,layout:x}=g;if(v&&x){const w=ii();bd(w,t.layoutBox,v.layoutBox);const A=ii();bd(A,n,x.layoutBox),vC(w,A)||(m=!0),g.options.layoutRoot&&(i.relativeTarget=A,i.relativeTargetOrigin=w,i.relativeParent=g)}}}i.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:h,layoutDelta:u,hasLayoutChanged:p,hasRelativeTargetChanged:m})}else if(i.isLead()){const{onExitComplete:n}=i.options;n&&n()}i.options.transition=void 0}function Ik(i){pd&&Ru.totalNodes++,i.parent&&(i.isProjecting()||(i.isProjectionDirty=i.parent.isProjectionDirty),i.isSharedProjectionDirty||(i.isSharedProjectionDirty=!!(i.isProjectionDirty||i.parent.isProjectionDirty||i.parent.isSharedProjectionDirty)),i.isTransformDirty||(i.isTransformDirty=i.parent.isTransformDirty))}function Lk(i){i.isProjectionDirty=i.isSharedProjectionDirty=i.isTransformDirty=!1}function Dk(i){i.clearSnapshot()}function Uw(i){i.clearMeasurements()}function Nk(i){i.isLayoutDirty=!1}function Uk(i){const{visualElement:e}=i.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),i.resetTransform()}function Fw(i){i.finishAnimation(),i.targetDelta=i.relativeTarget=i.target=void 0,i.isProjectionDirty=!0}function Fk(i){i.resolveTargetDelta()}function Ok(i){i.calcProjection()}function kk(i){i.resetSkewAndRotation()}function Bk(i){i.removeLeadSnapshot()}function Ow(i,e,t){i.translate=Gn(e.translate,0,t),i.scale=Gn(e.scale,1,t),i.origin=e.origin,i.originPoint=e.originPoint}function kw(i,e,t,n){i.min=Gn(e.min,t.min,n),i.max=Gn(e.max,t.max,n)}function zk(i,e,t,n){kw(i.x,e.x,t.x,n),kw(i.y,e.y,t.y,n)}function Vk(i){return i.animationValues&&i.animationValues.opacityExit!==void 0}const Hk={duration:.45,ease:[.4,0,.1,1]},Bw=i=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(i),zw=Bw("applewebkit/")&&!Bw("chrome/")?Math.round:rs;function Vw(i){i.min=zw(i.min),i.max=zw(i.max)}function Gk(i){Vw(i.x),Vw(i.y)}function xC(i,e,t){return i==="position"||i==="preserve-aspect"&&!WO(Lw(e),Lw(t),.2)}function Wk(i){var e;return i!==i.root&&((e=i.scroll)===null||e===void 0?void 0:e.wasRoot)}const Xk=_C({attachResizeListener:(i,e)=>Qd(i,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),By={current:void 0},SC=_C({measureScroll:i=>({x:i.scrollLeft,y:i.scrollTop}),defaultParent:()=>{if(!By.current){const i=new Xk({});i.mount(window),i.setOptions({layoutScroll:!0}),By.current=i}return By.current},resetTransform:(i,e)=>{i.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:i=>window.getComputedStyle(i).position==="fixed"}),jk={pan:{Feature:ok},drag:{Feature:sk,ProjectionNode:SC,MeasureLayout:dC}};function Yk(i,e,t){var n;if(i instanceof Element)return[i];if(typeof i=="string"){let r=document;const o=(n=void 0)!==null&&n!==void 0?n:r.querySelectorAll(i);return o?Array.from(o):[]}return Array.from(i)}function MC(i,e){const t=Yk(i),n=new AbortController,r={passive:!0,...e,signal:n.signal};return[t,r,()=>n.abort()]}function Hw(i){return e=>{e.pointerType==="touch"||tC()||i(e)}}function qk(i,e,t={}){const[n,r,o]=MC(i,t),a=Hw(u=>{const{target:h}=u,p=e(u);if(!p||!h)return;const m=Hw(g=>{p(g),h.removeEventListener("pointerleave",m)});h.addEventListener("pointerleave",m,r)});return n.forEach(u=>{u.addEventListener("pointerenter",a,r)}),o}function Gw(i,e,t){const{props:n}=i;i.animationState&&n.whileHover&&i.animationState.setActive("whileHover",t==="Start");const r="onHover"+t,o=n[r];o&&Un.postRender(()=>o(e,gp(e)))}class Zk extends Tl{mount(){const{current:e}=this.node;e&&(this.unmount=qk(e,t=>(Gw(this.node,t,"Start"),n=>Gw(this.node,n,"End"))))}unmount(){}}class Kk extends Tl{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=mp(Qd(this.node.current,"focus",()=>this.onFocus()),Qd(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const md=new WeakSet;function Ww(i){return e=>{e.key==="Enter"&&i(e)}}function zy(i,e){i.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Jk=(i,e)=>{const t=i.currentTarget;if(!t)return;const n=Ww(()=>{if(md.has(t))return;zy(t,"down");const r=Ww(()=>{zy(t,"up")}),o=()=>zy(t,"cancel");t.addEventListener("keyup",r,e),t.addEventListener("blur",o,e)});t.addEventListener("keydown",n,e),t.addEventListener("blur",()=>t.removeEventListener("keydown",n),e)},Qk=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function $k(i){return Qk.has(i.tagName)||i.tabIndex!==-1}const wC=(i,e)=>e?i===e?!0:wC(i,e.parentElement):!1;function Xw(i){return Bx(i)&&!tC()}function eB(i,e,t={}){const[n,r,o]=MC(i,t),a=u=>{const h=u.currentTarget;if(!Xw(u)||md.has(h))return;md.add(h);const p=e(u),m=(x,w)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",v),!(!Xw(x)||!md.has(h))&&(md.delete(h),p&&p(x,{success:w}))},g=x=>{m(x,t.useGlobalTarget||wC(h,x.target))},v=x=>{m(x,!1)};window.addEventListener("pointerup",g,r),window.addEventListener("pointercancel",v,r)};return n.forEach(u=>{$k(u)||(u.tabIndex=0),(t.useGlobalTarget?window:u).addEventListener("pointerdown",a,r),u.addEventListener("focus",p=>Jk(p,r),r)}),o}function jw(i,e,t){const{props:n}=i;i.animationState&&n.whileTap&&i.animationState.setActive("whileTap",t==="Start");const r="onTap"+(t==="End"?"":t),o=n[r];o&&Un.postRender(()=>o(e,gp(e)))}class tB extends Tl{mount(){const{current:e}=this.node;e&&(this.unmount=eB(e,t=>(jw(this.node,t,"Start"),(n,{success:r})=>jw(this.node,n,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const S_=new WeakMap,Vy=new WeakMap,nB=i=>{const e=S_.get(i.target);e&&e(i)},iB=i=>{i.forEach(nB)};function rB({root:i,...e}){const t=i||document;Vy.has(t)||Vy.set(t,{});const n=Vy.get(t),r=JSON.stringify(e);return n[r]||(n[r]=new IntersectionObserver(iB,{root:i,...e})),n[r]}function sB(i,e,t){const n=rB(e);return S_.set(i,t),n.observe(i),()=>{S_.delete(i),n.unobserve(i)}}const oB={some:0,all:1};class aB extends Tl{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r="some",once:o}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r=="number"?r:oB[r]},u=h=>{const{isIntersecting:p}=h;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:m,onViewportLeave:g}=this.node.getProps(),v=p?m:g;v&&v(h)};return sB(this.node.current,a,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(lB(e,t))&&this.startObserver()}unmount(){}}function lB({viewport:i={}},{viewport:e={}}={}){return t=>i[t]!==e[t]}const uB={inView:{Feature:aB},tap:{Feature:tB},focus:{Feature:Kk},hover:{Feature:Zk}},cB={layout:{ProjectionNode:SC,MeasureLayout:dC}},EC=Ie.createContext({transformPagePoint:i=>i,isStatic:!1,reducedMotion:"never"}),G0=Ie.createContext({}),Hx=typeof window<"u",fB=Hx?Ie.useLayoutEffect:Ie.useEffect,TC=Ie.createContext({strict:!1});function hB(i,e,t,n,r){var o,a;const{visualElement:u}=Ie.useContext(G0),h=Ie.useContext(TC),p=Ie.useContext(zx),m=Ie.useContext(EC).reducedMotion,g=Ie.useRef(null);n=n||h.renderer,!g.current&&n&&(g.current=n(i,{visualState:e,parent:u,props:t,presenceContext:p,blockInitialAnimation:p?p.initial===!1:!1,reducedMotionConfig:m}));const v=g.current,x=Ie.useContext(hC);v&&!v.projection&&r&&(v.type==="html"||v.type==="svg")&&dB(g.current,t,r,x);const w=Ie.useRef(!1);Ie.useInsertionEffect(()=>{v&&w.current&&v.update(t,p)});const A=t[JA],E=Ie.useRef(!!A&&!(!((o=window.MotionHandoffIsComplete)===null||o===void 0)&&o.call(window,A))&&((a=window.MotionHasOptimisedAnimation)===null||a===void 0?void 0:a.call(window,A)));return fB(()=>{v&&(w.current=!0,window.MotionIsMounted=!0,v.updateFeatures(),Vx.render(v.render),E.current&&v.animationState&&v.animationState.animateChanges())}),Ie.useEffect(()=>{v&&(!E.current&&v.animationState&&v.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{var S;(S=window.MotionHandoffMarkAsComplete)===null||S===void 0||S.call(window,A)}),E.current=!1))}),v}function dB(i,e,t,n){const{layoutId:r,layout:o,drag:a,dragConstraints:u,layoutScroll:h,layoutRoot:p}=e;i.projection=new t(i.latestValues,e["data-framer-portal-id"]?void 0:AC(i.parent)),i.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!a||u&&Df(u),visualElement:i,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,layoutScroll:h,layoutRoot:p})}function AC(i){if(i)return i.options.allowProjection!==!1?i.projection:AC(i.parent)}function pB(i,e,t){return Ie.useCallback(n=>{n&&i.mount&&i.mount(n),e&&(n?e.mount(n):e.unmount()),t&&(typeof t=="function"?t(n):Df(t)&&(t.current=n))},[e])}function W0(i){return z0(i.animate)||_x.some(e=>qd(i[e]))}function CC(i){return!!(W0(i)||i.variants)}function mB(i,e){if(W0(i)){const{initial:t,animate:n}=i;return{initial:t===!1||qd(t)?t:void 0,animate:qd(n)?n:void 0}}return i.inherit!==!1?e:{}}function gB(i){const{initial:e,animate:t}=mB(i,Ie.useContext(G0));return Ie.useMemo(()=>({initial:e,animate:t}),[Yw(e),Yw(t)])}function Yw(i){return Array.isArray(i)?i.join(" "):i}const qw={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},jf={};for(const i in qw)jf[i]={isEnabled:e=>qw[i].some(t=>!!e[t])};function vB(i){for(const e in i)jf[e]={...jf[e],...i[e]}}const yB=Symbol.for("motionComponentSymbol");function _B({preloadedFeatures:i,createVisualElement:e,useRender:t,useVisualState:n,Component:r}){i&&vB(i);function o(u,h){let p;const m={...Ie.useContext(EC),...u,layoutId:xB(u)},{isStatic:g}=m,v=gB(u),x=n(u,g);if(!g&&Hx){SB();const w=MB(m);p=w.MeasureLayout,v.visualElement=hB(r,x,m,e,w.ProjectionNode)}return tn.jsxs(G0.Provider,{value:v,children:[p&&v.visualElement?tn.jsx(p,{visualElement:v.visualElement,...m}):null,t(r,u,pB(x,v.visualElement,h),x,g,v.visualElement)]})}const a=Ie.forwardRef(o);return a[yB]=r,a}function xB({layoutId:i}){const e=Ie.useContext(fC).id;return e&&i!==void 0?e+"-"+i:i}function SB(i,e){Ie.useContext(TC).strict}function MB(i){const{drag:e,layout:t}=jf;if(!e&&!t)return{};const n={...e,...t};return{MeasureLayout:e?.isEnabled(i)||t?.isEnabled(i)?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}const wB=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Gx(i){return typeof i!="string"||i.includes("-")?!1:!!(wB.indexOf(i)>-1||/[A-Z]/u.test(i))}function RC(i,{style:e,vars:t},n,r){Object.assign(i.style,e,r&&r.getProjectionStyles(n));for(const o in t)i.style.setProperty(o,t[o])}const bC=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function PC(i,e,t,n){RC(i,e,void 0,n);for(const r in e.attrs)i.setAttribute(bC.has(r)?r:kx(r),e.attrs[r])}function IC(i,{layout:e,layoutId:t}){return Ju.has(i)||i.startsWith("origin")||(e||t!==void 0)&&(!!s0[i]||i==="opacity")}function Wx(i,e,t){var n;const{style:r}=i,o={};for(const a in r)(rr(r[a])||e.style&&rr(e.style[a])||IC(a,i)||((n=t?.getValue(a))===null||n===void 0?void 0:n.liveStyle)!==void 0)&&(o[a]=r[a]);return o}function LC(i,e,t){const n=Wx(i,e,t);for(const r in i)if(rr(i[r])||rr(e[r])){const o=hp.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;n[o]=i[r]}return n}function EB(i){const e=Ie.useRef(null);return e.current===null&&(e.current=i()),e.current}function TB({scrapeMotionValuesFromProps:i,createRenderState:e,onMount:t},n,r,o){const a={latestValues:AB(n,r,o,i),renderState:e()};return t&&(a.mount=u=>t(n,u,a)),a}const DC=i=>(e,t)=>{const n=Ie.useContext(G0),r=Ie.useContext(zx),o=()=>TB(i,e,n,r);return t?o():EB(o)};function AB(i,e,t,n){const r={},o=n(i,{});for(const v in o)r[v]=fg(o[v]);let{initial:a,animate:u}=i;const h=W0(i),p=CC(i);e&&p&&!h&&i.inherit!==!1&&(a===void 0&&(a=e.initial),u===void 0&&(u=e.animate));let m=t?t.initial===!1:!1;m=m||a===!1;const g=m?u:a;if(g&&typeof g!="boolean"&&!z0(g)){const v=Array.isArray(g)?g:[g];for(let x=0;x({style:{},transform:{},transformOrigin:{},vars:{}}),NC=()=>({...Xx(),attrs:{}}),UC=(i,e)=>e&&typeof i=="number"?e.transform(i):i,CB={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},RB=hp.length;function bB(i,e,t){let n="",r=!0;for(let o=0;otypeof i=="string"&&i.toLowerCase()==="svg",NB={useVisualState:DC({scrapeMotionValuesFromProps:LC,createRenderState:NC,onMount:(i,e,{renderState:t,latestValues:n})=>{Un.read(()=>{try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}),Un.render(()=>{Yx(t,n,qx(e.tagName),i.transformTemplate),PC(e,t)})}})},UB={useVisualState:DC({scrapeMotionValuesFromProps:Wx,createRenderState:Xx})};function FC(i,e,t){for(const n in e)!rr(e[n])&&!IC(n,t)&&(i[n]=e[n])}function FB({transformTemplate:i},e){return Ie.useMemo(()=>{const t=Xx();return jx(t,e,i),Object.assign({},t.vars,t.style)},[e])}function OB(i,e){const t=i.style||{},n={};return FC(n,t,i),Object.assign(n,FB(i,e)),n}function kB(i,e){const t={},n=OB(i,e);return i.drag&&i.dragListener!==!1&&(t.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=i.drag===!0?"none":`pan-${i.drag==="x"?"y":"x"}`),i.tabIndex===void 0&&(i.onTap||i.onTapStart||i.whileTap)&&(t.tabIndex=0),t.style=n,t}const BB=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function o0(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||BB.has(i)}let OC=i=>!o0(i);function zB(i){i&&(OC=e=>e.startsWith("on")?!o0(e):i(e))}try{zB(require("@emotion/is-prop-valid").default)}catch{}function VB(i,e,t){const n={};for(const r in i)r==="values"&&typeof i.values=="object"||(OC(r)||t===!0&&o0(r)||!e&&!o0(r)||i.draggable&&r.startsWith("onDrag"))&&(n[r]=i[r]);return n}function HB(i,e,t,n){const r=Ie.useMemo(()=>{const o=NC();return Yx(o,e,qx(n),i.transformTemplate),{...o.attrs,style:{...o.style}}},[e]);if(i.style){const o={};FC(o,i.style,i),r.style={...o,...r.style}}return r}function GB(i=!1){return(t,n,r,{latestValues:o},a)=>{const h=(Gx(t)?HB:kB)(n,o,a,t),p=VB(n,typeof t=="string",i),m=t!==Ie.Fragment?{...p,...h,ref:r}:{},{children:g}=n,v=Ie.useMemo(()=>rr(g)?g.get():g,[g]);return Ie.createElement(t,{...m,children:v})}}function WB(i,e){return function(n,{forwardMotionProps:r}={forwardMotionProps:!1}){const a={...Gx(n)?NB:UB,preloadedFeatures:i,useRender:GB(r),createVisualElement:e,Component:n};return _B(a)}}const M_={current:null},kC={current:!1};function XB(){if(kC.current=!0,!!Hx)if(window.matchMedia){const i=window.matchMedia("(prefers-reduced-motion)"),e=()=>M_.current=i.matches;i.addListener(e),e()}else M_.current=!1}function jB(i,e,t){for(const n in e){const r=e[n],o=t[n];if(rr(r))i.addValue(n,r);else if(rr(o))i.addValue(n,Jd(r,{owner:i}));else if(o!==r)if(i.hasValue(n)){const a=i.getValue(n);a.liveStyle===!0?a.jump(r):a.hasAnimated||a.set(r)}else{const a=i.getStaticValue(n);i.addValue(n,Jd(a!==void 0?a:r,{owner:i}))}}for(const n in t)e[n]===void 0&&i.removeValue(n);return e}const Kw=new WeakMap,YB=[...bA,nr,Sl],qB=i=>YB.find(RA(i)),Jw=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class ZB{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,blockInitialAnimation:o,visualState:a},u={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ex,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const v=Ro.now();this.renderScheduledAtthis.bindToMotionValue(n,t)),kC.current||XB(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:M_.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Kw.delete(this.current),this.projection&&this.projection.unmount(),xl(this.notifyUpdate),xl(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const n=Ju.has(e),r=t.on("change",u=>{this.latestValues[e]=u,this.props.onUpdate&&Un.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),o=t.on("renderRequest",this.scheduleRender);let a;window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),o(),a&&a(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in jf){const t=jf[e];if(!t)continue;const{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ii()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let n=0;nt.variantChildren.delete(e)}addValue(e,t){const n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Jd(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){var n;let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:(n=this.getBaseTargetFromProps(this.props,e))!==null&&n!==void 0?n:this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(EA(r)||wA(r))?r=parseFloat(r):!qB(r)&&Sl.test(t)&&(r=OA(e,t)),this.setBaseTarget(e,rr(r)?r.get():r)),rr(r)?r.get():r}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){var t;const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const a=vx(this.props,n,(t=this.presenceContext)===null||t===void 0?void 0:t.custom);a&&(r=a[e])}if(n&&r!==void 0)return r;const o=this.getBaseTargetFromProps(this.props,e);return o!==void 0&&!rr(o)?o:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new Ox),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}}class BC extends ZB{constructor(){super(...arguments),this.KeyframeResolver=kA}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;rr(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}}function KB(i){return window.getComputedStyle(i)}class JB extends BC{constructor(){super(...arguments),this.type="html",this.renderInstance=RC}readValueFromInstance(e,t){if(Ju.has(t)){const n=Rx(t);return n&&n.default||0}else{const n=KB(e),r=(AA(t)?n.getPropertyValue(t):n[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return uC(e,t)}build(e,t,n){jx(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Wx(e,t,n)}}class QB extends BC{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=ii}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Ju.has(t)){const n=Rx(t);return n&&n.default||0}return t=bC.has(t)?t:kx(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return LC(e,t,n)}build(e,t,n){Yx(e,t,this.isSVGTag,n.transformTemplate)}renderInstance(e,t,n,r){PC(e,t,n,r)}mount(e){this.isSVGTag=qx(e.tagName),super.mount(e)}}const $B=(i,e)=>Gx(i)?new QB(e):new JB(e,{allowProjection:i!==Ie.Fragment}),ez=WB({...NO,...uB,...jk,...cB},$B),Hy=LU(ez),zC={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform float opacity; uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); gl_FragColor = opacity * texel; }`};class eh{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const tz=new Jf(-1,1,1,-1,0,1);class nz extends Yt{constructor(){super(),this.setAttribute("position",new vt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new vt([0,2,0,0,2,0],2))}}const iz=new nz;class Zx{constructor(e){this._mesh=new Qn(iz,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,tz)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class rz extends eh{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof Ii?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Vf.clone(e.uniforms),this.material=new Ii({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Zx(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class Qw extends eh{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);let a,u;this.inverse?(a=0,u=1):(a=1,u=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),o.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),o.buffers.stencil.setClear(u),o.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.color.setMask(!0),o.buffers.depth.setMask(!0),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(r.EQUAL,1,4294967295),o.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),o.buffers.stencil.setLocked(!0)}}class sz extends eh{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class VC{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new Ce);this._width=n.width,this._height=n.height,t=new xr(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Eo}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new rz(zC),this.copyPass.material.blending=Mo,this.clock=new cp}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t #include varying vec2 vUv; void main() { gl_FragColor = texture2D( tDiffuse, vUv ); // tone mapping #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 ); #endif // color space #ifdef SRGB_TRANSFER gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif }`};class HC extends eh{constructor(){super();const e=oz;this.uniforms=Vf.clone(e.uniforms),this.material=new ex({name:e.name,uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader}),this.fsQuad=new Zx(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},ln.getTransfer(this._outputColorSpace)===_n&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===w_?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===E_?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===T_?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===c0?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===A_?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===C_&&(this.material.defines.NEUTRAL_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class GC extends eh{constructor(e,t,n=null,r=null,o=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=o,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new et}render(e,t,n){const r=e.autoClear;e.autoClear=!1;let o,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(o=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(o),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}}const az={name:"LuminosityHighPassShader",shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new et(0)},defaultOpacity:{value:0}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform sampler2D tDiffuse; uniform vec3 defaultColor; uniform float defaultOpacity; uniform float luminosityThreshold; uniform float smoothWidth; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); float v = luminance( texel.xyz ); vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity ); float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v ); gl_FragColor = mix( outputColor, texel, alpha ); }`};class Yu extends eh{constructor(e,t,n,r){super(),this.strength=t!==void 0?t:1,this.radius=n,this.threshold=r,this.resolution=e!==void 0?new Ce(e.x,e.y):new Ce(256,256),this.clearColor=new et(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let o=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new xr(o,a,{type:Eo}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let g=0;g varying vec2 vUv; uniform sampler2D colorTexture; uniform vec2 invSize; uniform vec2 direction; uniform float gaussianCoefficients[KERNEL_RADIUS]; void main() { float weightSum = gaussianCoefficients[0]; vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum; for( int i = 1; i < KERNEL_RADIUS; i ++ ) { float x = float(i); float w = gaussianCoefficients[i]; vec2 uvOffset = direction * invSize * x; vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; diffuseSum += (sample1 + sample2) * w; weightSum += 2.0 * w; } gl_FragColor = vec4(diffuseSum/weightSum, 1.0); }`})}getCompositeMaterial(e){return new Ii({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:`varying vec2 vUv; uniform sampler2D blurTexture1; uniform sampler2D blurTexture2; uniform sampler2D blurTexture3; uniform sampler2D blurTexture4; uniform sampler2D blurTexture5; uniform float bloomStrength; uniform float bloomRadius; uniform float bloomFactors[NUM_MIPS]; uniform vec3 bloomTintColors[NUM_MIPS]; float lerpBloomFactor(const in float factor) { float mirrorFactor = 1.2 - factor; return mix(factor, mirrorFactor, bloomRadius); } void main() { gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) ); }`})}}Yu.BlurDirectionX=new Ce(1,0);Yu.BlurDirectionY=new Ce(0,1);ZT({EffectComposer:VC,RenderPass:GC,UnrealBloomPass:Yu,OutputPass:HC});function lz({frequency:i}){const{gl:e,scene:t,camera:n,size:r}=lU(),o=Ie.useRef(),a=Ie.useRef(),u=Ie.useRef(),h=Ie.useRef();return Ie.useEffect(()=>(o.current=new GC(t,n),a.current=new HC,u.current=new VC(e),h.current=new Yu(new Ce(r.width,r.height),.2,1,0),u.current.addPass(o.current),u.current.addPass(h.current),u.current.addPass(a.current),()=>{u.current.removePass(o.current),u.current.removePass(h.current),u.current.removePass(a.current),o.current.dispose(),a.current.dispose(),h.current.dispose()}),[e,t,n,r]),Ie.useEffect(()=>{u.current.setSize(r.width,r.height)},[r]),Ie.useEffect(()=>{h.current.strength=.2+i/1e3},[i]),aA(()=>{u.current.render()},1),null}const uz=10,cz=.5,fz=60,hz=new cp;function dz({ready:i,active:e,frequency:t}){const n={red:i?e?1:0:.1,green:i?e?0:1:.1,blue:i?e?1:0:.1},r=Ie.useRef(),o=Ie.useMemo(()=>new sp(3,20),[]),a=Ie.useMemo(()=>new Ii({uniforms:{u_time:{value:0},u_frequency:{value:0},u_red:{value:0},u_green:{value:0},u_blue:{value:0}},vertexShader:document.getElementById("vertexshader").textContent,fragmentShader:document.getElementById("fragmentshader").textContent,wireframe:!0}),[]),u=a.uniforms;return aA(()=>{const h=hz.getElapsedTime();u.u_time.value=h,u.u_frequency.value=Math.min(uz+cz*t,fz),u.u_red.value=n.red,u.u_green.value=n.green,u.u_blue.value=n.blue}),tn.jsx("primitive",{object:new Qn(o,a),ref:r})}const $w=16e3;function eE(i){return new Date(i).toLocaleString("zh",{hour12:!1,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3})}function pz(){const[i,e]=Ie.useState(null),[t,n]=Ie.useState(null),[r,o]=Ie.useState([]),[a,u]=Ie.useState(0),h=Ie.useRef(null);Ie.useEffect(()=>{h.current??=new Worker(new URL("/assets/worker-BrsEphLD.js",import.meta.url),{type:"module"});const m=({data:v})=>{if(v.error)return g(v.error);v.type==="status"?(e(v.message),o(x=>[...x,v])):o(x=>[...x,v])},g=v=>n(v.message);return h.current.addEventListener("message",m),h.current.addEventListener("error",g),()=>{h.current.removeEventListener("message",m),h.current.removeEventListener("error",g)}},[]),Ie.useEffect(()=>{let m=!1;const g=navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:$w}});let v,x,w;return g.then(async A=>{if(m)return;x=new(window.AudioContext||window.webkitAudioContext)({sampleRate:$w,latencyHint:"interactive"});const E=x.createAnalyser();E.fftSize=32,w=x.createMediaStreamSource(A),w.connect(E);const S=new Uint8Array(E.frequencyBinCount),b=()=>(E.getByteFrequencyData(S),S.reduce((I,B)=>I+B,0)/S.length),P=()=>{const I=b();u(I),requestAnimationFrame(P)};P(),await x.audioWorklet.addModule(new URL("data:text/javascript;base64,Y29uc3QgTUlOX0NIVU5LX1NJWkUgPSA1MTI7CmxldCBnbG9iYWxQb2ludGVyID0gMDsKbGV0IGdsb2JhbEJ1ZmZlciA9IG5ldyBGbG9hdDMyQXJyYXkoTUlOX0NIVU5LX1NJWkUpOwoKY2xhc3MgVkFEUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBwcm9jZXNzKGlucHV0cywgb3V0cHV0cywgcGFyYW1ldGVycykgewogICAgY29uc3QgYnVmZmVyID0gaW5wdXRzWzBdWzBdOwogICAgaWYgKCFidWZmZXIpIHJldHVybjsgLy8gYnVmZmVyIGlzIG51bGwgd2hlbiB0aGUgc3RyZWFtIGVuZHMKCiAgICBpZiAoYnVmZmVyLmxlbmd0aCA+IE1JTl9DSFVOS19TSVpFKSB7CiAgICAgIC8vIElmIHRoZSBidWZmZXIgaXMgbGFyZ2VyIHRoYW4gdGhlIG1pbmltdW0gY2h1bmsgc2l6ZSwgc2VuZCB0aGUgZW50aXJlIGJ1ZmZlcgogICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyBidWZmZXIgfSk7CiAgICB9IGVsc2UgewogICAgICBjb25zdCByZW1haW5pbmcgPSBNSU5fQ0hVTktfU0laRSAtIGdsb2JhbFBvaW50ZXI7CiAgICAgIGlmIChidWZmZXIubGVuZ3RoID49IHJlbWFpbmluZykgewogICAgICAgIC8vIElmIHRoZSBidWZmZXIgaXMgbGFyZ2VyIHRoYW4gKG9yIGVxdWFsIHRvKSB0aGUgcmVtYWluaW5nIHNwYWNlIGluIHRoZSBnbG9iYWwgYnVmZmVyLCBjb3B5IHRoZSByZW1haW5pbmcgc3BhY2UKICAgICAgICBnbG9iYWxCdWZmZXIuc2V0KGJ1ZmZlci5zdWJhcnJheSgwLCByZW1haW5pbmcpLCBnbG9iYWxQb2ludGVyKTsKCiAgICAgICAgLy8gU2VuZCB0aGUgZ2xvYmFsIGJ1ZmZlcgogICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7IGJ1ZmZlcjogZ2xvYmFsQnVmZmVyIH0pOwoKICAgICAgICAvLyBSZXNldCB0aGUgZ2xvYmFsIGJ1ZmZlciBhbmQgc2V0IHRoZSByZW1haW5pbmcgYnVmZmVyCiAgICAgICAgZ2xvYmFsQnVmZmVyLmZpbGwoMCk7CiAgICAgICAgZ2xvYmFsQnVmZmVyLnNldChidWZmZXIuc3ViYXJyYXkocmVtYWluaW5nKSwgMCk7CiAgICAgICAgZ2xvYmFsUG9pbnRlciA9IGJ1ZmZlci5sZW5ndGggLSByZW1haW5pbmc7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgLy8gSWYgdGhlIGJ1ZmZlciBpcyBzbWFsbGVyIHRoYW4gdGhlIHJlbWFpbmluZyBzcGFjZSBpbiB0aGUgZ2xvYmFsIGJ1ZmZlciwgY29weSB0aGUgYnVmZmVyIHRvIHRoZSBnbG9iYWwgYnVmZmVyCiAgICAgICAgZ2xvYmFsQnVmZmVyLnNldChidWZmZXIsIGdsb2JhbFBvaW50ZXIpOwogICAgICAgIGdsb2JhbFBvaW50ZXIgKz0gYnVmZmVyLmxlbmd0aDsKICAgICAgfQogICAgfQoKICAgIHJldHVybiB0cnVlOyAvLyBLZWVwIHRoZSBwcm9jZXNzb3IgYWxpdmUKICB9Cn0KCnJlZ2lzdGVyUHJvY2Vzc29yKCJ2YWQtcHJvY2Vzc29yIiwgVkFEUHJvY2Vzc29yKTsK",import.meta.url)),v=new AudioWorkletNode(x,"vad-processor",{numberOfInputs:1,numberOfOutputs:0,channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"}),w.connect(v),v.port.onmessage=I=>{const{buffer:B}=I.data;h.current?.postMessage({buffer:B})}}).catch(A=>{n(A.message),console.error(A)}),()=>{m=!0,g.then(A=>A.getTracks().forEach(E=>E.stop())),w?.disconnect(),v?.disconnect(),x?.close()}},[]);const p=()=>{const m=r.filter(w=>w.type==="output").map(w=>`${eE(w.start)} - ${eE(w.end)} | ${w.message}`).join(` `),g=new Blob([m],{type:"text/plain"}),v=URL.createObjectURL(g),x=document.createElement("a");x.href=v,x.download="transcript.txt",x.click(),URL.revokeObjectURL(v)};return tn.jsxs("div",{className:"flex flex-col items-center justify-center w-screen supports-[height:100cqh]:h-[100cqh] supports-[height:100svh]:h-[100svh] bg-gray-900",children:[tn.jsxs(Hy.div,{initial:{opacity:1,display:"flex"},animate:{opacity:0,display:"none"},transition:{delay:1.5,duration:2},className:"p-2 fixed inset-0 flex flex-col items-center justify-center bg-black/90 backdrop-blur-md z-20 text-center w-full h-full",children:[tn.jsx("h1",{className:"text-6xl sm:text-7xl lg:text-8xl text-white font-bold",children:"Moonshine Web"}),tn.jsx("h2",{className:"text-2xl text-white",children:"Real-time in-browser speech recognition, powered by Transformers.js"})]}),t?tn.jsxs("div",{className:"text-center p-2",children:[tn.jsx("div",{className:"text-white text-4xl md:text-5xl mb-1 font-semibold",children:"An error occurred"}),tn.jsx("div",{className:"text-red-300 text-xl",children:t})]}):tn.jsxs(tn.Fragment,{children:[tn.jsx("div",{className:"bottom-0 absolute text-center w-full z-10 text-white overflow-hidden pb-8",children:r.map(({type:m,message:g,duration:v},x)=>tn.jsx(Hy.div,{initial:{opacity:0,y:25},animate:{opacity:1,y:0},transition:{duration:.2},className:`mb-1 ${m==="output"?"text-5xl":"text-2xl text-green-300 font-light"}`,children:tn.jsx(Hy.div,{initial:{opacity:1},animate:v==="until_next"&&x===r.length-1?{}:{opacity:0,display:"none"},transition:{delay:v==="until_next"?0:1+g.length/20,duration:1},children:g})},x))}),tn.jsxs(IU,{camera:{position:[0,0,8]},children:[tn.jsx("ambientLight",{intensity:.5}),tn.jsx(lz,{frequency:a}),tn.jsx(dz,{ready:i!==null,active:i==="recording_start",frequency:a})]}),tn.jsxs("div",{className:"absolute bottom-6 right-6 flex flex-col space-y-2 z-10",children:[tn.jsx("button",{onClick:()=>p(),className:"w-10 h-10 bg-white rounded-full shadow-md flex items-center justify-center hover:bg-gray-100",title:"Download Transcript",children:tn.jsxs("svg",{className:"w-7 h-7 cursor-pointer text-gray-800","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24",children:[tn.jsx("path",{fillRule:"evenodd",d:"M13 11.15V4a1 1 0 1 0-2 0v7.15L8.78 8.374a1 1 0 1 0-1.56 1.25l4 5a1 1 0 0 0 1.56 0l4-5a1 1 0 1 0-1.56-1.25L13 11.15Z",clipRule:"evenodd"}),tn.jsx("path",{fillRule:"evenodd",d:"M9.657 15.874 7.358 13H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2.358l-2.3 2.874a3 3 0 0 1-4.685 0ZM17 16a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2H17Z",clipRule:"evenodd"})]})}),tn.jsx("button",{onClick:()=>window.open("https://github.com/huggingface/transformers.js-examples/tree/main/moonshine-web","_blank"),className:"w-10 h-10 cursor-pointer bg-white rounded-full shadow-md flex items-center justify-center hover:bg-gray-100",title:"Source Code",children:tn.jsx("svg",{className:"w-7 h-7 text-gray-800","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24",children:tn.jsx("path",{fillRule:"evenodd",d:"M12.006 2a9.847 9.847 0 0 0-6.484 2.44 10.32 10.32 0 0 0-3.393 6.17 10.48 10.48 0 0 0 1.317 6.955 10.045 10.045 0 0 0 5.4 4.418c.504.095.683-.223.683-.494 0-.245-.01-1.052-.014-1.908-2.78.62-3.366-1.21-3.366-1.21a2.711 2.711 0 0 0-1.11-1.5c-.907-.637.07-.621.07-.621.317.044.62.163.885.346.266.183.487.426.647.71.135.253.318.476.538.655a2.079 2.079 0 0 0 2.37.196c.045-.52.27-1.006.635-1.37-2.219-.259-4.554-1.138-4.554-5.07a4.022 4.022 0 0 1 1.031-2.75 3.77 3.77 0 0 1 .096-2.713s.839-.275 2.749 1.05a9.26 9.26 0 0 1 5.004 0c1.906-1.325 2.74-1.05 2.74-1.05.37.858.406 1.828.101 2.713a4.017 4.017 0 0 1 1.029 2.75c0 3.939-2.339 4.805-4.564 5.058a2.471 2.471 0 0 1 .679 1.897c0 1.372-.012 2.477-.012 2.814 0 .272.18.592.687.492a10.05 10.05 0 0 0 5.388-4.421 10.473 10.473 0 0 0 1.313-6.948 10.32 10.32 0 0 0-3.39-6.165A9.847 9.847 0 0 0 12.007 2Z",clipRule:"evenodd"})})})]})]})]})}MR.createRoot(document.getElementById("root")).render(tn.jsx(Ie.StrictMode,{children:tn.jsx(pz,{})}));