diff --git "a/assets/index-8904bf20.js" "b/assets/index-8904bf20.js" new file mode 100644--- /dev/null +++ "b/assets/index-8904bf20.js" @@ -0,0 +1,4063 @@ +function YV(n,e){for(var t=0;ti[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function s2(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function du(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var lO={exports:{}},TS={},cO={exports:{}},En={};/** + * @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 yy=Symbol.for("react.element"),KV=Symbol.for("react.portal"),ZV=Symbol.for("react.fragment"),JV=Symbol.for("react.strict_mode"),QV=Symbol.for("react.profiler"),$V=Symbol.for("react.provider"),e6=Symbol.for("react.context"),t6=Symbol.for("react.forward_ref"),n6=Symbol.for("react.suspense"),i6=Symbol.for("react.memo"),r6=Symbol.for("react.lazy"),lR=Symbol.iterator;function s6(n){return n===null||typeof n!="object"?null:(n=lR&&n[lR]||n["@@iterator"],typeof n=="function"?n:null)}var uO={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},hO=Object.assign,fO={};function lm(n,e,t){this.props=n,this.context=e,this.refs=fO,this.updater=t||uO}lm.prototype.isReactComponent={};lm.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=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,n,e,"setState")};lm.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function dO(){}dO.prototype=lm.prototype;function o2(n,e,t){this.props=n,this.context=e,this.refs=fO,this.updater=t||uO}var a2=o2.prototype=new dO;a2.constructor=o2;hO(a2,lm.prototype);a2.isPureReactComponent=!0;var cR=Array.isArray,pO=Object.prototype.hasOwnProperty,l2={current:null},mO={key:!0,ref:!0,__self:!0,__source:!0};function gO(n,e,t){var i,r={},s=null,o=null;if(e!=null)for(i in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)pO.call(e,i)&&!mO.hasOwnProperty(i)&&(r[i]=e[i]);var a=arguments.length-2;if(a===1)r.children=t;else if(1>>1,Oe=X[de];if(0>>1;der(Ve,re))Yer(He,Ve)?(X[de]=He,X[Ye]=re,de=Ye):(X[de]=Ve,X[we]=re,de=we);else if(Yer(He,re))X[de]=He,X[Ye]=re,de=Ye;else break e}}return ie}function r(X,ie){var re=X.sortIndex-ie.sortIndex;return re!==0?re:X.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,f=null,g=3,y=!1,v=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(X){for(var ie=t(c);ie!==null;){if(ie.callback===null)i(c);else if(ie.startTime<=X)i(c),ie.sortIndex=ie.expirationTime,e(l,ie);else break;ie=t(c)}}function C(X){if(w=!1,A(X),!v)if(t(l)!==null)v=!0,Se(N);else{var ie=t(c);ie!==null&&Fe(C,ie.startTime-X)}}function N(X,ie){v=!1,w&&(w=!1,x(H),H=-1),y=!0;var re=g;try{for(A(ie),f=t(l);f!==null&&(!(f.expirationTime>ie)||X&&!W());){var de=f.callback;if(typeof de=="function"){f.callback=null,g=f.priorityLevel;var Oe=de(f.expirationTime<=ie);ie=n.unstable_now(),typeof Oe=="function"?f.callback=Oe:f===t(l)&&i(l),A(ie)}else i(l);f=t(l)}if(f!==null)var it=!0;else{var we=t(c);we!==null&&Fe(C,we.startTime-ie),it=!1}return it}finally{f=null,g=re,y=!1}}var L=!1,F=null,H=-1,I=5,R=-1;function W(){return!(n.unstable_now()-RX||125de?(X.sortIndex=re,e(c,X),t(l)===null&&X===t(c)&&(w?(x(H),H=-1):w=!0,Fe(C,re-de))):(X.sortIndex=Oe,e(l,X),v||y||(v=!0,Se(N))),X},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(X){var ie=g;return function(){var re=g;g=ie;try{return X.apply(this,arguments)}finally{g=re}}}})(wO);xO.exports=wO;var g6=xO.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 SO=le,lo=g6;function Qe(n){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+n,t=1;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fb=Object.prototype.hasOwnProperty,y6=/^[: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]*$/,fR={},dR={};function v6(n){return Fb.call(dR,n)?!0:Fb.call(fR,n)?!1:y6.test(n)?dR[n]=!0:(fR[n]=!0,!1)}function x6(n,e,t,i){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function w6(n,e,t,i){if(e===null||typeof e>"u"||x6(n,e,t,i))return!0;if(i)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function _s(n,e,t,i,r,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var zr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){zr[n]=new _s(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];zr[e]=new _s(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){zr[n]=new _s(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){zr[n]=new _s(n,2,!1,n,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(n){zr[n]=new _s(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){zr[n]=new _s(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){zr[n]=new _s(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){zr[n]=new _s(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){zr[n]=new _s(n,5,!1,n.toLowerCase(),null,!1,!1)});var u2=/[\-:]([a-z])/g;function h2(n){return n[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(n){var e=n.replace(u2,h2);zr[e]=new _s(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(u2,h2);zr[e]=new _s(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(u2,h2);zr[e]=new _s(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){zr[n]=new _s(n,1,!1,n.toLowerCase(),null,!1,!1)});zr.xlinkHref=new _s("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){zr[n]=new _s(n,1,!1,n.toLowerCase(),null,!0,!0)});function f2(n,e,t,i){var r=zr.hasOwnProperty(e)?zr[e]:null;(r!==null?r.type!==0:i||!(2a||r[o]!==s[a]){var l=` +`+r[o].replace(" at new "," at ");return n.displayName&&l.includes("")&&(l=l.replace("",n.displayName)),l}while(1<=o&&0<=a);break}}}finally{IM=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Kg(n):""}function S6(n){switch(n.tag){case 5:return Kg(n.type);case 16:return Kg("Lazy");case 13:return Kg("Suspense");case 19:return Kg("SuspenseList");case 0:case 2:case 15:return n=DM(n.type,!1),n;case 11:return n=DM(n.type.render,!1),n;case 1:return n=DM(n.type,!0),n;default:return""}}function Vb(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case lp:return"Fragment";case ap:return"Portal";case Ub:return"Profiler";case d2:return"StrictMode";case zb:return"Suspense";case Bb:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case AO:return(n.displayName||"Context")+".Consumer";case MO:return(n._context.displayName||"Context")+".Provider";case p2:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case m2:return e=n.displayName||null,e!==null?e:Vb(n.type)||"Memo";case Lc:e=n._payload,n=n._init;try{return Vb(n(e))}catch{}}return null}function _6(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Vb(e);case 8:return e===d2?"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 e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ru(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function EO(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function M6(n){var e=EO(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),i=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var r=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return r.call(this)},set:function(o){i=""+o,s.call(this,o)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return i},setValue:function(o){i=""+o},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function gx(n){n._valueTracker||(n._valueTracker=M6(n))}function TO(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=EO(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function Mw(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Hb(n,e){var t=e.checked;return Ei({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function mR(n,e){var t=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;t=ru(e.value!=null?e.value:t),n._wrapperState={initialChecked:i,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function CO(n,e){e=e.checked,e!=null&&f2(n,"checked",e,!1)}function Gb(n,e){CO(n,e);var t=ru(e.value),i=e.type;if(t!=null)i==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(i==="submit"||i==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?Wb(n,e.type,t):e.hasOwnProperty("defaultValue")&&Wb(n,e.type,ru(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function gR(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function Wb(n,e,t){(e!=="number"||Mw(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Zg=Array.isArray;function Tp(n,e,t,i){if(n=n.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=yx.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function T0(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var o0={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},A6=["Webkit","ms","Moz","O"];Object.keys(o0).forEach(function(n){A6.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),o0[e]=o0[n]})});function LO(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||o0.hasOwnProperty(n)&&o0[n]?(""+e).trim():e+"px"}function IO(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var i=t.indexOf("--")===0,r=LO(t,e[t],i);t==="float"&&(t="cssFloat"),i?n.setProperty(t,r):n[t]=r}}var b6=Ei({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 qb(n,e){if(e){if(b6[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Qe(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Qe(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Qe(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Qe(62))}}function Yb(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){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 Kb=null;function g2(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Zb=null,Cp=null,Pp=null;function xR(n){if(n=wy(n)){if(typeof Zb!="function")throw Error(Qe(280));var e=n.stateNode;e&&(e=LS(e),Zb(n.stateNode,n.type,e))}}function DO(n){Cp?Pp?Pp.push(n):Pp=[n]:Cp=n}function OO(){if(Cp){var n=Cp,e=Pp;if(Pp=Cp=null,xR(n),e)for(n=0;n>>=0,n===0?32:31-(N6(n)/F6|0)|0}var vx=64,xx=4194304;function Jg(n){switch(n&-n){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 n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Tw(n,e){var t=n.pendingLanes;if(t===0)return 0;var i=0,r=n.suspendedLanes,s=n.pingedLanes,o=t&268435455;if(o!==0){var a=o&~r;a!==0?i=Jg(a):(s&=o,s!==0&&(i=Jg(s)))}else o=t&~r,o!==0?i=Jg(o):s!==0&&(i=Jg(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=i;0t;t++)e.push(n);return e}function vy(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-wa(e),n[e]=t}function V6(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var i=n.eventTimes;for(n=n.expirationTimes;0=l0),CR=String.fromCharCode(32),PR=!1;function tN(n,e){switch(n){case"keyup":return mH.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nN(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var cp=!1;function yH(n,e){switch(n){case"compositionend":return nN(e);case"keypress":return e.which!==32?null:(PR=!0,CR);case"textInput":return n=e.data,n===CR&&PR?null:n;default:return null}}function vH(n,e){if(cp)return n==="compositionend"||!A2&&tN(n,e)?(n=$O(),q1=S2=Gc=null,cp=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=i}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=IR(t)}}function oN(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?oN(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function aN(){for(var n=window,e=Mw();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Mw(n.document)}return e}function b2(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function TH(n){var e=aN(),t=n.focusedElem,i=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&oN(t.ownerDocument.documentElement,t)){if(i!==null&&b2(t)){if(e=i.start,n=i.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var r=t.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!n.extend&&s>i&&(r=i,i=s,s=r),r=DR(t,s);var o=DR(t,i);r&&o&&(n.rangeCount!==1||n.anchorNode!==r.node||n.anchorOffset!==r.offset||n.focusNode!==o.node||n.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),n.removeAllRanges(),s>i?(n.addRange(e),n.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,up=null,nE=null,u0=null,iE=!1;function OR(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;iE||up==null||up!==Mw(i)||(i=up,"selectionStart"in i&&b2(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),u0&&I0(u0,i)||(u0=i,i=Rw(nE,"onSelect"),0dp||(n.current=cE[dp],cE[dp]=null,dp--)}function oi(n,e){dp++,cE[dp]=n.current,n.current=e}var su={},es=mu(su),Is=mu(!1),qh=su;function Hp(n,e){var t=n.type.contextTypes;if(!t)return su;var i=n.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in t)r[s]=e[s];return i&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=r),r}function Ds(n){return n=n.childContextTypes,n!=null}function Lw(){ui(Is),ui(es)}function HR(n,e,t){if(es.current!==su)throw Error(Qe(168));oi(es,e),oi(Is,t)}function gN(n,e,t){var i=n.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return t;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(Qe(108,_6(n)||"Unknown",r));return Ei({},t,i)}function Iw(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||su,qh=es.current,oi(es,n),oi(Is,Is.current),!0}function GR(n,e,t){var i=n.stateNode;if(!i)throw Error(Qe(169));t?(n=gN(n,e,qh),i.__reactInternalMemoizedMergedChildContext=n,ui(Is),ui(es),oi(es,n)):ui(Is),oi(Is,t)}var kl=null,IS=!1,YM=!1;function yN(n){kl===null?kl=[n]:kl.push(n)}function zH(n){IS=!0,yN(n)}function gu(){if(!YM&&kl!==null){YM=!0;var n=0,e=Yn;try{var t=kl;for(Yn=1;n>=o,r-=o,Dl=1<<32-wa(e)+r|t<H?(I=F,F=null):I=F.sibling;var R=g(x,F,A[H],C);if(R===null){F===null&&(F=I);break}n&&F&&R.alternate===null&&e(x,F),M=s(R,M,H),L===null?N=R:L.sibling=R,L=R,F=I}if(H===A.length)return t(x,F),yi&&yh(x,H),N;if(F===null){for(;HH?(I=F,F=null):I=F.sibling;var W=g(x,F,R.value,C);if(W===null){F===null&&(F=I);break}n&&F&&W.alternate===null&&e(x,F),M=s(W,M,H),L===null?N=W:L.sibling=W,L=W,F=I}if(R.done)return t(x,F),yi&&yh(x,H),N;if(F===null){for(;!R.done;H++,R=A.next())R=f(x,R.value,C),R!==null&&(M=s(R,M,H),L===null?N=R:L.sibling=R,L=R);return yi&&yh(x,H),N}for(F=i(x,F);!R.done;H++,R=A.next())R=y(F,x,H,R.value,C),R!==null&&(n&&R.alternate!==null&&F.delete(R.key===null?H:R.key),M=s(R,M,H),L===null?N=R:L.sibling=R,L=R);return n&&F.forEach(function(se){return e(x,se)}),yi&&yh(x,H),N}function S(x,M,A,C){if(typeof A=="object"&&A!==null&&A.type===lp&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case mx:e:{for(var N=A.key,L=M;L!==null;){if(L.key===N){if(N=A.type,N===lp){if(L.tag===7){t(x,L.sibling),M=r(L,A.props.children),M.return=x,x=M;break e}}else if(L.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Lc&&ZR(N)===L.type){t(x,L.sibling),M=r(L,A.props),M.ref=Mg(x,L,A),M.return=x,x=M;break e}t(x,L);break}else e(x,L);L=L.sibling}A.type===lp?(M=Bh(A.props.children,x.mode,C,A.key),M.return=x,x=M):(C=tw(A.type,A.key,A.props,null,x.mode,C),C.ref=Mg(x,M,A),C.return=x,x=C)}return o(x);case ap:e:{for(L=A.key;M!==null;){if(M.key===L)if(M.tag===4&&M.stateNode.containerInfo===A.containerInfo&&M.stateNode.implementation===A.implementation){t(x,M.sibling),M=r(M,A.children||[]),M.return=x,x=M;break e}else{t(x,M);break}else e(x,M);M=M.sibling}M=nA(A,x.mode,C),M.return=x,x=M}return o(x);case Lc:return L=A._init,S(x,M,L(A._payload),C)}if(Zg(A))return v(x,M,A,C);if(vg(A))return w(x,M,A,C);Ex(x,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,M!==null&&M.tag===6?(t(x,M.sibling),M=r(M,A),M.return=x,x=M):(t(x,M),M=tA(A,x.mode,C),M.return=x,x=M),o(x)):t(x,M)}return S}var Wp=bN(!0),EN=bN(!1),Sy={},Ka=mu(Sy),F0=mu(Sy),U0=mu(Sy);function Rh(n){if(n===Sy)throw Error(Qe(174));return n}function D2(n,e){switch(oi(U0,e),oi(F0,n),oi(Ka,Sy),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Xb(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=Xb(e,n)}ui(Ka),oi(Ka,e)}function jp(){ui(Ka),ui(F0),ui(U0)}function TN(n){Rh(U0.current);var e=Rh(Ka.current),t=Xb(e,n.type);e!==t&&(oi(F0,n),oi(Ka,t))}function O2(n){F0.current===n&&(ui(Ka),ui(F0))}var _i=mu(0);function zw(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var KM=[];function N2(){for(var n=0;nt?t:4,n(!0);var i=ZM.transition;ZM.transition={};try{n(!1),e()}finally{Yn=t,ZM.transition=i}}function GN(){return Yo().memoizedState}function GH(n,e,t){var i=Qc(n);if(t={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null},WN(n))jN(e,t);else if(t=SN(n,e,t,i),t!==null){var r=xs();Sa(t,n,i,r),XN(t,e,i)}}function WH(n,e,t){var i=Qc(n),r={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null};if(WN(n))jN(e,r);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,t);if(r.hasEagerState=!0,r.eagerState=a,_a(a,o)){var l=e.interleaved;l===null?(r.next=r,L2(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}t=SN(n,e,r,i),t!==null&&(r=xs(),Sa(t,n,i,r),XN(t,e,i))}}function WN(n){var e=n.alternate;return n===bi||e!==null&&e===bi}function jN(n,e){h0=Bw=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function XN(n,e,t){if(t&4194240){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,v2(n,t)}}var Vw={readContext:qo,useCallback:Wr,useContext:Wr,useEffect:Wr,useImperativeHandle:Wr,useInsertionEffect:Wr,useLayoutEffect:Wr,useMemo:Wr,useReducer:Wr,useRef:Wr,useState:Wr,useDebugValue:Wr,useDeferredValue:Wr,useTransition:Wr,useMutableSource:Wr,useSyncExternalStore:Wr,useId:Wr,unstable_isNewReconciler:!1},jH={readContext:qo,useCallback:function(n,e){return Ba().memoizedState=[n,e===void 0?null:e],n},useContext:qo,useEffect:QR,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,J1(4194308,4,UN.bind(null,e,n),t)},useLayoutEffect:function(n,e){return J1(4194308,4,n,e)},useInsertionEffect:function(n,e){return J1(4,2,n,e)},useMemo:function(n,e){var t=Ba();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var i=Ba();return e=t!==void 0?t(e):e,i.memoizedState=i.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},i.queue=n,n=n.dispatch=GH.bind(null,bi,n),[i.memoizedState,n]},useRef:function(n){var e=Ba();return n={current:n},e.memoizedState=n},useState:JR,useDebugValue:V2,useDeferredValue:function(n){return Ba().memoizedState=n},useTransition:function(){var n=JR(!1),e=n[0];return n=HH.bind(null,n[1]),Ba().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var i=bi,r=Ba();if(yi){if(t===void 0)throw Error(Qe(407));t=t()}else{if(t=e(),Cr===null)throw Error(Qe(349));Kh&30||RN(i,e,t)}r.memoizedState=t;var s={value:t,getSnapshot:e};return r.queue=s,QR(LN.bind(null,i,s,n),[n]),i.flags|=2048,V0(9,kN.bind(null,i,s,t,e),void 0,null),t},useId:function(){var n=Ba(),e=Cr.identifierPrefix;if(yi){var t=Ol,i=Dl;t=(i&~(1<<32-wa(i)-1)).toString(32)+t,e=":"+e+"R"+t,t=z0++,0<\/script>",n=n.removeChild(n.firstChild)):typeof i.is=="string"?n=o.createElement(t,{is:i.is}):(n=o.createElement(t),t==="select"&&(o=n,i.multiple?o.multiple=!0:i.size&&(o.size=i.size))):n=o.createElementNS(n,t),n[Wa]=e,n[N0]=i,tF(n,e,!1,!1),e.stateNode=n;e:{switch(o=Yb(t,i),t){case"dialog":li("cancel",n),li("close",n),r=i;break;case"iframe":case"object":case"embed":li("load",n),r=i;break;case"video":case"audio":for(r=0;rqp&&(e.flags|=128,i=!0,Ag(s,!1),e.lanes=4194304)}else{if(!i)if(n=zw(o),n!==null){if(e.flags|=128,i=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ag(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!yi)return jr(e),null}else 2*Gi()-s.renderingStartTime>qp&&t!==1073741824&&(e.flags|=128,i=!0,Ag(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(t=s.last,t!==null?t.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Gi(),e.sibling=null,t=_i.current,oi(_i,i?t&1|2:t&1),e):(jr(e),null);case 22:case 23:return q2(),i=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?$s&1073741824&&(jr(e),e.subtreeFlags&6&&(e.flags|=8192)):jr(e),null;case 24:return null;case 25:return null}throw Error(Qe(156,e.tag))}function $H(n,e){switch(T2(e),e.tag){case 1:return Ds(e.type)&&Lw(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return jp(),ui(Is),ui(es),N2(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return O2(e),null;case 13:if(ui(_i),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(Qe(340));Gp()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return ui(_i),null;case 4:return jp(),null;case 10:return k2(e.type._context),null;case 22:case 23:return q2(),null;case 24:return null;default:return null}}var Cx=!1,Jr=!1,eG=typeof WeakSet=="function"?WeakSet:Set,bt=null;function yp(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){Di(n,e,i)}else t.current=null}function SE(n,e,t){try{t()}catch(i){Di(n,e,i)}}var ak=!1;function tG(n,e){if(rE=Cw,n=aN(),b2(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var i=t.getSelection&&t.getSelection();if(i&&i.rangeCount!==0){t=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,l=-1,c=0,u=0,f=n,g=null;t:for(;;){for(var y;f!==t||r!==0&&f.nodeType!==3||(a=o+r),f!==s||i!==0&&f.nodeType!==3||(l=o+i),f.nodeType===3&&(o+=f.nodeValue.length),(y=f.firstChild)!==null;)g=f,f=y;for(;;){if(f===n)break t;if(g===t&&++c===r&&(a=o),g===s&&++u===i&&(l=o),(y=f.nextSibling)!==null)break;f=g,g=f.parentNode}f=y}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(sE={focusedElem:n,selectionRange:t},Cw=!1,bt=e;bt!==null;)if(e=bt,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,bt=n;else for(;bt!==null;){e=bt;try{var v=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var w=v.memoizedProps,S=v.memoizedState,x=e.stateNode,M=x.getSnapshotBeforeUpdate(e.elementType===e.type?w:ha(e.type,w),S);x.__reactInternalSnapshotBeforeUpdate=M}break;case 3:var A=e.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Qe(163))}}catch(C){Di(e,e.return,C)}if(n=e.sibling,n!==null){n.return=e.return,bt=n;break}bt=e.return}return v=ak,ak=!1,v}function f0(n,e,t){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&n)===n){var s=r.destroy;r.destroy=void 0,s!==void 0&&SE(e,t,s)}r=r.next}while(r!==i)}}function NS(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var i=t.create;t.destroy=i()}t=t.next}while(t!==e)}}function _E(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function rF(n){var e=n.alternate;e!==null&&(n.alternate=null,rF(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Wa],delete e[N0],delete e[lE],delete e[FH],delete e[UH])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function sF(n){return n.tag===5||n.tag===3||n.tag===4}function lk(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||sF(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function ME(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=kw));else if(i!==4&&(n=n.child,n!==null))for(ME(n,e,t),n=n.sibling;n!==null;)ME(n,e,t),n=n.sibling}function AE(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(i!==4&&(n=n.child,n!==null))for(AE(n,e,t),n=n.sibling;n!==null;)AE(n,e,t),n=n.sibling}var Dr=null,da=!1;function wc(n,e,t){for(t=t.child;t!==null;)oF(n,e,t),t=t.sibling}function oF(n,e,t){if(Ya&&typeof Ya.onCommitFiberUnmount=="function")try{Ya.onCommitFiberUnmount(CS,t)}catch{}switch(t.tag){case 5:Jr||yp(t,e);case 6:var i=Dr,r=da;Dr=null,wc(n,e,t),Dr=i,da=r,Dr!==null&&(da?(n=Dr,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):Dr.removeChild(t.stateNode));break;case 18:Dr!==null&&(da?(n=Dr,t=t.stateNode,n.nodeType===8?qM(n.parentNode,t):n.nodeType===1&&qM(n,t),k0(n)):qM(Dr,t.stateNode));break;case 4:i=Dr,r=da,Dr=t.stateNode.containerInfo,da=!0,wc(n,e,t),Dr=i,da=r;break;case 0:case 11:case 14:case 15:if(!Jr&&(i=t.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&SE(t,e,o),r=r.next}while(r!==i)}wc(n,e,t);break;case 1:if(!Jr&&(yp(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=t.memoizedProps,i.state=t.memoizedState,i.componentWillUnmount()}catch(a){Di(t,e,a)}wc(n,e,t);break;case 21:wc(n,e,t);break;case 22:t.mode&1?(Jr=(i=Jr)||t.memoizedState!==null,wc(n,e,t),Jr=i):wc(n,e,t);break;default:wc(n,e,t)}}function ck(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new eG),e.forEach(function(i){var r=uG.bind(null,n,i);t.has(i)||(t.add(i),i.then(r,r))})}}function oa(n,e){var t=e.deletions;if(t!==null)for(var i=0;ir&&(r=o),i&=~s}if(i=r,i=Gi()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*iG(i/1960))-i,10n?16:n,Wc===null)var i=!1;else{if(n=Wc,Wc=null,Ww=0,Nn&6)throw Error(Qe(331));var r=Nn;for(Nn|=4,bt=n.current;bt!==null;){var s=bt,o=s.child;if(bt.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lGi()-j2?zh(n,0):W2|=t),Os(n,e)}function pF(n,e){e===0&&(n.mode&1?(e=xx,xx<<=1,!(xx&130023424)&&(xx=4194304)):e=1);var t=xs();n=Gl(n,e),n!==null&&(vy(n,e,t),Os(n,t))}function cG(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),pF(n,t)}function uG(n,e){var t=0;switch(n.tag){case 13:var i=n.stateNode,r=n.memoizedState;r!==null&&(t=r.retryLane);break;case 19:i=n.stateNode;break;default:throw Error(Qe(314))}i!==null&&i.delete(e),pF(n,t)}var mF;mF=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Is.current)ks=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return ks=!1,JH(n,e,t);ks=!!(n.flags&131072)}else ks=!1,yi&&e.flags&1048576&&vN(e,Ow,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Q1(n,e),n=e.pendingProps;var r=Hp(e,es.current);kp(e,t),r=U2(null,e,i,n,r,t);var s=z2();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ds(i)?(s=!0,Iw(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,I2(e),r.updater=DS,e.stateNode=r,r._reactInternals=e,pE(e,i,n,t),e=yE(null,e,i,!0,s,t)):(e.tag=0,yi&&s&&E2(e),ps(null,e,r,t),e=e.child),e;case 16:i=e.elementType;e:{switch(Q1(n,e),n=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=fG(i),n=ha(i,n),r){case 0:e=gE(null,e,i,n,t);break e;case 1:e=rk(null,e,i,n,t);break e;case 11:e=nk(null,e,i,n,t);break e;case 14:e=ik(null,e,i,ha(i.type,n),t);break e}throw Error(Qe(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:ha(i,r),gE(n,e,i,r,t);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:ha(i,r),rk(n,e,i,r,t);case 3:e:{if(QN(e),n===null)throw Error(Qe(387));i=e.pendingProps,s=e.memoizedState,r=s.element,_N(n,e),Uw(e,i,null,t);var o=e.memoizedState;if(i=o.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=Xp(Error(Qe(423)),e),e=sk(n,e,i,t,r);break e}else if(i!==r){r=Xp(Error(Qe(424)),e),e=sk(n,e,i,t,r);break e}else for(no=Kc(e.stateNode.containerInfo.firstChild),so=e,yi=!0,ma=null,t=EN(e,null,i,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(Gp(),i===r){e=Wl(n,e,t);break e}ps(n,e,i,t)}e=e.child}return e;case 5:return TN(e),n===null&&hE(e),i=e.type,r=e.pendingProps,s=n!==null?n.memoizedProps:null,o=r.children,oE(i,r)?o=null:s!==null&&oE(i,s)&&(e.flags|=32),JN(n,e),ps(n,e,o,t),e.child;case 6:return n===null&&hE(e),null;case 13:return $N(n,e,t);case 4:return D2(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Wp(e,null,i,t):ps(n,e,i,t),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:ha(i,r),nk(n,e,i,r,t);case 7:return ps(n,e,e.pendingProps,t),e.child;case 8:return ps(n,e,e.pendingProps.children,t),e.child;case 12:return ps(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,o=r.value,oi(Nw,i._currentValue),i._currentValue=o,s!==null)if(_a(s.value,o)){if(s.children===r.children&&!Is.current){e=Wl(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===i){if(s.tag===1){l=Ul(-1,t&-t),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),fE(s.return,t,e),a.lanes|=t;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(Qe(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),fE(o,t,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ps(n,e,r.children,t),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,kp(e,t),r=qo(r),i=i(r),e.flags|=1,ps(n,e,i,t),e.child;case 14:return i=e.type,r=ha(i,e.pendingProps),r=ha(i.type,r),ik(n,e,i,r,t);case 15:return KN(n,e,e.type,e.pendingProps,t);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:ha(i,r),Q1(n,e),e.tag=1,Ds(i)?(n=!0,Iw(e)):n=!1,kp(e,t),AN(e,i,r),pE(e,i,r,t),yE(null,e,i,!0,n,t);case 19:return eF(n,e,t);case 22:return ZN(n,e,t)}throw Error(Qe(156,e.tag))};function gF(n,e){return HO(n,e)}function hG(n,e,t,i){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Go(n,e,t,i){return new hG(n,e,t,i)}function K2(n){return n=n.prototype,!(!n||!n.isReactComponent)}function fG(n){if(typeof n=="function")return K2(n)?1:0;if(n!=null){if(n=n.$$typeof,n===p2)return 11;if(n===m2)return 14}return 2}function $c(n,e){var t=n.alternate;return t===null?(t=Go(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function tw(n,e,t,i,r,s){var o=2;if(i=n,typeof n=="function")K2(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case lp:return Bh(t.children,r,s,e);case d2:o=8,r|=8;break;case Ub:return n=Go(12,t,e,r|2),n.elementType=Ub,n.lanes=s,n;case zb:return n=Go(13,t,e,r),n.elementType=zb,n.lanes=s,n;case Bb:return n=Go(19,t,e,r),n.elementType=Bb,n.lanes=s,n;case bO:return US(t,r,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case MO:o=10;break e;case AO:o=9;break e;case p2:o=11;break e;case m2:o=14;break e;case Lc:o=16,i=null;break e}throw Error(Qe(130,n==null?n:typeof n,""))}return e=Go(o,t,e,r),e.elementType=n,e.type=i,e.lanes=s,e}function Bh(n,e,t,i){return n=Go(7,n,i,e),n.lanes=t,n}function US(n,e,t,i){return n=Go(22,n,i,e),n.elementType=bO,n.lanes=t,n.stateNode={isHidden:!1},n}function tA(n,e,t){return n=Go(6,n,null,e),n.lanes=t,n}function nA(n,e,t){return e=Go(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function dG(n,e,t,i,r){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=NM(0),this.expirationTimes=NM(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=NM(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Z2(n,e,t,i,r,s,o,a,l){return n=new dG(n,e,t,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Go(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:i,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},I2(s),n}function pG(n,e,t){var i=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(wF)}catch(n){console.error(n)}}wF(),vO.exports=mo;var xG=vO.exports,yk=xG;Nb.createRoot=yk.createRoot,Nb.hydrateRoot=yk.hydrateRoot;function wG(n,e){let t=0;return function(...i){const r=performance.now();r-tn.addEventListener(i,t))}function sA(n,e,t){e.forEach(i=>n.removeEventListener(i,t))}function Mk(n){if(n.touches&&n.touches[0]){const e=(n.target.offsetHeight-document.body.offsetHeight)/2;return[n.touches[0].clientX,n.touches[0].clientY-e]}else return[n.offsetX,n.offsetY]}function SF({onSketchChange:n,disabled:e},t){const i=le.useRef(null),r=le.useRef(null),[s,o]=le.useState(null),[a,l]=le.useState(!1),[c,u]=le.useState(0);le.useEffect(function(){const y=i.current;r.current||(r.current=y.getContext("2d",{willReadFrequently:!0}));const v=r.current;v.imageSmoothingEnabled=!0,v.lineWidth=Wn.BRUSH_SIZE,v.lineJoin="round",v.lineCap="round",v.strokeStyle="#36454F",v.shadowColor="rgba(0, 0, 0, 0.9)",v.shadowBlur=1;const w=(y.width-window.innerWidth)/2,S=(y.height-window.innerHeight)/2,x=Wn.BRUSH_SIZE/2;function M(){y.style.width=window.innerWidth,y.style.height=window.innerHeight}function A(L){if(e)return;const[F,H]=Mk(L),I=F+w,R=H+S;v.moveTo(I,R),v.beginPath(),v.lineTo(I,R),v.arc(I,R,.5,0,2*Math.PI),v.stroke(),l(!0),o(function(W){return W===null?[I,R,I,R]:[Math.min(W[0],I-x),Math.min(W[1],R-x),Math.max(W[2],I+x),Math.max(W[3],R+x)]}),n()}const C=wG(function(L){if(!a||e)return;u(function(W){return W+Sk});const[F,H]=Mk(L),I=F+w,R=H+S;o(function(W){return W===null?W:[Math.min(W[0],I-x),Math.min(W[1],R-x),Math.max(W[2],I+x),Math.max(W[3],R+x)]}),v.lineTo(I,R),v.stroke(),n()},Sk);function N(){l(!1)}return M(),window.addEventListener("resize",M),rA(y,vk,A),rA(y,xk,C),rA(y,wk,N),function(){window.removeEventListener("resize",M),sA(y,vk,A),sA(y,xk,C),sA(y,wk,N)}},[a,n,e]);function f(){if(s===null)return null;const y=r.current;let v=s[0],w=s[1],S=s[2]-s[0],x=s[3]-s[1],M=2*iA;return S>=x?(M+=S,w=Math.max(w-(S-x)/2,0)):(M+=x,v=Math.max(v-(x-S)/2,0)),y.getImageData(v-iA,w-iA,M,M)}function g(y=!1){o(null);const v=i.current;r.current.clearRect(0,0,v.width,v.height),l(!1),y&&u(0)}return Ke.useImperativeHandle(t,function(){return{getCanvasData:f,clearCanvas:g,getTimeSpentDrawing:function(){return c}}}),Ke.createElement("canvas",{className:"object-none w-full h-full",ref:i,width:_k,height:_k})}SF.displayName="SketchCanvas";const _G=Ke.forwardRef(SF),_F=le.createContext({transformPagePoint:n=>n,isStatic:!1,reducedMotion:"never"}),GS=le.createContext({}),WS=le.createContext(null),jS=typeof document<"u",qw=jS?le.useLayoutEffect:le.useEffect,MF=le.createContext({strict:!1});function MG(n,e,t,i){const{visualElement:r}=le.useContext(GS),s=le.useContext(MF),o=le.useContext(WS),a=le.useContext(_F).reducedMotion,l=le.useRef();i=i||s.renderer,!l.current&&i&&(l.current=i(n,{visualState:e,parent:r,props:t,presenceContext:o,blockInitialAnimation:o?o.initial===!1:!1,reducedMotionConfig:a}));const c=l.current;return le.useInsertionEffect(()=>{c&&c.update(t,o)}),qw(()=>{c&&c.render()}),le.useEffect(()=>{c&&c.updateFeatures()}),(window.HandoffAppearAnimations?qw:le.useEffect)(()=>{c&&c.animationState&&c.animationState.animateChanges()}),c}function xp(n){return typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"current")}function AG(n,e,t){return le.useCallback(i=>{i&&n.mount&&n.mount(i),e&&(i?e.mount(i):e.unmount()),t&&(typeof t=="function"?t(i):xp(t)&&(t.current=i))},[e])}function G0(n){return typeof n=="string"||Array.isArray(n)}function XS(n){return typeof n=="object"&&typeof n.start=="function"}const tC=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],nC=["initial",...tC];function qS(n){return XS(n.animate)||nC.some(e=>G0(n[e]))}function AF(n){return!!(qS(n)||n.variants)}function bG(n,e){if(qS(n)){const{initial:t,animate:i}=n;return{initial:t===!1||G0(t)?t:void 0,animate:G0(i)?i:void 0}}return n.inherit!==!1?e:{}}function EG(n){const{initial:e,animate:t}=bG(n,le.useContext(GS));return le.useMemo(()=>({initial:e,animate:t}),[Ak(e),Ak(t)])}function Ak(n){return Array.isArray(n)?n.join(" "):n}const bk={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"]},W0={};for(const n in bk)W0[n]={isEnabled:e=>bk[n].some(t=>!!e[t])};function TG(n){for(const e in n)W0[e]={...W0[e],...n[e]}}const iC=le.createContext({}),bF=le.createContext({}),CG=Symbol.for("motionComponentSymbol");function PG({preloadedFeatures:n,createVisualElement:e,useRender:t,useVisualState:i,Component:r}){n&&TG(n);function s(a,l){let c;const u={...le.useContext(_F),...a,layoutId:RG(a)},{isStatic:f}=u,g=EG(a),y=i(a,f);if(!f&&jS){g.visualElement=MG(r,y,u,e);const v=le.useContext(bF),w=le.useContext(MF).strict;g.visualElement&&(c=g.visualElement.loadFeatures(u,w,n,v))}return le.createElement(GS.Provider,{value:g},c&&g.visualElement?le.createElement(c,{visualElement:g.visualElement,...u}):null,t(r,a,AG(y,g.visualElement,l),y,f,g.visualElement))}const o=le.forwardRef(s);return o[CG]=r,o}function RG({layoutId:n}){const e=le.useContext(iC).id;return e&&n!==void 0?e+"-"+n:n}function kG(n){function e(i,r={}){return PG(n(i,r))}if(typeof Proxy>"u")return e;const t=new Map;return new Proxy(e,{get:(i,r)=>(t.has(r)||t.set(r,e(r)),t.get(r))})}const LG=["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 rC(n){return typeof n!="string"||n.includes("-")?!1:!!(LG.indexOf(n)>-1||/[A-Z]/.test(n))}const Yw={};function IG(n){Object.assign(Yw,n)}const _y=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],cf=new Set(_y);function EF(n,{layout:e,layoutId:t}){return cf.has(n)||n.startsWith("origin")||(e||t!==void 0)&&(!!Yw[n]||n==="opacity")}const Ns=n=>!!(n&&n.getVelocity),DG={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},OG=_y.length;function NG(n,{enableHardwareAcceleration:e=!0,allowTransformNone:t=!0},i,r){let s="";for(let o=0;oe=>typeof e=="string"&&e.startsWith(n),CF=TF("--"),PE=TF("var(--"),FG=/var\s*\(\s*--[\w-]+(\s*,\s*(?:(?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)+)?\s*\)/g,UG=(n,e)=>e&&typeof n=="number"?e.transform(n):n,ou=(n,e,t)=>Math.min(Math.max(t,n),e),uf={test:n=>typeof n=="number",parse:parseFloat,transform:n=>n},m0={...uf,transform:n=>ou(0,1,n)},kx={...uf,default:1},g0=n=>Math.round(n*1e5)/1e5,YS=/(-)?([\d]*\.?[\d])+/g,PF=/(#[0-9a-f]{3,8}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi,zG=/^(#[0-9a-f]{3,8}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function My(n){return typeof n=="string"}const Ay=n=>({test:e=>My(e)&&e.endsWith(n)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${n}`}),Rc=Ay("deg"),Za=Ay("%"),$t=Ay("px"),BG=Ay("vh"),VG=Ay("vw"),Ek={...Za,parse:n=>Za.parse(n)/100,transform:n=>Za.transform(n*100)},Tk={...uf,transform:Math.round},RF={borderWidth:$t,borderTopWidth:$t,borderRightWidth:$t,borderBottomWidth:$t,borderLeftWidth:$t,borderRadius:$t,radius:$t,borderTopLeftRadius:$t,borderTopRightRadius:$t,borderBottomRightRadius:$t,borderBottomLeftRadius:$t,width:$t,maxWidth:$t,height:$t,maxHeight:$t,size:$t,top:$t,right:$t,bottom:$t,left:$t,padding:$t,paddingTop:$t,paddingRight:$t,paddingBottom:$t,paddingLeft:$t,margin:$t,marginTop:$t,marginRight:$t,marginBottom:$t,marginLeft:$t,rotate:Rc,rotateX:Rc,rotateY:Rc,rotateZ:Rc,scale:kx,scaleX:kx,scaleY:kx,scaleZ:kx,skew:Rc,skewX:Rc,skewY:Rc,distance:$t,translateX:$t,translateY:$t,translateZ:$t,x:$t,y:$t,z:$t,perspective:$t,transformPerspective:$t,opacity:m0,originX:Ek,originY:Ek,originZ:$t,zIndex:Tk,fillOpacity:m0,strokeOpacity:m0,numOctaves:Tk};function sC(n,e,t,i){const{style:r,vars:s,transform:o,transformOrigin:a}=n;let l=!1,c=!1,u=!0;for(const f in e){const g=e[f];if(CF(f)){s[f]=g;continue}const y=RF[f],v=UG(g,y);if(cf.has(f)){if(l=!0,o[f]=v,!u)continue;g!==(y.default||0)&&(u=!1)}else f.startsWith("origin")?(c=!0,a[f]=v):r[f]=v}if(e.transform||(l||i?r.transform=NG(n.transform,t,u,i):r.transform&&(r.transform="none")),c){const{originX:f="50%",originY:g="50%",originZ:y=0}=a;r.transformOrigin=`${f} ${g} ${y}`}}const oC=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function kF(n,e,t){for(const i in e)!Ns(e[i])&&!EF(i,t)&&(n[i]=e[i])}function HG({transformTemplate:n},e,t){return le.useMemo(()=>{const i=oC();return sC(i,e,{enableHardwareAcceleration:!t},n),Object.assign({},i.vars,i.style)},[e])}function GG(n,e,t){const i=n.style||{},r={};return kF(r,i,n),Object.assign(r,HG(n,e,t)),n.transformValues?n.transformValues(r):r}function WG(n,e,t){const i={},r=GG(n,e,t);return n.drag&&n.dragListener!==!1&&(i.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=n.drag===!0?"none":`pan-${n.drag==="x"?"y":"x"}`),n.tabIndex===void 0&&(n.onTap||n.onTapStart||n.whileTap)&&(i.tabIndex=0),i.style=r,i}const jG=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","transformValues","custom","inherit","onLayoutAnimationStart","onLayoutAnimationComplete","onLayoutMeasure","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","ignoreStrict","viewport"]);function Kw(n){return n.startsWith("while")||n.startsWith("drag")&&n!=="draggable"||n.startsWith("layout")||n.startsWith("onTap")||n.startsWith("onPan")||jG.has(n)}let LF=n=>!Kw(n);function XG(n){n&&(LF=e=>e.startsWith("on")?!Kw(e):n(e))}try{XG(require("@emotion/is-prop-valid").default)}catch{}function qG(n,e,t){const i={};for(const r in n)r==="values"&&typeof n.values=="object"||(LF(r)||t===!0&&Kw(r)||!e&&!Kw(r)||n.draggable&&r.startsWith("onDrag"))&&(i[r]=n[r]);return i}function Ck(n,e,t){return typeof n=="string"?n:$t.transform(e+t*n)}function YG(n,e,t){const i=Ck(e,n.x,n.width),r=Ck(t,n.y,n.height);return`${i} ${r}`}const KG={offset:"stroke-dashoffset",array:"stroke-dasharray"},ZG={offset:"strokeDashoffset",array:"strokeDasharray"};function JG(n,e,t=1,i=0,r=!0){n.pathLength=1;const s=r?KG:ZG;n[s.offset]=$t.transform(-i);const o=$t.transform(e),a=$t.transform(t);n[s.array]=`${o} ${a}`}function aC(n,{attrX:e,attrY:t,attrScale:i,originX:r,originY:s,pathLength:o,pathSpacing:a=1,pathOffset:l=0,...c},u,f,g){if(sC(n,c,u,g),f){n.style.viewBox&&(n.attrs.viewBox=n.style.viewBox);return}n.attrs=n.style,n.style={};const{attrs:y,style:v,dimensions:w}=n;y.transform&&(w&&(v.transform=y.transform),delete y.transform),w&&(r!==void 0||s!==void 0||v.transform)&&(v.transformOrigin=YG(w,r!==void 0?r:.5,s!==void 0?s:.5)),e!==void 0&&(y.x=e),t!==void 0&&(y.y=t),i!==void 0&&(y.scale=i),o!==void 0&&JG(y,o,a,l,!1)}const IF=()=>({...oC(),attrs:{}}),lC=n=>typeof n=="string"&&n.toLowerCase()==="svg";function QG(n,e,t,i){const r=le.useMemo(()=>{const s=IF();return aC(s,e,{enableHardwareAcceleration:!1},lC(i),n.transformTemplate),{...s.attrs,style:{...s.style}}},[e]);if(n.style){const s={};kF(s,n.style,n),r.style={...s,...r.style}}return r}function $G(n=!1){return(t,i,r,{latestValues:s},o)=>{const l=(rC(t)?QG:WG)(i,s,o,t),u={...qG(i,typeof t=="string",n),...l,ref:r},{children:f}=i,g=le.useMemo(()=>Ns(f)?f.get():f,[f]);return le.createElement(t,{...u,children:g})}}const cC=n=>n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();function DF(n,{style:e,vars:t},i,r){Object.assign(n.style,e,r&&r.getProjectionStyles(i));for(const s in t)n.style.setProperty(s,t[s])}const OF=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 NF(n,e,t,i){DF(n,e,void 0,i);for(const r in e.attrs)n.setAttribute(OF.has(r)?r:cC(r),e.attrs[r])}function uC(n,e){const{style:t}=n,i={};for(const r in t)(Ns(t[r])||e.style&&Ns(e.style[r])||EF(r,n))&&(i[r]=t[r]);return i}function FF(n,e){const t=uC(n,e);for(const i in n)if(Ns(n[i])||Ns(e[i])){const r=_y.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;t[r]=n[i]}return t}function hC(n,e,t,i={},r={}){return typeof e=="function"&&(e=e(t!==void 0?t:n.custom,i,r)),typeof e=="string"&&(e=n.variants&&n.variants[e]),typeof e=="function"&&(e=e(t!==void 0?t:n.custom,i,r)),e}function UF(n){const e=le.useRef(null);return e.current===null&&(e.current=n()),e.current}const Zw=n=>Array.isArray(n),e8=n=>!!(n&&typeof n=="object"&&n.mix&&n.toValue),t8=n=>Zw(n)?n[n.length-1]||0:n;function nw(n){const e=Ns(n)?n.get():n;return e8(e)?e.toValue():e}function n8({scrapeMotionValuesFromProps:n,createRenderState:e,onMount:t},i,r,s){const o={latestValues:i8(i,r,s,n),renderState:e()};return t&&(o.mount=a=>t(i,a,o)),o}const zF=n=>(e,t)=>{const i=le.useContext(GS),r=le.useContext(WS),s=()=>n8(n,e,i,r);return t?s():UF(s)};function i8(n,e,t,i){const r={},s=i(n,{});for(const g in s)r[g]=nw(s[g]);let{initial:o,animate:a}=n;const l=qS(n),c=AF(n);e&&c&&!l&&n.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let u=t?t.initial===!1:!1;u=u||o===!1;const f=u?a:o;return f&&typeof f!="boolean"&&!XS(f)&&(Array.isArray(f)?f:[f]).forEach(y=>{const v=hC(n,y);if(!v)return;const{transitionEnd:w,transition:S,...x}=v;for(const M in x){let A=x[M];if(Array.isArray(A)){const C=u?A.length-1:0;A=A[C]}A!==null&&(r[M]=A)}for(const M in w)r[M]=w[M]}),r}const r8={useVisualState:zF({scrapeMotionValuesFromProps:FF,createRenderState:IF,onMount:(n,e,{renderState:t,latestValues:i})=>{try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}aC(t,i,{enableHardwareAcceleration:!1},lC(e.tagName),n.transformTemplate),NF(e,t)}})},s8={useVisualState:zF({scrapeMotionValuesFromProps:uC,createRenderState:oC})};function o8(n,{forwardMotionProps:e=!1},t,i){return{...rC(n)?r8:s8,preloadedFeatures:t,useRender:$G(e),createVisualElement:i,Component:n}}function Nl(n,e,t,i={passive:!0}){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t)}const BF=n=>n.pointerType==="mouse"?typeof n.button!="number"||n.button<=0:n.isPrimary!==!1;function KS(n,e="page"){return{point:{x:n[e+"X"],y:n[e+"Y"]}}}const a8=n=>e=>BF(e)&&n(e,KS(e));function zl(n,e,t,i){return Nl(n,e,a8(t),i)}const l8=(n,e)=>t=>e(n(t)),eu=(...n)=>n.reduce(l8);function VF(n){let e=null;return()=>{const t=()=>{e=null};return e===null?(e=n,t):!1}}const Pk=VF("dragHorizontal"),Rk=VF("dragVertical");function HF(n){let e=!1;if(n==="y")e=Rk();else if(n==="x")e=Pk();else{const t=Pk(),i=Rk();t&&i?e=()=>{t(),i()}:(t&&t(),i&&i())}return e}function GF(){const n=HF(!0);return n?(n(),!1):!0}class yu{constructor(e){this.isMounted=!1,this.node=e}update(){}}function c8(n){let e=[],t=[],i=0,r=!1,s=!1;const o=new WeakSet,a={schedule:(l,c=!1,u=!1)=>{const f=u&&r,g=f?e:t;return c&&o.add(l),g.indexOf(l)===-1&&(g.push(l),f&&r&&(i=e.length)),l},cancel:l=>{const c=t.indexOf(l);c!==-1&&t.splice(c,1),o.delete(l)},process:l=>{if(r){s=!0;return}if(r=!0,[e,t]=[t,e],t.length=0,i=e.length,i)for(let c=0;c(n[e]=c8(()=>j0=!0),n),{}),h8=n=>Ip[n].process(Si),WF=n=>{j0=!1,Si.delta=RE?1e3/60:Math.max(Math.min(n-Si.timestamp,u8),1),Si.timestamp=n,Si.isProcessing=!0,ZS.forEach(h8),Si.isProcessing=!1,j0&&(RE=!1,requestAnimationFrame(WF))},f8=()=>{j0=!0,RE=!0,Si.isProcessing||requestAnimationFrame(WF)},vi=ZS.reduce((n,e)=>{const t=Ip[e];return n[e]=(i,r=!1,s=!1)=>(j0||f8(),t.schedule(i,r,s)),n},{});function jl(n){ZS.forEach(e=>Ip[e].cancel(n))}function kk(n,e){const t="pointer"+(e?"enter":"leave"),i="onHover"+(e?"Start":"End"),r=(s,o)=>{if(s.type==="touch"||GF())return;const a=n.getProps();n.animationState&&a.whileHover&&n.animationState.setActive("whileHover",e),a[i]&&vi.update(()=>a[i](s,o))};return zl(n.current,t,r,{passive:!n.getProps()[i]})}class d8 extends yu{mount(){this.unmount=eu(kk(this.node,!0),kk(this.node,!1))}unmount(){}}class p8 extends yu{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=eu(Nl(this.node.current,"focus",()=>this.onFocus()),Nl(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const jF=(n,e)=>e?n===e?!0:jF(n,e.parentElement):!1,dr=n=>n;function oA(n,e){if(!e)return;const t=new PointerEvent("pointer"+n);e(t,KS(t))}class m8 extends yu{constructor(){super(...arguments),this.removeStartListeners=dr,this.removeEndListeners=dr,this.removeAccessibleListeners=dr,this.startPointerPress=(e,t)=>{if(this.removeEndListeners(),this.isPressing)return;const i=this.node.getProps(),s=zl(window,"pointerup",(a,l)=>{if(!this.checkPressEnd())return;const{onTap:c,onTapCancel:u}=this.node.getProps();vi.update(()=>{jF(this.node.current,a.target)?c&&c(a,l):u&&u(a,l)})},{passive:!(i.onTap||i.onPointerUp)}),o=zl(window,"pointercancel",(a,l)=>this.cancelPress(a,l),{passive:!(i.onTapCancel||i.onPointerCancel)});this.removeEndListeners=eu(s,o),this.startPress(e,t)},this.startAccessiblePress=()=>{const e=s=>{if(s.key!=="Enter"||this.isPressing)return;const o=a=>{a.key!=="Enter"||!this.checkPressEnd()||oA("up",(l,c)=>{const{onTap:u}=this.node.getProps();u&&vi.update(()=>u(l,c))})};this.removeEndListeners(),this.removeEndListeners=Nl(this.node.current,"keyup",o),oA("down",(a,l)=>{this.startPress(a,l)})},t=Nl(this.node.current,"keydown",e),i=()=>{this.isPressing&&oA("cancel",(s,o)=>this.cancelPress(s,o))},r=Nl(this.node.current,"blur",i);this.removeAccessibleListeners=eu(t,r)}}startPress(e,t){this.isPressing=!0;const{onTapStart:i,whileTap:r}=this.node.getProps();r&&this.node.animationState&&this.node.animationState.setActive("whileTap",!0),i&&vi.update(()=>i(e,t))}checkPressEnd(){return this.removeEndListeners(),this.isPressing=!1,this.node.getProps().whileTap&&this.node.animationState&&this.node.animationState.setActive("whileTap",!1),!GF()}cancelPress(e,t){if(!this.checkPressEnd())return;const{onTapCancel:i}=this.node.getProps();i&&vi.update(()=>i(e,t))}mount(){const e=this.node.getProps(),t=zl(this.node.current,"pointerdown",this.startPointerPress,{passive:!(e.onTapStart||e.onPointerStart)}),i=Nl(this.node.current,"focus",this.startAccessiblePress);this.removeStartListeners=eu(t,i)}unmount(){this.removeStartListeners(),this.removeEndListeners(),this.removeAccessibleListeners()}}const kE=new WeakMap,aA=new WeakMap,g8=n=>{const e=kE.get(n.target);e&&e(n)},y8=n=>{n.forEach(g8)};function v8({root:n,...e}){const t=n||document;aA.has(t)||aA.set(t,{});const i=aA.get(t),r=JSON.stringify(e);return i[r]||(i[r]=new IntersectionObserver(y8,{root:n,...e})),i[r]}function x8(n,e,t){const i=v8(e);return kE.set(n,t),i.observe(n),()=>{kE.delete(n),i.unobserve(n)}}const w8={some:0,all:1};class S8 extends yu{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:t,margin:i,amount:r="some",once:s}=e,o={root:t?t.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:w8[r]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,s&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:f}=this.node.getProps(),g=c?u:f;g&&g(l)};return x8(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(_8(e,t))&&this.startObserver()}unmount(){}}function _8({viewport:n={}},{viewport:e={}}={}){return t=>n[t]!==e[t]}const M8={inView:{Feature:S8},tap:{Feature:m8},focus:{Feature:p8},hover:{Feature:d8}};function XF(n,e){if(!Array.isArray(e))return!1;const t=e.length;if(t!==n.length)return!1;for(let i=0;ie[i]=t.get()),e}function b8(n){const e={};return n.values.forEach((t,i)=>e[i]=t.getVelocity()),e}function JS(n,e,t){const i=n.getProps();return hC(i,e,t!==void 0?t:i.custom,A8(n),b8(n))}const E8="framerAppearId",T8="data-"+cC(E8);let C8=dr,fC=dr;const tu=n=>n*1e3,Bl=n=>n/1e3,P8={current:!1},qF=n=>Array.isArray(n)&&typeof n[0]=="number";function YF(n){return!!(!n||typeof n=="string"&&KF[n]||qF(n)||Array.isArray(n)&&n.every(YF))}const $g=([n,e,t,i])=>`cubic-bezier(${n}, ${e}, ${t}, ${i})`,KF={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:$g([0,.65,.55,1]),circOut:$g([.55,0,1,.45]),backIn:$g([.31,.01,.66,-.59]),backOut:$g([.33,1.53,.69,.99])};function ZF(n){if(n)return qF(n)?$g(n):Array.isArray(n)?n.map(ZF):KF[n]}function R8(n,e,t,{delay:i=0,duration:r,repeat:s=0,repeatType:o="loop",ease:a,times:l}={}){const c={[e]:t};l&&(c.offset=l);const u=ZF(a);return Array.isArray(u)&&(c.easing=u),n.animate(c,{delay:i,duration:r,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"})}const Lk={waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate")},lA={},JF={};for(const n in Lk)JF[n]=()=>(lA[n]===void 0&&(lA[n]=Lk[n]()),lA[n]);function k8(n,{repeat:e,repeatType:t="loop"}){const i=e&&t!=="loop"&&e%2===1?0:n.length-1;return n[i]}const QF=(n,e,t)=>(((1-3*t+3*e)*n+(3*t-6*e))*n+3*e)*n,L8=1e-7,I8=12;function D8(n,e,t,i,r){let s,o,a=0;do o=e+(t-e)/2,s=QF(o,i,r)-n,s>0?t=o:e=o;while(Math.abs(s)>L8&&++aD8(s,0,1,n,t);return s=>s===0||s===1?s:QF(r(s),e,i)}const O8=by(.42,0,1,1),N8=by(0,0,.58,1),$F=by(.42,0,.58,1),F8=n=>Array.isArray(n)&&typeof n[0]!="number",eU=n=>e=>e<=.5?n(2*e)/2:(2-n(2*(1-e)))/2,tU=n=>e=>1-n(1-e),nU=n=>1-Math.sin(Math.acos(n)),dC=tU(nU),U8=eU(dC),iU=by(.33,1.53,.69,.99),pC=tU(iU),z8=eU(pC),B8=n=>(n*=2)<1?.5*pC(n):.5*(2-Math.pow(2,-10*(n-1))),V8={linear:dr,easeIn:O8,easeInOut:$F,easeOut:N8,circIn:nU,circInOut:U8,circOut:dC,backIn:pC,backInOut:z8,backOut:iU,anticipate:B8},Ik=n=>{if(Array.isArray(n)){fC(n.length===4);const[e,t,i,r]=n;return by(e,t,i,r)}else if(typeof n=="string")return V8[n];return n},mC=(n,e)=>t=>!!(My(t)&&zG.test(t)&&t.startsWith(n)||e&&Object.prototype.hasOwnProperty.call(t,e)),rU=(n,e,t)=>i=>{if(!My(i))return i;const[r,s,o,a]=i.match(YS);return{[n]:parseFloat(r),[e]:parseFloat(s),[t]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},H8=n=>ou(0,255,n),cA={...uf,transform:n=>Math.round(H8(n))},kh={test:mC("rgb","red"),parse:rU("red","green","blue"),transform:({red:n,green:e,blue:t,alpha:i=1})=>"rgba("+cA.transform(n)+", "+cA.transform(e)+", "+cA.transform(t)+", "+g0(m0.transform(i))+")"};function G8(n){let e="",t="",i="",r="";return n.length>5?(e=n.substring(1,3),t=n.substring(3,5),i=n.substring(5,7),r=n.substring(7,9)):(e=n.substring(1,2),t=n.substring(2,3),i=n.substring(3,4),r=n.substring(4,5),e+=e,t+=t,i+=i,r+=r),{red:parseInt(e,16),green:parseInt(t,16),blue:parseInt(i,16),alpha:r?parseInt(r,16)/255:1}}const LE={test:mC("#"),parse:G8,transform:kh.transform},wp={test:mC("hsl","hue"),parse:rU("hue","saturation","lightness"),transform:({hue:n,saturation:e,lightness:t,alpha:i=1})=>"hsla("+Math.round(n)+", "+Za.transform(g0(e))+", "+Za.transform(g0(t))+", "+g0(m0.transform(i))+")"},ds={test:n=>kh.test(n)||LE.test(n)||wp.test(n),parse:n=>kh.test(n)?kh.parse(n):wp.test(n)?wp.parse(n):LE.parse(n),transform:n=>My(n)?n:n.hasOwnProperty("red")?kh.transform(n):wp.transform(n)},Mi=(n,e,t)=>-t*n+t*e+n;function uA(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*(2/3-t)*6:n}function W8({hue:n,saturation:e,lightness:t,alpha:i}){n/=360,e/=100,t/=100;let r=0,s=0,o=0;if(!e)r=s=o=t;else{const a=t<.5?t*(1+e):t+e-t*e,l=2*t-a;r=uA(l,a,n+1/3),s=uA(l,a,n),o=uA(l,a,n-1/3)}return{red:Math.round(r*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:i}}const hA=(n,e,t)=>{const i=n*n;return Math.sqrt(Math.max(0,t*(e*e-i)+i))},j8=[LE,kh,wp],X8=n=>j8.find(e=>e.test(n));function Dk(n){const e=X8(n);let t=e.parse(n);return e===wp&&(t=W8(t)),t}const sU=(n,e)=>{const t=Dk(n),i=Dk(e),r={...t};return s=>(r.red=hA(t.red,i.red,s),r.green=hA(t.green,i.green,s),r.blue=hA(t.blue,i.blue,s),r.alpha=Mi(t.alpha,i.alpha,s),kh.transform(r))};function q8(n){var e,t;return isNaN(n)&&My(n)&&(((e=n.match(YS))===null||e===void 0?void 0:e.length)||0)+(((t=n.match(PF))===null||t===void 0?void 0:t.length)||0)>0}const oU={regex:FG,countKey:"Vars",token:"${v}",parse:dr},aU={regex:PF,countKey:"Colors",token:"${c}",parse:ds.parse},lU={regex:YS,countKey:"Numbers",token:"${n}",parse:uf.parse};function fA(n,{regex:e,countKey:t,token:i,parse:r}){const s=n.tokenised.match(e);s&&(n["num"+t]=s.length,n.tokenised=n.tokenised.replace(e,i),n.values.push(...s.map(r)))}function Jw(n){const e=n.toString(),t={value:e,tokenised:e,values:[],numVars:0,numColors:0,numNumbers:0};return t.value.includes("var(--")&&fA(t,oU),fA(t,aU),fA(t,lU),t}function cU(n){return Jw(n).values}function uU(n){const{values:e,numColors:t,numVars:i,tokenised:r}=Jw(n),s=e.length;return o=>{let a=r;for(let l=0;ltypeof n=="number"?0:n;function K8(n){const e=cU(n);return uU(n)(e.map(Y8))}const au={test:q8,parse:cU,createTransformer:uU,getAnimatableNone:K8},hU=(n,e)=>t=>`${t>0?e:n}`;function fU(n,e){return typeof n=="number"?t=>Mi(n,e,t):ds.test(n)?sU(n,e):n.startsWith("var(")?hU(n,e):pU(n,e)}const dU=(n,e)=>{const t=[...n],i=t.length,r=n.map((s,o)=>fU(s,e[o]));return s=>{for(let o=0;o{const t={...n,...e},i={};for(const r in t)n[r]!==void 0&&e[r]!==void 0&&(i[r]=fU(n[r],e[r]));return r=>{for(const s in i)t[s]=i[s](r);return t}},pU=(n,e)=>{const t=au.createTransformer(e),i=Jw(n),r=Jw(e);return i.numVars===r.numVars&&i.numColors===r.numColors&&i.numNumbers>=r.numNumbers?eu(dU(i.values,r.values),t):hU(n,e)},X0=(n,e,t)=>{const i=e-n;return i===0?1:(t-n)/i},Ok=(n,e)=>t=>Mi(n,e,t);function J8(n){return typeof n=="number"?Ok:typeof n=="string"?ds.test(n)?sU:pU:Array.isArray(n)?dU:typeof n=="object"?Z8:Ok}function Q8(n,e,t){const i=[],r=t||J8(n[0]),s=n.length-1;for(let o=0;oe[0];n[0]>n[s-1]&&(n=[...n].reverse(),e=[...e].reverse());const o=Q8(e,i,r),a=o.length,l=c=>{let u=0;if(a>1)for(;ul(ou(n[0],n[s-1],c)):l}function $8(n,e){const t=n[n.length-1];for(let i=1;i<=e;i++){const r=X0(0,e,i);n.push(Mi(t,1,r))}}function eW(n){const e=[0];return $8(e,n.length-1),e}function tW(n,e){return n.map(t=>t*e)}function nW(n,e){return n.map(()=>e||$F).splice(0,n.length-1)}function Qw({duration:n=300,keyframes:e,times:t,ease:i="easeInOut"}){const r=F8(i)?i.map(Ik):Ik(i),s={done:!1,value:e[0]},o=tW(t&&t.length===e.length?t:eW(e),n),a=mU(o,e,{ease:Array.isArray(r)?r:nW(e,r)});return{calculatedDuration:n,next:l=>(s.value=a(l),s.done=l>=n,s)}}function gU(n,e){return e?n*(1e3/e):0}const iW=5;function yU(n,e,t){const i=Math.max(e-iW,0);return gU(t-n(i),e-i)}const dA=.001,rW=.01,Nk=10,sW=.05,oW=1;function aW({duration:n=800,bounce:e=.25,velocity:t=0,mass:i=1}){let r,s;C8(n<=tu(Nk));let o=1-e;o=ou(sW,oW,o),n=ou(rW,Nk,Bl(n)),o<1?(r=c=>{const u=c*o,f=u*n,g=u-t,y=IE(c,o),v=Math.exp(-f);return dA-g/y*v},s=c=>{const f=c*o*n,g=f*t+t,y=Math.pow(o,2)*Math.pow(c,2)*n,v=Math.exp(-f),w=IE(Math.pow(c,2),o);return(-r(c)+dA>0?-1:1)*((g-y)*v)/w}):(r=c=>{const u=Math.exp(-c*n),f=(c-t)*n+1;return-dA+u*f},s=c=>{const u=Math.exp(-c*n),f=(t-c)*(n*n);return u*f});const a=5/n,l=cW(r,s,a);if(n=tu(n),isNaN(l))return{stiffness:100,damping:10,duration:n};{const c=Math.pow(l,2)*i;return{stiffness:c,damping:o*2*Math.sqrt(i*c),duration:n}}}const lW=12;function cW(n,e,t){let i=t;for(let r=1;rn[t]!==void 0)}function fW(n){let e={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...n};if(!Fk(n,hW)&&Fk(n,uW)){const t=aW(n);e={...e,...t,velocity:0,mass:1},e.isResolvedFromDuration=!0}return e}function vU({keyframes:n,restDelta:e,restSpeed:t,...i}){const r=n[0],s=n[n.length-1],o={done:!1,value:r},{stiffness:a,damping:l,mass:c,velocity:u,duration:f,isResolvedFromDuration:g}=fW(i),y=u?-Bl(u):0,v=l/(2*Math.sqrt(a*c)),w=s-r,S=Bl(Math.sqrt(a/c)),x=Math.abs(w)<5;t||(t=x?.01:2),e||(e=x?.005:.5);let M;if(v<1){const A=IE(S,v);M=C=>{const N=Math.exp(-v*S*C);return s-N*((y+v*S*w)/A*Math.sin(A*C)+w*Math.cos(A*C))}}else if(v===1)M=A=>s-Math.exp(-S*A)*(w+(y+S*w)*A);else{const A=S*Math.sqrt(v*v-1);M=C=>{const N=Math.exp(-v*S*C),L=Math.min(A*C,300);return s-N*((y+v*S*w)*Math.sinh(L)+A*w*Math.cosh(L))/A}}return{calculatedDuration:g&&f||null,next:A=>{const C=M(A);if(g)o.done=A>=f;else{let N=y;A!==0&&(v<1?N=yU(M,A,C):N=0);const L=Math.abs(N)<=t,F=Math.abs(s-C)<=e;o.done=L&&F}return o.value=o.done?s:C,o}}}function Uk({keyframes:n,velocity:e=0,power:t=.8,timeConstant:i=325,bounceDamping:r=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const f=n[0],g={done:!1,value:f},y=H=>a!==void 0&&Hl,v=H=>a===void 0?l:l===void 0||Math.abs(a-H)-w*Math.exp(-H/i),A=H=>x+M(H),C=H=>{const I=M(H),R=A(H);g.done=Math.abs(I)<=c,g.value=g.done?x:R};let N,L;const F=H=>{y(g.value)&&(N=H,L=vU({keyframes:[g.value,v(g.value)],velocity:yU(A,H,g.value),damping:r,stiffness:s,restDelta:c,restSpeed:u}))};return F(0),{calculatedDuration:null,next:H=>{let I=!1;return!L&&N===void 0&&(I=!0,C(H),F(H)),N!==void 0&&H>N?L.next(H-N):(!I&&C(H),g)}}}const dW=n=>{const e=({timestamp:t})=>n(t);return{start:()=>vi.update(e,!0),stop:()=>jl(e),now:()=>Si.isProcessing?Si.timestamp:performance.now()}},zk=2e4;function Bk(n){let e=0;const t=50;let i=n.next(e);for(;!i.done&&e=zk?1/0:e}const pW={decay:Uk,inertia:Uk,tween:Qw,keyframes:Qw,spring:vU};function $w({autoplay:n=!0,delay:e=0,driver:t=dW,keyframes:i,type:r="keyframes",repeat:s=0,repeatDelay:o=0,repeatType:a="loop",onPlay:l,onStop:c,onComplete:u,onUpdate:f,...g}){let y=1,v=!1,w,S;const x=()=>{w&&w(),S=new Promise(de=>{w=de})};x();let M;const A=pW[r]||Qw;let C;A!==Qw&&typeof i[0]!="number"&&(C=mU([0,100],i,{clamp:!1}),i=[0,100]);const N=A({...g,keyframes:i});let L;a==="mirror"&&(L=A({...g,keyframes:[...i].reverse(),velocity:-(g.velocity||0)}));let F="idle",H=null,I=null,R=null;N.calculatedDuration===null&&s&&(N.calculatedDuration=Bk(N));const{calculatedDuration:W}=N;let se=1/0,Z=1/0;W!==null&&(se=W+o,Z=se*(s+1)-o);let oe=0;const fe=de=>{if(I===null)return;y>0&&(I=Math.min(I,de)),y<0&&(I=Math.min(de-Z/y,I)),H!==null?oe=H:oe=Math.round(de-I)*y;const Oe=oe-e*(y>=0?1:-1),it=y>=0?Oe<0:Oe>Z;oe=Math.max(Oe,0),F==="finished"&&H===null&&(oe=Z);let we=oe,Ve=N;if(s){const jt=oe/se;let ge=Math.floor(jt),Dt=jt%1;!Dt&&jt>=1&&(Dt=1),Dt===1&&ge--,ge=Math.min(ge,s+1);const Ie=!!(ge%2);Ie&&(a==="reverse"?(Dt=1-Dt,o&&(Dt-=o/se)):a==="mirror"&&(Ve=L));let Ge=ou(0,1,Dt);oe>Z&&(Ge=a==="reverse"&&Ie?1:0),we=Ge*se}const Ye=it?{done:!1,value:i[0]}:Ve.next(we);C&&(Ye.value=C(Ye.value));let{done:He}=Ye;!it&&W!==null&&(He=y>=0?oe>=Z:oe<=0);const Xt=H===null&&(F==="finished"||F==="running"&&He);return f&&f(Ye.value),Xt&&X(),Ye},Se=()=>{M&&M.stop(),M=void 0},Fe=()=>{F="idle",Se(),x(),I=R=null},X=()=>{F="finished",u&&u(),Se(),x()},ie=()=>{if(v)return;M||(M=t(fe));const de=M.now();l&&l(),H!==null?I=de-H:(!I||F==="finished")&&(I=de),R=I,H=null,F="running",M.start()};n&&ie();const re={then(de,Oe){return S.then(de,Oe)},get time(){return Bl(oe)},set time(de){de=tu(de),oe=de,H!==null||!M||y===0?H=de:I=M.now()-de/y},get duration(){const de=N.calculatedDuration===null?Bk(N):N.calculatedDuration;return Bl(de)},get speed(){return y},set speed(de){de===y||!M||(y=de,re.time=Bl(oe))},get state(){return F},play:ie,pause:()=>{F="paused",H=oe},stop:()=>{v=!0,F!=="idle"&&(F="idle",c&&c(),Fe())},cancel:()=>{R!==null&&fe(R),Fe()},complete:()=>{F="finished"},sample:de=>(I=0,fe(de))};return re}const mW=new Set(["opacity","clipPath","filter","transform","backgroundColor"]),Lx=10,gW=2e4,yW=(n,e)=>e.type==="spring"||n==="backgroundColor"||!YF(e.ease);function vW(n,e,{onUpdate:t,onComplete:i,...r}){if(!(JF.waapi()&&mW.has(e)&&!r.repeatDelay&&r.repeatType!=="mirror"&&r.damping!==0&&r.type!=="inertia"))return!1;let o=!1,a,l;const c=()=>{l=new Promise(x=>{a=x})};c();let{keyframes:u,duration:f=300,ease:g,times:y}=r;if(yW(e,r)){const x=$w({...r,repeat:0,delay:0});let M={done:!1,value:u[0]};const A=[];let C=0;for(;!M.done&&Cv.cancel(),S=()=>{vi.update(w),a(),c()};return v.onfinish=()=>{n.set(k8(u,r)),i&&i(),S()},{then(x,M){return l.then(x,M)},get time(){return Bl(v.currentTime||0)},set time(x){v.currentTime=tu(x)},get speed(){return v.playbackRate},set speed(x){v.playbackRate=x},get duration(){return Bl(f)},play:()=>{o||(v.play(),jl(w))},pause:()=>v.pause(),stop:()=>{if(o=!0,v.playState==="idle")return;const{currentTime:x}=v;if(x){const M=$w({...r,autoplay:!1});n.setWithVelocity(M.sample(x-Lx).value,M.sample(x).value,Lx)}S()},complete:()=>v.finish(),cancel:S}}function xW({keyframes:n,delay:e,onUpdate:t,onComplete:i}){const r=()=>(t&&t(n[n.length-1]),i&&i(),{time:0,speed:1,duration:0,play:dr,pause:dr,stop:dr,then:s=>(s(),Promise.resolve()),cancel:dr,complete:dr});return e?$w({keyframes:[0,1],duration:0,delay:e,onComplete:r}):r()}const wW={type:"spring",stiffness:500,damping:25,restSpeed:10},SW=n=>({type:"spring",stiffness:550,damping:n===0?2*Math.sqrt(550):30,restSpeed:10}),_W={type:"keyframes",duration:.8},MW={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},AW=(n,{keyframes:e})=>e.length>2?_W:cf.has(n)?n.startsWith("scale")?SW(e[1]):wW:MW,DE=(n,e)=>n==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(au.test(e)||e==="0")&&!e.startsWith("url(")),bW=new Set(["brightness","contrast","saturate","opacity"]);function EW(n){const[e,t]=n.slice(0,-1).split("(");if(e==="drop-shadow")return n;const[i]=t.match(YS)||[];if(!i)return n;const r=t.replace(i,"");let s=bW.has(e)?1:0;return i!==t&&(s*=100),e+"("+s+r+")"}const TW=/([a-z-]*)\(.*?\)/g,OE={...au,getAnimatableNone:n=>{const e=n.match(TW);return e?e.map(EW).join(" "):n}},CW={...RF,color:ds,backgroundColor:ds,outlineColor:ds,fill:ds,stroke:ds,borderColor:ds,borderTopColor:ds,borderRightColor:ds,borderBottomColor:ds,borderLeftColor:ds,filter:OE,WebkitFilter:OE},gC=n=>CW[n];function xU(n,e){let t=gC(n);return t!==OE&&(t=au),t.getAnimatableNone?t.getAnimatableNone(e):void 0}const wU=n=>/^0[^.\s]+$/.test(n);function PW(n){if(typeof n=="number")return n===0;if(n!==null)return n==="none"||n==="0"||wU(n)}function RW(n,e,t,i){const r=DE(e,t);let s;Array.isArray(t)?s=[...t]:s=[null,t];const o=i.from!==void 0?i.from:n.get();let a;const l=[];for(let c=0;cr=>{const s=SU(i,n)||{},o=s.delay||i.delay||0;let{elapsed:a=0}=i;a=a-tu(o);const l=RW(e,n,t,s),c=l[0],u=l[l.length-1],f=DE(n,c),g=DE(n,u);let y={keyframes:l,velocity:e.getVelocity(),ease:"easeOut",...s,delay:-a,onUpdate:v=>{e.set(v),s.onUpdate&&s.onUpdate(v)},onComplete:()=>{r(),s.onComplete&&s.onComplete()}};if(kW(s)||(y={...y,...AW(n,y)}),y.duration&&(y.duration=tu(y.duration)),y.repeatDelay&&(y.repeatDelay=tu(y.repeatDelay)),!f||!g||P8.current||s.type===!1)return xW(y);if(e.owner&&e.owner.current instanceof HTMLElement&&!e.owner.getProps().onUpdate){const v=vW(e,n,y);if(v)return v}return $w(y)};function eS(n){return!!(Ns(n)&&n.add)}const LW=n=>/^\-?\d*\.?\d+$/.test(n);function vC(n,e){n.indexOf(e)===-1&&n.push(e)}function xC(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}class wC{constructor(){this.subscriptions=[]}add(e){return vC(this.subscriptions,e),()=>xC(this.subscriptions,e)}notify(e,t,i){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,i);else for(let s=0;s!isNaN(parseFloat(n));class DW{constructor(e,t={}){this.version="10.12.18",this.timeDelta=0,this.lastUpdated=0,this.canTrackVelocity=!1,this.events={},this.updateAndNotify=(i,r=!0)=>{this.prev=this.current,this.current=i;const{delta:s,timestamp:o}=Si;this.lastUpdated!==o&&(this.timeDelta=s,this.lastUpdated=o,vi.postRender(this.scheduleVelocityCheck)),this.prev!==this.current&&this.events.change&&this.events.change.notify(this.current),this.events.velocityChange&&this.events.velocityChange.notify(this.getVelocity()),r&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.scheduleVelocityCheck=()=>vi.postRender(this.velocityCheck),this.velocityCheck=({timestamp:i})=>{i!==this.lastUpdated&&(this.prev=this.current,this.events.velocityChange&&this.events.velocityChange.notify(this.getVelocity()))},this.hasAnimated=!1,this.prev=this.current=e,this.canTrackVelocity=IW(this.current),this.owner=t.owner}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new wC);const i=this.events[e].add(t);return e==="change"?()=>{i(),vi.read(()=>{this.events.change.getSize()||this.stop()})}:i}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,i){this.set(t),this.prev=e,this.timeDelta=i}jump(e){this.updateAndNotify(e),this.prev=e,this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){return this.canTrackVelocity?gU(parseFloat(this.current)-parseFloat(this.prev),this.timeDelta):0}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 Yp(n,e){return new DW(n,e)}const _U=n=>e=>e.test(n),OW={test:n=>n==="auto",parse:n=>n},MU=[uf,$t,Za,Rc,VG,BG,OW],Eg=n=>MU.find(_U(n)),NW=[...MU,ds,au],FW=n=>NW.find(_U(n));function UW(n,e,t){n.hasValue(e)?n.getValue(e).set(t):n.addValue(e,Yp(t))}function zW(n,e){const t=JS(n,e);let{transitionEnd:i={},transition:r={},...s}=t?n.makeTargetAnimatable(t,!1):{};s={...s,...i};for(const o in s){const a=t8(s[o]);UW(n,o,a)}}function BW(n,e,t){var i,r;const s=Object.keys(e).filter(a=>!n.hasValue(a)),o=s.length;if(o)for(let a=0;al.remove(f))),c.push(w)}return o&&Promise.all(c).then(()=>{o&&zW(n,o)}),c}function NE(n,e,t={}){const i=JS(n,e,t.custom);let{transition:r=n.getDefaultTransition()||{}}=i||{};t.transitionOverride&&(r=t.transitionOverride);const s=i?()=>Promise.all(AU(n,i,t)):()=>Promise.resolve(),o=n.variantChildren&&n.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:f}=r;return WW(n,e,c+l,u,f,t)}:()=>Promise.resolve(),{when:a}=r;if(a){const[l,c]=a==="beforeChildren"?[s,o]:[o,s];return l().then(()=>c())}else return Promise.all([s(),o(t.delay)])}function WW(n,e,t=0,i=0,r=1,s){const o=[],a=(n.variantChildren.size-1)*i,l=r===1?(c=0)=>c*i:(c=0)=>a-c*i;return Array.from(n.variantChildren).sort(jW).forEach((c,u)=>{c.notify("AnimationStart",e),o.push(NE(c,e,{...s,delay:t+l(u)}).then(()=>c.notify("AnimationComplete",e)))}),Promise.all(o)}function jW(n,e){return n.sortNodePosition(e)}function XW(n,e,t={}){n.notify("AnimationStart",e);let i;if(Array.isArray(e)){const r=e.map(s=>NE(n,s,t));i=Promise.all(r)}else if(typeof e=="string")i=NE(n,e,t);else{const r=typeof e=="function"?JS(n,e,t.custom):e;i=Promise.all(AU(n,r,t))}return i.then(()=>n.notify("AnimationComplete",e))}const qW=[...tC].reverse(),YW=tC.length;function KW(n){return e=>Promise.all(e.map(({animation:t,options:i})=>XW(n,t,i)))}function ZW(n){let e=KW(n);const t=QW();let i=!0;const r=(l,c)=>{const u=JS(n,c);if(u){const{transition:f,transitionEnd:g,...y}=u;l={...l,...y,...g}}return l};function s(l){e=l(n)}function o(l,c){const u=n.getProps(),f=n.getVariantContext(!0)||{},g=[],y=new Set;let v={},w=1/0;for(let x=0;xw&&N;const R=Array.isArray(C)?C:[C];let W=R.reduce(r,{});L===!1&&(W={});const{prevResolvedValues:se={}}=A,Z={...se,...W},oe=fe=>{I=!0,y.delete(fe),A.needsAnimating[fe]=!0};for(const fe in Z){const Se=W[fe],Fe=se[fe];v.hasOwnProperty(fe)||(Se!==Fe?Zw(Se)&&Zw(Fe)?!XF(Se,Fe)||H?oe(fe):A.protectedKeys[fe]=!0:Se!==void 0?oe(fe):y.add(fe):Se!==void 0&&y.has(fe)?oe(fe):A.protectedKeys[fe]=!0)}A.prevProp=C,A.prevResolvedValues=W,A.isActive&&(v={...v,...W}),i&&n.blockInitialAnimation&&(I=!1),I&&!F&&g.push(...R.map(fe=>({animation:fe,options:{type:M,...l}})))}if(y.size){const x={};y.forEach(M=>{const A=n.getBaseTarget(M);A!==void 0&&(x[M]=A)}),g.push({animation:x})}let S=!!g.length;return i&&u.initial===!1&&!n.manuallyAnimateOnMount&&(S=!1),i=!1,S?e(g):Promise.resolve()}function a(l,c,u){var f;if(t[l].isActive===c)return Promise.resolve();(f=n.variantChildren)===null||f===void 0||f.forEach(y=>{var v;return(v=y.animationState)===null||v===void 0?void 0:v.setActive(l,c)}),t[l].isActive=c;const g=o(u,l);for(const y in t)t[y].protectedKeys={};return g}return{animateChanges:o,setActive:a,setAnimateFunction:s,getState:()=>t}}function JW(n,e){return typeof e=="string"?e!==n:Array.isArray(e)?!XF(e,n):!1}function th(n=!1){return{isActive:n,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function QW(){return{animate:th(!0),whileInView:th(),whileHover:th(),whileTap:th(),whileDrag:th(),whileFocus:th(),exit:th()}}class $W extends yu{constructor(e){super(e),e.animationState||(e.animationState=ZW(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();this.unmount(),XS(e)&&(this.unmount=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){}}let e9=0;class t9 extends yu{constructor(){super(...arguments),this.id=e9++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t,custom:i}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const s=this.node.animationState.setActive("exit",!e,{custom:i??this.node.getProps().custom});t&&!e&&s.then(()=>t(this.id))}mount(){const{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}const n9={animation:{Feature:$W},exit:{Feature:t9}},Vk=(n,e)=>Math.abs(n-e);function i9(n,e){const t=Vk(n.x,e.x),i=Vk(n.y,e.y);return Math.sqrt(t**2+i**2)}class bU{constructor(e,t,{transformPagePoint:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const c=mA(this.lastMoveEventInfo,this.history),u=this.startEvent!==null,f=i9(c.offset,{x:0,y:0})>=3;if(!u&&!f)return;const{point:g}=c,{timestamp:y}=Si;this.history.push({...g,timestamp:y});const{onStart:v,onMove:w}=this.handlers;u||(v&&v(this.lastMoveEvent,c),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,c)},this.handlePointerMove=(c,u)=>{this.lastMoveEvent=c,this.lastMoveEventInfo=pA(u,this.transformPagePoint),vi.update(this.updatePoint,!0)},this.handlePointerUp=(c,u)=>{if(this.end(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const{onEnd:f,onSessionEnd:g}=this.handlers,y=mA(c.type==="pointercancel"?this.lastMoveEventInfo:pA(u,this.transformPagePoint),this.history);this.startEvent&&f&&f(c,y),g&&g(c,y)},!BF(e))return;this.handlers=t,this.transformPagePoint=i;const r=KS(e),s=pA(r,this.transformPagePoint),{point:o}=s,{timestamp:a}=Si;this.history=[{...o,timestamp:a}];const{onSessionStart:l}=t;l&&l(e,mA(s,this.history)),this.removeListeners=eu(zl(window,"pointermove",this.handlePointerMove),zl(window,"pointerup",this.handlePointerUp),zl(window,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),jl(this.updatePoint)}}function pA(n,e){return e?{point:e(n.point)}:n}function Hk(n,e){return{x:n.x-e.x,y:n.y-e.y}}function mA({point:n},e){return{point:n,delta:Hk(n,EU(e)),offset:Hk(n,r9(e)),velocity:s9(e,.1)}}function r9(n){return n[0]}function EU(n){return n[n.length-1]}function s9(n,e){if(n.length<2)return{x:0,y:0};let t=n.length-1,i=null;const r=EU(n);for(;t>=0&&(i=n[t],!(r.timestamp-i.timestamp>tu(e)));)t--;if(!i)return{x:0,y:0};const s=Bl(r.timestamp-i.timestamp);if(s===0)return{x:0,y:0};const o={x:(r.x-i.x)/s,y:(r.y-i.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function co(n){return n.max-n.min}function FE(n,e=0,t=.01){return Math.abs(n-e)<=t}function Gk(n,e,t,i=.5){n.origin=i,n.originPoint=Mi(e.min,e.max,n.origin),n.scale=co(t)/co(e),(FE(n.scale,1,1e-4)||isNaN(n.scale))&&(n.scale=1),n.translate=Mi(t.min,t.max,n.origin)-n.originPoint,(FE(n.translate)||isNaN(n.translate))&&(n.translate=0)}function y0(n,e,t,i){Gk(n.x,e.x,t.x,i?i.originX:void 0),Gk(n.y,e.y,t.y,i?i.originY:void 0)}function Wk(n,e,t){n.min=t.min+e.min,n.max=n.min+co(e)}function o9(n,e,t){Wk(n.x,e.x,t.x),Wk(n.y,e.y,t.y)}function jk(n,e,t){n.min=e.min-t.min,n.max=n.min+co(e)}function v0(n,e,t){jk(n.x,e.x,t.x),jk(n.y,e.y,t.y)}function a9(n,{min:e,max:t},i){return e!==void 0&&nt&&(n=i?Mi(t,n,i.max):Math.min(n,t)),n}function Xk(n,e,t){return{min:e!==void 0?n.min+e:void 0,max:t!==void 0?n.max+t-(n.max-n.min):void 0}}function l9(n,{top:e,left:t,bottom:i,right:r}){return{x:Xk(n.x,t,r),y:Xk(n.y,e,i)}}function qk(n,e){let t=e.min-n.min,i=e.max-n.max;return e.max-e.mini?t=X0(e.min,e.max-i,n.min):i>r&&(t=X0(n.min,n.max-r,e.min)),ou(0,1,t)}function h9(n,e){const t={};return e.min!==void 0&&(t.min=e.min-n.min),e.max!==void 0&&(t.max=e.max-n.min),t}const UE=.35;function f9(n=UE){return n===!1?n=0:n===!0&&(n=UE),{x:Yk(n,"left","right"),y:Yk(n,"top","bottom")}}function Yk(n,e,t){return{min:Kk(n,e),max:Kk(n,t)}}function Kk(n,e){return typeof n=="number"?n:n[e]||0}const Zk=()=>({translate:0,scale:1,origin:0,originPoint:0}),Sp=()=>({x:Zk(),y:Zk()}),Jk=()=>({min:0,max:0}),$i=()=>({x:Jk(),y:Jk()});function Va(n){return[n("x"),n("y")]}function TU({top:n,left:e,right:t,bottom:i}){return{x:{min:e,max:t},y:{min:n,max:i}}}function d9({x:n,y:e}){return{top:e.min,right:n.max,bottom:e.max,left:n.min}}function p9(n,e){if(!e)return n;const t=e({x:n.left,y:n.top}),i=e({x:n.right,y:n.bottom});return{top:t.y,left:t.x,bottom:i.y,right:i.x}}function gA(n){return n===void 0||n===1}function zE({scale:n,scaleX:e,scaleY:t}){return!gA(n)||!gA(e)||!gA(t)}function xh(n){return zE(n)||CU(n)||n.z||n.rotate||n.rotateX||n.rotateY}function CU(n){return Qk(n.x)||Qk(n.y)}function Qk(n){return n&&n!=="0%"}function tS(n,e,t){const i=n-t,r=e*i;return t+r}function $k(n,e,t,i,r){return r!==void 0&&(n=tS(n,r,i)),tS(n,t,i)+e}function BE(n,e=0,t=1,i,r){n.min=$k(n.min,e,t,i,r),n.max=$k(n.max,e,t,i,r)}function PU(n,{x:e,y:t}){BE(n.x,e.translate,e.scale,e.originPoint),BE(n.y,t.translate,t.scale,t.originPoint)}function m9(n,e,t,i=!1){const r=t.length;if(!r)return;e.x=e.y=1;let s,o;for(let a=0;a1.0000000000001||n<.999999999999?n:1}function Dc(n,e){n.min=n.min+e,n.max=n.max+e}function t3(n,e,[t,i,r]){const s=e[r]!==void 0?e[r]:.5,o=Mi(n.min,n.max,s);BE(n,e[t],e[i],o,e.scale)}const g9=["x","scaleX","originX"],y9=["y","scaleY","originY"];function _p(n,e){t3(n.x,e,g9),t3(n.y,e,y9)}function RU(n,e){return TU(p9(n.getBoundingClientRect(),e))}function v9(n,e,t){const i=RU(n,t),{scroll:r}=e;return r&&(Dc(i.x,r.offset.x),Dc(i.y,r.offset.y)),i}const x9=new WeakMap;class w9{constructor(e){this.openGlobalLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=$i(),this.visualElement=e}start(e,{snapToCursor:t=!1}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=l=>{this.stopAnimation(),t&&this.snapToCursor(KS(l,"page").point)},s=(l,c)=>{const{drag:u,dragPropagation:f,onDragStart:g}=this.getProps();if(u&&!f&&(this.openGlobalLock&&this.openGlobalLock(),this.openGlobalLock=HF(u),!this.openGlobalLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Va(v=>{let w=this.getAxisMotionValue(v).get()||0;if(Za.test(w)){const{projection:S}=this.visualElement;if(S&&S.layout){const x=S.layout.layoutBox[v];x&&(w=co(x)*(parseFloat(w)/100))}}this.originPoint[v]=w}),g&&vi.update(()=>g(l,c),!1,!0);const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},o=(l,c)=>{const{dragPropagation:u,dragDirectionLock:f,onDirectionLock:g,onDrag:y}=this.getProps();if(!u&&!this.openGlobalLock)return;const{offset:v}=c;if(f&&this.currentDirection===null){this.currentDirection=S9(v),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",c.point,v),this.updateAxis("y",c.point,v),this.visualElement.render(),y&&y(l,c)},a=(l,c)=>this.stop(l,c);this.panSession=new bU(e,{onSessionStart:r,onStart:s,onMove:o,onSessionEnd:a},{transformPagePoint:this.visualElement.getTransformPagePoint()})}stop(e,t){const i=this.isDragging;if(this.cancel(),!i)return;const{velocity:r}=t;this.startAnimation(r);const{onDragEnd:s}=this.getProps();s&&vi.update(()=>s(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:i}=this.getProps();!i&&this.openGlobalLock&&(this.openGlobalLock(),this.openGlobalLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,i){const{drag:r}=this.getProps();if(!i||!Ix(e,r,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+i[e];this.constraints&&this.constraints[e]&&(o=a9(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:t}=this.getProps(),{layout:i}=this.visualElement.projection||{},r=this.constraints;e&&xp(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&i?this.constraints=l9(i.layoutBox,e):this.constraints=!1,this.elastic=f9(t),r!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Va(s=>{this.getAxisMotionValue(s)&&(this.constraints[s]=h9(i.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!xp(e))return!1;const i=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const s=v9(i,r.root,this.visualElement.getTransformPagePoint());let o=c9(r.layout.layoutBox,s);if(t){const a=t(d9(o));this.hasMutatedConstraints=!!a,a&&(o=TU(a))}return o}startAnimation(e){const{drag:t,dragMomentum:i,dragElastic:r,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=Va(u=>{if(!Ix(u,t,this.currentDirection))return;let f=l&&l[u]||{};o&&(f={min:0,max:0});const g=r?200:1e6,y=r?40:1e7,v={type:"inertia",velocity:i?e[u]:0,bounceStiffness:g,bounceDamping:y,timeConstant:750,restDelta:1,restSpeed:10,...s,...f};return this.startAxisValueAnimation(u,v)});return Promise.all(c).then(a)}startAxisValueAnimation(e,t){const i=this.getAxisMotionValue(e);return i.start(yC(e,i,0,t))}stopAnimation(){Va(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t="_drag"+e.toUpperCase(),i=this.visualElement.getProps(),r=i[t];return r||this.visualElement.getValue(e,(i.initial?i.initial[e]:void 0)||0)}snapToCursor(e){Va(t=>{const{drag:i}=this.getProps();if(!Ix(t,i,this.currentDirection))return;const{projection:r}=this.visualElement,s=this.getAxisMotionValue(t);if(r&&r.layout){const{min:o,max:a}=r.layout.layoutBox[t];s.set(e[t]-Mi(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:i}=this.visualElement;if(!xp(t)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Va(o=>{const a=this.getAxisMotionValue(o);if(a){const l=a.get();r[o]=u9({min:l,max:l},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),Va(o=>{if(!Ix(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=this.constraints[o];a.set(Mi(l,c,r[o]))})}addListeners(){if(!this.visualElement.current)return;x9.set(this.visualElement,this);const e=this.visualElement.current,t=zl(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),i=()=>{const{dragConstraints:l}=this.getProps();xp(l)&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,s=r.addEventListener("measure",i);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),i();const o=Nl(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(Va(u=>{const f=this.getAxisMotionValue(u);f&&(this.originPoint[u]+=l[u].translate,f.set(f.get()+l[u].translate))}),this.visualElement.render())});return()=>{o(),t(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:s=!1,dragElastic:o=UE,dragMomentum:a=!0}=e;return{...e,drag:t,dragDirectionLock:i,dragPropagation:r,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function Ix(n,e,t){return(e===!0||e===n)&&(t===null||t===n)}function S9(n,e=10){let t=null;return Math.abs(n.y)>e?t="y":Math.abs(n.x)>e&&(t="x"),t}class _9 extends yu{constructor(e){super(e),this.removeGroupControls=dr,this.removeListeners=dr,this.controls=new w9(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||dr}unmount(){this.removeGroupControls(),this.removeListeners()}}const n3=n=>(e,t)=>{n&&vi.update(()=>n(e,t))};class M9 extends yu{constructor(){super(...arguments),this.removePointerDownListener=dr}onPointerDown(e){this.session=new bU(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint()})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:n3(e),onStart:n3(t),onMove:i,onEnd:(s,o)=>{delete this.session,r&&vi.update(()=>r(s,o))}}}mount(){this.removePointerDownListener=zl(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}function A9(){const n=le.useContext(WS);if(n===null)return[!0,null];const{isPresent:e,onExitComplete:t,register:i}=n,r=le.useId();return le.useEffect(()=>i(r),[]),!e&&t?[!1,()=>t&&t(r)]:[!0]}const iw={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function i3(n,e){return e.max===e.min?0:n/(e.max-e.min)*100}const Tg={correct:(n,e)=>{if(!e.target)return n;if(typeof n=="string")if($t.test(n))n=parseFloat(n);else return n;const t=i3(n,e.target.x),i=i3(n,e.target.y);return`${t}% ${i}%`}},b9={correct:(n,{treeScale:e,projectionDelta:t})=>{const i=n,r=au.parse(n);if(r.length>5)return i;const s=au.createTransformer(n),o=typeof r[0]!="number"?1:0,a=t.x.scale*e.x,l=t.y.scale*e.y;r[0+o]/=a,r[1+o]/=l;const c=Mi(a,l,.5);return typeof r[2+o]=="number"&&(r[2+o]/=c),typeof r[3+o]=="number"&&(r[3+o]/=c),s(r)}};class E9 extends Ke.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:i,layoutId:r}=this.props,{projection:s}=e;IG(T9),s&&(t.group&&t.group.add(s),i&&i.register&&r&&i.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),iw.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:i,drag:r,isPresent:s}=this.props,o=i.projection;return o&&(o.isPresent=s,r||e.layoutDependency!==t||t===void 0?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||vi.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),queueMicrotask(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:i}=this.props,{projection:r}=e;r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function kU(n){const[e,t]=A9(),i=le.useContext(iC);return Ke.createElement(E9,{...n,layoutGroup:i,switchLayoutGroup:le.useContext(bF),isPresent:e,safeToRemove:t})}const T9={borderRadius:{...Tg,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Tg,borderTopRightRadius:Tg,borderBottomLeftRadius:Tg,borderBottomRightRadius:Tg,boxShadow:b9},LU=["TopLeft","TopRight","BottomLeft","BottomRight"],C9=LU.length,r3=n=>typeof n=="string"?parseFloat(n):n,s3=n=>typeof n=="number"||$t.test(n);function P9(n,e,t,i,r,s){r?(n.opacity=Mi(0,t.opacity!==void 0?t.opacity:1,R9(i)),n.opacityExit=Mi(e.opacity!==void 0?e.opacity:1,0,k9(i))):s&&(n.opacity=Mi(e.opacity!==void 0?e.opacity:1,t.opacity!==void 0?t.opacity:1,i));for(let o=0;oie?1:t(X0(n,e,i))}function a3(n,e){n.min=e.min,n.max=e.max}function Oo(n,e){a3(n.x,e.x),a3(n.y,e.y)}function l3(n,e,t,i,r){return n-=e,n=tS(n,1/t,i),r!==void 0&&(n=tS(n,1/r,i)),n}function L9(n,e=0,t=1,i=.5,r,s=n,o=n){if(Za.test(e)&&(e=parseFloat(e),e=Mi(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=Mi(s.min,s.max,i);n===s&&(a-=e),n.min=l3(n.min,e,t,a,r),n.max=l3(n.max,e,t,a,r)}function c3(n,e,[t,i,r],s,o){L9(n,e[t],e[i],e[r],e.scale,s,o)}const I9=["x","scaleX","originX"],D9=["y","scaleY","originY"];function u3(n,e,t,i){c3(n.x,e,I9,t?t.x:void 0,i?i.x:void 0),c3(n.y,e,D9,t?t.y:void 0,i?i.y:void 0)}function h3(n){return n.translate===0&&n.scale===1}function DU(n){return h3(n.x)&&h3(n.y)}function VE(n,e){return n.x.min===e.x.min&&n.x.max===e.x.max&&n.y.min===e.y.min&&n.y.max===e.y.max}function f3(n){return co(n.x)/co(n.y)}class O9{constructor(){this.members=[]}add(e){vC(this.members,e),e.scheduleRender()}remove(e){if(xC(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 i;for(let r=t;r>=0;r--){const s=this.members[r];if(s.isPresent!==!1){i=s;break}}return i?(this.promote(i),!0):!1}promote(e,t){const i=this.lead;if(e!==i&&(this.prevLead=i,this.lead=e,e.show(),i)){i.instance&&i.scheduleRender(),e.scheduleRender(),e.resumeFrom=i,t&&(e.resumeFrom.preserveOpacity=!0),i.snapshot&&(e.snapshot=i.snapshot,e.snapshot.latestValues=i.animationValues||i.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:r}=e.options;r===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:t,resumingFrom:i}=e;t.onExitComplete&&t.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function d3(n,e,t){let i="";const r=n.x.translate/e.x,s=n.y.translate/e.y;if((r||s)&&(i=`translate3d(${r}px, ${s}px, 0) `),(e.x!==1||e.y!==1)&&(i+=`scale(${1/e.x}, ${1/e.y}) `),t){const{rotate:l,rotateX:c,rotateY:u}=t;l&&(i+=`rotate(${l}deg) `),c&&(i+=`rotateX(${c}deg) `),u&&(i+=`rotateY(${u}deg) `)}const o=n.x.scale*e.x,a=n.y.scale*e.y;return(o!==1||a!==1)&&(i+=`scale(${o}, ${a})`),i||"none"}const N9=(n,e)=>n.depth-e.depth;class F9{constructor(){this.children=[],this.isDirty=!1}add(e){vC(this.children,e),this.isDirty=!0}remove(e){xC(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(N9),this.isDirty=!1,this.children.forEach(e)}}function U9(n,e){const t=performance.now(),i=({timestamp:r})=>{const s=r-t;s>=e&&(jl(i),n(s-e))};return vi.read(i,!0),()=>jl(i)}function z9(n){window.MotionDebug&&window.MotionDebug.record(n)}function B9(n){return n instanceof SVGElement&&n.tagName!=="svg"}function V9(n,e,t){const i=Ns(n)?n:Yp(n);return i.start(yC("",i,e,t)),i.animation}const p3=["","X","Y","Z"],m3=1e3;let H9=0;const wh={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0};function OU({attachResizeListener:n,defaultParent:e,measureScroll:t,checkIsScrollRoot:i,resetTransform:r}){return class{constructor(o={},a=e==null?void 0:e()){this.id=H9++,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.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{wh.totalNodes=wh.resolvedTargetDeltas=wh.recalculatedProjection=0,this.nodes.forEach(j9),this.nodes.forEach(Z9),this.nodes.forEach(J9),this.nodes.forEach(X9),z9(wh)},this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;lthis.root.updateBlockedByResize=!1;n(o,()=>{this.root.updateBlockedByResize=!0,f&&f(),f=U9(g,250),iw.hasAnimatedSinceResize&&(iw.hasAnimatedSinceResize=!1,this.nodes.forEach(y3))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&u&&(l||c)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:g,hasRelativeTargetChanged:y,layout:v})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const w=this.options.transition||u.getDefaultTransition()||nj,{onLayoutAnimationStart:S,onLayoutAnimationComplete:x}=u.getProps(),M=!this.targetLayout||!VE(this.targetLayout,v)||y,A=!g&&y;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||A||g&&(M||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(f,A);const C={...SU(w,"layout"),onPlay:S,onComplete:x};(u.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C)}else g||y3(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=v})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,jl(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(Q9),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;uthis.update()))}clearAllSnapshots(){this.nodes.forEach(q9),this.sharedNodes.forEach($9)}scheduleUpdateProjection(){vi.preRender(this.updateProjection,!1,!0)}scheduleCheckAfterUnmount(){vi.postRender(()=>{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 l=0;l{const N=C/1e3;v3(f.x,o.x,N),v3(f.y,o.y,N),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(v0(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ej(this.relativeTarget,this.relativeTargetOrigin,g,N),A&&VE(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=$i()),Oo(A,this.relativeTarget)),w&&(this.animationValues=u,P9(u,c,this.latestValues,N,M,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=N},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(jl(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=vi.update(()=>{iw.hasAnimatedSinceResize=!0,this.currentAnimation=V9(0,m3,{...o,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(m3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&NU(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||$i();const f=co(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+f;const g=co(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+g}Oo(a,l),_p(a,u),y0(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new O9),this.sharedNodes.get(o).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.rotate||l.rotateX||l.rotateY||l.rotateZ)&&(a=!0),!a)return;const c={};for(let u=0;u{var a;return(a=o.currentAnimation)===null||a===void 0?void 0:a.stop()}),this.root.nodes.forEach(g3),this.root.sharedNodes.clear()}}}function G9(n){n.updateLayout()}function W9(n){var e;const t=((e=n.resumeFrom)===null||e===void 0?void 0:e.snapshot)||n.snapshot;if(n.isLead()&&n.layout&&t&&n.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:r}=n.layout,{animationType:s}=n.options,o=t.source!==n.layout.source;s==="size"?Va(f=>{const g=o?t.measuredBox[f]:t.layoutBox[f],y=co(g);g.min=i[f].min,g.max=g.min+y}):NU(s,t.layoutBox,i)&&Va(f=>{const g=o?t.measuredBox[f]:t.layoutBox[f],y=co(i[f]);g.max=g.min+y,n.relativeTarget&&!n.currentAnimation&&(n.isProjectionDirty=!0,n.relativeTarget[f].max=n.relativeTarget[f].min+y)});const a=Sp();y0(a,i,t.layoutBox);const l=Sp();o?y0(l,n.applyTransform(r,!0),t.measuredBox):y0(l,i,t.layoutBox);const c=!DU(a);let u=!1;if(!n.resumeFrom){const f=n.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:y}=f;if(g&&y){const v=$i();v0(v,t.layoutBox,g.layoutBox);const w=$i();v0(w,i,y.layoutBox),VE(v,w)||(u=!0),f.options.layoutRoot&&(n.relativeTarget=w,n.relativeTargetOrigin=v,n.relativeParent=f)}}}n.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:l,layoutDelta:a,hasLayoutChanged:c,hasRelativeTargetChanged:u})}else if(n.isLead()){const{onExitComplete:i}=n.options;i&&i()}n.options.transition=void 0}function j9(n){wh.totalNodes++,n.parent&&(n.isProjecting()||(n.isProjectionDirty=n.parent.isProjectionDirty),n.isSharedProjectionDirty||(n.isSharedProjectionDirty=!!(n.isProjectionDirty||n.parent.isProjectionDirty||n.parent.isSharedProjectionDirty)),n.isTransformDirty||(n.isTransformDirty=n.parent.isTransformDirty))}function X9(n){n.isProjectionDirty=n.isSharedProjectionDirty=n.isTransformDirty=!1}function q9(n){n.clearSnapshot()}function g3(n){n.clearMeasurements()}function Y9(n){n.isLayoutDirty=!1}function K9(n){const{visualElement:e}=n.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),n.resetTransform()}function y3(n){n.finishAnimation(),n.targetDelta=n.relativeTarget=n.target=void 0,n.isProjectionDirty=!0}function Z9(n){n.resolveTargetDelta()}function J9(n){n.calcProjection()}function Q9(n){n.resetRotation()}function $9(n){n.removeLeadSnapshot()}function v3(n,e,t){n.translate=Mi(e.translate,0,t),n.scale=Mi(e.scale,1,t),n.origin=e.origin,n.originPoint=e.originPoint}function x3(n,e,t,i){n.min=Mi(e.min,t.min,i),n.max=Mi(e.max,t.max,i)}function ej(n,e,t,i){x3(n.x,e.x,t.x,i),x3(n.y,e.y,t.y,i)}function tj(n){return n.animationValues&&n.animationValues.opacityExit!==void 0}const nj={duration:.45,ease:[.4,0,.1,1]};function w3(n){n.min=Math.round(n.min),n.max=Math.round(n.max)}function ij(n){w3(n.x),w3(n.y)}function NU(n,e,t){return n==="position"||n==="preserve-aspect"&&!FE(f3(e),f3(t),.2)}const rj=OU({attachResizeListener:(n,e)=>Nl(n,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),yA={current:void 0},FU=OU({measureScroll:n=>({x:n.scrollLeft,y:n.scrollTop}),defaultParent:()=>{if(!yA.current){const n=new rj({});n.mount(window),n.setOptions({layoutScroll:!0}),yA.current=n}return yA.current},resetTransform:(n,e)=>{n.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:n=>window.getComputedStyle(n).position==="fixed"}),sj={pan:{Feature:M9},drag:{Feature:_9,ProjectionNode:FU,MeasureLayout:kU}},oj=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;function aj(n){const e=oj.exec(n);if(!e)return[,];const[,t,i]=e;return[t,i]}function HE(n,e,t=1){const[i,r]=aj(n);if(!i)return;const s=window.getComputedStyle(e).getPropertyValue(i);return s?s.trim():PE(r)?HE(r,e,t+1):r}function lj(n,{...e},t){const i=n.current;if(!(i instanceof Element))return{target:e,transitionEnd:t};t&&(t={...t}),n.values.forEach(r=>{const s=r.get();if(!PE(s))return;const o=HE(s,i);o&&r.set(o)});for(const r in e){const s=e[r];if(!PE(s))continue;const o=HE(s,i);o&&(e[r]=o,t||(t={}),t[r]===void 0&&(t[r]=s))}return{target:e,transitionEnd:t}}const cj=new Set(["width","height","top","left","right","bottom","x","y","translateX","translateY"]),UU=n=>cj.has(n),uj=n=>Object.keys(n).some(UU),S3=n=>n===uf||n===$t,_3=(n,e)=>parseFloat(n.split(", ")[e]),M3=(n,e)=>(t,{transform:i})=>{if(i==="none"||!i)return 0;const r=i.match(/^matrix3d\((.+)\)$/);if(r)return _3(r[1],e);{const s=i.match(/^matrix\((.+)\)$/);return s?_3(s[1],n):0}},hj=new Set(["x","y","z"]),fj=_y.filter(n=>!hj.has(n));function dj(n){const e=[];return fj.forEach(t=>{const i=n.getValue(t);i!==void 0&&(e.push([t,i.get()]),i.set(t.startsWith("scale")?1:0))}),e.length&&n.render(),e}const A3={width:({x:n},{paddingLeft:e="0",paddingRight:t="0"})=>n.max-n.min-parseFloat(e)-parseFloat(t),height:({y:n},{paddingTop:e="0",paddingBottom:t="0"})=>n.max-n.min-parseFloat(e)-parseFloat(t),top:(n,{top:e})=>parseFloat(e),left:(n,{left:e})=>parseFloat(e),bottom:({y:n},{top:e})=>parseFloat(e)+(n.max-n.min),right:({x:n},{left:e})=>parseFloat(e)+(n.max-n.min),x:M3(4,13),y:M3(5,14)},pj=(n,e,t)=>{const i=e.measureViewportBox(),r=e.current,s=getComputedStyle(r),{display:o}=s,a={};o==="none"&&e.setStaticValue("display",n.display||"block"),t.forEach(c=>{a[c]=A3[c](i,s)}),e.render();const l=e.measureViewportBox();return t.forEach(c=>{const u=e.getValue(c);u&&u.jump(a[c]),n[c]=A3[c](l,s)}),n},mj=(n,e,t={},i={})=>{e={...e},i={...i};const r=Object.keys(e).filter(UU);let s=[],o=!1;const a=[];if(r.forEach(l=>{const c=n.getValue(l);if(!n.hasValue(l))return;let u=t[l],f=Eg(u);const g=e[l];let y;if(Zw(g)){const v=g.length,w=g[0]===null?1:0;u=g[w],f=Eg(u);for(let S=w;S=0?window.pageYOffset:null,c=pj(e,n,a);return s.length&&s.forEach(([u,f])=>{n.getValue(u).set(f)}),n.render(),jS&&l!==null&&window.scrollTo({top:l}),{target:c,transitionEnd:i}}else return{target:e,transitionEnd:i}};function gj(n,e,t,i){return uj(e)?mj(n,e,t,i):{target:e,transitionEnd:i}}const yj=(n,e,t,i)=>{const r=lj(n,e,i);return e=r.target,i=r.transitionEnd,gj(n,e,t,i)},GE={current:null},zU={current:!1};function vj(){if(zU.current=!0,!!jS)if(window.matchMedia){const n=window.matchMedia("(prefers-reduced-motion)"),e=()=>GE.current=n.matches;n.addListener(e),e()}else GE.current=!1}function xj(n,e,t){const{willChange:i}=e;for(const r in e){const s=e[r],o=t[r];if(Ns(s))n.addValue(r,s),eS(i)&&i.add(r);else if(Ns(o))n.addValue(r,Yp(s,{owner:n})),eS(i)&&i.remove(r);else if(o!==s)if(n.hasValue(r)){const a=n.getValue(r);!a.hasAnimated&&a.set(s)}else{const a=n.getStaticValue(r);n.addValue(r,Yp(a!==void 0?a:s,{owner:n}))}}for(const r in t)e[r]===void 0&&n.removeValue(r);return e}const b3=new WeakMap,BU=Object.keys(W0),wj=BU.length,E3=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],Sj=nC.length;class _j{constructor({parent:e,props:t,presenceContext:i,reducedMotionConfig:r,visualState:s},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,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.scheduleRender=()=>vi.render(this.render,!1,!0);const{latestValues:a,renderState:l}=s;this.latestValues=a,this.baseTarget={...a},this.initialValues=t.initial?{...a}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=i,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=o,this.isControllingVariants=qS(t),this.isVariantNode=AF(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...u}=this.scrapeMotionValuesFromProps(t,{});for(const f in u){const g=u[f];a[f]!==void 0&&Ns(g)&&(g.set(a[f],!1),eS(c)&&c.add(f))}}scrapeMotionValuesFromProps(e,t){return{}}mount(e){this.current=e,b3.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((t,i)=>this.bindToMotionValue(i,t)),zU.current||vj(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:GE.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){b3.delete(this.current),this.projection&&this.projection.unmount(),jl(this.notifyUpdate),jl(this.render),this.valueSubscriptions.forEach(e=>e()),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)this.features[e].unmount();this.current=null}bindToMotionValue(e,t){const i=cf.has(e),r=t.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&vi.update(this.notifyUpdate,!1,!0),i&&this.projection&&(this.projection.isTransformDirty=!0)}),s=t.on("renderRequest",this.scheduleRender);this.valueSubscriptions.set(e,()=>{r(),s()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}loadFeatures({children:e,...t},i,r,s){let o,a;for(let l=0;lthis.scheduleRender(),animationType:typeof c=="string"?c:"both",initialPromotionConfig:s,layoutScroll:g,layoutRoot:y})}return a}updateFeatures(){for(const e in this.features){const t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}triggerBuild(){this.build(this.renderState,this.latestValues,this.options,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):$i()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}makeTargetAnimatable(e,t=!0){return this.makeTargetAnimatableFromInstance(e,this.props,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 i=0;it.variantChildren.delete(e)}addValue(e,t){t!==this.values.get(e)&&(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 i=this.values.get(e);return i===void 0&&t!==void 0&&(i=Yp(t,{owner:this}),this.addValue(e,i)),i}readValue(e){return this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.readValueFromInstance(this.current,e,this.options)}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){var t;const{initial:i}=this.props,r=typeof i=="string"||typeof i=="object"?(t=hC(this.props,i))===null||t===void 0?void 0:t[e]:void 0;if(i&&r!==void 0)return r;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!Ns(s)?s:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new wC),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}}class VU extends _j{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:i}){delete t[e],delete i[e]}makeTargetAnimatableFromInstance({transition:e,transitionEnd:t,...i},{transformValues:r},s){let o=HW(i,e||{},this);if(r&&(t&&(t=r(t)),i&&(i=r(i)),o&&(o=r(o))),s){BW(this,i,o);const a=yj(this,i,o,t);t=a.transitionEnd,i=a.target}return{transition:e,transitionEnd:t,...i}}}function Mj(n){return window.getComputedStyle(n)}class Aj extends VU{readValueFromInstance(e,t){if(cf.has(t)){const i=gC(t);return i&&i.default||0}else{const i=Mj(e),r=(CF(t)?i.getPropertyValue(t):i[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return RU(e,t)}build(e,t,i,r){sC(e,t,i,r.transformTemplate)}scrapeMotionValuesFromProps(e,t){return uC(e,t)}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Ns(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}renderInstance(e,t,i,r){DF(e,t,i,r)}}class bj extends VU{constructor(){super(...arguments),this.isSVGTag=!1}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(cf.has(t)){const i=gC(t);return i&&i.default||0}return t=OF.has(t)?t:cC(t),e.getAttribute(t)}measureInstanceViewportBox(){return $i()}scrapeMotionValuesFromProps(e,t){return FF(e,t)}build(e,t,i,r){aC(e,t,i,this.isSVGTag,r.transformTemplate)}renderInstance(e,t,i,r){NF(e,t,i,r)}mount(e){this.isSVGTag=lC(e.tagName),super.mount(e)}}const Ej=(n,e)=>rC(n)?new bj(e,{enableHardwareAcceleration:!1}):new Aj(e,{enableHardwareAcceleration:!0}),Tj={layout:{ProjectionNode:FU,MeasureLayout:kU}},Cj={...n9,...M8,...sj,...Tj},QS=kG((n,e)=>o8(n,e,Cj,Ej));function HU(){const n=le.useRef(!1);return qw(()=>(n.current=!0,()=>{n.current=!1}),[]),n}function Pj(){const n=HU(),[e,t]=le.useState(0),i=le.useCallback(()=>{n.current&&t(e+1)},[e]);return[le.useCallback(()=>vi.postRender(i),[i]),e]}class Rj extends le.Component{getSnapshotBeforeUpdate(e){const t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){const i=this.props.sizeRef.current;i.height=t.offsetHeight||0,i.width=t.offsetWidth||0,i.top=t.offsetTop,i.left=t.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function kj({children:n,isPresent:e}){const t=le.useId(),i=le.useRef(null),r=le.useRef({width:0,height:0,top:0,left:0});return le.useInsertionEffect(()=>{const{width:s,height:o,top:a,left:l}=r.current;if(e||!i.current||!s||!o)return;i.current.dataset.motionPopId=t;const c=document.createElement("style");return document.head.appendChild(c),c.sheet&&c.sheet.insertRule(` + [data-motion-pop-id="${t}"] { + position: absolute !important; + width: ${s}px !important; + height: ${o}px !important; + top: ${a}px !important; + left: ${l}px !important; + } + `),()=>{document.head.removeChild(c)}},[e]),le.createElement(Rj,{isPresent:e,childRef:i,sizeRef:r},le.cloneElement(n,{ref:i}))}const vA=({children:n,initial:e,isPresent:t,onExitComplete:i,custom:r,presenceAffectsLayout:s,mode:o})=>{const a=UF(Lj),l=le.useId(),c=le.useMemo(()=>({id:l,initial:e,isPresent:t,custom:r,onExitComplete:u=>{a.set(u,!0);for(const f of a.values())if(!f)return;i&&i()},register:u=>(a.set(u,!1),()=>a.delete(u))}),s?void 0:[t]);return le.useMemo(()=>{a.forEach((u,f)=>a.set(f,!1))},[t]),le.useEffect(()=>{!t&&!a.size&&i&&i()},[t]),o==="popLayout"&&(n=le.createElement(kj,{isPresent:t},n)),le.createElement(WS.Provider,{value:c},n)};function Lj(){return new Map}function Ij(n){return le.useEffect(()=>()=>n(),[])}const ip=n=>n.key||"";function Dj(n,e){n.forEach(t=>{const i=ip(t);e.set(i,t)})}function Oj(n){const e=[];return le.Children.forEach(n,t=>{le.isValidElement(t)&&e.push(t)}),e}const Dx=({children:n,custom:e,initial:t=!0,onExitComplete:i,exitBeforeEnter:r,presenceAffectsLayout:s=!0,mode:o="sync"})=>{const a=le.useContext(iC).forceRender||Pj()[0],l=HU(),c=Oj(n);let u=c;const f=le.useRef(new Map).current,g=le.useRef(u),y=le.useRef(new Map).current,v=le.useRef(!0);if(qw(()=>{v.current=!1,Dj(c,y),g.current=u}),Ij(()=>{v.current=!0,y.clear(),f.clear()}),v.current)return le.createElement(le.Fragment,null,u.map(M=>le.createElement(vA,{key:ip(M),isPresent:!0,initial:t?void 0:!1,presenceAffectsLayout:s,mode:o},M)));u=[...u];const w=g.current.map(ip),S=c.map(ip),x=w.length;for(let M=0;M{if(S.indexOf(A)!==-1)return;const C=y.get(A);if(!C)return;const N=w.indexOf(A);let L=M;if(!L){const F=()=>{y.delete(A),f.delete(A);const H=g.current.findIndex(I=>I.key===A);if(g.current.splice(H,1),!f.size){if(g.current=c,l.current===!1)return;a(),i&&i()}};L=le.createElement(vA,{key:ip(C),isPresent:!1,onExitComplete:F,custom:e,presenceAffectsLayout:s,mode:o},C),f.set(A,L)}u.splice(N,0,L)}),u=u.map(M=>{const A=M.key;return f.has(A)?M:le.createElement(vA,{key:ip(M),isPresent:!0,presenceAffectsLayout:s,mode:o},M)}),le.createElement(le.Fragment,null,f.size?u:u.map(M=>le.cloneElement(M)))};/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */const $S="164",Nj={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Fj={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},GU=0,WE=1,WU=2,Uj=3,jU=0,e_=1,x0=2,fa=3,il=0,ws=1,va=2,Ja=0,Vh=1,jE=2,XE=3,qE=4,XU=5,Bc=100,qU=101,YU=102,KU=103,ZU=104,JU=200,QU=201,$U=202,e4=203,nS=204,iS=205,t4=206,n4=207,i4=208,r4=209,s4=210,o4=211,a4=212,l4=213,c4=214,u4=0,h4=1,f4=2,q0=3,d4=4,p4=5,m4=6,g4=7,Ey=0,y4=1,v4=2,Qa=0,x4=1,w4=2,S4=3,SC=4,_4=5,M4=6,A4=7,YE="attached",b4="detached",t_=300,Xl=301,lu=302,Y0=303,K0=304,hm=306,cu=1e3,io=1001,Kp=1002,Wi=1003,n_=1004,zj=1004,Lh=1005,Bj=1005,Ni=1006,Dp=1007,Vj=1007,Wo=1008,Hj=1008,rl=1009,E4=1010,T4=1011,_C=1012,MC=1013,Qh=1014,jo=1015,hf=1016,AC=1017,bC=1018,fm=1020,C4=35902,P4=1021,R4=1022,vs=1023,k4=1024,L4=1025,Hh=1026,Zp=1027,EC=1028,TC=1029,I4=1030,CC=1031,PC=1033,rw=33776,sw=33777,ow=33778,aw=33779,KE=35840,ZE=35841,JE=35842,QE=35843,$E=36196,eT=37492,tT=37496,nT=37808,iT=37809,rT=37810,sT=37811,oT=37812,aT=37813,lT=37814,cT=37815,uT=37816,hT=37817,fT=37818,dT=37819,pT=37820,mT=37821,lw=36492,gT=36494,yT=36495,D4=36283,vT=36284,xT=36285,wT=36286,O4=2200,N4=2201,F4=2202,Jp=2300,$h=2301,cw=2302,Ih=2400,Dh=2401,Z0=2402,i_=2500,RC=2501,U4=0,kC=1,rS=2,z4=3200,B4=3201,vu=0,V4=1,Ll="",hr="srgb",mr="srgb-linear",r_="display-p3",Ty="display-p3-linear",J0="linear",si="srgb",Q0="rec709",$0="p3",Gj=0,Sh=7680,Wj=7681,jj=7682,Xj=7683,qj=34055,Yj=34056,Kj=5386,Zj=512,Jj=513,Qj=514,$j=515,e7=516,t7=517,n7=518,ST=519,H4=512,G4=513,W4=514,LC=515,j4=516,X4=517,q4=518,Y4=519,ey=35044,i7=35048,r7=35040,s7=35045,o7=35049,a7=35041,l7=35046,c7=35050,u7=35042,h7="100",_T="300 es",ja=2e3,ty=2001;class Jl{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,o=r.length;s>8&255]+Xr[n>>16&255]+Xr[n>>24&255]+"-"+Xr[e&255]+Xr[e>>8&255]+"-"+Xr[e>>16&15|64]+Xr[e>>24&255]+"-"+Xr[t&63|128]+Xr[t>>8&255]+"-"+Xr[t>>16&255]+Xr[t>>24&255]+Xr[i&255]+Xr[i>>8&255]+Xr[i>>16&255]+Xr[i>>24&255]).toLowerCase()}function Oi(n,e,t){return Math.max(e,Math.min(t,n))}function IC(n,e){return(n%e+e)%e}function f7(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function d7(n,e,t){return n!==e?(t-n)/(e-n):0}function w0(n,e,t){return(1-t)*n+t*e}function p7(n,e,t,i){return w0(n,e,1-Math.exp(-t*i))}function m7(n,e=1){return e-Math.abs(IC(n,e*2)-e)}function g7(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function y7(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function v7(n,e){return n+Math.floor(Math.random()*(e-n+1))}function x7(n,e){return n+Math.random()*(e-n)}function w7(n){return n*(.5-Math.random())}function S7(n){n!==void 0&&(T3=n);let e=T3+=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 _7(n){return n*Gh}function M7(n){return n*Qp}function A7(n){return(n&n-1)===0&&n!==0}function b7(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function E7(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function T7(n,e,t,i,r){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+i)/2),u=o((e+i)/2),f=s((e-i)/2),g=o((e-i)/2),y=s((i-e)/2),v=o((i-e)/2);switch(r){case"XYX":n.set(a*u,l*f,l*g,a*c);break;case"YZY":n.set(l*g,a*u,l*f,a*c);break;case"ZXZ":n.set(l*f,l*g,a*u,a*c);break;case"XZX":n.set(a*u,l*v,l*y,a*c);break;case"YXY":n.set(l*y,a*u,l*v,a*c);break;case"ZYZ":n.set(l*v,l*y,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function gs(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function fn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const bh={DEG2RAD:Gh,RAD2DEG:Qp,generateUUID:oo,clamp:Oi,euclideanModulo:IC,mapLinear:f7,inverseLerp:d7,lerp:w0,damp:p7,pingpong:m7,smoothstep:g7,smootherstep:y7,randInt:v7,randFloat:x7,randFloatSpread:w7,seededRandom:S7,degToRad:_7,radToDeg:M7,isPowerOfTwo:A7,ceilPowerOfTwo:b7,floorPowerOfTwo:E7,setQuaternionFromProperEuler:T7,normalize:fn,denormalize:gs};class Be{constructor(e=0,t=0){Be.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Oi(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hn{constructor(e,t,i,r,s,o,a,l,c){hn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c)}set(e,t,i,r,s,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],f=i[7],g=i[2],y=i[5],v=i[8],w=r[0],S=r[3],x=r[6],M=r[1],A=r[4],C=r[7],N=r[2],L=r[5],F=r[8];return s[0]=o*w+a*M+l*N,s[3]=o*S+a*A+l*L,s[6]=o*x+a*C+l*F,s[1]=c*w+u*M+f*N,s[4]=c*S+u*A+f*L,s[7]=c*x+u*C+f*F,s[2]=g*w+y*M+v*N,s[5]=g*S+y*A+v*L,s[8]=g*x+y*C+v*F,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-i*s*u+i*a*l+r*s*c-r*o*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],f=u*o-a*c,g=a*l-u*s,y=c*s-o*l,v=t*f+i*g+r*y;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/v;return e[0]=f*w,e[1]=(r*c-u*i)*w,e[2]=(a*i-r*o)*w,e[3]=g*w,e[4]=(u*t-r*l)*w,e[5]=(r*s-a*t)*w,e[6]=y*w,e[7]=(i*l-c*t)*w,e[8]=(o*t-i*s)*w,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(xA.makeScale(e,t)),this}rotate(e){return this.premultiply(xA.makeRotation(-e)),this}translate(e,t){return this.premultiply(xA.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const xA=new hn;function K4(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const C7={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Mp(n,e){return new C7[n](e)}function ny(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Z4(){const n=ny("canvas");return n.style.display="block",n}const C3={};function J4(n){n in C3||(C3[n]=!0,console.warn(n))}const P3=new hn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),R3=new hn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ox={[mr]:{transfer:J0,primaries:Q0,toReference:n=>n,fromReference:n=>n},[hr]:{transfer:si,primaries:Q0,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Ty]:{transfer:J0,primaries:$0,toReference:n=>n.applyMatrix3(R3),fromReference:n=>n.applyMatrix3(P3)},[r_]:{transfer:si,primaries:$0,toReference:n=>n.convertSRGBToLinear().applyMatrix3(R3),fromReference:n=>n.applyMatrix3(P3).convertLinearToSRGB()}},P7=new Set([mr,Ty]),Vn={enabled:!0,_workingColorSpace:mr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!P7.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=Ox[e].toReference,r=Ox[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Ox[n].primaries},getTransfer:function(n){return n===Ll?J0:Ox[n].transfer}};function Op(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function wA(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Ad;class Q4{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ad===void 0&&(Ad=ny("canvas")),Ad.width=e.width,Ad.height=e.height;const i=Ad.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Ad}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=ny("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==t_)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case cu:e.x=e.x-Math.floor(e.x);break;case io:e.x=e.x<0?0:1;break;case Kp: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 cu:e.y=e.y-Math.floor(e.y);break;case io:e.y=e.y<0?0:1;break;case Kp: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++}}hi.DEFAULT_IMAGE=null;hi.DEFAULT_MAPPING=t_;hi.DEFAULT_ANISOTROPY=1;class qn{constructor(e=0,t=0,i=0,r=1){qn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const l=e.elements,c=l[0],u=l[4],f=l[8],g=l[1],y=l[5],v=l[9],w=l[2],S=l[6],x=l[10];if(Math.abs(u-g)<.01&&Math.abs(f-w)<.01&&Math.abs(v-S)<.01){if(Math.abs(u+g)<.1&&Math.abs(f+w)<.1&&Math.abs(v+S)<.1&&Math.abs(c+y+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(c+1)/2,C=(y+1)/2,N=(x+1)/2,L=(u+g)/4,F=(f+w)/4,H=(v+S)/4;return A>C&&A>N?A<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(A),r=L/i,s=F/i):C>N?C<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(C),i=L/r,s=H/r):N<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(N),i=F/s,r=H/s),this.set(i,r,s,t),this}let M=Math.sqrt((S-v)*(S-v)+(f-w)*(f-w)+(g-u)*(g-u));return Math.abs(M)<.001&&(M=1),this.x=(S-v)/M,this.y=(f-w)/M,this.z=(g-u)/M,this.w=Math.acos((c+y+x-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class $4 extends Jl{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new qn(0,0,e,t),this.scissorTest=!1,this.viewport=new qn(0,0,e,t);const r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ni,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const s=new hi(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];const o=i.count;for(let a=0;a=0?1:-1,A=1-x*x;if(A>Number.EPSILON){const N=Math.sqrt(A),L=Math.atan2(N,x*M);S=Math.sin(S*L)/N,a=Math.sin(a*L)/N}const C=a*M;if(l=l*S+g*C,c=c*S+y*C,u=u*S+v*C,f=f*S+w*C,S===1-a){const N=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=N,c*=N,u*=N,f*=N}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,r,s,o){const a=i[r],l=i[r+1],c=i[r+2],u=i[r+3],f=s[o],g=s[o+1],y=s[o+2],v=s[o+3];return e[t]=a*v+u*f+l*y-c*g,e[t+1]=l*v+u*g+c*f-a*y,e[t+2]=c*v+u*y+a*g-l*f,e[t+3]=u*v-a*f-l*g-c*y,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(r/2),f=a(s/2),g=l(i/2),y=l(r/2),v=l(s/2);switch(o){case"XYZ":this._x=g*u*f+c*y*v,this._y=c*y*f-g*u*v,this._z=c*u*v+g*y*f,this._w=c*u*f-g*y*v;break;case"YXZ":this._x=g*u*f+c*y*v,this._y=c*y*f-g*u*v,this._z=c*u*v-g*y*f,this._w=c*u*f+g*y*v;break;case"ZXY":this._x=g*u*f-c*y*v,this._y=c*y*f+g*u*v,this._z=c*u*v+g*y*f,this._w=c*u*f-g*y*v;break;case"ZYX":this._x=g*u*f-c*y*v,this._y=c*y*f+g*u*v,this._z=c*u*v-g*y*f,this._w=c*u*f+g*y*v;break;case"YZX":this._x=g*u*f+c*y*v,this._y=c*y*f+g*u*v,this._z=c*u*v-g*y*f,this._w=c*u*f-g*y*v;break;case"XZY":this._x=g*u*f-c*y*v,this._y=c*y*f-g*u*v,this._z=c*u*v+g*y*f,this._w=c*u*f+g*y*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],f=t[10],g=i+a+f;if(g>0){const y=.5/Math.sqrt(g+1);this._w=.25/y,this._x=(u-l)*y,this._y=(s-c)*y,this._z=(o-r)*y}else if(i>a&&i>f){const y=2*Math.sqrt(1+i-a-f);this._w=(u-l)/y,this._x=.25*y,this._y=(r+o)/y,this._z=(s+c)/y}else if(a>f){const y=2*Math.sqrt(1+a-i-f);this._w=(s-c)/y,this._x=(r+o)/y,this._y=.25*y,this._z=(l+u)/y}else{const y=2*Math.sqrt(1+f-i-a);this._w=(o-r)/y,this._x=(s+c)/y,this._y=(l+u)/y,this._z=.25*y}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Oi(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-r*a,this._w=o*u-i*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const y=1-t;return this._w=y*o+t*this._w,this._x=y*i+t*this._x,this._y=y*r+t*this._y,this._z=y*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),f=Math.sin((1-t)*u)/c,g=Math.sin(t*u)/c;return this._w=o*f+this._w*g,this._x=i*f+this._x*g,this._y=r*f+this._y*g,this._z=s*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Q{constructor(e=0,t=0,i=0){Q.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(k3.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(k3.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*i),u=2*(a*t-s*r),f=2*(s*i-o*t);return this.x=t+l*c+o*f-a*u,this.y=i+l*u+a*c-s*f,this.z=r+l*f+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-i*l,this.z=i*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return _A.copy(this).projectOnVector(e),this.sub(_A)}reflect(e){return this.sub(_A.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Oi(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _A=new Q,k3=new Qr;class $r{constructor(e=new Q(1/0,1/0,1/0),t=new Q(-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,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,aa),aa.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Cg),Fx.subVectors(this.max,Cg),bd.subVectors(e.a,Cg),Ed.subVectors(e.b,Cg),Td.subVectors(e.c,Cg),Sc.subVectors(Ed,bd),_c.subVectors(Td,Ed),nh.subVectors(bd,Td);let t=[0,-Sc.z,Sc.y,0,-_c.z,_c.y,0,-nh.z,nh.y,Sc.z,0,-Sc.x,_c.z,0,-_c.x,nh.z,0,-nh.x,-Sc.y,Sc.x,0,-_c.y,_c.x,0,-nh.y,nh.x,0];return!MA(t,bd,Ed,Td,Fx)||(t=[1,0,0,0,1,0,0,0,1],!MA(t,bd,Ed,Td,Fx))?!1:(Ux.crossVectors(Sc,_c),t=[Ux.x,Ux.y,Ux.z],MA(t,bd,Ed,Td,Fx))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,aa).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(aa).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:(Ml[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ml[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ml[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ml[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ml[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ml[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ml[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ml[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ml),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 Ml=[new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q],aa=new Q,Nx=new $r,bd=new Q,Ed=new Q,Td=new Q,Sc=new Q,_c=new Q,nh=new Q,Cg=new Q,Fx=new Q,Ux=new Q,ih=new Q;function MA(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){ih.fromArray(n,s);const a=r.x*Math.abs(ih.x)+r.y*Math.abs(ih.y)+r.z*Math.abs(ih.z),l=e.dot(ih),c=t.dot(ih),u=i.dot(ih);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const D7=new $r,Pg=new Q,AA=new Q;class Ur{constructor(e=new Q,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):D7.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Pg.subVectors(e,this.center);const t=Pg.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Pg,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(AA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Pg.copy(e.center).add(AA)),this.expandByPoint(Pg.copy(e.center).sub(AA))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Al=new Q,bA=new Q,zx=new Q,Mc=new Q,EA=new Q,Bx=new Q,TA=new Q;class dm{constructor(e=new Q,t=new Q(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Al)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Al.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Al.copy(this.origin).addScaledVector(this.direction,t),Al.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){bA.copy(e).add(t).multiplyScalar(.5),zx.copy(t).sub(e).normalize(),Mc.copy(this.origin).sub(bA);const s=e.distanceTo(t)*.5,o=-this.direction.dot(zx),a=Mc.dot(this.direction),l=-Mc.dot(zx),c=Mc.lengthSq(),u=Math.abs(1-o*o);let f,g,y,v;if(u>0)if(f=o*l-a,g=o*a-l,v=s*u,f>=0)if(g>=-v)if(g<=v){const w=1/u;f*=w,g*=w,y=f*(f+o*g+2*a)+g*(o*f+g+2*l)+c}else g=s,f=Math.max(0,-(o*g+a)),y=-f*f+g*(g+2*l)+c;else g=-s,f=Math.max(0,-(o*g+a)),y=-f*f+g*(g+2*l)+c;else g<=-v?(f=Math.max(0,-(-o*s+a)),g=f>0?-s:Math.min(Math.max(-s,-l),s),y=-f*f+g*(g+2*l)+c):g<=v?(f=0,g=Math.min(Math.max(-s,-l),s),y=g*(g+2*l)+c):(f=Math.max(0,-(o*s+a)),g=f>0?s:Math.min(Math.max(-s,-l),s),y=-f*f+g*(g+2*l)+c);else g=o>0?-s:s,f=Math.max(0,-(o*g+a)),y=-f*f+g*(g+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(bA).addScaledVector(zx,g),y}intersectSphere(e,t){Al.subVectors(e.center,this.origin);const i=Al.dot(this.direction),r=Al.dot(Al)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,g=this.origin;return c>=0?(i=(e.min.x-g.x)*c,r=(e.max.x-g.x)*c):(i=(e.max.x-g.x)*c,r=(e.min.x-g.x)*c),u>=0?(s=(e.min.y-g.y)*u,o=(e.max.y-g.y)*u):(s=(e.max.y-g.y)*u,o=(e.min.y-g.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o=0?(a=(e.min.z-g.z)*f,l=(e.max.z-g.z)*f):(a=(e.max.z-g.z)*f,l=(e.min.z-g.z)*f),i>l||a>r)||((a>i||i!==i)&&(i=a),(l=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Al)!==null}intersectTriangle(e,t,i,r,s){EA.subVectors(t,e),Bx.subVectors(i,e),TA.crossVectors(EA,Bx);let o=this.direction.dot(TA),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Mc.subVectors(this.origin,e);const l=a*this.direction.dot(Bx.crossVectors(Mc,Bx));if(l<0)return null;const c=a*this.direction.dot(EA.cross(Mc));if(c<0||l+c>o)return null;const u=-a*Mc.dot(TA);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wt{constructor(e,t,i,r,s,o,a,l,c,u,f,g,y,v,w,S){Wt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c,u,f,g,y,v,w,S)}set(e,t,i,r,s,o,a,l,c,u,f,g,y,v,w,S){const x=this.elements;return x[0]=e,x[4]=t,x[8]=i,x[12]=r,x[1]=s,x[5]=o,x[9]=a,x[13]=l,x[2]=c,x[6]=u,x[10]=f,x[14]=g,x[3]=y,x[7]=v,x[11]=w,x[15]=S,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Wt().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/Cd.setFromMatrixColumn(e,0).length(),s=1/Cd.setFromMatrixColumn(e,1).length(),o=1/Cd.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const g=o*u,y=o*f,v=a*u,w=a*f;t[0]=l*u,t[4]=-l*f,t[8]=c,t[1]=y+v*c,t[5]=g-w*c,t[9]=-a*l,t[2]=w-g*c,t[6]=v+y*c,t[10]=o*l}else if(e.order==="YXZ"){const g=l*u,y=l*f,v=c*u,w=c*f;t[0]=g+w*a,t[4]=v*a-y,t[8]=o*c,t[1]=o*f,t[5]=o*u,t[9]=-a,t[2]=y*a-v,t[6]=w+g*a,t[10]=o*l}else if(e.order==="ZXY"){const g=l*u,y=l*f,v=c*u,w=c*f;t[0]=g-w*a,t[4]=-o*f,t[8]=v+y*a,t[1]=y+v*a,t[5]=o*u,t[9]=w-g*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const g=o*u,y=o*f,v=a*u,w=a*f;t[0]=l*u,t[4]=v*c-y,t[8]=g*c+w,t[1]=l*f,t[5]=w*c+g,t[9]=y*c-v,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const g=o*l,y=o*c,v=a*l,w=a*c;t[0]=l*u,t[4]=w-g*f,t[8]=v*f+y,t[1]=f,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=y*f+v,t[10]=g-w*f}else if(e.order==="XZY"){const g=o*l,y=o*c,v=a*l,w=a*c;t[0]=l*u,t[4]=-f,t[8]=c*u,t[1]=g*f+w,t[5]=o*u,t[9]=y*f-v,t[2]=v*f-y,t[6]=a*u,t[10]=w*f+g}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(O7,e,N7)}lookAt(e,t,i){const r=this.elements;return Ks.subVectors(e,t),Ks.lengthSq()===0&&(Ks.z=1),Ks.normalize(),Ac.crossVectors(i,Ks),Ac.lengthSq()===0&&(Math.abs(i.z)===1?Ks.x+=1e-4:Ks.z+=1e-4,Ks.normalize(),Ac.crossVectors(i,Ks)),Ac.normalize(),Vx.crossVectors(Ks,Ac),r[0]=Ac.x,r[4]=Vx.x,r[8]=Ks.x,r[1]=Ac.y,r[5]=Vx.y,r[9]=Ks.y,r[2]=Ac.z,r[6]=Vx.z,r[10]=Ks.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],f=i[5],g=i[9],y=i[13],v=i[2],w=i[6],S=i[10],x=i[14],M=i[3],A=i[7],C=i[11],N=i[15],L=r[0],F=r[4],H=r[8],I=r[12],R=r[1],W=r[5],se=r[9],Z=r[13],oe=r[2],fe=r[6],Se=r[10],Fe=r[14],X=r[3],ie=r[7],re=r[11],de=r[15];return s[0]=o*L+a*R+l*oe+c*X,s[4]=o*F+a*W+l*fe+c*ie,s[8]=o*H+a*se+l*Se+c*re,s[12]=o*I+a*Z+l*Fe+c*de,s[1]=u*L+f*R+g*oe+y*X,s[5]=u*F+f*W+g*fe+y*ie,s[9]=u*H+f*se+g*Se+y*re,s[13]=u*I+f*Z+g*Fe+y*de,s[2]=v*L+w*R+S*oe+x*X,s[6]=v*F+w*W+S*fe+x*ie,s[10]=v*H+w*se+S*Se+x*re,s[14]=v*I+w*Z+S*Fe+x*de,s[3]=M*L+A*R+C*oe+N*X,s[7]=M*F+A*W+C*fe+N*ie,s[11]=M*H+A*se+C*Se+N*re,s[15]=M*I+A*Z+C*Fe+N*de,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],f=e[6],g=e[10],y=e[14],v=e[3],w=e[7],S=e[11],x=e[15];return v*(+s*l*f-r*c*f-s*a*g+i*c*g+r*a*y-i*l*y)+w*(+t*l*y-t*c*g+s*o*g-r*o*y+r*c*u-s*l*u)+S*(+t*c*f-t*a*y-s*o*f+i*o*y+s*a*u-i*c*u)+x*(-r*a*u-t*l*f+t*a*g+r*o*f-i*o*g+i*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],f=e[9],g=e[10],y=e[11],v=e[12],w=e[13],S=e[14],x=e[15],M=f*S*c-w*g*c+w*l*y-a*S*y-f*l*x+a*g*x,A=v*g*c-u*S*c-v*l*y+o*S*y+u*l*x-o*g*x,C=u*w*c-v*f*c+v*a*y-o*w*y-u*a*x+o*f*x,N=v*f*l-u*w*l-v*a*g+o*w*g+u*a*S-o*f*S,L=t*M+i*A+r*C+s*N;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const F=1/L;return e[0]=M*F,e[1]=(w*g*s-f*S*s-w*r*y+i*S*y+f*r*x-i*g*x)*F,e[2]=(a*S*s-w*l*s+w*r*c-i*S*c-a*r*x+i*l*x)*F,e[3]=(f*l*s-a*g*s-f*r*c+i*g*c+a*r*y-i*l*y)*F,e[4]=A*F,e[5]=(u*S*s-v*g*s+v*r*y-t*S*y-u*r*x+t*g*x)*F,e[6]=(v*l*s-o*S*s-v*r*c+t*S*c+o*r*x-t*l*x)*F,e[7]=(o*g*s-u*l*s+u*r*c-t*g*c-o*r*y+t*l*y)*F,e[8]=C*F,e[9]=(v*f*s-u*w*s-v*i*y+t*w*y+u*i*x-t*f*x)*F,e[10]=(o*w*s-v*a*s+v*i*c-t*w*c-o*i*x+t*a*x)*F,e[11]=(u*a*s-o*f*s-u*i*c+t*f*c+o*i*y-t*a*y)*F,e[12]=N*F,e[13]=(u*w*r-v*f*r+v*i*g-t*w*g-u*i*S+t*f*S)*F,e[14]=(v*a*r-o*w*r-v*i*l+t*w*l+o*i*S-t*a*S)*F,e[15]=(o*f*r-u*a*r+u*i*l-t*f*l-o*i*g+t*a*g)*F,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+i,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,f=a+a,g=s*c,y=s*u,v=s*f,w=o*u,S=o*f,x=a*f,M=l*c,A=l*u,C=l*f,N=i.x,L=i.y,F=i.z;return r[0]=(1-(w+x))*N,r[1]=(y+C)*N,r[2]=(v-A)*N,r[3]=0,r[4]=(y-C)*L,r[5]=(1-(g+x))*L,r[6]=(S+M)*L,r[7]=0,r[8]=(v+A)*F,r[9]=(S-M)*F,r[10]=(1-(g+w))*F,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=Cd.set(r[0],r[1],r[2]).length();const o=Cd.set(r[4],r[5],r[6]).length(),a=Cd.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],la.copy(this);const c=1/s,u=1/o,f=1/a;return la.elements[0]*=c,la.elements[1]*=c,la.elements[2]*=c,la.elements[4]*=u,la.elements[5]*=u,la.elements[6]*=u,la.elements[8]*=f,la.elements[9]*=f,la.elements[10]*=f,t.setFromRotationMatrix(la),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=ja){const l=this.elements,c=2*s/(t-e),u=2*s/(i-r),f=(t+e)/(t-e),g=(i+r)/(i-r);let y,v;if(a===ja)y=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(a===ty)y=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=u,l[9]=g,l[13]=0,l[2]=0,l[6]=0,l[10]=y,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=ja){const l=this.elements,c=1/(t-e),u=1/(i-r),f=1/(o-s),g=(t+e)*c,y=(i+r)*u;let v,w;if(a===ja)v=(o+s)*f,w=-2*f;else if(a===ty)v=s*f,w=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-g,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-y,l[2]=0,l[6]=0,l[10]=w,l[14]=-v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Cd=new Q,la=new Wt,O7=new Q(0,0,0),N7=new Q(1,1,1),Ac=new Q,Vx=new Q,Ks=new Q,L3=new Wt,I3=new Qr;class ho{constructor(e=0,t=0,i=0,r=ho.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],l=r[1],c=r[5],u=r[9],f=r[2],g=r[6],y=r[10];switch(t){case"XYZ":this._y=Math.asin(Oi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,y),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Oi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,y),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Oi(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,y),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Oi(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,y),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Oi(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,y));break;case"XZY":this._z=Math.asin(-Oi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,y),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return L3.makeRotationFromQuaternion(e),this.setFromRotationMatrix(L3,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return I3.setFromEuler(this),this.setFromQuaternion(I3,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}}ho.DEFAULT_ORDER="XYZ";class Wh{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.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 s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),f.length>0&&(i.shapes=f),g.length>0&&(i.skeletons=g),y.length>0&&(i.animations=y),v.length>0&&(i.nodes=v)}return i.object=r,i;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){ca.subVectors(r,t),El.subVectors(i,t),PA.subVectors(e,t);const o=ca.dot(ca),a=ca.dot(El),l=ca.dot(PA),c=El.dot(El),u=El.dot(PA),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const g=1/f,y=(c*l-a*u)*g,v=(o*u-a*l)*g;return s.set(1-y-v,v,y)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Tl)===null?!1:Tl.x>=0&&Tl.y>=0&&Tl.x+Tl.y<=1}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Tl)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Tl.x),l.addScaledVector(o,Tl.y),l.addScaledVector(a,Tl.z),l)}static isFrontFacing(e,t,i,r){return ca.subVectors(i,t),El.subVectors(e,t),ca.cross(El).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ca.subVectors(this.c,this.b),El.subVectors(this.a,this.b),ca.cross(El).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return eo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return eo.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return eo.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return eo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return eo.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let o,a;kd.subVectors(r,i),Ld.subVectors(s,i),RA.subVectors(e,i);const l=kd.dot(RA),c=Ld.dot(RA);if(l<=0&&c<=0)return t.copy(i);kA.subVectors(e,r);const u=kd.dot(kA),f=Ld.dot(kA);if(u>=0&&f<=u)return t.copy(r);const g=l*f-u*c;if(g<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(i).addScaledVector(kd,o);LA.subVectors(e,s);const y=kd.dot(LA),v=Ld.dot(LA);if(v>=0&&y<=v)return t.copy(s);const w=y*c-l*v;if(w<=0&&c>=0&&v<=0)return a=c/(c-v),t.copy(i).addScaledVector(Ld,a);const S=u*v-y*f;if(S<=0&&f-u>=0&&y-v>=0)return z3.subVectors(s,r),a=(f-u)/(f-u+(y-v)),t.copy(r).addScaledVector(z3,a);const x=1/(S+w+g);return o=w*x,a=g*x,t.copy(i).addScaledVector(kd,o).addScaledVector(Ld,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ez={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},bc={h:0,s:0,l:0},Gx={h:0,s:0,l:0};function IA(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}let ht=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=hr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Vn.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Vn.workingColorSpace){return this.r=e,this.g=t,this.b=i,Vn.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Vn.workingColorSpace){if(e=IC(e,1),t=Oi(t,0,1),i=Oi(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=IA(o,s,e+1/3),this.g=IA(o,s,e),this.b=IA(o,s,e-1/3)}return Vn.toWorkingColorSpace(this,r),this}setStyle(e,t=hr){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,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=hr){const i=ez[e.toLowerCase()];return i!==void 0?this.setHex(i,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=Op(e.r),this.g=Op(e.g),this.b=Op(e.b),this}copyLinearToSRGB(e){return this.r=wA(e.r),this.g=wA(e.g),this.b=wA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=hr){return Vn.fromWorkingColorSpace(qr.copy(this),e),Math.round(Oi(qr.r*255,0,255))*65536+Math.round(Oi(qr.g*255,0,255))*256+Math.round(Oi(qr.b*255,0,255))}getHexString(e=hr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Vn.workingColorSpace){Vn.fromWorkingColorSpace(qr.copy(this),t);const i=qr.r,r=qr.g,s=qr.b,o=Math.max(i,r,s),a=Math.min(i,r,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=u<=.5?f/(o+a):f/(2-o-a),o){case i:l=(r-s)/f+(r0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){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(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Vh&&(i.blending=this.blending),this.side!==il&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==nS&&(i.blendSrc=this.blendSrc),this.blendDst!==iS&&(i.blendDst=this.blendDst),this.blendEquation!==Bc&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==q0&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ST&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Sh&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Sh&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Sh&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ro extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ht(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 ho,this.combine=Ey,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 Il=H7();function H7(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;!(c&8388608);)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function Ps(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Oi(n,-65504,65504),Il.floatView[0]=n;const e=Il.uint32View[0],t=e>>23&511;return Il.baseTable[t]+((e&8388607)>>Il.shiftTable[t])}function e0(n){const e=n>>10;return Il.uint32View[0]=Il.mantissaTable[Il.offsetTable[e]+(n&1023)]+Il.exponentTable[e],Il.floatView[0]}const G7={toHalfFloat:Ps,fromHalfFloat:e0},Qi=new Q,Wx=new Be;class On{constructor(e,t,i=!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=i,this.usage=ey,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=jo,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return J4("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let f=0,g=c.length;f0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.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 i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],f=s[c];for(let g=0,y=f.length;g0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s(e.far-e.near)**2))&&(B3.copy(s).invert(),rh.copy(e.ray).applyMatrix4(B3),!(i.boundingBox!==null&&rh.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,rh)))}_computeIntersections(e,t,i){let r;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,f=s.attributes.normal,g=s.groups,y=s.drawRange;if(a!==null)if(Array.isArray(o))for(let v=0,w=g.length;vt.far?null:{distance:c,point:Jx.clone(),object:n}}function Qx(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,Dd),n.getVertexPosition(l,Od),n.getVertexPosition(c,Nd);const u=J7(n,e,t,i,Dd,Od,Nd,Zx);if(u){r&&(qx.fromBufferAttribute(r,a),Yx.fromBufferAttribute(r,l),Kx.fromBufferAttribute(r,c),u.uv=eo.getInterpolation(Zx,Dd,Od,Nd,qx,Yx,Kx,new Be)),s&&(qx.fromBufferAttribute(s,a),Yx.fromBufferAttribute(s,l),Kx.fromBufferAttribute(s,c),u.uv1=eo.getInterpolation(Zx,Dd,Od,Nd,qx,Yx,Kx,new Be)),o&&(H3.fromBufferAttribute(o,a),G3.fromBufferAttribute(o,l),W3.fromBufferAttribute(o,c),u.normal=eo.getInterpolation(Zx,Dd,Od,Nd,H3,G3,W3,new Q),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:l,c,normal:new Q,materialIndex:0};eo.getNormal(Dd,Od,Nd,f.normal),u.face=f}return u}class ff extends cn{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],f=[];let g=0,y=0;v("z","y","x",-1,-1,i,t,e,o,s,0),v("z","y","x",1,-1,i,t,-e,o,s,1),v("x","z","y",1,1,e,i,t,r,o,2),v("x","z","y",1,-1,e,i,-t,r,o,3),v("x","y","z",1,-1,e,t,i,r,s,4),v("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new Rt(c,3)),this.setAttribute("normal",new Rt(u,3)),this.setAttribute("uv",new Rt(f,2));function v(w,S,x,M,A,C,N,L,F,H,I){const R=C/F,W=N/H,se=C/2,Z=N/2,oe=L/2,fe=F+1,Se=H+1;let Fe=0,X=0;const ie=new Q;for(let re=0;re0?1:-1,u.push(ie.x,ie.y,ie.z),f.push(Oe/F),f.push(1-re/H),Fe+=1}}for(let re=0;re0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Cy extends Dn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Wt,this.projectionMatrix=new Wt,this.projectionMatrixInverse=new Wt,this.coordinateSystem=ja}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 Ec=new Q,j3=new Be,X3=new Be;class fr extends Cy{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Qp*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Gh*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Qp*2*Math.atan(Math.tan(Gh*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Ec.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ec.x,Ec.y).multiplyScalar(-e/Ec.z),Ec.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ec.x,Ec.y).multiplyScalar(-e/Ec.z)}getViewSize(e,t){return this.getViewBounds(e,j3,X3),t.subVectors(X3,j3)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Gh*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*i/c,r*=o.width/l,i*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,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 Fd=-90,Ud=1;class nz extends Dn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new fr(Fd,Ud,e,t);r.layers=this.layers,this.add(r);const s=new fr(Fd,Ud,e,t);s.layers=this.layers,this.add(s);const o=new fr(Fd,Ud,e,t);o.layers=this.layers,this.add(o);const a=new fr(Fd,Ud,e,t);a.layers=this.layers,this.add(a);const l=new fr(Fd,Ud,e,t);l.layers=this.layers,this.add(l);const c=new fr(Fd,Ud,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,l]=t;for(const c of t)this.remove(c);if(e===ja)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===ty)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,u]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),y=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const w=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=w,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(f,g,y),e.xr.enabled=v,i.texture.needsPMREMUpdate=!0}}class Py extends hi{constructor(e,t,i,r,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:Xl,super(e,t,i,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class iz extends uo{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Py(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:Ni}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new ff(5,5,5),s=new Fs({name:"CubemapFromEquirect",uniforms:$p(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:ws,blending:Ja});s.uniforms.tEquirect.value=t;const o=new Fi(r,s),a=t.minFilter;return t.minFilter===Wo&&(t.minFilter=Ni),new nz(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}}const NA=new Q,tX=new Q,nX=new hn;class Oc{constructor(e=new Q(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=NA.subVectors(i,t).cross(tX.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(NA),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||nX.getNormalMatrix(e),r=this.coplanarPoint(NA).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sh=new Ur,$x=new Q;class Ry{constructor(e=new Oc,t=new Oc,i=new Oc,r=new Oc,s=new Oc,o=new Oc){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=ja){const i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],l=r[3],c=r[4],u=r[5],f=r[6],g=r[7],y=r[8],v=r[9],w=r[10],S=r[11],x=r[12],M=r[13],A=r[14],C=r[15];if(i[0].setComponents(l-s,g-c,S-y,C-x).normalize(),i[1].setComponents(l+s,g+c,S+y,C+x).normalize(),i[2].setComponents(l+o,g+u,S+v,C+M).normalize(),i[3].setComponents(l-o,g-u,S-v,C-M).normalize(),i[4].setComponents(l-a,g-f,S-w,C-A).normalize(),t===ja)i[5].setComponents(l+a,g+f,S+w,C+A).normalize();else if(t===ty)i[5].setComponents(a,f,w,A).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(),sh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sh.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sh)}intersectsSprite(e){return sh.center.set(0,0,0),sh.radius=.7071067811865476,sh.applyMatrix4(e.matrixWorld),this.intersectsSphere(sh)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,$x.y=r.normal.y>0?e.max.y:e.min.y,$x.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint($x)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function rz(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function iX(n){const e=new WeakMap;function t(a,l){const c=a.array,u=a.usage,f=c.byteLength,g=n.createBuffer();n.bindBuffer(l,g),n.bufferData(l,c,u),a.onUploadCallback();let y;if(c instanceof Float32Array)y=n.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?y=n.HALF_FLOAT:y=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)y=n.SHORT;else if(c instanceof Uint32Array)y=n.UNSIGNED_INT;else if(c instanceof Int32Array)y=n.INT;else if(c instanceof Int8Array)y=n.BYTE;else if(c instanceof Uint8Array)y=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)y=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:g,type:y,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,l,c){const u=l.array,f=l._updateRange,g=l.updateRanges;if(n.bindBuffer(c,a),f.count===-1&&g.length===0&&n.bufferSubData(c,0,u),g.length!==0){for(let y=0,v=g.length;y 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,wX=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,SX=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_X=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,MX=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,AX=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,bX=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`,EX=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif`,TX=`#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; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +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`,CX=`#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`,PX=`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`,RX=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,kX=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,LX=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,IX=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,DX="gl_FragColor = linearToOutputTexel( gl_FragColor );",OX=` +const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( + vec3( 0.8224621, 0.177538, 0.0 ), + vec3( 0.0331941, 0.9668058, 0.0 ), + vec3( 0.0170827, 0.0723974, 0.9105199 ) +); +const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( + vec3( 1.2249401, - 0.2249404, 0.0 ), + vec3( - 0.0420569, 1.0420571, 0.0 ), + vec3( - 0.0196376, - 0.0786361, 1.0982735 ) +); +vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { + return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); +} +vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { + return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); +} +vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +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 ); +} +vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( in vec4 value ) { + return sRGBTransferOETF( value ); +}`,NX=`#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`,FX=`#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`,UX=`#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`,zX=`#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`,BX=`#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`,VX=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,HX=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,GX=`#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`,WX=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,jX=`#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 +}`,XX=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,qX=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,YX=`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`,KX=`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 ) { + #if defined ( LEGACY_LIGHTS ) + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #else + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; + #endif +} +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`,ZX=`#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`,JX=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,QX=`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`,$X=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,eq=`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`,tq=`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`,nq=`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 ); +}`,iq=` +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.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.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.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`,rq=`#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`,sq=`#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`,oq=`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,aq=`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,lq=`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,cq=`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,uq=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,hq=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,fq=`#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`,dq=`#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`,pq=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,mq=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,gq=`#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`,yq=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) + 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`,vq=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } + #else + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + #endif +#endif`,xq=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + #endif + #ifdef MORPHTARGETS_TEXTURE + #ifndef USE_INSTANCING_MORPH + 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 ); + } + #else + #ifndef USE_MORPHNORMALS + uniform float morphTargetInfluences[ 8 ]; + #else + uniform float morphTargetInfluences[ 4 ]; + #endif + #endif +#endif`,wq=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } + #else + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + #ifndef USE_MORPHNORMALS + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + #endif + #endif +#endif`,Sq=`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;`,_q=`#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`,Mq=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Aq=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,bq=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,Eq=`#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`,Tq=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,Cq=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,Pq=`#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`,Rq=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,kq=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Lq=`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 vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( 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( 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 ); +}`,Iq=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,Dq=`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;`,Oq=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Nq=`#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`,Fq=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,Uq=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,zq=`#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 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 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 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 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 shadow; + } + 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 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 shadow; + } +#endif`,Bq=`#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 shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + 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 shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Vq=`#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`,Hq=`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.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.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.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,Gq=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,Wq=`#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`,jq=`#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`,Xq=`#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`,qq=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Yq=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Kq=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Zq=`#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 OptimizedCineonToneMapping( 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; }`,Jq=`#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`,Qq=`#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`,$q=`#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`,eY=`#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`,tY=`#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`,nY=`#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 iY=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,rY=`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 +}`,sY=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,oY=`#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 +}`,aY=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,lY=`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 +}`,cY=`#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; +}`,uY=`#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 ); + #endif +}`,hY=`#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; +}`,fY=`#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 ); +}`,dY=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,pY=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,mY=`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 +}`,gY=`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 +}`,yY=`#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 +}`,vY=`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 +}`,xY=`#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 +}`,wY=`#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 +}`,SY=`#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; +}`,_Y=`#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 +}`,MY=`#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 +}`,AY=`#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 +}`,bY=`#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 +}`,EY=`#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 +}`,TY=`#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 +}`,CY=`#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 +}`,PY=`#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 +}`,RY=`#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 +}`,kY=`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 +}`,LY=`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 +}`,IY=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,DY=`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 +}`,OY=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #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 +}`,NY=`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 +}`,yn={alphahash_fragment:rX,alphahash_pars_fragment:sX,alphamap_fragment:oX,alphamap_pars_fragment:aX,alphatest_fragment:lX,alphatest_pars_fragment:cX,aomap_fragment:uX,aomap_pars_fragment:hX,batching_pars_vertex:fX,batching_vertex:dX,begin_vertex:pX,beginnormal_vertex:mX,bsdfs:gX,iridescence_fragment:yX,bumpmap_pars_fragment:vX,clipping_planes_fragment:xX,clipping_planes_pars_fragment:wX,clipping_planes_pars_vertex:SX,clipping_planes_vertex:_X,color_fragment:MX,color_pars_fragment:AX,color_pars_vertex:bX,color_vertex:EX,common:TX,cube_uv_reflection_fragment:CX,defaultnormal_vertex:PX,displacementmap_pars_vertex:RX,displacementmap_vertex:kX,emissivemap_fragment:LX,emissivemap_pars_fragment:IX,colorspace_fragment:DX,colorspace_pars_fragment:OX,envmap_fragment:NX,envmap_common_pars_fragment:FX,envmap_pars_fragment:UX,envmap_pars_vertex:zX,envmap_physical_pars_fragment:ZX,envmap_vertex:BX,fog_vertex:VX,fog_pars_vertex:HX,fog_fragment:GX,fog_pars_fragment:WX,gradientmap_pars_fragment:jX,lightmap_pars_fragment:XX,lights_lambert_fragment:qX,lights_lambert_pars_fragment:YX,lights_pars_begin:KX,lights_toon_fragment:JX,lights_toon_pars_fragment:QX,lights_phong_fragment:$X,lights_phong_pars_fragment:eq,lights_physical_fragment:tq,lights_physical_pars_fragment:nq,lights_fragment_begin:iq,lights_fragment_maps:rq,lights_fragment_end:sq,logdepthbuf_fragment:oq,logdepthbuf_pars_fragment:aq,logdepthbuf_pars_vertex:lq,logdepthbuf_vertex:cq,map_fragment:uq,map_pars_fragment:hq,map_particle_fragment:fq,map_particle_pars_fragment:dq,metalnessmap_fragment:pq,metalnessmap_pars_fragment:mq,morphinstance_vertex:gq,morphcolor_vertex:yq,morphnormal_vertex:vq,morphtarget_pars_vertex:xq,morphtarget_vertex:wq,normal_fragment_begin:Sq,normal_fragment_maps:_q,normal_pars_fragment:Mq,normal_pars_vertex:Aq,normal_vertex:bq,normalmap_pars_fragment:Eq,clearcoat_normal_fragment_begin:Tq,clearcoat_normal_fragment_maps:Cq,clearcoat_pars_fragment:Pq,iridescence_pars_fragment:Rq,opaque_fragment:kq,packing:Lq,premultiplied_alpha_fragment:Iq,project_vertex:Dq,dithering_fragment:Oq,dithering_pars_fragment:Nq,roughnessmap_fragment:Fq,roughnessmap_pars_fragment:Uq,shadowmap_pars_fragment:zq,shadowmap_pars_vertex:Bq,shadowmap_vertex:Vq,shadowmask_pars_fragment:Hq,skinbase_vertex:Gq,skinning_pars_vertex:Wq,skinning_vertex:jq,skinnormal_vertex:Xq,specularmap_fragment:qq,specularmap_pars_fragment:Yq,tonemapping_fragment:Kq,tonemapping_pars_fragment:Zq,transmission_fragment:Jq,transmission_pars_fragment:Qq,uv_pars_fragment:$q,uv_pars_vertex:eY,uv_vertex:tY,worldpos_vertex:nY,background_vert:iY,background_frag:rY,backgroundCube_vert:sY,backgroundCube_frag:oY,cube_vert:aY,cube_frag:lY,depth_vert:cY,depth_frag:uY,distanceRGBA_vert:hY,distanceRGBA_frag:fY,equirect_vert:dY,equirect_frag:pY,linedashed_vert:mY,linedashed_frag:gY,meshbasic_vert:yY,meshbasic_frag:vY,meshlambert_vert:xY,meshlambert_frag:wY,meshmatcap_vert:SY,meshmatcap_frag:_Y,meshnormal_vert:MY,meshnormal_frag:AY,meshphong_vert:bY,meshphong_frag:EY,meshphysical_vert:TY,meshphysical_frag:CY,meshtoon_vert:PY,meshtoon_frag:RY,points_vert:kY,points_frag:LY,shadow_vert:IY,shadow_frag:DY,sprite_vert:OY,sprite_frag:NY},mt={common:{diffuse:{value:new ht(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new hn}},envmap:{envMap:{value:null},envMapRotation:{value:new hn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new hn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new hn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new hn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new hn},normalScale:{value:new Be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new hn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new hn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new hn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new hn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ht(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 ht(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0},uvTransform:{value:new hn}},sprite:{diffuse:{value:new ht(16777215)},opacity:{value:1},center:{value:new Be(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}}},ga={basic:{uniforms:fs([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.fog]),vertexShader:yn.meshbasic_vert,fragmentShader:yn.meshbasic_frag},lambert:{uniforms:fs([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,mt.lights,{emissive:{value:new ht(0)}}]),vertexShader:yn.meshlambert_vert,fragmentShader:yn.meshlambert_frag},phong:{uniforms:fs([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,mt.lights,{emissive:{value:new ht(0)},specular:{value:new ht(1118481)},shininess:{value:30}}]),vertexShader:yn.meshphong_vert,fragmentShader:yn.meshphong_frag},standard:{uniforms:fs([mt.common,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.roughnessmap,mt.metalnessmap,mt.fog,mt.lights,{emissive:{value:new ht(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yn.meshphysical_vert,fragmentShader:yn.meshphysical_frag},toon:{uniforms:fs([mt.common,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.gradientmap,mt.fog,mt.lights,{emissive:{value:new ht(0)}}]),vertexShader:yn.meshtoon_vert,fragmentShader:yn.meshtoon_frag},matcap:{uniforms:fs([mt.common,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,{matcap:{value:null}}]),vertexShader:yn.meshmatcap_vert,fragmentShader:yn.meshmatcap_frag},points:{uniforms:fs([mt.points,mt.fog]),vertexShader:yn.points_vert,fragmentShader:yn.points_frag},dashed:{uniforms:fs([mt.common,mt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yn.linedashed_vert,fragmentShader:yn.linedashed_frag},depth:{uniforms:fs([mt.common,mt.displacementmap]),vertexShader:yn.depth_vert,fragmentShader:yn.depth_frag},normal:{uniforms:fs([mt.common,mt.bumpmap,mt.normalmap,mt.displacementmap,{opacity:{value:1}}]),vertexShader:yn.meshnormal_vert,fragmentShader:yn.meshnormal_frag},sprite:{uniforms:fs([mt.sprite,mt.fog]),vertexShader:yn.sprite_vert,fragmentShader:yn.sprite_frag},background:{uniforms:{uvTransform:{value:new hn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:yn.background_vert,fragmentShader:yn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new hn}},vertexShader:yn.backgroundCube_vert,fragmentShader:yn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yn.cube_vert,fragmentShader:yn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yn.equirect_vert,fragmentShader:yn.equirect_frag},distanceRGBA:{uniforms:fs([mt.common,mt.displacementmap,{referencePosition:{value:new Q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yn.distanceRGBA_vert,fragmentShader:yn.distanceRGBA_frag},shadow:{uniforms:fs([mt.lights,mt.fog,{color:{value:new ht(0)},opacity:{value:1}}]),vertexShader:yn.shadow_vert,fragmentShader:yn.shadow_frag}};ga.physical={uniforms:fs([ga.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new hn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new hn},clearcoatNormalScale:{value:new Be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new hn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new hn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new hn},sheen:{value:0},sheenColor:{value:new ht(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new hn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new hn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new hn},transmissionSamplerSize:{value:new Be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new hn},attenuationDistance:{value:0},attenuationColor:{value:new ht(0)},specularColor:{value:new ht(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new hn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new hn},anisotropyVector:{value:new Be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new hn}}]),vertexShader:yn.meshphysical_vert,fragmentShader:yn.meshphysical_frag};const e1={r:0,b:0,g:0},oh=new ho,FY=new Wt;function UY(n,e,t,i,r,s,o){const a=new ht(0);let l=s===!0?0:1,c,u,f=null,g=0,y=null;function v(M){let A=M.isScene===!0?M.background:null;return A&&A.isTexture&&(A=(M.backgroundBlurriness>0?t:e).get(A)),A}function w(M){let A=!1;const C=v(M);C===null?x(a,l):C&&C.isColor&&(x(C,1),A=!0);const N=n.xr.getEnvironmentBlendMode();N==="additive"?i.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||A)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function S(M,A){const C=v(A);C&&(C.isCubeTexture||C.mapping===hm)?(u===void 0&&(u=new Fi(new ff(1,1,1),new Fs({name:"BackgroundCubeMaterial",uniforms:$p(ga.backgroundCube.uniforms),vertexShader:ga.backgroundCube.vertexShader,fragmentShader:ga.backgroundCube.fragmentShader,side:ws,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(N,L,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),oh.copy(A.backgroundRotation),oh.x*=-1,oh.y*=-1,oh.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(oh.y*=-1,oh.z*=-1),u.material.uniforms.envMap.value=C,u.material.uniforms.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(FY.makeRotationFromEuler(oh)),u.material.toneMapped=Vn.getTransfer(C.colorSpace)!==si,(f!==C||g!==C.version||y!==n.toneMapping)&&(u.material.needsUpdate=!0,f=C,g=C.version,y=n.toneMapping),u.layers.enableAll(),M.unshift(u,u.geometry,u.material,0,0,null)):C&&C.isTexture&&(c===void 0&&(c=new Fi(new pm(2,2),new Fs({name:"BackgroundMaterial",uniforms:$p(ga.background.uniforms),vertexShader:ga.background.vertexShader,fragmentShader:ga.background.fragmentShader,side:il,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=C,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.toneMapped=Vn.getTransfer(C.colorSpace)!==si,C.matrixAutoUpdate===!0&&C.updateMatrix(),c.material.uniforms.uvTransform.value.copy(C.matrix),(f!==C||g!==C.version||y!==n.toneMapping)&&(c.material.needsUpdate=!0,f=C,g=C.version,y=n.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null))}function x(M,A){M.getRGB(e1,tz(n)),i.buffers.color.setClear(e1.r,e1.g,e1.b,A,o)}return{getClearColor:function(){return a},setClearColor:function(M,A=1){a.set(M),l=A,x(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(M){l=M,x(a,l)},render:w,addToRenderList:S}}function zY(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=g(null);let s=r,o=!1;function a(R,W,se,Z,oe){let fe=!1;const Se=f(Z,se,W);s!==Se&&(s=Se,c(s.object)),fe=y(R,Z,se,oe),fe&&v(R,Z,se,oe),oe!==null&&e.update(oe,n.ELEMENT_ARRAY_BUFFER),(fe||o)&&(o=!1,C(R,W,se,Z),oe!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(oe).buffer))}function l(){return n.createVertexArray()}function c(R){return n.bindVertexArray(R)}function u(R){return n.deleteVertexArray(R)}function f(R,W,se){const Z=se.wireframe===!0;let oe=i[R.id];oe===void 0&&(oe={},i[R.id]=oe);let fe=oe[W.id];fe===void 0&&(fe={},oe[W.id]=fe);let Se=fe[Z];return Se===void 0&&(Se=g(l()),fe[Z]=Se),Se}function g(R){const W=[],se=[],Z=[];for(let oe=0;oe=0){const re=oe[X];let de=fe[X];if(de===void 0&&(X==="instanceMatrix"&&R.instanceMatrix&&(de=R.instanceMatrix),X==="instanceColor"&&R.instanceColor&&(de=R.instanceColor)),re===void 0||re.attribute!==de||de&&re.data!==de.data)return!0;Se++}return s.attributesNum!==Se||s.index!==Z}function v(R,W,se,Z){const oe={},fe=W.attributes;let Se=0;const Fe=se.getAttributes();for(const X in Fe)if(Fe[X].location>=0){let re=fe[X];re===void 0&&(X==="instanceMatrix"&&R.instanceMatrix&&(re=R.instanceMatrix),X==="instanceColor"&&R.instanceColor&&(re=R.instanceColor));const de={};de.attribute=re,re&&re.data&&(de.data=re.data),oe[X]=de,Se++}s.attributes=oe,s.attributesNum=Se,s.index=Z}function w(){const R=s.newAttributes;for(let W=0,se=R.length;W=0){let ie=oe[Fe];if(ie===void 0&&(Fe==="instanceMatrix"&&R.instanceMatrix&&(ie=R.instanceMatrix),Fe==="instanceColor"&&R.instanceColor&&(ie=R.instanceColor)),ie!==void 0){const re=ie.normalized,de=ie.itemSize,Oe=e.get(ie);if(Oe===void 0)continue;const it=Oe.buffer,we=Oe.type,Ve=Oe.bytesPerElement,Ye=we===n.INT||we===n.UNSIGNED_INT||ie.gpuType===MC;if(ie.isInterleavedBufferAttribute){const He=ie.data,Xt=He.stride,jt=ie.offset;if(He.isInstancedInterleavedBuffer){for(let ge=0;ge0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";L="mediump"}return L==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const f=t.logarithmicDepthBuffer===!0,g=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),w=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),S=n.getParameter(n.MAX_VERTEX_ATTRIBS),x=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),M=n.getParameter(n.MAX_VARYING_VECTORS),A=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),C=y>0,N=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,maxTextures:g,maxVertexTextures:y,maxTextureSize:v,maxCubemapSize:w,maxAttributes:S,maxVertexUniforms:x,maxVaryings:M,maxFragmentUniforms:A,vertexTextures:C,maxSamples:N}}function HY(n){const e=this;let t=null,i=0,r=!1,s=!1;const o=new Oc,a=new hn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const y=f.length!==0||g||i!==0||r;return r=g,i=f.length,y},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,g){t=u(f,g,0)},this.setState=function(f,g,y){const v=f.clippingPlanes,w=f.clipIntersection,S=f.clipShadows,x=n.get(f);if(!r||v===null||v.length===0||s&&!S)s?u(null):c();else{const M=s?0:i,A=M*4;let C=x.clippingState||null;l.value=C,C=u(v,g,A,y);for(let N=0;N!==A;++N)C[N]=t[N];x.clippingState=C,this.numIntersection=w?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(f,g,y,v){const w=f!==null?f.length:0;let S=null;if(w!==0){if(S=l.value,v!==!0||S===null){const x=y+w*4,M=g.matrixWorldInverse;a.getNormalMatrix(M),(S===null||S.length0){const c=new iz(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",r),t(c.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class df extends Cy{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,a=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Ap=4,q3=[.125,.215,.35,.446,.526,.582],Eh=20,FA=new df,Y3=new ht;let UA=null,zA=0,BA=0,VA=!1;const _h=(1+Math.sqrt(5))/2,zd=1/_h,K3=[new Q(-_h,zd,0),new Q(_h,zd,0),new Q(-zd,0,_h),new Q(zd,0,_h),new Q(0,_h,-zd),new Q(0,_h,zd),new Q(-1,1,-1),new Q(1,1,-1),new Q(-1,1,1),new Q(1,1,1)];class MT{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,i=.1,r=100){UA=this._renderer.getRenderTarget(),zA=this._renderer.getActiveCubeFace(),BA=this._renderer.getActiveMipmapLevel(),VA=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Q3(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=J3(),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?A:0,A,A),u.setRenderTarget(r),w&&u.render(v,a),u.render(e,a)}v.geometry.dispose(),v.material.dispose(),u.toneMapping=g,u.autoClear=f,e.background=S}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Xl||e.mapping===lu;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Q3()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=J3());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new Fi(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;t1(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,FA)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sEh&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${Eh}`);const x=[];let M=0;for(let F=0;FA-Ap?r-A+Ap:0),L=4*(this._cubeSize-C);t1(t,N,L,3*C,2*C),l.setRenderTarget(t),l.render(f,FA)}}function WY(n){const e=[],t=[],i=[];let r=n;const s=n-Ap+1+q3.length;for(let o=0;on-Ap?l=q3[o-n+Ap-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),u=-c,f=1+c,g=[u,u,f,u,f,f,u,u,f,f,u,f],y=6,v=6,w=3,S=2,x=1,M=new Float32Array(w*v*y),A=new Float32Array(S*v*y),C=new Float32Array(x*v*y);for(let L=0;L2?0:-1,I=[F,H,0,F+2/3,H,0,F+2/3,H+1,0,F,H,0,F+2/3,H+1,0,F,H+1,0];M.set(I,w*v*L),A.set(g,S*v*L);const R=[L,L,L,L,L,L];C.set(R,x*v*L)}const N=new cn;N.setAttribute("position",new On(M,w)),N.setAttribute("uv",new On(A,S)),N.setAttribute("faceIndex",new On(C,x)),e.push(N),r>Ap&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Z3(n,e,t){const i=new uo(n,e,t);return i.texture.mapping=hm,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function t1(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function jY(n,e,t){const i=new Float32Array(Eh),r=new Q(0,1,0);return new Fs({name:"SphericalGaussianBlur",defines:{n:Eh,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:UC(),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:Ja,depthTest:!1,depthWrite:!1})}function J3(){return new Fs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:UC(),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:Ja,depthTest:!1,depthWrite:!1})}function Q3(){return new Fs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:UC(),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:Ja,depthTest:!1,depthWrite:!1})}function UC(){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 XY(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===Y0||l===K0,u=l===Xl||l===lu;if(c||u){let f=e.get(a);const g=f!==void 0?f.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==g)return t===null&&(t=new MT(n)),f=c?t.fromEquirectangular(a,f):t.fromCubemap(a,f),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),f.texture;if(f!==void 0)return f.texture;{const y=a.image;return c&&y&&y.height>0||u&&y&&r(y)?(t===null&&(t=new MT(n)),f=c?t.fromEquirectangular(a):t.fromCubemap(a),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),a.addEventListener("dispose",s),f.texture):null}}}return a}function r(a){let l=0;const c=6;for(let u=0;ue.maxTextureSize&&(N=Math.ceil(C/e.maxTextureSize),C=e.maxTextureSize);const L=new Float32Array(C*N*4*f),F=new s_(L,C,N,f);F.type=jo,F.needsUpdate=!0;const H=A*4;for(let R=0;R0)return n;const r=e*t;let s=$3[r];if(s===void 0&&(s=new Float32Array(r),$3[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function gr(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t":" "} ${a}: ${t[o]}`)}return i.join(` +`)}function XK(n){const e=Vn.getPrimaries(Vn.workingColorSpace),t=Vn.getPrimaries(n);let i;switch(e===t?i="":e===$0&&t===Q0?i="LinearDisplayP3ToLinearSRGB":e===Q0&&t===$0&&(i="LinearSRGBToLinearDisplayP3"),n){case mr:case Ty:return[i,"LinearTransferOETF"];case hr:case r_:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function oL(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return t.toUpperCase()+` + +`+r+` + +`+jK(n.getShaderSource(e),o)}else return r}function qK(n,e){const t=XK(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function YK(n,e){let t;switch(e){case x4:t="Linear";break;case w4:t="Reinhard";break;case S4:t="OptimizedCineon";break;case SC:t="ACESFilmic";break;case M4:t="AgX";break;case A4:t="Neutral";break;case _4:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function KK(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(t0).join(` +`)}function ZK(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function JK(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function AT(n){return n.replace(QK,eZ)}const $K=new Map;function eZ(n,e){let t=yn[e];if(t===void 0){const i=$K.get(e);if(i!==void 0)t=yn[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return AT(t)}const tZ=/#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 cL(n){return n.replace(tZ,nZ)}function nZ(n,e,t,i){let r="";for(let s=parseInt(e);s0&&(S+=` +`),x=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(t0).join(` +`),x.length>0&&(x+=` +`)):(S=[uL(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",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 "+u:"",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":"",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 "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","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","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(t0).join(` +`),x=[uL(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,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 "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.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?"#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 "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Qa?"#define TONE_MAPPING":"",t.toneMapping!==Qa?yn.tonemapping_pars_fragment:"",t.toneMapping!==Qa?YK("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",yn.colorspace_pars_fragment,qK("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(t0).join(` +`)),o=AT(o),o=aL(o,t),o=lL(o,t),a=AT(a),a=aL(a,t),a=lL(a,t),o=cL(o),a=cL(a),t.isRawShaderMaterial!==!0&&(M=`#version 300 es +`,S=[y,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+S,x=["#define varying in",t.glslVersion===_T?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===_T?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+x);const A=M+S+o,C=M+x+a,N=sL(r,r.VERTEX_SHADER,A),L=sL(r,r.FRAGMENT_SHADER,C);r.attachShader(w,N),r.attachShader(w,L),t.index0AttributeName!==void 0?r.bindAttribLocation(w,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(w,0,"position"),r.linkProgram(w);function F(W){if(n.debug.checkShaderErrors){const se=r.getProgramInfoLog(w).trim(),Z=r.getShaderInfoLog(N).trim(),oe=r.getShaderInfoLog(L).trim();let fe=!0,Se=!0;if(r.getProgramParameter(w,r.LINK_STATUS)===!1)if(fe=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,w,N,L);else{const Fe=oL(r,N,"vertex"),X=oL(r,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(w,r.VALIDATE_STATUS)+` + +Material Name: `+W.name+` +Material Type: `+W.type+` + +Program Info Log: `+se+` +`+Fe+` +`+X)}else se!==""?console.warn("THREE.WebGLProgram: Program Info Log:",se):(Z===""||oe==="")&&(Se=!1);Se&&(W.diagnostics={runnable:fe,programLog:se,vertexShader:{log:Z,prefix:S},fragmentShader:{log:oe,prefix:x}})}r.deleteShader(N),r.deleteShader(L),H=new uw(r,w),I=JK(r,w)}let H;this.getUniforms=function(){return H===void 0&&F(this),H};let I;this.getAttributes=function(){return I===void 0&&F(this),I};let R=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=r.getProgramParameter(w,GK)),R},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(w),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=WK++,this.cacheKey=e,this.usedTimes=1,this.program=w,this.vertexShader=N,this.fragmentShader=L,this}let cZ=0;class uZ{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new hZ(e),t.set(e,i)),i}}class hZ{constructor(e){this.id=cZ++,this.code=e,this.usedTimes=0}}function fZ(n,e,t,i,r,s,o){const a=new Wh,l=new uZ,c=new Set,u=[],f=r.logarithmicDepthBuffer,g=r.vertexTextures;let y=r.precision;const v={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 w(I){return c.add(I),I===0?"uv":`uv${I}`}function S(I,R,W,se,Z){const oe=se.fog,fe=Z.geometry,Se=I.isMeshStandardMaterial?se.environment:null,Fe=(I.isMeshStandardMaterial?t:e).get(I.envMap||Se),X=Fe&&Fe.mapping===hm?Fe.image.height:null,ie=v[I.type];I.precision!==null&&(y=r.getMaxPrecision(I.precision),y!==I.precision&&console.warn("THREE.WebGLProgram.getParameters:",I.precision,"not supported, using",y,"instead."));const re=fe.morphAttributes.position||fe.morphAttributes.normal||fe.morphAttributes.color,de=re!==void 0?re.length:0;let Oe=0;fe.morphAttributes.position!==void 0&&(Oe=1),fe.morphAttributes.normal!==void 0&&(Oe=2),fe.morphAttributes.color!==void 0&&(Oe=3);let it,we,Ve,Ye;if(ie){const kn=ga[ie];it=kn.vertexShader,we=kn.fragmentShader}else it=I.vertexShader,we=I.fragmentShader,l.update(I),Ve=l.getVertexShaderID(I),Ye=l.getFragmentShaderID(I);const He=n.getRenderTarget(),Xt=Z.isInstancedMesh===!0,jt=Z.isBatchedMesh===!0,ge=!!I.map,Dt=!!I.matcap,Ie=!!Fe,Ge=!!I.aoMap,Pe=!!I.lightMap,rt=!!I.bumpMap,We=!!I.normalMap,ft=!!I.displacementMap,Ct=!!I.emissiveMap,te=!!I.metalnessMap,q=!!I.roughnessMap,Me=I.anisotropy>0,Ne=I.clearcoat>0,je=I.dispersion>0,ze=I.iridescence>0,At=I.sheen>0,at=I.transmission>0,lt=Me&&!!I.anisotropyMap,Zt=Ne&&!!I.clearcoatMap,Ze=Ne&&!!I.clearcoatNormalMap,kt=Ne&&!!I.clearcoatRoughnessMap,en=ze&&!!I.iridescenceMap,Ft=ze&&!!I.iridescenceThicknessMap,dt=At&&!!I.sheenColorMap,on=At&&!!I.sheenRoughnessMap,dn=!!I.specularMap,Qn=!!I.specularColorMap,et=!!I.specularIntensityMap,ce=at&&!!I.transmissionMap,Ue=at&&!!I.thicknessMap,Re=!!I.gradientMap,nt=!!I.alphaMap,ct=I.alphaTest>0,pn=!!I.alphaHash,Tn=!!I.extensions;let Jn=Qa;I.toneMapped&&(He===null||He.isXRRenderTarget===!0)&&(Jn=n.toneMapping);const Ui={shaderID:ie,shaderType:I.type,shaderName:I.name,vertexShader:it,fragmentShader:we,defines:I.defines,customVertexShaderID:Ve,customFragmentShaderID:Ye,isRawShaderMaterial:I.isRawShaderMaterial===!0,glslVersion:I.glslVersion,precision:y,batching:jt,instancing:Xt,instancingColor:Xt&&Z.instanceColor!==null,instancingMorph:Xt&&Z.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:He===null?n.outputColorSpace:He.isXRRenderTarget===!0?He.texture.colorSpace:mr,alphaToCoverage:!!I.alphaToCoverage,map:ge,matcap:Dt,envMap:Ie,envMapMode:Ie&&Fe.mapping,envMapCubeUVHeight:X,aoMap:Ge,lightMap:Pe,bumpMap:rt,normalMap:We,displacementMap:g&&ft,emissiveMap:Ct,normalMapObjectSpace:We&&I.normalMapType===V4,normalMapTangentSpace:We&&I.normalMapType===vu,metalnessMap:te,roughnessMap:q,anisotropy:Me,anisotropyMap:lt,clearcoat:Ne,clearcoatMap:Zt,clearcoatNormalMap:Ze,clearcoatRoughnessMap:kt,dispersion:je,iridescence:ze,iridescenceMap:en,iridescenceThicknessMap:Ft,sheen:At,sheenColorMap:dt,sheenRoughnessMap:on,specularMap:dn,specularColorMap:Qn,specularIntensityMap:et,transmission:at,transmissionMap:ce,thicknessMap:Ue,gradientMap:Re,opaque:I.transparent===!1&&I.blending===Vh&&I.alphaToCoverage===!1,alphaMap:nt,alphaTest:ct,alphaHash:pn,combine:I.combine,mapUv:ge&&w(I.map.channel),aoMapUv:Ge&&w(I.aoMap.channel),lightMapUv:Pe&&w(I.lightMap.channel),bumpMapUv:rt&&w(I.bumpMap.channel),normalMapUv:We&&w(I.normalMap.channel),displacementMapUv:ft&&w(I.displacementMap.channel),emissiveMapUv:Ct&&w(I.emissiveMap.channel),metalnessMapUv:te&&w(I.metalnessMap.channel),roughnessMapUv:q&&w(I.roughnessMap.channel),anisotropyMapUv:lt&&w(I.anisotropyMap.channel),clearcoatMapUv:Zt&&w(I.clearcoatMap.channel),clearcoatNormalMapUv:Ze&&w(I.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:kt&&w(I.clearcoatRoughnessMap.channel),iridescenceMapUv:en&&w(I.iridescenceMap.channel),iridescenceThicknessMapUv:Ft&&w(I.iridescenceThicknessMap.channel),sheenColorMapUv:dt&&w(I.sheenColorMap.channel),sheenRoughnessMapUv:on&&w(I.sheenRoughnessMap.channel),specularMapUv:dn&&w(I.specularMap.channel),specularColorMapUv:Qn&&w(I.specularColorMap.channel),specularIntensityMapUv:et&&w(I.specularIntensityMap.channel),transmissionMapUv:ce&&w(I.transmissionMap.channel),thicknessMapUv:Ue&&w(I.thicknessMap.channel),alphaMapUv:nt&&w(I.alphaMap.channel),vertexTangents:!!fe.attributes.tangent&&(We||Me),vertexColors:I.vertexColors,vertexAlphas:I.vertexColors===!0&&!!fe.attributes.color&&fe.attributes.color.itemSize===4,pointsUvs:Z.isPoints===!0&&!!fe.attributes.uv&&(ge||nt),fog:!!oe,useFog:I.fog===!0,fogExp2:!!oe&&oe.isFogExp2,flatShading:I.flatShading===!0,sizeAttenuation:I.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:Z.isSkinnedMesh===!0,morphTargets:fe.morphAttributes.position!==void 0,morphNormals:fe.morphAttributes.normal!==void 0,morphColors:fe.morphAttributes.color!==void 0,morphTargetsCount:de,morphTextureStride:Oe,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:I.dithering,shadowMapEnabled:n.shadowMap.enabled&&W.length>0,shadowMapType:n.shadowMap.type,toneMapping:Jn,useLegacyLights:n._useLegacyLights,decodeVideoTexture:ge&&I.map.isVideoTexture===!0&&Vn.getTransfer(I.map.colorSpace)===si,premultipliedAlpha:I.premultipliedAlpha,doubleSided:I.side===va,flipSided:I.side===ws,useDepthPacking:I.depthPacking>=0,depthPacking:I.depthPacking||0,index0AttributeName:I.index0AttributeName,extensionClipCullDistance:Tn&&I.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:Tn&&I.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:I.customProgramCacheKey()};return Ui.vertexUv1s=c.has(1),Ui.vertexUv2s=c.has(2),Ui.vertexUv3s=c.has(3),c.clear(),Ui}function x(I){const R=[];if(I.shaderID?R.push(I.shaderID):(R.push(I.customVertexShaderID),R.push(I.customFragmentShaderID)),I.defines!==void 0)for(const W in I.defines)R.push(W),R.push(I.defines[W]);return I.isRawShaderMaterial===!1&&(M(R,I),A(R,I),R.push(n.outputColorSpace)),R.push(I.customProgramCacheKey),R.join()}function M(I,R){I.push(R.precision),I.push(R.outputColorSpace),I.push(R.envMapMode),I.push(R.envMapCubeUVHeight),I.push(R.mapUv),I.push(R.alphaMapUv),I.push(R.lightMapUv),I.push(R.aoMapUv),I.push(R.bumpMapUv),I.push(R.normalMapUv),I.push(R.displacementMapUv),I.push(R.emissiveMapUv),I.push(R.metalnessMapUv),I.push(R.roughnessMapUv),I.push(R.anisotropyMapUv),I.push(R.clearcoatMapUv),I.push(R.clearcoatNormalMapUv),I.push(R.clearcoatRoughnessMapUv),I.push(R.iridescenceMapUv),I.push(R.iridescenceThicknessMapUv),I.push(R.sheenColorMapUv),I.push(R.sheenRoughnessMapUv),I.push(R.specularMapUv),I.push(R.specularColorMapUv),I.push(R.specularIntensityMapUv),I.push(R.transmissionMapUv),I.push(R.thicknessMapUv),I.push(R.combine),I.push(R.fogExp2),I.push(R.sizeAttenuation),I.push(R.morphTargetsCount),I.push(R.morphAttributeCount),I.push(R.numDirLights),I.push(R.numPointLights),I.push(R.numSpotLights),I.push(R.numSpotLightMaps),I.push(R.numHemiLights),I.push(R.numRectAreaLights),I.push(R.numDirLightShadows),I.push(R.numPointLightShadows),I.push(R.numSpotLightShadows),I.push(R.numSpotLightShadowsWithMaps),I.push(R.numLightProbes),I.push(R.shadowMapType),I.push(R.toneMapping),I.push(R.numClippingPlanes),I.push(R.numClipIntersection),I.push(R.depthPacking)}function A(I,R){a.disableAll(),R.supportsVertexTextures&&a.enable(0),R.instancing&&a.enable(1),R.instancingColor&&a.enable(2),R.instancingMorph&&a.enable(3),R.matcap&&a.enable(4),R.envMap&&a.enable(5),R.normalMapObjectSpace&&a.enable(6),R.normalMapTangentSpace&&a.enable(7),R.clearcoat&&a.enable(8),R.iridescence&&a.enable(9),R.alphaTest&&a.enable(10),R.vertexColors&&a.enable(11),R.vertexAlphas&&a.enable(12),R.vertexUv1s&&a.enable(13),R.vertexUv2s&&a.enable(14),R.vertexUv3s&&a.enable(15),R.vertexTangents&&a.enable(16),R.anisotropy&&a.enable(17),R.alphaHash&&a.enable(18),R.batching&&a.enable(19),R.dispersion&&a.enable(20),I.push(a.mask),a.disableAll(),R.fog&&a.enable(0),R.useFog&&a.enable(1),R.flatShading&&a.enable(2),R.logarithmicDepthBuffer&&a.enable(3),R.skinning&&a.enable(4),R.morphTargets&&a.enable(5),R.morphNormals&&a.enable(6),R.morphColors&&a.enable(7),R.premultipliedAlpha&&a.enable(8),R.shadowMapEnabled&&a.enable(9),R.useLegacyLights&&a.enable(10),R.doubleSided&&a.enable(11),R.flipSided&&a.enable(12),R.useDepthPacking&&a.enable(13),R.dithering&&a.enable(14),R.transmission&&a.enable(15),R.sheen&&a.enable(16),R.opaque&&a.enable(17),R.pointsUvs&&a.enable(18),R.decodeVideoTexture&&a.enable(19),R.alphaToCoverage&&a.enable(20),I.push(a.mask)}function C(I){const R=v[I.type];let W;if(R){const se=ga[R];W=FC.clone(se.uniforms)}else W=I.uniforms;return W}function N(I,R){let W;for(let se=0,Z=u.length;se0?i.push(x):y.transparent===!0?r.push(x):t.push(x)}function l(f,g,y,v,w,S){const x=o(f,g,y,v,w,S);y.transmission>0?i.unshift(x):y.transparent===!0?r.unshift(x):t.unshift(x)}function c(f,g){t.length>1&&t.sort(f||pZ),i.length>1&&i.sort(g||hL),r.length>1&&r.sort(g||hL)}function u(){for(let f=e,g=n.length;f=s.length?(o=new fL,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function gZ(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Q,color:new ht};break;case"SpotLight":t={position:new Q,direction:new Q,color:new ht,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Q,color:new ht,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Q,skyColor:new ht,groundColor:new ht};break;case"RectAreaLight":t={color:new ht,position:new Q,halfWidth:new Q,halfHeight:new Q};break}return n[e.id]=t,t}}}function yZ(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let vZ=0;function xZ(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function wZ(n){const e=new gZ,t=yZ(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new Q);const r=new Q,s=new Wt,o=new Wt;function a(c,u){let f=0,g=0,y=0;for(let W=0;W<9;W++)i.probe[W].set(0,0,0);let v=0,w=0,S=0,x=0,M=0,A=0,C=0,N=0,L=0,F=0,H=0;c.sort(xZ);const I=u===!0?Math.PI:1;for(let W=0,se=c.length;W0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=mt.LTC_FLOAT_1,i.rectAreaLTC2=mt.LTC_FLOAT_2):(i.rectAreaLTC1=mt.LTC_HALF_1,i.rectAreaLTC2=mt.LTC_HALF_2)),i.ambient[0]=f,i.ambient[1]=g,i.ambient[2]=y;const R=i.hash;(R.directionalLength!==v||R.pointLength!==w||R.spotLength!==S||R.rectAreaLength!==x||R.hemiLength!==M||R.numDirectionalShadows!==A||R.numPointShadows!==C||R.numSpotShadows!==N||R.numSpotMaps!==L||R.numLightProbes!==H)&&(i.directional.length=v,i.spot.length=S,i.rectArea.length=x,i.point.length=w,i.hemi.length=M,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=C,i.pointShadowMap.length=C,i.spotShadow.length=N,i.spotShadowMap.length=N,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=C,i.spotLightMatrix.length=N+L-F,i.spotLightMap.length=L,i.numSpotLightShadowsWithMaps=F,i.numLightProbes=H,R.directionalLength=v,R.pointLength=w,R.spotLength=S,R.rectAreaLength=x,R.hemiLength=M,R.numDirectionalShadows=A,R.numPointShadows=C,R.numSpotShadows=N,R.numSpotMaps=L,R.numLightProbes=H,i.version=vZ++)}function l(c,u){let f=0,g=0,y=0,v=0,w=0;const S=u.matrixWorldInverse;for(let x=0,M=c.length;x=o.length?(a=new dL(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}class BC extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=z4,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 VC extends nr{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}}const _Z=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,MZ=`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 AZ(n,e,t){let i=new Ry;const r=new Be,s=new Be,o=new qn,a=new BC({depthPacking:B4}),l=new VC,c={},u=t.maxTextureSize,f={[il]:ws,[ws]:il,[va]:va},g=new Fs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Be},radius:{value:4}},vertexShader:_Z,fragmentShader:MZ}),y=g.clone();y.defines.HORIZONTAL_PASS=1;const v=new cn;v.setAttribute("position",new On(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const w=new Fi(v,g),S=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=e_;let x=this.type;this.render=function(L,F,H){if(S.enabled===!1||S.autoUpdate===!1&&S.needsUpdate===!1||L.length===0)return;const I=n.getRenderTarget(),R=n.getActiveCubeFace(),W=n.getActiveMipmapLevel(),se=n.state;se.setBlending(Ja),se.buffers.color.setClear(1,1,1,1),se.buffers.depth.setTest(!0),se.setScissorTest(!1);const Z=x!==fa&&this.type===fa,oe=x===fa&&this.type!==fa;for(let fe=0,Se=L.length;feu||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ie.x),r.x=s.x*ie.x,X.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ie.y),r.y=s.y*ie.y,X.mapSize.y=s.y)),X.map===null||Z===!0||oe===!0){const de=this.type!==fa?{minFilter:Wi,magFilter:Wi}:{};X.map!==null&&X.map.dispose(),X.map=new uo(r.x,r.y,de),X.map.texture.name=Fe.name+".shadowMap",X.camera.updateProjectionMatrix()}n.setRenderTarget(X.map),n.clear();const re=X.getViewportCount();for(let de=0;de0||F.map&&F.alphaTest>0){const se=R.uuid,Z=F.uuid;let oe=c[se];oe===void 0&&(oe={},c[se]=oe);let fe=oe[Z];fe===void 0&&(fe=R.clone(),oe[Z]=fe,F.addEventListener("dispose",N)),R=fe}if(R.visible=F.visible,R.wireframe=F.wireframe,I===fa?R.side=F.shadowSide!==null?F.shadowSide:F.side:R.side=F.shadowSide!==null?F.shadowSide:f[F.side],R.alphaMap=F.alphaMap,R.alphaTest=F.alphaTest,R.map=F.map,R.clipShadows=F.clipShadows,R.clippingPlanes=F.clippingPlanes,R.clipIntersection=F.clipIntersection,R.displacementMap=F.displacementMap,R.displacementScale=F.displacementScale,R.displacementBias=F.displacementBias,R.wireframeLinewidth=F.wireframeLinewidth,R.linewidth=F.linewidth,H.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const se=n.properties.get(R);se.light=H}return R}function C(L,F,H,I,R){if(L.visible===!1)return;if(L.layers.test(F.layers)&&(L.isMesh||L.isLine||L.isPoints)&&(L.castShadow||L.receiveShadow&&R===fa)&&(!L.frustumCulled||i.intersectsObject(L))){L.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,L.matrixWorld);const Z=e.update(L),oe=L.material;if(Array.isArray(oe)){const fe=Z.groups;for(let Se=0,Fe=fe.length;Se=1):Fe.indexOf("OpenGL ES")!==-1&&(Se=parseFloat(/^OpenGL ES (\d)/.exec(Fe)[1]),fe=Se>=2);let X=null,ie={};const re=n.getParameter(n.SCISSOR_BOX),de=n.getParameter(n.VIEWPORT),Oe=new qn().fromArray(re),it=new qn().fromArray(de);function we(ce,Ue,Re,nt){const ct=new Uint8Array(4),pn=n.createTexture();n.bindTexture(ce,pn),n.texParameteri(ce,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(ce,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Tn=0;Tn"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Be,u=new WeakMap;let f;const g=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(te,q){return y?new OffscreenCanvas(te,q):ny("canvas")}function w(te,q,Me){let Ne=1;const je=Ct(te);if((je.width>Me||je.height>Me)&&(Ne=Me/Math.max(je.width,je.height)),Ne<1)if(typeof HTMLImageElement<"u"&&te instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&te instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&te instanceof ImageBitmap||typeof VideoFrame<"u"&&te instanceof VideoFrame){const ze=Math.floor(Ne*je.width),At=Math.floor(Ne*je.height);f===void 0&&(f=v(ze,At));const at=q?v(ze,At):f;return at.width=ze,at.height=At,at.getContext("2d").drawImage(te,0,0,ze,At),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+je.width+"x"+je.height+") to ("+ze+"x"+At+")."),at}else return"data"in te&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+je.width+"x"+je.height+")."),te;return te}function S(te){return te.generateMipmaps&&te.minFilter!==Wi&&te.minFilter!==Ni}function x(te){n.generateMipmap(te)}function M(te,q,Me,Ne,je=!1){if(te!==null){if(n[te]!==void 0)return n[te];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+te+"'")}let ze=q;if(q===n.RED&&(Me===n.FLOAT&&(ze=n.R32F),Me===n.HALF_FLOAT&&(ze=n.R16F),Me===n.UNSIGNED_BYTE&&(ze=n.R8)),q===n.RED_INTEGER&&(Me===n.UNSIGNED_BYTE&&(ze=n.R8UI),Me===n.UNSIGNED_SHORT&&(ze=n.R16UI),Me===n.UNSIGNED_INT&&(ze=n.R32UI),Me===n.BYTE&&(ze=n.R8I),Me===n.SHORT&&(ze=n.R16I),Me===n.INT&&(ze=n.R32I)),q===n.RG&&(Me===n.FLOAT&&(ze=n.RG32F),Me===n.HALF_FLOAT&&(ze=n.RG16F),Me===n.UNSIGNED_BYTE&&(ze=n.RG8)),q===n.RG_INTEGER&&(Me===n.UNSIGNED_BYTE&&(ze=n.RG8UI),Me===n.UNSIGNED_SHORT&&(ze=n.RG16UI),Me===n.UNSIGNED_INT&&(ze=n.RG32UI),Me===n.BYTE&&(ze=n.RG8I),Me===n.SHORT&&(ze=n.RG16I),Me===n.INT&&(ze=n.RG32I)),q===n.RGB&&Me===n.UNSIGNED_INT_5_9_9_9_REV&&(ze=n.RGB9_E5),q===n.RGBA){const At=je?J0:Vn.getTransfer(Ne);Me===n.FLOAT&&(ze=n.RGBA32F),Me===n.HALF_FLOAT&&(ze=n.RGBA16F),Me===n.UNSIGNED_BYTE&&(ze=At===si?n.SRGB8_ALPHA8:n.RGBA8),Me===n.UNSIGNED_SHORT_4_4_4_4&&(ze=n.RGBA4),Me===n.UNSIGNED_SHORT_5_5_5_1&&(ze=n.RGB5_A1)}return(ze===n.R16F||ze===n.R32F||ze===n.RG16F||ze===n.RG32F||ze===n.RGBA16F||ze===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ze}function A(te,q){return S(te)===!0||te.isFramebufferTexture&&te.minFilter!==Wi&&te.minFilter!==Ni?Math.log2(Math.max(q.width,q.height))+1:te.mipmaps!==void 0&&te.mipmaps.length>0?te.mipmaps.length:te.isCompressedTexture&&Array.isArray(te.image)?q.mipmaps.length:1}function C(te){const q=te.target;q.removeEventListener("dispose",C),L(q),q.isVideoTexture&&u.delete(q)}function N(te){const q=te.target;q.removeEventListener("dispose",N),H(q)}function L(te){const q=i.get(te);if(q.__webglInit===void 0)return;const Me=te.source,Ne=g.get(Me);if(Ne){const je=Ne[q.__cacheKey];je.usedTimes--,je.usedTimes===0&&F(te),Object.keys(Ne).length===0&&g.delete(Me)}i.remove(te)}function F(te){const q=i.get(te);n.deleteTexture(q.__webglTexture);const Me=te.source,Ne=g.get(Me);delete Ne[q.__cacheKey],o.memory.textures--}function H(te){const q=i.get(te);if(te.depthTexture&&te.depthTexture.dispose(),te.isWebGLCubeRenderTarget)for(let Ne=0;Ne<6;Ne++){if(Array.isArray(q.__webglFramebuffer[Ne]))for(let je=0;je=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+te+" texture units while this GPU supports only "+r.maxTextures),I+=1,te}function se(te){const q=[];return q.push(te.wrapS),q.push(te.wrapT),q.push(te.wrapR||0),q.push(te.magFilter),q.push(te.minFilter),q.push(te.anisotropy),q.push(te.internalFormat),q.push(te.format),q.push(te.type),q.push(te.generateMipmaps),q.push(te.premultiplyAlpha),q.push(te.flipY),q.push(te.unpackAlignment),q.push(te.colorSpace),q.join()}function Z(te,q){const Me=i.get(te);if(te.isVideoTexture&&We(te),te.isRenderTargetTexture===!1&&te.version>0&&Me.__version!==te.version){const Ne=te.image;if(Ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Oe(Me,te,q);return}}t.bindTexture(n.TEXTURE_2D,Me.__webglTexture,n.TEXTURE0+q)}function oe(te,q){const Me=i.get(te);if(te.version>0&&Me.__version!==te.version){Oe(Me,te,q);return}t.bindTexture(n.TEXTURE_2D_ARRAY,Me.__webglTexture,n.TEXTURE0+q)}function fe(te,q){const Me=i.get(te);if(te.version>0&&Me.__version!==te.version){Oe(Me,te,q);return}t.bindTexture(n.TEXTURE_3D,Me.__webglTexture,n.TEXTURE0+q)}function Se(te,q){const Me=i.get(te);if(te.version>0&&Me.__version!==te.version){it(Me,te,q);return}t.bindTexture(n.TEXTURE_CUBE_MAP,Me.__webglTexture,n.TEXTURE0+q)}const Fe={[cu]:n.REPEAT,[io]:n.CLAMP_TO_EDGE,[Kp]:n.MIRRORED_REPEAT},X={[Wi]:n.NEAREST,[n_]:n.NEAREST_MIPMAP_NEAREST,[Lh]:n.NEAREST_MIPMAP_LINEAR,[Ni]:n.LINEAR,[Dp]:n.LINEAR_MIPMAP_NEAREST,[Wo]:n.LINEAR_MIPMAP_LINEAR},ie={[H4]:n.NEVER,[Y4]:n.ALWAYS,[G4]:n.LESS,[LC]:n.LEQUAL,[W4]:n.EQUAL,[q4]:n.GEQUAL,[j4]:n.GREATER,[X4]:n.NOTEQUAL};function re(te,q){if(q.type===jo&&e.has("OES_texture_float_linear")===!1&&(q.magFilter===Ni||q.magFilter===Dp||q.magFilter===Lh||q.magFilter===Wo||q.minFilter===Ni||q.minFilter===Dp||q.minFilter===Lh||q.minFilter===Wo)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(te,n.TEXTURE_WRAP_S,Fe[q.wrapS]),n.texParameteri(te,n.TEXTURE_WRAP_T,Fe[q.wrapT]),(te===n.TEXTURE_3D||te===n.TEXTURE_2D_ARRAY)&&n.texParameteri(te,n.TEXTURE_WRAP_R,Fe[q.wrapR]),n.texParameteri(te,n.TEXTURE_MAG_FILTER,X[q.magFilter]),n.texParameteri(te,n.TEXTURE_MIN_FILTER,X[q.minFilter]),q.compareFunction&&(n.texParameteri(te,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(te,n.TEXTURE_COMPARE_FUNC,ie[q.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(q.magFilter===Wi||q.minFilter!==Lh&&q.minFilter!==Wo||q.type===jo&&e.has("OES_texture_float_linear")===!1)return;if(q.anisotropy>1||i.get(q).__currentAnisotropy){const Me=e.get("EXT_texture_filter_anisotropic");n.texParameterf(te,Me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(q.anisotropy,r.getMaxAnisotropy())),i.get(q).__currentAnisotropy=q.anisotropy}}}function de(te,q){let Me=!1;te.__webglInit===void 0&&(te.__webglInit=!0,q.addEventListener("dispose",C));const Ne=q.source;let je=g.get(Ne);je===void 0&&(je={},g.set(Ne,je));const ze=se(q);if(ze!==te.__cacheKey){je[ze]===void 0&&(je[ze]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,Me=!0),je[ze].usedTimes++;const At=je[te.__cacheKey];At!==void 0&&(je[te.__cacheKey].usedTimes--,At.usedTimes===0&&F(q)),te.__cacheKey=ze,te.__webglTexture=je[ze].texture}return Me}function Oe(te,q,Me){let Ne=n.TEXTURE_2D;(q.isDataArrayTexture||q.isCompressedArrayTexture)&&(Ne=n.TEXTURE_2D_ARRAY),q.isData3DTexture&&(Ne=n.TEXTURE_3D);const je=de(te,q),ze=q.source;t.bindTexture(Ne,te.__webglTexture,n.TEXTURE0+Me);const At=i.get(ze);if(ze.version!==At.__version||je===!0){t.activeTexture(n.TEXTURE0+Me);const at=Vn.getPrimaries(Vn.workingColorSpace),lt=q.colorSpace===Ll?null:Vn.getPrimaries(q.colorSpace),Zt=q.colorSpace===Ll||at===lt?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,q.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,q.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,q.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Zt);let Ze=w(q.image,!1,r.maxTextureSize);Ze=ft(q,Ze);const kt=s.convert(q.format,q.colorSpace),en=s.convert(q.type);let Ft=M(q.internalFormat,kt,en,q.colorSpace,q.isVideoTexture);re(Ne,q);let dt;const on=q.mipmaps,dn=q.isVideoTexture!==!0,Qn=At.__version===void 0||je===!0,et=ze.dataReady,ce=A(q,Ze);if(q.isDepthTexture)Ft=n.DEPTH_COMPONENT16,q.type===jo?Ft=n.DEPTH_COMPONENT32F:q.type===Qh?Ft=n.DEPTH_COMPONENT24:q.type===fm&&(Ft=n.DEPTH24_STENCIL8),Qn&&(dn?t.texStorage2D(n.TEXTURE_2D,1,Ft,Ze.width,Ze.height):t.texImage2D(n.TEXTURE_2D,0,Ft,Ze.width,Ze.height,0,kt,en,null));else if(q.isDataTexture)if(on.length>0){dn&&Qn&&t.texStorage2D(n.TEXTURE_2D,ce,Ft,on[0].width,on[0].height);for(let Ue=0,Re=on.length;Ue>=1,Re>>=1}}else if(on.length>0){if(dn&&Qn){const Ue=Ct(on[0]);t.texStorage2D(n.TEXTURE_2D,ce,Ft,Ue.width,Ue.height)}for(let Ue=0,Re=on.length;Ue0&&ce++;const Re=Ct(kt[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ce,on,Re.width,Re.height)}for(let Re=0;Re<6;Re++)if(Ze){dn?et&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,kt[Re].width,kt[Re].height,Ft,dt,kt[Re].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,on,kt[Re].width,kt[Re].height,0,Ft,dt,kt[Re].data);for(let nt=0;nt>ze),kt=Math.max(1,q.height>>ze);je===n.TEXTURE_3D||je===n.TEXTURE_2D_ARRAY?t.texImage3D(je,ze,lt,Ze,kt,q.depth,0,At,at,null):t.texImage2D(je,ze,lt,Ze,kt,0,At,at,null)}t.bindFramebuffer(n.FRAMEBUFFER,te),rt(q)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ne,je,i.get(Me).__webglTexture,0,Pe(q)):(je===n.TEXTURE_2D||je>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&je<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Ne,je,i.get(Me).__webglTexture,ze),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ve(te,q,Me){if(n.bindRenderbuffer(n.RENDERBUFFER,te),q.depthBuffer&&!q.stencilBuffer){let Ne=n.DEPTH_COMPONENT24;if(Me||rt(q)){const je=q.depthTexture;je&&je.isDepthTexture&&(je.type===jo?Ne=n.DEPTH_COMPONENT32F:je.type===Qh&&(Ne=n.DEPTH_COMPONENT24));const ze=Pe(q);rt(q)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ze,Ne,q.width,q.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,ze,Ne,q.width,q.height)}else n.renderbufferStorage(n.RENDERBUFFER,Ne,q.width,q.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,te)}else if(q.depthBuffer&&q.stencilBuffer){const Ne=Pe(q);Me&&rt(q)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ne,n.DEPTH24_STENCIL8,q.width,q.height):rt(q)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ne,n.DEPTH24_STENCIL8,q.width,q.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,q.width,q.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,te)}else{const Ne=q.textures;for(let je=0;je1;if(At||(Ne.__webglTexture===void 0&&(Ne.__webglTexture=n.createTexture()),Ne.__version=q.version,o.memory.textures++),ze){Me.__webglFramebuffer=[];for(let at=0;at<6;at++)if(q.mipmaps&&q.mipmaps.length>0){Me.__webglFramebuffer[at]=[];for(let lt=0;lt0){Me.__webglFramebuffer=[];for(let at=0;at0&&rt(te)===!1){Me.__webglMultisampledFramebuffer=n.createFramebuffer(),Me.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,Me.__webglMultisampledFramebuffer);for(let at=0;at0)for(let lt=0;lt0)for(let lt=0;lt0){if(rt(te)===!1){const q=te.textures,Me=te.width,Ne=te.height;let je=n.COLOR_BUFFER_BIT;const ze=te.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,At=i.get(te),at=q.length>1;if(at)for(let lt=0;lt0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&q.__useRenderToTexture!==!1}function We(te){const q=o.render.frame;u.get(te)!==q&&(u.set(te,q),te.update())}function ft(te,q){const Me=te.colorSpace,Ne=te.format,je=te.type;return te.isCompressedTexture===!0||te.isVideoTexture===!0||Me!==mr&&Me!==Ll&&(Vn.getTransfer(Me)===si?(Ne!==vs||je!==rl)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Me)),q}function Ct(te){return typeof HTMLImageElement<"u"&&te instanceof HTMLImageElement?(c.width=te.naturalWidth||te.width,c.height=te.naturalHeight||te.height):typeof VideoFrame<"u"&&te instanceof VideoFrame?(c.width=te.displayWidth,c.height=te.displayHeight):(c.width=te.width,c.height=te.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=R,this.setTexture2D=Z,this.setTexture2DArray=oe,this.setTexture3D=fe,this.setTextureCube=Se,this.rebindTextures=Xt,this.setupRenderTarget=jt,this.updateRenderTargetMipmap=ge,this.updateMultisampleRenderTarget=Ge,this.setupDepthRenderbuffer=He,this.setupFrameBufferTexture=we,this.useMultisampledRTT=rt}function uz(n,e){function t(i,r=Ll){let s;const o=Vn.getTransfer(r);if(i===rl)return n.UNSIGNED_BYTE;if(i===AC)return n.UNSIGNED_SHORT_4_4_4_4;if(i===bC)return n.UNSIGNED_SHORT_5_5_5_1;if(i===C4)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===E4)return n.BYTE;if(i===T4)return n.SHORT;if(i===_C)return n.UNSIGNED_SHORT;if(i===MC)return n.INT;if(i===Qh)return n.UNSIGNED_INT;if(i===jo)return n.FLOAT;if(i===hf)return n.HALF_FLOAT;if(i===P4)return n.ALPHA;if(i===R4)return n.RGB;if(i===vs)return n.RGBA;if(i===k4)return n.LUMINANCE;if(i===L4)return n.LUMINANCE_ALPHA;if(i===Hh)return n.DEPTH_COMPONENT;if(i===Zp)return n.DEPTH_STENCIL;if(i===EC)return n.RED;if(i===TC)return n.RED_INTEGER;if(i===I4)return n.RG;if(i===CC)return n.RG_INTEGER;if(i===PC)return n.RGBA_INTEGER;if(i===rw||i===sw||i===ow||i===aw)if(o===si)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===rw)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===sw)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ow)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===aw)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===rw)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===sw)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ow)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===aw)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===KE||i===ZE||i===JE||i===QE)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===KE)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===ZE)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===JE)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===QE)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===$E||i===eT||i===tT)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===$E||i===eT)return o===si?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===tT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===nT||i===iT||i===rT||i===sT||i===oT||i===aT||i===lT||i===cT||i===uT||i===hT||i===fT||i===dT||i===pT||i===mT)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===nT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===iT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===rT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===sT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===oT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===aT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===lT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===cT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===uT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===hT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===fT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===dT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===pT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===mT)return o===si?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===lw||i===gT||i===yT)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===lw)return o===si?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===gT)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===yT)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===D4||i===vT||i===xT||i===wT)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===lw)return s.COMPRESSED_RED_RGTC1_EXT;if(i===vT)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===xT)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===wT)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===fm?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class hz extends fr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Xa extends Dn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const TZ={type:"move"};class GA{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xa,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 Xa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Q,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Q),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Q,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Q),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const w of e.hand.values()){const S=t.getJointPose(w,i),x=this._getHandJoint(c,w);S!==null&&(x.matrix.fromArray(S.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=S.radius),x.visible=S!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],g=u.position.distanceTo(f.position),y=.02,v=.005;c.inputState.pinching&&g>y+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=y-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(TZ)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Xa;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const CZ=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,PZ=` +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 RZ{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new hi,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){const i=t.cameras[0].viewport,r=new Fs({vertexShader:CZ,fragmentShader:PZ,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new Fi(new pm(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}}class kZ extends Jl{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,g=null,y=null,v=null;const w=new RZ,S=t.getContextAttributes();let x=null,M=null;const A=[],C=[],N=new Be;let L=null;const F=new fr;F.layers.enable(1),F.viewport=new qn;const H=new fr;H.layers.enable(2),H.viewport=new qn;const I=[F,H],R=new hz;R.layers.enable(1),R.layers.enable(2);let W=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(we){let Ve=A[we];return Ve===void 0&&(Ve=new GA,A[we]=Ve),Ve.getTargetRaySpace()},this.getControllerGrip=function(we){let Ve=A[we];return Ve===void 0&&(Ve=new GA,A[we]=Ve),Ve.getGripSpace()},this.getHand=function(we){let Ve=A[we];return Ve===void 0&&(Ve=new GA,A[we]=Ve),Ve.getHandSpace()};function Z(we){const Ve=C.indexOf(we.inputSource);if(Ve===-1)return;const Ye=A[Ve];Ye!==void 0&&(Ye.update(we.inputSource,we.frame,c||o),Ye.dispatchEvent({type:we.type,data:we.inputSource}))}function oe(){r.removeEventListener("select",Z),r.removeEventListener("selectstart",Z),r.removeEventListener("selectend",Z),r.removeEventListener("squeeze",Z),r.removeEventListener("squeezestart",Z),r.removeEventListener("squeezeend",Z),r.removeEventListener("end",oe),r.removeEventListener("inputsourceschange",fe);for(let we=0;we=0&&(C[He]=null,A[He].disconnect(Ye))}for(let Ve=0;Ve=C.length){C.push(Ye),He=jt;break}else if(C[jt]===null){C[jt]=Ye,He=jt;break}if(He===-1)break}const Xt=A[He];Xt&&Xt.connect(Ye)}}const Se=new Q,Fe=new Q;function X(we,Ve,Ye){Se.setFromMatrixPosition(Ve.matrixWorld),Fe.setFromMatrixPosition(Ye.matrixWorld);const He=Se.distanceTo(Fe),Xt=Ve.projectionMatrix.elements,jt=Ye.projectionMatrix.elements,ge=Xt[14]/(Xt[10]-1),Dt=Xt[14]/(Xt[10]+1),Ie=(Xt[9]+1)/Xt[5],Ge=(Xt[9]-1)/Xt[5],Pe=(Xt[8]-1)/Xt[0],rt=(jt[8]+1)/jt[0],We=ge*Pe,ft=ge*rt,Ct=He/(-Pe+rt),te=Ct*-Pe;Ve.matrixWorld.decompose(we.position,we.quaternion,we.scale),we.translateX(te),we.translateZ(Ct),we.matrixWorld.compose(we.position,we.quaternion,we.scale),we.matrixWorldInverse.copy(we.matrixWorld).invert();const q=ge+Ct,Me=Dt+Ct,Ne=We-te,je=ft+(He-te),ze=Ie*Dt/Me*q,At=Ge*Dt/Me*q;we.projectionMatrix.makePerspective(Ne,je,ze,At,q,Me),we.projectionMatrixInverse.copy(we.projectionMatrix).invert()}function ie(we,Ve){Ve===null?we.matrixWorld.copy(we.matrix):we.matrixWorld.multiplyMatrices(Ve.matrixWorld,we.matrix),we.matrixWorldInverse.copy(we.matrixWorld).invert()}this.updateCamera=function(we){if(r===null)return;w.texture!==null&&(we.near=w.depthNear,we.far=w.depthFar),R.near=H.near=F.near=we.near,R.far=H.far=F.far=we.far,(W!==R.near||se!==R.far)&&(r.updateRenderState({depthNear:R.near,depthFar:R.far}),W=R.near,se=R.far,F.near=W,F.far=se,H.near=W,H.far=se,F.updateProjectionMatrix(),H.updateProjectionMatrix(),we.updateProjectionMatrix());const Ve=we.parent,Ye=R.cameras;ie(R,Ve);for(let He=0;He0&&(S.alphaTest.value=x.alphaTest);const M=e.get(x),A=M.envMap,C=M.envMapRotation;if(A&&(S.envMap.value=A,ah.copy(C),ah.x*=-1,ah.y*=-1,ah.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(ah.y*=-1,ah.z*=-1),S.envMapRotation.value.setFromMatrix4(LZ.makeRotationFromEuler(ah)),S.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=x.reflectivity,S.ior.value=x.ior,S.refractionRatio.value=x.refractionRatio),x.lightMap){S.lightMap.value=x.lightMap;const N=n._useLegacyLights===!0?Math.PI:1;S.lightMapIntensity.value=x.lightMapIntensity*N,t(x.lightMap,S.lightMapTransform)}x.aoMap&&(S.aoMap.value=x.aoMap,S.aoMapIntensity.value=x.aoMapIntensity,t(x.aoMap,S.aoMapTransform))}function o(S,x){S.diffuse.value.copy(x.color),S.opacity.value=x.opacity,x.map&&(S.map.value=x.map,t(x.map,S.mapTransform))}function a(S,x){S.dashSize.value=x.dashSize,S.totalSize.value=x.dashSize+x.gapSize,S.scale.value=x.scale}function l(S,x,M,A){S.diffuse.value.copy(x.color),S.opacity.value=x.opacity,S.size.value=x.size*M,S.scale.value=A*.5,x.map&&(S.map.value=x.map,t(x.map,S.uvTransform)),x.alphaMap&&(S.alphaMap.value=x.alphaMap,t(x.alphaMap,S.alphaMapTransform)),x.alphaTest>0&&(S.alphaTest.value=x.alphaTest)}function c(S,x){S.diffuse.value.copy(x.color),S.opacity.value=x.opacity,S.rotation.value=x.rotation,x.map&&(S.map.value=x.map,t(x.map,S.mapTransform)),x.alphaMap&&(S.alphaMap.value=x.alphaMap,t(x.alphaMap,S.alphaMapTransform)),x.alphaTest>0&&(S.alphaTest.value=x.alphaTest)}function u(S,x){S.specular.value.copy(x.specular),S.shininess.value=Math.max(x.shininess,1e-4)}function f(S,x){x.gradientMap&&(S.gradientMap.value=x.gradientMap)}function g(S,x){S.metalness.value=x.metalness,x.metalnessMap&&(S.metalnessMap.value=x.metalnessMap,t(x.metalnessMap,S.metalnessMapTransform)),S.roughness.value=x.roughness,x.roughnessMap&&(S.roughnessMap.value=x.roughnessMap,t(x.roughnessMap,S.roughnessMapTransform)),x.envMap&&(S.envMapIntensity.value=x.envMapIntensity)}function y(S,x,M){S.ior.value=x.ior,x.sheen>0&&(S.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),S.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(S.sheenColorMap.value=x.sheenColorMap,t(x.sheenColorMap,S.sheenColorMapTransform)),x.sheenRoughnessMap&&(S.sheenRoughnessMap.value=x.sheenRoughnessMap,t(x.sheenRoughnessMap,S.sheenRoughnessMapTransform))),x.clearcoat>0&&(S.clearcoat.value=x.clearcoat,S.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(S.clearcoatMap.value=x.clearcoatMap,t(x.clearcoatMap,S.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,t(x.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(S.clearcoatNormalMap.value=x.clearcoatNormalMap,t(x.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===ws&&S.clearcoatNormalScale.value.negate())),x.dispersion>0&&(S.dispersion.value=x.dispersion),x.iridescence>0&&(S.iridescence.value=x.iridescence,S.iridescenceIOR.value=x.iridescenceIOR,S.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(S.iridescenceMap.value=x.iridescenceMap,t(x.iridescenceMap,S.iridescenceMapTransform)),x.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=x.iridescenceThicknessMap,t(x.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),x.transmission>0&&(S.transmission.value=x.transmission,S.transmissionSamplerMap.value=M.texture,S.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(S.transmissionMap.value=x.transmissionMap,t(x.transmissionMap,S.transmissionMapTransform)),S.thickness.value=x.thickness,x.thicknessMap&&(S.thicknessMap.value=x.thicknessMap,t(x.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=x.attenuationDistance,S.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(S.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(S.anisotropyMap.value=x.anisotropyMap,t(x.anisotropyMap,S.anisotropyMapTransform))),S.specularIntensity.value=x.specularIntensity,S.specularColor.value.copy(x.specularColor),x.specularColorMap&&(S.specularColorMap.value=x.specularColorMap,t(x.specularColorMap,S.specularColorMapTransform)),x.specularIntensityMap&&(S.specularIntensityMap.value=x.specularIntensityMap,t(x.specularIntensityMap,S.specularIntensityMapTransform))}function v(S,x){x.matcap&&(S.matcap.value=x.matcap)}function w(S,x){const M=e.get(x).light;S.referencePosition.value.setFromMatrixPosition(M.matrixWorld),S.nearDistance.value=M.shadow.camera.near,S.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function DZ(n,e,t,i){let r={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,A){const C=A.program;i.uniformBlockBinding(M,C)}function c(M,A){let C=r[M.id];C===void 0&&(v(M),C=u(M),r[M.id]=C,M.addEventListener("dispose",S));const N=A.program;i.updateUBOMapping(M,N);const L=e.render.frame;s[M.id]!==L&&(g(M),s[M.id]=L)}function u(M){const A=f();M.__bindingPointIndex=A;const C=n.createBuffer(),N=M.__size,L=M.usage;return n.bindBuffer(n.UNIFORM_BUFFER,C),n.bufferData(n.UNIFORM_BUFFER,N,L),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,C),C}function f(){for(let M=0;M0&&(C+=N-L),M.__size=C,M.__cache={},this}function w(M){const A={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(A.boundary=4,A.storage=4):M.isVector2?(A.boundary=8,A.storage=8):M.isVector3||M.isColor?(A.boundary=16,A.storage=12):M.isVector4?(A.boundary=16,A.storage=16):M.isMatrix3?(A.boundary=48,A.storage=48):M.isMatrix4?(A.boundary=64,A.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),A}function S(M){const A=M.target;A.removeEventListener("dispose",S);const C=o.indexOf(A.__bindingPointIndex);o.splice(C,1),n.deleteBuffer(r[A.id]),delete r[A.id],delete s[A.id]}function x(){for(const M in r)n.deleteBuffer(r[M]);o=[],r={},s={}}return{bind:l,update:c,dispose:x}}class fz{constructor(e={}){const{canvas:t=Z4(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=i.getContextAttributes().alpha}else g=o;const y=new Uint32Array(4),v=new Int32Array(4);let w=null,S=null;const x=[],M=[];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=hr,this._useLegacyLights=!1,this.toneMapping=Qa,this.toneMappingExposure=1;const A=this;let C=!1,N=0,L=0,F=null,H=-1,I=null;const R=new qn,W=new qn;let se=null;const Z=new ht(0);let oe=0,fe=t.width,Se=t.height,Fe=1,X=null,ie=null;const re=new qn(0,0,fe,Se),de=new qn(0,0,fe,Se);let Oe=!1;const it=new Ry;let we=!1,Ve=!1;const Ye=new Wt,He=new Q,Xt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function jt(){return F===null?Fe:1}let ge=i;function Dt(K,ye){return t.getContext(K,ye)}try{const K={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${$S}`),t.addEventListener("webglcontextlost",ce,!1),t.addEventListener("webglcontextrestored",Ue,!1),t.addEventListener("webglcontextcreationerror",Re,!1),ge===null){const ye="webgl2";if(ge=Dt(ye,K),ge===null)throw Dt(ye)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(K){throw console.error("THREE.WebGLRenderer: "+K.message),K}let Ie,Ge,Pe,rt,We,ft,Ct,te,q,Me,Ne,je,ze,At,at,lt,Zt,Ze,kt,en,Ft,dt,on,dn;function Qn(){Ie=new qY(ge),Ie.init(),dt=new uz(ge,Ie),Ge=new VY(ge,Ie,e,dt),Pe=new bZ(ge),rt=new ZY(ge),We=new dZ,ft=new EZ(ge,Ie,Pe,We,Ge,dt,rt),Ct=new GY(A),te=new XY(A),q=new iX(ge),on=new zY(ge,q),Me=new YY(ge,q,rt,on),Ne=new QY(ge,Me,q,rt),kt=new JY(ge,Ge,ft),lt=new HY(We),je=new fZ(A,Ct,te,Ie,Ge,on,lt),ze=new IZ(A,We),At=new mZ,at=new SZ(Ie),Ze=new UY(A,Ct,te,Pe,Ne,g,l),Zt=new AZ(A,Ne,Ge),dn=new DZ(ge,rt,Ge,Pe),en=new BY(ge,Ie,rt),Ft=new KY(ge,Ie,rt),rt.programs=je.programs,A.capabilities=Ge,A.extensions=Ie,A.properties=We,A.renderLists=At,A.shadowMap=Zt,A.state=Pe,A.info=rt}Qn();const et=new kZ(A,ge);this.xr=et,this.getContext=function(){return ge},this.getContextAttributes=function(){return ge.getContextAttributes()},this.forceContextLoss=function(){const K=Ie.get("WEBGL_lose_context");K&&K.loseContext()},this.forceContextRestore=function(){const K=Ie.get("WEBGL_lose_context");K&&K.restoreContext()},this.getPixelRatio=function(){return Fe},this.setPixelRatio=function(K){K!==void 0&&(Fe=K,this.setSize(fe,Se,!1))},this.getSize=function(K){return K.set(fe,Se)},this.setSize=function(K,ye,Ee=!0){if(et.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}fe=K,Se=ye,t.width=Math.floor(K*Fe),t.height=Math.floor(ye*Fe),Ee===!0&&(t.style.width=K+"px",t.style.height=ye+"px"),this.setViewport(0,0,K,ye)},this.getDrawingBufferSize=function(K){return K.set(fe*Fe,Se*Fe).floor()},this.setDrawingBufferSize=function(K,ye,Ee){fe=K,Se=ye,Fe=Ee,t.width=Math.floor(K*Ee),t.height=Math.floor(ye*Ee),this.setViewport(0,0,K,ye)},this.getCurrentViewport=function(K){return K.copy(R)},this.getViewport=function(K){return K.copy(re)},this.setViewport=function(K,ye,Ee,_e){K.isVector4?re.set(K.x,K.y,K.z,K.w):re.set(K,ye,Ee,_e),Pe.viewport(R.copy(re).multiplyScalar(Fe).round())},this.getScissor=function(K){return K.copy(de)},this.setScissor=function(K,ye,Ee,_e){K.isVector4?de.set(K.x,K.y,K.z,K.w):de.set(K,ye,Ee,_e),Pe.scissor(W.copy(de).multiplyScalar(Fe).round())},this.getScissorTest=function(){return Oe},this.setScissorTest=function(K){Pe.setScissorTest(Oe=K)},this.setOpaqueSort=function(K){X=K},this.setTransparentSort=function(K){ie=K},this.getClearColor=function(K){return K.copy(Ze.getClearColor())},this.setClearColor=function(){Ze.setClearColor.apply(Ze,arguments)},this.getClearAlpha=function(){return Ze.getClearAlpha()},this.setClearAlpha=function(){Ze.setClearAlpha.apply(Ze,arguments)},this.clear=function(K=!0,ye=!0,Ee=!0){let _e=0;if(K){let Ae=!1;if(F!==null){const st=F.texture.format;Ae=st===PC||st===CC||st===TC}if(Ae){const st=F.texture.type,Lt=st===rl||st===Qh||st===_C||st===fm||st===AC||st===bC,Ot=Ze.getClearColor(),qt=Ze.getClearAlpha(),tn=Ot.r,nn=Ot.g,rn=Ot.b;Lt?(y[0]=tn,y[1]=nn,y[2]=rn,y[3]=qt,ge.clearBufferuiv(ge.COLOR,0,y)):(v[0]=tn,v[1]=nn,v[2]=rn,v[3]=qt,ge.clearBufferiv(ge.COLOR,0,v))}else _e|=ge.COLOR_BUFFER_BIT}ye&&(_e|=ge.DEPTH_BUFFER_BIT),Ee&&(_e|=ge.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ge.clear(_e)},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",ce,!1),t.removeEventListener("webglcontextrestored",Ue,!1),t.removeEventListener("webglcontextcreationerror",Re,!1),At.dispose(),at.dispose(),We.dispose(),Ct.dispose(),te.dispose(),Ne.dispose(),on.dispose(),dn.dispose(),je.dispose(),et.dispose(),et.removeEventListener("sessionstart",kn),et.removeEventListener("sessionend",is),qi.stop()};function ce(K){K.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),C=!0}function Ue(){console.log("THREE.WebGLRenderer: Context Restored."),C=!1;const K=rt.autoReset,ye=Zt.enabled,Ee=Zt.autoUpdate,_e=Zt.needsUpdate,Ae=Zt.type;Qn(),rt.autoReset=K,Zt.enabled=ye,Zt.autoUpdate=Ee,Zt.needsUpdate=_e,Zt.type=Ae}function Re(K){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",K.statusMessage)}function nt(K){const ye=K.target;ye.removeEventListener("dispose",nt),ct(ye)}function ct(K){pn(K),We.remove(K)}function pn(K){const ye=We.get(K).programs;ye!==void 0&&(ye.forEach(function(Ee){je.releaseProgram(Ee)}),K.isShaderMaterial&&je.releaseShaderCache(K))}this.renderBufferDirect=function(K,ye,Ee,_e,Ae,st){ye===null&&(ye=Xt);const Lt=Ae.isMesh&&Ae.matrixWorld.determinant()<0,Ot=vo(K,ye,Ee,_e,Ae);Pe.setMaterial(_e,Lt);let qt=Ee.index,tn=1;if(_e.wireframe===!0){if(qt=Me.getWireframeAttribute(Ee),qt===void 0)return;tn=2}const nn=Ee.drawRange,rn=Ee.attributes.position;let $n=nn.start*tn,Ti=(nn.start+nn.count)*tn;st!==null&&($n=Math.max($n,st.start*tn),Ti=Math.min(Ti,(st.start+st.count)*tn)),qt!==null?($n=Math.max($n,0),Ti=Math.min(Ti,qt.count)):rn!=null&&($n=Math.max($n,0),Ti=Math.min(Ti,rn.count));const vr=Ti-$n;if(vr<0||vr===1/0)return;on.setup(Ae,_e,Ot,Ee,qt);let Br,vn=en;if(qt!==null&&(Br=q.get(qt),vn=Ft,vn.setIndex(Br)),Ae.isMesh)_e.wireframe===!0?(Pe.setLineWidth(_e.wireframeLinewidth*jt()),vn.setMode(ge.LINES)):vn.setMode(ge.TRIANGLES);else if(Ae.isLine){let Ht=_e.linewidth;Ht===void 0&&(Ht=1),Pe.setLineWidth(Ht*jt()),Ae.isLineSegments?vn.setMode(ge.LINES):Ae.isLineLoop?vn.setMode(ge.LINE_LOOP):vn.setMode(ge.LINE_STRIP)}else Ae.isPoints?vn.setMode(ge.POINTS):Ae.isSprite&&vn.setMode(ge.TRIANGLES);if(Ae.isBatchedMesh)Ae._multiDrawInstances!==null?vn.renderMultiDrawInstances(Ae._multiDrawStarts,Ae._multiDrawCounts,Ae._multiDrawCount,Ae._multiDrawInstances):vn.renderMultiDraw(Ae._multiDrawStarts,Ae._multiDrawCounts,Ae._multiDrawCount);else if(Ae.isInstancedMesh)vn.renderInstances($n,vr,Ae.count);else if(Ee.isInstancedBufferGeometry){const Ht=Ee._maxInstanceCount!==void 0?Ee._maxInstanceCount:1/0,_n=Math.min(Ee.instanceCount,Ht);vn.renderInstances($n,vr,_n)}else vn.render($n,vr)};function Tn(K,ye,Ee){K.transparent===!0&&K.side===va&&K.forceSinglePass===!1?(K.side=ws,K.needsUpdate=!0,ol(K,ye,Ee),K.side=il,K.needsUpdate=!0,ol(K,ye,Ee),K.side=va):ol(K,ye,Ee)}this.compile=function(K,ye,Ee=null){Ee===null&&(Ee=K),S=at.get(Ee),S.init(ye),M.push(S),Ee.traverseVisible(function(Ae){Ae.isLight&&Ae.layers.test(ye.layers)&&(S.pushLight(Ae),Ae.castShadow&&S.pushShadow(Ae))}),K!==Ee&&K.traverseVisible(function(Ae){Ae.isLight&&Ae.layers.test(ye.layers)&&(S.pushLight(Ae),Ae.castShadow&&S.pushShadow(Ae))}),S.setupLights(A._useLegacyLights);const _e=new Set;return K.traverse(function(Ae){const st=Ae.material;if(st)if(Array.isArray(st))for(let Lt=0;Lt{function st(){if(_e.forEach(function(Lt){We.get(Lt).currentProgram.isReady()&&_e.delete(Lt)}),_e.size===0){Ae(K);return}setTimeout(st,10)}Ie.get("KHR_parallel_shader_compile")!==null?st():setTimeout(st,10)})};let Jn=null;function Ui(K){Jn&&Jn(K)}function kn(){qi.stop()}function is(){qi.start()}const qi=new rz;qi.setAnimationLoop(Ui),typeof self<"u"&&qi.setContext(self),this.setAnimationLoop=function(K){Jn=K,et.setAnimationLoop(K),K===null?qi.stop():qi.start()},et.addEventListener("sessionstart",kn),et.addEventListener("sessionend",is),this.render=function(K,ye){if(ye!==void 0&&ye.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),ye.parent===null&&ye.matrixWorldAutoUpdate===!0&&ye.updateMatrixWorld(),et.enabled===!0&&et.isPresenting===!0&&(et.cameraAutoUpdate===!0&&et.updateCamera(ye),ye=et.getCamera()),K.isScene===!0&&K.onBeforeRender(A,K,ye,F),S=at.get(K,M.length),S.init(ye),M.push(S),Ye.multiplyMatrices(ye.projectionMatrix,ye.matrixWorldInverse),it.setFromProjectionMatrix(Ye),Ve=this.localClippingEnabled,we=lt.init(this.clippingPlanes,Ve),w=At.get(K,x.length),w.init(),x.push(w),wf(K,ye,0,A.sortObjects),w.finish(),A.sortObjects===!0&&w.sort(X,ie);const Ee=et.enabled===!1||et.isPresenting===!1||et.hasDepthSensing()===!1;Ee&&Ze.addToRenderList(w,K),this.info.render.frame++,we===!0&<.beginShadows();const _e=S.state.shadowsArray;Zt.render(_e,K,ye),we===!0&<.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ae=w.opaque,st=w.transmissive;if(S.setupLights(A._useLegacyLights),ye.isArrayCamera){const Lt=ye.cameras;if(st.length>0)for(let Ot=0,qt=Lt.length;Ot0&&Su(Ae,st,K,ye),Ee&&Ze.render(K),Ta(w,K,ye);F!==null&&(ft.updateMultisampleRenderTarget(F),ft.updateRenderTargetMipmap(F)),K.isScene===!0&&K.onAfterRender(A,K,ye),on.resetDefaultState(),H=-1,I=null,M.pop(),M.length>0?(S=M[M.length-1],we===!0&<.setGlobalState(A.clippingPlanes,S.state.camera)):S=null,x.pop(),x.length>0?w=x[x.length-1]:w=null};function wf(K,ye,Ee,_e){if(K.visible===!1)return;if(K.layers.test(ye.layers)){if(K.isGroup)Ee=K.renderOrder;else if(K.isLOD)K.autoUpdate===!0&&K.update(ye);else if(K.isLight)S.pushLight(K),K.castShadow&&S.pushShadow(K);else if(K.isSprite){if(!K.frustumCulled||it.intersectsSprite(K)){_e&&He.setFromMatrixPosition(K.matrixWorld).applyMatrix4(Ye);const Lt=Ne.update(K),Ot=K.material;Ot.visible&&w.push(K,Lt,Ot,Ee,He.z,null)}}else if((K.isMesh||K.isLine||K.isPoints)&&(!K.frustumCulled||it.intersectsObject(K))){const Lt=Ne.update(K),Ot=K.material;if(_e&&(K.boundingSphere!==void 0?(K.boundingSphere===null&&K.computeBoundingSphere(),He.copy(K.boundingSphere.center)):(Lt.boundingSphere===null&&Lt.computeBoundingSphere(),He.copy(Lt.boundingSphere.center)),He.applyMatrix4(K.matrixWorld).applyMatrix4(Ye)),Array.isArray(Ot)){const qt=Lt.groups;for(let tn=0,nn=qt.length;tn0&&Ca(Ae,ye,Ee),st.length>0&&Ca(st,ye,Ee),Lt.length>0&&Ca(Lt,ye,Ee),Pe.buffers.depth.setTest(!0),Pe.buffers.depth.setMask(!0),Pe.buffers.color.setMask(!0),Pe.setPolygonOffset(!1)}function Su(K,ye,Ee,_e){if((Ee.isScene===!0?Ee.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[_e.id]===void 0&&(S.state.transmissionRenderTarget[_e.id]=new uo(1,1,{generateMipmaps:!0,type:Ie.has("EXT_color_buffer_half_float")||Ie.has("EXT_color_buffer_float")?hf:rl,minFilter:Wo,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));const st=S.state.transmissionRenderTarget[_e.id],Lt=_e.viewport||R;st.setSize(Lt.z,Lt.w);const Ot=A.getRenderTarget();A.setRenderTarget(st),A.getClearColor(Z),oe=A.getClearAlpha(),oe<1&&A.setClearColor(16777215,.5),A.clear();const qt=A.toneMapping;A.toneMapping=Qa;const tn=_e.viewport;if(_e.viewport!==void 0&&(_e.viewport=void 0),S.setupLightsView(_e),we===!0&<.setGlobalState(A.clippingPlanes,_e),Ca(K,Ee,_e),ft.updateMultisampleRenderTarget(st),ft.updateRenderTargetMipmap(st),Ie.has("WEBGL_multisampled_render_to_texture")===!1){let nn=!1;for(let rn=0,$n=ye.length;rn<$n;rn++){const Ti=ye[rn],vr=Ti.object,Br=Ti.geometry,vn=Ti.material,Ht=Ti.group;if(vn.side===va&&vr.layers.test(_e.layers)){const _n=vn.side;vn.side=ws,vn.needsUpdate=!0,Pa(vr,Ee,_e,Br,vn,Ht),vn.side=_n,vn.needsUpdate=!0,nn=!0}}nn===!0&&(ft.updateMultisampleRenderTarget(st),ft.updateRenderTargetMipmap(st))}A.setRenderTarget(Ot),A.setClearColor(Z,oe),tn!==void 0&&(_e.viewport=tn),A.toneMapping=qt}function Ca(K,ye,Ee){const _e=ye.isScene===!0?ye.overrideMaterial:null;for(let Ae=0,st=K.length;Ae0),rn=!!Ee.morphAttributes.position,$n=!!Ee.morphAttributes.normal,Ti=!!Ee.morphAttributes.color;let vr=Qa;_e.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(vr=A.toneMapping);const Br=Ee.morphAttributes.position||Ee.morphAttributes.normal||Ee.morphAttributes.color,vn=Br!==void 0?Br.length:0,Ht=We.get(_e),_n=S.state.lights;if(we===!0&&(Ve===!0||K!==I)){const xr=K===I&&_e.id===H;lt.setState(_e,K,xr)}let Gt=!1;_e.version===Ht.__version?(Ht.needsLights&&Ht.lightsStateVersion!==_n.state.version||Ht.outputColorSpace!==Ot||Ae.isBatchedMesh&&Ht.batching===!1||!Ae.isBatchedMesh&&Ht.batching===!0||Ae.isInstancedMesh&&Ht.instancing===!1||!Ae.isInstancedMesh&&Ht.instancing===!0||Ae.isSkinnedMesh&&Ht.skinning===!1||!Ae.isSkinnedMesh&&Ht.skinning===!0||Ae.isInstancedMesh&&Ht.instancingColor===!0&&Ae.instanceColor===null||Ae.isInstancedMesh&&Ht.instancingColor===!1&&Ae.instanceColor!==null||Ae.isInstancedMesh&&Ht.instancingMorph===!0&&Ae.morphTexture===null||Ae.isInstancedMesh&&Ht.instancingMorph===!1&&Ae.morphTexture!==null||Ht.envMap!==qt||_e.fog===!0&&Ht.fog!==st||Ht.numClippingPlanes!==void 0&&(Ht.numClippingPlanes!==lt.numPlanes||Ht.numIntersection!==lt.numIntersection)||Ht.vertexAlphas!==tn||Ht.vertexTangents!==nn||Ht.morphTargets!==rn||Ht.morphNormals!==$n||Ht.morphColors!==Ti||Ht.toneMapping!==vr||Ht.morphTargetsCount!==vn)&&(Gt=!0):(Gt=!0,Ht.__version=_e.version);let ir=Ht.currentProgram;Gt===!0&&(ir=ol(_e,ye,Ae));let xi=!1,fi=!1,jn=!1;const ei=ir.getUniforms(),ti=Ht.uniforms;if(Pe.useProgram(ir.program)&&(xi=!0,fi=!0,jn=!0),_e.id!==H&&(H=_e.id,fi=!0),xi||I!==K){ei.setValue(ge,"projectionMatrix",K.projectionMatrix),ei.setValue(ge,"viewMatrix",K.matrixWorldInverse);const xr=ei.map.cameraPosition;xr!==void 0&&xr.setValue(ge,He.setFromMatrixPosition(K.matrixWorld)),Ge.logarithmicDepthBuffer&&ei.setValue(ge,"logDepthBufFC",2/(Math.log(K.far+1)/Math.LN2)),(_e.isMeshPhongMaterial||_e.isMeshToonMaterial||_e.isMeshLambertMaterial||_e.isMeshBasicMaterial||_e.isMeshStandardMaterial||_e.isShaderMaterial)&&ei.setValue(ge,"isOrthographic",K.isOrthographicCamera===!0),I!==K&&(I=K,fi=!0,jn=!0)}if(Ae.isSkinnedMesh){ei.setOptional(ge,Ae,"bindMatrix"),ei.setOptional(ge,Ae,"bindMatrixInverse");const xr=Ae.skeleton;xr&&(xr.boneTexture===null&&xr.computeBoneTexture(),ei.setValue(ge,"boneTexture",xr.boneTexture,ft))}Ae.isBatchedMesh&&(ei.setOptional(ge,Ae,"batchingTexture"),ei.setValue(ge,"batchingTexture",Ae._matricesTexture,ft));const wo=Ee.morphAttributes;if((wo.position!==void 0||wo.normal!==void 0||wo.color!==void 0)&&kt.update(Ae,Ee,ir),(fi||Ht.receiveShadow!==Ae.receiveShadow)&&(Ht.receiveShadow=Ae.receiveShadow,ei.setValue(ge,"receiveShadow",Ae.receiveShadow)),_e.isMeshGouraudMaterial&&_e.envMap!==null&&(ti.envMap.value=qt,ti.flipEnvMap.value=qt.isCubeTexture&&qt.isRenderTargetTexture===!1?-1:1),_e.isMeshStandardMaterial&&_e.envMap===null&&ye.environment!==null&&(ti.envMapIntensity.value=ye.environmentIntensity),fi&&(ei.setValue(ge,"toneMappingExposure",A.toneMappingExposure),Ht.needsLights&&xo(ti,jn),st&&_e.fog===!0&&ze.refreshFogUniforms(ti,st),ze.refreshMaterialUniforms(ti,_e,Fe,Se,S.state.transmissionRenderTarget[K.id]),uw.upload(ge,zs(Ht),ti,ft)),_e.isShaderMaterial&&_e.uniformsNeedUpdate===!0&&(uw.upload(ge,zs(Ht),ti,ft),_e.uniformsNeedUpdate=!1),_e.isSpriteMaterial&&ei.setValue(ge,"center",Ae.center),ei.setValue(ge,"modelViewMatrix",Ae.modelViewMatrix),ei.setValue(ge,"normalMatrix",Ae.normalMatrix),ei.setValue(ge,"modelMatrix",Ae.matrixWorld),_e.isShaderMaterial||_e.isRawShaderMaterial){const xr=_e.uniformsGroups;for(let al=0,$l=xr.length;al<$l;al++){const Vr=xr[al];dn.update(Vr,ir),dn.bind(Vr,ir)}}return ir}function xo(K,ye){K.ambientLightColor.needsUpdate=ye,K.lightProbe.needsUpdate=ye,K.directionalLights.needsUpdate=ye,K.directionalLightShadows.needsUpdate=ye,K.pointLights.needsUpdate=ye,K.pointLightShadows.needsUpdate=ye,K.spotLights.needsUpdate=ye,K.spotLightShadows.needsUpdate=ye,K.rectAreaLights.needsUpdate=ye,K.hemisphereLights.needsUpdate=ye}function Ra(K){return K.isMeshLambertMaterial||K.isMeshToonMaterial||K.isMeshPhongMaterial||K.isMeshStandardMaterial||K.isShadowMaterial||K.isShaderMaterial&&K.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(K,ye,Ee){We.get(K.texture).__webglTexture=ye,We.get(K.depthTexture).__webglTexture=Ee;const _e=We.get(K);_e.__hasExternalTextures=!0,_e.__autoAllocateDepthBuffer=Ee===void 0,_e.__autoAllocateDepthBuffer||Ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),_e.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(K,ye){const Ee=We.get(K);Ee.__webglFramebuffer=ye,Ee.__useDefaultFramebuffer=ye===void 0},this.setRenderTarget=function(K,ye=0,Ee=0){F=K,N=ye,L=Ee;let _e=!0,Ae=null,st=!1,Lt=!1;if(K){const qt=We.get(K);qt.__useDefaultFramebuffer!==void 0?(Pe.bindFramebuffer(ge.FRAMEBUFFER,null),_e=!1):qt.__webglFramebuffer===void 0?ft.setupRenderTarget(K):qt.__hasExternalTextures&&ft.rebindTextures(K,We.get(K.texture).__webglTexture,We.get(K.depthTexture).__webglTexture);const tn=K.texture;(tn.isData3DTexture||tn.isDataArrayTexture||tn.isCompressedArrayTexture)&&(Lt=!0);const nn=We.get(K).__webglFramebuffer;K.isWebGLCubeRenderTarget?(Array.isArray(nn[ye])?Ae=nn[ye][Ee]:Ae=nn[ye],st=!0):K.samples>0&&ft.useMultisampledRTT(K)===!1?Ae=We.get(K).__webglMultisampledFramebuffer:Array.isArray(nn)?Ae=nn[Ee]:Ae=nn,R.copy(K.viewport),W.copy(K.scissor),se=K.scissorTest}else R.copy(re).multiplyScalar(Fe).floor(),W.copy(de).multiplyScalar(Fe).floor(),se=Oe;if(Pe.bindFramebuffer(ge.FRAMEBUFFER,Ae)&&_e&&Pe.drawBuffers(K,Ae),Pe.viewport(R),Pe.scissor(W),Pe.setScissorTest(se),st){const qt=We.get(K.texture);ge.framebufferTexture2D(ge.FRAMEBUFFER,ge.COLOR_ATTACHMENT0,ge.TEXTURE_CUBE_MAP_POSITIVE_X+ye,qt.__webglTexture,Ee)}else if(Lt){const qt=We.get(K.texture),tn=ye||0;ge.framebufferTextureLayer(ge.FRAMEBUFFER,ge.COLOR_ATTACHMENT0,qt.__webglTexture,Ee||0,tn)}H=-1},this.readRenderTargetPixels=function(K,ye,Ee,_e,Ae,st,Lt){if(!(K&&K.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ot=We.get(K).__webglFramebuffer;if(K.isWebGLCubeRenderTarget&&Lt!==void 0&&(Ot=Ot[Lt]),Ot){Pe.bindFramebuffer(ge.FRAMEBUFFER,Ot);try{const qt=K.texture,tn=qt.format,nn=qt.type;if(!Ge.textureFormatReadable(tn)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ge.textureTypeReadable(nn)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ye>=0&&ye<=K.width-_e&&Ee>=0&&Ee<=K.height-Ae&&ge.readPixels(ye,Ee,_e,Ae,dt.convert(tn),dt.convert(nn),st)}finally{const qt=F!==null?We.get(F).__webglFramebuffer:null;Pe.bindFramebuffer(ge.FRAMEBUFFER,qt)}}},this.copyFramebufferToTexture=function(K,ye,Ee=0){const _e=Math.pow(2,-Ee),Ae=Math.floor(ye.image.width*_e),st=Math.floor(ye.image.height*_e);ft.setTexture2D(ye,0),ge.copyTexSubImage2D(ge.TEXTURE_2D,Ee,0,0,K.x,K.y,Ae,st),Pe.unbindTexture()},this.copyTextureToTexture=function(K,ye,Ee,_e=0){const Ae=ye.image.width,st=ye.image.height,Lt=dt.convert(Ee.format),Ot=dt.convert(Ee.type);ft.setTexture2D(Ee,0),ge.pixelStorei(ge.UNPACK_FLIP_Y_WEBGL,Ee.flipY),ge.pixelStorei(ge.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ee.premultiplyAlpha),ge.pixelStorei(ge.UNPACK_ALIGNMENT,Ee.unpackAlignment),ye.isDataTexture?ge.texSubImage2D(ge.TEXTURE_2D,_e,K.x,K.y,Ae,st,Lt,Ot,ye.image.data):ye.isCompressedTexture?ge.compressedTexSubImage2D(ge.TEXTURE_2D,_e,K.x,K.y,ye.mipmaps[0].width,ye.mipmaps[0].height,Lt,ye.mipmaps[0].data):ge.texSubImage2D(ge.TEXTURE_2D,_e,K.x,K.y,Lt,Ot,ye.image),_e===0&&Ee.generateMipmaps&&ge.generateMipmap(ge.TEXTURE_2D),Pe.unbindTexture()},this.copyTextureToTexture3D=function(K,ye,Ee,_e,Ae=0){const st=K.max.x-K.min.x,Lt=K.max.y-K.min.y,Ot=K.max.z-K.min.z,qt=dt.convert(_e.format),tn=dt.convert(_e.type);let nn;if(_e.isData3DTexture)ft.setTexture3D(_e,0),nn=ge.TEXTURE_3D;else if(_e.isDataArrayTexture||_e.isCompressedArrayTexture)ft.setTexture2DArray(_e,0),nn=ge.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ge.pixelStorei(ge.UNPACK_FLIP_Y_WEBGL,_e.flipY),ge.pixelStorei(ge.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_e.premultiplyAlpha),ge.pixelStorei(ge.UNPACK_ALIGNMENT,_e.unpackAlignment);const rn=ge.getParameter(ge.UNPACK_ROW_LENGTH),$n=ge.getParameter(ge.UNPACK_IMAGE_HEIGHT),Ti=ge.getParameter(ge.UNPACK_SKIP_PIXELS),vr=ge.getParameter(ge.UNPACK_SKIP_ROWS),Br=ge.getParameter(ge.UNPACK_SKIP_IMAGES),vn=Ee.isCompressedTexture?Ee.mipmaps[Ae]:Ee.image;ge.pixelStorei(ge.UNPACK_ROW_LENGTH,vn.width),ge.pixelStorei(ge.UNPACK_IMAGE_HEIGHT,vn.height),ge.pixelStorei(ge.UNPACK_SKIP_PIXELS,K.min.x),ge.pixelStorei(ge.UNPACK_SKIP_ROWS,K.min.y),ge.pixelStorei(ge.UNPACK_SKIP_IMAGES,K.min.z),Ee.isDataTexture||Ee.isData3DTexture?ge.texSubImage3D(nn,Ae,ye.x,ye.y,ye.z,st,Lt,Ot,qt,tn,vn.data):_e.isCompressedArrayTexture?ge.compressedTexSubImage3D(nn,Ae,ye.x,ye.y,ye.z,st,Lt,Ot,qt,vn.data):ge.texSubImage3D(nn,Ae,ye.x,ye.y,ye.z,st,Lt,Ot,qt,tn,vn),ge.pixelStorei(ge.UNPACK_ROW_LENGTH,rn),ge.pixelStorei(ge.UNPACK_IMAGE_HEIGHT,$n),ge.pixelStorei(ge.UNPACK_SKIP_PIXELS,Ti),ge.pixelStorei(ge.UNPACK_SKIP_ROWS,vr),ge.pixelStorei(ge.UNPACK_SKIP_IMAGES,Br),Ae===0&&_e.generateMipmaps&&ge.generateMipmap(nn),Pe.unbindTexture()},this.initTexture=function(K){K.isCubeTexture?ft.setTextureCube(K,0):K.isData3DTexture?ft.setTexture3D(K,0):K.isDataArrayTexture||K.isCompressedArrayTexture?ft.setTexture2DArray(K,0):ft.setTexture2D(K,0),Pe.unbindTexture()},this.resetState=function(){N=0,L=0,F=null,Pe.reset(),on.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ja}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===r_?"display-p3":"srgb",t.unpackColorSpace=Vn.workingColorSpace===Ty?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class a_{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ht(e),this.density=t}clone(){return new a_(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class l_{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new ht(e),this.near=t,this.far=i}clone(){return new l_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class sS 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 ho,this.environmentIntensity=1,this.environmentRotation=new ho,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 ky{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ey,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=oo()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return J4("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;re.far||t.push({distance:l,point:Lg.clone(),uv:eo.getInterpolation(Lg,n1,Dg,i1,pL,WA,mL,new Be),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function r1(n,e,t,i,r,s){Gd.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Ig.x=s*Gd.x-r*Gd.y,Ig.y=r*Gd.x+s*Gd.y):Ig.copy(Gd),n.copy(e),n.x+=Ig.x,n.y+=Ig.y,n.applyMatrix4(dz)}const s1=new Q,gL=new Q;class mz 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 i=0,r=t.length;i0){let i,r;for(i=1,r=t.length;i0){s1.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(s1);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){s1.setFromMatrixPosition(e.matrixWorld),gL.setFromMatrixPosition(this.matrixWorld);const i=s1.distanceTo(gL)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r=i.length&&i.push({start:-1,count:-1,z:-1});const s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}}const jd="batchId",Tc=new Wt,bL=new Wt,VZ=new Wt,EL=new Wt,qA=new Ry,l1=new $r,lh=new Ur,Fg=new Q,YA=new BZ,Yr=new Fi,c1=[];function HZ(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new On(a,1))}const o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(jd,new On(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(jd))throw new Error(`BatchedMesh: Geometry cannot use attribute "${jd}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(i===jd)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new $r);const e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const o=this._reservedRanges,a=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,y=this._matricesTexture,v=this._matricesTexture.image.data;f.push(!0),g.push(!0);const w=this._geometryCount;this._geometryCount++,VZ.toArray(v,w*16),y.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new $r,sphereInitialized:!1,sphere:new Ur});const S=this.geometry.getAttribute(jd);for(let x=0;x=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.vertexCount;for(const y in i.attributes){if(y===jd)continue;const v=t.getAttribute(y),w=i.getAttribute(y);HZ(v,w,l);const S=v.itemSize;for(let x=v.count,M=c;x=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;const r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();const a=o.index,l=o.attributes.position,c=this._drawRanges[e];for(let u=c.start,f=c.start+c.count;u=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){const i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){const i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,l=this.geometry;Yr.material=this.material,Yr.geometry.index=l.index,Yr.geometry.attributes=l.attributes,Yr.geometry.boundingBox===null&&(Yr.geometry.boundingBox=new $r),Yr.geometry.boundingSphere===null&&(Yr.geometry.boundingSphere=new Ur);for(let c=0;c({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,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.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,u=this._multiDrawStarts,f=this._multiDrawCounts,g=this._drawRanges,y=this.perObjectFrustumCulled;y&&(EL.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),qA.setFromProjectionMatrix(EL,e.coordinateSystem));let v=0;if(this.sortObjects){bL.copy(this.matrixWorld).invert(),Fg.setFromMatrixPosition(i.matrixWorld).applyMatrix4(bL);for(let x=0,M=c.length;x0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;si)return;KA.applyMatrix4(n.matrixWorld);const l=e.ray.origin.distanceTo(KA);if(!(le.far))return{distance:l,point:CL.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}const PL=new Q,RL=new Q;class Ma extends ql{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class GZ extends hi{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ni,this.magFilter=s!==void 0?s:Ni,this.generateMipmaps=!1;const u=this;function f(){u.needsUpdate=!0,e.requestVideoFrameCallback(f)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(f)}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 WZ extends hi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Wi,this.minFilter=Wi,this.generateMipmaps=!1,this.needsUpdate=!0}}class h_ extends hi{constructor(e,t,i,r,s,o,a,l,c,u,f,g){super(null,o,a,l,c,u,r,s,f,g),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class jZ extends h_{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=io}}class XZ extends h_{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Xl),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class qZ extends hi{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Aa{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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 i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let a=0,l=s-1,c;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),c=i[r]-o,c<0)a=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===o)return r/(s-1);const u=i[r],g=i[r+1]-u,y=(o-u)/g;return(r+y)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),l=t||(o.isVector2?new Be:new Q);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new Q,r=[],s=[],o=[],a=new Q,l=new Wt;for(let y=0;y<=e;y++){const v=y/e;r[y]=this.getTangentAt(v,new Q)}s[0]=new Q,o[0]=new Q;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),f=Math.abs(r[0].y),g=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),f<=c&&(c=f,i.set(0,1,0)),g<=c&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let y=1;y<=e;y++){if(s[y]=s[y-1].clone(),o[y]=o[y-1].clone(),a.crossVectors(r[y-1],r[y]),a.length()>Number.EPSILON){a.normalize();const v=Math.acos(Oi(r[y-1].dot(r[y]),-1,1));s[y].applyMatrix4(l.makeRotationAxis(a,v))}o[y].crossVectors(r[y],s[y])}if(t===!0){let y=Math.acos(Oi(s[0].dot(s[e]),-1,1));y/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(y=-y);for(let v=1;v<=e;v++)s[v].applyMatrix4(l.makeRotationAxis(r[v],y*v)),o[v].crossVectors(r[v],s[v])}return{tangents:r,normals:s,binormals:o}}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 f_ extends Aa{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Be){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=r[(a-1)%s]:(p1.subVectors(r[0],r[1]).add(r[0]),c=p1);const f=r[a%s],g=r[(a+1)%s];if(this.closed||a+2r.length-2?r.length-1:o+1],f=r[o>r.length-3?r.length-1:o+2];return i.set(IL(a,l.x,c.x,u.x,f.x),IL(a,l.y,c.y,u.y,f.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const o=r[s]-i,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),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 Iy extends cn{constructor(e=[new Be(0,-.5),new Be(.5,0),new Be(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Oi(r,0,Math.PI*2);const s=[],o=[],a=[],l=[],c=[],u=1/t,f=new Q,g=new Be,y=new Q,v=new Q,w=new Q;let S=0,x=0;for(let M=0;M<=e.length-1;M++)switch(M){case 0:S=e[M+1].x-e[M].x,x=e[M+1].y-e[M].y,y.x=x*1,y.y=-S,y.z=x*0,w.copy(y),y.normalize(),l.push(y.x,y.y,y.z);break;case e.length-1:l.push(w.x,w.y,w.z);break;default:S=e[M+1].x-e[M].x,x=e[M+1].y-e[M].y,y.x=x*1,y.y=-S,y.z=x*0,v.copy(y),y.x+=w.x,y.y+=w.y,y.z+=w.z,y.normalize(),l.push(y.x,y.y,y.z),w.copy(v)}for(let M=0;M<=t;M++){const A=i+M*u*r,C=Math.sin(A),N=Math.cos(A);for(let L=0;L<=e.length-1;L++){f.x=e[L].x*C,f.y=e[L].y,f.z=e[L].x*N,o.push(f.x,f.y,f.z),g.x=M/t,g.y=L/(e.length-1),a.push(g.x,g.y);const F=l[3*L+0]*C,H=l[3*L+1],I=l[3*L+0]*N;c.push(F,H,I)}}for(let M=0;M0&&A(!0),t>0&&A(!1)),this.setIndex(u),this.setAttribute("position",new Rt(f,3)),this.setAttribute("normal",new Rt(g,3)),this.setAttribute("uv",new Rt(y,2));function M(){const C=new Q,N=new Q;let L=0;const F=(t-e)/i;for(let H=0;H<=s;H++){const I=[],R=H/s,W=R*(t-e)+e;for(let se=0;se<=r;se++){const Z=se/r,oe=Z*l+a,fe=Math.sin(oe),Se=Math.cos(oe);N.x=W*fe,N.y=-R*i+S,N.z=W*Se,f.push(N.x,N.y,N.z),C.set(fe,F,Se).normalize(),g.push(C.x,C.y,C.z),y.push(Z,1-R),I.push(v++)}w.push(I)}for(let H=0;H.9&&F<.1&&(A<.2&&(o[M+0]+=1),C<.2&&(o[M+2]+=1),N<.2&&(o[M+4]+=1))}}function g(M){s.push(M.x,M.y,M.z)}function y(M,A){const C=M*3;A.x=e[C+0],A.y=e[C+1],A.z=e[C+2]}function v(){const M=new Q,A=new Q,C=new Q,N=new Q,L=new Be,F=new Be,H=new Be;for(let I=0,R=0;I80*t){a=c=n[0],l=u=n[1];for(let v=t;vc&&(c=f),g>u&&(u=g);y=Math.max(c-a,u-l),y=y!==0?32767/y:0}return ry(s,o,t,a,l,y,0),o}};function Mz(n,e,t,i,r){let s,o;if(r===yJ(n,e,t,i)>0)for(s=e;s=e;s-=i)o=DL(s,n[s],n[s+1],o);return o&&y_(o,o.next)&&(oy(o),o=o.next),o}function tf(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(y_(t,t.next)||Ai(t.prev,t,t.next)===0)){if(oy(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function ry(n,e,t,i,r,s,o){if(!n)return;!o&&s&&hJ(n,i,r,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?iJ(n,i,r,s):nJ(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),oy(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=rJ(tf(n),e,t),ry(n,e,t,i,r,s,2)):o===2&&sJ(n,e,t,i,r,s):ry(tf(n),e,t,i,r,s,1);break}}}function nJ(n){const e=n.prev,t=n,i=n.next;if(Ai(e,t,i)>=0)return!1;const r=e.x,s=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=rs?r>o?r:o:s>o?s:o,y=a>l?a>c?a:c:l>c?l:c;let v=i.next;for(;v!==e;){if(v.x>=u&&v.x<=g&&v.y>=f&&v.y<=y&&bp(r,a,s,l,o,c,v.x,v.y)&&Ai(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function iJ(n,e,t,i){const r=n.prev,s=n,o=n.next;if(Ai(r,s,o)>=0)return!1;const a=r.x,l=s.x,c=o.x,u=r.y,f=s.y,g=o.y,y=al?a>c?a:c:l>c?l:c,S=u>f?u>g?u:g:f>g?f:g,x=ET(y,v,e,t,i),M=ET(w,S,e,t,i);let A=n.prevZ,C=n.nextZ;for(;A&&A.z>=x&&C&&C.z<=M;){if(A.x>=y&&A.x<=w&&A.y>=v&&A.y<=S&&A!==r&&A!==o&&bp(a,u,l,f,c,g,A.x,A.y)&&Ai(A.prev,A,A.next)>=0||(A=A.prevZ,C.x>=y&&C.x<=w&&C.y>=v&&C.y<=S&&C!==r&&C!==o&&bp(a,u,l,f,c,g,C.x,C.y)&&Ai(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;A&&A.z>=x;){if(A.x>=y&&A.x<=w&&A.y>=v&&A.y<=S&&A!==r&&A!==o&&bp(a,u,l,f,c,g,A.x,A.y)&&Ai(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;C&&C.z<=M;){if(C.x>=y&&C.x<=w&&C.y>=v&&C.y<=S&&C!==r&&C!==o&&bp(a,u,l,f,c,g,C.x,C.y)&&Ai(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function rJ(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!y_(r,s)&&Az(r,i,i.next,s)&&sy(r,s)&&sy(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),oy(i),oy(i.next),i=n=s),i=i.next}while(i!==n);return tf(i)}function sJ(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&pJ(o,a)){let l=bz(o,a);o=tf(o,o.next),l=tf(l,l.next),ry(o,e,t,i,r,s,0),ry(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function oJ(n,e,t,i){const r=[];let s,o,a,l,c;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){const g=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(g<=s&&g>i&&(i=g,r=t.x=t.x&&t.x>=l&&s!==t.x&&bp(or.x||t.x===r.x&&uJ(r,t)))&&(r=t,u=f)),t=t.next;while(t!==a);return r}function uJ(n,e){return Ai(n.prev,n,e.prev)<0&&Ai(e.next,n,n.next)<0}function hJ(n,e,t,i){let r=n;do r.z===0&&(r.z=ET(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,fJ(r)}function fJ(n){let e,t,i,r,s,o,a,l,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(o>1);return n}function ET(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function dJ(n){let e=n,t=n;do(e.x=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function pJ(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!mJ(n,e)&&(sy(n,e)&&sy(e,n)&&gJ(n,e)&&(Ai(n.prev,n,e.prev)||Ai(n,e.prev,e))||y_(n,e)&&Ai(n.prev,n,n.next)>0&&Ai(e.prev,e,e.next)>0)}function Ai(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function y_(n,e){return n.x===e.x&&n.y===e.y}function Az(n,e,t,i){const r=x1(Ai(n,e,t)),s=x1(Ai(n,e,i)),o=x1(Ai(t,i,n)),a=x1(Ai(t,i,e));return!!(r!==s&&o!==a||r===0&&v1(n,t,e)||s===0&&v1(n,i,e)||o===0&&v1(t,n,i)||a===0&&v1(t,e,i))}function v1(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function x1(n){return n>0?1:n<0?-1:0}function mJ(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Az(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function sy(n,e){return Ai(n.prev,n,n.next)<0?Ai(n,e,n.next)>=0&&Ai(n,n.prev,e)>=0:Ai(n,e,n.prev)<0||Ai(n,n.next,e)<0}function gJ(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function bz(n,e){const t=new TT(n.i,n.x,n.y),i=new TT(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function DL(n,e,t,i){const r=new TT(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function oy(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function TT(n,e,t){this.i=n,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 yJ(n,e,t,i){let r=0;for(let s=e,o=t-i;s2&&n[e-1].equals(n[0])&&n.pop()}function NL(n,e){for(let t=0;tNumber.EPSILON){const ze=Math.sqrt(Ne),At=Math.sqrt(q*q+Me*Me),at=Ge.x-te/ze,lt=Ge.y+Ct/ze,Zt=Pe.x-Me/At,Ze=Pe.y+q/At,kt=((Zt-at)*Me-(Ze-lt)*q)/(Ct*Me-te*q);rt=at+Ct*kt-Ie.x,We=lt+te*kt-Ie.y;const en=rt*rt+We*We;if(en<=2)return new Be(rt,We);ft=Math.sqrt(en/2)}else{let ze=!1;Ct>Number.EPSILON?q>Number.EPSILON&&(ze=!0):Ct<-Number.EPSILON?q<-Number.EPSILON&&(ze=!0):Math.sign(te)===Math.sign(Me)&&(ze=!0),ze?(rt=-te,We=Ct,ft=Math.sqrt(Ne)):(rt=Ct,We=te,ft=Math.sqrt(Ne/2))}return new Be(rt/ft,We/ft)}const ie=[];for(let Ie=0,Ge=oe.length,Pe=Ge-1,rt=Ie+1;Ie=0;Ie--){const Ge=Ie/S,Pe=y*Math.cos(Ge*Math.PI/2),rt=v*Math.sin(Ge*Math.PI/2)+w;for(let We=0,ft=oe.length;We=0;){const rt=Pe;let We=Pe-1;We<0&&(We=Ie.length-1);for(let ft=0,Ct=u+S*2;ft0)&&y.push(A,C,L),(x!==i-1||l0!=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 Pz extends nr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ht(16777215),this.specular=new ht(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ho,this.combine=Ey,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 Rz extends nr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ht(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class $C extends nr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class kz extends nr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ho,this.combine=Ey,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 Lz extends nr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ht(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new Be(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 Iz extends ts{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 Nh(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Dz(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Oz(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function CT(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=n[a+l]}return r}function eP(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function SJ(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let l=0;l=i)){f.push(c.times[y]);for(let w=0;ws.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l=a.times[v]){const x=v*f+u,M=x+f-u;w=a.values.slice(x,M)}else{const x=a.createInterpolant(),M=u,A=f-u;x.evaluate(s),w=x.resultBuffer.slice(M,A)}l==="quaternion"&&new Qr().fromArray(w).normalize().conjugate().toArray(w);const S=c.times.length;for(let x=0;x=s)){const a=t[1];e=s)break t}o=i,i=0;break n}break e}for(;i>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}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 i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&Dz(r))for(let a=0,l=r.length;a!==l;++a){const c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===cw,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}ba.prototype.TimeBufferType=Float32Array;ba.prototype.ValueBufferType=Float32Array;ba.prototype.DefaultInterpolation=$h;class pf extends ba{}pf.prototype.ValueTypeName="bool";pf.prototype.ValueBufferType=Array;pf.prototype.DefaultInterpolation=Jp;pf.prototype.InterpolantFactoryMethodLinear=void 0;pf.prototype.InterpolantFactoryMethodSmooth=void 0;class nP extends ba{}nP.prototype.ValueTypeName="color";class nf extends ba{}nf.prototype.ValueTypeName="number";class Uz extends ym{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(r-t);let c=e*a;for(let u=c+a;c!==u;c+=4)Qr.slerpFlat(s,0,o,c-a,o,c,l);return s}}class hu extends ba{InterpolantFactoryMethodLinear(e){return new Uz(this.times,this.values,this.getValueSize(),e)}}hu.prototype.ValueTypeName="quaternion";hu.prototype.DefaultInterpolation=$h;hu.prototype.InterpolantFactoryMethodSmooth=void 0;class mf extends ba{}mf.prototype.ValueTypeName="string";mf.prototype.ValueBufferType=Array;mf.prototype.DefaultInterpolation=Jp;mf.prototype.InterpolantFactoryMethodLinear=void 0;mf.prototype.InterpolantFactoryMethodSmooth=void 0;class rf extends ba{}rf.prototype.ValueTypeName="vector";class em{constructor(e="",t=-1,i=[],r=i_){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=oo(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(bJ(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(ba.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a1){const f=u[1];let g=r[f];g||(r[f]=g=[]),g.push(c)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(f,g,y,v,w){if(y.length!==0){const S=[],x=[];eP(y,S,x,v),S.length!==0&&w.push(new f(g,S,x))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let f=0;f{t&&t(s),this.manager.itemEnd(e)},0),s;if(Cl[e]!==void 0){Cl[e].push({onLoad:t,onProgress:i,onError:r});return}Cl[e]=[],Cl[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Cl[e],f=c.body.getReader(),g=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),y=g?parseInt(g):0,v=y!==0;let w=0;const S=new ReadableStream({start(x){M();function M(){f.read().then(({done:A,value:C})=>{if(A)x.close();else{w+=C.byteLength;const N=new ProgressEvent("progress",{lengthComputable:v,loaded:w,total:y});for(let L=0,F=u.length;L{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),g=f&&f[1]?f[1].toLowerCase():void 0,y=new TextDecoder(g);return c.arrayBuffer().then(v=>y.decode(v))}}}).then(c=>{Fl.add(e,c);const u=Cl[e];delete Cl[e];for(let f=0,g=u.length;f{const u=Cl[e];if(u===void 0)throw this.manager.itemError(e),c;delete Cl[e];for(let f=0,g=u.length;f{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class TJ extends ns{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new fo(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new ht().setHex(o.value);break;case"v2":r.uniforms[s].value=new Be().fromArray(o.value);break;case"v3":r.uniforms[s].value=new Q().fromArray(o.value);break;case"v4":r.uniforms[s].value=new qn().fromArray(o.value);break;case"m3":r.uniforms[s].value=new hn().fromArray(o.value);break;case"m4":r.uniforms[s].value=new Wt().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Be().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Be().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:Tz,SpriteMaterial:HC,RawShaderMaterial:Cz,ShaderMaterial:Fs,PointsMaterial:u_,MeshPhysicalMaterial:Zo,MeshStandardMaterial:Ny,MeshPhongMaterial:Pz,MeshToonMaterial:Rz,MeshNormalMaterial:$C,MeshLambertMaterial:kz,MeshDepthMaterial:BC,MeshDistanceMaterial:VC,MeshBasicMaterial:ro,MeshMatcapMaterial:Lz,LineDashedMaterial:Iz,LineBasicMaterial:ts,Material:nr};return new t[e]}}class iu{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i0){const l=new iP(t);s=new ay(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c0){r=new ay(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o{const S=new $r;S.min.fromArray(w.boxMin),S.max.fromArray(w.boxMax);const x=new Ur;return x.radius=w.sphereRadius,x.center.fromArray(w.sphereCenter),{boxInitialized:w.boxInitialized,box:S,sphereInitialized:w.sphereInitialized,sphere:x}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid);break;case"LOD":o=new mz;break;case"Line":o=new ql(a(e.geometry),l(e.material));break;case"LineLoop":o=new jC(a(e.geometry),l(e.material));break;case"LineSegments":o=new Ma(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new XC(a(e.geometry),l(e.material));break;case"Sprite":o=new pz(l(e.material));break;case"Group":o=new Xa;break;case"Bone":o=new c_;break;default:o=new Dn}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const g=e.children;for(let y=0;y"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,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Fl.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Fl.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Fl.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Fl.add(e,l),s.manager.itemStart(e)}}let w1;class lP{static getContext(){return w1===void 0&&(w1=new(window.AudioContext||window.webkitAudioContext)),w1}static setContext(e){w1=e}}class NJ extends ns{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new fo(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);lP.getContext().decodeAudioData(c,function(f){t(f)}).catch(a)}catch(c){a(c)}},i,r);function a(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const WL=new Wt,jL=new Wt,ch=new Wt;class FJ{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new fr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new fr,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,ch.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Gh*t.fov*.5)/t.zoom;let a,l;jL.elements[12]=-r,WL.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,ch.elements[0]=2*t.near/(l-a),ch.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(ch),a=-o*t.aspect-s,l=o*t.aspect-s,ch.elements[0]=2*t.near/(l-a),ch.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(ch)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(jL),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(WL)}}class T_{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=XL(),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=XL();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function XL(){return(typeof performance>"u"?Date:performance).now()}const uh=new Q,qL=new Qr,UJ=new Q,hh=new Q;class zJ extends Dn{constructor(){super(),this.type="AudioListener",this.context=lP.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new T_}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,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(uh,qL,UJ),hh.set(0,0,-1).applyQuaternion(qL),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(uh.x,r),t.positionY.linearRampToValueAtTime(uh.y,r),t.positionZ.linearRampToValueAtTime(uh.z,r),t.forwardX.linearRampToValueAtTime(hh.x,r),t.forwardY.linearRampToValueAtTime(hh.y,r),t.forwardZ.linearRampToValueAtTime(hh.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(uh.x,uh.y,uh.z),t.setOrientation(hh.x,hh.y,hh.z,i.x,i.y,i.z)}}class Kz 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(){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.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Qr.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const o=this._workIndex*s;Qr.multiplyQuaternionsFlat(e,o,e,t,e,i),Qr.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){const o=1-r;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[i+o]*r}}}const cP="\\[\\]\\.:\\/",GJ=new RegExp("["+cP+"]","g"),uP="[^"+cP+"]",WJ="[^"+cP.replace("\\.","")+"]",jJ=/((?:WC+[\/:])*)/.source.replace("WC",uP),XJ=/(WCOD+)?/.source.replace("WCOD",WJ),qJ=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",uP),YJ=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",uP),KJ=new RegExp("^"+jJ+XJ+qJ+YJ+"$"),ZJ=["material","materials","bones","map"];class JJ{constructor(e,t,i){const r=i||In.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class In{constructor(e,t,i){this.path=t,this.parsedPath=i||In.parseTrackName(t),this.node=In.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new In.Composite(e,t,i):new In(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(GJ,"")}static parseTrackName(e){const t=KJ.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);ZJ.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o=s){const f=s++,g=e[f];t[g.uuid]=u,e[u]=g,t[c]=f,e[f]=l;for(let y=0,v=r;y!==v;++y){const w=i[y],S=w[f],x=w[u];w[u]=S,w[f]=x}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,f=t[u];if(f!==void 0)if(delete t[u],f0&&(t[y.uuid]=f),e[f]=y,e.pop();for(let v=0,w=r;v!==w;++v){const S=i[v];S[f]=S[g],S.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,f=new Array(c);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(f);for(let g=u,y=l.length;g!==y;++g){const v=l[g];f[g]=new In(v,e,t)}return f}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}}class Jz{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,o=s.length,a=new Array(o),l={endingStart:Ih,endingEnd:Ih};for(let c=0;c!==o;++c){const u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=N4,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case RC:for(let u=0,f=l.length;u!==f;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case i_:default:for(let u=0,f=l.length;u!==f;++u)l[u].evaluate(o),c[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const o=i===F4;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===O4){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){const a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=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(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=Dh,r.endingEnd=Dh):(e?r.endingStart=this.zeroSlopeAtStart?Dh:Ih:r.endingStart=Z0,t?r.endingEnd=this.zeroSlopeAtEnd?Dh:Ih:r.endingEnd=Z0)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=i,this}}const $J=new Float32Array(1);class eQ extends Jl{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let f=0;f!==s;++f){const g=r[f],y=g.name;let v=u[y];if(v!==void 0)++v.referenceCount,o[f]=v;else{if(v=o[f],v!==void 0){v._cacheIndex===null&&(++v.referenceCount,this._addInactiveBinding(v,l,y));continue}const w=t&&t._propertyBindings[f].binding.parsedPath;v=new Zz(In.create(i,y,w),g.ValueTypeName,g.getValueSize()),++v.referenceCount,this._addInactiveBinding(v,l,y),o[f]=v}a[f].resultBuffer=v.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.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.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,JL).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 QL=new Q,S1=new Q;class lQ{constructor(e=new Q,t=new Q){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){QL.subVectors(e,this.start),S1.subVectors(this.end,this.start);const i=S1.dot(S1);let s=S1.dot(QL)/i;return t&&(s=Oi(s,0,1)),s}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).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 $L=new Q;class cQ extends Dn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new cn,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 o=0,a=1,l=32;o1)for(let f=0;f.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{rI.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(rI,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class _Q extends Ma{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new cn;r.setAttribute("position",new Rt(t,3)),r.setAttribute("color",new Rt(i,3));const s=new ts({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new ht,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class MQ{constructor(){this.type="ShapePath",this.color=new ht,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new iy,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(x){const M=[];for(let A=0,C=x.length;ANumber.EPSILON){if(R<0&&(F=M[L],I=-I,H=M[N],R=-R),x.yH.y)continue;if(x.y===F.y){if(x.x===F.x)return!0}else{const W=R*(x.x-F.x)-I*(x.y-F.y);if(W===0)return!0;if(W<0)continue;C=!C}}else{if(x.y!==F.y)continue;if(H.x<=x.x&&x.x<=F.x||F.x<=x.x&&x.x<=H.x)return!0}}return C}const r=$a.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new jh,l.curves=a.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const f=[],g=[];let y=[],v=0,w;g[v]=void 0,y[v]=[];for(let x=0,M=s.length;x1){let x=!1,M=0;for(let A=0,C=g.length;A0&&x===!1&&(y=f)}let S;for(let x=0,M=g.length;x{const f=typeof c=="function"?c(e):c;if(f!==e){const g=e;e=u?f:Object.assign({},e,f),t.forEach(y=>y(e,g))}},r=()=>e,s=(c,u=r,f=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let g=u(e);function y(){const v=u(e);if(!f(g,v)){const w=g;c(g=v,w)}}return t.add(y),()=>t.delete(y)},l={setState:i,getState:r,subscribe:(c,u,f)=>u||f?s(c,u,f):(t.add(c),()=>t.delete(c)),destroy:()=>t.clear()};return e=n(i,r,l),l}const TQ=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),sI=TQ?le.useEffect:le.useLayoutEffect;function CQ(n){const e=typeof n=="function"?EQ(n):n,t=(i=e.getState,r=Object.is)=>{const[,s]=le.useReducer(S=>S+1,0),o=e.getState(),a=le.useRef(o),l=le.useRef(i),c=le.useRef(r),u=le.useRef(!1),f=le.useRef();f.current===void 0&&(f.current=i(o));let g,y=!1;(a.current!==o||l.current!==i||c.current!==r||u.current)&&(g=i(o),y=!r(f.current,g)),sI(()=>{y&&(f.current=g),a.current=o,l.current=i,c.current=r,u.current=!1});const v=le.useRef(o);sI(()=>{const S=()=>{try{const M=e.getState(),A=l.current(M);c.current(f.current,A)||(a.current=M,f.current=A,s())}catch{u.current=!0,s()}},x=e.subscribe(S);return e.getState()!==v.current&&S(),x},[]);const w=y?g:f.current;return le.useDebugValue(w),w};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const i=[t,e];return{next(){const r=i.length<=0;return{value:i.shift(),done:r}}}},t}var t5={exports:{}},rb={exports:{}},sb={};/** + * @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 oI;function PQ(){return oI||(oI=1,function(n){function e(X,ie){var re=X.length;X.push(ie);e:for(;0>>1,Oe=X[de];if(0>>1;der(Ve,re))Yer(He,Ve)?(X[de]=He,X[Ye]=re,de=Ye):(X[de]=Ve,X[we]=re,de=we);else if(Yer(He,re))X[de]=He,X[Ye]=re,de=Ye;else break e}}return ie}function r(X,ie){var re=X.sortIndex-ie.sortIndex;return re!==0?re:X.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,f=null,g=3,y=!1,v=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(X){for(var ie=t(c);ie!==null;){if(ie.callback===null)i(c);else if(ie.startTime<=X)i(c),ie.sortIndex=ie.expirationTime,e(l,ie);else break;ie=t(c)}}function C(X){if(w=!1,A(X),!v)if(t(l)!==null)v=!0,Se(N);else{var ie=t(c);ie!==null&&Fe(C,ie.startTime-X)}}function N(X,ie){v=!1,w&&(w=!1,x(H),H=-1),y=!0;var re=g;try{for(A(ie),f=t(l);f!==null&&(!(f.expirationTime>ie)||X&&!W());){var de=f.callback;if(typeof de=="function"){f.callback=null,g=f.priorityLevel;var Oe=de(f.expirationTime<=ie);ie=n.unstable_now(),typeof Oe=="function"?f.callback=Oe:f===t(l)&&i(l),A(ie)}else i(l);f=t(l)}if(f!==null)var it=!0;else{var we=t(c);we!==null&&Fe(C,we.startTime-ie),it=!1}return it}finally{f=null,g=re,y=!1}}var L=!1,F=null,H=-1,I=5,R=-1;function W(){return!(n.unstable_now()-RX||125de?(X.sortIndex=re,e(c,X),t(l)===null&&X===t(c)&&(w?(x(H),H=-1):w=!0,Fe(C,re-de))):(X.sortIndex=Oe,e(l,X),v||y||(v=!0,Se(N))),X},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(X){var ie=g;return function(){var re=g;g=ie;try{return X.apply(this,arguments)}finally{g=re}}}}(sb)),sb}var aI;function RQ(){return aI||(aI=1,rb.exports=PQ()),rb.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 kQ=function(e){var t={},i=le,r=RQ(),s=Object.assign;function o(h){for(var p="https://reactjs.org/docs/error-decoder.html?invariant="+h,_=1;_he||P[ee]!==O[he]){var Le=` +`+P[ee].replace(" at new "," at ");return h.displayName&&Le.includes("")&&(Le=Le.replace("",h.displayName)),Le}while(1<=ee&&0<=he);break}}}finally{$n=!1,Error.prepareStackTrace=_}return(h=h?h.displayName||h.name:"")?rn(h):""}var vr=Object.prototype.hasOwnProperty,Br=[],vn=-1;function Ht(h){return{current:h}}function _n(h){0>vn||(h.current=Br[vn],Br[vn]=null,vn--)}function Gt(h,p){vn++,Br[vn]=h.current,h.current=p}var ir={},xi=Ht(ir),fi=Ht(!1),jn=ir;function ei(h,p){var _=h.type.contextTypes;if(!_)return ir;var E=h.stateNode;if(E&&E.__reactInternalMemoizedUnmaskedChildContext===p)return E.__reactInternalMemoizedMaskedChildContext;var P={},O;for(O in _)P[O]=p[O];return E&&(h=h.stateNode,h.__reactInternalMemoizedUnmaskedChildContext=p,h.__reactInternalMemoizedMaskedChildContext=P),P}function ti(h){return h=h.childContextTypes,h!=null}function wo(){_n(fi),_n(xi)}function xr(h,p,_){if(xi.current!==ir)throw Error(o(168));Gt(xi,p),Gt(fi,_)}function al(h,p,_){var E=h.stateNode;if(p=p.childContextTypes,typeof E.getChildContext!="function")return _;E=E.getChildContext();for(var P in E)if(!(P in p))throw Error(o(108,H(h)||"Unknown",P));return s({},_,E)}function $l(h){return h=(h=h.stateNode)&&h.__reactInternalMemoizedMergedChildContext||ir,jn=xi.current,Gt(xi,h),Gt(fi,fi.current),!0}function Vr(h,p,_){var E=h.stateNode;if(!E)throw Error(o(169));_?(h=al(h,p,jn),E.__reactInternalMemoizedMergedChildContext=h,_n(fi),_n(xi),Gt(xi,h)):_n(fi),Gt(fi,_)}var rs=Math.clz32?Math.clz32:_f,Ky=Math.log,Zy=Math.LN2;function _f(h){return h>>>=0,h===0?32:31-(Ky(h)/Zy|0)|0}var _u=64,Mu=4194304;function ec(h){switch(h&-h){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 h&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return h&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return h}}function Au(h,p){var _=h.pendingLanes;if(_===0)return 0;var E=0,P=h.suspendedLanes,O=h.pingedLanes,ee=_&268435455;if(ee!==0){var he=ee&~P;he!==0?E=ec(he):(O&=ee,O!==0&&(E=ec(O)))}else ee=_&~P,ee!==0?E=ec(ee):O!==0&&(E=ec(O));if(E===0)return 0;if(p!==0&&p!==E&&!(p&P)&&(P=E&-E,O=p&-p,P>=O||P===16&&(O&4194240)!==0))return p;if(E&4&&(E|=_&16),p=h.entangledLanes,p!==0)for(h=h.entanglements,p&=E;0_;_++)p.push(h);return p}function bu(h,p,_){h.pendingLanes|=p,p!==536870912&&(h.suspendedLanes=0,h.pingedLanes=0),h=h.eventTimes,p=31-rs(p),h[p]=_}function So(h,p){var _=h.pendingLanes&~p;h.pendingLanes=p,h.suspendedLanes=0,h.pingedLanes=0,h.expiredLanes&=p,h.mutableReadLanes&=p,h.entangledLanes&=p,p=h.entanglements;var E=h.eventTimes;for(h=h.expirationTimes;0<_;){var P=31-rs(_),O=1<>=ee,P-=ee,ta=1<<32-rs(p)+P|_<Ln?(Ji=an,an=null):Ji=an.sibling;var Cn=Bt(be,an,Ce[Ln],gt);if(Cn===null){an===null&&(an=Ji);break}h&&an&&Cn.alternate===null&&p(be,an),pe=O(Cn,pe,Ln),un===null?Nt=Cn:un.sibling=Cn,un=Cn,an=Ji}if(Ln===Ce.length)return _(be,an),ni&&os(be,Ln),Nt;if(an===null){for(;LnLn?(Ji=an,an=null):Ji=an.sibling;var Ua=Bt(be,an,Cn.value,gt);if(Ua===null){an===null&&(an=Ji);break}h&&an&&Ua.alternate===null&&p(be,an),pe=O(Ua,pe,Ln),un===null?Nt=Ua:un.sibling=Ua,un=Ua,an=Ji}if(Cn.done)return _(be,an),ni&&os(be,Ln),Nt;if(an===null){for(;!Cn.done;Ln++,Cn=Ce.next())Cn=sn(be,Cn.value,gt),Cn!==null&&(pe=O(Cn,pe,Ln),un===null?Nt=Cn:un.sibling=Cn,un=Cn);return ni&&os(be,Ln),Nt}for(an=E(be,an);!Cn.done;Ln++,Cn=Ce.next())Cn=Gn(an,be,Ln,Cn.value,gt),Cn!==null&&(h&&Cn.alternate!==null&&an.delete(Cn.key===null?Ln:Cn.key),pe=O(Cn,pe,Ln),un===null?Nt=Cn:un.sibling=Cn,un=Cn);return h&&an.forEach(function(cx){return p(be,cx)}),ni&&os(be,Ln),Nt}function cr(be,pe,Ce,gt){if(typeof Ce=="object"&&Ce!==null&&Ce.type===u&&Ce.key===null&&(Ce=Ce.props.children),typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case l:e:{for(var Nt=Ce.key,un=pe;un!==null;){if(un.key===Nt){if(Nt=Ce.type,Nt===u){if(un.tag===7){_(be,un.sibling),pe=P(un,Ce.props.children),pe.return=be,be=pe;break e}}else if(un.elementType===Nt||typeof Nt=="object"&&Nt!==null&&Nt.$$typeof===A&&lv(Nt)===un.type){_(be,un.sibling),pe=P(un,Ce.props),pe.ref=Ou(be,un,Ce),pe.return=be,be=pe;break e}_(be,un);break}else p(be,un);un=un.sibling}Ce.type===u?(pe=_l(Ce.props.children,be.mode,gt,Ce.key),pe.return=be,be=pe):(gt=Sl(Ce.type,Ce.key,Ce.props,null,be.mode,gt),gt.ref=Ou(be,pe,Ce),gt.return=be,be=gt)}return ee(be);case c:e:{for(un=Ce.key;pe!==null;){if(pe.key===un)if(pe.tag===4&&pe.stateNode.containerInfo===Ce.containerInfo&&pe.stateNode.implementation===Ce.implementation){_(be,pe.sibling),pe=P(pe,Ce.children||[]),pe.return=be,be=pe;break e}else{_(be,pe);break}else p(be,pe);pe=pe.sibling}pe=gd(Ce,be.mode,gt),pe.return=be,be=pe}return ee(be);case A:return un=Ce._init,cr(be,pe,un(Ce._payload),gt)}if(fe(Ce))return It(be,pe,Ce,gt);if(L(Ce))return Zi(be,pe,Ce,gt);fl(be,Ce)}return typeof Ce=="string"&&Ce!==""||typeof Ce=="number"?(Ce=""+Ce,pe!==null&&pe.tag===6?(_(be,pe.sibling),pe=P(pe,Ce),pe.return=be,be=pe):(_(be,pe),pe=gc(Ce,be.mode,gt),pe.return=be,be=pe),ee(be)):_(be,pe)}return cr}var oc=cv(!0),Na=cv(!1),Eo={},ls=Ht(Eo),ac=Ht(Eo),lc=Ht(Eo);function To(h){if(h===Eo)throw Error(o(174));return h}function cc(h,p){Gt(lc,p),Gt(ac,h),Gt(ls,Eo),h=Fe(p),_n(ls),Gt(ls,h)}function Co(){_n(ls),_n(ac),_n(lc)}function uv(h){var p=To(lc.current),_=To(ls.current);p=X(_,h.type,p),_!==p&&(Gt(ac,h),Gt(ls,p))}function Df(h){ac.current===h&&(_n(ls),_n(ac))}var mn=Ht(0);function Of(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||Ca(_)||Pa(_)))return p}else if(p.tag===19&&p.memoizedProps.revealOrder!==void 0){if(p.flags&128)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var Im=[];function Fn(){for(var h=0;h_?_:4,h(!0);var E=Sr.transition;Sr.transition={};try{h(!1),p()}finally{bn=_,Sr.transition=E}}function Av(){return ko().memoizedState}function pM(h,p,_){var E=ar(h);_={lane:E,action:_,hasEagerState:!1,eagerState:null,next:null},Bm(h)?bv(p,_):(Ev(h,p,_),_=Tt(),h=Ts(h,E,_),h!==null&&Tv(h,p,E))}function mM(h,p,_){var E=ar(h),P={lane:E,action:_,hasEagerState:!1,eagerState:null,next:null};if(Bm(h))bv(p,P);else{Ev(h,p,P);var O=h.alternate;if(h.lanes===0&&(O===null||O.lanes===0)&&(O=p.lastRenderedReducer,O!==null))try{var ee=p.lastRenderedState,he=O(ee,_);if(P.hasEagerState=!0,P.eagerState=he,_o(he,ee))return}catch{}finally{}_=Tt(),h=Ts(h,E,_),h!==null&&Tv(h,p,E)}}function Bm(h){var p=h.alternate;return h===di||p!==null&&p===di}function bv(h,p){Nu=Ff=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function Ev(h,p,_){Ci!==null&&h.mode&1&&!(gn&2)?(h=p.interleaved,h===null?(_.next=_,Gs===null?Gs=[p]:Gs.push(p)):(_.next=h.next,h.next=_),p.interleaved=_):(h=p.pending,h===null?_.next=_:(_.next=h.next,h.next=_),p.pending=_)}function Tv(h,p,_){if(_&4194240){var E=p.lanes;E&=h.pendingLanes,_|=E,p.lanes=_,Eu(h,_)}}var Gf={readContext:As,useCallback:Mr,useContext:Mr,useEffect:Mr,useImperativeHandle:Mr,useInsertionEffect:Mr,useLayoutEffect:Mr,useMemo:Mr,useReducer:Mr,useRef:Mr,useState:Mr,useDebugValue:Mr,useDeferredValue:Mr,useTransition:Mr,useMutableSource:Mr,useSyncExternalStore:Mr,useId:Mr,unstable_isNewReconciler:!1},gM={readContext:As,useCallback:function(h,p){return Ro().memoizedState=[h,p===void 0?null:p],h},useContext:As,useEffect:Um,useImperativeHandle:function(h,p,_){return _=_!=null?_.concat([h]):null,Vf(4194308,4,xv.bind(null,p,h),_)},useLayoutEffect:function(h,p){return Vf(4194308,4,h,p)},useInsertionEffect:function(h,p){return Vf(4,2,h,p)},useMemo:function(h,p){var _=Ro();return p=p===void 0?null:p,h=h(),_.memoizedState=[h,p],h},useReducer:function(h,p,_){var E=Ro();return p=_!==void 0?_(p):p,E.memoizedState=E.baseState=p,h={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:p},E.queue=h,h=h.dispatch=pM.bind(null,di,h),[E.memoizedState,h]},useRef:function(h){var p=Ro();return h={current:h},p.memoizedState=h},useState:Fm,useDebugValue:zm,useDeferredValue:function(h){var p=Fm(h),_=p[0],E=p[1];return Um(function(){var P=Sr.transition;Sr.transition={};try{E(h)}finally{Sr.transition=P}},[h]),_},useTransition:function(){var h=Fm(!1),p=h[0];return h=Mv.bind(null,h[1]),Ro().memoizedState=h,[p,h]},useMutableSource:function(){},useSyncExternalStore:function(h,p,_){var E=di,P=Ro();if(ni){if(_===void 0)throw Error(o(407));_=_()}else{if(_=p(),Ci===null)throw Error(o(349));Po&30||dv(E,p,_)}P.memoizedState=_;var O={value:_,getSnapshot:p};return P.queue=O,Um(pv.bind(null,E,O,h),[h]),E.flags|=2048,uc(9,Nm.bind(null,E,O,_,p),void 0,null),_},useId:function(){var h=Ro(),p=Ci.identifierPrefix;if(ni){var _=Ws,E=ta;_=(E&~(1<<32-rs(E)-1)).toString(32)+_,p=":"+p+"R"+_,_=Fu++,0<_&&(p+="H"+_.toString(32)),p+=":"}else _=dM++,p=":"+p+"r"+_.toString(32)+":";return h.memoizedState=p},unstable_isNewReconciler:!1},yM={readContext:As,useCallback:Sv,useContext:As,useEffect:Uu,useImperativeHandle:wv,useInsertionEffect:yv,useLayoutEffect:vv,useMemo:_v,useReducer:zf,useRef:gv,useState:function(){return zf(dl)},useDebugValue:zm,useDeferredValue:function(h){var p=zf(dl),_=p[0],E=p[1];return Uu(function(){var P=Sr.transition;Sr.transition={};try{E(h)}finally{Sr.transition=P}},[h]),_},useTransition:function(){var h=zf(dl)[0],p=ko().memoizedState;return[h,p]},useMutableSource:hv,useSyncExternalStore:fv,useId:Av,unstable_isNewReconciler:!1},vM={readContext:As,useCallback:Sv,useContext:As,useEffect:Uu,useImperativeHandle:wv,useInsertionEffect:yv,useLayoutEffect:vv,useMemo:_v,useReducer:Bf,useRef:gv,useState:function(){return Bf(dl)},useDebugValue:zm,useDeferredValue:function(h){var p=Bf(dl),_=p[0],E=p[1];return Uu(function(){var P=Sr.transition;Sr.transition={};try{E(h)}finally{Sr.transition=P}},[h]),_},useTransition:function(){var h=Bf(dl)[0],p=ko().memoizedState;return[h,p]},useMutableSource:hv,useSyncExternalStore:fv,useId:Av,unstable_isNewReconciler:!1};function Vm(h,p){try{var _="",E=p;do _+=nv(E),E=E.return;while(E);var P=_}catch(O){P=` +Error generating stack: `+O.message+` +`+O.stack}return{value:h,source:p,stack:P}}function Hm(h,p){try{console.error(p.value)}catch(_){setTimeout(function(){throw _})}}var xM=typeof WeakMap=="function"?WeakMap:Map;function Cv(h,p,_){_=Hr(-1,_),_.tag=3,_.payload={element:null};var E=p.value;return _.callback=function(){od||(od=!0,ug=E),Hm(h,p)},_}function Pv(h,p,_){_=Hr(-1,_),_.tag=3;var E=h.type.getDerivedStateFromError;if(typeof E=="function"){var P=p.value;_.payload=function(){return E(P)},_.callback=function(){Hm(h,p)}}var O=h.stateNode;return O!==null&&typeof O.componentDidCatch=="function"&&(_.callback=function(){Hm(h,p),typeof E!="function"&&(ra===null?ra=new Set([this]):ra.add(this));var ee=p.stack;this.componentDidCatch(p.value,{componentStack:ee!==null?ee:""})}),_}function Gm(h,p,_){var E=h.pingCache;if(E===null){E=h.pingCache=new xM;var P=new Set;E.set(p,P)}else P=E.get(p),P===void 0&&(P=new Set,E.set(p,P));P.has(_)||(P.add(_),h=Vi.bind(null,h,p,_),p.then(h,h))}function Wm(h){do{var p;if((p=h.tag===13)&&(p=h.memoizedState,p=p!==null?p.dehydrated!==null:!0),p)return h;h=h.return}while(h!==null);return null}function jm(h,p,_,E,P){return h.mode&1?(h.flags|=65536,h.lanes=P,h):(h===p?h.flags|=65536:(h.flags|=128,_.flags|=131072,_.flags&=-52805,_.tag===1&&(_.alternate===null?_.tag=17:(p=Hr(-1,1),p.tag=2,bo(_,p))),_.lanes|=1),h)}function Xs(h){h.flags|=4}function Rv(h,p){if(h!==null&&h.child===p.child)return!0;if(p.flags&16)return!1;for(h=p.child;h!==null;){if(h.flags&12854||h.subtreeFlags&12854)return!1;h=h.sibling}return!0}var zu,Bu,Wf,hc;if(Dt)zu=function(h,p){for(var _=p.child;_!==null;){if(_.tag===5||_.tag===6)Oe(h,_.stateNode);else if(_.tag!==4&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===p)break;for(;_.sibling===null;){if(_.return===null||_.return===p)return;_=_.return}_.sibling.return=_.return,_=_.sibling}},Bu=function(){},Wf=function(h,p,_,E,P){if(h=h.memoizedProps,h!==E){var O=p.stateNode,ee=To(ls.current);_=we(O,_,h,E,P,ee),(p.updateQueue=_)&&Xs(p)}},hc=function(h,p,_,E){_!==E&&Xs(p)};else if(Ie){zu=function(h,p,_,E){for(var P=p.child;P!==null;){if(P.tag===5){var O=P.stateNode;_&&E&&(O=is(O,P.type,P.memoizedProps,P)),Oe(h,O)}else if(P.tag===6)O=P.stateNode,_&&E&&(O=qi(O,P.memoizedProps,P)),Oe(h,O);else if(P.tag!==4){if(P.tag===22&&P.memoizedState!==null)O=P.child,O!==null&&(O.return=P),zu(h,P,!0,!0);else if(P.child!==null){P.child.return=P,P=P.child;continue}}if(P===p)break;for(;P.sibling===null;){if(P.return===null||P.return===p)return;P=P.return}P.sibling.return=P.return,P=P.sibling}};var Xm=function(h,p,_,E){for(var P=p.child;P!==null;){if(P.tag===5){var O=P.stateNode;_&&E&&(O=is(O,P.type,P.memoizedProps,P)),Jn(h,O)}else if(P.tag===6)O=P.stateNode,_&&E&&(O=qi(O,P.memoizedProps,P)),Jn(h,O);else if(P.tag!==4){if(P.tag===22&&P.memoizedState!==null)O=P.child,O!==null&&(O.return=P),Xm(h,P,!0,!0);else if(P.child!==null){P.child.return=P,P=P.child;continue}}if(P===p)break;for(;P.sibling===null;){if(P.return===null||P.return===p)return;P=P.return}P.sibling.return=P.return,P=P.sibling}};Bu=function(h,p){var _=p.stateNode;if(!Rv(h,p)){h=_.containerInfo;var E=Tn(h);Xm(E,p,!1,!1),_.pendingChildren=E,Xs(p),Ui(h,E)}},Wf=function(h,p,_,E,P){var O=h.stateNode,ee=h.memoizedProps;if((h=Rv(h,p))&&ee===E)p.stateNode=O;else{var he=p.stateNode,Le=To(ls.current),tt=null;ee!==E&&(tt=we(he,_,ee,E,P,Le)),h&&tt===null?p.stateNode=O:(O=pn(O,tt,_,ee,E,p,h,he),it(O,_,E,P,Le)&&Xs(p),p.stateNode=O,h?Xs(p):zu(O,p,!1,!1))}},hc=function(h,p,_,E){_!==E?(h=To(lc.current),_=To(ls.current),p.stateNode=Ye(E,h,_,p),Xs(p)):p.stateNode=h.stateNode}}else Bu=function(){},Wf=function(){},hc=function(){};function fc(h,p){if(!ni)switch(h.tailMode){case"hidden":p=h.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var E=null;_!==null;)_.alternate!==null&&(E=_),_=_.sibling;E===null?p||h.tail===null?h.tail=null:h.tail.sibling=null:E.sibling=null}}function rr(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,E=0;if(p)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,E|=P.subtreeFlags&14680064,E|=P.flags&14680064,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,E|=P.subtreeFlags,E|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=E,h.childLanes=_,p}function wM(h,p,_){var E=p.pendingProps;switch(Rm(p),p.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return rr(p),null;case 1:return ti(p.type)&&wo(),rr(p),null;case 3:return E=p.stateNode,Co(),_n(fi),_n(xi),Fn(),E.pendingContext&&(E.context=E.pendingContext,E.pendingContext=null),(h===null||h.child===null)&&(sc(p)?Xs(p):h===null||h.memoizedState.isDehydrated&&!(p.flags&256)||(p.flags|=1024,js!==null&&(fg(js),js=null))),Bu(h,p),rr(p),null;case 5:Df(p),_=To(lc.current);var P=p.type;if(h!==null&&p.stateNode!=null)Wf(h,p,P,E,_),h.ref!==p.ref&&(p.flags|=512,p.flags|=2097152);else{if(!E){if(p.stateNode===null)throw Error(o(166));return rr(p),null}if(h=To(ls.current),sc(p)){if(!Ge)throw Error(o(175));h=Ra(p.stateNode,p.type,p.memoizedProps,_,h,p,!Iu),p.updateQueue=h,h!==null&&Xs(p)}else{var O=de(P,E,_,h,p);zu(O,p,!1,!1),p.stateNode=O,it(O,P,E,_,h)&&Xs(p)}p.ref!==null&&(p.flags|=512,p.flags|=2097152)}return rr(p),null;case 6:if(h&&p.stateNode!=null)hc(h,p,h.memoizedProps,E);else{if(typeof E!="string"&&p.stateNode===null)throw Error(o(166));if(h=To(lc.current),_=To(ls.current),sc(p)){if(!Ge)throw Error(o(176));if(h=p.stateNode,E=p.memoizedProps,(_=K(h,E,p,!Iu))&&(P=as,P!==null))switch(O=(P.mode&1)!==0,P.tag){case 3:qt(P.stateNode.containerInfo,h,E,O);break;case 5:tn(P.type,P.memoizedProps,P.stateNode,h,E,O)}_&&Xs(p)}else p.stateNode=Ye(E,h,_,p)}return rr(p),null;case 13:if(_n(mn),E=p.memoizedState,ni&&wr!==null&&p.mode&1&&!(p.flags&128)){for(h=wr;h;)h=zs(h);return na(),p.flags|=98560,p}if(E!==null&&E.dehydrated!==null){if(E=sc(p),h===null){if(!E)throw Error(o(318));if(!Ge)throw Error(o(344));if(h=p.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(o(317));ye(h,p)}else na(),!(p.flags&128)&&(p.memoizedState=null),p.flags|=4;return rr(p),null}return js!==null&&(fg(js),js=null),p.flags&128?(p.lanes=_,p):(E=E!==null,_=!1,h===null?sc(p):_=h.memoizedState!==null,E&&!_&&(p.child.flags|=8192,p.mode&1&&(h===null||mn.current&1?pi===0&&(pi=3):pg())),p.updateQueue!==null&&(p.flags|=4),rr(p),null);case 4:return Co(),Bu(h,p),h===null&&rt(p.stateNode.containerInfo),rr(p),null;case 10:return Am(p.type._context),rr(p),null;case 17:return ti(p.type)&&wo(),rr(p),null;case 19:if(_n(mn),P=p.memoizedState,P===null)return rr(p),null;if(E=(p.flags&128)!==0,O=P.rendering,O===null)if(E)fc(P,!1);else{if(pi!==0||h!==null&&h.flags&128)for(h=p.child;h!==null;){if(O=Of(h),O!==null){for(p.flags|=128,fc(P,!1),h=O.updateQueue,h!==null&&(p.updateQueue=h,p.flags|=4),p.subtreeFlags=0,h=_,E=p.child;E!==null;)_=E,P=h,_.flags&=14680066,O=_.alternate,O===null?(_.childLanes=0,_.lanes=P,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=O.childLanes,_.lanes=O.lanes,_.child=O.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=O.memoizedProps,_.memoizedState=O.memoizedState,_.updateQueue=O.updateQueue,_.type=O.type,P=O.dependencies,_.dependencies=P===null?null:{lanes:P.lanes,firstContext:P.firstContext}),E=E.sibling;return Gt(mn,mn.current&1|2),p.child}h=h.sibling}P.tail!==null&&zi()>sd&&(p.flags|=128,E=!0,fc(P,!1),p.lanes=4194304)}else{if(!E)if(h=Of(O),h!==null){if(p.flags|=128,E=!0,h=h.updateQueue,h!==null&&(p.updateQueue=h,p.flags|=4),fc(P,!0),P.tail===null&&P.tailMode==="hidden"&&!O.alternate&&!ni)return rr(p),null}else 2*zi()-P.renderingStartTime>sd&&_!==1073741824&&(p.flags|=128,E=!0,fc(P,!1),p.lanes=4194304);P.isBackwards?(O.sibling=p.child,p.child=O):(h=P.last,h!==null?h.sibling=O:p.child=O,P.last=O)}return P.tail!==null?(p=P.tail,P.rendering=p,P.tail=p.sibling,P.renderingStartTime=zi(),p.sibling=null,h=mn.current,Gt(mn,E?h&1|2:h&1),p):(rr(p),null);case 22:case 23:return hd(),E=p.memoizedState!==null,h!==null&&h.memoizedState!==null!==E&&(p.flags|=8192),E&&p.mode&1?us&1073741824&&(rr(p),Dt&&p.subtreeFlags&6&&(p.flags|=8192)):rr(p),null;case 24:return null;case 25:return null}throw Error(o(156,p.tag))}var kv=a.ReactCurrentOwner,cs=!1;function Rr(h,p,_,E){p.child=h===null?Na(p,null,_,E):oc(p,h.child,_,E)}function Lv(h,p,_,E,P){_=_.render;var O=p.ref;return La(p,P),E=Uf(h,p,_,E,O,P),_=Om(),h!==null&&!cs?(p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~P,ia(h,p,P)):(ni&&_&&rc(p),p.flags|=1,Rr(h,p,E,P),p.child)}function Iv(h,p,_,E,P){if(h===null){var O=_.type;return typeof O=="function"&&!Ki(O)&&O.defaultProps===void 0&&_.compare===null&&_.defaultProps===void 0?(p.tag=15,p.type=O,Dv(h,p,O,E,P)):(h=Sl(_.type,null,E,p,p.mode,P),h.ref=p.ref,h.return=p,p.child=h)}if(O=h.child,!(h.lanes&P)){var ee=O.memoizedProps;if(_=_.compare,_=_!==null?_:ll,_(ee,E)&&h.ref===p.ref)return ia(h,p,P)}return p.flags|=1,h=qs(O,E),h.ref=p.ref,h.return=p,p.child=h}function Dv(h,p,_,E,P){if(h!==null&&ll(h.memoizedProps,E)&&h.ref===p.ref)if(cs=!1,(h.lanes&P)!==0)h.flags&131072&&(cs=!0);else return p.lanes=h.lanes,ia(h,p,P);return Ym(h,p,_,E,P)}function Ov(h,p,_){var E=p.pendingProps,P=E.children,O=h!==null?h.memoizedState:null;if(E.mode==="hidden")if(!(p.mode&1))p.memoizedState={baseLanes:0,cachePool:null},Gt(gl,us),us|=_;else if(_&1073741824)p.memoizedState={baseLanes:0,cachePool:null},E=O!==null?O.baseLanes:_,Gt(gl,us),us|=E;else return h=O!==null?O.baseLanes|_:_,p.lanes=p.childLanes=1073741824,p.memoizedState={baseLanes:h,cachePool:null},p.updateQueue=null,Gt(gl,us),us|=h,null;else O!==null?(E=O.baseLanes|_,p.memoizedState=null):E=_,Gt(gl,us),us|=E;return Rr(h,p,P,_),p.child}function qm(h,p){var _=p.ref;(h===null&&_!==null||h!==null&&h.ref!==_)&&(p.flags|=512,p.flags|=2097152)}function Ym(h,p,_,E,P){var O=ti(_)?jn:xi.current;return O=ei(p,O),La(p,P),_=Uf(h,p,_,E,O,P),E=Om(),h!==null&&!cs?(p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~P,ia(h,p,P)):(ni&&E&&rc(p),p.flags|=1,Rr(h,p,_,P),p.child)}function Vu(h,p,_,E,P){if(ti(_)){var O=!0;$l(p)}else O=!1;if(La(p,P),p.stateNode===null)h!==null&&(h.alternate=null,p.alternate=null,p.flags|=2),If(p,_,E),ku(p,_,E,P),E=!0;else if(h===null){var ee=p.stateNode,he=p.memoizedProps;ee.props=he;var Le=ee.context,tt=_.contextType;typeof tt=="object"&&tt!==null?tt=As(tt):(tt=ti(_)?jn:xi.current,tt=ei(p,tt));var Mt=_.getDerivedStateFromProps,sn=typeof Mt=="function"||typeof ee.getSnapshotBeforeUpdate=="function";sn||typeof ee.UNSAFE_componentWillReceiveProps!="function"&&typeof ee.componentWillReceiveProps!="function"||(he!==E||Le!==tt)&&Bi(p,ee,E,tt),Ia=!1;var Bt=p.memoizedState;ee.state=Bt,Rf(p,E,ee,P),Le=p.memoizedState,he!==E||Bt!==Le||fi.current||Ia?(typeof Mt=="function"&&(Cm(p,_,Mt,E),Le=p.memoizedState),(he=Ia||Lf(p,_,he,E,Bt,Le,tt))?(sn||typeof ee.UNSAFE_componentWillMount!="function"&&typeof ee.componentWillMount!="function"||(typeof ee.componentWillMount=="function"&&ee.componentWillMount(),typeof ee.UNSAFE_componentWillMount=="function"&&ee.UNSAFE_componentWillMount()),typeof ee.componentDidMount=="function"&&(p.flags|=4194308)):(typeof ee.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=E,p.memoizedState=Le),ee.props=E,ee.state=Le,ee.context=tt,E=he):(typeof ee.componentDidMount=="function"&&(p.flags|=4194308),E=!1)}else{ee=p.stateNode,Tm(h,p),he=p.memoizedProps,tt=p.type===p.elementType?he:Hs(p.type,he),ee.props=tt,sn=p.pendingProps,Bt=ee.context,Le=_.contextType,typeof Le=="object"&&Le!==null?Le=As(Le):(Le=ti(_)?jn:xi.current,Le=ei(p,Le));var Gn=_.getDerivedStateFromProps;(Mt=typeof Gn=="function"||typeof ee.getSnapshotBeforeUpdate=="function")||typeof ee.UNSAFE_componentWillReceiveProps!="function"&&typeof ee.componentWillReceiveProps!="function"||(he!==sn||Bt!==Le)&&Bi(p,ee,E,Le),Ia=!1,Bt=p.memoizedState,ee.state=Bt,Rf(p,E,ee,P);var It=p.memoizedState;he!==sn||Bt!==It||fi.current||Ia?(typeof Gn=="function"&&(Cm(p,_,Gn,E),It=p.memoizedState),(tt=Ia||Lf(p,_,tt,E,Bt,It,Le)||!1)?(Mt||typeof ee.UNSAFE_componentWillUpdate!="function"&&typeof ee.componentWillUpdate!="function"||(typeof ee.componentWillUpdate=="function"&&ee.componentWillUpdate(E,It,Le),typeof ee.UNSAFE_componentWillUpdate=="function"&&ee.UNSAFE_componentWillUpdate(E,It,Le)),typeof ee.componentDidUpdate=="function"&&(p.flags|=4),typeof ee.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof ee.componentDidUpdate!="function"||he===h.memoizedProps&&Bt===h.memoizedState||(p.flags|=4),typeof ee.getSnapshotBeforeUpdate!="function"||he===h.memoizedProps&&Bt===h.memoizedState||(p.flags|=1024),p.memoizedProps=E,p.memoizedState=It),ee.props=E,ee.state=It,ee.context=Le,E=tt):(typeof ee.componentDidUpdate!="function"||he===h.memoizedProps&&Bt===h.memoizedState||(p.flags|=4),typeof ee.getSnapshotBeforeUpdate!="function"||he===h.memoizedProps&&Bt===h.memoizedState||(p.flags|=1024),E=!1)}return Km(h,p,_,E,O,P)}function Km(h,p,_,E,P,O){qm(h,p);var ee=(p.flags&128)!==0;if(!E&&!ee)return P&&Vr(p,_,!1),ia(h,p,O);E=p.stateNode,kv.current=p;var he=ee&&typeof _.getDerivedStateFromError!="function"?null:E.render();return p.flags|=1,h!==null&&ee?(p.child=oc(p,h.child,null,O),p.child=oc(p,null,he,O)):Rr(h,p,he,O),p.memoizedState=E.state,P&&Vr(p,_,!0),p.child}function Zm(h){var p=h.stateNode;p.pendingContext?xr(h,p.pendingContext,p.pendingContext!==p.context):p.context&&xr(h,p.context,!1),cc(h,p.containerInfo)}function Nv(h,p,_,E,P){return na(),Lm(P),p.flags|=256,Rr(h,p,_,E),p.child}var jf={dehydrated:null,treeContext:null,retryLane:0};function Xf(h){return{baseLanes:h,cachePool:null}}function Fv(h,p,_){var E=p.pendingProps,P=mn.current,O=!1,ee=(p.flags&128)!==0,he;if((he=ee)||(he=h!==null&&h.memoizedState===null?!1:(P&2)!==0),he?(O=!0,p.flags&=-129):(h===null||h.memoizedState!==null)&&(P|=1),Gt(mn,P&1),h===null)return Du(p),h=p.memoizedState,h!==null&&(h=h.dehydrated,h!==null)?(p.mode&1?Pa(h)?p.lanes=8:p.lanes=1073741824:p.lanes=1,null):(P=E.children,h=E.fallback,O?(E=p.mode,O=p.child,P={mode:"hidden",children:P},!(E&1)&&O!==null?(O.childLanes=0,O.pendingProps=P):O=Zu(P,E,0,null),h=_l(h,E,_,null),O.return=p,h.return=p,O.sibling=h,p.child=O,p.child.memoizedState=Xf(_),p.memoizedState=jf,h):Jm(p,P));if(P=h.memoizedState,P!==null){if(he=P.dehydrated,he!==null){if(ee)return p.flags&256?(p.flags&=-257,qf(h,p,_,Error(o(422)))):p.memoizedState!==null?(p.child=h.child,p.flags|=128,null):(O=E.fallback,P=p.mode,E=Zu({mode:"visible",children:E.children},P,0,null),O=_l(O,P,_,null),O.flags|=2,E.return=p,O.return=p,E.sibling=O,p.child=E,p.mode&1&&oc(p,h.child,null,_),p.child.memoizedState=Xf(_),p.memoizedState=jf,O);if(!(p.mode&1))p=qf(h,p,_,null);else if(Pa(he))p=qf(h,p,_,Error(o(419)));else if(E=(_&h.childLanes)!==0,cs||E){if(E=Ci,E!==null){switch(_&-_){case 4:O=2;break;case 16:O=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:O=32;break;case 536870912:O=268435456;break;default:O=0}E=O&(E.suspendedLanes|_)?0:O,E!==0&&E!==P.retryLane&&(P.retryLane=E,Ts(h,E,-1))}pg(),p=qf(h,p,_,Error(o(421)))}else Ca(he)?(p.flags|=128,p.child=h.child,p=br.bind(null,h),ol(he,p),p=null):(_=P.treeContext,Ge&&(wr=xo(he),as=p,ni=!0,js=null,Iu=!1,_!==null&&(ss[Es++]=ta,ss[Es++]=Ws,ss[Es++]=hl,ta=_.id,Ws=_.overflow,hl=p)),p=Jm(p,p.pendingProps.children),p.flags|=4096);return p}return O?(E=zv(h,p,E.children,E.fallback,_),O=p.child,P=h.child.memoizedState,O.memoizedState=P===null?Xf(_):{baseLanes:P.baseLanes|_,cachePool:null},O.childLanes=h.childLanes&~_,p.memoizedState=jf,E):(_=Uv(h,p,E.children,_),p.memoizedState=null,_)}return O?(E=zv(h,p,E.children,E.fallback,_),O=p.child,P=h.child.memoizedState,O.memoizedState=P===null?Xf(_):{baseLanes:P.baseLanes|_,cachePool:null},O.childLanes=h.childLanes&~_,p.memoizedState=jf,E):(_=Uv(h,p,E.children,_),p.memoizedState=null,_)}function Jm(h,p){return p=Zu({mode:"visible",children:p},h.mode,0,null),p.return=h,h.child=p}function Uv(h,p,_,E){var P=h.child;return h=P.sibling,_=qs(P,{mode:"visible",children:_}),!(p.mode&1)&&(_.lanes=E),_.return=p,_.sibling=null,h!==null&&(E=p.deletions,E===null?(p.deletions=[h],p.flags|=16):E.push(h)),p.child=_}function zv(h,p,_,E,P){var O=p.mode;h=h.child;var ee=h.sibling,he={mode:"hidden",children:_};return!(O&1)&&p.child!==h?(_=p.child,_.childLanes=0,_.pendingProps=he,p.deletions=null):(_=qs(h,he),_.subtreeFlags=h.subtreeFlags&14680064),ee!==null?E=qs(ee,E):(E=_l(E,O,P,null),E.flags|=2),E.return=p,_.return=p,_.sibling=E,p.child=_,E}function qf(h,p,_,E){return E!==null&&Lm(E),oc(p,h.child,null,_),h=Jm(p,p.pendingProps.children),h.flags|=2,p.memoizedState=null,h}function Bv(h,p,_){h.lanes|=p;var E=h.alternate;E!==null&&(E.lanes|=p),bm(h.return,p,_)}function Qm(h,p,_,E,P){var O=h.memoizedState;O===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:E,tail:_,tailMode:P}:(O.isBackwards=p,O.rendering=null,O.renderingStartTime=0,O.last=E,O.tail=_,O.tailMode=P)}function Vv(h,p,_){var E=p.pendingProps,P=E.revealOrder,O=E.tail;if(Rr(h,p,E.children,_),E=mn.current,E&2)E=E&1|2,p.flags|=128;else{if(h!==null&&h.flags&128)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&Bv(h,_,p);else if(h.tag===19)Bv(h,_,p);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===p)break e;for(;h.sibling===null;){if(h.return===null||h.return===p)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}E&=1}if(Gt(mn,E),!(p.mode&1))p.memoizedState=null;else switch(P){case"forwards":for(_=p.child,P=null;_!==null;)h=_.alternate,h!==null&&Of(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),Qm(p,!1,P,_,O);break;case"backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(h=P.alternate,h!==null&&Of(h)===null){p.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}Qm(p,!0,_,null,O);break;case"together":Qm(p,!1,null,null,void 0);break;default:p.memoizedState=null}return p.child}function ia(h,p,_){if(h!==null&&(p.dependencies=h.dependencies),dc|=p.lanes,!(_&p.childLanes))return null;if(h!==null&&p.child!==h.child)throw Error(o(153));if(p.child!==null){for(h=p.child,_=qs(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=qs(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function SM(h,p,_){switch(p.tag){case 3:Zm(p),na();break;case 5:uv(p);break;case 1:ti(p.type)&&$l(p);break;case 4:cc(p,p.stateNode.containerInfo);break;case 10:iv(p,p.type._context,p.memoizedProps.value);break;case 13:var E=p.memoizedState;if(E!==null)return E.dehydrated!==null?(Gt(mn,mn.current&1),p.flags|=128,null):_&p.child.childLanes?Fv(h,p,_):(Gt(mn,mn.current&1),h=ia(h,p,_),h!==null?h.sibling:null);Gt(mn,mn.current&1);break;case 19:if(E=(_&p.childLanes)!==0,h.flags&128){if(E)return Vv(h,p,_);p.flags|=128}var P=p.memoizedState;if(P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),Gt(mn,mn.current),E)break;return null;case 22:case 23:return p.lanes=0,Ov(h,p,_)}return ia(h,p,_)}function _M(h,p){switch(Rm(p),p.tag){case 1:return ti(p.type)&&wo(),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return Co(),_n(fi),_n(xi),Fn(),h=p.flags,h&65536&&!(h&128)?(p.flags=h&-65537|128,p):null;case 5:return Df(p),null;case 13:if(_n(mn),h=p.memoizedState,h!==null&&h.dehydrated!==null){if(p.alternate===null)throw Error(o(340));na()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 19:return _n(mn),null;case 4:return Co(),null;case 10:return Am(p.type._context),null;case 22:case 23:return hd(),null;case 24:return null;default:return null}}var Yf=!1,pl=!1,MM=typeof WeakSet=="function"?WeakSet:Set,pt=null;function Kf(h,p){var _=h.ref;if(_!==null)if(typeof _=="function")try{_(null)}catch(E){Ar(h,p,E)}else _.current=null}function $m(h,p,_){try{_()}catch(E){Ar(h,p,E)}}var Hv=!1;function AM(h,p){for(ie(h.containerInfo),pt=p;pt!==null;)if(h=pt,p=h.child,(h.subtreeFlags&1028)!==0&&p!==null)p.return=h,pt=p;else for(;pt!==null;){h=pt;try{var _=h.alternate;if(h.flags&1024)switch(h.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var E=_.memoizedProps,P=_.memoizedState,O=h.stateNode,ee=O.getSnapshotBeforeUpdate(h.elementType===h.type?E:Hs(h.type,E),P);O.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:Dt&&ct(h.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(he){Ar(h,h.return,he)}if(p=h.sibling,p!==null){p.return=h.return,pt=p;break}pt=h.return}return _=Hv,Hv=!1,_}function ml(h,p,_){var E=p.updateQueue;if(E=E!==null?E.lastEffect:null,E!==null){var P=E=E.next;do{if((P.tag&h)===h){var O=P.destroy;P.destroy=void 0,O!==void 0&&$m(p,_,O)}P=P.next}while(P!==E)}}function Hu(h,p){if(p=p.updateQueue,p=p!==null?p.lastEffect:null,p!==null){var _=p=p.next;do{if((_.tag&h)===h){var E=_.create;_.destroy=E()}_=_.next}while(_!==p)}}function eg(h){var p=h.ref;if(p!==null){var _=h.stateNode;switch(h.tag){case 5:h=Se(_);break;default:h=_}typeof p=="function"?p(h):p.current=h}}function tg(h,p,_){if(Bs&&typeof Bs.onCommitFiberUnmount=="function")try{Bs.onCommitFiberUnmount(ka,p)}catch{}switch(p.tag){case 0:case 11:case 14:case 15:if(h=p.updateQueue,h!==null&&(h=h.lastEffect,h!==null)){var E=h=h.next;do{var P=E,O=P.destroy;P=P.tag,O!==void 0&&(P&2||P&4)&&$m(p,_,O),E=E.next}while(E!==h)}break;case 1:if(Kf(p,_),h=p.stateNode,typeof h.componentWillUnmount=="function")try{h.props=p.memoizedProps,h.state=p.memoizedState,h.componentWillUnmount()}catch(ee){Ar(p,_,ee)}break;case 5:Kf(p,_);break;case 4:Dt?Jf(h,p,_):Ie&&Ie&&(p=p.stateNode.containerInfo,_=Tn(p),kn(p,_))}}function Gv(h,p,_){for(var E=p;;)if(tg(h,E,_),E.child===null||Dt&&E.tag===4){if(E===p)break;for(;E.sibling===null;){if(E.return===null||E.return===p)return;E=E.return}E.sibling.return=E.return,E=E.sibling}else E.child.return=E,E=E.child}function Wv(h){var p=h.alternate;p!==null&&(h.alternate=null,Wv(p)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(p=h.stateNode,p!==null&&ft(p)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}function jv(h){return h.tag===5||h.tag===3||h.tag===4}function Xv(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||jv(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function qv(h){if(Dt){e:{for(var p=h.return;p!==null;){if(jv(p))break e;p=p.return}throw Error(o(160))}var _=p;switch(_.tag){case 5:p=_.stateNode,_.flags&32&&(et(p),_.flags&=-33),_=Xv(h),Zf(h,_,p);break;case 3:case 4:p=_.stateNode.containerInfo,_=Xv(h),ng(h,_,p);break;default:throw Error(o(161))}}}function ng(h,p,_){var E=h.tag;if(E===5||E===6)h=h.stateNode,p?on(_,h,p):Ze(_,h);else if(E!==4&&(h=h.child,h!==null))for(ng(h,p,_),h=h.sibling;h!==null;)ng(h,p,_),h=h.sibling}function Zf(h,p,_){var E=h.tag;if(E===5||E===6)h=h.stateNode,p?dt(_,h,p):Zt(_,h);else if(E!==4&&(h=h.child,h!==null))for(Zf(h,p,_),h=h.sibling;h!==null;)Zf(h,p,_),h=h.sibling}function Jf(h,p,_){for(var E=p,P=!1,O,ee;;){if(!P){P=E.return;e:for(;;){if(P===null)throw Error(o(160));switch(O=P.stateNode,P.tag){case 5:ee=!1;break e;case 3:O=O.containerInfo,ee=!0;break e;case 4:O=O.containerInfo,ee=!0;break e}P=P.return}P=!0}if(E.tag===5||E.tag===6)Gv(h,E,_),ee?Qn(O,E.stateNode):dn(O,E.stateNode);else if(E.tag===18)ee?Lt(O,E.stateNode):st(O,E.stateNode);else if(E.tag===4){if(E.child!==null){O=E.stateNode.containerInfo,ee=!0,E.child.return=E,E=E.child;continue}}else if(tg(h,E,_),E.child!==null){E.child.return=E,E=E.child;continue}if(E===p)break;for(;E.sibling===null;){if(E.return===null||E.return===p)return;E=E.return,E.tag===4&&(P=!1)}E.sibling.return=E.return,E=E.sibling}}function Qf(h,p){if(Dt){switch(p.tag){case 0:case 11:case 14:case 15:ml(3,p,p.return),Hu(3,p),ml(5,p,p.return);return;case 1:return;case 5:var _=p.stateNode;if(_!=null){var E=p.memoizedProps;h=h!==null?h.memoizedProps:E;var P=p.type,O=p.updateQueue;p.updateQueue=null,O!==null&&Ft(_,O,P,h,E,p)}return;case 6:if(p.stateNode===null)throw Error(o(162));_=p.memoizedProps,kt(p.stateNode,h!==null?h.memoizedProps:_,_);return;case 3:Ge&&h!==null&&h.memoizedState.isDehydrated&&_e(p.stateNode.containerInfo);return;case 12:return;case 13:Gu(p);return;case 19:Gu(p);return;case 17:return}throw Error(o(163))}switch(p.tag){case 0:case 11:case 14:case 15:ml(3,p,p.return),Hu(3,p),ml(5,p,p.return);return;case 12:return;case 13:Gu(p);return;case 19:Gu(p);return;case 3:Ge&&h!==null&&h.memoizedState.isDehydrated&&_e(p.stateNode.containerInfo);break;case 22:case 23:return}e:if(Ie){switch(p.tag){case 1:case 5:case 6:break e;case 3:case 4:p=p.stateNode,kn(p.containerInfo,p.pendingChildren);break e}throw Error(o(163))}}function Gu(h){var p=h.updateQueue;if(p!==null){h.updateQueue=null;var _=h.stateNode;_===null&&(_=h.stateNode=new MM),p.forEach(function(E){var P=wl.bind(null,h,E);_.has(E)||(_.add(E),E.then(P,P))})}}function Yv(h,p){for(pt=p;pt!==null;){p=pt;var _=p.deletions;if(_!==null)for(var E=0;E<_.length;E++){var P=_[E];try{var O=h;Dt?Jf(O,P,p):Gv(O,P,p);var ee=P.alternate;ee!==null&&(ee.return=null),P.return=null}catch(Nt){Ar(P,p,Nt)}}if(_=p.child,p.subtreeFlags&12854&&_!==null)_.return=p,pt=_;else for(;pt!==null;){p=pt;try{var he=p.flags;if(he&32&&Dt&&et(p.stateNode),he&512){var Le=p.alternate;if(Le!==null){var tt=Le.ref;tt!==null&&(typeof tt=="function"?tt(null):tt.current=null)}}if(he&8192)switch(p.tag){case 13:if(p.memoizedState!==null){var Mt=p.alternate;(Mt===null||Mt.memoizedState===null)&&(cg=zi())}break;case 22:var sn=p.memoizedState!==null,Bt=p.alternate,Gn=Bt!==null&&Bt.memoizedState!==null;if(_=p,Dt){e:if(E=_,P=sn,O=null,Dt)for(var It=E;;){if(It.tag===5){if(O===null){O=It;var Zi=It.stateNode;P?ce(Zi):Re(It.stateNode,It.memoizedProps)}}else if(It.tag===6){if(O===null){var cr=It.stateNode;P?Ue(cr):nt(cr,It.memoizedProps)}}else if((It.tag!==22&&It.tag!==23||It.memoizedState===null||It===E)&&It.child!==null){It.child.return=It,It=It.child;continue}if(It===E)break;for(;It.sibling===null;){if(It.return===null||It.return===E)break e;O===It&&(O=null),It=It.return}O===It&&(O=null),It.sibling.return=It.return,It=It.sibling}}if(sn&&!Gn&&_.mode&1){pt=_;for(var be=_.child;be!==null;){for(_=pt=be;pt!==null;){E=pt;var pe=E.child;switch(E.tag){case 0:case 11:case 14:case 15:ml(4,E,E.return);break;case 1:Kf(E,E.return);var Ce=E.stateNode;if(typeof Ce.componentWillUnmount=="function"){var gt=E.return;try{Ce.props=E.memoizedProps,Ce.state=E.memoizedState,Ce.componentWillUnmount()}catch(Nt){Ar(E,gt,Nt)}}break;case 5:Kf(E,E.return);break;case 22:if(E.memoizedState!==null){Jv(_);continue}}pe!==null?(pe.return=E,pt=pe):Jv(_)}be=be.sibling}}}switch(he&4102){case 2:qv(p),p.flags&=-3;break;case 6:qv(p),p.flags&=-3,Qf(p.alternate,p);break;case 4096:p.flags&=-4097;break;case 4100:p.flags&=-4097,Qf(p.alternate,p);break;case 4:Qf(p.alternate,p)}}catch(Nt){Ar(p,p.return,Nt)}if(_=p.sibling,_!==null){_.return=p.return,pt=_;break}pt=p.return}}}function bM(h,p,_){pt=h,Kv(h)}function Kv(h,p,_){for(var E=(h.mode&1)!==0;pt!==null;){var P=pt,O=P.child;if(P.tag===22&&E){var ee=P.memoizedState!==null||Yf;if(!ee){var he=P.alternate,Le=he!==null&&he.memoizedState!==null||pl;he=Yf;var tt=pl;if(Yf=ee,(pl=Le)&&!tt)for(pt=P;pt!==null;)ee=pt,Le=ee.child,ee.tag===22&&ee.memoizedState!==null?Qv(P):Le!==null?(Le.return=ee,pt=Le):Qv(P);for(;O!==null;)pt=O,Kv(O),O=O.sibling;pt=P,Yf=he,pl=tt}Zv(h)}else P.subtreeFlags&8772&&O!==null?(O.return=P,pt=O):Zv(h)}}function Zv(h){for(;pt!==null;){var p=pt;if(p.flags&8772){var _=p.alternate;try{if(p.flags&8772)switch(p.tag){case 0:case 11:case 15:pl||Hu(5,p);break;case 1:var E=p.stateNode;if(p.flags&4&&!pl)if(_===null)E.componentDidMount();else{var P=p.elementType===p.type?_.memoizedProps:Hs(p.type,_.memoizedProps);E.componentDidUpdate(P,_.memoizedState,E.__reactInternalSnapshotBeforeUpdate)}var O=p.updateQueue;O!==null&&sv(p,O,E);break;case 3:var ee=p.updateQueue;if(ee!==null){if(_=null,p.child!==null)switch(p.child.tag){case 5:_=Se(p.child.stateNode);break;case 1:_=p.child.stateNode}sv(p,ee,_)}break;case 5:var he=p.stateNode;_===null&&p.flags&4&&en(he,p.type,p.memoizedProps,p);break;case 6:break;case 4:break;case 12:break;case 13:if(Ge&&p.memoizedState===null){var Le=p.alternate;if(Le!==null){var tt=Le.memoizedState;if(tt!==null){var Mt=tt.dehydrated;Mt!==null&&Ae(Mt)}}}break;case 19:case 17:case 21:case 22:case 23:break;default:throw Error(o(163))}pl||p.flags&512&&eg(p)}catch(sn){Ar(p,p.return,sn)}}if(p===h){pt=null;break}if(_=p.sibling,_!==null){_.return=p.return,pt=_;break}pt=p.return}}function Jv(h){for(;pt!==null;){var p=pt;if(p===h){pt=null;break}var _=p.sibling;if(_!==null){_.return=p.return,pt=_;break}pt=p.return}}function Qv(h){for(;pt!==null;){var p=pt;try{switch(p.tag){case 0:case 11:case 15:var _=p.return;try{Hu(4,p)}catch(Le){Ar(p,_,Le)}break;case 1:var E=p.stateNode;if(typeof E.componentDidMount=="function"){var P=p.return;try{E.componentDidMount()}catch(Le){Ar(p,P,Le)}}var O=p.return;try{eg(p)}catch(Le){Ar(p,O,Le)}break;case 5:var ee=p.return;try{eg(p)}catch(Le){Ar(p,ee,Le)}}}catch(Le){Ar(p,p.return,Le)}if(p===h){pt=null;break}var he=p.sibling;if(he!==null){he.return=p.return,pt=he;break}pt=p.return}}var $f=0,ed=1,td=2,nd=3,id=4;if(typeof Symbol=="function"&&Symbol.for){var Wu=Symbol.for;$f=Wu("selector.component"),ed=Wu("selector.has_pseudo_class"),td=Wu("selector.role"),nd=Wu("selector.test_id"),id=Wu("selector.text")}function ig(h){var p=Pe(h);if(p!=null){if(typeof p.memoizedProps["data-testname"]!="string")throw Error(o(364));return p}if(h=Me(h),h===null)throw Error(o(362));return h.stateNode.current}function rg(h,p){switch(p.$$typeof){case $f:if(h.type===p.value)return!0;break;case ed:e:{p=p.value,h=[h,0];for(var _=0;_";case ed:return":has("+(sg(h)||"")+")";case td:return'[role="'+h.value+'"]';case id:return'"'+h.value+'"';case nd:return'[data-testname="'+h.value+'"]';default:throw Error(o(365))}}function $v(h,p){var _=[];h=[h,0];for(var E=0;EP&&(P=ee),E&=~O}if(E=P,E=zi()-E,E=(120>E?120:480>E?480:1080>E?1080:1920>E?1920:3e3>E?3e3:4320>E?4320:1960*EM(E/1960))-E,10h?16:h,$e===null)var E=!1;else{if(h=$e,$e=null,ad=0,gn&6)throw Error(o(331));var P=gn;for(gn|=4,pt=h.current;pt!==null;){var O=pt,ee=O.child;if(pt.flags&16){var he=O.deletions;if(he!==null){for(var Le=0;Lezi()-cg?yl(h,0):lg|=_),kr(h,p)}function mg(h,p){p===0&&(h.mode&1?(p=Mu,Mu<<=1,!(Mu&130023424)&&(Mu=4194304)):p=1);var _=Tt();h=cd(h,p),h!==null&&(bu(h,p,_),kr(h,_))}function br(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),mg(h,_)}function wl(h,p){var _=0;switch(h.tag){case 13:var E=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:E=h.stateNode;break;default:throw Error(o(314))}E!==null&&E.delete(p),mg(h,_)}var rx;rx=function(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps||fi.current)cs=!0;else{if(!(h.lanes&_)&&!(p.flags&128))return cs=!1,SM(h,p,_);cs=!!(h.flags&131072)}else cs=!1,ni&&p.flags&1048576&&Pm(p,Lu,p.index);switch(p.lanes=0,p.tag){case 2:var E=p.type;h!==null&&(h.alternate=null,p.alternate=null,p.flags|=2),h=p.pendingProps;var P=ei(p,xi.current);La(p,_),P=Uf(null,p,E,h,P,_);var O=Om();return p.flags|=1,typeof P=="object"&&P!==null&&typeof P.render=="function"&&P.$$typeof===void 0?(p.tag=1,p.memoizedState=null,p.updateQueue=null,ti(E)?(O=!0,$l(p)):O=!1,p.memoizedState=P.state!==null&&P.state!==void 0?P.state:null,Em(p),P.updater=kf,p.stateNode=P,P._reactInternals=p,ku(p,E,h,_),p=Km(null,p,E,!0,O,_)):(p.tag=0,ni&&O&&rc(p),Rr(null,p,P,_),p=p.child),p;case 16:E=p.elementType;e:{switch(h!==null&&(h.alternate=null,p.alternate=null,p.flags|=2),h=p.pendingProps,P=E._init,E=P(E._payload),p.type=E,P=p.tag=Ku(E),h=Hs(E,h),P){case 0:p=Ym(null,p,E,h,_);break e;case 1:p=Vu(null,p,E,h,_);break e;case 11:p=Lv(null,p,E,h,_);break e;case 14:p=Iv(null,p,E,Hs(E.type,h),_);break e}throw Error(o(306,E,""))}return p;case 0:return E=p.type,P=p.pendingProps,P=p.elementType===E?P:Hs(E,P),Ym(h,p,E,P,_);case 1:return E=p.type,P=p.pendingProps,P=p.elementType===E?P:Hs(E,P),Vu(h,p,E,P,_);case 3:e:{if(Zm(p),h===null)throw Error(o(387));E=p.pendingProps,O=p.memoizedState,P=O.element,Tm(h,p),Rf(p,E,null,_);var ee=p.memoizedState;if(E=ee.element,Ge&&O.isDehydrated)if(O={element:E,isDehydrated:!1,cache:ee.cache,transitions:ee.transitions},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){P=Error(o(423)),p=Nv(h,p,E,_,P);break e}else if(E!==P){P=Error(o(424)),p=Nv(h,p,E,_,P);break e}else for(Ge&&(wr=vo(p.stateNode.containerInfo),as=p,ni=!0,js=null,Iu=!1),_=Na(p,null,E,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(na(),E===P){p=ia(h,p,_);break e}Rr(h,p,E,_)}p=p.child}return p;case 5:return uv(p),h===null&&Du(p),E=p.type,P=p.pendingProps,O=h!==null?h.memoizedProps:null,ee=P.children,Ve(E,P)?ee=null:O!==null&&Ve(E,O)&&(p.flags|=32),qm(h,p),Rr(h,p,ee,_),p.child;case 6:return h===null&&Du(p),null;case 13:return Fv(h,p,_);case 4:return cc(p,p.stateNode.containerInfo),E=p.pendingProps,h===null?p.child=oc(p,null,E,_):Rr(h,p,E,_),p.child;case 11:return E=p.type,P=p.pendingProps,P=p.elementType===E?P:Hs(E,P),Lv(h,p,E,P,_);case 7:return Rr(h,p,p.pendingProps,_),p.child;case 8:return Rr(h,p,p.pendingProps.children,_),p.child;case 12:return Rr(h,p,p.pendingProps.children,_),p.child;case 10:e:{if(E=p.type._context,P=p.pendingProps,O=p.memoizedProps,ee=P.value,iv(p,E,ee),O!==null)if(_o(O.value,ee)){if(O.children===P.children&&!fi.current){p=ia(h,p,_);break e}}else for(O=p.child,O!==null&&(O.return=p);O!==null;){var he=O.dependencies;if(he!==null){ee=O.child;for(var Le=he.firstContext;Le!==null;){if(Le.context===E){if(O.tag===1){Le=Hr(-1,_&-_),Le.tag=2;var tt=O.updateQueue;if(tt!==null){tt=tt.shared;var Mt=tt.pending;Mt===null?Le.next=Le:(Le.next=Mt.next,Mt.next=Le),tt.pending=Le}}O.lanes|=_,Le=O.alternate,Le!==null&&(Le.lanes|=_),bm(O.return,_,p),he.lanes|=_;break}Le=Le.next}}else if(O.tag===10)ee=O.type===p.type?null:O.child;else if(O.tag===18){if(ee=O.return,ee===null)throw Error(o(341));ee.lanes|=_,he=ee.alternate,he!==null&&(he.lanes|=_),bm(ee,_,p),ee=O.sibling}else ee=O.child;if(ee!==null)ee.return=O;else for(ee=O;ee!==null;){if(ee===p){ee=null;break}if(O=ee.sibling,O!==null){O.return=ee.return,ee=O;break}ee=ee.return}O=ee}Rr(h,p,P.children,_),p=p.child}return p;case 9:return P=p.type,E=p.pendingProps.children,La(p,_),P=As(P),E=E(P),p.flags|=1,Rr(h,p,E,_),p.child;case 14:return E=p.type,P=Hs(E,p.pendingProps),P=Hs(E.type,P),Iv(h,p,E,P,_);case 15:return Dv(h,p,p.type,p.pendingProps,_);case 17:return E=p.type,P=p.pendingProps,P=p.elementType===E?P:Hs(E,P),h!==null&&(h.alternate=null,p.alternate=null,p.flags|=2),p.tag=1,ti(E)?(h=!0,$l(p)):h=!1,La(p,_),If(p,E,P),ku(p,E,P,_),Km(null,p,E,!0,h,_);case 19:return Vv(h,p,_);case 22:return Ov(h,p,_)}throw Error(o(156,p.tag))};function md(h,p){return Tu(h,p)}function Io(h,p,_,E){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lr(h,p,_,E){return new Io(h,p,_,E)}function Ki(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Ku(h){if(typeof h=="function")return Ki(h)?1:0;if(h!=null){if(h=h.$$typeof,h===w)return 11;if(h===M)return 14}return 2}function qs(h,p){var _=h.alternate;return _===null?(_=lr(h.tag,p,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=p,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&14680064,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,p=h.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_}function Sl(h,p,_,E,P,O){var ee=2;if(E=h,typeof h=="function")Ki(h)&&(ee=1);else if(typeof h=="string")ee=5;else e:switch(h){case u:return _l(_.children,P,O,p);case f:ee=8,P|=8;break;case g:return h=lr(12,_,p,P|2),h.elementType=g,h.lanes=O,h;case S:return h=lr(13,_,p,P),h.elementType=S,h.lanes=O,h;case x:return h=lr(19,_,p,P),h.elementType=x,h.lanes=O,h;case C:return Zu(_,P,O,p);default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case y:ee=10;break e;case v:ee=9;break e;case w:ee=11;break e;case M:ee=14;break e;case A:ee=16,E=null;break e}throw Error(o(130,h==null?h:typeof h,""))}return p=lr(ee,_,p,P),p.elementType=h,p.type=E,p.lanes=O,p}function _l(h,p,_,E){return h=lr(7,h,E,p),h.lanes=_,h}function Zu(h,p,_,E){return h=lr(22,h,E,p),h.elementType=C,h.lanes=_,h.stateNode={},h}function gc(h,p,_){return h=lr(6,h,null,p),h.lanes=_,h}function gd(h,p,_){return p=lr(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}function RM(h,p,_,E,P){this.tag=p,this.containerInfo=h,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=jt,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mf(0),this.expirationTimes=Mf(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mf(0),this.identifierPrefix=E,this.onRecoverableError=P,Ge&&(this.mutableSourceEagerHydrationData=null)}function sx(h,p,_,E,P,O,ee,he,Le){return h=new RM(h,p,_,he,Le),p===1?(p=1,O===!0&&(p|=8)):p=0,O=lr(3,null,null,p),h.current=O,O.stateNode=h,O.memoizedState={element:E,isDehydrated:_,cache:null,transitions:null},Em(O),h}function ox(h){if(!h)return ir;h=h._reactInternals;e:{if(I(h)!==h||h.tag!==1)throw Error(o(170));var p=h;do{switch(p.tag){case 3:p=p.stateNode.context;break e;case 1:if(ti(p.type)){p=p.stateNode.__reactInternalMemoizedMergedChildContext;break e}}p=p.return}while(p!==null);throw Error(o(171))}if(h.tag===1){var _=h.type;if(ti(_))return al(h,_,p)}return p}function ax(h){var p=h._reactInternals;if(p===void 0)throw typeof h.render=="function"?Error(o(188)):(h=Object.keys(h).join(","),Error(o(268,h)));return h=se(p),h===null?null:h.stateNode}function lx(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_=tt&&O>=sn&&P<=Mt&&ee<=Bt){h.splice(p,1);break}else if(E!==tt||_.width!==Le.width||Btee){if(!(O!==sn||_.height!==Le.height||MtP)){tt>E&&(Le.width+=tt-E,Le.x=E),MtO&&(Le.height+=sn-O,Le.y=O),Bt_&&(_=ee)),ee ")+` + +No matching component was found for: + `)+h.join(" > ")}return null},t.getPublicRootInstance=function(h){if(h=h.current,!h.child)return null;switch(h.child.tag){case 5:return Se(h.child.stateNode);default:return h.child.stateNode}},t.injectIntoDevTools=function(h){if(h={bundleType:h.bundleType,version:h.version,rendererPackageName:h.rendererPackageName,rendererConfig:h.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:a.ReactCurrentDispatcher,findHostInstanceByFiber:yd,findFiberByHostInstance:h.findFiberByHostInstance||vd,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")h=!1;else{var p=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(p.isDisabled||!p.supportsFiber)h=!0;else{try{ka=p.inject(h),Bs=p}catch{}h=!!p.checkDCE}}return h},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(h,p,_,E){if(!q)throw Error(o(363));h=og(h,p);var P=lt(h,_,E).disconnect;return{disconnect:function(){P()}}},t.registerMutableSourceForHydration=function(h,p){var _=p._getVersion;_=_(p._source),h.mutableSourceEagerHydrationData==null?h.mutableSourceEagerHydrationData=[p,_]:h.mutableSourceEagerHydrationData.push(p,_)},t.runWithPriority=function(h,p){var _=bn;try{return bn=h,p()}finally{bn=_}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(h,p,_,E){var P=p.current,O=Tt(),ee=ar(P);return _=ox(_),p.context===null?p.context=_:p.pendingContext=_,p=Hr(O,ee),p.payload={element:h},E=E===void 0?null:E,E!==null&&(p.callback=E),bo(P,p),h=Ts(P,ee,O),h!==null&&Pf(h,P,ee),ee},t};t5.exports=kQ;var LQ=t5.exports;const IQ=s2(LQ);var n5={exports:{}},i5={};/** + * @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. + */(function(n){function e(X,ie){var re=X.length;X.push(ie);e:for(;0>>1,Oe=X[de];if(0>>1;der(Ve,re))Yer(He,Ve)?(X[de]=He,X[Ye]=re,de=Ye):(X[de]=Ve,X[we]=re,de=we);else if(Yer(He,re))X[de]=He,X[Ye]=re,de=Ye;else break e}}return ie}function r(X,ie){var re=X.sortIndex-ie.sortIndex;return re!==0?re:X.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,f=null,g=3,y=!1,v=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(X){for(var ie=t(c);ie!==null;){if(ie.callback===null)i(c);else if(ie.startTime<=X)i(c),ie.sortIndex=ie.expirationTime,e(l,ie);else break;ie=t(c)}}function C(X){if(w=!1,A(X),!v)if(t(l)!==null)v=!0,Se(N);else{var ie=t(c);ie!==null&&Fe(C,ie.startTime-X)}}function N(X,ie){v=!1,w&&(w=!1,x(H),H=-1),y=!0;var re=g;try{for(A(ie),f=t(l);f!==null&&(!(f.expirationTime>ie)||X&&!W());){var de=f.callback;if(typeof de=="function"){f.callback=null,g=f.priorityLevel;var Oe=de(f.expirationTime<=ie);ie=n.unstable_now(),typeof Oe=="function"?f.callback=Oe:f===t(l)&&i(l),A(ie)}else i(l);f=t(l)}if(f!==null)var it=!0;else{var we=t(c);we!==null&&Fe(C,we.startTime-ie),it=!1}return it}finally{f=null,g=re,y=!1}}var L=!1,F=null,H=-1,I=5,R=-1;function W(){return!(n.unstable_now()-RX||125de?(X.sortIndex=re,e(c,X),t(l)===null&&X===t(c)&&(w?(x(H),H=-1):w=!0,Fe(C,re-de))):(X.sortIndex=Oe,e(l,X),v||y||(v=!0,Se(N))),X},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(X){var ie=g;return function(){var re=g;g=ie;try{return X.apply(this,arguments)}finally{g=re}}}})(i5);n5.exports=i5;var lI=n5.exports;const DQ=n=>typeof n=="object"&&typeof n.then=="function",Fh=[];function r5(n,e,t=(i,r)=>i===r){if(n===e)return!0;if(!n||!e)return!1;const i=n.length;if(e.length!==i)return!1;for(let r=0;r0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,i.lifespan)),s.response;if(!t)throw s.promise}const r={keys:e,equal:i.equal,remove:()=>{const s=Fh.indexOf(r);s!==-1&&Fh.splice(s,1)},promise:(DQ(n)?n:n(...e)).then(s=>{r.response=s,i.lifespan&&i.lifespan>0&&(r.timeout=setTimeout(r.remove,i.lifespan))}).catch(s=>r.error=s)};if(Fh.push(r),!t)throw r.promise}const OQ=(n,e,t)=>s5(n,e,!1,t),NQ=(n,e,t)=>void s5(n,e,!0,t),FQ=n=>{if(n===void 0||n.length===0)Fh.splice(0,Fh.length);else{const e=Fh.find(t=>r5(n,t.keys,t.equal));e&&e.remove()}},fP={},UQ=n=>void Object.assign(fP,n);function zQ(n,e){function t(u,{args:f=[],attach:g,...y},v){let w=`${u[0].toUpperCase()}${u.slice(1)}`,S;if(u==="primitive"){if(y.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const x=y.object;S=rp(x,{type:u,root:v,attach:g,primitive:!0})}else{const x=fP[w];if(!x)throw new Error(`R3F: ${w} 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(f))throw new Error("R3F: The args prop must be an array!");S=rp(new x(...f),{type:u,root:v,attach:g,memoizedProps:{args:f}})}return S.__r3f.attach===void 0&&(S instanceof cn?S.__r3f.attach="geometry":S instanceof nr&&(S.__r3f.attach="material")),w!=="inject"&&lb(S,y),S}function i(u,f){let g=!1;if(f){var y,v;(y=f.__r3f)!=null&&y.attach?ab(u,f,f.__r3f.attach):f.isObject3D&&u.isObject3D&&(u.add(f),g=!0),g||(v=u.__r3f)==null||v.objects.push(f),f.__r3f||rp(f,{}),f.__r3f.parent=u,kT(f),sp(f)}}function r(u,f,g){let y=!1;if(f){var v,w;if((v=f.__r3f)!=null&&v.attach)ab(u,f,f.__r3f.attach);else if(f.isObject3D&&u.isObject3D){f.parent=u,f.dispatchEvent({type:"added"}),u.dispatchEvent({type:"childadded",child:f});const S=u.children.filter(M=>M!==f),x=S.indexOf(g);u.children=[...S.slice(0,x),f,...S.slice(x)],y=!0}y||(w=u.__r3f)==null||w.objects.push(f),f.__r3f||rp(f,{}),f.__r3f.parent=u,kT(f),sp(f)}}function s(u,f,g=!1){u&&[...u].forEach(y=>o(f,y,g))}function o(u,f,g){if(f){var y,v,w;if(f.__r3f&&(f.__r3f.parent=null),(y=u.__r3f)!=null&&y.objects&&(u.__r3f.objects=u.__r3f.objects.filter(C=>C!==f)),(v=f.__r3f)!=null&&v.attach)dI(u,f,f.__r3f.attach);else if(f.isObject3D&&u.isObject3D){var S;u.remove(f),(S=f.__r3f)!=null&&S.root&&YQ(hw(f),f)}const M=(w=f.__r3f)==null?void 0:w.primitive,A=!M&&(g===void 0?f.dispose!==null:g);if(!M){var x;s((x=f.__r3f)==null?void 0:x.objects,f,A),s(f.children,f,A)}if(delete f.__r3f,A&&f.dispose&&f.type!=="Scene"){const C=()=>{try{f.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?lI.unstable_scheduleCallback(lI.unstable_IdlePriority,C):C()}sp(u)}}function a(u,f,g,y){var v;const w=(v=u.__r3f)==null?void 0:v.parent;if(!w)return;const S=t(f,g,u.__r3f.root);if(u.children){for(const x of u.children)x.__r3f&&i(S,x);u.children=u.children.filter(x=>!x.__r3f)}u.__r3f.objects.forEach(x=>i(S,x)),u.__r3f.objects=[],u.__r3f.autoRemovedBeforeAppend||o(w,u),S.parent&&(S.__r3f.autoRemovedBeforeAppend=!0),i(w,S),S.raycast&&S.__r3f.eventCount&&hw(S).getState().internal.interaction.push(S),[y,y.alternate].forEach(x=>{x!==null&&(x.stateNode=S,x.ref&&(typeof x.ref=="function"?x.ref(S):x.ref.current=S))})}const l=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:IQ({createInstance:t,removeChild:o,appendChild:i,appendInitialChild:i,insertBefore:r,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(u,f)=>{if(!f)return;const g=u.getState().scene;g.__r3f&&(g.__r3f.root=u,i(g,f))},removeChildFromContainer:(u,f)=>{f&&o(u.getState().scene,f)},insertInContainerBefore:(u,f,g)=>{if(!f||!g)return;const y=u.getState().scene;y.__r3f&&r(y,f,g)},getRootHostContext:()=>null,getChildHostContext:u=>u,finalizeInitialChildren(u){var f;return!!((f=u==null?void 0:u.__r3f)!=null?f:{}).handlers},prepareUpdate(u,f,g,y){var v;if(((v=u==null?void 0:u.__r3f)!=null?v:{}).primitive&&y.object&&y.object!==u)return[!0];{const{args:S=[],children:x,...M}=y,{args:A=[],children:C,...N}=g;if(!Array.isArray(S))throw new Error("R3F: the args prop must be an array!");if(S.some((F,H)=>F!==A[H]))return[!0];const L=f5(u,M,N,!0);return L.changes.length?[!1,L]:null}},commitUpdate(u,[f,g],y,v,w,S){f?a(u,y,w,S):lb(u,g)},commitMount(u,f,g,y){var v;const w=(v=u.__r3f)!=null?v:{};u.raycast&&w.handlers&&w.eventCount&&hw(u).getState().internal.interaction.push(u)},getPublicInstance:u=>u,prepareForCommit:()=>null,preparePortalMount:u=>rp(u.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(u){var f;const{attach:g,parent:y}=(f=u.__r3f)!=null?f:{};g&&y&&dI(y,u,g),u.isObject3D&&(u.visible=!1),sp(u)},unhideInstance(u,f){var g;const{attach:y,parent:v}=(g=u.__r3f)!=null?g:{};y&&v&&ab(v,u,y),(u.isObject3D&&f.visible==null||f.visible)&&(u.visible=!0),sp(u)},createTextInstance:l,hideTextInstance:l,unhideTextInstance:l,getCurrentEventPriority:()=>e?e():Ep.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&ci.fun(performance.now)?performance.now:ci.fun(Date.now)?Date.now:()=>0,scheduleTimeout:ci.fun(setTimeout)?setTimeout:void 0,cancelTimeout:ci.fun(clearTimeout)?clearTimeout:void 0}),applyProps:lb}}var cI,uI;const ob=n=>"colorSpace"in n||"outputColorSpace"in n,o5=()=>{var n;return(n=fP.ColorManagement)!=null?n:null},a5=n=>n&&n.isOrthographicCamera,BQ=n=>n&&n.hasOwnProperty("current"),Fy=typeof window<"u"&&((cI=window.document)!=null&&cI.createElement||((uI=window.navigator)==null?void 0:uI.product)==="ReactNative")?le.useLayoutEffect:le.useEffect;function l5(n){const e=le.useRef(n);return Fy(()=>void(e.current=n),[n]),e}function VQ({set:n}){return Fy(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}class c5 extends le.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}c5.getDerivedStateFromError=()=>({error:!0});const u5="__default",hI=new Map,HQ=n=>n&&!!n.memoized&&!!n.changes;function h5(n){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(n)?Math.min(Math.max(n[0],t),n[1]):n}const Bg=n=>{var e;return(e=n.__r3f)==null?void 0:e.root.getState()};function hw(n){let e=n.__r3f.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const ci={obj:n=>n===Object(n)&&!ci.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:i="reference",strict:r=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(ci.str(n)||ci.num(n))return n===e;const s=ci.obj(n);if(s&&i==="reference")return n===e;const o=ci.arr(n);if(o&&t==="reference")return n===e;if((o||s)&&n===e)return!0;let a;for(a in n)if(!(a in e))return!1;if(s&&t==="shallow"&&i==="shallow"){for(a in r?e:n)if(!ci.equ(n[a],e[a],{strict:r,objects:"reference"}))return!1}else for(a in r?e:n)if(n[a]!==e[a])return!1;if(ci.und(a)){if(o&&n.length===0&&e.length===0||s&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function GQ(n){const e={nodes:{},materials:{}};return n&&n.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material)}),e}function WQ(n){n.dispose&&n.type!=="Scene"&&n.dispose();for(const e in n)e.dispose==null||e.dispose(),delete n[e]}function rp(n,e){const t=n;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},n}function RT(n,e){let t=n;if(e.includes("-")){const i=e.split("-"),r=i.pop();return t=i.reduce((s,o)=>s[o],n),{target:t,key:r}}else return{target:t,key:e}}const fI=/-\d+$/;function ab(n,e,t){if(ci.str(t)){if(fI.test(t)){const s=t.replace(fI,""),{target:o,key:a}=RT(n,s);Array.isArray(o[a])||(o[a]=[])}const{target:i,key:r}=RT(n,t);e.__r3f.previousAttach=i[r],i[r]=e}else e.__r3f.previousAttach=t(n,e)}function dI(n,e,t){var i,r;if(ci.str(t)){const{target:s,key:o}=RT(n,t),a=e.__r3f.previousAttach;a===void 0?delete s[o]:s[o]=a}else(i=e.__r3f)==null||i.previousAttach==null||i.previousAttach(n,e);(r=e.__r3f)==null||delete r.previousAttach}function f5(n,{children:e,key:t,ref:i,...r},{children:s,key:o,ref:a,...l}={},c=!1){const u=n.__r3f,f=Object.entries(r),g=[];if(c){const v=Object.keys(l);for(let w=0;w{var S;if((S=n.__r3f)!=null&&S.primitive&&v==="object"||ci.equ(w,l[v]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(v))return g.push([v,w,!0,[]]);let x=[];v.includes("-")&&(x=v.split("-")),g.push([v,w,!1,x]);for(const M in r){const A=r[M];M.startsWith(`${v}-`)&&g.push([M,A,!1,M.split("-")])}});const y={...r};return u!=null&&u.memoizedProps&&u!=null&&u.memoizedProps.args&&(y.args=u.memoizedProps.args),u!=null&&u.memoizedProps&&u!=null&&u.memoizedProps.attach&&(y.attach=u.memoizedProps.attach),{memoized:y,changes:g}}const jQ=typeof process<"u"&&!1;function lb(n,e){var t;const i=n.__r3f,r=i==null?void 0:i.root,s=r==null||r.getState==null?void 0:r.getState(),{memoized:o,changes:a}=HQ(e)?e:f5(n,e),l=i==null?void 0:i.eventCount;n.__r3f&&(n.__r3f.memoizedProps=o);for(let u=0;ux[M],n),!(S&&S.set))){const[x,...M]=v.reverse();w=M.reverse().reduce((A,C)=>A[C],n),f=x}if(g===u5+"remove")if(w.constructor){let x=hI.get(w.constructor);x||(x=new w.constructor,hI.set(w.constructor,x)),g=x[f]}else g=0;if(y&&i)g?i.handlers[f]=g:delete i.handlers[f],i.eventCount=Object.keys(i.handlers).length;else if(S&&S.set&&(S.copy||S instanceof Wh)){if(Array.isArray(g))S.fromArray?S.fromArray(g):S.set(...g);else if(S.copy&&g&&g.constructor&&(jQ?S.constructor.name===g.constructor.name:S.constructor===g.constructor))S.copy(g);else if(g!==void 0){const x=S instanceof ht;!x&&S.setScalar?S.setScalar(g):S instanceof Wh&&g instanceof Wh?S.mask=g.mask:S.set(g),!o5()&&s&&!s.linear&&x&&S.convertSRGBToLinear()}}else if(w[f]=g,w[f]instanceof hi&&w[f].format===vs&&w[f].type===rl&&s){const x=w[f];ob(x)&&ob(s.gl)?x.colorSpace=s.gl.outputColorSpace:x.encoding=s.gl.outputEncoding}sp(n)}if(i&&i.parent&&n.raycast&&l!==i.eventCount){const u=hw(n).getState().internal,f=u.interaction.indexOf(n);f>-1&&u.interaction.splice(f,1),i.eventCount&&u.interaction.push(n)}return!(a.length===1&&a[0][0]==="onUpdate")&&a.length&&(t=n.__r3f)!=null&&t.parent&&kT(n),n}function sp(n){var e,t;const i=(e=n.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();i&&i.internal.frames===0&&i.invalidate()}function kT(n){n.onUpdate==null||n.onUpdate(n)}function XQ(n,e){n.manual||(a5(n)?(n.left=e.width/-2,n.right=e.width/2,n.top=e.height/2,n.bottom=e.height/-2):n.aspect=e.width/e.height,n.updateProjectionMatrix(),n.updateMatrixWorld())}function T1(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function qQ(){var n;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return Ep.DefaultEventPriority;switch((n=e.event)==null?void 0:n.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Ep.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Ep.ContinuousEventPriority;default:return Ep.DefaultEventPriority}}function d5(n,e,t,i){const r=t.get(e);r&&(t.delete(e),t.size===0&&(n.delete(i),r.target.releasePointerCapture(i)))}function YQ(n,e){const{internal:t}=n.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,r)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((i,r)=>{d5(t.capturedMap,e,i,r)})}function KQ(n){function e(l){const{internal:c}=n.getState(),u=l.offsetX-c.initialClick[0],f=l.offsetY-c.initialClick[1];return Math.round(Math.sqrt(u*u+f*f))}function t(l){return l.filter(c=>["Move","Over","Enter","Out","Leave"].some(u=>{var f;return(f=c.__r3f)==null?void 0:f.handlers["onPointer"+u]}))}function i(l,c){const u=n.getState(),f=new Set,g=[],y=c?c(u.internal.interaction):u.internal.interaction;for(let x=0;x{const A=Bg(x.object),C=Bg(M.object);return!A||!C?x.distance-M.distance:C.events.priority-A.events.priority||x.distance-M.distance}).filter(x=>{const M=T1(x);return f.has(M)?!1:(f.add(M),!0)});u.events.filter&&(w=u.events.filter(w,u));for(const x of w){let M=x.object;for(;M;){var S;(S=M.__r3f)!=null&&S.eventCount&&g.push({...x,eventObject:M}),M=M.parent}}if("pointerId"in l&&u.internal.capturedMap.has(l.pointerId))for(let x of u.internal.capturedMap.get(l.pointerId).values())f.has(T1(x.intersection))||g.push(x.intersection);return g}function r(l,c,u,f){const g=n.getState();if(l.length){const y={stopped:!1};for(const v of l){const w=Bg(v.object)||g,{raycaster:S,pointer:x,camera:M,internal:A}=w,C=new Q(x.x,x.y,0).unproject(M),N=R=>{var W,se;return(W=(se=A.capturedMap.get(R))==null?void 0:se.has(v.eventObject))!=null?W:!1},L=R=>{const W={intersection:v,target:c.target};A.capturedMap.has(R)?A.capturedMap.get(R).set(v.eventObject,W):A.capturedMap.set(R,new Map([[v.eventObject,W]])),c.target.setPointerCapture(R)},F=R=>{const W=A.capturedMap.get(R);W&&d5(A.capturedMap,v.eventObject,W,R)};let H={};for(let R in c){let W=c[R];typeof W!="function"&&(H[R]=W)}let I={...v,...H,pointer:x,intersections:l,stopped:y.stopped,delta:u,unprojectedPoint:C,ray:S.ray,camera:M,stopPropagation(){const R="pointerId"in c&&A.capturedMap.get(c.pointerId);if((!R||R.has(v.eventObject))&&(I.stopped=y.stopped=!0,A.hovered.size&&Array.from(A.hovered.values()).find(W=>W.eventObject===v.eventObject))){const W=l.slice(0,l.indexOf(v));s([...W,v])}},target:{hasPointerCapture:N,setPointerCapture:L,releasePointerCapture:F},currentTarget:{hasPointerCapture:N,setPointerCapture:L,releasePointerCapture:F},nativeEvent:c};if(f(I),y.stopped===!0)break}}return l}function s(l){const{internal:c}=n.getState();for(const u of c.hovered.values())if(!l.length||!l.find(f=>f.object===u.object&&f.index===u.index&&f.instanceId===u.instanceId)){const g=u.eventObject.__r3f,y=g==null?void 0:g.handlers;if(c.hovered.delete(T1(u)),g!=null&&g.eventCount){const v={...u,intersections:l};y.onPointerOut==null||y.onPointerOut(v),y.onPointerLeave==null||y.onPointerLeave(v)}}}function o(l,c){for(let u=0;us([]);case"onLostPointerCapture":return c=>{const{internal:u}=n.getState();"pointerId"in c&&u.capturedMap.has(c.pointerId)&&requestAnimationFrame(()=>{u.capturedMap.has(c.pointerId)&&(u.capturedMap.delete(c.pointerId),s([]))})}}return function(u){const{onPointerMissed:f,internal:g}=n.getState();g.lastEvent.current=u;const y=l==="onPointerMove",v=l==="onClick"||l==="onContextMenu"||l==="onDoubleClick",S=i(u,y?t:void 0),x=v?e(u):0;l==="onPointerDown"&&(g.initialClick=[u.offsetX,u.offsetY],g.initialHits=S.map(A=>A.eventObject)),v&&!S.length&&x<=2&&(o(u,g.interaction),f&&f(u)),y&&s(S);function M(A){const C=A.eventObject,N=C.__r3f,L=N==null?void 0:N.handlers;if(N!=null&&N.eventCount)if(y){if(L.onPointerOver||L.onPointerEnter||L.onPointerOut||L.onPointerLeave){const F=T1(A),H=g.hovered.get(F);H?H.stopped&&A.stopPropagation():(g.hovered.set(F,A),L.onPointerOver==null||L.onPointerOver(A),L.onPointerEnter==null||L.onPointerEnter(A))}L.onPointerMove==null||L.onPointerMove(A)}else{const F=L[l];F?(!v||g.initialHits.includes(C))&&(o(u,g.interaction.filter(H=>!g.initialHits.includes(H))),F(A)):v&&g.initialHits.includes(C)&&o(u,g.interaction.filter(H=>!g.initialHits.includes(H)))}}r(S,u,x,M)}}return{handlePointer:a}}const p5=n=>!!(n!=null&&n.render),m5=le.createContext(null),ZQ=(n,e)=>{const t=CQ((a,l)=>{const c=new Q,u=new Q,f=new Q;function g(x=l().camera,M=u,A=l().size){const{width:C,height:N,top:L,left:F}=A,H=C/N;M instanceof Q?f.copy(M):f.set(...M);const I=x.getWorldPosition(c).distanceTo(f);if(a5(x))return{width:C/x.zoom,height:N/x.zoom,top:L,left:F,factor:1,distance:I,aspect:H};{const R=x.fov*Math.PI/180,W=2*Math.tan(R/2)*I,se=W*(C/N);return{width:se,height:W,top:L,left:F,factor:C/se,distance:I,aspect:H}}}let y;const v=x=>a(M=>({performance:{...M.performance,current:x}})),w=new Be;return{set:a,get:l,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(x=1)=>n(l(),x),advance:(x,M)=>e(x,M,l()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new T_,pointer:w,mouse:w,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const x=l();y&&clearTimeout(y),x.performance.current!==x.performance.min&&v(x.performance.min),y=setTimeout(()=>v(l().performance.max),x.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:g},setEvents:x=>a(M=>({...M,events:{...M.events,...x}})),setSize:(x,M,A,C,N)=>{const L=l().camera,F={width:x,height:M,top:C||0,left:N||0,updateStyle:A};a(H=>({size:F,viewport:{...H.viewport,...g(L,u,F)}}))},setDpr:x=>a(M=>{const A=h5(x);return{viewport:{...M.viewport,dpr:A,initialDpr:M.viewport.initialDpr||A}}}),setFrameloop:(x="always")=>{const M=l().clock;M.stop(),M.elapsedTime=0,x!=="never"&&(M.start(),M.elapsedTime=0),a(()=>({frameloop:x}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:le.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(x,M,A)=>{const C=l().internal;return C.priority=C.priority+(M>0?1:0),C.subscribers.push({ref:x,priority:M,store:A}),C.subscribers=C.subscribers.sort((N,L)=>N.priority-L.priority),()=>{const N=l().internal;N!=null&&N.subscribers&&(N.priority=N.priority-(M>0?1:0),N.subscribers=N.subscribers.filter(L=>L.ref!==x))}}}}}),i=t.getState();let r=i.size,s=i.viewport.dpr,o=i.camera;return t.subscribe(()=>{const{camera:a,size:l,viewport:c,gl:u,set:f}=t.getState();if(l.width!==r.width||l.height!==r.height||c.dpr!==s){var g;r=l,s=c.dpr,XQ(a,l),u.setPixelRatio(c.dpr);const y=(g=l.updateStyle)!=null?g:typeof HTMLCanvasElement<"u"&&u.domElement instanceof HTMLCanvasElement;u.setSize(l.width,l.height,y)}a!==o&&(o=a,f(y=>({viewport:{...y.viewport,...y.viewport.getCurrentViewport(a)}})))}),t.subscribe(a=>n(a)),t};let C1,JQ=new Set,QQ=new Set,$Q=new Set;function cb(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function Vg(n,e){switch(n){case"before":return cb(JQ,e);case"after":return cb(QQ,e);case"tail":return cb($Q,e)}}let ub,hb;function fb(n,e,t){let i=e.clock.getDelta();for(e.frameloop==="never"&&typeof n=="number"&&(i=n-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=n),ub=e.internal.subscribers,C1=0;C10)&&!((u=s.gl.xr)!=null&&u.isPresenting)&&(i+=fb(c,s))}if(t=!1,Vg("after",c),i===0)return Vg("tail",c),e=!1,cancelAnimationFrame(r)}function a(c,u=1){var f;if(!c)return n.forEach(g=>a(g.store.getState(),u));(f=c.gl.xr)!=null&&f.isPresenting||!c.internal.active||c.frameloop==="never"||(u>1?c.internal.frames=Math.min(60,c.internal.frames+u):t?c.internal.frames=2:c.internal.frames=1,e||(e=!0,requestAnimationFrame(o)))}function l(c,u=!0,f,g){if(u&&Vg("before",c),f)fb(c,f,g);else for(const y of n.values())fb(c,y.store.getState());u&&Vg("after",c)}return{loop:o,invalidate:a,advance:l}}function g5(){const n=le.useContext(m5);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function y5(n=t=>t,e){return g5()(n,e)}function t$(n,e=0){const t=g5(),i=t.getState().internal.subscribe,r=l5(n);return Fy(()=>i(r,e,t),[e,i,t]),null}const pI=new WeakMap;function v5(n,e){return function(t,...i){let r=pI.get(t);return r||(r=new t,pI.set(t,r)),n&&n(r),Promise.all(i.map(s=>new Promise((o,a)=>r.load(s,l=>{l.scene&&Object.assign(l,GQ(l.scene)),o(l)},e,l=>a(new Error(`Could not load ${s}: ${l==null?void 0:l.message}`))))))}}function dP(n,e,t,i){const r=Array.isArray(e)?e:[e],s=OQ(v5(t,i),[n,...r],{equal:ci.equ});return Array.isArray(e)?s:s[0]}dP.preload=function(n,e,t){const i=Array.isArray(e)?e:[e];return NQ(v5(t),[n,...i])};dP.clear=function(n,e){const t=Array.isArray(e)?e:[e];return FQ([n,...t])};const tm=new Map,{invalidate:mI,advance:gI}=e$(tm),{reconciler:cS,applyProps:Xd}=zQ(tm,qQ),qd={objects:"shallow",strict:!1},n$=(n,e)=>{const t=typeof n=="function"?n(e):n;return p5(t)?t:new fz({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...n})};function i$(n,e){const t=typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement;if(e){const{width:i,height:r,top:s,left:o,updateStyle:a=t}=e;return{width:i,height:r,top:s,left:o,updateStyle:a}}else if(typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:i,height:r,top:s,left:o}=n.parentElement.getBoundingClientRect();return{width:i,height:r,top:s,left:o,updateStyle:t}}else if(typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0,updateStyle:t};return{width:0,height:0,top:0,left:0}}function r$(n){const e=tm.get(n),t=e==null?void 0:e.fiber,i=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,s=i||ZQ(mI,gI),o=t||cS.createContainer(s,Ep.ConcurrentRoot,null,!1,null,"",r,null);e||tm.set(n,{fiber:o,store:s});let a,l=!1,c;return{configure(u={}){let{gl:f,size:g,scene:y,events:v,onCreated:w,shadows:S=!1,linear:x=!1,flat:M=!1,legacy:A=!1,orthographic:C=!1,frameloop:N="always",dpr:L=[1,2],performance:F,raycaster:H,camera:I,onPointerMissed:R}=u,W=s.getState(),se=W.gl;W.gl||W.set({gl:se=n$(f,n)});let Z=W.raycaster;Z||W.set({raycaster:Z=new Qz});const{params:oe,...fe}=H||{};if(ci.equ(fe,Z,qd)||Xd(Z,{...fe}),ci.equ(oe,Z.params,qd)||Xd(Z,{params:{...Z.params,...oe}}),!W.camera||W.camera===c&&!ci.equ(c,I,qd)){c=I;const re=I instanceof Cy,de=re?I:C?new df(0,0,0,0,.1,1e3):new fr(75,0,.1,1e3);re||(de.position.z=5,I&&(Xd(de,I),("aspect"in I||"left"in I||"right"in I||"bottom"in I||"top"in I)&&(de.manual=!0,de.updateProjectionMatrix())),!W.camera&&!(I!=null&&I.rotation)&&de.lookAt(0,0,0)),W.set({camera:de}),Z.camera=de}if(!W.scene){let re;y instanceof sS?re=y:(re=new sS,y&&Xd(re,y)),W.set({scene:rp(re)})}if(!W.xr){var Se;const re=(it,we)=>{const Ve=s.getState();Ve.frameloop!=="never"&&gI(it,!0,Ve,we)},de=()=>{const it=s.getState();it.gl.xr.enabled=it.gl.xr.isPresenting,it.gl.xr.setAnimationLoop(it.gl.xr.isPresenting?re:null),it.gl.xr.isPresenting||mI(it)},Oe={connect(){const it=s.getState().gl;it.xr.addEventListener("sessionstart",de),it.xr.addEventListener("sessionend",de)},disconnect(){const it=s.getState().gl;it.xr.removeEventListener("sessionstart",de),it.xr.removeEventListener("sessionend",de)}};typeof((Se=se.xr)==null?void 0:Se.addEventListener)=="function"&&Oe.connect(),W.set({xr:Oe})}if(se.shadowMap){const re=se.shadowMap.enabled,de=se.shadowMap.type;if(se.shadowMap.enabled=!!S,ci.boo(S))se.shadowMap.type=x0;else if(ci.str(S)){var Fe;const Oe={basic:jU,percentage:e_,soft:x0,variance:fa};se.shadowMap.type=(Fe=Oe[S])!=null?Fe:x0}else ci.obj(S)&&Object.assign(se.shadowMap,S);(re!==se.shadowMap.enabled||de!==se.shadowMap.type)&&(se.shadowMap.needsUpdate=!0)}const X=o5();X&&("enabled"in X?X.enabled=!A:"legacyMode"in X&&(X.legacyMode=A)),l||Xd(se,{outputEncoding:x?3e3:3001,toneMapping:M?Qa:SC}),W.legacy!==A&&W.set(()=>({legacy:A})),W.linear!==x&&W.set(()=>({linear:x})),W.flat!==M&&W.set(()=>({flat:M})),f&&!ci.fun(f)&&!p5(f)&&!ci.equ(f,se,qd)&&Xd(se,f),v&&!W.events.handlers&&W.set({events:v(s)});const ie=i$(n,g);return ci.equ(ie,W.size,qd)||W.setSize(ie.width,ie.height,ie.updateStyle,ie.top,ie.left),L&&W.viewport.dpr!==h5(L)&&W.setDpr(L),W.frameloop!==N&&W.setFrameloop(N),W.onPointerMissed||W.set({onPointerMissed:R}),F&&!ci.equ(F,W.performance,qd)&&W.set(re=>({performance:{...re.performance,...F}})),a=w,l=!0,this},render(u){return l||this.configure(),cS.updateContainer(Or.jsx(s$,{store:s,children:u,onCreated:a,rootElement:n}),o,null,()=>{}),s},unmount(){x5(n)}}}function s$({store:n,children:e,onCreated:t,rootElement:i}){return Fy(()=>{const r=n.getState();r.set(s=>({internal:{...s.internal,active:!0}})),t&&t(r),n.getState().events.connected||r.events.connect==null||r.events.connect(i)},[]),Or.jsx(m5.Provider,{value:n,children:e})}function x5(n,e){const t=tm.get(n),i=t==null?void 0:t.fiber;if(i){const r=t==null?void 0:t.store.getState();r&&(r.internal.active=!1),cS.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{var s,o,a,l;r.events.disconnect==null||r.events.disconnect(),(s=r.gl)==null||(o=s.renderLists)==null||o.dispose==null||o.dispose(),(a=r.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(l=r.gl)!=null&&l.xr&&r.xr.disconnect(),WQ(r),tm.delete(n),e&&e(n)}catch{}},500)})}}cS.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:le.version});function LT(n,e,t){var i,r,s,o,a;e==null&&(e=100);function l(){var u=Date.now()-o;u=0?i=setTimeout(l,e-u):(i=null,t||(a=n.apply(s,r),s=r=null))}var c=function(){s=this,r=arguments,o=Date.now();var u=t&&!i;return i||(i=setTimeout(l,e)),u&&(a=n.apply(s,r),s=r=null),a};return c.clear=function(){i&&(clearTimeout(i),i=null)},c.flush=function(){i&&(a=n.apply(s,r),s=r=null,clearTimeout(i),i=null)},c}LT.debounce=LT;var o$=LT;const yI=s2(o$);function a$(n){let{debounce:e,scroll:t,polyfill:i,offsetSize:r}=n===void 0?{debounce:0,scroll:!1,offsetSize:!1}:n;const s=i||(typeof window>"u"?class{}:window.ResizeObserver);if(!s)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[o,a]=le.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),l=le.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),c=e?typeof e=="number"?e:e.scroll:null,u=e?typeof e=="number"?e:e.resize:null,f=le.useRef(!1);le.useEffect(()=>(f.current=!0,()=>void(f.current=!1)));const[g,y,v]=le.useMemo(()=>{const M=()=>{if(!l.current.element)return;const{left:A,top:C,width:N,height:L,bottom:F,right:H,x:I,y:R}=l.current.element.getBoundingClientRect(),W={left:A,top:C,width:N,height:L,bottom:F,right:H,x:I,y:R};l.current.element instanceof HTMLElement&&r&&(W.height=l.current.element.offsetHeight,W.width=l.current.element.offsetWidth),Object.freeze(W),f.current&&!h$(l.current.lastBounds,W)&&a(l.current.lastBounds=W)};return[M,u?yI(M,u):M,c?yI(M,c):M]},[a,r,c,u]);function w(){l.current.scrollContainers&&(l.current.scrollContainers.forEach(M=>M.removeEventListener("scroll",v,!0)),l.current.scrollContainers=null),l.current.resizeObserver&&(l.current.resizeObserver.disconnect(),l.current.resizeObserver=null)}function S(){l.current.element&&(l.current.resizeObserver=new s(v),l.current.resizeObserver.observe(l.current.element),t&&l.current.scrollContainers&&l.current.scrollContainers.forEach(M=>M.addEventListener("scroll",v,{capture:!0,passive:!0})))}const x=M=>{!M||M===l.current.element||(w(),l.current.element=M,l.current.scrollContainers=w5(M),S())};return c$(v,!!t),l$(y),le.useEffect(()=>{w(),S()},[t,v,y]),le.useEffect(()=>w,[]),[x,o,g]}function l$(n){le.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function c$(n,e){le.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function w5(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:i,overflowY:r}=window.getComputedStyle(n);return[t,i,r].some(s=>s==="auto"||s==="scroll")&&e.push(n),[...e,...w5(n.parentElement)]}const u$=["x","y","top","bottom","left","right","width","height"],h$=(n,e)=>u$.every(t=>n[t]===e[t]);var f$=Object.defineProperty,d$=Object.defineProperties,p$=Object.getOwnPropertyDescriptors,vI=Object.getOwnPropertySymbols,m$=Object.prototype.hasOwnProperty,g$=Object.prototype.propertyIsEnumerable,xI=(n,e,t)=>e in n?f$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,wI=(n,e)=>{for(var t in e||(e={}))m$.call(e,t)&&xI(n,t,e[t]);if(vI)for(var t of vI(e))g$.call(e,t)&&xI(n,t,e[t]);return n},y$=(n,e)=>d$(n,p$(e)),SI,_I;typeof window<"u"&&((SI=window.document)!=null&&SI.createElement||((_I=window.navigator)==null?void 0:_I.product)==="ReactNative")?le.useLayoutEffect:le.useEffect;function S5(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const r=S5(i,e,t);if(r)return r;i=e?null:i.sibling}}function _5(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const MI=console.error;console.error=function(){const n=[...arguments].join("");if(n!=null&&n.startsWith("Warning:")&&n.includes("useContext")){console.error=MI;return}return MI.apply(this,arguments)};const pP=_5(le.createContext(null));class M5 extends le.Component{render(){return le.createElement(pP.Provider,{value:this._reactInternals},this.props.children)}}function v$(){const n=le.useContext(pP);if(n===null)throw new Error("its-fine: useFiber must be called within a !");const e=le.useId();return le.useMemo(()=>{for(const i of[n,n==null?void 0:n.alternate]){if(!i)continue;const r=S5(i,!1,s=>{let o=s.memoizedState;for(;o;){if(o.memoizedState===e)return!0;o=o.next}});if(r)return r}},[n,e])}function x$(){const n=v$(),[e]=le.useState(()=>new Map);e.clear();let t=n;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!==pP&&!e.has(r)&&e.set(r,le.useContext(_5(r)))}t=t.return}return e}function w$(){const n=x$();return le.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>le.createElement(e,null,le.createElement(t.Provider,y$(wI({},i),{value:n.get(t)}))),e=>le.createElement(M5,wI({},e))),[n])}const db={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 S$(n){const{handlePointer:e}=KQ(n);return{priority:1,enabled:!0,compute(t,i,r){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(db).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:r}=n.getState();(t=r.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{var i;const{set:r,events:s}=n.getState();s.disconnect==null||s.disconnect(),r(o=>({events:{...o.events,connected:t}})),Object.entries((i=s.handlers)!=null?i:[]).forEach(([o,a])=>{const[l,c]=db[o];t.addEventListener(l,a,{passive:c})})},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){var r;Object.entries((r=i.handlers)!=null?r:[]).forEach(([s,o])=>{if(i&&i.connected instanceof HTMLElement){const[a]=db[s];i.connected.removeEventListener(a,o)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}const _$=le.forwardRef(function({children:e,fallback:t,resize:i,style:r,gl:s,events:o=S$,eventSource:a,eventPrefix:l,shadows:c,linear:u,flat:f,legacy:g,orthographic:y,frameloop:v,dpr:w,performance:S,raycaster:x,camera:M,scene:A,onPointerMissed:C,onCreated:N,...L},F){le.useMemo(()=>UQ(bQ),[]);const H=w$(),[I,R]=a$({scroll:!0,debounce:{scroll:50,resize:0},...i}),W=le.useRef(null),se=le.useRef(null);le.useImperativeHandle(F,()=>W.current);const Z=l5(C),[oe,fe]=le.useState(!1),[Se,Fe]=le.useState(!1);if(oe)throw oe;if(Se)throw Se;const X=le.useRef(null);Fy(()=>{const re=W.current;R.width>0&&R.height>0&&re&&(X.current||(X.current=r$(re)),X.current.configure({gl:s,events:o,shadows:c,linear:u,flat:f,legacy:g,orthographic:y,frameloop:v,dpr:w,performance:S,raycaster:x,camera:M,scene:A,size:R,onPointerMissed:(...de)=>Z.current==null?void 0:Z.current(...de),onCreated:de=>{de.events.connect==null||de.events.connect(a?BQ(a)?a.current:a:se.current),l&&de.setEvents({compute:(Oe,it)=>{const we=Oe[l+"X"],Ve=Oe[l+"Y"];it.pointer.set(we/it.size.width*2-1,-(Ve/it.size.height)*2+1),it.raycaster.setFromCamera(it.pointer,it.camera)}}),N==null||N(de)}}),X.current.render(Or.jsx(H,{children:Or.jsx(c5,{set:Fe,children:Or.jsx(le.Suspense,{fallback:Or.jsx(VQ,{set:fe}),children:e})})})))}),le.useEffect(()=>{const re=W.current;if(re)return()=>x5(re)},[]);const ie=a?"none":"auto";return Or.jsx("div",{ref:se,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:ie,...r},...L,children:Or.jsx("div",{ref:I,style:{width:"100%",height:"100%"},children:Or.jsx("canvas",{ref:W,style:{display:"block"},children:t})})})}),M$=le.forwardRef(function(e,t){return Or.jsx(M5,{children:Or.jsx(_$,{...e,ref:t})})}),A$={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 Uy{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 b$=new df(-1,1,1,-1,0,1);class E$ extends cn{constructor(){super(),this.setAttribute("position",new Rt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Rt([0,2,0,0,2,0],2))}}const T$=new E$;class A5{constructor(e){this._mesh=new Fi(T$,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,b$)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class C$ extends Uy{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof Fs?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=FC.clone(e.uniforms),this.material=new Fs({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 A5(this.material)}render(e,t,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.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 AI extends Uy{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,i){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,o,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class P$ extends Uy{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class R${constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const i=e.getSize(new Be);this._width=i.width,this._height=i.height,t=new uo(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:hf}),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 C$(A$),this.copyPass.material.blending=Ja,this.clock=new T_}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 0.0) { + float sobelValue = combinedSobelValue(); + sobelValue = smoothstep(0.01, .9, sobelValue); + + vec3 watercolor = getWatercolor(vUv); + vec3 lineColor = vec3(0.1, 0.12, 0.2) * watercolor; + + if (sobelValue > 0.1) { + gl_FragColor = vec4(lineColor, 1.0); + } else { + gl_FragColor = vec4(watercolor, 1.0); + } + } else { + gl_FragColor = baseColor; + } + } +`;class D$ extends Fs{constructor(){super({uniforms:{tDiffuse:{value:null},uNormals:{value:null},uResolution:{value:new Be(1,1)}},vertexShader:L$,fragmentShader:I$})}}class O$ extends Uy{constructor(e,t,i,r){super(),this.scene=e,this.camera=t,this.normalMaterial=new $C,this.normalBuffer=new uo(i,r,{format:vs,type:hf,minFilter:Wi,magFilter:Wi,generateMipmaps:!1,stencilBuffer:!1}),this.material=new D$,this.fsQuad=new A5(this.material),this.material.uniforms.uResolution.value=new Be(i,r)}dispose(){this.material.dispose(),this.fsQuad.dispose()}render(e,t,i){e.setRenderTarget(this.normalBuffer);const r=this.scene.overrideMaterial;this.scene.overrideMaterial=this.normalMaterial,e.render(this.scene,this.camera),this.scene.overrideMaterial=r,this.material.uniforms.uNormals.value=this.normalBuffer.texture,this.material.uniforms.tDiffuse.value=i.texture,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.fsQuad.render(e))}}function bI(n,e){if(e===U4)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===rS||e===kC){let t=n.getIndex();if(t===null){const o=[],a=n.getAttribute("position");if(a!==void 0){for(let l=0;l=2.0 are supported."));return}const c=new mee(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,s){i.parse(e,t,r,s)})}}function F$(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const An={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class U${constructor(e){this.parser=e,this.name=An.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Q${constructor(e){this.parser=e,this.name=An.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class $${constructor(e){this.parser=e,this.name=An.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class eee{constructor(e){this.name=An.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=r.byteOffset||0,c=r.byteLength||0,u=r.count,f=r.byteStride,g=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,f,g,r.mode,r.filter).then(function(y){return y.buffer}):o.ready.then(function(){const y=new ArrayBuffer(u*f);return o.decodeGltfBuffer(new Uint8Array(y),u,f,g,r.mode,r.filter),y})})}else return null}}class tee{constructor(e){this.name=An.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const c of r.primitives)if(c.mode!==Uo.TRIANGLES&&c.mode!==Uo.TRIANGLE_STRIP&&c.mode!==Uo.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),f=u.isGroup?u.children:[u],g=c[0].count,y=[];for(const v of f){const w=new Wt,S=new Q,x=new Qr,M=new Q(1,1,1),A=new WC(v.geometry,v.material,g);for(let C=0;C0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const pee=new Wt;class mee{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new F$,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=!1,s=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&s<98?this.textureLoader=new Bz(this.options.manager):this.textureLoader=new Yz(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new fo(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return ph(s,a,r),Nc(a,r),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,s=t.length;r{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())s(u,a.children[c])};return s(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i=2&&S.setY(I,L[F*l+1]),l>=3&&S.setZ(I,L[F*l+2]),l>=4&&S.setW(I,L[F*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return S})}loadTexture(e){const t=this.json,i=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=i.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){const r=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const g=(s.samplers||{})[o.sampler]||{};return u.magFilter=TI[g.magFilter]||Ni,u.minFilter=TI[g.minFilter]||Wo,u.wrapS=CI[g.wrapS]||cu,u.wrapT=CI[g.wrapT]||cu,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const o=r.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=i.getDependency("bufferView",o.bufferView).then(function(f){c=!0;const g=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(g),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(f){return new Promise(function(g,y){let v=g;t.isImageBitmapLoader===!0&&(v=function(w){const S=new hi(w);S.needsUpdate=!0,g(S)}),t.load(iu.resolveURL(f,s.path),v,void 0,y)})}).then(function(f){return c===!0&&a.revokeObjectURL(l),f.userData.mimeType=o.mimeType||dee(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=u,u}assignTexture(e,t,i,r){const s=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),s.extensions[An.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[An.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[An.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new u_,nr.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(a,l)),i=l}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new ts,nr.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(a,l)),i=l}if(r||s||o){let a="ClonedMaterial:"+i.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=i.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return Ny}loadMaterial(e){const t=this,i=this.json,r=this.extensions,s=i.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[An.KHR_MATERIALS_UNLIT]){const f=r[An.KHR_MATERIALS_UNLIT];o=f.getMaterialType(),c.push(f.extendParams(a,s,t))}else{const f=s.pbrMetallicRoughness||{};if(a.color=new ht(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const g=f.baseColorFactor;a.color.setRGB(g[0],g[1],g[2],mr),a.opacity=g[3]}f.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",f.baseColorTexture,hr)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=va);const u=s.alphaMode||mb.OPAQUE;if(u===mb.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===mb.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==ro&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Be(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;a.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&o!==ro&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==ro){const f=s.emissiveFactor;a.emissive=new ht().setRGB(f[0],f[1],f[2],mr)}return s.emissiveTexture!==void 0&&o!==ro&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,hr)),Promise.all(c).then(function(){const f=new o(a);return s.name&&(f.name=s.name),Nc(f,s),t.associations.set(f,{materials:e}),s.extensions&&ph(r,f,s),f})}createUniqueName(e){const t=In.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function s(a){return i[An.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return PI(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&hee(x,s),x.name=t.createUniqueName(s.name||"mesh_"+e),Nc(x,s),S.extensions&&ph(r,x,S),t.assignFinalMaterial(x),f.push(x)}for(let y=0,v=f.length;y1?u=new Xa:c.length===1?u=c[0]:u=new Dn,u!==c[0])for(let f=0,g=c.length;f{const f=new Map;for(const[g,y]of r.associations)(g instanceof nr||g instanceof hi)&&f.set(g,y);return u.traverse(g=>{const y=r.associations.get(g);y!=null&&f.set(g,y)}),f};return r.associations=c(s),s})}_createAnimationTracks(e,t,i,r,s){const o=[],a=e.name?e.name:e.uuid,l=[];Pc[s.path]===Pc.weights?e.traverse(function(g){g.morphTargetInfluences&&l.push(g.name?g.name:g.uuid)}):l.push(a);let c;switch(Pc[s.path]){case Pc.weights:c=nf;break;case Pc.rotation:c=hu;break;case Pc.position:case Pc.scale:c=rf;break;default:switch(i.itemSize){case 1:c=nf;break;case 2:case 3:default:c=rf;break}break}const u=r.interpolation!==void 0?lee[r.interpolation]:$h,f=this._getArrayFromAccessor(i);for(let g=0,y=l.length;g{this.parse(o,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,hr).catch(i)}decodeDracoFile(e,t,i,r,s=mr,o=()=>{}){const a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(yb.has(e)){const l=yb.get(e);if(l.key===i)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(r=l,new Promise((c,u)=>{r._callbacks[s]={resolve:c,reject:u},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),yb.set(e,{key:i,promise:a}),a}_createGeometry(e){const t=new cn;e.index&&t.setIndex(new On(e.index.array,1));for(let i=0;i{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const s=vee.toString(),o=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` +`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const f=u.draco,g=new f.Decoder;try{const y=t(f,g,new Int8Array(l),c),v=y.attributes.map(w=>w.array.buffer);y.index&&v.push(y.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:y},v)}catch(y){console.error(y),self.postMessage({type:"error",id:a.id,error:y.message})}finally{f.destroy(g)}});break}};function t(o,a,l,c){const u=c.attributeIDs,f=c.attributeTypes;let g,y;const v=a.GetEncodedGeometryType(l);if(v===o.TRIANGULAR_MESH)g=new o.Mesh,y=a.DecodeArrayToMesh(l,l.byteLength,g);else if(v===o.POINT_CLOUD)g=new o.PointCloud,y=a.DecodeArrayToPointCloud(l,l.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!y.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());const w={index:null,attributes:[]};for(const S in u){const x=self[f[S]];let M,A;if(c.useUniqueIDs)A=u[S],M=a.GetAttributeByUniqueId(g,A);else{if(A=a.GetAttributeId(g,o[u[S]]),A===-1)continue;M=a.GetAttribute(g,A)}const C=r(o,a,g,S,x,M);S==="color"&&(C.vertexColorSpace=c.vertexColorSpace),w.attributes.push(C)}return v===o.TRIANGULAR_MESH&&(w.index=i(o,a,g)),o.destroy(g),w}function i(o,a,l){const u=l.num_faces()*3,f=u*4,g=o._malloc(f);a.GetTrianglesUInt32Array(l,f,g);const y=new Uint32Array(o.HEAPF32.buffer,g,u).slice();return o._free(g),{array:y,itemSize:1}}function r(o,a,l,c,u,f){const g=f.num_components(),v=l.num_points()*g,w=v*u.BYTES_PER_ELEMENT,S=s(o,u),x=o._malloc(w);a.GetAttributeDataArrayForAllPoints(l,f,S,w,x);const M=new u(o.HEAPF32.buffer,x,v).slice();return o._free(x),{name:c,array:M,itemSize:g}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const xee="/assets/new-a6e72a82.glb",wee=10,P1=4,RI=.002,kI=.005,See=.2,_ee=.2,LI=-.003,II=.003,R1=100,DI=.01,Mee=()=>{const{scene:n}=y5(),e=le.useRef(new Xa),t=le.useMemo(()=>{const s=new yee;return s.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/"),s},[]),i=dP(N$,xee,s=>{s.setDRACOLoader(t)});le.useEffect(()=>{for(let s=0;s{n.remove(e.current)}},[n,i]);const r=()=>{const s=e.current.children;for(let o=0;o{e.current.children.forEach(a=>{a.position.x+=a.userData.speed.x*o*R1,a.position.y+=a.userData.speed.y*o*R1,Math.abs(a.position.x)>P1*2&&(a.userData.speed.x*=-1),Math.abs(a.position.y)>P1&&(a.userData.speed.y*=-1),a.rotation.x+=a.userData.rotationSpeed.x*o*R1,a.rotation.y+=a.userData.rotationSpeed.y*o*R1}),r()}),null},Aee={hidden:{y:"-100vh",transition:{delay:.1,type:"spring",damping:10,stiffness:100}},visible:{y:"0",opacity:1,transition:{type:"spring",damping:10,stiffness:100}}},bee=()=>{const{scene:n,camera:e,gl:t}=y5();return le.useEffect(()=>{const i=new R$(t),r=new k$(n,e),s=new O$(n,e,window.innerWidth,window.innerHeight);i.addPass(r),i.addPass(s);const o=()=>{i.render()};return t.setAnimationLoop(o),()=>{t.setAnimationLoop(null)}},[n,e,t]),null},Eee=({onClick:n,gameState:e,onLeaderboardClick:t})=>{const i=["#fdcdac","#e8b5d6"];return le.useEffect(()=>{const r=a=>{a.preventDefault()},s=()=>{console.log("webgl context restored")},o=document.querySelector("canvas");return o&&(o.addEventListener("webglcontextlost",r),o.addEventListener("webglcontextrestored",s)),()=>{o&&(o.removeEventListener("webglcontextlost",r),o.removeEventListener("webglcontextrestored",s))}},[]),Ke.createElement("div",{className:"relative w-full h-screen"},Ke.createElement(le.Suspense,{fallback:null},Ke.createElement(M$,{className:"fixed top-0 left-0 w-full h-full",style:{zIndex:-1}},Ke.createElement("ambientLight",{intensity:1}),Ke.createElement(Mee,null),Ke.createElement(bee,null))),Ke.createElement(QS.div,{initial:"hidden",animate:"visible",variants:Aee,exit:"hidden",className:"absolute inset-0 flex justify-center items-center"},Ke.createElement("div",{className:"relative z-10 flex flex-col items-center px-8 pb-8",style:{marginTop:"20vh"}},Ke.createElement("h1",{className:"text-6xl sm:text-7xl mb-4 font-extrabold tracking-tight text-slate-900 text-center"},"Dueling Doodles!"),Ke.createElement("h2",{className:"text-2xl mb-10 font-semibold text-slate-900 text-center",style:{fontSize:"min(3vw, 3vh)"}},"Benchmarking Lightweight Computer Vision Models through Sketch Recognition"),Ke.createElement("button",{onClick:n,disabled:e!=="menu",type:"button",style:{backgroundColor:i[0]},className:`text-md inline-flex items-center leading-5 shadow rounded-md text-[#555555] hover:opacity-80 transition ease-in-out duration-150 px-6 py-4 ${e==="loading"?"cursor-not-allowed":""}`},e==="loading"?Ke.createElement(Ke.Fragment,null,Ke.createElement("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},Ke.createElement("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ke.createElement("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})),"Loading neural network..."):"Play Game"),Ke.createElement("button",{onClick:t,type:"button",style:{backgroundColor:i[1]},className:"text-md inline-flex items-center leading-6 shadow rounded-md text-[#555555] hover:opacity-80 transition ease-in-out duration-150 px-6 py-4 mt-4"},"Leaderboard"))))},Tee={hidden:{y:"-100vh",transition:{delay:.1,type:"spring",damping:10,stiffness:100}},visible:{y:"0",opacity:1,transition:{type:"spring",damping:10,stiffness:100}}};function Cee(n){const e=document.createElement("canvas"),t=e.getContext("2d");return e.width=n.width,e.height=n.height,t.putImageData(n,0,0),e.toDataURL()}const Pee=({predictions:n,onClick:e})=>Ke.createElement(QS.div,{initial:"hidden",animate:"visible",variants:Tee,exit:"hidden",className:"absolute w-full h-full flex justify-center items-center flex-col px-8 text-center"},Ke.createElement("h1",{className:"sm:text-7xl text-6xl mb-3 font-bold tracking-tight text-slate-900 text-center"},"Game Over!"),Ke.createElement("h2",{className:"mb-4 sm:text-2xl text-xl font-semibold text-slate-900"},"Score: ",n.filter(t=>t.correct).length," / ",n.length),Ke.createElement("div",{className:"max-w-full overflow-x-auto flex gap-4 px-8 p-4 rounded-lg shadow-[0_5px_25px_-5px_rgb(0,0,0,0.1),_0_8px_10px_-6px_rgb(0,0,0,0.1);]"},n.map((t,i)=>Ke.createElement("div",{key:i,className:"flex justify-center items-center w-full flex-col"},Ke.createElement("img",{className:"max-h-[12rem] min-w-[12rem]",src:t.image?Cee(t.image):""}),Ke.createElement("p",{className:"text-slate-900 text-lg font-semibold mt-2"},t.target," ",t.correct?"✅":"❌"),t.correct&&t.output1&&t.output1.label===t.target&&Ke.createElement("p",{className:"text-slate-600 text-base mt-1"},"Predicted by: ",t.model1Name),t.correct&&t.output2&&t.output2.label===t.target&&Ke.createElement("p",{className:"text-slate-600 text-base mt-1"},"Predicted by: ",t.model2Name)))),Ke.createElement("div",{className:"flex mt-6 gap-4"},Ke.createElement("button",{onClick:()=>e(!0),type:"button",className:"inline-flex items-center px-4 py-2 font-semibold leading-6 shadow rounded-md text-[#555555]",style:{backgroundColor:"#ff9980"}},"Play Again"),Ke.createElement("button",{onClick:()=>e(!1),type:"button",className:"inline-flex items-center px-4 py-2 font-semibold leading-6 shadow rounded-md text-[#555555]",style:{backgroundColor:"#fffb91"}},"Main Menu"))),Ree={hidden:{y:"100vh",transition:{delay:.1,type:"spring",damping:10,stiffness:100}},visible:{y:"0",opacity:1,transition:{type:"spring",damping:10,stiffness:100}},exit:{scale:8,opacity:0,transition:{duration:1,type:"ease-out"}}},kee=({countdown:n})=>Ke.createElement(QS.div,{initial:"hidden",animate:"visible",variants:Ree,exit:"exit",className:"pointer-events-none absolute w-full h-full flex justify-center items-center text-[#555555]"},Ke.createElement("h1",{style:{transform:"translateY(-0.8rem)"},className:"text-9xl"},n>0?n:"Draw!"));function fw(n,e){return n==null||e==null?NaN:ne?1:n>=e?0:NaN}function Lee(n,e){return n==null||e==null?NaN:en?1:e>=n?0:NaN}function T5(n){let e,t,i;n.length!==2?(e=fw,t=(a,l)=>fw(n(a),l),i=(a,l)=>n(a)-l):(e=n===fw||n===Lee?n:Iee,t=n,i=n);function r(a,l,c=0,u=a.length){if(c>>1;t(a[f],l)<0?c=f+1:u=f}while(c>>1;t(a[f],l)<=0?c=f+1:u=f}while(cc&&i(a[f-1],l)>-i(a[f],l)?f-1:f}return{left:r,center:o,right:s}}function Iee(){return 0}function Dee(n){return n===null?NaN:+n}const Oee=T5(fw),Nee=Oee.right;T5(Dee).center;const Fee=Nee;class OI extends Map{constructor(e,t=Bee){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[i,r]of e)this.set(i,r)}get(e){return super.get(NI(this,e))}has(e){return super.has(NI(this,e))}set(e,t){return super.set(Uee(this,e),t)}delete(e){return super.delete(zee(this,e))}}function NI({_intern:n,_key:e},t){const i=e(t);return n.has(i)?n.get(i):t}function Uee({_intern:n,_key:e},t){const i=e(t);return n.has(i)?n.get(i):(n.set(i,t),t)}function zee({_intern:n,_key:e},t){const i=e(t);return n.has(i)&&(t=n.get(i),n.delete(i)),t}function Bee(n){return n!==null&&typeof n=="object"?n.valueOf():n}const Vee=Math.sqrt(50),Hee=Math.sqrt(10),Gee=Math.sqrt(2);function uS(n,e,t){const i=(e-n)/Math.max(0,t),r=Math.floor(Math.log10(i)),s=i/Math.pow(10,r),o=s>=Vee?10:s>=Hee?5:s>=Gee?2:1;let a,l,c;return r<0?(c=Math.pow(10,-r)/o,a=Math.round(n*c),l=Math.round(e*c),a/ce&&--l,c=-c):(c=Math.pow(10,r)*o,a=Math.round(n/c),l=Math.round(e/c),a*ce&&--l),l0))return[];if(n===e)return[n];const i=e=r))return[];const a=s-r+1,l=new Array(a);if(i)if(o<0)for(let c=0;c{}};function mP(){for(var n=0,e=arguments.length,t={},i;n=0&&(i=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}dw.prototype=mP.prototype={constructor:dw,on:function(n,e){var t=this._,i=qee(n+"",t),r,s=-1,o=i.length;if(arguments.length<2){for(;++s0)for(var t=new Array(r),i=0,r,s;i=0&&(e=n.slice(0,t))!=="xmlns"&&(n=n.slice(t+1)),UI.hasOwnProperty(e)?{space:UI[e],local:n}:n}function Kee(n){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===NT&&e.documentElement.namespaceURI===NT?e.createElement(n):e.createElementNS(t,n)}}function Zee(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function C5(n){var e=C_(n);return(e.local?Zee:Kee)(e)}function Jee(){}function gP(n){return n==null?Jee:function(){return this.querySelector(n)}}function Qee(n){typeof n!="function"&&(n=gP(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r=A&&(A=M+1);!(N=S[A])&&++A=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Mte(n){n||(n=Ate);function e(f,g){return f&&g?n(f.__data__,g.__data__):!f-!g}for(var t=this._groups,i=t.length,r=new Array(i),s=0;se?1:n>=e?0:NaN}function bte(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function Ete(){return Array.from(this)}function Tte(){for(var n=this._groups,e=0,t=n.length;e1?this.each((e==null?Ute:typeof e=="function"?Bte:zte)(n,e,t??"")):nm(this.node(),n)}function nm(n,e){return n.style.getPropertyValue(e)||I5(n).getComputedStyle(n,null).getPropertyValue(e)}function Hte(n){return function(){delete this[n]}}function Gte(n,e){return function(){this[n]=e}}function Wte(n,e){return function(){var t=e.apply(this,arguments);t==null?delete this[n]:this[n]=t}}function jte(n,e){return arguments.length>1?this.each((e==null?Hte:typeof e=="function"?Wte:Gte)(n,e)):this.node()[n]}function D5(n){return n.trim().split(/^|\s+/)}function yP(n){return n.classList||new O5(n)}function O5(n){this._node=n,this._names=D5(n.getAttribute("class")||"")}O5.prototype={add:function(n){var e=this._names.indexOf(n);e<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var e=this._names.indexOf(n);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function N5(n,e){for(var t=yP(n),i=-1,r=e.length;++i=0&&(t=e.slice(i+1),e=e.slice(0,i)),{type:e,name:t}})}function xne(n){return function(){var e=this.__on;if(e){for(var t=0,i=-1,r=e.length,s;t>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?k1(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?k1(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Pne.exec(n))?new Ls(e[1],e[2],e[3],1):(e=Rne.exec(n))?new Ls(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=kne.exec(n))?k1(e[1],e[2],e[3],e[4]):(e=Lne.exec(n))?k1(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Ine.exec(n))?jI(e[1],e[2]/100,e[3]/100,1):(e=Dne.exec(n))?jI(e[1],e[2]/100,e[3]/100,e[4]):zI.hasOwnProperty(n)?HI(zI[n]):n==="transparent"?new Ls(NaN,NaN,NaN,0):null}function HI(n){return new Ls(n>>16&255,n>>8&255,n&255,1)}function k1(n,e,t,i){return i<=0&&(n=e=t=NaN),new Ls(n,e,t,i)}function Fne(n){return n instanceof By||(n=sf(n)),n?(n=n.rgb(),new Ls(n.r,n.g,n.b,n.opacity)):new Ls}function FT(n,e,t,i){return arguments.length===1?Fne(n):new Ls(n,e,t,i??1)}function Ls(n,e,t,i){this.r=+n,this.g=+e,this.b=+t,this.opacity=+i}vP(Ls,FT,B5(By,{brighter(n){return n=n==null?fS:Math.pow(fS,n),new Ls(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?ly:Math.pow(ly,n),new Ls(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new Ls(Xh(this.r),Xh(this.g),Xh(this.b),dS(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:GI,formatHex:GI,formatHex8:Une,formatRgb:WI,toString:WI}));function GI(){return`#${Uh(this.r)}${Uh(this.g)}${Uh(this.b)}`}function Une(){return`#${Uh(this.r)}${Uh(this.g)}${Uh(this.b)}${Uh((isNaN(this.opacity)?1:this.opacity)*255)}`}function WI(){const n=dS(this.opacity);return`${n===1?"rgb(":"rgba("}${Xh(this.r)}, ${Xh(this.g)}, ${Xh(this.b)}${n===1?")":`, ${n})`}`}function dS(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function Xh(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function Uh(n){return n=Xh(n),(n<16?"0":"")+n.toString(16)}function jI(n,e,t,i){return i<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new xa(n,e,t,i)}function V5(n){if(n instanceof xa)return new xa(n.h,n.s,n.l,n.opacity);if(n instanceof By||(n=sf(n)),!n)return new xa;if(n instanceof xa)return n;n=n.rgb();var e=n.r/255,t=n.g/255,i=n.b/255,r=Math.min(e,t,i),s=Math.max(e,t,i),o=NaN,a=s-r,l=(s+r)/2;return a?(e===s?o=(t-i)/a+(t0&&l<1?0:o,new xa(o,a,l,n.opacity)}function zne(n,e,t,i){return arguments.length===1?V5(n):new xa(n,e,t,i??1)}function xa(n,e,t,i){this.h=+n,this.s=+e,this.l=+t,this.opacity=+i}vP(xa,zne,B5(By,{brighter(n){return n=n==null?fS:Math.pow(fS,n),new xa(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?ly:Math.pow(ly,n),new xa(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,i=t+(t<.5?t:1-t)*e,r=2*t-i;return new Ls(vb(n>=240?n-240:n+120,r,i),vb(n,r,i),vb(n<120?n+240:n-120,r,i),this.opacity)},clamp(){return new xa(XI(this.h),L1(this.s),L1(this.l),dS(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=dS(this.opacity);return`${n===1?"hsl(":"hsla("}${XI(this.h)}, ${L1(this.s)*100}%, ${L1(this.l)*100}%${n===1?")":`, ${n})`}`}}));function XI(n){return n=(n||0)%360,n<0?n+360:n}function L1(n){return Math.max(0,Math.min(1,n||0))}function vb(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const xP=n=>()=>n;function Bne(n,e){return function(t){return n+t*e}}function Vne(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(i){return Math.pow(n+i*e,t)}}function Hne(n){return(n=+n)==1?H5:function(e,t){return t-e?Vne(e,t,n):xP(isNaN(e)?t:e)}}function H5(n,e){var t=e-n;return t?Bne(n,t):xP(isNaN(n)?e:n)}const pS=function n(e){var t=Hne(e);function i(r,s){var o=t((r=FT(r)).r,(s=FT(s)).r),a=t(r.g,s.g),l=t(r.b,s.b),c=H5(r.opacity,s.opacity);return function(u){return r.r=o(u),r.g=a(u),r.b=l(u),r.opacity=c(u),r+""}}return i.gamma=n,i}(1);function Gne(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,i=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:ya(i,r)})),t=xb.lastIndex;return t180?u+=360:u-c>180&&(c+=360),g.push({i:f.push(r(f)+"rotate(",null,i)-2,x:ya(c,u)})):u&&f.push(r(f)+"rotate("+u+i)}function a(c,u,f,g){c!==u?g.push({i:f.push(r(f)+"skewX(",null,i)-2,x:ya(c,u)}):u&&f.push(r(f)+"skewX("+u+i)}function l(c,u,f,g,y,v){if(c!==f||u!==g){var w=y.push(r(y)+"scale(",null,",",null,")");v.push({i:w-4,x:ya(c,f)},{i:w-2,x:ya(u,g)})}else(f!==1||g!==1)&&y.push(r(y)+"scale("+f+","+g+")")}return function(c,u){var f=[],g=[];return c=n(c),u=n(u),s(c.translateX,c.translateY,u.translateX,u.translateY,f,g),o(c.rotate,u.rotate,f,g),a(c.skewX,u.skewX,f,g),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,g),c=u=null,function(y){for(var v=-1,w=g.length,S;++v=0&&n._call.call(void 0,e),n=n._next;--im}function YI(){of=(gS=uy.now())+P_,im=n0=0;try{nie()}finally{im=0,rie(),of=0}}function iie(){var n=uy.now(),e=n-gS;e>X5&&(P_-=e,gS=n)}function rie(){for(var n,e=mS,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:mS=t);i0=n,BT(i)}function BT(n){if(!im){n0&&(n0=clearTimeout(n0));var e=n-of;e>24?(n<1/0&&(n0=setTimeout(YI,n-uy.now()-P_)),Gg&&(Gg=clearInterval(Gg))):(Gg||(gS=uy.now(),Gg=setInterval(iie,X5)),im=1,q5(YI))}}function KI(n,e,t){var i=new yS;return e=e==null?0:+e,i.restart(r=>{i.stop(),n(r+e)},e,t),i}var sie=mP("start","end","cancel","interrupt"),oie=[],Y5=0,ZI=1,VT=2,pw=3,JI=4,HT=5,mw=6;function R_(n,e,t,i,r,s){var o=n.__transition;if(!o)n.__transition={};else if(t in o)return;aie(n,t,{name:e,index:i,group:r,on:sie,tween:oie,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Y5})}function MP(n,e){var t=Ea(n,e);if(t.state>Y5)throw new Error("too late; already scheduled");return t}function sl(n,e){var t=Ea(n,e);if(t.state>pw)throw new Error("too late; already running");return t}function Ea(n,e){var t=n.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function aie(n,e,t){var i=n.__transition,r;i[e]=t,t.timer=_P(s,0,t.time);function s(c){t.state=ZI,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,f,g,y;if(t.state!==ZI)return l();for(u in i)if(y=i[u],y.name===t.name){if(y.state===pw)return KI(o);y.state===JI?(y.state=mw,y.timer.stop(),y.on.call("interrupt",n,n.__data__,y.index,y.group),delete i[u]):+uVT&&i.state=0&&(e=e.slice(0,t)),!e||e==="start"})}function Uie(n,e,t){var i,r,s=Fie(e)?MP:sl;return function(){var o=s(this,n),a=o.on;a!==i&&(r=(i=a).copy()).on(e,t),o.on=r}}function zie(n,e){var t=this._id;return arguments.length<2?Ea(this.node(),t).on.on(n):this.each(Uie(t,n,e))}function Bie(n){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==n)return;e&&e.removeChild(this)}}function Vie(){return this.on("end.remove",Bie(this._id))}function Hie(n){var e=this._name,t=this._id;typeof n!="function"&&(n=gP(n));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o=(f=(a+c)/2))?a=f:c=f,(S=t>=(g=(l+u)/2))?l=g:u=g,r=s,!(s=s[x=S<<1|w]))return r[x]=o,n;if(y=+n._x.call(null,s.data),v=+n._y.call(null,s.data),e===y&&t===v)return o.next=s,r?r[x]=o:n._root=o,n;do r=r?r[x]=new Array(4):n._root=new Array(4),(w=e>=(f=(a+c)/2))?a=f:c=f,(S=t>=(g=(l+u)/2))?l=g:u=g;while((x=S<<1|w)===(M=(v>=g)<<1|y>=f));return r[M]=s,r[x]=o,n}function mre(n){var e,t,i=n.length,r,s,o=new Array(i),a=new Array(i),l=1/0,c=1/0,u=-1/0,f=-1/0;for(t=0;tu&&(u=r),sf&&(f=s));if(l>u||c>f)return this;for(this.cover(l,c).cover(u,f),t=0;tn||n>=r||i>e||e>=s;)switch(c=(eu||(a=v.y0)>f||(l=v.x1)=x)<<1|n>=S)&&(v=g[g.length-1],g[g.length-1]=g[g.length-1-w],g[g.length-1-w]=v)}else{var M=n-+this._x.call(null,y.data),A=e-+this._y.call(null,y.data),C=M*M+A*A;if(C=(g=(o+l)/2))?o=g:l=g,(w=f>=(y=(a+c)/2))?a=y:c=y,e=t,!(t=t[S=w<<1|v]))return this;if(!t.length)break;(e[S+1&3]||e[S+2&3]||e[S+3&3])&&(i=e,x=S)}for(;t.data!==n;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[S]=s:delete e[S],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(i?i[x]=t:this._root=t),this):(this._root=s,this)}function Sre(n){for(var e=0,t=n.length;eg.index){var W=y-H.x-H.vx,se=v-H.y-H.vy,Z=W*W+se*se;Zy+R||Lv+R||Fc.r&&(c.r=c[u].r)}function l(){if(e){var c,u=e.length,f;for(t=new Array(u),c=0;c(n=(Ire*n+Dre)%eD)/eD}var Nre=10,Fre=Math.PI*(3-Math.sqrt(5));function Ure(n){var e,t=1,i=.001,r=1-Math.pow(i,1/300),s=0,o=.6,a=new Map,l=_P(f),c=mP("tick","end"),u=Ore();n==null&&(n=[]);function f(){g(),c.call("tick",e),t1?(S==null?a.delete(w):a.set(w,v(S)),e):a.get(w)},find:function(w,S,x){var M=0,A=n.length,C,N,L,F,H;for(x==null?x=1/0:x*=x,M=0;M1?(c.on(w,S),e):c.on(w)}}}function zre(n){var e=qa(.1),t,i,r;typeof n!="function"&&(n=qa(n==null?0:+n));function s(a){for(var l=0,c=t.length,u;l=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function vS(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,i=n.slice(0,t);return[i.length>1?i[0]+i.slice(2):i,+n.slice(t+1)]}function rm(n){return n=vS(Math.abs(n)),n?n[1]:NaN}function Hre(n,e){return function(t,i){for(var r=t.length,s=[],o=0,a=n[0],l=0;r>0&&a>0&&(l+a+1>i&&(a=Math.max(1,i-l)),s.push(t.substring(r-=a,r+a)),!((l+=a+1)>i));)a=n[o=(o+1)%n.length];return s.reverse().join(e)}}function Gre(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var Wre=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function xS(n){if(!(e=Wre.exec(n)))throw new Error("invalid format: "+n);var e;return new EP({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}xS.prototype=EP.prototype;function EP(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}EP.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function jre(n){e:for(var e=n.length,t=1,i=-1,r;t0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(r+1):n}var eB;function Xre(n,e){var t=vS(n,e);if(!t)return n+"";var i=t[0],r=t[1],s=r-(eB=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+vS(n,Math.max(0,e+s-1))[0]}function tD(n,e){var t=vS(n,e);if(!t)return n+"";var i=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const nD={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:Vre,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>tD(n*100,e),r:tD,s:Xre,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function iD(n){return n}var rD=Array.prototype.map,sD=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function qre(n){var e=n.grouping===void 0||n.thousands===void 0?iD:Hre(rD.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",r=n.decimal===void 0?".":n.decimal+"",s=n.numerals===void 0?iD:Gre(rD.call(n.numerals,String)),o=n.percent===void 0?"%":n.percent+"",a=n.minus===void 0?"−":n.minus+"",l=n.nan===void 0?"NaN":n.nan+"";function c(f){f=xS(f);var g=f.fill,y=f.align,v=f.sign,w=f.symbol,S=f.zero,x=f.width,M=f.comma,A=f.precision,C=f.trim,N=f.type;N==="n"?(M=!0,N="g"):nD[N]||(A===void 0&&(A=12),C=!0,N="g"),(S||g==="0"&&y==="=")&&(S=!0,g="0",y="=");var L=w==="$"?t:w==="#"&&/[boxX]/.test(N)?"0"+N.toLowerCase():"",F=w==="$"?i:/[%p]/.test(N)?o:"",H=nD[N],I=/[defgprs%]/.test(N);A=A===void 0?6:/[gprs]/.test(N)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function R(W){var se=L,Z=F,oe,fe,Se;if(N==="c")Z=H(W)+Z,W="";else{W=+W;var Fe=W<0||1/W<0;if(W=isNaN(W)?l:H(Math.abs(W),A),C&&(W=jre(W)),Fe&&+W==0&&v!=="+"&&(Fe=!1),se=(Fe?v==="("?v:a:v==="-"||v==="("?"":v)+se,Z=(N==="s"?sD[8+eB/3]:"")+Z+(Fe&&v==="("?")":""),I){for(oe=-1,fe=W.length;++oeSe||Se>57){Z=(Se===46?r+W.slice(oe+1):W.slice(oe))+Z,W=W.slice(0,oe);break}}}M&&!S&&(W=e(W,1/0));var X=se.length+W.length+Z.length,ie=X>1)+se+W+Z+ie.slice(X);break;default:W=ie+se+W+Z;break}return s(W)}return R.toString=function(){return f+""},R}function u(f,g){var y=c((f=xS(f),f.type="f",f)),v=Math.max(-8,Math.min(8,Math.floor(rm(g)/3)))*3,w=Math.pow(10,-v),S=sD[8+v/3];return function(x){return y(w*x)+S}}return{format:c,formatPrefix:u}}var D1,tB,nB;Yre({thousands:",",grouping:[3],currency:["$",""]});function Yre(n){return D1=qre(n),tB=D1.format,nB=D1.formatPrefix,D1}function Kre(n){return Math.max(0,-rm(Math.abs(n)))}function Zre(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(rm(e)/3)))*3-rm(Math.abs(n)))}function Jre(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,rm(e)-rm(n))+1}function iB(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}const oD=Symbol("implicit");function GT(){var n=new OI,e=[],t=[],i=oD;function r(s){let o=n.get(s);if(o===void 0){if(i!==oD)return i;n.set(s,o=e.push(s)-1)}return t[o%t.length]}return r.domain=function(s){if(!arguments.length)return e.slice();e=[],n=new OI;for(const o of s)n.has(o)||n.set(o,e.push(o)-1);return r},r.range=function(s){return arguments.length?(t=Array.from(s),r):t.slice()},r.unknown=function(s){return arguments.length?(i=s,r):i},r.copy=function(){return GT(e,t).unknown(i)},iB.apply(r,arguments),r}function Qre(n){return function(){return n}}function $re(n){return+n}var aD=[0,1];function jc(n){return n}function WT(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:Qre(isNaN(e)?NaN:.5)}function ese(n,e){var t;return n>e&&(t=n,n=e,e=t),function(i){return Math.max(n,Math.min(e,i))}}function tse(n,e,t){var i=n[0],r=n[1],s=e[0],o=e[1];return r2?nse:tse,l=c=null,f}function f(g){return g==null||isNaN(g=+g)?s:(l||(l=a(n.map(i),e,t)))(i(o(g)))}return f.invert=function(g){return o(r((c||(c=a(e,n.map(i),ya)))(g)))},f.domain=function(g){return arguments.length?(n=Array.from(g,$re),u()):n.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),u()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),t=Zne,u()},f.clamp=function(g){return arguments.length?(o=g?!0:jc,u()):o!==jc},f.interpolate=function(g){return arguments.length?(t=g,u()):t},f.unknown=function(g){return arguments.length?(s=g,f):s},function(g,y){return i=g,r=y,u()}}function sse(n,e,t,i){var r=jee(n,e,t),s;switch(i=xS(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(n),Math.abs(e));return i.precision==null&&!isNaN(s=Zre(r,o))&&(i.precision=s),nB(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=Jre(r,Math.max(Math.abs(n),Math.abs(e))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=Kre(r))&&(i.precision=s-(i.type==="%")*2);break}}return tB(i)}function ose(n){var e=n.domain;return n.ticks=function(t){var i=e();return Wee(i[0],i[i.length-1],t??10)},n.tickFormat=function(t,i){var r=e();return sse(r[0],r[r.length-1],t??10,i)},n.nice=function(t){t==null&&(t=10);var i=e(),r=0,s=i.length-1,o=i[r],a=i[s],l,c,u=10;for(a0;){if(c=OT(o,a,t),c===l)return i[r]=o,i[s]=a,e(i);if(c>0)o=Math.floor(o/c)*c,a=Math.ceil(a/c)*c;else if(c<0)o=Math.ceil(o*c)/c,a=Math.floor(a*c)/c;else break;l=c}return n},n}function lD(n){return function(e){return e<0?-Math.pow(-e,n):Math.pow(e,n)}}function ase(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function lse(n){return n<0?-n*n:n*n}function cse(n){var e=n(jc,jc),t=1;function i(){return t===1?n(jc,jc):t===.5?n(ase,lse):n(lD(t),lD(1/t))}return e.exponent=function(r){return arguments.length?(t=+r,i()):t},ose(e)}function rB(){var n=cse(rse());return n.copy=function(){return ise(n,rB()).exponent(n.exponent())},iB.apply(n,arguments),n}function use(){return rB.apply(null,arguments).exponent(.5)}function sB(n){for(var e=n.length/6|0,t=new Array(e),i=0;i{const t=le.useRef(null),[i,r]=le.useState(null);return le.useEffect(()=>{if(!n||n.length===0)return;const s=window.innerWidth/4,o=window.innerHeight,a=Math.min(s,o),l=window.innerWidth<=768?[3,90]:[a*.025,a*.4],c=window.innerWidth<=768?1e-4:.005,u=Tne(t.current).attr("width",s).attr("height",o).style("background","white"),f=use().domain([0,1]).range(l),g=GT(e===1?hse:fse);i&&(i.stop(),u.selectAll("*").remove());const y=Ure(n).force("x",zre(s/2).strength(.01)).force("y",Bre(o/2).strength(c)).force("collide",Lre().radius(w=>f(w.score)).strength(.7)).force("center",dre(s/2,o/2)).on("tick",()=>{v.attr("transform",w=>{const S=f(w.score);return w.x=Math.max(S,Math.min(s-S,w.x)),w.y=Math.max(S,Math.min(o-S,w.y)),`translate(${w.x}, ${w.y})`})});r(y);const v=u.selectAll("g").data(n).enter().append("g").attr("transform",`translate(${s/2}, ${o/2})`);return v.append("circle").attr("r",w=>f(w.score)).style("fill",(w,S)=>g(S)).style("fill-opacity",1).attr("stroke","#69a2b2").style("stroke-width",2),v.filter((w,S)=>S<10).append("text").text(w=>w.label).style("text-anchor","middle").style("alignment-baseline","middle").style("font-size",w=>{const S=f(w.score),x=w.label.length;return`${Math.min(S,S/(x/3))}px`}).style("fill","#36454F"),()=>{y.stop(),u.selectAll("*").remove()}},[n]),Ke.createElement("svg",{ref:t,className:"object-none w-full h-full",width:window.innerWidth/4,height:window.innerHeight})},dse={black:"#000",white:"#fff"},hy=dse,pse={50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",A100:"#ff8a80",A200:"#ff5252",A400:"#ff1744",A700:"#d50000"},Yd=pse,mse={50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c",A100:"#ea80fc",A200:"#e040fb",A400:"#d500f9",A700:"#aa00ff"},Kd=mse,gse={50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",A100:"#82b1ff",A200:"#448aff",A400:"#2979ff",A700:"#2962ff"},Zd=gse,yse={50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b",A100:"#80d8ff",A200:"#40c4ff",A400:"#00b0ff",A700:"#0091ea"},Jd=yse,vse={50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",A100:"#b9f6ca",A200:"#69f0ae",A400:"#00e676",A700:"#00c853"},Qd=vse,xse={50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",A100:"#ffd180",A200:"#ffab40",A400:"#ff9100",A700:"#ff6d00"},Wg=xse,wse={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},Sse=wse;function fy(n){let e="https://mui.com/production-error/?code="+n;for(let t=1;t=0)continue;t[i]=n[i]}return t}function Mse(n){var e=Object.create(null);return function(t){return e[t]===void 0&&(e[t]=n(t)),e[t]}}var Ase=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,bse=Mse(function(n){return Ase.test(n)||n.charCodeAt(0)===111&&n.charCodeAt(1)===110&&n.charCodeAt(2)<91});function Ese(n){if(n.sheet)return n.sheet;for(var e=0;e0?Nr(vm,--Us):0,sm--,er===10&&(sm=1,L_--),er}function ao(){return er=Us2||py(er)>3?"":" "}function zse(n,e){for(;--e&&ao()&&!(er<48||er>102||er>57&&er<65||er>70&&er<97););return Vy(n,gw()+(e<6&&tl()==32&&ao()==32))}function XT(n){for(;ao();)switch(er){case n:return Us;case 34:case 39:n!==34&&n!==39&&XT(er);break;case 40:n===41&&XT(n);break;case 92:ao();break}return Us}function Bse(n,e){for(;ao()&&n+er!==47+10;)if(n+er===42+42&&tl()===47)break;return"/*"+Vy(e,Us-1)+"*"+k_(n===47?n:ao())}function Vse(n){for(;!py(tl());)ao();return Vy(n,Us)}function Hse(n){return hB(vw("",null,null,null,[""],n=uB(n),0,[0],n))}function vw(n,e,t,i,r,s,o,a,l){for(var c=0,u=0,f=o,g=0,y=0,v=0,w=1,S=1,x=1,M=0,A="",C=r,N=s,L=i,F=A;S;)switch(v=M,M=ao()){case 40:if(v!=108&&Nr(F,f-1)==58){jT(F+=Bn(yw(M),"&","&\f"),"&\f")!=-1&&(x=-1);break}case 34:case 39:case 91:F+=yw(M);break;case 9:case 10:case 13:case 32:F+=Use(v);break;case 92:F+=zse(gw()-1,7);continue;case 47:switch(tl()){case 42:case 47:O1(Gse(Bse(ao(),gw()),e,t),l);break;default:F+="/"}break;case 123*w:a[c++]=Ha(F)*x;case 125*w:case 59:case 0:switch(M){case 0:case 125:S=0;case 59+u:x==-1&&(F=Bn(F,/\f/g,"")),y>0&&Ha(F)-f&&O1(y>32?hD(F+";",i,t,f-1):hD(Bn(F," ","")+";",i,t,f-2),l);break;case 59:F+=";";default:if(O1(L=uD(F,e,t,c,u,r,a,A,C=[],N=[],f),s),M===123)if(u===0)vw(F,e,L,L,C,s,f,a,N);else switch(g===99&&Nr(F,3)===110?100:g){case 100:case 108:case 109:case 115:vw(n,L,L,i&&O1(uD(n,L,L,0,0,r,a,A,r,C=[],f),N),r,N,f,a,i?C:N);break;default:vw(F,L,L,L,[""],N,0,a,N)}}c=u=y=0,w=x=1,A=F="",f=o;break;case 58:f=1+Ha(F),y=v;default:if(w<1){if(M==123)--w;else if(M==125&&w++==0&&Fse()==125)continue}switch(F+=k_(M),M*w){case 38:x=u>0?1:(F+="\f",-1);break;case 44:a[c++]=(Ha(F)-1)*x,x=1;break;case 64:tl()===45&&(F+=yw(ao())),g=tl(),u=f=Ha(A=F+=Vse(gw())),M++;break;case 45:v===45&&Ha(F)==2&&(w=0)}}return s}function uD(n,e,t,i,r,s,o,a,l,c,u){for(var f=r-1,g=r===0?s:[""],y=RP(g),v=0,w=0,S=0;v0?g[x]+" "+M:Bn(M,/&\f/g,g[x])))&&(l[S++]=A);return I_(n,e,t,r===0?CP:a,l,c,u)}function Gse(n,e,t){return I_(n,e,t,oB,k_(Nse()),dy(n,2,-2),0)}function hD(n,e,t,i){return I_(n,e,t,PP,dy(n,0,i),dy(n,i+1,-1),i)}function Up(n,e){for(var t="",i=RP(n),r=0;r6)switch(Nr(n,e+1)){case 109:if(Nr(n,e+4)!==45)break;case 102:return Bn(n,/(.+:)(.+)-([^]+)/,"$1"+zn+"$2-$3$1"+wS+(Nr(n,e+3)==108?"$3":"$2-$3"))+n;case 115:return~jT(n,"stretch")?fB(Bn(n,"stretch","fill-available"),e)+n:n}break;case 4949:if(Nr(n,e+1)!==115)break;case 6444:switch(Nr(n,Ha(n)-3-(~jT(n,"!important")&&10))){case 107:return Bn(n,":",":"+zn)+n;case 101:return Bn(n,/(.+:)([^;!]+)(;|!.+)?/,"$1"+zn+(Nr(n,14)===45?"inline-":"")+"box$3$1"+zn+"$2$3$1"+Kr+"$2box$3")+n}break;case 5936:switch(Nr(n,e+11)){case 114:return zn+n+Kr+Bn(n,/[svh]\w+-[tblr]{2}/,"tb")+n;case 108:return zn+n+Kr+Bn(n,/[svh]\w+-[tblr]{2}/,"tb-rl")+n;case 45:return zn+n+Kr+Bn(n,/[svh]\w+-[tblr]{2}/,"lr")+n}return zn+n+Kr+n+n}return n}var Qse=function(e,t,i,r){if(e.length>-1&&!e.return)switch(e.type){case PP:e.return=fB(e.value,e.length);break;case aB:return Up([jg(e,{value:Bn(e.value,"@","@"+zn)})],r);case CP:if(e.length)return Ose(e.props,function(s){switch(Dse(s,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Up([jg(e,{props:[Bn(s,/:(read-\w+)/,":"+wS+"$1")]})],r);case"::placeholder":return Up([jg(e,{props:[Bn(s,/:(plac\w+)/,":"+zn+"input-$1")]}),jg(e,{props:[Bn(s,/:(plac\w+)/,":"+wS+"$1")]}),jg(e,{props:[Bn(s,/:(plac\w+)/,Kr+"input-$1")]})],r)}return""})}},$se=[Qse],dB=function(e){var t=e.key;if(t==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(w){var S=w.getAttribute("data-emotion");S.indexOf(" ")!==-1&&(document.head.appendChild(w),w.setAttribute("data-s",""))})}var r=e.stylisPlugins||$se,s={},o,a=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(w){for(var S=w.getAttribute("data-emotion").split(" "),x=1;x=4;++i,r-=4)t=n.charCodeAt(i)&255|(n.charCodeAt(++i)&255)<<8|(n.charCodeAt(++i)&255)<<16|(n.charCodeAt(++i)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,e=(t&65535)*1540483477+((t>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(r){case 3:e^=(n.charCodeAt(i+2)&255)<<16;case 2:e^=(n.charCodeAt(i+1)&255)<<8;case 1:e^=n.charCodeAt(i)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var hoe={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function foe(n){var e=Object.create(null);return function(t){return e[t]===void 0&&(e[t]=n(t)),e[t]}}var doe=/[A-Z]|^ms/g,poe=/_EMO_([^_]+?)_([^]*?)_EMO_/g,wB=function(e){return e.charCodeAt(1)===45},dD=function(e){return e!=null&&typeof e!="boolean"},wb=foe(function(n){return wB(n)?n:n.replace(doe,"-$&").toLowerCase()}),pD=function(e,t){switch(e){case"animation":case"animationName":if(typeof t=="string")return t.replace(poe,function(i,r,s){return Ga={name:r,styles:s,next:Ga},r})}return hoe[e]!==1&&!wB(e)&&typeof t=="number"&&t!==0?t+"px":t};function my(n,e,t){if(t==null)return"";if(t.__emotion_styles!==void 0)return t;switch(typeof t){case"boolean":return"";case"object":{if(t.anim===1)return Ga={name:t.name,styles:t.styles,next:Ga},t.name;if(t.styles!==void 0){var i=t.next;if(i!==void 0)for(;i!==void 0;)Ga={name:i.name,styles:i.styles,next:Ga},i=i.next;var r=t.styles+";";return r}return moe(n,e,t)}case"function":{if(n!==void 0){var s=Ga,o=t(n);return Ga=s,my(n,e,o)}break}}if(e==null)return t;var a=e[t];return a!==void 0?a:t}function moe(n,e,t){var i="";if(Array.isArray(t))for(var r=0;r96?Soe:_oe},xD=function(e,t,i){var r;if(t){var s=t.shouldForwardProp;r=e.__emotion_forwardProp&&s?function(o){return e.__emotion_forwardProp(o)&&s(o)}:s}return typeof r!="function"&&i&&(r=e.__emotion_forwardProp),r},Moe=function(e){var t=e.cache,i=e.serialized,r=e.isStringTag;return vB(t,i,r),yoe(function(){return xB(t,i,r)}),null},Aoe=function n(e,t){var i=e.__emotion_real===e,r=i&&e.__emotion_base||e,s,o;t!==void 0&&(s=t.label,o=t.target);var a=xD(e,t,i),l=a||vD(r),c=!l("as");return function(){var u=arguments,f=i&&e.__emotion_styles!==void 0?e.__emotion_styles.slice(0):[];if(s!==void 0&&f.push("label:"+s+";"),u[0]==null||u[0].raw===void 0)f.push.apply(f,u);else{f.push(u[0][0]);for(var g=u.length,y=1;ye(Toe(r)?t:r):e;return Or.jsx(xoe,{styles:i})}/** + * @mui/styled-engine v5.15.14 + * + * @license MIT + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */function EB(n,e){return qT(n,e)}const Poe=(n,e)=>{Array.isArray(n.__emotion_styles)&&(n.__emotion_styles=e(n.__emotion_styles))},Roe=Object.freeze(Object.defineProperty({__proto__:null,GlobalStyles:Coe,StyledEngineProvider:Eoe,ThemeContext:W_,css:bB,default:EB,internal_processStyles:Poe,keyframes:woe},Symbol.toStringTag,{value:"Module"}));function Vc(n){if(typeof n!="object"||n===null)return!1;const e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function TB(n){if(!Vc(n))return n;const e={};return Object.keys(n).forEach(t=>{e[t]=TB(n[t])}),e}function nl(n,e,t={clone:!0}){const i=t.clone?Hn({},n):n;return Vc(n)&&Vc(e)&&Object.keys(e).forEach(r=>{r!=="__proto__"&&(Vc(e[r])&&r in n&&Vc(n[r])?i[r]=nl(n[r],e[r],t):t.clone?i[r]=Vc(e[r])?TB(e[r]):e[r]:i[r]=e[r])}),i}const koe=Object.freeze(Object.defineProperty({__proto__:null,default:nl,isPlainObject:Vc},Symbol.toStringTag,{value:"Module"})),Loe=["values","unit","step"],Ioe=n=>{const e=Object.keys(n).map(t=>({key:t,val:n[t]}))||[];return e.sort((t,i)=>t.val-i.val),e.reduce((t,i)=>Hn({},t,{[i.key]:i.val}),{})};function CB(n){const{values:e={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:t="px",step:i=5}=n,r=Ql(n,Loe),s=Ioe(e),o=Object.keys(s);function a(g){return`@media (min-width:${typeof e[g]=="number"?e[g]:g}${t})`}function l(g){return`@media (max-width:${(typeof e[g]=="number"?e[g]:g)-i/100}${t})`}function c(g,y){const v=o.indexOf(y);return`@media (min-width:${typeof e[g]=="number"?e[g]:g}${t}) and (max-width:${(v!==-1&&typeof e[o[v]]=="number"?e[o[v]]:y)-i/100}${t})`}function u(g){return o.indexOf(g)+1`@media (min-width:${OP[n]}px)`};function Kl(n,e,t){const i=n.theme||{};if(Array.isArray(e)){const s=i.breakpoints||wD;return e.reduce((o,a,l)=>(o[s.up(s.keys[l])]=t(e[l]),o),{})}if(typeof e=="object"){const s=i.breakpoints||wD;return Object.keys(e).reduce((o,a)=>{if(Object.keys(s.values||OP).indexOf(a)!==-1){const l=s.up(a);o[l]=t(e[a],a)}else{const l=a;o[l]=e[l]}return o},{})}return t(e)}function Noe(n={}){var e;return((e=n.keys)==null?void 0:e.reduce((i,r)=>{const s=n.up(r);return i[s]={},i},{}))||{}}function Foe(n,e){return n.reduce((t,i)=>{const r=t[i];return(!r||Object.keys(r).length===0)&&delete t[i],t},e)}function Hy(n){if(typeof n!="string")throw new Error(fy(7));return n.charAt(0).toUpperCase()+n.slice(1)}const Uoe=Object.freeze(Object.defineProperty({__proto__:null,default:Hy},Symbol.toStringTag,{value:"Module"}));function j_(n,e,t=!0){if(!e||typeof e!="string")return null;if(n&&n.vars&&t){const i=`vars.${e}`.split(".").reduce((r,s)=>r&&r[s]?r[s]:null,n);if(i!=null)return i}return e.split(".").reduce((i,r)=>i&&i[r]!=null?i[r]:null,n)}function SS(n,e,t,i=t){let r;return typeof n=="function"?r=n(t):Array.isArray(n)?r=n[t]||i:r=j_(n,t)||i,e&&(r=e(r,i,n)),r}function ji(n){const{prop:e,cssProperty:t=n.prop,themeKey:i,transform:r}=n,s=o=>{if(o[e]==null)return null;const a=o[e],l=o.theme,c=j_(l,i)||{};return Kl(o,a,f=>{let g=SS(c,r,f);return f===g&&typeof f=="string"&&(g=SS(c,r,`${e}${f==="default"?"":Hy(f)}`,f)),t===!1?g:{[t]:g}})};return s.propTypes={},s.filterProps=[e],s}function zoe(n){const e={};return t=>(e[t]===void 0&&(e[t]=n(t)),e[t])}const Boe={m:"margin",p:"padding"},Voe={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},SD={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Hoe=zoe(n=>{if(n.length>2)if(SD[n])n=SD[n];else return[n];const[e,t]=n.split(""),i=Boe[e],r=Voe[t]||"";return Array.isArray(r)?r.map(s=>i+s):[i+r]}),NP=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],FP=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"];[...NP,...FP];function Gy(n,e,t,i){var r;const s=(r=j_(n,e,!1))!=null?r:t;return typeof s=="number"?o=>typeof o=="string"?o:s*o:Array.isArray(s)?o=>typeof o=="string"?o:s[o]:typeof s=="function"?s:()=>{}}function PB(n){return Gy(n,"spacing",8)}function Wy(n,e){if(typeof e=="string"||e==null)return e;const t=Math.abs(e),i=n(t);return e>=0?i:typeof i=="number"?-i:`-${i}`}function Goe(n,e){return t=>n.reduce((i,r)=>(i[r]=Wy(e,t),i),{})}function Woe(n,e,t,i){if(e.indexOf(t)===-1)return null;const r=Hoe(t),s=Goe(r,i),o=n[t];return Kl(n,o,s)}function RB(n,e){const t=PB(n.theme);return Object.keys(n).map(i=>Woe(n,e,i,t)).reduce(M0,{})}function Li(n){return RB(n,NP)}Li.propTypes={};Li.filterProps=NP;function Ii(n){return RB(n,FP)}Ii.propTypes={};Ii.filterProps=FP;function joe(n=8){if(n.mui)return n;const e=PB({spacing:n}),t=(...i)=>(i.length===0?[1]:i).map(s=>{const o=e(s);return typeof o=="number"?`${o}px`:o}).join(" ");return t.mui=!0,t}function X_(...n){const e=n.reduce((i,r)=>(r.filterProps.forEach(s=>{i[s]=r}),i),{}),t=i=>Object.keys(i).reduce((r,s)=>e[s]?M0(r,e[s](i)):r,{});return t.propTypes={},t.filterProps=n.reduce((i,r)=>i.concat(r.filterProps),[]),t}function Ho(n){return typeof n!="number"?n:`${n}px solid`}function Jo(n,e){return ji({prop:n,themeKey:"borders",transform:e})}const Xoe=Jo("border",Ho),qoe=Jo("borderTop",Ho),Yoe=Jo("borderRight",Ho),Koe=Jo("borderBottom",Ho),Zoe=Jo("borderLeft",Ho),Joe=Jo("borderColor"),Qoe=Jo("borderTopColor"),$oe=Jo("borderRightColor"),eae=Jo("borderBottomColor"),tae=Jo("borderLeftColor"),nae=Jo("outline",Ho),iae=Jo("outlineColor"),q_=n=>{if(n.borderRadius!==void 0&&n.borderRadius!==null){const e=Gy(n.theme,"shape.borderRadius",4),t=i=>({borderRadius:Wy(e,i)});return Kl(n,n.borderRadius,t)}return null};q_.propTypes={};q_.filterProps=["borderRadius"];X_(Xoe,qoe,Yoe,Koe,Zoe,Joe,Qoe,$oe,eae,tae,q_,nae,iae);const Y_=n=>{if(n.gap!==void 0&&n.gap!==null){const e=Gy(n.theme,"spacing",8),t=i=>({gap:Wy(e,i)});return Kl(n,n.gap,t)}return null};Y_.propTypes={};Y_.filterProps=["gap"];const K_=n=>{if(n.columnGap!==void 0&&n.columnGap!==null){const e=Gy(n.theme,"spacing",8),t=i=>({columnGap:Wy(e,i)});return Kl(n,n.columnGap,t)}return null};K_.propTypes={};K_.filterProps=["columnGap"];const Z_=n=>{if(n.rowGap!==void 0&&n.rowGap!==null){const e=Gy(n.theme,"spacing",8),t=i=>({rowGap:Wy(e,i)});return Kl(n,n.rowGap,t)}return null};Z_.propTypes={};Z_.filterProps=["rowGap"];const rae=ji({prop:"gridColumn"}),sae=ji({prop:"gridRow"}),oae=ji({prop:"gridAutoFlow"}),aae=ji({prop:"gridAutoColumns"}),lae=ji({prop:"gridAutoRows"}),cae=ji({prop:"gridTemplateColumns"}),uae=ji({prop:"gridTemplateRows"}),hae=ji({prop:"gridTemplateAreas"}),fae=ji({prop:"gridArea"});X_(Y_,K_,Z_,rae,sae,oae,aae,lae,cae,uae,hae,fae);function zp(n,e){return e==="grey"?e:n}const dae=ji({prop:"color",themeKey:"palette",transform:zp}),pae=ji({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:zp}),mae=ji({prop:"backgroundColor",themeKey:"palette",transform:zp});X_(dae,pae,mae);function to(n){return n<=1&&n!==0?`${n*100}%`:n}const gae=ji({prop:"width",transform:to}),UP=n=>{if(n.maxWidth!==void 0&&n.maxWidth!==null){const e=t=>{var i,r;const s=((i=n.theme)==null||(i=i.breakpoints)==null||(i=i.values)==null?void 0:i[t])||OP[t];return s?((r=n.theme)==null||(r=r.breakpoints)==null?void 0:r.unit)!=="px"?{maxWidth:`${s}${n.theme.breakpoints.unit}`}:{maxWidth:s}:{maxWidth:to(t)}};return Kl(n,n.maxWidth,e)}return null};UP.filterProps=["maxWidth"];const yae=ji({prop:"minWidth",transform:to}),vae=ji({prop:"height",transform:to}),xae=ji({prop:"maxHeight",transform:to}),wae=ji({prop:"minHeight",transform:to});ji({prop:"size",cssProperty:"width",transform:to});ji({prop:"size",cssProperty:"height",transform:to});const Sae=ji({prop:"boxSizing"});X_(gae,UP,yae,vae,xae,wae,Sae);const _ae={border:{themeKey:"borders",transform:Ho},borderTop:{themeKey:"borders",transform:Ho},borderRight:{themeKey:"borders",transform:Ho},borderBottom:{themeKey:"borders",transform:Ho},borderLeft:{themeKey:"borders",transform:Ho},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:Ho},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:q_},color:{themeKey:"palette",transform:zp},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:zp},backgroundColor:{themeKey:"palette",transform:zp},p:{style:Ii},pt:{style:Ii},pr:{style:Ii},pb:{style:Ii},pl:{style:Ii},px:{style:Ii},py:{style:Ii},padding:{style:Ii},paddingTop:{style:Ii},paddingRight:{style:Ii},paddingBottom:{style:Ii},paddingLeft:{style:Ii},paddingX:{style:Ii},paddingY:{style:Ii},paddingInline:{style:Ii},paddingInlineStart:{style:Ii},paddingInlineEnd:{style:Ii},paddingBlock:{style:Ii},paddingBlockStart:{style:Ii},paddingBlockEnd:{style:Ii},m:{style:Li},mt:{style:Li},mr:{style:Li},mb:{style:Li},ml:{style:Li},mx:{style:Li},my:{style:Li},margin:{style:Li},marginTop:{style:Li},marginRight:{style:Li},marginBottom:{style:Li},marginLeft:{style:Li},marginX:{style:Li},marginY:{style:Li},marginInline:{style:Li},marginInlineStart:{style:Li},marginInlineEnd:{style:Li},marginBlock:{style:Li},marginBlockStart:{style:Li},marginBlockEnd:{style:Li},displayPrint:{cssProperty:!1,transform:n=>({"@media print":{display:n}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:Y_},rowGap:{style:Z_},columnGap:{style:K_},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:to},maxWidth:{style:UP},minWidth:{transform:to},height:{transform:to},maxHeight:{transform:to},minHeight:{transform:to},boxSizing:{},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}},jy=_ae;function Mae(...n){const e=n.reduce((i,r)=>i.concat(Object.keys(r)),[]),t=new Set(e);return n.every(i=>t.size===Object.keys(i).length)}function Aae(n,e){return typeof n=="function"?n(e):n}function kB(){function n(t,i,r,s){const o={[t]:i,theme:r},a=s[t];if(!a)return{[t]:i};const{cssProperty:l=t,themeKey:c,transform:u,style:f}=a;if(i==null)return null;if(c==="typography"&&i==="inherit")return{[t]:i};const g=j_(r,c)||{};return f?f(o):Kl(o,i,v=>{let w=SS(g,u,v);return v===w&&typeof v=="string"&&(w=SS(g,u,`${t}${v==="default"?"":Hy(v)}`,v)),l===!1?w:{[l]:w}})}function e(t){var i;const{sx:r,theme:s={}}=t||{};if(!r)return null;const o=(i=s.unstable_sxConfig)!=null?i:jy;function a(l){let c=l;if(typeof l=="function")c=l(s);else if(typeof l!="object")return l;if(!c)return null;const u=Noe(s.breakpoints),f=Object.keys(u);let g=u;return Object.keys(c).forEach(y=>{const v=Aae(c[y],s);if(v!=null)if(typeof v=="object")if(o[y])g=M0(g,n(y,v,s,o));else{const w=Kl({theme:s},v,S=>({[y]:S}));Mae(w,v)?g[y]=e({sx:v,theme:s}):g=M0(g,w)}else g=M0(g,n(y,v,s,o))}),Foe(f,g)}return Array.isArray(r)?r.map(a):a(r)}return e}const LB=kB();LB.filterProps=["sx"];const J_=LB;function IB(n,e){const t=this;return t.vars&&typeof t.getColorSchemeSelector=="function"?{[t.getColorSchemeSelector(n).replace(/(\[[^\]]+\])/,"*:where($1)")]:e}:t.palette.mode===n?e:{}}const bae=["breakpoints","palette","spacing","shape"];function zP(n={},...e){const{breakpoints:t={},palette:i={},spacing:r,shape:s={}}=n,o=Ql(n,bae),a=CB(t),l=joe(r);let c=nl({breakpoints:a,direction:"ltr",components:{},palette:Hn({mode:"light"},i),spacing:l,shape:Hn({},Ooe,s)},o);return c.applyStyles=IB,c=e.reduce((u,f)=>nl(u,f),c),c.unstable_sxConfig=Hn({},jy,o==null?void 0:o.unstable_sxConfig),c.unstable_sx=function(f){return J_({sx:f,theme:this})},c}const Eae=Object.freeze(Object.defineProperty({__proto__:null,default:zP,private_createBreakpoints:CB,unstable_applyStyles:IB},Symbol.toStringTag,{value:"Module"}));function Tae(n){return Object.keys(n).length===0}function Cae(n=null){const e=le.useContext(W_);return!e||Tae(e)?n:e}const Pae=zP();function DB(n=Pae){return Cae(n)}const Rae=["sx"],kae=n=>{var e,t;const i={systemProps:{},otherProps:{}},r=(e=n==null||(t=n.theme)==null?void 0:t.unstable_sxConfig)!=null?e:jy;return Object.keys(n).forEach(s=>{r[s]?i.systemProps[s]=n[s]:i.otherProps[s]=n[s]}),i};function BP(n){const{sx:e}=n,t=Ql(n,Rae),{systemProps:i,otherProps:r}=kae(t);let s;return Array.isArray(e)?s=[i,...e]:typeof e=="function"?s=(...o)=>{const a=e(...o);return Vc(a)?Hn({},i,a):i}:s=Hn({},i,e),Hn({},r,{sx:s})}const Lae=Object.freeze(Object.defineProperty({__proto__:null,default:J_,extendSxProp:BP,unstable_createStyleFunctionSx:kB,unstable_defaultSxConfig:jy},Symbol.toStringTag,{value:"Module"})),_D=n=>n,Iae=()=>{let n=_D;return{configure(e){n=e},generate(e){return n(e)},reset(){n=_D}}},Dae=Iae(),OB=Dae;function NB(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;ea!=="theme"&&a!=="sx"&&a!=="as"})(J_);return le.forwardRef(function(l,c){const u=DB(t),f=BP(l),{className:g,component:y="div"}=f,v=Ql(f,Oae);return Or.jsx(s,Hn({as:y,ref:c,className:FB(g,r?r(i):i),theme:e&&u[e]||u},v))})}const Fae={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function UB(n,e,t="Mui"){const i=Fae[e];return i?`${t}-${i}`:`${OB.generate(n)}-${e}`}function zB(n,e,t="Mui"){const i={};return e.forEach(r=>{i[r]=UB(n,r,t)}),i}var BB={exports:{}},Zn={};/** + * @license React + * react-is.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 VP=Symbol.for("react.element"),HP=Symbol.for("react.portal"),Q_=Symbol.for("react.fragment"),$_=Symbol.for("react.strict_mode"),eM=Symbol.for("react.profiler"),tM=Symbol.for("react.provider"),nM=Symbol.for("react.context"),Uae=Symbol.for("react.server_context"),iM=Symbol.for("react.forward_ref"),rM=Symbol.for("react.suspense"),sM=Symbol.for("react.suspense_list"),oM=Symbol.for("react.memo"),aM=Symbol.for("react.lazy"),zae=Symbol.for("react.offscreen"),VB;VB=Symbol.for("react.module.reference");function Qo(n){if(typeof n=="object"&&n!==null){var e=n.$$typeof;switch(e){case VP:switch(n=n.type,n){case Q_:case eM:case $_:case rM:case sM:return n;default:switch(n=n&&n.$$typeof,n){case Uae:case nM:case iM:case aM:case oM:case tM:return n;default:return e}}case HP:return e}}}Zn.ContextConsumer=nM;Zn.ContextProvider=tM;Zn.Element=VP;Zn.ForwardRef=iM;Zn.Fragment=Q_;Zn.Lazy=aM;Zn.Memo=oM;Zn.Portal=HP;Zn.Profiler=eM;Zn.StrictMode=$_;Zn.Suspense=rM;Zn.SuspenseList=sM;Zn.isAsyncMode=function(){return!1};Zn.isConcurrentMode=function(){return!1};Zn.isContextConsumer=function(n){return Qo(n)===nM};Zn.isContextProvider=function(n){return Qo(n)===tM};Zn.isElement=function(n){return typeof n=="object"&&n!==null&&n.$$typeof===VP};Zn.isForwardRef=function(n){return Qo(n)===iM};Zn.isFragment=function(n){return Qo(n)===Q_};Zn.isLazy=function(n){return Qo(n)===aM};Zn.isMemo=function(n){return Qo(n)===oM};Zn.isPortal=function(n){return Qo(n)===HP};Zn.isProfiler=function(n){return Qo(n)===eM};Zn.isStrictMode=function(n){return Qo(n)===$_};Zn.isSuspense=function(n){return Qo(n)===rM};Zn.isSuspenseList=function(n){return Qo(n)===sM};Zn.isValidElementType=function(n){return typeof n=="string"||typeof n=="function"||n===Q_||n===eM||n===$_||n===rM||n===sM||n===zae||typeof n=="object"&&n!==null&&(n.$$typeof===aM||n.$$typeof===oM||n.$$typeof===tM||n.$$typeof===nM||n.$$typeof===iM||n.$$typeof===VB||n.getModuleId!==void 0)};Zn.typeOf=Qo;BB.exports=Zn;var MD=BB.exports;const Bae=/^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;function HB(n){const e=`${n}`.match(Bae);return e&&e[1]||""}function GB(n,e=""){return n.displayName||n.name||HB(n)||e}function AD(n,e,t){const i=GB(e);return n.displayName||(i!==""?`${t}(${i})`:t)}function Vae(n){if(n!=null){if(typeof n=="string")return n;if(typeof n=="function")return GB(n,"Component");if(typeof n=="object")switch(n.$$typeof){case MD.ForwardRef:return AD(n,n.render,"ForwardRef");case MD.Memo:return AD(n,n.type,"memo");default:return}}}const Hae=Object.freeze(Object.defineProperty({__proto__:null,default:Vae,getFunctionName:HB},Symbol.toStringTag,{value:"Module"}));function WB(n,e){const t=Hn({},e);return Object.keys(n).forEach(i=>{if(i.toString().match(/^(components|slots)$/))t[i]=Hn({},n[i],t[i]);else if(i.toString().match(/^(componentsProps|slotProps)$/)){const r=n[i]||{},s=e[i];t[i]={},!s||!Object.keys(s)?t[i]=r:!r||!Object.keys(r)?t[i]=s:(t[i]=Hn({},s),Object.keys(r).forEach(o=>{t[i][o]=WB(r[o],s[o])}))}else t[i]===void 0&&(t[i]=n[i])}),t}function Gae(n){const{theme:e,name:t,props:i}=n;return!e||!e.components||!e.components[t]||!e.components[t].defaultProps?i:WB(e.components[t].defaultProps,i)}function Wae({props:n,name:e,defaultTheme:t,themeId:i}){let r=DB(t);return i&&(r=r[i]||r),Gae({theme:r,name:e,props:n})}function jae(n,e=Number.MIN_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(n,t))}const Xae=Object.freeze(Object.defineProperty({__proto__:null,default:jae},Symbol.toStringTag,{value:"Module"}));function qae(n,e,t=void 0){const i={};return Object.keys(n).forEach(r=>{i[r]=n[r].reduce((s,o)=>{if(o){const a=e(o);a!==""&&s.push(a),t&&t[o]&&s.push(t[o])}return s},[]).join(" ")}),i}function Yae(n,e){return Hn({toolbar:{minHeight:56,[n.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[n.up("sm")]:{minHeight:64}}},e)}var Xi={},jB={exports:{}};(function(n){function e(t){return t&&t.__esModule?t:{default:t}}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports})(jB);var XB=jB.exports;const Kae=du(_se),Zae=du(Xae);var qB=XB;Object.defineProperty(Xi,"__esModule",{value:!0});Xi.alpha=JB;Xi.blend=cle;Xi.colorChannel=void 0;var Jae=Xi.darken=WP;Xi.decomposeColor=Ko;Xi.emphasize=QB;var Qae=Xi.getContrastRatio=rle;Xi.getLuminance=_S;Xi.hexToRgb=YB;Xi.hslToRgb=ZB;var $ae=Xi.lighten=jP;Xi.private_safeAlpha=sle;Xi.private_safeColorChannel=void 0;Xi.private_safeDarken=ole;Xi.private_safeEmphasize=lle;Xi.private_safeLighten=ale;Xi.recomposeColor=xm;Xi.rgbToHex=ile;var bD=qB(Kae),ele=qB(Zae);function GP(n,e=0,t=1){return(0,ele.default)(n,e,t)}function YB(n){n=n.slice(1);const e=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let t=n.match(e);return t&&t[0].length===1&&(t=t.map(i=>i+i)),t?`rgb${t.length===4?"a":""}(${t.map((i,r)=>r<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function tle(n){const e=n.toString(16);return e.length===1?`0${e}`:e}function Ko(n){if(n.type)return n;if(n.charAt(0)==="#")return Ko(YB(n));const e=n.indexOf("("),t=n.substring(0,e);if(["rgb","rgba","hsl","hsla","color"].indexOf(t)===-1)throw new Error((0,bD.default)(9,n));let i=n.substring(e+1,n.length-1),r;if(t==="color"){if(i=i.split(" "),r=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(r)===-1)throw new Error((0,bD.default)(10,r))}else i=i.split(",");return i=i.map(s=>parseFloat(s)),{type:t,values:i,colorSpace:r}}const KB=n=>{const e=Ko(n);return e.values.slice(0,3).map((t,i)=>e.type.indexOf("hsl")!==-1&&i!==0?`${t}%`:t).join(" ")};Xi.colorChannel=KB;const nle=(n,e)=>{try{return KB(n)}catch{return n}};Xi.private_safeColorChannel=nle;function xm(n){const{type:e,colorSpace:t}=n;let{values:i}=n;return e.indexOf("rgb")!==-1?i=i.map((r,s)=>s<3?parseInt(r,10):r):e.indexOf("hsl")!==-1&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),e.indexOf("color")!==-1?i=`${t} ${i.join(" ")}`:i=`${i.join(", ")}`,`${e}(${i})`}function ile(n){if(n.indexOf("#")===0)return n;const{values:e}=Ko(n);return`#${e.map((t,i)=>tle(i===3?Math.round(255*t):t)).join("")}`}function ZB(n){n=Ko(n);const{values:e}=n,t=e[0],i=e[1]/100,r=e[2]/100,s=i*Math.min(r,1-r),o=(c,u=(c+t/30)%12)=>r-s*Math.max(Math.min(u-3,9-u,1),-1);let a="rgb";const l=[Math.round(o(0)*255),Math.round(o(8)*255),Math.round(o(4)*255)];return n.type==="hsla"&&(a+="a",l.push(e[3])),xm({type:a,values:l})}function _S(n){n=Ko(n);let e=n.type==="hsl"||n.type==="hsla"?Ko(ZB(n)).values:n.values;return e=e.map(t=>(n.type!=="color"&&(t/=255),t<=.03928?t/12.92:((t+.055)/1.055)**2.4)),Number((.2126*e[0]+.7152*e[1]+.0722*e[2]).toFixed(3))}function rle(n,e){const t=_S(n),i=_S(e);return(Math.max(t,i)+.05)/(Math.min(t,i)+.05)}function JB(n,e){return n=Ko(n),e=GP(e),(n.type==="rgb"||n.type==="hsl")&&(n.type+="a"),n.type==="color"?n.values[3]=`/${e}`:n.values[3]=e,xm(n)}function sle(n,e,t){try{return JB(n,e)}catch{return n}}function WP(n,e){if(n=Ko(n),e=GP(e),n.type.indexOf("hsl")!==-1)n.values[2]*=1-e;else if(n.type.indexOf("rgb")!==-1||n.type.indexOf("color")!==-1)for(let t=0;t<3;t+=1)n.values[t]*=1-e;return xm(n)}function ole(n,e,t){try{return WP(n,e)}catch{return n}}function jP(n,e){if(n=Ko(n),e=GP(e),n.type.indexOf("hsl")!==-1)n.values[2]+=(100-n.values[2])*e;else if(n.type.indexOf("rgb")!==-1)for(let t=0;t<3;t+=1)n.values[t]+=(255-n.values[t])*e;else if(n.type.indexOf("color")!==-1)for(let t=0;t<3;t+=1)n.values[t]+=(1-n.values[t])*e;return xm(n)}function ale(n,e,t){try{return jP(n,e)}catch{return n}}function QB(n,e=.15){return _S(n)>.5?WP(n,e):jP(n,e)}function lle(n,e,t){try{return QB(n,e)}catch{return n}}function cle(n,e,t,i=1){const r=(l,c)=>Math.round((l**(1/i)*(1-t)+c**(1/i)*t)**i),s=Ko(n),o=Ko(e),a=[r(s.values[0],o.values[0]),r(s.values[1],o.values[1]),r(s.values[2],o.values[2])];return xm({type:"rgb",values:a})}const ule=["mode","contrastThreshold","tonalOffset"],ED={text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:hy.white,default:hy.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}},_b={text:{primary:hy.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:hy.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}};function TD(n,e,t,i){const r=i.light||i,s=i.dark||i*1.5;n[e]||(n.hasOwnProperty(t)?n[e]=n[t]:e==="light"?n.light=$ae(n.main,r):e==="dark"&&(n.dark=Jae(n.main,s)))}function hle(n="light"){return n==="dark"?{main:Zd[200],light:Zd[50],dark:Zd[400]}:{main:Zd[700],light:Zd[400],dark:Zd[800]}}function fle(n="light"){return n==="dark"?{main:Kd[200],light:Kd[50],dark:Kd[400]}:{main:Kd[500],light:Kd[300],dark:Kd[700]}}function dle(n="light"){return n==="dark"?{main:Yd[500],light:Yd[300],dark:Yd[700]}:{main:Yd[700],light:Yd[400],dark:Yd[800]}}function ple(n="light"){return n==="dark"?{main:Jd[400],light:Jd[300],dark:Jd[700]}:{main:Jd[700],light:Jd[500],dark:Jd[900]}}function mle(n="light"){return n==="dark"?{main:Qd[400],light:Qd[300],dark:Qd[700]}:{main:Qd[800],light:Qd[500],dark:Qd[900]}}function gle(n="light"){return n==="dark"?{main:Wg[400],light:Wg[300],dark:Wg[700]}:{main:"#ed6c02",light:Wg[500],dark:Wg[900]}}function yle(n){const{mode:e="light",contrastThreshold:t=3,tonalOffset:i=.2}=n,r=Ql(n,ule),s=n.primary||hle(e),o=n.secondary||fle(e),a=n.error||dle(e),l=n.info||ple(e),c=n.success||mle(e),u=n.warning||gle(e);function f(w){return Qae(w,_b.text.primary)>=t?_b.text.primary:ED.text.primary}const g=({color:w,name:S,mainShade:x=500,lightShade:M=300,darkShade:A=700})=>{if(w=Hn({},w),!w.main&&w[x]&&(w.main=w[x]),!w.hasOwnProperty("main"))throw new Error(fy(11,S?` (${S})`:"",x));if(typeof w.main!="string")throw new Error(fy(12,S?` (${S})`:"",JSON.stringify(w.main)));return TD(w,"light",M,i),TD(w,"dark",A,i),w.contrastText||(w.contrastText=f(w.main)),w},y={dark:_b,light:ED};return nl(Hn({common:Hn({},hy),mode:e,primary:g({color:s,name:"primary"}),secondary:g({color:o,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:g({color:a,name:"error"}),warning:g({color:u,name:"warning"}),info:g({color:l,name:"info"}),success:g({color:c,name:"success"}),grey:Sse,contrastThreshold:t,getContrastText:f,augmentColor:g,tonalOffset:i},y[e]),r)}const vle=["fontFamily","fontSize","fontWeightLight","fontWeightRegular","fontWeightMedium","fontWeightBold","htmlFontSize","allVariants","pxToRem"];function xle(n){return Math.round(n*1e5)/1e5}const CD={textTransform:"uppercase"},PD='"Roboto", "Helvetica", "Arial", sans-serif';function wle(n,e){const t=typeof e=="function"?e(n):e,{fontFamily:i=PD,fontSize:r=14,fontWeightLight:s=300,fontWeightRegular:o=400,fontWeightMedium:a=500,fontWeightBold:l=700,htmlFontSize:c=16,allVariants:u,pxToRem:f}=t,g=Ql(t,vle),y=r/14,v=f||(x=>`${x/c*y}rem`),w=(x,M,A,C,N)=>Hn({fontFamily:i,fontWeight:x,fontSize:v(M),lineHeight:A},i===PD?{letterSpacing:`${xle(C/M)}em`}:{},N,u),S={h1:w(s,96,1.167,-1.5),h2:w(s,60,1.2,-.5),h3:w(o,48,1.167,0),h4:w(o,34,1.235,.25),h5:w(o,24,1.334,0),h6:w(a,20,1.6,.15),subtitle1:w(o,16,1.75,.15),subtitle2:w(a,14,1.57,.1),body1:w(o,16,1.5,.15),body2:w(o,14,1.43,.15),button:w(a,14,1.75,.4,CD),caption:w(o,12,1.66,.4),overline:w(o,12,2.66,1,CD),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return nl(Hn({htmlFontSize:c,pxToRem:v,fontFamily:i,fontSize:r,fontWeightLight:s,fontWeightRegular:o,fontWeightMedium:a,fontWeightBold:l},S),g,{clone:!1})}const Sle=.2,_le=.14,Mle=.12;function gi(...n){return[`${n[0]}px ${n[1]}px ${n[2]}px ${n[3]}px rgba(0,0,0,${Sle})`,`${n[4]}px ${n[5]}px ${n[6]}px ${n[7]}px rgba(0,0,0,${_le})`,`${n[8]}px ${n[9]}px ${n[10]}px ${n[11]}px rgba(0,0,0,${Mle})`].join(",")}const Ale=["none",gi(0,2,1,-1,0,1,1,0,0,1,3,0),gi(0,3,1,-2,0,2,2,0,0,1,5,0),gi(0,3,3,-2,0,3,4,0,0,1,8,0),gi(0,2,4,-1,0,4,5,0,0,1,10,0),gi(0,3,5,-1,0,5,8,0,0,1,14,0),gi(0,3,5,-1,0,6,10,0,0,1,18,0),gi(0,4,5,-2,0,7,10,1,0,2,16,1),gi(0,5,5,-3,0,8,10,1,0,3,14,2),gi(0,5,6,-3,0,9,12,1,0,3,16,2),gi(0,6,6,-3,0,10,14,1,0,4,18,3),gi(0,6,7,-4,0,11,15,1,0,4,20,3),gi(0,7,8,-4,0,12,17,2,0,5,22,4),gi(0,7,8,-4,0,13,19,2,0,5,24,4),gi(0,7,9,-4,0,14,21,2,0,5,26,4),gi(0,8,9,-5,0,15,22,2,0,6,28,5),gi(0,8,10,-5,0,16,24,2,0,6,30,5),gi(0,8,11,-5,0,17,26,2,0,6,32,5),gi(0,9,11,-5,0,18,28,2,0,7,34,6),gi(0,9,12,-6,0,19,29,2,0,7,36,6),gi(0,10,13,-6,0,20,31,3,0,8,38,7),gi(0,10,13,-6,0,21,33,3,0,8,40,7),gi(0,10,14,-6,0,22,35,3,0,8,42,7),gi(0,11,14,-7,0,23,36,3,0,9,44,8),gi(0,11,15,-7,0,24,38,3,0,9,46,8)],ble=Ale,Ele=["duration","easing","delay"],Tle={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},Cle={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function RD(n){return`${Math.round(n)}ms`}function Ple(n){if(!n)return 0;const e=n/36;return Math.round((4+15*e**.25+e/5)*10)}function Rle(n){const e=Hn({},Tle,n.easing),t=Hn({},Cle,n.duration);return Hn({getAutoHeightDuration:Ple,create:(r=["all"],s={})=>{const{duration:o=t.standard,easing:a=e.easeInOut,delay:l=0}=s;return Ql(s,Ele),(Array.isArray(r)?r:[r]).map(c=>`${c} ${typeof o=="string"?o:RD(o)} ${a} ${typeof l=="string"?l:RD(l)}`).join(",")}},n,{easing:e,duration:t})}const kle={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500},Lle=kle,Ile=["breakpoints","mixins","spacing","palette","transitions","typography","shape"];function $B(n={},...e){const{mixins:t={},palette:i={},transitions:r={},typography:s={}}=n,o=Ql(n,Ile);if(n.vars)throw new Error(fy(18));const a=yle(i),l=zP(n);let c=nl(l,{mixins:Yae(l.breakpoints,t),palette:a,shadows:ble.slice(),typography:wle(a,s),transitions:Rle(r),zIndex:Hn({},Lle)});return c=nl(c,o),c=e.reduce((u,f)=>nl(u,f),c),c.unstable_sxConfig=Hn({},jy,o==null?void 0:o.unstable_sxConfig),c.unstable_sx=function(f){return J_({sx:f,theme:this})},c}const Dle=$B(),eV=Dle;function Ole({props:n,name:e}){return Wae({props:n,name:e,defaultTheme:eV,themeId:TP})}var Xy={},Mb={exports:{}},kD;function Nle(){return kD||(kD=1,function(n){function e(t,i){if(t==null)return{};var r={};for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){if(i.indexOf(s)>=0)continue;r[s]=t[s]}return r}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}(Mb)),Mb.exports}const Fle=du(Roe),Ule=du(koe),zle=du(Uoe),Ble=du(Hae),Vle=du(Eae),Hle=du(Lae);var wm=XB;Object.defineProperty(Xy,"__esModule",{value:!0});var Gle=Xy.default=nce;Xy.shouldForwardProp=xw;Xy.systemDefaultTheme=void 0;var zo=wm(AB()),KT=wm(Nle()),LD=Zle(Fle),Wle=Ule;wm(zle);wm(Ble);var jle=wm(Vle),Xle=wm(Hle);const qle=["ownerState"],Yle=["variants"],Kle=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function tV(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(tV=function(i){return i?t:e})(n)}function Zle(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=tV(e);if(t&&t.has(n))return t.get(n);var i={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=r?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(i,s,o):i[s]=n[s]}return i.default=n,t&&t.set(n,i),i}function Jle(n){return Object.keys(n).length===0}function Qle(n){return typeof n=="string"&&n.charCodeAt(0)>96}function xw(n){return n!=="ownerState"&&n!=="theme"&&n!=="sx"&&n!=="as"}const $le=Xy.systemDefaultTheme=(0,jle.default)(),ece=n=>n&&n.charAt(0).toLowerCase()+n.slice(1);function N1({defaultTheme:n,theme:e,themeId:t}){return Jle(e)?n:e[t]||e}function tce(n){return n?(e,t)=>t[n]:null}function ww(n,e){let{ownerState:t}=e,i=(0,KT.default)(e,qle);const r=typeof n=="function"?n((0,zo.default)({ownerState:t},i)):n;if(Array.isArray(r))return r.flatMap(s=>ww(s,(0,zo.default)({ownerState:t},i)));if(r&&typeof r=="object"&&Array.isArray(r.variants)){const{variants:s=[]}=r;let a=(0,KT.default)(r,Yle);return s.forEach(l=>{let c=!0;typeof l.props=="function"?c=l.props((0,zo.default)({ownerState:t},i,t)):Object.keys(l.props).forEach(u=>{(t==null?void 0:t[u])!==l.props[u]&&i[u]!==l.props[u]&&(c=!1)}),c&&(Array.isArray(a)||(a=[a]),a.push(typeof l.style=="function"?l.style((0,zo.default)({ownerState:t},i,t)):l.style))}),a}return r}function nce(n={}){const{themeId:e,defaultTheme:t=$le,rootShouldForwardProp:i=xw,slotShouldForwardProp:r=xw}=n,s=o=>(0,Xle.default)((0,zo.default)({},o,{theme:N1((0,zo.default)({},o,{defaultTheme:t,themeId:e}))}));return s.__mui_systemSx=!0,(o,a={})=>{(0,LD.internal_processStyles)(o,N=>N.filter(L=>!(L!=null&&L.__mui_systemSx)));const{name:l,slot:c,skipVariantsResolver:u,skipSx:f,overridesResolver:g=tce(ece(c))}=a,y=(0,KT.default)(a,Kle),v=u!==void 0?u:c&&c!=="Root"&&c!=="root"||!1,w=f||!1;let S,x=xw;c==="Root"||c==="root"?x=i:c?x=r:Qle(o)&&(x=void 0);const M=(0,LD.default)(o,(0,zo.default)({shouldForwardProp:x,label:S},y)),A=N=>typeof N=="function"&&N.__emotion_real!==N||(0,Wle.isPlainObject)(N)?L=>ww(N,(0,zo.default)({},L,{theme:N1({theme:L.theme,defaultTheme:t,themeId:e})})):N,C=(N,...L)=>{let F=A(N);const H=L?L.map(A):[];l&&g&&H.push(W=>{const se=N1((0,zo.default)({},W,{defaultTheme:t,themeId:e}));if(!se.components||!se.components[l]||!se.components[l].styleOverrides)return null;const Z=se.components[l].styleOverrides,oe={};return Object.entries(Z).forEach(([fe,Se])=>{oe[fe]=ww(Se,(0,zo.default)({},W,{theme:se}))}),g(W,oe)}),l&&!v&&H.push(W=>{var se;const Z=N1((0,zo.default)({},W,{defaultTheme:t,themeId:e})),oe=Z==null||(se=Z.components)==null||(se=se[l])==null?void 0:se.variants;return ww({variants:oe},(0,zo.default)({},W,{theme:Z}))}),w||H.push(s);const I=H.length-L.length;if(Array.isArray(N)&&I>0){const W=new Array(I).fill("");F=[...N,...W],F.raw=[...N.raw,...W]}const R=M(F,...H);return o.muiName&&(R.muiName=o.muiName),R};return M.withConfig&&(C.withConfig=M.withConfig),C}}function ice(n){return n!=="ownerState"&&n!=="theme"&&n!=="sx"&&n!=="as"}const rce=n=>ice(n)&&n!=="classes",sce=rce,oce=Gle({themeId:TP,defaultTheme:eV,rootShouldForwardProp:sce}),ace=oce;function lce(n){return UB("MuiTypography",n)}zB("MuiTypography",["root","h1","h2","h3","h4","h5","h6","subtitle1","subtitle2","body1","body2","inherit","button","caption","overline","alignLeft","alignRight","alignCenter","alignJustify","noWrap","gutterBottom","paragraph"]);const cce=["align","className","component","gutterBottom","noWrap","paragraph","variant","variantMapping"],uce=n=>{const{align:e,gutterBottom:t,noWrap:i,paragraph:r,variant:s,classes:o}=n,a={root:["root",s,n.align!=="inherit"&&`align${Hy(e)}`,t&&"gutterBottom",i&&"noWrap",r&&"paragraph"]};return qae(a,lce,o)},hce=ace("span",{name:"MuiTypography",slot:"Root",overridesResolver:(n,e)=>{const{ownerState:t}=n;return[e.root,t.variant&&e[t.variant],t.align!=="inherit"&&e[`align${Hy(t.align)}`],t.noWrap&&e.noWrap,t.gutterBottom&&e.gutterBottom,t.paragraph&&e.paragraph]}})(({theme:n,ownerState:e})=>Hn({margin:0},e.variant==="inherit"&&{font:"inherit"},e.variant!=="inherit"&&n.typography[e.variant],e.align!=="inherit"&&{textAlign:e.align},e.noWrap&&{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},e.gutterBottom&&{marginBottom:"0.35em"},e.paragraph&&{marginBottom:16})),ID={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",subtitle1:"h6",subtitle2:"h6",body1:"p",body2:"p",inherit:"p"},fce={primary:"primary.main",textPrimary:"text.primary",secondary:"secondary.main",textSecondary:"text.secondary",error:"error.main"},dce=n=>fce[n]||n,pce=le.forwardRef(function(e,t){const i=Ole({props:e,name:"MuiTypography"}),r=dce(i.color),s=BP(Hn({},i,{color:r})),{align:o="inherit",className:a,component:l,gutterBottom:c=!1,noWrap:u=!1,paragraph:f=!1,variant:g="body1",variantMapping:y=ID}=s,v=Ql(s,cce),w=Hn({},s,{align:o,color:r,className:a,component:l,gutterBottom:c,noWrap:u,paragraph:f,variant:g,variantMapping:y}),S=l||(f?"p":y[g]||ID[g])||"span",x=uce(w);return Or.jsx(hce,Hn({as:S,ref:t,ownerState:w,className:FB(x.root,a)},v))}),mce=pce,gce=zB("MuiBox",["root"]),yce=gce,vce=$B(),xce=Nae({themeId:TP,defaultTheme:vce,defaultClassName:yce.root,generateClassName:OB.generate}),wce=xce;function Ab(n,e,t){if(n&&n.length){const[i,r]=e,s=Math.PI/180*t,o=Math.cos(s),a=Math.sin(s);for(const l of n){const[c,u]=l;l[0]=(c-i)*o-(u-r)*a+i,l[1]=(c-i)*a+(u-r)*o+r}}}function Sce(n,e){return n[0]===e[0]&&n[1]===e[1]}function _ce(n,e,t,i=1){const r=t,s=Math.max(e,.1),o=n[0]&&n[0][0]&&typeof n[0][0]=="number"?[n]:n,a=[0,0];if(r)for(const c of o)Ab(c,a,r);const l=function(c,u,f){const g=[];for(const M of c){const A=[...M];Sce(A[0],A[A.length-1])||A.push([A[0][0],A[0][1]]),A.length>2&&g.push(A)}const y=[];u=Math.max(u,.1);const v=[];for(const M of g)for(let A=0;AM.yminA.ymin?1:M.xA.x?1:M.ymax===A.ymax?0:(M.ymax-A.ymax)/Math.abs(M.ymax-A.ymax)),!v.length)return y;let w=[],S=v[0].ymin,x=0;for(;w.length||v.length;){if(v.length){let M=-1;for(let A=0;AS);A++)M=A;v.splice(0,M+1).forEach(A=>{w.push({s:S,edge:A})})}if(w=w.filter(M=>!(M.edge.ymax<=S)),w.sort((M,A)=>M.edge.x===A.edge.x?0:(M.edge.x-A.edge.x)/Math.abs(M.edge.x-A.edge.x)),(f!==1||x%u==0)&&w.length>1)for(let M=0;M=w.length)break;const C=w[M].edge,N=w[A].edge;y.push([[Math.round(C.x),S],[Math.round(N.x),S]])}S+=f,w.forEach(M=>{M.edge.x=M.edge.x+f*M.edge.islope}),x++}return y}(o,s,i);if(r){for(const c of o)Ab(c,a,-r);(function(c,u,f){const g=[];c.forEach(y=>g.push(...y)),Ab(g,u,f)})(l,a,-r)}return l}function qy(n,e){var t;const i=e.hachureAngle+90;let r=e.hachureGap;r<0&&(r=4*e.strokeWidth),r=Math.round(Math.max(r,.1));let s=1;return e.roughness>=1&&(((t=e.randomizer)===null||t===void 0?void 0:t.next())||Math.random())>.7&&(s=r),_ce(n,r,i,s||1)}class XP{constructor(e){this.helper=e}fillPolygons(e,t){return this._fillPolygons(e,t)}_fillPolygons(e,t){const i=qy(e,t);return{type:"fillSketch",ops:this.renderLines(i,t)}}renderLines(e,t){const i=[];for(const r of e)i.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],t));return i}}function lM(n){const e=n[0],t=n[1];return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2))}class Mce extends XP{fillPolygons(e,t){let i=t.hachureGap;i<0&&(i=4*t.strokeWidth),i=Math.max(i,.1);const r=qy(e,Object.assign({},t,{hachureGap:i})),s=Math.PI/180*t.hachureAngle,o=[],a=.5*i*Math.cos(s),l=.5*i*Math.sin(s);for(const[c,u]of r)lM([c,u])&&o.push([[c[0]-a,c[1]+l],[...u]],[[c[0]+a,c[1]-l],[...u]]);return{type:"fillSketch",ops:this.renderLines(o,t)}}}class Ace extends XP{fillPolygons(e,t){const i=this._fillPolygons(e,t),r=Object.assign({},t,{hachureAngle:t.hachureAngle+90}),s=this._fillPolygons(e,r);return i.ops=i.ops.concat(s.ops),i}}class bce{constructor(e){this.helper=e}fillPolygons(e,t){const i=qy(e,t=Object.assign({},t,{hachureAngle:0}));return this.dotsOnLines(i,t)}dotsOnLines(e,t){const i=[];let r=t.hachureGap;r<0&&(r=4*t.strokeWidth),r=Math.max(r,.1);let s=t.fillWeight;s<0&&(s=t.strokeWidth/2);const o=r/4;for(const a of e){const l=lM(a),c=l/r,u=Math.ceil(c)-1,f=l-u*r,g=(a[0][0]+a[1][0])/2-r/4,y=Math.min(a[0][1],a[1][1]);for(let v=0;v{const a=lM(o),l=Math.floor(a/(i+r)),c=(a+r-l*(i+r))/2;let u=o[0],f=o[1];u[0]>f[0]&&(u=o[1],f=o[0]);const g=Math.atan((f[1]-u[1])/(f[0]-u[0]));for(let y=0;y{const o=lM(s),a=Math.round(o/(2*t));let l=s[0],c=s[1];l[0]>c[0]&&(l=s[1],c=s[0]);const u=Math.atan((c[1]-l[1])/(c[0]-l[0]));for(let f=0;fu%2?c+t:c+e);s.push({key:"C",data:l}),e=l[4],t=l[5];break}case"Q":s.push({key:"Q",data:[...a]}),e=a[2],t=a[3];break;case"q":{const l=a.map((c,u)=>u%2?c+t:c+e);s.push({key:"Q",data:l}),e=l[2],t=l[3];break}case"A":s.push({key:"A",data:[...a]}),e=a[5],t=a[6];break;case"a":e+=a[5],t+=a[6],s.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],e,t]});break;case"H":s.push({key:"H",data:[...a]}),e=a[0];break;case"h":e+=a[0],s.push({key:"H",data:[e]});break;case"V":s.push({key:"V",data:[...a]}),t=a[0];break;case"v":t+=a[0],s.push({key:"V",data:[t]});break;case"S":s.push({key:"S",data:[...a]}),e=a[2],t=a[3];break;case"s":{const l=a.map((c,u)=>u%2?c+t:c+e);s.push({key:"S",data:l}),e=l[2],t=l[3];break}case"T":s.push({key:"T",data:[...a]}),e=a[0],t=a[1];break;case"t":e+=a[0],t+=a[1],s.push({key:"T",data:[e,t]});break;case"Z":case"z":s.push({key:"Z",data:[]}),e=i,t=r}return s}function iV(n){const e=[];let t="",i=0,r=0,s=0,o=0,a=0,l=0;for(const{key:c,data:u}of n){switch(c){case"M":e.push({key:"M",data:[...u]}),[i,r]=u,[s,o]=u;break;case"C":e.push({key:"C",data:[...u]}),i=u[4],r=u[5],a=u[2],l=u[3];break;case"L":e.push({key:"L",data:[...u]}),[i,r]=u;break;case"H":i=u[0],e.push({key:"L",data:[i,r]});break;case"V":r=u[0],e.push({key:"L",data:[i,r]});break;case"S":{let f=0,g=0;t==="C"||t==="S"?(f=i+(i-a),g=r+(r-l)):(f=i,g=r),e.push({key:"C",data:[f,g,...u]}),a=u[0],l=u[1],i=u[2],r=u[3];break}case"T":{const[f,g]=u;let y=0,v=0;t==="Q"||t==="T"?(y=i+(i-a),v=r+(r-l)):(y=i,v=r);const w=i+2*(y-i)/3,S=r+2*(v-r)/3,x=f+2*(y-f)/3,M=g+2*(v-g)/3;e.push({key:"C",data:[w,S,x,M,f,g]}),a=y,l=v,i=f,r=g;break}case"Q":{const[f,g,y,v]=u,w=i+2*(f-i)/3,S=r+2*(g-r)/3,x=y+2*(f-y)/3,M=v+2*(g-v)/3;e.push({key:"C",data:[w,S,x,M,y,v]}),a=f,l=g,i=y,r=v;break}case"A":{const f=Math.abs(u[0]),g=Math.abs(u[1]),y=u[2],v=u[3],w=u[4],S=u[5],x=u[6];f===0||g===0?(e.push({key:"C",data:[i,r,S,x,S,x]}),i=S,r=x):(i!==S||r!==x)&&(rV(i,r,S,x,f,g,y,v,w).forEach(function(M){e.push({key:"C",data:M})}),i=S,r=x);break}case"Z":e.push({key:"Z",data:[]}),i=s,r=o}t=c}return e}function Xg(n,e,t){return[n*Math.cos(t)-e*Math.sin(t),n*Math.sin(t)+e*Math.cos(t)]}function rV(n,e,t,i,r,s,o,a,l,c){const u=(f=o,Math.PI*f/180);var f;let g=[],y=0,v=0,w=0,S=0;if(c)[y,v,w,S]=c;else{[n,e]=Xg(n,e,-u),[t,i]=Xg(t,i,-u);const Z=(n-t)/2,oe=(e-i)/2;let fe=Z*Z/(r*r)+oe*oe/(s*s);fe>1&&(fe=Math.sqrt(fe),r*=fe,s*=fe);const Se=r*r,Fe=s*s,X=Se*Fe-Se*oe*oe-Fe*Z*Z,ie=Se*oe*oe+Fe*Z*Z,re=(a===l?-1:1)*Math.sqrt(Math.abs(X/ie));w=re*r*oe/s+(n+t)/2,S=re*-s*Z/r+(e+i)/2,y=Math.asin(parseFloat(((e-S)/s).toFixed(9))),v=Math.asin(parseFloat(((i-S)/s).toFixed(9))),nv&&(y-=2*Math.PI),!l&&v>y&&(v-=2*Math.PI)}let x=v-y;if(Math.abs(x)>120*Math.PI/180){const Z=v,oe=t,fe=i;v=l&&v>y?y+120*Math.PI/180*1:y+120*Math.PI/180*-1,g=rV(t=w+r*Math.cos(v),i=S+s*Math.sin(v),oe,fe,r,s,o,0,l,[v,Z,w,S])}x=v-y;const M=Math.cos(y),A=Math.sin(y),C=Math.cos(v),N=Math.sin(v),L=Math.tan(x/4),F=4/3*r*L,H=4/3*s*L,I=[n,e],R=[n+F*A,e-H*M],W=[t+F*N,i-H*C],se=[t,i];if(R[0]=2*I[0]-R[0],R[1]=2*I[1]-R[1],c)return[R,W,se].concat(g);{g=[R,W,se].concat(g);const Z=[];for(let oe=0;oe2){const r=[];for(let s=0;s2*Math.PI&&(y=0,v=2*Math.PI);const w=2*Math.PI/l.curveStepCount,S=Math.min(w/2,(v-y)/2),x=BD(S,c,u,f,g,y,v,1,l);if(!l.disableMultiStroke){const M=BD(S,c,u,f,g,y,v,1.5,l);x.push(...M)}return o&&(a?x.push(...fu(c,u,c+f*Math.cos(y),u+g*Math.sin(y),l),...fu(c,u,c+f*Math.cos(v),u+g*Math.sin(v),l)):x.push({op:"lineTo",data:[c,u]},{op:"lineTo",data:[c+f*Math.cos(y),u+g*Math.sin(y)]})),{type:"path",ops:x}}function FD(n,e){const t=iV(nV(qP(n))),i=[];let r=[0,0],s=[0,0];for(const{key:o,data:a}of t)switch(o){case"M":s=[a[0],a[1]],r=[a[0],a[1]];break;case"L":i.push(...fu(s[0],s[1],a[0],a[1],e)),s=[a[0],a[1]];break;case"C":{const[l,c,u,f,g,y]=a;i.push(...Lce(l,c,u,f,g,y,s,e)),s=[g,y];break}case"Z":i.push(...fu(s[0],s[1],r[0],r[1],e)),s=[r[0],r[1]]}return{type:"path",ops:i}}function Tb(n,e){const t=[];for(const i of n)if(i.length){const r=e.maxRandomnessOffset||0,s=i.length;if(s>2){t.push({op:"move",data:[i[0][0]+Kt(r,e),i[0][1]+Kt(r,e)]});for(let o=1;o500?.4:-.0016668*l+1.233334;let u=r.maxRandomnessOffset||0;u*u*100>a&&(u=l/10);const f=u/2,g=.2+.2*aV(r);let y=r.bowing*r.maxRandomnessOffset*(i-e)/200,v=r.bowing*r.maxRandomnessOffset*(n-t)/200;y=Kt(y,r,c),v=Kt(v,r,c);const w=[],S=()=>Kt(f,r,c),x=()=>Kt(u,r,c),M=r.preserveVertices;return s&&(o?w.push({op:"move",data:[n+(M?0:S()),e+(M?0:S())]}):w.push({op:"move",data:[n+(M?0:Kt(u,r,c)),e+(M?0:Kt(u,r,c))]})),o?w.push({op:"bcurveTo",data:[y+n+(t-n)*g+S(),v+e+(i-e)*g+S(),y+n+2*(t-n)*g+S(),v+e+2*(i-e)*g+S(),t+(M?0:S()),i+(M?0:S())]}):w.push({op:"bcurveTo",data:[y+n+(t-n)*g+x(),v+e+(i-e)*g+x(),y+n+2*(t-n)*g+x(),v+e+2*(i-e)*g+x(),t+(M?0:x()),i+(M?0:x())]}),w}function U1(n,e,t){if(!n.length)return[];const i=[];i.push([n[0][0]+Kt(e,t),n[0][1]+Kt(e,t)]),i.push([n[0][0]+Kt(e,t),n[0][1]+Kt(e,t)]);for(let r=1;r3){const s=[],o=1-t.curveTightness;r.push({op:"move",data:[n[1][0],n[1][1]]});for(let a=1;a+21&&r.push(a)):r.push(a),r.push(n[e+3])}else{const l=n[e+0],c=n[e+1],u=n[e+2],f=n[e+3],g=Mh(l,c,.5),y=Mh(c,u,.5),v=Mh(u,f,.5),w=Mh(g,y,.5),S=Mh(y,v,.5),x=Mh(w,S,.5);QT([l,g,w,x],0,t,r),QT([x,S,v,f],0,t,r)}var s,o;return r}function Dce(n,e){return bS(n,0,n.length,e)}function bS(n,e,t,i,r){const s=r||[],o=n[e],a=n[t-1];let l=0,c=1;for(let u=e+1;ul&&(l=f,c=u)}return Math.sqrt(l)>i?(bS(n,e,c+1,i,s),bS(n,c,t,i,s)):(s.length||s.push(o),s.push(a)),s}function Cb(n,e=.15,t){const i=[],r=(n.length-1)/3;for(let s=0;s0?bS(i,0,i.length,t):i}const Js="none";class ES{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,t,i){return{shape:e,sets:t||[],options:i||this.defaultOptions}}line(e,t,i,r,s){const o=this._o(s);return this._d("line",[sV(e,t,i,r,o)],o)}rectangle(e,t,i,r,s){const o=this._o(s),a=[],l=kce(e,t,i,r,o);if(o.fill){const c=[[e,t],[e+i,t],[e+i,t+r],[e,t+r]];o.fillStyle==="solid"?a.push(Tb([c],o)):a.push($d([c],o))}return o.stroke!==Js&&a.push(l),this._d("rectangle",a,o)}ellipse(e,t,i,r,s){const o=this._o(s),a=[],l=oV(i,r,o),c=ZT(e,t,o,l);if(o.fill)if(o.fillStyle==="solid"){const u=ZT(e,t,o,l).opset;u.type="fillPath",a.push(u)}else a.push($d([c.estimatedPoints],o));return o.stroke!==Js&&a.push(c.opset),this._d("ellipse",a,o)}circle(e,t,i,r){const s=this.ellipse(e,t,i,i,r);return s.shape="circle",s}linearPath(e,t){const i=this._o(t);return this._d("linearPath",[Sw(e,!1,i)],i)}arc(e,t,i,r,s,o,a=!1,l){const c=this._o(l),u=[],f=ND(e,t,i,r,s,o,a,!0,c);if(a&&c.fill)if(c.fillStyle==="solid"){const g=Object.assign({},c);g.disableMultiStroke=!0;const y=ND(e,t,i,r,s,o,!0,!1,g);y.type="fillPath",u.push(y)}else u.push(function(g,y,v,w,S,x,M){const A=g,C=y;let N=Math.abs(v/2),L=Math.abs(w/2);N+=Kt(.01*N,M),L+=Kt(.01*L,M);let F=S,H=x;for(;F<0;)F+=2*Math.PI,H+=2*Math.PI;H-F>2*Math.PI&&(F=0,H=2*Math.PI);const I=(H-F)/M.curveStepCount,R=[];for(let W=F;W<=H;W+=I)R.push([A+N*Math.cos(W),C+L*Math.sin(W)]);return R.push([A+N*Math.cos(H),C+L*Math.sin(H)]),R.push([A,C]),$d([R],M)}(e,t,i,r,s,o,c));return c.stroke!==Js&&u.push(f),this._d("arc",u,c)}curve(e,t){const i=this._o(t),r=[],s=OD(e,i);if(i.fill&&i.fill!==Js)if(i.fillStyle==="solid"){const o=OD(e,Object.assign(Object.assign({},i),{disableMultiStroke:!0,roughness:i.roughness?i.roughness+i.fillShapeRoughnessGain:0}));r.push({type:"fillPath",ops:this._mergedShape(o.ops)})}else{const o=[],a=e;if(a.length){const l=typeof a[0][0]=="number"?[a]:a;for(const c of l)c.length<3?o.push(...c):c.length===3?o.push(...Cb(VD([c[0],c[0],c[1],c[2]]),10,(1+i.roughness)/2)):o.push(...Cb(VD(c),10,(1+i.roughness)/2))}o.length&&r.push($d([o],i))}return i.stroke!==Js&&r.push(s),this._d("curve",r,i)}polygon(e,t){const i=this._o(t),r=[],s=Sw(e,!0,i);return i.fill&&(i.fillStyle==="solid"?r.push(Tb([e],i)):r.push($d([e],i))),i.stroke!==Js&&r.push(s),this._d("polygon",r,i)}path(e,t){const i=this._o(t),r=[];if(!e)return this._d("path",r,i);e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const s=i.fill&&i.fill!=="transparent"&&i.fill!==Js,o=i.stroke!==Js,a=!!(i.simplification&&i.simplification<1),l=function(u,f,g){const y=iV(nV(qP(u))),v=[];let w=[],S=[0,0],x=[];const M=()=>{x.length>=4&&w.push(...Cb(x,f)),x=[]},A=()=>{M(),w.length&&(v.push(w),w=[])};for(const{key:N,data:L}of y)switch(N){case"M":A(),S=[L[0],L[1]],w.push(S);break;case"L":M(),w.push([L[0],L[1]]);break;case"C":if(!x.length){const F=w.length?w[w.length-1]:S;x.push([F[0],F[1]])}x.push([L[0],L[1]]),x.push([L[2],L[3]]),x.push([L[4],L[5]]);break;case"Z":M(),w.push([S[0],S[1]])}if(A(),!g)return v;const C=[];for(const N of v){const L=Dce(N,g);L.length&&C.push(L)}return C}(e,1,a?4-4*(i.simplification||1):(1+i.roughness)/2),c=FD(e,i);if(s)if(i.fillStyle==="solid")if(l.length===1){const u=FD(e,Object.assign(Object.assign({},i),{disableMultiStroke:!0,roughness:i.roughness?i.roughness+i.fillShapeRoughnessGain:0}));r.push({type:"fillPath",ops:this._mergedShape(u.ops)})}else r.push(Tb(l,i));else r.push($d(l,i));return o&&(a?l.forEach(u=>{r.push(Sw(u,!1,i))}):r.push(c)),this._d("path",r,i)}opsToPath(e,t){let i="";for(const r of e.ops){const s=typeof t=="number"&&t>=0?r.data.map(o=>+o.toFixed(t)):r.data;switch(r.op){case"move":i+=`M${s[0]} ${s[1]} `;break;case"bcurveTo":i+=`C${s[0]} ${s[1]}, ${s[2]} ${s[3]}, ${s[4]} ${s[5]} `;break;case"lineTo":i+=`L${s[0]} ${s[1]} `}}return i.trim()}toPaths(e){const t=e.sets||[],i=e.options||this.defaultOptions,r=[];for(const s of t){let o=null;switch(s.type){case"path":o={d:this.opsToPath(s),stroke:i.stroke,strokeWidth:i.strokeWidth,fill:Js};break;case"fillPath":o={d:this.opsToPath(s),stroke:Js,strokeWidth:0,fill:i.fill||Js};break;case"fillSketch":o=this.fillSketch(s,i)}o&&r.push(o)}return r}fillSketch(e,t){let i=t.fillWeight;return i<0&&(i=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||Js,strokeWidth:i,fill:Js}}_mergedShape(e){return e.filter((t,i)=>i===0||t.op!=="move")}}class Oce{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.gen=new ES(t)}draw(e){const t=e.sets||[],i=e.options||this.getDefaultOptions(),r=this.ctx,s=e.options.fixedDecimalPlaceDigits;for(const o of t)switch(o.type){case"path":r.save(),r.strokeStyle=i.stroke==="none"?"transparent":i.stroke,r.lineWidth=i.strokeWidth,i.strokeLineDash&&r.setLineDash(i.strokeLineDash),i.strokeLineDashOffset&&(r.lineDashOffset=i.strokeLineDashOffset),this._drawToContext(r,o,s),r.restore();break;case"fillPath":{r.save(),r.fillStyle=i.fill||"";const a=e.shape==="curve"||e.shape==="polygon"||e.shape==="path"?"evenodd":"nonzero";this._drawToContext(r,o,s,a),r.restore();break}case"fillSketch":this.fillSketch(r,o,i)}}fillSketch(e,t,i){let r=i.fillWeight;r<0&&(r=i.strokeWidth/2),e.save(),i.fillLineDash&&e.setLineDash(i.fillLineDash),i.fillLineDashOffset&&(e.lineDashOffset=i.fillLineDashOffset),e.strokeStyle=i.fill||"",e.lineWidth=r,this._drawToContext(e,t,i.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,t,i,r="nonzero"){e.beginPath();for(const s of t.ops){const o=typeof i=="number"&&i>=0?s.data.map(a=>+a.toFixed(i)):s.data;switch(s.op){case"move":e.moveTo(o[0],o[1]);break;case"bcurveTo":e.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"lineTo":e.lineTo(o[0],o[1])}}t.type==="fillPath"?e.fill(r):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,t,i,r,s){const o=this.gen.line(e,t,i,r,s);return this.draw(o),o}rectangle(e,t,i,r,s){const o=this.gen.rectangle(e,t,i,r,s);return this.draw(o),o}ellipse(e,t,i,r,s){const o=this.gen.ellipse(e,t,i,r,s);return this.draw(o),o}circle(e,t,i,r){const s=this.gen.circle(e,t,i,r);return this.draw(s),s}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i),i}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i),i}arc(e,t,i,r,s,o,a=!1,l){const c=this.gen.arc(e,t,i,r,s,o,a,l);return this.draw(c),c}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i),i}path(e,t){const i=this.gen.path(e,t);return this.draw(i),i}}const z1="http://www.w3.org/2000/svg";class Nce{constructor(e,t){this.svg=e,this.gen=new ES(t)}draw(e){const t=e.sets||[],i=e.options||this.getDefaultOptions(),r=this.svg.ownerDocument||window.document,s=r.createElementNS(z1,"g"),o=e.options.fixedDecimalPlaceDigits;for(const a of t){let l=null;switch(a.type){case"path":l=r.createElementNS(z1,"path"),l.setAttribute("d",this.opsToPath(a,o)),l.setAttribute("stroke",i.stroke),l.setAttribute("stroke-width",i.strokeWidth+""),l.setAttribute("fill","none"),i.strokeLineDash&&l.setAttribute("stroke-dasharray",i.strokeLineDash.join(" ").trim()),i.strokeLineDashOffset&&l.setAttribute("stroke-dashoffset",`${i.strokeLineDashOffset}`);break;case"fillPath":l=r.createElementNS(z1,"path"),l.setAttribute("d",this.opsToPath(a,o)),l.setAttribute("stroke","none"),l.setAttribute("stroke-width","0"),l.setAttribute("fill",i.fill||""),e.shape!=="curve"&&e.shape!=="polygon"||l.setAttribute("fill-rule","evenodd");break;case"fillSketch":l=this.fillSketch(r,a,i)}l&&s.appendChild(l)}return s}fillSketch(e,t,i){let r=i.fillWeight;r<0&&(r=i.strokeWidth/2);const s=e.createElementNS(z1,"path");return s.setAttribute("d",this.opsToPath(t,i.fixedDecimalPlaceDigits)),s.setAttribute("stroke",i.fill||""),s.setAttribute("stroke-width",r+""),s.setAttribute("fill","none"),i.fillLineDash&&s.setAttribute("stroke-dasharray",i.fillLineDash.join(" ").trim()),i.fillLineDashOffset&&s.setAttribute("stroke-dashoffset",`${i.fillLineDashOffset}`),s}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,t){return this.gen.opsToPath(e,t)}line(e,t,i,r,s){const o=this.gen.line(e,t,i,r,s);return this.draw(o)}rectangle(e,t,i,r,s){const o=this.gen.rectangle(e,t,i,r,s);return this.draw(o)}ellipse(e,t,i,r,s){const o=this.gen.ellipse(e,t,i,r,s);return this.draw(o)}circle(e,t,i,r){const s=this.gen.circle(e,t,i,r);return this.draw(s)}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i)}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i)}arc(e,t,i,r,s,o,a=!1,l){const c=this.gen.arc(e,t,i,r,s,o,a,l);return this.draw(c)}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i)}path(e,t){const i=this.gen.path(e,t);return this.draw(i)}}var Fce={canvas:(n,e)=>new Oce(n,e),svg:(n,e)=>new Nce(n,e),generator:n=>new ES(n),newSeed:()=>ES.newSeed()},ms={},lV={exports:{}};(function(n,e){(function(){function t(m){return m&&m.__esModule?{d:m.default}:{d:m}}var i={};function r(m){return(r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(m)}function s(m,d){if(!(m instanceof d))throw new TypeError("Cannot call a class as a function")}function o(m,d){for(var b=0;bd?1:m>=d?0:NaN},g=function(m){return m.length===1&&(m=y(m)),{left:function(d,b,T,D){for(T==null&&(T=0),D==null&&(D=d.length);T>>1;m(d[z],b)<0?T=z+1:D=z}return T},right:function(d,b,T,D){for(T==null&&(T=0),D==null&&(D=d.length);T>>1;m(d[z],b)>0?D=z:T=z+1}return T}}};function y(m){return function(d,b){return f(m(d),b)}}var v=g(f),w=v.right,S=function(m,d){let b,T;if(d===void 0)for(const D of m)D!=null&&(b===void 0?D>=D&&(b=T=D):(b>D&&(b=D),T=z&&(b=T=z):(b>z&&(b=z),T0)return[m];if((T=d0)for(m=Math.ceil(m/j),d=Math.floor(d/j),z=new Array(D=Math.ceil(d-m+1));++U=0?(z>=M?10:z>=A?5:z>=C?2:1)*Math.pow(10,D):-Math.pow(10,-D)/(z>=M?10:z>=A?5:z>=C?2:1)}function F(m,d,b){var T=Math.abs(d-m)/Math.max(0,b),D=Math.pow(10,Math.floor(Math.log(T)/Math.LN10)),z=T/D;return z>=M?D*=10:z>=A?D*=5:z>=C&&(D*=2),d=T)&&(b=T);else{let T=-1;for(let D of m)(D=d(D,++T,m))!=null&&(b=D)&&(b=D)}return b}function I(m,d){let b;if(d===void 0)for(const T of m)T!=null&&(b>T||b===void 0&&T>=T)&&(b=T);else{let T=-1;for(let D of m)(D=d(D,++T,m))!=null&&(b>D||b===void 0&&D>=D)&&(b=D)}return b}var R=Array.prototype.slice,W=function(m){return m},se=1,Z=2,oe=3,fe=4,Se=1e-6;function Fe(m){return"translate("+(m+.5)+",0)"}function X(m){return"translate(0,"+(m+.5)+")"}function ie(m){return function(d){return+m(d)}}function re(m){var d=Math.max(0,m.bandwidth()-1)/2;return m.round()&&(d=Math.round(d)),function(b){return+m(b)+d}}function de(){return!this.__axis}function Oe(m,d){var b=[],T=null,D=null,z=6,j=6,U=3,$=m===se||m===fe?-1:1,ae=m===fe||m===Z?"x":"y",me=m===se||m===oe?Fe:X;function Te(xe){var St=T??(d.ticks?d.ticks.apply(d,b):d.domain()),Yt=D??(d.tickFormat?d.tickFormat.apply(d,b):W),ln=Math.max(z,0)+U,Ut=d.range(),xt=+Ut[0]+.5,Et=+Ut[Ut.length-1]+.5,Jt=(d.bandwidth?re:ie)(d.copy()),zt=xe.selection?xe.selection():xe,Xn=zt.selectAll(".domain").data([null]),xn=zt.selectAll(".tick").data(St,d).order(),Pn=xn.exit(),mi=xn.enter().append("g").attr("class","tick"),ut=xn.select("line"),ot=xn.select("text");Xn=Xn.merge(Xn.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),xn=xn.merge(mi),ut=ut.merge(mi.append("line").attr("stroke","currentColor").attr(ae+"2",$*z)),ot=ot.merge(mi.append("text").attr("fill","currentColor").attr(ae,$*ln).attr("dy",m===se?"0em":m===oe?"0.71em":"0.32em")),xe!==zt&&(Xn=Xn.transition(xe),xn=xn.transition(xe),ut=ut.transition(xe),ot=ot.transition(xe),Pn=Pn.transition(xe).attr("opacity",Se).attr("transform",function(Pt){return isFinite(Pt=Jt(Pt))?me(Pt):this.getAttribute("transform")}),mi.attr("opacity",Se).attr("transform",function(Pt){var yt=this.parentNode.__axis;return me(yt&&isFinite(yt=yt(Pt))?yt:Jt(Pt))})),Pn.remove(),Xn.attr("d",m===fe||m==Z?j?"M"+$*j+","+xt+"H0.5V"+Et+"H"+$*j:"M0.5,"+xt+"V"+Et:j?"M"+xt+","+$*j+"V0.5H"+Et+"V"+$*j:"M"+xt+",0.5H"+Et),xn.attr("opacity",1).attr("transform",function(Pt){return me(Jt(Pt))}),ut.attr(ae+"2",$*z),ot.attr(ae,$*ln).text(Yt),zt.filter(de).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",m===Z?"start":m===fe?"end":"middle"),zt.each(function(){this.__axis=Jt})}return Te.scale=function(xe){return arguments.length?(d=xe,Te):d},Te.ticks=function(){return b=R.call(arguments),Te},Te.tickArguments=function(xe){return arguments.length?(b=xe==null?[]:R.call(xe),Te):b.slice()},Te.tickValues=function(xe){return arguments.length?(T=xe==null?null:R.call(xe),Te):T&&T.slice()},Te.tickFormat=function(xe){return arguments.length?(D=xe,Te):D},Te.tickSize=function(xe){return arguments.length?(z=j=+xe,Te):z},Te.tickSizeInner=function(xe){return arguments.length?(z=+xe,Te):z},Te.tickSizeOuter=function(xe){return arguments.length?(j=+xe,Te):j},Te.tickPadding=function(xe){return arguments.length?(U=+xe,Te):U},Te}function it(m){return Oe(oe,m)}function we(m){return Oe(fe,m)}function Ve(m){return function(d,b,T){return arguments.length===2&&typeof b=="function"&&(T=b,b=void 0),je(d,b).then(function(D){return m(D,T)})}}var Ye={},He={},Xt=34,jt=10,ge=13;function Dt(m){return new Function("d","return {"+m.map(function(d,b){return JSON.stringify(d)+": d["+b+"]"}).join(",")+"}")}function Ie(m,d){var b=Dt(m);return function(T,D){return d(b(T),D,m)}}function Ge(m){var d=Object.create(null),b=[];return m.forEach(function(T){for(var D in T)D in d||b.push(d[D]=D)}),b}function Pe(m,d){var b=m+"",T=b.length;return T9999?"+"+Pe(m,6):Pe(m,4)}function We(m){var d=m.getUTCHours(),b=m.getUTCMinutes(),T=m.getUTCSeconds(),D=m.getUTCMilliseconds();return isNaN(m)?"Invalid Date":rt(m.getUTCFullYear())+"-"+Pe(m.getUTCMonth()+1,2)+"-"+Pe(m.getUTCDate(),2)+(D?"T"+Pe(d,2)+":"+Pe(b,2)+":"+Pe(T,2)+"."+Pe(D,3)+"Z":T?"T"+Pe(d,2)+":"+Pe(b,2)+":"+Pe(T,2)+"Z":b||d?"T"+Pe(d,2)+":"+Pe(b,2)+"Z":"")}var ft=function(m){var d=new RegExp('["'+m+` +\r]`),b=m.charCodeAt(0);function T(U,$){var ae,me=[],Te=U.length,xe=0,St=0,Yt=Te<=0,ln=!1;function Ut(){if(Yt)return He;if(ln)return ln=!1,Ye;var Et,Jt,zt=xe;if(U.charCodeAt(zt)===Xt){for(;xe++=Te?Yt=!0:(Jt=U.charCodeAt(xe++))===jt?ln=!0:Jt===ge&&(ln=!0,U.charCodeAt(xe)===jt&&++xe),U.slice(zt+1,Et-1).replace(/""/g,'"')}for(;xe1?T[0]+T.slice(2):T,+m.slice(b+1)]},dt=function(m){return(m=Ft(Math.abs(m)))?m[1]:NaN},on=function(m,d){return function(b,T){for(var D=b.length,z=[],j=0,U=m[0],$=0;D>0&&U>0&&($+U+1>T&&(U=Math.max(1,T-$)),z.push(b.substring(D-=U,D+U)),!(($+=U+1)>T));)U=m[j=(j+1)%m.length];return z.reverse().join(d)}},dn=function(m){return function(d){return d.replace(/[0-9]/g,function(b){return m[+b]})}},Qn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function et(m){if(!(d=Qn.exec(m)))throw new Error("invalid format: "+m);var d;return new ce({fill:d[1],align:d[2],sign:d[3],symbol:d[4],zero:d[5],width:d[6],comma:d[7],precision:d[8]&&d[8].slice(1),trim:d[9],type:d[10]})}function ce(m){this.fill=m.fill===void 0?" ":m.fill+"",this.align=m.align===void 0?">":m.align+"",this.sign=m.sign===void 0?"-":m.sign+"",this.symbol=m.symbol===void 0?"":m.symbol+"",this.zero=!!m.zero,this.width=m.width===void 0?void 0:+m.width,this.comma=!!m.comma,this.precision=m.precision===void 0?void 0:+m.precision,this.trim=!!m.trim,this.type=m.type===void 0?"":m.type+""}et.prototype=ce.prototype,ce.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,0|this.width))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Ue=function(m){e:for(var d,b=m.length,T=1,D=-1;T0){if(!+m[T])break e;D=0}}return D>0?m.slice(0,D)+m.slice(d+1):m},Re,nt=function(m,d){var b,T=Ft(m,d);if(!T)return m+"";var D=T[0],z=T[1],j=z-(b=Re=3*Math.max(-8,Math.min(8,Math.floor(z/3))),b)+1,U=D.length;return j===U?D:j>U?D+new Array(j-U+1).join("0"):j>0?D.slice(0,j)+"."+D.slice(j):"0."+new Array(1-j).join("0")+Ft(m,Math.max(0,d+j-1))[0]},ct=function(m,d){var b=Ft(m,d);if(!b)return m+"";var T=b[0],D=b[1];return D<0?"0."+new Array(-D).join("0")+T:T.length>D+1?T.slice(0,D+1)+"."+T.slice(D+1):T+new Array(D-T.length+2).join("0")},pn={"%":function(m,d){return(100*m).toFixed(d)},b:function(m){return Math.round(m).toString(2)},c:function(m){return m+""},d:function(m){return Math.round(m).toString(10)},e:function(m,d){return m.toExponential(d)},f:function(m,d){return m.toFixed(d)},g:function(m,d){return m.toPrecision(d)},o:function(m){return Math.round(m).toString(8)},p:function(m,d){return ct(100*m,d)},r:ct,s:nt,X:function(m){return Math.round(m).toString(16).toUpperCase()},x:function(m){return Math.round(m).toString(16)}},Tn=function(m){return m},Jn=Array.prototype.map,Ui=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],kn=function(m){var d=m.grouping===void 0||m.thousands===void 0?Tn:on(Jn.call(m.grouping,Number),m.thousands+""),b=m.currency===void 0?"":m.currency[0]+"",T=m.currency===void 0?"":m.currency[1]+"",D=m.decimal===void 0?".":m.decimal+"",z=m.numerals===void 0?Tn:dn(Jn.call(m.numerals,String)),j=m.percent===void 0?"%":m.percent+"",U=m.minus===void 0?"-":m.minus+"",$=m.nan===void 0?"NaN":m.nan+"";function ae(me){var Te=(me=et(me)).fill,xe=me.align,St=me.sign,Yt=me.symbol,ln=me.zero,Ut=me.width,xt=me.comma,Et=me.precision,Jt=me.trim,zt=me.type;zt==="n"?(xt=!0,zt="g"):pn[zt]||(Et===void 0&&(Et=12),Jt=!0,zt="g"),(ln||Te==="0"&&xe==="=")&&(ln=!0,Te="0",xe="=");var Xn=Yt==="$"?b:Yt==="#"&&/[boxX]/.test(zt)?"0"+zt.toLowerCase():"",xn=Yt==="$"?T:/[%p]/.test(zt)?j:"",Pn=pn[zt],mi=/[defgprs%]/.test(zt);function ut(ot){var Pt,yt,wn,vt=Xn,Un=xn;if(zt==="c")Un=Pn(ot)+Un,ot="";else{var ii=(ot=+ot)<0;if(ot=isNaN(ot)?$:Pn(Math.abs(ot),Et),Jt&&(ot=Ue(ot)),ii&&+ot==0&&(ii=!1),vt=(ii?St==="("?St:U:St==="-"||St==="("?"":St)+vt,Un=(zt==="s"?Ui[8+Re/3]:"")+Un+(ii&&St==="("?")":""),mi){for(Pt=-1,yt=ot.length;++Pt(wn=ot.charCodeAt(Pt))||wn>57){Un=(wn===46?D+ot.slice(Pt+1):ot.slice(Pt))+Un,ot=ot.slice(0,Pt);break}}}xt&&!ln&&(ot=d(ot,1/0));var Ri=vt.length+ot.length+Un.length,Je=Ri>1)+vt+ot+Un+Je.slice(Ri);break;default:ot=Je+vt+ot+Un}return z(ot)}return Et=Et===void 0?6:/[gprs]/.test(zt)?Math.max(1,Math.min(21,Et)):Math.max(0,Math.min(20,Et)),ut.toString=function(){return me+""},ut}return{format:ae,formatPrefix:function(me,Te){var xe=ae(((me=et(me)).type="f",me)),St=3*Math.max(-8,Math.min(8,Math.floor(dt(Te)/3))),Yt=Math.pow(10,-St),ln=Ui[8+St/3];return function(Ut){return xe(Yt*Ut)+ln}}}};en({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"});var is=function(m){return Math.max(0,-dt(Math.abs(m)))},qi=function(m,d){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(dt(d)/3)))-dt(Math.abs(m)))},wf=function(m,d){return m=Math.abs(m),d=Math.abs(d)-m,Math.max(0,dt(d)-dt(m))+1};function Ta(){var m,d,b=zs().unknown(void 0),T=b.domain,D=b.range,z=0,j=1,U=!1,$=0,ae=0,me=.5;function Te(){var xe=T().length,St=j0?(U=Math.floor(U/T)*T,$=Math.ceil($/T)*T,T=L(U,$,b)):T<0&&(U=Math.ceil(U*T)/T,$=Math.floor($*T)/T,T=L(U,$,b)),T>0?(D[z]=Math.floor(U/T)*T,D[j]=Math.ceil($/T)*T,d(D)):T<0&&(D[z]=Math.ceil(U*T)/T,D[j]=Math.floor($*T)/T,d(D)),m},m}function vo(){var m=Cm();return m.copy=function(){return sv(m,vo())},Pa.apply(m,arguments),Sf(m)}function xo(){}var Ra=function(m,d,b){m.prototype=d.prototype=b,b.constructor=m};function K(m,d){var b=Object.create(m.prototype);for(var T in d)b[T]=d[T];return b}var ye=.7,Ee=1/ye,_e="\\s*([+-]?\\d+)\\s*",Ae="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",st="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Lt=/^#([0-9a-f]{3})$/,Ot=/^#([0-9a-f]{6})$/,qt=new RegExp("^rgb\\("+[_e,_e,_e]+"\\)$"),tn=new RegExp("^rgb\\("+[st,st,st]+"\\)$"),nn=new RegExp("^rgba\\("+[_e,_e,_e,Ae]+"\\)$"),rn=new RegExp("^rgba\\("+[st,st,st,Ae]+"\\)$"),$n=new RegExp("^hsl\\("+[Ae,st,st]+"\\)$"),Ti=new RegExp("^hsla\\("+[Ae,st,st,Ae]+"\\)$"),vr={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};function Br(){return this.rgb().formatHex()}function vn(){return al(this).formatHsl()}function Ht(){return this.rgb().formatRgb()}function _n(m){var d;return m=(m+"").trim().toLowerCase(),(d=Lt.exec(m))?new jn((d=parseInt(d[1],16))>>8&15|d>>4&240,d>>4&15|240&d,(15&d)<<4|15&d,1):(d=Ot.exec(m))?Gt(parseInt(d[1],16)):(d=qt.exec(m))?new jn(d[1],d[2],d[3],1):(d=tn.exec(m))?new jn(255*d[1]/100,255*d[2]/100,255*d[3]/100,1):(d=nn.exec(m))?ir(d[1],d[2],d[3],d[4]):(d=rn.exec(m))?ir(255*d[1]/100,255*d[2]/100,255*d[3]/100,d[4]):(d=$n.exec(m))?xr(d[1],d[2]/100,d[3]/100,1):(d=Ti.exec(m))?xr(d[1],d[2]/100,d[3]/100,d[4]):vr.hasOwnProperty(m)?Gt(vr[m]):m==="transparent"?new jn(NaN,NaN,NaN,0):null}function Gt(m){return new jn(m>>16&255,m>>8&255,255&m,1)}function ir(m,d,b,T){return T<=0&&(m=d=b=NaN),new jn(m,d,b,T)}function xi(m){return m instanceof xo||(m=_n(m)),m?new jn((m=m.rgb()).r,m.g,m.b,m.opacity):new jn}function fi(m,d,b,T){return arguments.length===1?xi(m):new jn(m,d,b,T??1)}function jn(m,d,b,T){this.r=+m,this.g=+d,this.b=+b,this.opacity=+T}function ei(){return"#"+wo(this.r)+wo(this.g)+wo(this.b)}function ti(){var m=this.opacity;return((m=isNaN(m)?1:Math.max(0,Math.min(1,m)))===1?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(m===1?")":", "+m+")")}function wo(m){return((m=Math.max(0,Math.min(255,Math.round(m)||0)))<16?"0":"")+m.toString(16)}function xr(m,d,b,T){return T<=0?m=d=b=NaN:b<=0||b>=1?m=d=NaN:d<=0&&(m=NaN),new Vr(m,d,b,T)}function al(m){if(m instanceof Vr)return new Vr(m.h,m.s,m.l,m.opacity);if(m instanceof xo||(m=_n(m)),!m)return new Vr;if(m instanceof Vr)return m;var d=(m=m.rgb()).r/255,b=m.g/255,T=m.b/255,D=Math.min(d,b,T),z=Math.max(d,b,T),j=NaN,U=z-D,$=(z+D)/2;return U?(j=d===z?(b-T)/U+6*(b0&&$<1?0:j,new Vr(j,U,$,m.opacity)}function $l(m,d,b,T){return arguments.length===1?al(m):new Vr(m,d,b,T??1)}function Vr(m,d,b,T){this.h=+m,this.s=+d,this.l=+b,this.opacity=+T}function rs(m,d,b){return 255*(m<60?d+(b-d)*m/60:m<180?b:m<240?d+(b-d)*(240-m)/60:d)}Ra(xo,_n,{copy:function(m){return Object.assign(new this.constructor,this,m)},displayable:function(){return this.rgb().displayable()},hex:Br,formatHex:Br,formatHsl:vn,formatRgb:Ht,toString:Ht}),Ra(jn,fi,K(xo,{brighter:function(m){return m=m==null?Ee:Math.pow(Ee,m),new jn(this.r*m,this.g*m,this.b*m,this.opacity)},darker:function(m){return m=m==null?ye:Math.pow(ye,m),new jn(this.r*m,this.g*m,this.b*m,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ei,formatHex:ei,formatRgb:ti,toString:ti})),Ra(Vr,$l,K(xo,{brighter:function(m){return m=m==null?Ee:Math.pow(Ee,m),new Vr(this.h,this.s,this.l*m,this.opacity)},darker:function(m){return m=m==null?ye:Math.pow(ye,m),new Vr(this.h,this.s,this.l*m,this.opacity)},rgb:function(){var m=this.h%360+360*(this.h<0),d=isNaN(m)||isNaN(this.s)?0:this.s,b=this.l,T=b+(b<.5?b:1-b)*d,D=2*b-T;return new jn(rs(m>=240?m-240:m+120,D,T),rs(m,D,T),rs(m<120?m+240:m-120,D,T),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var m=this.opacity;return((m=isNaN(m)?1:Math.max(0,Math.min(1,m)))===1?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(m===1?")":", "+m+")")}}));var Ky=Math.PI/180,Zy=180/Math.PI,_f=18,_u=.96422,Mu=1,ec=.82521,Au=4/29,tc=6/29,Jy=3*tc*tc,_m=tc*tc*tc;function Mf(m){if(m instanceof So)return new So(m.l,m.a,m.b,m.opacity);if(m instanceof $o)return zi(m);m instanceof jn||(m=xi(m));var d,b,T=Tu(m.r),D=Tu(m.g),z=Tu(m.b),j=Eu((.2225045*T+.7168786*D+.0606169*z)/Mu);return T===D&&D===z?d=b=j:(d=Eu((.4360747*T+.3850649*D+.1430804*z)/_u),b=Eu((.0139322*T+.0971045*D+.7141733*z)/ec)),new So(116*j-16,500*(d-j),200*(j-b),m.opacity)}function bu(m,d,b,T){return arguments.length===1?Mf(m):new So(m,d,b,T??1)}function So(m,d,b,T){this.l=+m,this.a=+d,this.b=+b,this.opacity=+T}function Eu(m){return m>_m?Math.pow(m,1/3):m/Jy+Au}function bn(m){return m>tc?m*m*m:Jy*(m-Au)}function Af(m){return 255*(m<=.0031308?12.92*m:1.055*Math.pow(m,1/2.4)-.055)}function Tu(m){return(m/=255)<=.04045?m/12.92:Math.pow((m+.055)/1.055,2.4)}function Qy(m){if(m instanceof $o)return new $o(m.h,m.c,m.l,m.opacity);if(m instanceof So||(m=Mf(m)),m.a===0&&m.b===0)return new $o(NaN,0180||b<-180?b-360*Math.round(b/360):b):ll(isNaN(m)?d:m)}function Ao(m){return(m=+m)==1?nc:function(d,b){return b-d?tv(d,b,m):ll(isNaN(d)?b:d)}}function nc(m,d){var b=d-m;return b?Tf(m,b):ll(isNaN(m)?d:m)}var ll=function(m){return function(){return m}},nv=function m(d){var b=Ao(d);function T(D,z){var j=b((D=fi(D)).r,(z=fi(z)).r),U=b(D.g,z.g),$=b(D.b,z.b),ae=nc(D.opacity,z.opacity);return function(me){return D.r=j(me),D.g=U(me),D.b=$(me),D.opacity=ae(me),D+""}}return T.gamma=m,T}(1),Hs=function(m,d){var b,T=d?d.length:0,D=m?Math.min(T,m.length):0,z=new Array(D),j=new Array(T);for(b=0;bz&&(D=d.slice(z,D),U[j]?U[j]+=D:U[++j]=D),(b=b[0])===(T=T[0])?U[j]?U[j]+=T:U[++j]=T:(U[++j]=null,$.push({i:j,x:cl(b,T)})),z=Ru.lastIndex;return zd&&(b=m,m=d,d=b),function(T){return Math.max(m,Math.min(d,T))}}function rv(m,d,b){var T=m[0],D=m[1],z=d[0],j=d[1];return D2?Rf:rv,D=z=null,Te}function Te(xe){return isNaN(xe=+xe)?b:(D||(D=T(j.map(m),U,$)))(m(ae(xe)))}return Te.invert=function(xe){return ae(d((z||(z=T(U,j.map(m),cl)))(xe)))},Te.domain=function(xe){return arguments.length?(j=Array.from(xe,Em),me()):j.slice()},Te.range=function(xe){return arguments.length?(U=Array.from(xe),me()):U.slice()},Te.rangeRound=function(xe){return U=Array.from(xe),$=As,me()},Te.clamp=function(xe){return arguments.length?(ae=!!xe||Hr,me()):ae!==Hr},Te.interpolate=function(xe){return arguments.length?($=xe,me()):$},Te.unknown=function(xe){return arguments.length?(b=xe,Te):b},function(xe,St){return m=xe,d=St,me()}}function Cm(){return ov()(Hr,Hr)}var kf=function(m,d,b,T){var D,z=F(m,d,b);switch((T=et(T??",f")).type){case"s":var j=Math.max(Math.abs(m),Math.abs(d));return T.precision!=null||isNaN(D=qi(z,j))||(T.precision=D),kt(T,j);case"":case"e":case"g":case"p":case"r":T.precision!=null||isNaN(D=wf(z,Math.max(Math.abs(m),Math.abs(d))))||(T.precision=D-(T.type==="e"));break;case"f":case"%":T.precision!=null||isNaN(D=is(z))||(T.precision=D-2*(T.type==="%"))}return Ze(T)},Lf=new Date,If=new Date;function Bi(m,d,b,T){function D(z){return m(z=new Date(+z)),z}return D.floor=D,D.ceil=function(z){return m(z=new Date(z-1)),d(z,1),m(z),z},D.round=function(z){var j=D(z),U=D.ceil(z);return z-j0))return ae;do ae.push($=new Date(+z)),d(z,U),m(z);while($=j)for(;m(j),!z(j);)j.setTime(j-1)},function(j,U){if(j>=j)if(U<0)for(;++U<=0;)for(;d(j,-1),!z(j););else for(;--U>=0;)for(;d(j,1),!z(j););})},b&&(D.count=function(z,j){return Lf.setTime(+z),If.setTime(+j),m(Lf),m(If),Math.floor(b(Lf,If))},D.every=function(z){return z=Math.floor(z),isFinite(z)&&z>0?z>1?D.filter(T?function(j){return T(j)%z==0}:function(j){return D.count(0,j)%z==0}):D:null}),D}var ku=Bi(function(){},function(m,d){m.setTime(+m+d)},function(m,d){return d-m});ku.every=function(m){return m=Math.floor(m),isFinite(m)&&m>0?m>1?Bi(function(d){d.setTime(Math.floor(d/m)*m)},function(d,b){d.setTime(+d+b*m)},function(d,b){return(b-d)/m}):ku:null},ku.range;var ea=1e3,bs=6e4,ul=36e5,Lu=864e5,ss=6048e5,Es=Bi(function(m){m.setTime(m-m.getMilliseconds())},function(m,d){m.setTime(+m+d*ea)},function(m,d){return(d-m)/ea},function(m){return m.getUTCSeconds()});Es.range;var hl=Bi(function(m){m.setTime(m-m.getMilliseconds()-m.getSeconds()*ea)},function(m,d){m.setTime(+m+d*bs)},function(m,d){return(d-m)/bs},function(m){return m.getMinutes()});hl.range;var ta=Bi(function(m){m.setTime(m-m.getMilliseconds()-m.getSeconds()*ea-m.getMinutes()*bs)},function(m,d){m.setTime(+m+d*ul)},function(m,d){return(d-m)/ul},function(m){return m.getHours()});ta.range;var Ws=Bi(function(m){m.setHours(0,0,0,0)},function(m,d){m.setDate(m.getDate()+d)},function(m,d){return(d-m-(d.getTimezoneOffset()-m.getTimezoneOffset())*bs)/Lu},function(m){return m.getDate()-1});Ws.range;function os(m){return Bi(function(d){d.setDate(d.getDate()-(d.getDay()+7-m)%7),d.setHours(0,0,0,0)},function(d,b){d.setDate(d.getDate()+7*b)},function(d,b){return(b-d-(b.getTimezoneOffset()-d.getTimezoneOffset())*bs)/ss})}var Pm=os(0),rc=os(1),Rm=os(2),as=os(3),wr=os(4),ni=os(5),Iu=os(6);Pm.range,rc.range,Rm.range,as.range,wr.range,ni.range,Iu.range;var js=Bi(function(m){m.setDate(1),m.setHours(0,0,0,0)},function(m,d){m.setMonth(m.getMonth()+d)},function(m,d){return d.getMonth()-m.getMonth()+12*(d.getFullYear()-m.getFullYear())},function(m){return m.getMonth()});js.range;var Da=Bi(function(m){m.setMonth(0,1),m.setHours(0,0,0,0)},function(m,d){m.setFullYear(m.getFullYear()+d)},function(m,d){return d.getFullYear()-m.getFullYear()},function(m){return m.getFullYear()});Da.every=function(m){return isFinite(m=Math.floor(m))&&m>0?Bi(function(d){d.setFullYear(Math.floor(d.getFullYear()/m)*m),d.setMonth(0,1),d.setHours(0,0,0,0)},function(d,b){d.setFullYear(d.getFullYear()+b*m)}):null},Da.range;var av=Bi(function(m){m.setUTCSeconds(0,0)},function(m,d){m.setTime(+m+d*bs)},function(m,d){return(d-m)/bs},function(m){return m.getUTCMinutes()});av.range;var km=Bi(function(m){m.setUTCMinutes(0,0,0)},function(m,d){m.setTime(+m+d*ul)},function(m,d){return(d-m)/ul},function(m){return m.getUTCHours()});km.range;var Du=Bi(function(m){m.setUTCHours(0,0,0,0)},function(m,d){m.setUTCDate(m.getUTCDate()+d)},function(m,d){return(d-m)/Lu},function(m){return m.getUTCDate()-1});Du.range;function Oa(m){return Bi(function(d){d.setUTCDate(d.getUTCDate()-(d.getUTCDay()+7-m)%7),d.setUTCHours(0,0,0,0)},function(d,b){d.setUTCDate(d.getUTCDate()+7*b)},function(d,b){return(b-d)/ss})}var sc=Oa(0),na=Oa(1),Lm=Oa(2),Ou=Oa(3),fl=Oa(4),lv=Oa(5),cv=Oa(6);sc.range,na.range,Lm.range,Ou.range,fl.range,lv.range,cv.range;var oc=Bi(function(m){m.setUTCDate(1),m.setUTCHours(0,0,0,0)},function(m,d){m.setUTCMonth(m.getUTCMonth()+d)},function(m,d){return d.getUTCMonth()-m.getUTCMonth()+12*(d.getUTCFullYear()-m.getUTCFullYear())},function(m){return m.getUTCMonth()});oc.range;var Na=Bi(function(m){m.setUTCMonth(0,1),m.setUTCHours(0,0,0,0)},function(m,d){m.setUTCFullYear(m.getUTCFullYear()+d)},function(m,d){return d.getUTCFullYear()-m.getUTCFullYear()},function(m){return m.getUTCFullYear()});Na.every=function(m){return isFinite(m=Math.floor(m))&&m>0?Bi(function(d){d.setUTCFullYear(Math.floor(d.getUTCFullYear()/m)*m),d.setUTCMonth(0,1),d.setUTCHours(0,0,0,0)},function(d,b){d.setUTCFullYear(d.getUTCFullYear()+b*m)}):null},Na.range;var Eo,ls,ac;function lc(m){return Eo=uv(m),Eo.format,Eo.parse,ls=Eo.utcFormat,ac=Eo.utcParse,Eo}function To(m){if(0<=m.y&&m.y<100){var d=new Date(-1,m.m,m.d,m.H,m.M,m.S,m.L);return d.setFullYear(m.y),d}return new Date(m.y,m.m,m.d,m.H,m.M,m.S,m.L)}function cc(m){if(0<=m.y&&m.y<100){var d=new Date(Date.UTC(-1,m.m,m.d,m.H,m.M,m.S,m.L));return d.setUTCFullYear(m.y),d}return new Date(Date.UTC(m.y,m.m,m.d,m.H,m.M,m.S,m.L))}function Co(m){return{y:m,m:0,d:1,H:0,M:0,S:0,L:0}}function uv(m){var d=m.dateTime,b=m.date,T=m.time,D=m.periods,z=m.days,j=m.shortDays,U=m.months,$=m.shortMonths,ae=Sr(D),me=Po(D),Te=Sr(z),xe=Po(z),St=Sr(j),Yt=Po(j),ln=Sr(U),Ut=Po(U),xt=Sr($),Et=Po($),Jt={a:function(ut){return j[ut.getDay()]},A:function(ut){return z[ut.getDay()]},b:function(ut){return $[ut.getMonth()]},B:function(ut){return U[ut.getMonth()]},c:null,d:Nm,e:Nm,f:gv,H:pv,I:mv,j:Fm,L:uc,m:Vf,M:Hf,p:function(ut){return D[+(ut.getHours()>=12)]},Q:Wm,s:jm,S:Um,u:Uu,U:yv,V:vv,w:xv,W:wv,x:null,X:null,y:zm,Y:Sv,Z:_v,"%":Gm},zt={a:function(ut){return j[ut.getUTCDay()]},A:function(ut){return z[ut.getUTCDay()]},b:function(ut){return $[ut.getUTCMonth()]},B:function(ut){return U[ut.getUTCMonth()]},c:null,d:Mv,e:Mv,f:bv,H:Av,I:pM,j:mM,L:Bm,m:Ev,M:Tv,p:function(ut){return D[+(ut.getUTCHours()>=12)]},Q:Wm,s:jm,S:Gf,u:gM,U:yM,V:vM,w:Vm,W:Hm,x:null,X:null,y:xM,Y:Cv,Z:Pv,"%":Gm},Xn={a:function(ut,ot,Pt){var yt=St.exec(ot.slice(Pt));return yt?(ut.w=Yt[yt[0].toLowerCase()],Pt+yt[0].length):-1},A:function(ut,ot,Pt){var yt=Te.exec(ot.slice(Pt));return yt?(ut.w=xe[yt[0].toLowerCase()],Pt+yt[0].length):-1},b:function(ut,ot,Pt){var yt=xt.exec(ot.slice(Pt));return yt?(ut.m=Et[yt[0].toLowerCase()],Pt+yt[0].length):-1},B:function(ut,ot,Pt){var yt=ln.exec(ot.slice(Pt));return yt?(ut.m=Ut[yt[0].toLowerCase()],Pt+yt[0].length):-1},c:function(ut,ot,Pt){return mi(ut,d,ot,Pt)},d:Uf,e:Uf,f:Bf,H:Ro,I:Ro,j:Om,L:zf,m:Dm,M:ko,p:function(ut,ot,Pt){var yt=ae.exec(ot.slice(Pt));return yt?(ut.p=me[yt[0].toLowerCase()],Pt+yt[0].length):-1},Q:fv,s:dv,S:dl,u:_r,U:Yi,V:Ff,w:di,W:Nu,x:function(ut,ot,Pt){return mi(ut,b,ot,Pt)},X:function(ut,ot,Pt){return mi(ut,T,ot,Pt)},y:dM,Y:Fu,Z:Mr,"%":hv};function xn(ut,ot){return function(Pt){var yt,wn,vt,Un=[],ii=-1,Ri=0,Je=ut.length;for(Pt instanceof Date||(Pt=new Date(+Pt));++ii53)return null;"w"in vt||(vt.w=1),"Z"in vt?(wn=(yt=cc(Co(vt.y))).getUTCDay(),yt=wn>4||wn===0?na.ceil(yt):na(yt),yt=Du.offset(yt,7*(vt.V-1)),vt.y=yt.getUTCFullYear(),vt.m=yt.getUTCMonth(),vt.d=yt.getUTCDate()+(vt.w+6)%7):(wn=(yt=ot(Co(vt.y))).getDay(),yt=wn>4||wn===0?rc.ceil(yt):rc(yt),yt=Ws.offset(yt,7*(vt.V-1)),vt.y=yt.getFullYear(),vt.m=yt.getMonth(),vt.d=yt.getDate()+(vt.w+6)%7)}else("W"in vt||"U"in vt)&&("w"in vt||(vt.w="u"in vt?vt.u%7:"W"in vt?1:0),wn="Z"in vt?cc(Co(vt.y)).getUTCDay():ot(Co(vt.y)).getDay(),vt.m=0,vt.d="W"in vt?(vt.w+6)%7+7*vt.W-(wn+5)%7:vt.w+7*vt.U-(wn+6)%7);return"Z"in vt?(vt.H+=vt.Z/100|0,vt.M+=vt.Z%100,cc(vt)):ot(vt)}}function mi(ut,ot,Pt,yt){for(var wn,vt,Un=0,ii=ot.length,Ri=Pt.length;Un=Ri)return-1;if((wn=ot.charCodeAt(Un++))===37){if(wn=ot.charAt(Un++),!(vt=Xn[wn in Df?ot.charAt(Un++):wn])||(yt=vt(ut,Pt,yt))<0)return-1}else if(wn!=Pt.charCodeAt(yt++))return-1}return yt}return Jt.x=xn(b,Jt),Jt.X=xn(T,Jt),Jt.c=xn(d,Jt),zt.x=xn(b,zt),zt.X=xn(T,zt),zt.c=xn(d,zt),{format:function(ut){var ot=xn(ut+="",Jt);return ot.toString=function(){return ut},ot},parse:function(ut){var ot=Pn(ut+="",To);return ot.toString=function(){return ut},ot},utcFormat:function(ut){var ot=xn(ut+="",zt);return ot.toString=function(){return ut},ot},utcParse:function(ut){var ot=Pn(ut,cc);return ot.toString=function(){return ut},ot}}}var Df={"-":"",_:" ",0:"0"},mn=/^\s*\d+/,Of=/^%/,Im=/[\\^$*+?|[\]().{}]/g;function Fn(m,d,b){var T=m<0?"-":"",D=(T?-m:m)+"",z=D.length;return T+(z68?1900:2e3),b+T[0].length):-1}function Mr(m,d,b){var T=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(d.slice(b,b+6));return T?(m.Z=T[1]?0:-(T[2]+(T[3]||"00")),b+T[0].length):-1}function Dm(m,d,b){var T=mn.exec(d.slice(b,b+2));return T?(m.m=T[0]-1,b+T[0].length):-1}function Uf(m,d,b){var T=mn.exec(d.slice(b,b+2));return T?(m.d=+T[0],b+T[0].length):-1}function Om(m,d,b){var T=mn.exec(d.slice(b,b+3));return T?(m.m=0,m.d=+T[0],b+T[0].length):-1}function Ro(m,d,b){var T=mn.exec(d.slice(b,b+2));return T?(m.H=+T[0],b+T[0].length):-1}function ko(m,d,b){var T=mn.exec(d.slice(b,b+2));return T?(m.M=+T[0],b+T[0].length):-1}function dl(m,d,b){var T=mn.exec(d.slice(b,b+2));return T?(m.S=+T[0],b+T[0].length):-1}function zf(m,d,b){var T=mn.exec(d.slice(b,b+3));return T?(m.L=+T[0],b+T[0].length):-1}function Bf(m,d,b){var T=mn.exec(d.slice(b,b+6));return T?(m.L=Math.floor(T[0]/1e3),b+T[0].length):-1}function hv(m,d,b){var T=Of.exec(d.slice(b,b+1));return T?b+T[0].length:-1}function fv(m,d,b){var T=mn.exec(d.slice(b));return T?(m.Q=+T[0],b+T[0].length):-1}function dv(m,d,b){var T=mn.exec(d.slice(b));return T?(m.Q=1e3*+T[0],b+T[0].length):-1}function Nm(m,d){return Fn(m.getDate(),d,2)}function pv(m,d){return Fn(m.getHours(),d,2)}function mv(m,d){return Fn(m.getHours()%12||12,d,2)}function Fm(m,d){return Fn(1+Ws.count(Da(m),m),d,3)}function uc(m,d){return Fn(m.getMilliseconds(),d,3)}function gv(m,d){return uc(m,d)+"000"}function Vf(m,d){return Fn(m.getMonth()+1,d,2)}function Hf(m,d){return Fn(m.getMinutes(),d,2)}function Um(m,d){return Fn(m.getSeconds(),d,2)}function Uu(m){var d=m.getDay();return d===0?7:d}function yv(m,d){return Fn(Pm.count(Da(m),m),d,2)}function vv(m,d){var b=m.getDay();return m=b>=4||b===0?wr(m):wr.ceil(m),Fn(wr.count(Da(m),m)+(Da(m).getDay()===4),d,2)}function xv(m){return m.getDay()}function wv(m,d){return Fn(rc.count(Da(m),m),d,2)}function zm(m,d){return Fn(m.getFullYear()%100,d,2)}function Sv(m,d){return Fn(m.getFullYear()%1e4,d,4)}function _v(m){var d=m.getTimezoneOffset();return(d>0?"-":(d*=-1,"+"))+Fn(d/60|0,"0",2)+Fn(d%60,"0",2)}function Mv(m,d){return Fn(m.getUTCDate(),d,2)}function Av(m,d){return Fn(m.getUTCHours(),d,2)}function pM(m,d){return Fn(m.getUTCHours()%12||12,d,2)}function mM(m,d){return Fn(1+Du.count(Na(m),m),d,3)}function Bm(m,d){return Fn(m.getUTCMilliseconds(),d,3)}function bv(m,d){return Bm(m,d)+"000"}function Ev(m,d){return Fn(m.getUTCMonth()+1,d,2)}function Tv(m,d){return Fn(m.getUTCMinutes(),d,2)}function Gf(m,d){return Fn(m.getUTCSeconds(),d,2)}function gM(m){var d=m.getUTCDay();return d===0?7:d}function yM(m,d){return Fn(sc.count(Na(m),m),d,2)}function vM(m,d){var b=m.getUTCDay();return m=b>=4||b===0?fl(m):fl.ceil(m),Fn(fl.count(Na(m),m)+(Na(m).getUTCDay()===4),d,2)}function Vm(m){return m.getUTCDay()}function Hm(m,d){return Fn(na.count(Na(m),m),d,2)}function xM(m,d){return Fn(m.getUTCFullYear()%100,d,2)}function Cv(m,d){return Fn(m.getUTCFullYear()%1e4,d,4)}function Pv(){return"+0000"}function Gm(){return"%"}function Wm(m){return+m}function jm(m){return Math.floor(+m/1e3)}lc({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var Xs="%Y-%m-%dT%H:%M:%S.%LZ";function Rv(m){return m.toISOString()}Date.prototype.toISOString||ls(Xs);function zu(m){var d=new Date(m);return isNaN(d)?null:d}+new Date("2000-01-01T00:00:00.000Z")||ac(Xs);function Bu(m){return function(){var d=this.ownerDocument,b=this.namespaceURI;return b===hc&&d.documentElement.namespaceURI===hc?d.createElement(m):d.createElementNS(b,m)}}function Wf(m){return function(){return this.ownerDocument.createElementNS(m.space,m.local)}}var hc="http://www.w3.org/1999/xhtml",Xm={svg:"http://www.w3.org/2000/svg",xhtml:hc,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},fc=function(m){var d=m+="",b=d.indexOf(":");return b>=0&&(d=m.slice(0,b))!=="xmlns"&&(m=m.slice(b+1)),Xm.hasOwnProperty(d)?{space:Xm[d],local:m}:m},rr=function(m){var d=fc(m);return(d.local?Wf:Bu)(d)};function wM(){}var kv=function(m){return m==null?wM:function(){return this.querySelector(m)}},cs=function(m){typeof m!="function"&&(m=kv(m));for(var d=this._groups,b=d.length,T=new Array(b),D=0;D=zt&&(zt=Jt+1);!(Et=Ut[zt])&&++zt=0;)(T=D[z])&&(j&&4^T.compareDocumentPosition(j)&&j.parentNode.insertBefore(T,j),j=T);return this},qf=function(m){function d(Te,xe){return Te&&xe?m(Te.__data__,xe.__data__):!Te-!xe}m||(m=Bv);for(var b=this._groups,T=b.length,D=new Array(T),z=0;zd?1:m>=d?0:NaN}var Qm=function(){var m=arguments[0];return arguments[0]=this,m.apply(null,arguments),this},Vv=function(){var m=new Array(this.size()),d=-1;return this.each(function(){m[++d]=this}),m},ia=function(){for(var m=this._groups,d=0,b=m.length;d1?this.each((d==null?ml:typeof d=="function"?eg:Hu)(m,d,b??"")):Wv(this.node(),m)};function Wv(m,d){return m.style.getPropertyValue(d)||tg(m).getComputedStyle(m,null).getPropertyValue(d)}function jv(m){return function(){delete this[m]}}function Xv(m,d){return function(){this[m]=d}}function qv(m,d){return function(){var b=d.apply(this,arguments);b==null?delete this[m]:this[m]=b}}var ng=function(m,d){return arguments.length>1?this.each((d==null?jv:typeof d=="function"?qv:Xv)(m,d)):this.node()[m]};function Zf(m){return m.trim().split(/^|\s+/)}function Jf(m){return m.classList||new Qf(m)}function Qf(m){this._node=m,this._names=Zf(m.getAttribute("class")||"")}function Gu(m,d){for(var b=Jf(m),T=-1,D=d.length;++T=0&&(this._names.splice(d,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(m){return this._names.indexOf(m)>=0}};var Jv=function(m,d){var b=Zf(m+"");if(arguments.length<2){for(var T=Jf(this.node()),D=-1,z=b.length;++D=0&&(b=d.slice(T+1),d=d.slice(0,T)),{type:d,name:b}})}function qu(m){return function(){var d=this.__on;if(d){for(var b,T=0,D=-1,z=d.length;TB&&typeof B=="object"&&B.baseVal&&B.baseVal.value?B.baseVal.value:B||100;return this.surface?[k(this.surface.width),k(this.surface.height)]:[100,100]}computePolygonSize(k){if(k.length){let B=k[0][0],G=k[0][0],V=k[0][1],Y=k[0][1];for(let J=1;J0?wt-=2*Math.PI:J&&wt<0&&(wt+=2*Math.PI),this._numSegs=Math.ceil(Math.abs(wt/(Math.PI/2))),this._delta=wt/this._numSegs,this._T=8/3*Math.sin(this._delta/4)*Math.sin(this._delta/4)/Math.sin(this._delta/2)}getNextSegment(){if(this._segIndex===this._numSegs)return null;const k=Math.cos(this._theta),B=Math.sin(this._theta),G=this._theta+this._delta,V=Math.cos(G),Y=Math.sin(G),J=[this._cosPhi*this._rx*V-this._sinPhi*this._ry*Y+this._C[0],this._sinPhi*this._rx*V+this._cosPhi*this._ry*Y+this._C[1]],ue=[this._from[0]+this._T*(-this._cosPhi*this._rx*B-this._sinPhi*this._ry*k),this._from[1]+this._T*(-this._sinPhi*this._rx*B+this._cosPhi*this._ry*k)],ve=[J[0]+this._T*(this._cosPhi*this._rx*Y+this._sinPhi*this._ry*V),J[1]+this._T*(this._sinPhi*this._rx*Y-this._cosPhi*this._ry*V)];return this._theta=G,this._from=[J[0],J[1]],this._segIndex++,{cp1:ue,cp2:ve,to:J}}calculateVectorAngle(k,B,G,V){const Y=Math.atan2(B,k),J=Math.atan2(V,G);return J>=Y?J-Y:2*Math.PI-(Y-J)}}class U{constructor(k,B){this.sets=k,this.closed=B}fit(k){const B=[];for(const V of this.sets){const Y=V.length;let J=Math.floor(k*Y);if(J<5){if(Y<=5)continue;J=5}B.push(this.reduce(V,J))}let G="";for(const V of B){for(let Y=0;YB;){let V=-1,Y=-1;for(let J=1;J0))break;G.splice(Y,1)}return G}}class ${constructor(k,B){this.xi=Number.MAX_VALUE,this.yi=Number.MAX_VALUE,this.px1=k[0],this.py1=k[1],this.px2=B[0],this.py2=B[1],this.a=this.py2-this.py1,this.b=this.px1-this.px2,this.c=this.px2*this.py1-this.px1*this.py2,this._undefined=this.a===0&&this.b===0&&this.c===0}isUndefined(){return this._undefined}intersects(k){if(this.isUndefined()||k.isUndefined())return!1;let B=Number.MAX_VALUE,G=Number.MAX_VALUE,V=0,Y=0;const J=this.a,ue=this.b,ve=this.c;return Math.abs(ue)>1e-5&&(B=-J/ue,V=-ve/ue),Math.abs(k.b)>1e-5&&(G=-k.a/k.b,Y=-k.c/k.b),B===Number.MAX_VALUE?G===Number.MAX_VALUE?-ve/J==-k.c/k.a&&(this.py1>=Math.min(k.py1,k.py2)&&this.py1<=Math.max(k.py1,k.py2)?(this.xi=this.px1,this.yi=this.py1,!0):this.py2>=Math.min(k.py1,k.py2)&&this.py2<=Math.max(k.py1,k.py2)&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=G*this.xi+Y,!((this.py1-this.yi)*(this.yi-this.py2)<-1e-5||(k.py1-this.yi)*(this.yi-k.py2)<-1e-5||Math.abs(k.a)<1e-5&&(k.px1-this.xi)*(this.xi-k.px2)<-1e-5)):G===Number.MAX_VALUE?(this.xi=k.px1,this.yi=B*this.xi+V,!((k.py1-this.yi)*(this.yi-k.py2)<-1e-5||(this.py1-this.yi)*(this.yi-this.py2)<-1e-5||Math.abs(J)<1e-5&&(this.px1-this.xi)*(this.xi-this.px2)<-1e-5)):B===G?V===Y&&(this.px1>=Math.min(k.px1,k.px2)&&this.px1<=Math.max(k.py1,k.py2)?(this.xi=this.px1,this.yi=this.py1,!0):this.px2>=Math.min(k.px1,k.px2)&&this.px2<=Math.max(k.px1,k.px2)&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(Y-V)/(B-G),this.yi=B*this.xi+V,!((this.px1-this.xi)*(this.xi-this.px2)<-1e-5||(k.px1-this.xi)*(this.xi-k.px2)<-1e-5))}}function ae(ne,k){const B=ne[1][1]-ne[0][1],G=ne[0][0]-ne[1][0],V=B*ne[0][0]+G*ne[0][1],Y=k[1][1]-k[0][1],J=k[0][0]-k[1][0],ue=Y*k[0][0]+J*k[0][1],ve=B*J-Y*G;return ve?[Math.round((J*V-G*ue)/ve),Math.round((B*ue-Y*V)/ve)]:null}class me{constructor(k,B,G,V,Y,J,ue,ve){this.deltaX=0,this.hGap=0,this.top=k,this.bottom=B,this.left=G,this.right=V,this.gap=Y,this.sinAngle=J,this.tanAngle=ve,Math.abs(J)<1e-4?this.pos=G+Y:Math.abs(J)>.9999?this.pos=k+Y:(this.deltaX=(B-k)*Math.abs(ve),this.pos=G-Math.abs(this.deltaX),this.hGap=Math.abs(Y/ue),this.sLeft=new $([G,B],[G,k]),this.sRight=new $([V,B],[V,k]))}nextLine(){if(Math.abs(this.sinAngle)<1e-4){if(this.pos.9999){if(this.posthis.right&&B>this.right;)if(this.pos+=this.hGap,k=this.pos-this.deltaX/2,B=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;const Y=new $([k,G],[B,V]);this.sLeft&&Y.intersects(this.sLeft)&&(k=Y.xi,G=Y.yi),this.sRight&&Y.intersects(this.sRight)&&(B=Y.xi,V=Y.yi),this.tanAngle>0&&(k=this.right-(k-this.left),B=this.right-(B-this.left));const J=[k,G,B,V];return this.pos+=this.hGap,J}}return null}}function Te(ne){const k=ne[0],B=ne[1];return Math.sqrt(Math.pow(k[0]-B[0],2)+Math.pow(k[1]-B[1],2))}function xe(ne,k){const B=[],G=new $([ne[0],ne[1]],[ne[2],ne[3]]);for(let V=0;V{G[0]=Math.min(G[0],qe[0]),G[1]=Math.max(G[1],qe[0]),V[0]=Math.min(V[0],qe[1]),V[1]=Math.max(V[1],qe[1])});const Y=function(qe){let _t=0,wt=0,Vt=0;for(let Qt=0;Qt0?B.hachureGap:4*B.strokeWidth,ve=[];if(k.length>2)for(let qe=0;qe{const Qt=ae(Vt,wt);Qt&&Qt[0]>=G[0]&&Qt[0]<=G[1]&&Qt[1]>=V[0]&&Qt[1]<=V[1]&&ke.push(Qt)})}ke=this.removeDuplocatePoints(ke);const Xe=this.createLinesFromCenter(Y,ke);return{type:"fillSketch",ops:this.drawLines(Xe,B)}}fillEllipse(k,B,G,V,Y){return this.fillArcSegment(k,B,G,V,0,2*Math.PI,Y)}fillArc(k,B,G,V,Y,J,ue){return this.fillArcSegment(k,B,G,V,Y,J,ue)}fillArcSegment(k,B,G,V,Y,J,ue){const ve=[k,B],ke=G/2,De=V/2,Xe=Math.max(G/2,V/2);let qe=ue.hachureGap;qe<0&&(qe=4*ue.strokeWidth);const _t=Math.max(1,Math.abs(J-Y)*Xe/qe);let wt=[];for(let Qt=0;Qt<_t;Qt++){const Sn=Qt*((J-Y)/_t)+Y,ai=Xe*Math.cos(Sn),Ir=Xe*Math.sin(Sn),Ys=Math.sqrt(ke*ke*Ir*Ir+De*De*ai*ai),vc=ke*De*ai/Ys,xc=ke*De*Ir/Ys;wt.push([ve[0]+vc,ve[1]+xc])}wt=this.removeDuplocatePoints(wt);const Vt=this.createLinesFromCenter(ve,wt);return{type:"fillSketch",ops:this.drawLines(Vt,ue)}}drawLines(k,B){let G=[];return k.forEach(V=>{const Y=V[0],J=V[1];G=G.concat(this.helper.doubleLineOps(Y[0],Y[1],J[0],J[1],B))}),G}createLinesFromCenter(k,B){return B.map(G=>[k,G])}removeDuplocatePoints(k){const B=new Set;return k.filter(G=>{const V=G.join(",");return!B.has(V)&&(B.add(V),!0)})}}class Xn{constructor(k){this.helper=k}fillPolygon(k,B){const G=Yt(k,B);return{type:"fillSketch",ops:this.dashedLine(G,B)}}fillEllipse(k,B,G,V,Y){const J=ln(this.helper,k,B,G,V,Y);return{type:"fillSketch",ops:this.dashedLine(J,Y)}}fillArc(k,B,G,V,Y,J,ue){return null}dashedLine(k,B){const G=B.dashOffset<0?B.hachureGap<0?4*B.strokeWidth:B.hachureGap:B.dashOffset,V=B.dashGap<0?B.hachureGap<0?4*B.strokeWidth:B.hachureGap:B.dashGap;let Y=[];return k.forEach(J=>{const ue=Te(J),ve=Math.floor(ue/(G+V)),ke=(ue+V-ve*(G+V))/2;let De=J[0],Xe=J[1];De[0]>Xe[0]&&(De=J[1],Xe=J[0]);const qe=Math.atan((Xe[1]-De[1])/(Xe[0]-De[0]));for(let _t=0;_t{const J=Te(Y),ue=Math.round(J/(2*B));let ve=Y[0],ke=Y[1];ve[0]>ke[0]&&(ve=Y[1],ke=Y[0]);const De=Math.atan((ke[1]-ve[1])/(ke[0]-ve[0]));for(let Xe=0;Xe2){let V=[];for(let Y=0;Y2*Math.PI&&(_t=0,wt=2*Math.PI);const Vt=2*Math.PI/ve.curveStepCount,Qt=Math.min(Vt/2,(wt-_t)/2),Sn=wd(Qt,ke,De,Xe,qe,_t,wt,1,ve),ai=wd(Qt,ke,De,Xe,qe,_t,wt,1.5,ve);let Ir=Sn.concat(ai);return J&&(ue?Ir=(Ir=Ir.concat(Lr(ke,De,ke+Xe*Math.cos(_t),De+qe*Math.sin(_t),ve))).concat(Lr(ke,De,ke+Xe*Math.cos(wt),De+qe*Math.sin(wt),ve)):(Ir.push({op:"lineTo",data:[ke,De]}),Ir.push({op:"lineTo",data:[ke+Xe*Math.cos(_t),De+qe*Math.sin(_t)]}))),{type:"path",ops:Ir}}function Un(ne,k){const B=[];if(ne.length){const G=k.maxRandomnessOffset||0,V=ne.length;if(V>2){B.push({op:"move",data:[ne[0][0]+Je(G,k),ne[0][1]+Je(G,k)]});for(let Y=1;Yue&&(ve=Math.sqrt(ue)/10);const ke=ve/2,De=.2+.2*Math.random();let Xe=V.bowing*V.maxRandomnessOffset*(G-k)/200,qe=V.bowing*V.maxRandomnessOffset*(ne-B)/200;Xe=Je(Xe,V),qe=Je(qe,V);const _t=[],wt=()=>Je(ke,V),Vt=()=>Je(ve,V);return Y&&(J?_t.push({op:"move",data:[ne+wt(),k+wt()]}):_t.push({op:"move",data:[ne+Je(ve,V),k+Je(ve,V)]})),J?_t.push({op:"bcurveTo",data:[Xe+ne+(B-ne)*De+wt(),qe+k+(G-k)*De+wt(),Xe+ne+2*(B-ne)*De+wt(),qe+k+2*(G-k)*De+wt(),B+wt(),G+wt()]}):_t.push({op:"bcurveTo",data:[Xe+ne+(B-ne)*De+Vt(),qe+k+(G-k)*De+Vt(),Xe+ne+2*(B-ne)*De+Vt(),qe+k+2*(G-k)*De+Vt(),B+Vt(),G+Vt()]}),_t}function Ju(ne,k,B){const G=[];G.push([ne[0][0]+Je(k,B),ne[0][1]+Je(k,B)]),G.push([ne[0][0]+Je(k,B),ne[0][1]+Je(k,B)]);for(let V=1;V3){const Y=[],J=1-B.curveTightness;V.push({op:"move",data:[ne[1][0],ne[1][1]]});for(let ue=1;ue+2=2){let J=+k.data[0],ue=+k.data[1];Y&&(J+=ne.x,ue+=ne.y);const ve=1*(G.maxRandomnessOffset||0);J+=Je(ve,G),ue+=Je(ve,G),ne.setPosition(J,ue),V.push({op:"move",data:[J,ue]})}break}case"L":case"l":{const Y=k.key==="l";if(k.data.length>=2){let J=+k.data[0],ue=+k.data[1];Y&&(J+=ne.x,ue+=ne.y),V=V.concat(Lr(ne.x,ne.y,J,ue,G)),ne.setPosition(J,ue)}break}case"H":case"h":{const Y=k.key==="h";if(k.data.length){let J=+k.data[0];Y&&(J+=ne.x),V=V.concat(Lr(ne.x,ne.y,J,ne.y,G)),ne.setPosition(J,ne.y)}break}case"V":case"v":{const Y=k.key==="v";if(k.data.length){let J=+k.data[0];Y&&(J+=ne.y),V=V.concat(Lr(ne.x,ne.y,ne.x,J,G)),ne.setPosition(ne.x,J)}break}case"Z":case"z":ne.first&&(V=V.concat(Lr(ne.x,ne.y,ne.first[0],ne.first[1],G)),ne.setPosition(ne.first[0],ne.first[1]),ne.first=null);break;case"C":case"c":{const Y=k.key==="c";if(k.data.length>=6){let J=+k.data[0],ue=+k.data[1],ve=+k.data[2],ke=+k.data[3],De=+k.data[4],Xe=+k.data[5];Y&&(J+=ne.x,ve+=ne.x,De+=ne.x,ue+=ne.y,ke+=ne.y,Xe+=ne.y);const qe=Qu(J,ue,ve,ke,De,Xe,ne,G);V=V.concat(qe),ne.bezierReflectionPoint=[De+(De-ve),Xe+(Xe-ke)]}break}case"S":case"s":{const Y=k.key==="s";if(k.data.length>=4){let J=+k.data[0],ue=+k.data[1],ve=+k.data[2],ke=+k.data[3];Y&&(J+=ne.x,ve+=ne.x,ue+=ne.y,ke+=ne.y);let De=J,Xe=ue;const qe=B?B.key:"";let _t=null;qe!=="c"&&qe!=="C"&&qe!=="s"&&qe!=="S"||(_t=ne.bezierReflectionPoint),_t&&(De=_t[0],Xe=_t[1]);const wt=Qu(De,Xe,J,ue,ve,ke,ne,G);V=V.concat(wt),ne.bezierReflectionPoint=[ve+(ve-J),ke+(ke-ue)]}break}case"Q":case"q":{const Y=k.key==="q";if(k.data.length>=4){let J=+k.data[0],ue=+k.data[1],ve=+k.data[2],ke=+k.data[3];Y&&(J+=ne.x,ve+=ne.x,ue+=ne.y,ke+=ne.y);const De=1*(1+.2*G.roughness),Xe=1.5*(1+.22*G.roughness);V.push({op:"move",data:[ne.x+Je(De,G),ne.y+Je(De,G)]});let qe=[ve+Je(De,G),ke+Je(De,G)];V.push({op:"qcurveTo",data:[J+Je(De,G),ue+Je(De,G),qe[0],qe[1]]}),V.push({op:"move",data:[ne.x+Je(Xe,G),ne.y+Je(Xe,G)]}),qe=[ve+Je(Xe,G),ke+Je(Xe,G)],V.push({op:"qcurveTo",data:[J+Je(Xe,G),ue+Je(Xe,G),qe[0],qe[1]]}),ne.setPosition(qe[0],qe[1]),ne.quadReflectionPoint=[ve+(ve-J),ke+(ke-ue)]}break}case"T":case"t":{const Y=k.key==="t";if(k.data.length>=2){let J=+k.data[0],ue=+k.data[1];Y&&(J+=ne.x,ue+=ne.y);let ve=J,ke=ue;const De=B?B.key:"";let Xe=null;De!=="q"&&De!=="Q"&&De!=="t"&&De!=="T"||(Xe=ne.quadReflectionPoint),Xe&&(ve=Xe[0],ke=Xe[1]);const qe=1*(1+.2*G.roughness),_t=1.5*(1+.22*G.roughness);V.push({op:"move",data:[ne.x+Je(qe,G),ne.y+Je(qe,G)]});let wt=[J+Je(qe,G),ue+Je(qe,G)];V.push({op:"qcurveTo",data:[ve+Je(qe,G),ke+Je(qe,G),wt[0],wt[1]]}),V.push({op:"move",data:[ne.x+Je(_t,G),ne.y+Je(_t,G)]}),wt=[J+Je(_t,G),ue+Je(_t,G)],V.push({op:"qcurveTo",data:[ve+Je(_t,G),ke+Je(_t,G),wt[0],wt[1]]}),ne.setPosition(wt[0],wt[1]),ne.quadReflectionPoint=[J+(J-ve),ue+(ue-ke)]}break}case"A":case"a":{const Y=k.key==="a";if(k.data.length>=7){const J=+k.data[0],ue=+k.data[1],ve=+k.data[2],ke=+k.data[3],De=+k.data[4];let Xe=+k.data[5],qe=+k.data[6];if(Y&&(Xe+=ne.x,qe+=ne.y),Xe===ne.x&&qe===ne.y)break;if(J===0||ue===0)V=V.concat(Lr(ne.x,ne.y,Xe,qe,G)),ne.setPosition(Xe,qe);else for(let _t=0;_t<1;_t++){const wt=new j([ne.x,ne.y],[Xe,qe],[J,ue],ve,!!ke,!!De);let Vt=wt.getNextSegment();for(;Vt;){const Qt=Qu(Vt.cp1[0],Vt.cp1[1],Vt.cp2[0],Vt.cp2[1],Vt.to[0],Vt.to[1],ne,G);V=V.concat(Qt),Vt=wt.getNextSegment()}}}break}}return V}class $u extends d{line(k,B,G,V,Y){const J=this._options(Y);return this._drawable("line",[ot(k,B,G,V,J)],J)}rectangle(k,B,G,V,Y){const J=this._options(Y),ue=[];if(J.fill){const ve=[[k,B],[k+G,B],[k+G,B+V],[k,B+V]];J.fillStyle==="solid"?ue.push(Un(ve,J)):ue.push(ii(ve,J))}return ue.push(function(ve,ke,De,Xe,qe){return function(_t,wt){return Pt(_t,!0,qe)}([[ve,ke],[ve+De,ke],[ve+De,ke+Xe],[ve,ke+Xe]])}(k,B,G,V,J)),this._drawable("rectangle",ue,J)}ellipse(k,B,G,V,Y){const J=this._options(Y),ue=[];if(J.fill)if(J.fillStyle==="solid"){const ve=wn(k,B,G,V,J);ve.type="fillPath",ue.push(ve)}else ue.push(function(ve,ke,De,Xe,qe){return mi(qe,ut).fillEllipse(ve,ke,De,Xe,qe)}(k,B,G,V,J));return ue.push(wn(k,B,G,V,J)),this._drawable("ellipse",ue,J)}circle(k,B,G,V){const Y=this.ellipse(k,B,G,G,V);return Y.shape="circle",Y}linearPath(k,B){const G=this._options(B);return this._drawable("linearPath",[Pt(k,!1,G)],G)}arc(k,B,G,V,Y,J,ue=!1,ve){const ke=this._options(ve),De=[];if(ue&&ke.fill)if(ke.fillStyle==="solid"){const Xe=vt(k,B,G,V,Y,J,!0,!1,ke);Xe.type="fillPath",De.push(Xe)}else De.push(function(Xe,qe,_t,wt,Vt,Qt,Sn){const ai=mi(Sn,ut).fillArc(Xe,qe,_t,wt,Vt,Qt,Sn);if(ai)return ai;const Ir=Xe,Ys=qe;let vc=Math.abs(_t/2),xc=Math.abs(wt/2);vc+=Je(.01*vc,Sn),xc+=Je(.01*xc,Sn);let _d=Vt,eh=Qt;for(;_d<0;)_d+=2*Math.PI,eh+=2*Math.PI;eh-_d>2*Math.PI&&(_d=0,eh=2*Math.PI);const qV=(eh-_d)/Sn.curveStepCount,fx=[];for(let dx=_d;dx<=eh;dx+=qV)fx.push([Ir+vc*Math.cos(dx),Ys+xc*Math.sin(dx)]);return fx.push([Ir+vc*Math.cos(eh),Ys+xc*Math.sin(eh)]),fx.push([Ir,Ys]),ii(fx,Sn)}(k,B,G,V,Y,J,ke));return De.push(vt(k,B,G,V,Y,J,ue,!0,ke)),this._drawable("arc",De,ke)}curve(k,B){const G=this._options(B);return this._drawable("curve",[yt(k,G)],G)}polygon(k,B){const G=this._options(B),V=[];if(G.fill)if(G.fillStyle==="solid")V.push(Un(k,G));else{const Y=this.computePolygonSize(k),J=ii([[0,0],[Y[0],0],[Y[0],Y[1]],[0,Y[1]]],G);J.type="path2Dpattern",J.size=Y,J.path=this.polygonPath(k),V.push(J)}return V.push(Pt(k,!0,G)),this._drawable("polygon",V,G)}path(k,B){const G=this._options(B),V=[];if(!k)return this._drawable("path",V,G);if(G.fill)if(G.fillStyle==="solid"){const Y={type:"path2Dfill",path:k,ops:[]};V.push(Y)}else{const Y=this.computePathSize(k),J=ii([[0,0],[Y[0],0],[Y[0],Y[1]],[0,Y[1]]],G);J.type="path2Dpattern",J.size=Y,J.path=k,V.push(J)}return V.push(function(Y,J){Y=(Y||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let ue=new z(Y);if(J.simplification){const De=new U(ue.linearPoints,ue.closed).fit(J.simplification);ue=new z(De)}let ve=[];const ke=ue.segments||[];for(let De=0;De0?ke[De-1]:null,J);Xe&&Xe.length&&(ve=ve.concat(Xe))}return{type:"path",ops:ve}}(k,G)),this._drawable("path",V,G)}}const Sd=typeof document<"u";class ux{constructor(k){this.canvas=k,this.ctx=this.canvas.getContext("2d")}draw(k){const B=k.sets||[],G=k.options||this.getDefaultOptions(),V=this.ctx;for(const Y of B)switch(Y.type){case"path":V.save(),V.strokeStyle=G.stroke,V.lineWidth=G.strokeWidth,this._drawToContext(V,Y),V.restore();break;case"fillPath":V.save(),V.fillStyle=G.fill||"",this._drawToContext(V,Y),V.restore();break;case"fillSketch":this.fillSketch(V,Y,G);break;case"path2Dfill":{this.ctx.save(),this.ctx.fillStyle=G.fill||"";const J=new Path2D(Y.path);this.ctx.fill(J),this.ctx.restore();break}case"path2Dpattern":{const J=this.canvas.ownerDocument||Sd&&document;if(J){const ue=Y.size,ve=J.createElement("canvas"),ke=ve.getContext("2d"),De=this.computeBBox(Y.path);De&&(De.width||De.height)?(ve.width=this.canvas.width,ve.height=this.canvas.height,ke.translate(De.x||0,De.y||0)):(ve.width=ue[0],ve.height=ue[1]),this.fillSketch(ke,Y,G),this.ctx.save(),this.ctx.fillStyle=this.ctx.createPattern(ve,"repeat");const Xe=new Path2D(Y.path);this.ctx.fill(Xe),this.ctx.restore()}else console.error("Cannot render path2Dpattern. No defs/document defined.");break}}}computeBBox(k){if(Sd)try{const B="http://www.w3.org/2000/svg",G=document.createElementNS(B,"svg");G.setAttribute("width","0"),G.setAttribute("height","0");const V=self.document.createElementNS(B,"path");V.setAttribute("d",k),G.appendChild(V),document.body.appendChild(G);const Y=V.getBBox();return document.body.removeChild(G),Y}catch{}return null}fillSketch(k,B,G){let V=G.fillWeight;V<0&&(V=G.strokeWidth/2),k.save(),k.strokeStyle=G.fill||"",k.lineWidth=V,this._drawToContext(k,B),k.restore()}_drawToContext(k,B){k.beginPath();for(const G of B.ops){const V=G.data;switch(G.op){case"move":k.moveTo(V[0],V[1]);break;case"bcurveTo":k.bezierCurveTo(V[0],V[1],V[2],V[3],V[4],V[5]);break;case"qcurveTo":k.quadraticCurveTo(V[0],V[1],V[2],V[3]);break;case"lineTo":k.lineTo(V[0],V[1])}}B.type==="fillPath"?k.fill():k.stroke()}}class hx extends ux{constructor(k,B){super(k),this.gen=new $u(B||null,this.canvas)}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(k,B,G,V,Y){const J=this.gen.line(k,B,G,V,Y);return this.draw(J),J}rectangle(k,B,G,V,Y){const J=this.gen.rectangle(k,B,G,V,Y);return this.draw(J),J}ellipse(k,B,G,V,Y){const J=this.gen.ellipse(k,B,G,V,Y);return this.draw(J),J}circle(k,B,G,V){const Y=this.gen.circle(k,B,G,V);return this.draw(Y),Y}linearPath(k,B){const G=this.gen.linearPath(k,B);return this.draw(G),G}polygon(k,B){const G=this.gen.polygon(k,B);return this.draw(G),G}arc(k,B,G,V,Y,J,ue=!1,ve){const ke=this.gen.arc(k,B,G,V,Y,J,ue,ve);return this.draw(ke),ke}curve(k,B){const G=this.gen.curve(k,B);return this.draw(G),G}path(k,B){const G=this.gen.path(k,B);return this.draw(G),G}}const WV=typeof document<"u";class jV{constructor(k){this.svg=k}get defs(){const k=this.svg.ownerDocument||WV&&document;if(k&&!this._defs){const B=k.createElementNS("http://www.w3.org/2000/svg","defs");this.svg.firstChild?this.svg.insertBefore(B,this.svg.firstChild):this.svg.appendChild(B),this._defs=B}return this._defs||null}draw(k){const B=k.sets||[],G=k.options||this.getDefaultOptions(),V=this.svg.ownerDocument||window.document,Y=V.createElementNS("http://www.w3.org/2000/svg","g");for(const J of B){let ue=null;switch(J.type){case"path":(ue=V.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",this.opsToPath(J)),ue.style.stroke=G.stroke,ue.style.strokeWidth=G.strokeWidth+"",ue.style.fill="none";break;case"fillPath":(ue=V.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",this.opsToPath(J)),ue.style.stroke="none",ue.style.strokeWidth="0",ue.style.fill=G.fill||null;break;case"fillSketch":ue=this.fillSketch(V,J,G);break;case"path2Dfill":(ue=V.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",J.path||""),ue.style.stroke="none",ue.style.strokeWidth="0",ue.style.fill=G.fill||null;break;case"path2Dpattern":if(this.defs){const ve=J.size,ke=V.createElementNS("http://www.w3.org/2000/svg","pattern"),De=`rough-${Math.floor(Math.random()*(Number.MAX_SAFE_INTEGER||999999))}`;ke.setAttribute("id",De),ke.setAttribute("x","0"),ke.setAttribute("y","0"),ke.setAttribute("width","1"),ke.setAttribute("height","1"),ke.setAttribute("height","1"),ke.setAttribute("viewBox",`0 0 ${Math.round(ve[0])} ${Math.round(ve[1])}`),ke.setAttribute("patternUnits","objectBoundingBox");const Xe=this.fillSketch(V,J,G);ke.appendChild(Xe),this.defs.appendChild(ke),(ue=V.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",J.path||""),ue.style.stroke="none",ue.style.strokeWidth="0",ue.style.fill=`url(#${De})`}else console.error("Cannot render path2Dpattern. No defs/document defined.")}ue&&Y.appendChild(ue)}return Y}fillSketch(k,B,G){let V=G.fillWeight;V<0&&(V=G.strokeWidth/2);const Y=k.createElementNS("http://www.w3.org/2000/svg","path");return Y.setAttribute("d",this.opsToPath(B)),Y.style.stroke=G.fill||null,Y.style.strokeWidth=V+"",Y.style.fill="none",Y}}class XV extends jV{constructor(k,B){super(k),this.gen=new $u(B||null,this.svg)}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(k){return this.gen.opsToPath(k)}line(k,B,G,V,Y){const J=this.gen.line(k,B,G,V,Y);return this.draw(J)}rectangle(k,B,G,V,Y){const J=this.gen.rectangle(k,B,G,V,Y);return this.draw(J)}ellipse(k,B,G,V,Y){const J=this.gen.ellipse(k,B,G,V,Y);return this.draw(J)}circle(k,B,G,V){const Y=this.gen.circle(k,B,G,V);return this.draw(Y)}linearPath(k,B){const G=this.gen.linearPath(k,B);return this.draw(G)}polygon(k,B){const G=this.gen.polygon(k,B);return this.draw(G)}arc(k,B,G,V,Y,J,ue=!1,ve){const ke=this.gen.arc(k,B,G,V,Y,J,ue,ve);return this.draw(ke)}curve(k,B){const G=this.gen.curve(k,B);return this.draw(G)}path(k,B){const G=this.gen.path(k,B);return this.draw(G)}}return{canvas:(ne,k)=>new hx(ne,k),svg:(ne,k)=>new XV(ne,k),generator:(ne,k)=>new $u(ne,k)}});var Ts=function(m){return m>20?20:m},cd=function(){function m(d){s(this,m),this.el=d.element,this.data=d.data,this.element=d.element,this.margin=d.margin||{top:50,right:20,bottom:70,left:100},this.title=d.title,this.color=d.color||"skyblue",this.highlight=d.highlight||"coral",this.roughness=Ts(d.roughness)||1,this.stroke=d.stroke||"black",this.strokeWidth=d.strokeWidth||1,this.axisStrokeWidth=d.axisStrokeWidth||.5,this.axisRoughness=d.axisRoughness||.5,this.innerStrokeWidth=d.innerStrokeWidth||1,this.fillStyle=d.fillStyle,this.bowing=d.bowing||0,this.fillWeight=d.fillWeight||.5,this.simplification=d.simplification||.2,this.interactive=d.interactive!==!1,this.titleFontSize=d.titleFontSize,this.axisFontSize=d.axisFontSize,this.tooltipFontSize=d.tooltipFontSize||"0.95rem",this.font=d.font||0,this.dataFormat=r(d.data)==="object"?"object":"file",this.labels=this.dataFormat==="object"?"labels":d.labels,this.values=this.dataFormat==="object"?"values":d.values,this.xValueFormat=d.xValueFormat,this.yValueFormat=d.yValueFormat,this.padding=d.padding||.1,this.xLabel=d.xLabel||"",this.yLabel=d.yLabel||"",this.labelFontSize=d.labelFontSize||"1rem",this.initChartValues(d),this.resolveFont(),this.drawChart=this.resolveData(d.data),this.drawChart(),d.title!=="undefined"&&this.setTitle(d.title)}return a(m,[{key:"initChartValues",value:function(d){var b=d.width?d.width:350,T=d.height?d.height:450;this.width=b-this.margin.left-this.margin.right,this.height=T-this.margin.top-this.margin.bottom,this.roughId=this.el+"_svg",this.graphClass=this.el.substring(1,this.el.length),this.interactionG="g."+this.graphClass,this.setSvg()}},{key:"setSvg",value:function(){this.svg=$e(this.el).append("svg").attr("width",this.width+this.margin.left+this.margin.right).attr("height",this.height+this.margin.top+this.margin.bottom).append("g").attr("id",this.roughId).attr("transform","translate("+this.margin.left+","+this.margin.top+")")}},{key:"resolveFont",value:function(){this.font===0||this.font===void 0||this.font.toString().toLowerCase()==="gaegu"?(l.addFontGaegu(this.svg),this.fontFamily="gaeguregular"):this.font===1||this.font.toString().toLowerCase()==="indie flower"?(l.addFontIndieFlower(this.svg),this.fontFamily="indie_flowerregular"):this.fontFamily=this.font}},{key:"resolveData",value:function(d){var b=this;return typeof d!="string"?function(){b.data=d,b.drawFromObject()}:d.includes(".csv")?function(){ze(d).then(function(T){b.data=T,b.drawFromFile()})}:d.includes(".tsv")?function(){At(d).then(function(T){b.data=T,b.drawFromFile()})}:void 0}},{key:"addScales",value:function(){var d=this;this.xScale=Ta().rangeRound([0,this.width]).padding(this.padding).domain(this.dataFormat==="file"?this.data.map(function(b){return b[d.labels]}):this.data[d.labels]),this.yScale=vo().rangeRound([this.height,0]).domain(this.dataFormat==="file"?[0,H(this.data,function(b){return+b[d.values]})]:[0,H(this.data[d.values])])}},{key:"addLabels",value:function(){this.xLabel!==""&&this.svg.append("text").attr("x",this.width/2).attr("y",this.height+this.margin.bottom/2).attr("dx","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.xLabel),this.yLabel!==""&&this.svg.append("text").attr("transform","rotate(-90)").attr("y",0-this.margin.left/1.4).attr("x",0-this.height/2).attr("dy","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.yLabel)}},{key:"addAxes",value:function(){var d=this,b=it(this.xScale).tickSize(0).tickFormat(function(D){return d.xValueFormat?Ze(d.xValueFormat)(D):D}),T=we(this.yScale).tickSize(0).tickFormat(function(D){return d.yValueFormat?Ze(d.yValueFormat)(D):D});this.svg.append("g").attr("transform","translate(0,"+this.height+")").call(b).attr("class","xAxis".concat(this.graphClass)).selectAll("text").attr("transform","translate(-10,0)rotate(-45)").style("text-anchor","end").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.8,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize).style("opacity",.9),this.svg.append("g").call(T).attr("class","yAxis".concat(this.graphClass)).selectAll("text").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.95,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize).style("opacity",.9),Tt("path.domain").attr("stroke","transparent")}},{key:"makeAxesRough",value:function(d,b){var T="xAxis".concat(this.graphClass),D="yAxis".concat(this.graphClass),z="rough-".concat(T),j="rough-".concat(D);$e(".".concat(T)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{fillStyle:"hachure"});me.setAttribute("class",z),d.appendChild(me)}),Tt(".".concat(z)).attr("transform","translate(0, ".concat(this.height,")")),$e(".".concat(D)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{fillStyle:"hachure"});me.setAttribute("class",j),d.appendChild(me)})}},{key:"setTitle",value:function(d){this.svg.append("text").attr("x",this.width/2).attr("y",0-this.margin.top/2).attr("class","title").attr("text-anchor","middle").style("font-size",this.titleFontSize===void 0?"".concat(Math.min(40,Math.min(this.width,this.height)/5),"px"):this.titleFontSize).style("font-family",this.fontFamily).style("opacity",.8).text(d)}},{key:"addInteraction",value:function(){var d=this;Tt(this.interactionG).data(this.dataFormat==="file"?this.data:this.data.values).append("rect").attr("x",function(D,z){return d.dataFormat==="file"?d.xScale(D[d.labels]):d.xScale(d.data[d.labels][z])}).attr("y",function(D,z){return d.dataFormat==="file"?d.yScale(+D[d.values]):d.yScale(d.data[d.values][z])}).attr("width",this.xScale.bandwidth()).attr("height",function(D,z){return d.dataFormat==="file"?d.height-d.yScale(+D[d.values]):d.height-d.yScale(d.data[d.values][z])}).attr("fill","transparent");var b=$e(this.el).append("div").style("opacity",0).attr("class","tooltip").style("position","absolute").style("background-color","white").style("border","solid").style("border-width","1px").style("border-radius","5px").style("padding","3px").style("font-family",this.fontFamily).style("font-size",this.tooltipFontSize).style("pointer-events","none"),T=this;Tt(this.interactionG).on("mouseover",function(){b.style("opacity",1),$e(this).select("path").style("stroke",T.highlight),$e(this).selectAll("path:nth-child(2)").style("stroke-width",T.strokeWidth+1.2)}),Tt(this.interactionG).on("mouseout",function(){b.style("opacity",0),$e(this).select("path").style("stroke",T.color),$e(this).selectAll("path:nth-child(2)").style("stroke-width",T.strokeWidth)}),Tt(this.interactionG).on("mousemove",function(D){var z=$e(this).attr("attrX"),j=$e(this).attr("attrY"),U=Lo(this);b.html("".concat(z,": ").concat(j)).style("opacity",.95).attr("class",function($){}).style("transform","translate(".concat(U[0]+T.margin.left,`px, + `).concat(U[1]-(T.height+T.margin.top+T.margin.bottom),"px)"))})}},{key:"initRoughObjects",value:function(){var d=t(ar);this.roughSvg=document.getElementById(this.roughId),this.rcAxis=d.d.svg(this.roughSvg,{options:{strokeWidth:this.axisStrokeWidth,roughness:this.axisRoughness}}),this.rc=d.d.svg(this.roughSvg,{options:{fill:this.color,stroke:this.stroke==="none"?void 0:this.stroke,strokeWidth:this.innerStrokeWidth,roughness:this.roughness,bowing:this.bowing,fillStyle:this.fillStyle}})}},{key:"drawFromObject",value:function(){var d=this;this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.data.values.forEach(function(b,T){var D=d.rc.rectangle(d.xScale(d.data[d.labels][T]),d.yScale(+b),d.xScale.bandwidth(),d.height-d.yScale(+b),{simplification:d.simplification,fillWeight:d.fillWeight}),z=d.roughSvg.appendChild(D);z.setAttribute("class",d.graphClass),z.setAttribute("attrX",d.data[d.labels][T]),z.setAttribute("attrY",+b)}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}},{key:"drawFromFile",value:function(){var d=this;this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.data.forEach(function(b){var T=d.rc.rectangle(d.xScale(b[d.labels]),d.yScale(+b[d.values]),d.xScale.bandwidth(),d.height-d.yScale(+b[d.values]),{simplification:d.simplification,fillWeight:d.fillWeight}),D=d.roughSvg.appendChild(T);D.setAttribute("class",d.graphClass),D.setAttribute("attrX",b[d.labels]),D.setAttribute("attrY",+b[d.values])}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}}]),m}();function kr(m){return(kr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(m)}function ex(m,d){if(!(m instanceof d))throw new TypeError("Cannot call a class as a function")}function ud(m,d){for(var b=0;b20?20:m},Fa=function(){function m(d){ex(this,m),this.el=d.element,this.element=d.element,this.margin=d.margin||{top:50,right:20,bottom:50,left:100},this.title=d.title,this.color=d.color||"skyblue",this.highlight=d.highlight||"coral",this.roughness=TM(d.roughness)||1,this.stroke=d.stroke||"black",this.strokeWidth=d.strokeWidth||1,this.axisStrokeWidth=d.axisStrokeWidth||.5,this.axisRoughness=d.axisRoughness||1,this.innerStrokeWidth=d.innerStrokeWidth||1,this.fillStyle=d.fillStyle,this.bowing=d.bowing||0,this.fillWeight=d.fillWeight||.5,this.simplification=d.simplification||.2,this.interactive=d.interactive!==!1,this.titleFontSize=d.titleFontSize,this.axisFontSize=d.axisFontSize,this.tooltipFontSize=d.tooltipFontSize||".95rem",this.font=d.font||0,this.dataFormat=kr(d.data)==="object"?"object":"file",this.labels=this.dataFormat==="object"?"labels":d.labels,this.values=this.dataFormat==="object"?"values":d.values,this.xValueFormat=d.xValueFormat,this.yValueFormat=d.yValueFormat,this.padding=d.padding||.1,this.xLabel=d.xLabel||"",this.yLabel=d.yLabel||"",this.labelFontSize=d.labelFontSize||"1rem",this.initChartValues(d),this.resolveFont(),this.drawChart=this.resolveData(d.data),this.drawChart(),d.title!=="undefined"&&this.setTitle(d.title)}return fg(m,[{key:"initChartValues",value:function(d){var b=d.width?d.width:350,T=d.height?d.height:450;this.width=b-this.margin.left-this.margin.right,this.height=T-this.margin.top-this.margin.bottom,this.roughId=this.el+"_svg",this.graphClass=this.el.substring(1,this.el.length),this.interactionG="g."+this.graphClass,this.setSvg()}},{key:"setSvg",value:function(){this.svg=$e(this.el).append("svg").attr("width",this.width+this.margin.left+this.margin.right).attr("height",this.height+this.margin.top+this.margin.bottom).append("g").attr("id",this.roughId).attr("transform","translate("+this.margin.left+","+this.margin.top+")")}},{key:"resolveFont",value:function(){this.font===0||this.font===void 0||this.font.toString().toLowerCase()==="gaegu"?(l.addFontGaegu(this.svg),this.fontFamily="gaeguregular"):this.font===1||this.font.toString().toLowerCase()==="indie flower"?(l.addFontIndieFlower(this.svg),this.fontFamily="indie_flowerregular"):this.fontFamily=this.font}},{key:"resolveData",value:function(d){var b=this;return typeof d!="string"?function(){b.data=d,b.drawFromObject()}:d.includes(".csv")?function(){ze(d).then(function(T){console.log(T),b.data=T,b.drawFromFile()})}:d.includes(".tsv")?function(){At(d).then(function(T){b.data=T,b.drawFromFile()})}:void 0}},{key:"addScales",value:function(){var d=this;this.yScale=Ta().rangeRound([0,this.height]).padding(this.padding).domain(this.dataFormat==="file"?this.data.map(function(b){return b[d.labels]}):this.data[d.labels]),this.xScale=vo().rangeRound([0,this.width]).domain(this.dataFormat==="file"?[0,H(this.data,function(b){return+b[d.values]})]:[0,H(this.data[d.values])])}},{key:"addLabels",value:function(){this.xLabel!==""&&this.svg.append("text").attr("x",this.width/2).attr("y",this.height+this.margin.bottom/2.4).attr("dx","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.xLabel),this.yLabel!==""&&this.svg.append("text").attr("transform","rotate(-90)").attr("y",0-this.margin.left/1.5).attr("x",0-this.height/2).attr("dy","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.yLabel)}},{key:"addAxes",value:function(){var d=this,b=it(this.xScale).tickSize(0).tickFormat(function(D){return d.xValueFormat?Ze(d.xValueFormat)(D):D}),T=we(this.yScale).tickSize(0).tickFormat(function(D){return d.yValueFormat?Ze(d.yValueFormat)(D):D});this.svg.append("g").attr("transform","translate(0, ".concat(this.height,")")).call(b).attr("class","xAxis".concat(this.graphClass)).selectAll("text").attr("transform","translate(-10,0)rotate(-45)").style("text-anchor","end").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.95,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize).style("opacity",.85),this.svg.append("g").call(T).attr("class","yAxis".concat(this.graphClass)).selectAll("text").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.95,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize).style("opacity",.85),Tt("path.domain").attr("stroke","transparent")}},{key:"makeAxesRough",value:function(d,b){var T="xAxis".concat(this.graphClass),D="yAxis".concat(this.graphClass),z="rough-".concat(T),j="rough-".concat(D);$e(".".concat(T)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{stroke:"black",fillStyle:"hachure"});me.setAttribute("class",z),d.appendChild(me)}),Tt(".".concat(z)).attr("transform","translate(0, ".concat(this.height,")")),$e(".".concat(D)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{stroke:"black",fillStyle:"hachure"});me.setAttribute("class",j),d.appendChild(me)})}},{key:"setTitle",value:function(d){this.svg.append("text").attr("x",this.width/2).attr("y",0-this.margin.top/2).attr("class","title").attr("text-anchor","middle").style("font-size",this.titleFontSize===void 0?"".concat(Math.min(40,Math.min(this.width,this.height)/5),"px"):this.titleFontSize).style("font-family",this.fontFamily).style("opacity",.8).text(d)}},{key:"addInteraction",value:function(){var d=this;Tt(this.interactionG).data(this.dataFormat==="file"?this.data:this.data.values).append("rect").attr("x",0).attr("y",function(D,z){return d.dataFormat==="file"?d.yScale(D[d.labels]):d.yScale(d.data[d.labels][z])}).attr("width",function(D,z){return d.dataFormat==="file"?d.xScale(+D[d.values]):d.xScale(d.data[d.values][z])}).attr("height",this.yScale.bandwidth()).attr("fill","transparent");var b=$e(this.el).append("div").style("opacity",0).attr("class","tooltip").style("position","absolute").style("background-color","white").style("border","solid").style("border-width","1px").style("border-radius","5px").style("padding","3px").style("font-family",this.fontFamily).style("font-size",this.tooltipFontSize).style("pointer-events","none"),T=this;Tt(this.interactionG).on("mouseover",function(){b.style("opacity",1),$e(this).select("path").style("stroke",T.highlight),$e(this).selectAll("path:nth-child(2)").style("stroke-width",T.strokeWidth+1.2)}),Tt(this.interactionG).on("mouseout",function(){b.style("opacity",0),$e(this).select("path").style("stroke",T.color),$e(this).selectAll("path:nth-child(2)").style("stroke-width",T.strokeWidth)}),Tt(this.interactionG).on("mousemove",function(D){var z=$e(this).attr("attrX"),j=$e(this).attr("attrY"),U=Lo(this);b.html("".concat(z,": ").concat(j)).style("opacity",.95).attr("class",function($){}).style("transform","translate(".concat(U[0]+T.margin.left,`px, + `).concat(U[1]-(T.height+T.margin.top+T.margin.bottom),"px)"))})}},{key:"initRoughObjects",value:function(){var d=t(ar);this.roughSvg=document.getElementById(this.roughId),this.rcAxis=d.d.svg(this.roughSvg,{options:{strokeWidth:this.axisStrokeWidth,roughness:this.axisRoughness}}),this.rc=d.d.svg(this.roughSvg,{options:{fill:this.color,stroke:this.stroke==="none"?void 0:this.stroke,strokeWidth:this.innerStrokeWidth,roughness:this.roughness,bowing:this.bowing,fillStyle:this.fillStyle}})}},{key:"drawFromObject",value:function(){var d=this;this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.data.values.forEach(function(b,T){var D=d.rc.rectangle(0,d.yScale(d.data[d.labels][T]),d.xScale(b),d.yScale.bandwidth(),{simplification:d.simplification,fillWeight:d.fillWeight}),z=d.roughSvg.appendChild(D);z.setAttribute("class",d.graphClass),z.setAttribute("attrX",d.data[d.labels][T]),z.setAttribute("attrY",+b)}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}},{key:"drawFromFile",value:function(){var d=this;this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.data.forEach(function(b){var T=d.rc.rectangle(0,d.yScale(b[d.labels]),d.xScale(+b[d.values]),d.yScale.bandwidth(),{simplification:d.simplification,fillWeight:d.fillWeight}),D=d.roughSvg.appendChild(T);D.setAttribute("class",d.graphClass),D.setAttribute("attrX",b[d.labels]),D.setAttribute("attrY",+b[d.values])}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}}]),m}();function dg(m){return(dg=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(m)}function tx(m,d){if(!(m instanceof d))throw new TypeError("Cannot call a class as a function")}function hd(m,d){for(var b=0;bvt*vt+Un*Un&&(mi=ot,ut=Pt),{cx:mi,cy:ut,x01:-me,y01:-Te,x11:mi*(D/Xn-1),y11:ut*(D/Xn-1)}}var dd=Math.PI,sa=2*dd,vl=1e-6,xl=sa-vl;function pd(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function Ar(){return new pd}pd.prototype=Ar.prototype={constructor:pd,moveTo:function(m,d){this._+="M"+(this._x0=this._x1=+m)+","+(this._y0=this._y1=+d)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(m,d){this._+="L"+(this._x1=+m)+","+(this._y1=+d)},quadraticCurveTo:function(m,d,b,T){this._+="Q"+ +m+","+ +d+","+(this._x1=+b)+","+(this._y1=+T)},bezierCurveTo:function(m,d,b,T,D,z){this._+="C"+ +m+","+ +d+","+ +b+","+ +T+","+(this._x1=+D)+","+(this._y1=+z)},arcTo:function(m,d,b,T,D){m=+m,d=+d,b=+b,T=+T,D=+D;var z=this._x1,j=this._y1,U=b-m,$=T-d,ae=z-m,me=j-d,Te=ae*ae+me*me;if(D<0)throw new Error("negative radius: "+D);if(this._x1===null)this._+="M"+(this._x1=m)+","+(this._y1=d);else if(Te>vl)if(Math.abs(me*U-$*ae)>vl&&D){var xe=b-z,St=T-j,Yt=U*U+$*$,ln=xe*xe+St*St,Ut=Math.sqrt(Yt),xt=Math.sqrt(Te),Et=D*Math.tan((dd-Math.acos((Yt+Te-ln)/(2*Ut*xt)))/2),Jt=Et/xt,zt=Et/Ut;Math.abs(Jt-1)>vl&&(this._+="L"+(m+Jt*ae)+","+(d+Jt*me)),this._+="A"+D+","+D+",0,0,"+ +(me*xe>ae*St)+","+(this._x1=m+zt*U)+","+(this._y1=d+zt*$)}else this._+="L"+(this._x1=m)+","+(this._y1=d)},arc:function(m,d,b,T,D,z){m=+m,d=+d,z=!!z;var j=(b=+b)*Math.cos(T),U=b*Math.sin(T),$=m+j,ae=d+U,me=1^z,Te=z?T-D:D-T;if(b<0)throw new Error("negative radius: "+b);this._x1===null?this._+="M"+$+","+ae:(Math.abs(this._x1-$)>vl||Math.abs(this._y1-ae)>vl)&&(this._+="L"+$+","+ae),b&&(Te<0&&(Te=Te%sa+sa),Te>xl?this._+="A"+b+","+b+",0,1,"+me+","+(m-j)+","+(d-U)+"A"+b+","+b+",0,1,"+me+","+(this._x1=$)+","+(this._y1=ae):Te>vl&&(this._+="A"+b+","+b+",0,"+ +(Te>=dd)+","+me+","+(this._x1=m+b*Math.cos(D))+","+(this._y1=d+b*Math.sin(D))))},rect:function(m,d,b,T){this._+="M"+(this._x0=this._x1=+m)+","+(this._y0=this._y1=+d)+"h"+ +b+"v"+ +T+"h"+-b+"Z"},toString:function(){return this._}};var Vi=function(m){return function(){return m}},mg=Math.abs,br=Math.atan2,wl=Math.cos,rx=Math.max,md=Math.min,Io=Math.sin,lr=Math.sqrt,Ki=1e-12,Ku=Math.PI,qs=Ku/2,Sl=2*Ku;function _l(m){return m>1?0:m<-1?Ku:Math.acos(m)}function Zu(m){return m>=1?qs:m<=-1?-qs:Math.asin(m)}var gc=function(){var m=nx,d=ix,b=Vi(0),T=null,D=pg,z=fd,j=CM,U=null;function $(){var ae,me,Te=+m.apply(this,arguments),xe=+d.apply(this,arguments),St=D.apply(this,arguments)-qs,Yt=z.apply(this,arguments)-qs,ln=mg(Yt-St),Ut=Yt>St;if(U||(U=ae=Ar()),xeKi)if(ln>Sl-Ki)U.moveTo(xe*wl(St),xe*Io(St)),U.arc(0,0,xe,St,Yt,!Ut),Te>Ki&&(U.moveTo(Te*wl(Yt),Te*Io(Yt)),U.arc(0,0,Te,Yt,St,Ut));else{var xt,Et,Jt=St,zt=Yt,Xn=St,xn=Yt,Pn=ln,mi=ln,ut=j.apply(this,arguments)/2,ot=ut>Ki&&(T?+T.apply(this,arguments):lr(Te*Te+xe*xe)),Pt=md(mg(xe-Te)/2,+b.apply(this,arguments)),yt=Pt,wn=Pt;if(ot>Ki){var vt=Zu(ot/Te*Io(ut)),Un=Zu(ot/xe*Io(ut));(Pn-=2*vt)>Ki?(Xn+=vt*=Ut?1:-1,xn-=vt):(Pn=0,Xn=xn=(St+Yt)/2),(mi-=2*Un)>Ki?(Jt+=Un*=Ut?1:-1,zt-=Un):(mi=0,Jt=zt=(St+Yt)/2)}var ii=xe*wl(Jt),Ri=xe*Io(Jt),Je=Te*wl(xn),Lr=Te*Io(xn);if(Pt>Ki){var Do,Ju=xe*wl(zt),yc=xe*Io(zt),xd=Te*wl(Xn),wd=Te*Io(Xn);if(lnKi?wn>Ki?(xt=Yu(xd,wd,ii,Ri,xe,wn,Ut),Et=Yu(Ju,yc,Je,Lr,xe,wn,Ut),U.moveTo(xt.cx+xt.x01,xt.cy+xt.y01),wnKi&&Pn>Ki?yt>Ki?(xt=Yu(Je,Lr,Ju,yc,Te,-yt,Ut),Et=Yu(ii,Ri,xd,wd,Te,-yt,Ut),U.lineTo(xt.cx+xt.x01,xt.cy+xt.y01),ytm?1:d>=m?0:NaN},gg=function(m){return m},yd=function(){var m=gg,d=lx,b=null,T=Vi(0),D=Vi(Sl),z=Vi(0);function j(U){var $,ae,me,Te,xe,St=U.length,Yt=0,ln=new Array(St),Ut=new Array(St),xt=+T.apply(this,arguments),Et=Math.min(Sl,Math.max(-Sl,D.apply(this,arguments)-xt)),Jt=Math.min(Math.abs(Et)/St,z.apply(this,arguments)),zt=Jt*(Et<0?-1:1);for($=0;$0&&(Yt+=xe);for(d!=null?ln.sort(function(Xn,xn){return d(Ut[Xn],Ut[xn])}):b!=null&&ln.sort(function(Xn,xn){return b(U[Xn],U[xn])}),$=0,me=Yt?(Et-St*zt)/Yt:0;$0?xe*me:0)+zt,Ut[ae]={data:U[ae],index:$,value:xe,startAngle:xt,endAngle:Te,padAngle:Jt};return Ut}return j.value=function(U){return arguments.length?(m=typeof U=="function"?U:Vi(+U),j):m},j.sortValues=function(U){return arguments.length?(d=U,b=null,j):d},j.sort=function(U){return arguments.length?(b=U,d=null,j):b},j.startAngle=function(U){return arguments.length?(T=typeof U=="function"?U:Vi(+U),j):T},j.endAngle=function(U){return arguments.length?(D=typeof U=="function"?U:Vi(+U),j):D},j.padAngle=function(U){return arguments.length?(z=typeof U=="function"?U:Vi(+U),j):z},j},vd=function(){};function h(m,d,b){m._context.bezierCurveTo((2*m._x0+m._x1)/3,(2*m._y0+m._y1)/3,(m._x0+2*m._x1)/3,(m._y0+2*m._y1)/3,(m._x0+4*m._x1+d)/6,(m._y0+4*m._y1+b)/6)}function p(m){this._context=m}p.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:h(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(m,d){switch(m=+m,d=+d,this._point){case 0:this._point=1,this._line?this._context.lineTo(m,d):this._context.moveTo(m,d);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:h(this,m,d)}this._x0=this._x1,this._x1=m,this._y0=this._y1,this._y1=d}};function _(m,d){this._basis=new p(m),this._beta=d}_.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var m=this._x,d=this._y,b=m.length-1;if(b>0)for(var T,D=m[0],z=d[0],j=m[b]-D,U=d[b]-z,$=-1;++$<=b;)T=$/b,this._basis.point(this._beta*m[$]+(1-this._beta)*(D+T*j),this._beta*d[$]+(1-this._beta)*(z+T*U));this._x=this._y=null,this._basis.lineEnd()},point:function(m,d){this._x.push(+m),this._y.push(+d)}},function m(d){function b(T){return d===1?new p(T):new _(T,d)}return b.beta=function(T){return m(+T)},b}(.85);function E(m,d){this._context=m,this._k=(1-d)/6}function P(m,d,b){m._context.bezierCurveTo(m._x1+m._k*(m._x2-m._x0),m._y1+m._k*(m._y2-m._y0),m._x2+m._k*(m._x1-d),m._y2+m._k*(m._y1-b),m._x2,m._y2)}function O(m,d){this._context=m,this._k=(1-d)/6}O.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:P(this,this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(m,d){switch(m=+m,d=+d,this._point){case 0:this._point=1,this._line?this._context.lineTo(m,d):this._context.moveTo(m,d);break;case 1:this._point=2,this._x1=m,this._y1=d;break;case 2:this._point=3;default:P(this,m,d)}this._x0=this._x1,this._x1=this._x2,this._x2=m,this._y0=this._y1,this._y1=this._y2,this._y2=d}},function m(d){function b(T){return new O(T,d)}return b.tension=function(T){return m(+T)},b}(0),E.prototype={areaStart:vd,areaEnd:vd,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(m,d){switch(m=+m,d=+d,this._point){case 0:this._point=1,this._x3=m,this._y3=d;break;case 1:this._point=2,this._context.moveTo(this._x4=m,this._y4=d);break;case 2:this._point=3,this._x5=m,this._y5=d;break;default:P(this,m,d)}this._x0=this._x1,this._x1=this._x2,this._x2=m,this._y0=this._y1,this._y1=this._y2,this._y2=d}},function m(d){function b(T){return new E(T,d)}return b.tension=function(T){return m(+T)},b}(0);function ee(m,d){this._context=m,this._k=(1-d)/6}ee.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(m,d){switch(m=+m,d=+d,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:P(this,m,d)}this._x0=this._x1,this._x1=this._x2,this._x2=m,this._y0=this._y1,this._y1=this._y2,this._y2=d}},function m(d){function b(T){return new ee(T,d)}return b.tension=function(T){return m(+T)},b}(0);function he(m,d){this._context=m,this._alpha=d}function Le(m,d,b){var T=m._x1,D=m._y1,z=m._x2,j=m._y2;if(m._l01_a>Ki){var U=2*m._l01_2a+3*m._l01_a*m._l12_a+m._l12_2a,$=3*m._l01_a*(m._l01_a+m._l12_a);T=(T*U-m._x0*m._l12_2a+m._x2*m._l01_2a)/$,D=(D*U-m._y0*m._l12_2a+m._y2*m._l01_2a)/$}if(m._l23_a>Ki){var ae=2*m._l23_2a+3*m._l23_a*m._l12_a+m._l12_2a,me=3*m._l23_a*(m._l23_a+m._l12_a);z=(z*ae+m._x1*m._l23_2a-d*m._l12_2a)/me,j=(j*ae+m._y1*m._l23_2a-b*m._l12_2a)/me}m._context.bezierCurveTo(T,D,z,j,m._x2,m._y2)}function tt(m,d){this._context=m,this._alpha=d}tt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(m,d){if(m=+m,d=+d,this._point){var b=this._x2-m,T=this._y2-d;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(b*b+T*T,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(m,d):this._context.moveTo(m,d);break;case 1:this._point=2;break;case 2:this._point=3;default:Le(this,m,d)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=m,this._y0=this._y1,this._y1=this._y2,this._y2=d}},function m(d){function b(T){return d?new tt(T,d):new O(T,0)}return b.alpha=function(T){return m(+T)},b}(.5),he.prototype={areaStart:vd,areaEnd:vd,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(m,d){if(m=+m,d=+d,this._point){var b=this._x2-m,T=this._y2-d;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(b*b+T*T,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=m,this._y3=d;break;case 1:this._point=2,this._context.moveTo(this._x4=m,this._y4=d);break;case 2:this._point=3,this._x5=m,this._y5=d;break;default:Le(this,m,d)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=m,this._y0=this._y1,this._y1=this._y2,this._y2=d}},function m(d){function b(T){return d?new he(T,d):new E(T,0)}return b.alpha=function(T){return m(+T)},b}(.5);function Mt(m,d){this._context=m,this._alpha=d}Mt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(m,d){if(m=+m,d=+d,this._point){var b=this._x2-m,T=this._y2-d;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(b*b+T*T,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Le(this,m,d)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=m,this._y0=this._y1,this._y1=this._y2,this._y2=d}},function m(d){function b(T){return d?new Mt(T,d):new ee(T,0)}return b.alpha=function(T){return m(+T)},b}(.5);function sn(m){return m<0?-1:1}function Bt(m,d,b){var T=m._x1-m._x0,D=d-m._x1,z=(m._y1-m._y0)/(T||D<0&&-0),j=(b-m._y1)/(D||T<0&&-0),U=(z*D+j*T)/(T+D);return(sn(z)+sn(j))*Math.min(Math.abs(z),Math.abs(j),.5*Math.abs(U))||0}function Gn(m,d){var b=m._x1-m._x0;return b?(3*(m._y1-m._y0)/b-d)/2:d}function It(m,d,b){var T=m._x0,D=m._y0,z=m._x1,j=m._y1,U=(z-T)/3;m._context.bezierCurveTo(T+U,D+U*d,z-U,j-U*b,z,j)}function Zi(m){this._context=m}Zi.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:It(this,this._t0,Gn(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(m,d){var b=NaN;if(d=+d,(m=+m)!==this._x1||d!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(m,d):this._context.moveTo(m,d);break;case 1:this._point=2;break;case 2:this._point=3,It(this,Gn(this,b=Bt(this,m,d)),b);break;default:It(this,this._t0,b=Bt(this,m,d))}this._x0=this._x1,this._x1=m,this._y0=this._y1,this._y1=d,this._t0=b}}},Object.create(Zi.prototype).point=function(m,d){Zi.prototype.point.call(this,d,m)};var cr={},be=["coral","skyblue","#66c2a5","tan","#8da0cb","#e78ac3","#a6d854","#ffd92f","coral","skyblue","tan","orange"];cr={colors:be};var pe={},Ce=function(m,d,b,T,D){m.svg.append("svg").attr("x",m.legendPosition==="left"?5:m.width-(b+2)).attr("y",0);var z=D===void 0?5-m.margin.left:D,j=m.rc.rectangle(m.legendPosition==="left"?z:m.width+m.margin.right-2-b,-m.margin.top/3,b,T,{fill:"white",fillWeight:.1,strokeWidth:.75,roughness:2}),U=m.roughSvg.appendChild(j),$="rough"+m.el.substring(1,m.el.length);U.setAttribute("class",$),d.forEach(function(ae,me){var Te=$e("."+$).append("g").attr("transform",`translate( + `.concat(m.legendPosition==="left"?5:m.width-(b+2),`, + `,0,")"));Te.append("rect").style("fill",m.colors[me]).attr("width",20).attr("height",8).attr("x",m.legendPosition==="left"?z:m.margin.right+5).attr("y",6+11*me-m.margin.top/3),Te.append("text").style("font-size",".8rem").style("font-family",m.fontFamily).attr("x",m.legendPosition==="left"?z+25:m.margin.right+30).attr("y",6+11*me+8-m.margin.top/3).text(ae.text)})};pe={addLegend:Ce};var gt=function(m){return m>30?30:m},Nt=function(){function m(d){tx(this,m),this.el=d.element,this.element=d.element,this.margin=d.margin||{top:50,right:20,bottom:10,left:20},this.title=d.title,this.colors=d.colors||cr.colors,this.highlight=d.highlight,this.roughness=gt(d.roughness)||1,this.strokeWidth=d.strokeWidth||.75,this.innerStrokeWidth=d.innerStrokeWidth||.75,this.fillStyle=d.fillStyle,this.bowing=d.bowing||0,this.fillWeight=d.fillWeight||.85,this.simplification=d.simplification||.2,this.interactive=d.interactive!==!1,this.titleFontSize=d.titleFontSize,this.tooltipFontSize=d.tooltipFontSize||".95rem",this.font=d.font||0,this.dataFormat=dg(d.data)==="object"?"object":"file",this.labels=this.dataFormat==="object"?"labels":d.labels,this.values=this.dataFormat==="object"?"values":d.values,this.labels!==void 0&&this.values!==void 0?(this.legend=d.legend!==!1,this.legendPosition=d.legendPosition||"right",this.initChartValues(d),this.resolveFont(),this.drawChart=this.resolveData(d.data),this.drawChart(),d.title!=="undefined"&&this.setTitle(d.title)):console.log("Error for ".concat(this.el,": Must include labels and values when instantiating Donut chart. Skipping chart."))}return yl(m,[{key:"initChartValues",value:function(d){var b=d.width?d.width:300,T=d.height?d.height:300;this.width=b-this.margin.left-this.margin.right,this.height=T-this.margin.top-this.margin.bottom,this.roughId=this.el+"_svg",this.graphClass=this.el.substring(1,this.el.length),this.interactionG="g."+this.graphClass,this.radius=Math.min(this.width,this.height)/2,this.setSvg()}},{key:"setSvg",value:function(){this.svg=$e(this.el).append("svg").attr("width",this.width+this.margin.left+this.margin.right).attr("height",this.height+this.margin.top+this.margin.bottom).append("g").attr("id",this.roughId).attr("transform","translate("+this.margin.left+","+this.margin.top+")")}},{key:"resolveFont",value:function(){this.font===0||this.font===void 0||this.font.toString().toLowerCase()==="gaegu"?(l.addFontGaegu(this.svg),this.fontFamily="gaeguregular"):this.font===1||this.font.toString().toLowerCase()==="indie flower"?(l.addFontIndieFlower(this.svg),this.fontFamily="indie_flowerregular"):this.fontFamily=this.font}},{key:"resolveData",value:function(d){var b=this;return typeof d!="string"?function(){b.data=d,b.drawFromObject()}:d.includes(".csv")?function(){ze(d).then(function(T){b.data=T,b.drawFromFile()})}:d.includes(".tsv")?function(){At(d).then(function(T){b.data=T,b.drawFromFile()})}:d.includes(".json")?function(){lt(d).then(function(T){b.data=T,b.drawFromFile()})}:void 0}},{key:"setTitle",value:function(d){this.svg.append("text").attr("x",this.width/2).attr("y",0-this.margin.top/3).attr("class","title").attr("text-anchor","middle").style("font-size",this.titleFontSize===void 0?"".concat(Math.min(40,Math.min(this.width,this.height)/4),"px"):this.titleFontSize).style("font-family",this.fontFamily).style("opacity",.8).text(d)}},{key:"addInteraction",value:function(){Tt(this.interactionG).append("g").attr("transform","translate(".concat(this.width/2,", ").concat(this.height/2,")")).data(this.dataFormat==="object"?this.makePie(this.data[this.values]):this.makePie(this.data)).append("path").attr("d",this.makeArc).attr("stroke-width","0px").attr("fill","transparent");var d,b=$e(this.el).append("div").style("opacity",0).attr("class","tooltip").style("position","absolute").style("background-color","white").style("border","solid").style("border-width","1px").style("border-radius","5px").style("padding","3px").style("font-family",this.fontFamily).style("font-size",this.tooltipFontSize).style("pointer-events","none"),T=this;Tt(this.interactionG).on("mouseover",function(){b.style("opacity",1),d=$e(this).selectAll("path").style("stroke"),T.highlight===void 0?$e(this).selectAll("path").style("opacity",.5):$e(this).selectAll("path").style("stroke",T.highlight)}),Tt(this.interactionG).on("mouseout",function(){b.style("opacity",0),$e(this).selectAll("path").style("stroke",d),$e(this).selectAll("path").style("opacity",1)}),Tt(this.interactionG).on("mousemove",function(D){var z=$e(this).attr("attrX"),j=$e(this).attr("attrY"),U=Lo(this);b.html("".concat(z,": ").concat(j)).style("opacity",.95).attr("class",function($){}).style("transform","translate(".concat(U[0]+T.margin.left,`px, + `).concat(U[1]-T.height-T.margin.bottom,"px)"))})}},{key:"initRoughObjects",value:function(){var d=t(ar);this.roughSvg=document.getElementById(this.roughId),this.rcAxis=d.d.svg(this.roughSvg,{options:{strokeWidth:this.strokeWidth>=3?3:this.strokeWidth}}),this.rc=d.d.svg(this.roughSvg,{options:{fill:this.color,strokeWidth:this.innerStrokeWidth,roughness:this.roughness,bowing:this.bowing,fillStyle:this.fillStyle,fillWeight:this.fillWeight}})}},{key:"drawFromObject",value:function(){var d=this;this.initRoughObjects(),this.makePie=yd(),this.makeArc=gc().innerRadius(0).outerRadius(this.radius),this.arcs=this.makePie(this.data[this.values]),this.arcs.forEach(function(j,U){var $=d.rc.arc(d.width/2,d.height/2,2*d.radius,2*d.radius,j.startAngle-Math.PI/2,j.endAngle-Math.PI/2,!0,{fill:d.colors[U],stroke:d.colors[U]});$.setAttribute("class",d.graphClass);var ae=d.roughSvg.appendChild($);ae.setAttribute("attrY",d.data[d.values][U]),ae.setAttribute("attrX",d.data[d.labels][U])});var b=this.rc.circle(this.width/2,this.height/2,this.radius,{fill:"white",strokeWidth:.05,fillWeight:10,fillStyle:"solid"});this.roughSvg.appendChild(b),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth);var T=this.data.labels.map(function(j,U){return{color:d.colors[U],text:j}}),D=6*T.reduce(function(j,U){return j>U.text.length?j:U.text.length},0)+35,z=11*T.length+8;this.legend===!0&&pe.addLegend(this,T,D,z),this.interactive===!0&&this.addInteraction()}},{key:"drawFromFile",value:function(){var d=this;this.initRoughObjects(),this.makePie=yd().value(function(U){return U[d.values]}).sort(null);var b=[];this.makeArc=gc().innerRadius(0).outerRadius(this.radius),this.arcs=this.makePie(this.data),this.arcs.forEach(function(U,$){var ae=d.rc.arc(d.width/2,d.height/2,2*d.radius,2*d.radius,U.startAngle-Math.PI/2,U.endAngle-Math.PI/2,!0,{fill:d.colors[$],stroke:d.colors[$]});ae.setAttribute("class",d.graphClass);var me=d.roughSvg.appendChild(ae);me.setAttribute("attrY",U.data[d.values]),me.setAttribute("attrX",U.data[d.labels]),b.push(U.data[d.labels])});var T=this.rc.circle(this.width/2,this.height/2,this.radius,{fill:"white",strokeWidth:.05,fillWeight:10,fillStyle:"solid"});this.roughSvg.appendChild(T),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth);var D=b.map(function(U,$){return{color:d.colors[$],text:U}}),z=6*D.reduce(function(U,$){return U>$.text.length?U:$.text.length},0)+35,j=11*D.length+8;this.legend===!0&&pe.addLegend(this,D,z,j),this.interactive===!0&&this.addInteraction()}}]),m}();function un(m){return Ji(m)||Ln(m)||an()}function an(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function Ln(m){if(Symbol.iterator in Object(m)||Object.prototype.toString.call(m)==="[object Arguments]")return Array.from(m)}function Ji(m){if(Array.isArray(m)){for(var d=0,b=new Array(m.length);d20?20:m},RV=function(m){var d=Object.keys(m).map(function(b){return S(m[b])});return[I(d,function(b){return b[0]}),H(d,function(b){return b[1]})]},kV=function(){function m(d){var b=this;Ua(this,m),this.el=d.element,this.element=d.element,this.margin=d.margin||{top:50,right:20,bottom:50,left:100},this.title=d.title,this.roughness=eR(d.roughness)||2.2,this.fillStyle=d.fillStyle,this.bowing=d.bowing||0,this.axisStrokeWidth=d.axisStrokeWidth||.4,this.axisRoughness=d.axisRoughness||.9,this.interactive=d.interactive!==!1,this.stroke=d.stroke||"black",this.fillWeight=d.fillWeight||.85,this.simplification=d.simplification||.2,this.colors=d.colors,this.strokeWidth=d.strokeWidth||8,this.titleFontSize=d.titleFontSize,this.axisFontSize=d.axisFontSize,this.tooltipFontSize=d.tooltipFontSize||"0.95rem",this.font=d.font||0,this.dataFormat=Cn(d.data)==="object"?"object":"file",this.x=d.x,this.y=this.dataFormat==="object"?"y":d.y,this.xValueFormat=d.xValueFormat,this.yValueFormat=d.yValueFormat,this.legend=d.legend!==!1,this.legendPosition=d.legendPosition||"right",this.circle=d.circle!==!1,this.circleRadius=d.circleRadius||10,this.circleRoughness=eR(d.circleRoughness)||2,this.xLabel=d.xLabel||"",this.yLabel=d.yLabel||"",this.labelFontSize=d.labelFontSize||"1rem",this.dataFormat==="file"&&(this.dataSources=[],this.yKeys=Object.keys(d).filter(function(T){return/y/.test(T)}),this.yKeys.map(function(T,D){T!=="yLabel"&&b.dataSources.push(d[T])})),this.initChartValues(d),this.resolveFont(),this.drawChart=this.resolveData(d.data),this.drawChart(),d.title!=="undefined"&&this.setTitle(d.title)}return PV(m,[{key:"resolveFont",value:function(){this.font===0||this.font===void 0||this.font.toString().toLowerCase()==="gaegu"?(l.addFontGaegu(this.svg),this.fontFamily="gaeguregular"):this.font===1||this.font.toString().toLowerCase()==="indie flower"?(l.addFontIndieFlower(this.svg),this.fontFamily="indie_flowerregular"):this.fontFamily=this.font}},{key:"initChartValues",value:function(d){var b=d.width?d.width:300,T=d.height?d.height:400;this.width=b-this.margin.left-this.margin.right,this.height=T-this.margin.top-this.margin.bottom,this.roughId=this.el+"_svg",this.graphClass=this.el.substring(1,this.el.length),this.interactionG="g."+this.graphClass,this.setSvg()}},{key:"setSvg",value:function(){this.svg=$e(this.el).append("svg").attr("width",this.width+this.margin.left+this.margin.right).attr("height",this.height+this.margin.top+this.margin.bottom).append("g").attr("id",this.roughId).attr("transform","translate("+this.margin.left+","+this.margin.top+")")}},{key:"resolveData",value:function(d){var b=this;return typeof d!="string"?function(){b.data=d,b.drawFromObject()}:d.includes(".csv")?function(){ze(d).then(function(T){b.data=T,b.drawFromFile()})}:d.includes(".tsv")?function(){At(d).then(function(T){b.data=T,b.drawFromFile()})}:void 0}},{key:"addScales",value:function(){var d,b,T=this;if(this.dataFormat!=="file")d=RV(this.data);else{var D=this.dataSources.map(function(ae){return S(T.data,function(me){return+me[ae]})});d=[I(D,function(ae){return ae[0]}),H(D,function(ae){return ae[1]})]}if(this.x===void 0){var z=Object.keys(this.data).map(function(ae){return T.data[ae].length}),j=H(z);b=this.dataFormat==="file"?[0,this.data.length]:[0,j]}else b=S(this.x);var U=d,$=U[1]-U[0];this.xScale=this.x===void 0?Ca().range([0,this.width]).domain(un(Array(b[1]).keys())):Ca().range([0,this.width]).domain(this.x),this.yScale=vo().range([this.height,0]).domain([0,U[1]+.05*$])}},{key:"addLabels",value:function(){this.xLabel!==""&&this.svg.append("text").attr("x",this.width/2).attr("y",this.height+this.margin.bottom/1.3).attr("dx","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.xLabel),this.yLabel!==""&&this.svg.append("text").attr("transform","rotate(-90)").attr("y",0-this.margin.left/2).attr("x",0-this.height/2).attr("dy","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.yLabel)}},{key:"addAxes",value:function(){var d=this,b=it(this.xScale).tickSize(0).tickFormat(function(D){return d.xValueFormat?Ze(d.xValueFormat)(D):D}),T=we(this.yScale).tickSize(0).tickFormat(function(D){return d.yValueFormat?Ze(d.yValueFormat)(D):D});this.svg.append("g").attr("transform","translate(0,"+this.height+")").call(b).attr("class","xAxis".concat(this.graphClass)).selectAll("text").attr("transform","translate(-10, 0)rotate(-45)").style("text-anchor","end").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.95,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize),this.svg.append("g").call(T).attr("class","yAxis".concat(this.graphClass)).selectAll("text").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.95,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize),Tt("path.domain").attr("stroke","transparent"),Tt("g.tick").style("opacity",1)}},{key:"makeAxesRough",value:function(d,b){var T="xAxis".concat(this.graphClass),D="yAxis".concat(this.graphClass),z="rough-".concat(T),j="rough-".concat(D);$e(".".concat(T)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{stroke:"black",fillStyle:"hachure"});me.setAttribute("class",z),d.appendChild(me)}),Tt(".".concat(z)).attr("transform","translate(0, ".concat(this.height,")")),$e(".".concat(D)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{stroke:"black",fillStyle:"hachure"});me.setAttribute("class",j),d.appendChild(me)})}},{key:"setTitle",value:function(d){this.svg.append("text").attr("x",this.width/2).attr("y",0-this.margin.top/2).attr("text-anchor","middle").style("font-size",this.titleFontSize===void 0?"".concat(Math.min(20,Math.min(this.width,this.height)/4),"px"):this.titleFontSize).style("font-family",this.fontFamily).style("opacity",.8).text(d)}},{key:"addInteraction",value:function(){var d=this,b=this;this.chartScreen=this.svg.append("g").attr("pointer-events","all"),this.dataSources.map(function(T,D){var z=d.data.map(function($,ae){return d.x===void 0?[d.xScale(ae),d.yScale($[T])]:[d.xScale(d.x[ae]),d.yScale(+$[T])]}).filter(function($){return $[0]!==void 0}),j=ax().x(function($){return $[0]}).y(function($){return $[1]});d.svg.append("path").datum(z).attr("fill","none").attr("stroke","blue").attr("stroke-width",1.5).attr("d",j).attr("visibility","hidden");var U=T+"class";d.svg.append("g").attr("class",U+"text").append("text").style("font-size",d.tooltipFontSize).style("opacity",0).style("font-family",d.fontFamily).attr("text-anchor","middle").attr("alignment-baseline","middle")}),this.chartScreen.append("rect").attr("width",this.width).attr("height",this.height).attr("fill","none").on("mousemove",function(T){var D=Lo(this)[0],z=b.xScale.domain(),j=b.xScale.range(),U=x(j[0],j[1]+1,b.xScale.step()),$=w(U,D),ae=z[$];b.dataSources.map(function(me,Te){var xe=b.dataFormat==="file"?b.x===void 0?b.data[ae]:b.data[$]:b.data[me][$],St="."+me+"classtext";b.dataFormat==="file"?$e(St).selectAll("text").style("opacity",1).html(b.x===void 0?"(".concat($,",").concat(xe[me],")"):"(".concat(b.x[$],", ").concat(xe[me],")")).attr("x",b.x===void 0?b.xScale($):b.xScale(b.x[$])).attr("y",b.yScale(xe[me])-6):$e(St).selectAll("text").style("opacity",1).html(b.x===void 0?"(".concat($,", ").concat(xe,")"):"(".concat(b.x[$],", ").concat(xe,")")).attr("x",b.x===void 0?b.xScale($):b.xScale(b.x[$])).attr("y",b.yScale(xe))})}).on("mouseout",function(){b.dataSources.map(function(T){$e("."+T+"classtext").selectAll("text").style("opacity",0)})})}},{key:"initRoughObjects",value:function(){var d=t(ar);this.roughSvg=document.getElementById(this.roughId),this.rcAxis=d.d.svg(this.roughSvg,{options:{strokeWidth:this.axisStrokeWidth,roughness:this.axisRoughness}}),this.rc=d.d.svg(this.roughSvg,{options:{stroke:this.stroke==="none"?void 0:this.stroke,strokeWidth:this.strokeWidth,roughness:this.roughness,bowing:this.bowing,fillStyle:this.fillStyle}})}},{key:"drawFromObject",value:function(){var d=this;this.colors===void 0&&(this.colors=cr.colors),this.dataSources=Object.keys(this.data),this.initRoughObjects(),this.addScales(),this.dataSources.map(function(z,j){var U=d.data[z].map(function(me,Te){return d.x===void 0?[d.xScale(Te),d.yScale(+me)]:[d.xScale(d.x[Te]),d.yScale(me)]}),$=U.filter(function(me){return me[0]!==void 0}),ae=d.rc.curve($,{stroke:d.colors.length===1?d.colors[0]:d.colors[j],roughness:d.roughness,bowing:d.bowing});d.roughSvg.appendChild(ae).setAttribute("class",d.graphClass),d.circle===!0&&U.forEach(function(me,Te){var xe=d.rc.circle(me[0],me[1],d.circleRadius,{stroke:d.colors[j],fill:d.colors[j],fillStyle:"solid",strokeWidth:1,roughness:d.circleRoughness});d.roughSvg.appendChild(xe)})});var b=this.dataSources.map(function(z,j){return{color:d.colors[j],text:z}}),T=6*b.reduce(function(z,j){return z>j.text.length?z:j.text.length},0)+35,D=11*b.length+8;this.legend===!0&&pe.addLegend(this,b,T,D,2),this.addAxes(),this.addLabels(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.interactive===!0&&this.addInteraction()}},{key:"drawFromFile",value:function(){var d=this;this.colors===void 0&&(this.colors=cr.colors),this.initRoughObjects(),this.addScales(),this.dataSources.map(function(z,j){var U=d.data.map(function(ae,me){return d.x===void 0?[d.xScale(me),d.yScale(ae[z])]:[d.xScale(d.x[me]),d.yScale(+ae[z])]}).filter(function(ae){return ae[0]!==void 0}),$=d.rc.curve(U,{stroke:d.colors[j],strokeWidth:d.strokeWidth,roughness:1,bowing:10});d.roughSvg.appendChild($),d.circle===!0&&U.forEach(function(ae,me){var Te=d.rc.circle(ae[0],ae[1],d.circleRadius,{stroke:d.colors[j],fill:d.colors[j],fillStyle:"solid",strokeWidth:1,roughness:d.circleRoughness});d.roughSvg.appendChild(Te)})});var b=this.dataSources.map(function(z,j){return{color:d.colors[j],text:z}}),T=6*b.reduce(function(z,j){return z>j.text.length?z:j.text.length},0)+35,D=11*b.length+8;this.legend===!0&&pe.addLegend(this,b,T,D,2),this.addAxes(),this.addLabels(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.interactive===!0&&this.addInteraction()}}]),m}();function tR(m){return(tR=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(m)}function LV(m,d){if(!(m instanceof d))throw new TypeError("Cannot call a class as a function")}function nR(m,d){for(var b=0;b30?30:m},OV=function(){function m(d){LV(this,m),this.el=d.element,this.element=d.element,this.margin=d.margin||{top:50,right:20,bottom:10,left:20},this.title=d.title,this.colors=d.colors||cr.colors,this.highlight=d.highlight,this.roughness=DV(d.roughness)||0,this.strokeWidth=d.strokeWidth||.75,this.innerStrokeWidth=d.innerStrokeWidth||1,this.fillStyle=d.fillStyle,this.bowing=d.bowing||0,this.fillWeight=d.fillWeight||.5,this.simplification=d.simplification||.2,this.interactive=d.interactive!==!1,this.titleFontSize=d.titleFontSize,this.tooltipFontSize=d.tooltipFontSize||"0.95rem",this.font=d.font||0,this.dataFormat=tR(d.data)==="object"?"object":"file",this.labels=this.dataFormat==="object"?"labels":d.labels,this.values=this.dataFormat==="object"?"values":d.values,this.labels!==void 0&&this.values!==void 0?(this.legend=d.legend!==!1,this.legendPosition=d.legendPosition||"right",this.initChartValues(d),this.resolveFont(),this.drawChart=this.resolveData(d.data),this.drawChart(),d.title!=="undefined"&&this.setTitle(d.title)):console.log("Error for ".concat(this.el,": Must include labels and values when instantiating Donut chart. Skipping chart."))}return IV(m,[{key:"initChartValues",value:function(d){var b=d.width?d.width:350,T=d.height?d.height:450;this.width=b-this.margin.left-this.margin.right,this.height=T-this.margin.top-this.margin.bottom,this.roughId=this.el+"_svg",this.graphClass=this.el.substring(1,this.el.length),this.interactionG="g."+this.graphClass,this.radius=Math.min(this.width,this.height)/2,this.setSvg()}},{key:"setSvg",value:function(){this.svg=$e(this.el).append("svg").attr("width",this.width+this.margin.left+this.margin.right).attr("height",this.height+this.margin.top+this.margin.bottom).append("g").attr("id",this.roughId).attr("transform","translate("+this.margin.left+","+this.margin.top+")")}},{key:"resolveFont",value:function(){this.font===0||this.font===void 0||this.font.toString().toLowerCase()==="gaegu"?(l.addFontGaegu(this.svg),this.fontFamily="gaeguregular"):this.font===1||this.font.toString().toLowerCase()==="indie flower"?(l.addFontIndieFlower(this.svg),this.fontFamily="indie_flowerregular"):this.fontFamily=this.font}},{key:"resolveData",value:function(d){var b=this;return typeof d!="string"?function(){b.data=d,b.drawFromObject()}:d.includes(".csv")?function(){ze(d).then(function(T){console.log(T),b.data=T,b.drawFromFile()})}:d.includes(".tsv")?function(){At(d).then(function(T){console.log(T),b.data=T,b.drawFromFile()})}:d.includes(".json")?function(){lt(d).then(function(T){console.log(T),b.data=T,b.drawFromFile()})}:void 0}},{key:"setTitle",value:function(d){this.svg.append("text").attr("x",this.width/2).attr("y",0-this.margin.top/3).attr("class","title").attr("text-anchor","middle").style("font-size",this.titleFontSize===void 0?"".concat(Math.min(40,Math.min(this.width,this.height)/4),"px"):this.titleFontSize).style("font-family",this.fontFamily).style("opacity",.8).text(d)}},{key:"addInteraction",value:function(){Tt(this.interactionG).append("g").attr("transform","translate(".concat(this.width/2,", ").concat(this.height/2,")")).data(this.dataFormat==="object"?this.makePie(this.data[this.values]):this.makePie(this.data)).append("path").attr("d",this.makeArc).attr("stroke-width","0px").attr("fill","transparent");var d,b=$e(this.el).append("div").style("opacity",0).attr("class","tooltip").style("position","absolute").style("background-color","white").style("border","solid").style("border-width","1px").style("border-radius","5px").style("padding","3px").style("font-family",this.fontFamily).style("font-size",this.tooltipFontSize).style("pointer-events","none"),T=this;Tt(this.interactionG).on("mouseover",function(){b.style("opacity",1),d=$e(this).selectAll("path").style("stroke"),T.highlight===void 0?$e(this).selectAll("path").style("opacity",.5):$e(this).selectAll("path").style("stroke",T.highlight)}),Tt(this.interactionG).on("mouseout",function(){b.style("opacity",0),$e(this).selectAll("path").style("stroke",d),$e(this).selectAll("path").style("opacity",1)}),Tt(this.interactionG).on("mousemove",function(D){var z=$e(this).attr("attrX"),j=$e(this).attr("attrY"),U=Lo(this);b.html("".concat(z,": ").concat(j)).style("opacity",.95).attr("class",function($){}).style("transform","translate(".concat(U[0]+T.margin.left,`px, + `).concat(U[1]-T.height-T.margin.bottom,"px)"))})}},{key:"initRoughObjects",value:function(){var d=t(ar);this.roughSvg=document.getElementById(this.roughId),this.rcAxis=d.d.svg(this.roughSvg,{options:{strokeWidth:this.strokeWidth>=3?3:this.strokeWidth}}),this.rc=d.d.svg(this.roughSvg,{options:{fill:this.color,strokeWidth:this.innerStrokeWidth,roughness:this.roughness,bowing:this.bowing,fillStyle:this.fillStyle}})}},{key:"drawFromObject",value:function(){var d=this;this.initRoughObjects(),this.makePie=yd(),this.makeArc=gc().innerRadius(0).outerRadius(this.radius),this.arcs=this.makePie(this.data[this.values]),this.arcs.forEach(function(z,j){var U=d.rc.arc(d.width/2,d.height/2,2*d.radius,2*d.radius,z.startAngle-Math.PI/2,z.endAngle-Math.PI/2,!0,{fill:d.colors[j],stroke:d.colors[j]});U.setAttribute("class",d.graphClass);var $=d.roughSvg.appendChild(U);$.setAttribute("attrY",d.data[d.values][j]),$.setAttribute("attrX",d.data[d.labels][j])}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth);var b=this.data.labels.map(function(z,j){return{color:d.colors[j],text:z}}),T=6*b.reduce(function(z,j){return z>j.text.length?z:j.text.length},0)+35,D=11*b.length+8;this.legend===!0&&pe.addLegend(this,b,T,D),this.interactive===!0&&this.addInteraction()}},{key:"drawFromFile",value:function(){var d=this;this.initRoughObjects(),this.makePie=yd().value(function(j){return j[d.values]}).sort(null);var b=[];this.makeArc=gc().innerRadius(0).outerRadius(this.radius),this.arcs=this.makePie(this.data),this.arcs.forEach(function(j,U){var $=d.rc.arc(d.width/2,d.height/2,2*d.radius,2*d.radius,j.startAngle-Math.PI/2,j.endAngle-Math.PI/2,!0,{fill:d.colors[U],stroke:d.colors[U]});$.setAttribute("class",d.graphClass);var ae=d.roughSvg.appendChild($);ae.setAttribute("attrY",j.data[d.values]),ae.setAttribute("attrX",j.data[d.labels]),b.push(j.data[d.labels])}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth);var T=b.map(function(j,U){return{color:d.colors[U],text:j}}),D=6*T.reduce(function(j,U){return j>U.text.length?j:U.text.length},0)+35,z=11*T.length+8;this.legend===!0&&pe.addLegend(this,T,D,z),this.interactive===!0&&this.addInteraction()}}]),m}();function iR(m){return(iR=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(m)}function NV(m,d){if(!(m instanceof d))throw new TypeError("Cannot call a class as a function")}function rR(m,d){for(var b=0;b20?20:m},sR=["pink","skyblue","coral","gold","teal","grey","darkgreen","pink","brown","slateblue","grey1","orange"],zV=function(){function m(d){NV(this,m),this.el=d.element,this.element=d.element,this.margin=d.margin||{top:50,right:20,bottom:50,left:100},this.title=d.title,this.colorVar=d.colorVar,this.roughness=UV(d.roughness)||1,this.highlight=d.highlight,this.highlightLabel=d.highlightLabel||"xy",this.radius=d.radius||8,this.fillStyle=d.fillStyle,this.bowing=d.bowing||0,this.axisStrokeWidth=d.axisStrokeWidth||.4,this.axisRoughness=d.axisRoughness||.9,this.interactive=d.interactive!==!1,this.curbZero=d.curbZero===!0,this.innerStrokeWidth=d.innerStrokeWidth||1,this.stroke=d.stroke||"black",this.fillWeight=d.fillWeight||.85,this.simplification=d.simplification||.2,this.colors=d.colors,this.strokeWidth=d.strokeWidth||1,this.titleFontSize=d.titleFontSize,this.axisFontSize=d.axisFontSize,this.tooltipFontSize=d.tooltipFontSize||"0.95rem",this.font=d.font||0,this.dataFormat=iR(d.data)==="object"?"object":"file",this.x=this.dataFormat==="object"?"x":d.x,this.y=this.dataFormat==="object"?"y":d.y,this.xValueFormat=d.xValueFormat,this.yValueFormat=d.yValueFormat,this.xLabel=d.xLabel||"",this.yLabel=d.yLabel||"",this.labelFontSize=d.labelFontSize||"1rem",this.initChartValues(d),this.resolveFont(),this.drawChart=this.resolveData(d.data),this.drawChart(),d.title!=="undefined"&&this.setTitle(d.title)}return FV(m,[{key:"resolveFont",value:function(){this.font===0||this.font===void 0||this.font.toString().toLowerCase()==="gaegu"?(l.addFontGaegu(this.svg),this.fontFamily="gaeguregular"):this.font===1||this.font.toString().toLowerCase()==="indie flower"?(l.addFontIndieFlower(this.svg),this.fontFamily="indie_flowerregular"):this.fontFamily=this.font}},{key:"initChartValues",value:function(d){var b=d.width?d.width:300,T=d.height?d.height:400;this.width=b-this.margin.left-this.margin.right,this.height=T-this.margin.top-this.margin.bottom,this.roughId=this.el+"_svg",this.graphClass=this.el.substring(1,this.el.length),this.interactionG="g."+this.graphClass,this.setSvg()}},{key:"setSvg",value:function(){this.svg=$e(this.el).append("svg").attr("width",this.width+this.margin.left+this.margin.right).attr("height",this.height+this.margin.top+this.margin.bottom).append("g").attr("id",this.roughId).attr("transform","translate("+this.margin.left+","+this.margin.top+")")}},{key:"resolveData",value:function(d){var b=this;return typeof d!="string"?function(){b.data=d,b.drawFromObject()}:d.includes(".csv")?function(){ze(d).then(function(T){console.log(T),b.data=T,b.drawFromFile()})}:d.includes(".tsv")?function(){At(d).then(function(T){b.data=T,b.drawFromFile()})}:void 0}},{key:"addScales",value:function(){var d=this,b=this.dataFormat==="file"?S(this.data,function(ae){return+ae[d.x]}):S(this.data[this.x]),T=b[1]-b[0],D=this.dataFormat==="file"?S(this.data,function(ae){return+ae[d.y]}):S(this.data[this.y]),z=D[1]-D[0],j=this.dataFormat==="file"?S(this.data,function(ae){return ae[d.colorVar]}):[1,1];if(this.dataFormat==="file"){var U=S(this.data,function(ae){return+ae[d.radius]}),$=Math.min(this.width,this.height)/2/2;this.radiusScale=vo().range([8,$]).domain(U)}this.curbZero===!0&&(D[0]>0&&(D[0]=0),b[0]>0&&(b[0]=0)),this.xScale=vo().range([0,this.width]).domain([b[0]-.05*T,b[1]+.05*T]),this.yScale=vo().range([this.height,0]).domain([D[0]-.05*z,D[1]+.05*z]),this.colorScale=zs().range(this.colors).domain(j)}},{key:"addLabels",value:function(){this.xLabel!==""&&this.svg.append("text").attr("x",this.width/2).attr("y",this.height+this.margin.bottom/1.3).attr("dx","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.xLabel),this.yLabel!==""&&this.svg.append("text").attr("transform","rotate(-90)").attr("y",0-this.margin.left/2).attr("x",0-this.height/2).attr("dy","1em").attr("class","labelText").style("text-anchor","middle").style("font-family",this.fontFamily).style("font-size",this.labelFontSize).text(this.yLabel)}},{key:"addAxes",value:function(){var d=this,b=it(this.xScale).tickSize(0).tickFormat(function(D){return d.xValueFormat?Ze(d.xValueFormat)(D):D}),T=we(this.yScale).tickSize(0).tickFormat(function(D){return d.yValueFormat?Ze(d.yValueFormat)(D):D});this.svg.append("g").attr("transform","translate(0,"+this.height+")").call(b).attr("class","xAxis".concat(this.graphClass)).selectAll("text").attr("transform","translate(-10, 0)rotate(-45)").style("text-anchor","end").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.95,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize),this.svg.append("g").call(T).attr("class","yAxis".concat(this.graphClass)).selectAll("text").style("font-family",this.fontFamily).style("font-size",this.axisFontSize===void 0?"".concat(Math.min(.95,Math.min(this.width,this.height)/140),"rem"):this.axisFontSize),Tt("path.domain").attr("stroke","transparent"),Tt("g.tick").style("opacity",1)}},{key:"makeAxesRough",value:function(d,b){var T="xAxis".concat(this.graphClass),D="yAxis".concat(this.graphClass),z="rough-".concat(T),j="rough-".concat(D);$e(".".concat(T)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{stroke:"black",fillStyle:"hachure"});me.setAttribute("class",z),d.appendChild(me)}),Tt(".".concat(z)).attr("transform","translate(0, ".concat(this.height,")")),$e(".".concat(D)).selectAll("path.domain").each(function(U,$){var ae=$e(this).node().getAttribute("d"),me=b.path(ae,{stroke:"black",fillStyle:"hachure"});me.setAttribute("class",j),d.appendChild(me)})}},{key:"setTitle",value:function(d){this.svg.append("text").attr("x",this.width/2).attr("y",0-this.margin.top/2).attr("text-anchor","middle").style("font-size",this.titleFontSize===void 0?"".concat(Math.min(20,Math.min(this.width,this.height)/4),"px"):this.titleFontSize).style("font-family",this.fontFamily).style("opacity",.8).text(d)}},{key:"addInteraction",value:function(){var d=this,b=Tt(this.interactionG).data(this.dataFormat==="file"?this.data:this.data.x).append("circle").attr("cx",function(j,U){return d.dataFormat==="file"?d.xScale(+j[d.x]):d.xScale(+d.data[d.x][U])}).attr("cy",function(j,U){return d.dataFormat==="file"?d.yScale(+j[d.y]):d.yScale(+d.data[d.y][U])});this.dataFormat==="file"?b.attr("r",function(j){return typeof d.radius=="number"?.7*d.radius:.6*d.radiusScale(+j[d.radius])}).attr("fill","transparent"):b.attr("r",function(j,U){return typeof d.radius=="number"?.7*d.radius:.6*d.radius[U]}).attr("fill","transparent");var T,D=$e(this.el).append("div").style("opacity",0).attr("class","tooltip").style("position","absolute").style("background-color","white").style("border","solid").style("border-width","1px").style("border-radius","5px").style("padding","3px").style("font-family",this.fontFamily).style("font-size",this.tooltipFontSize).style("pointer-events","none"),z=this;Tt(this.interactionG).on("mouseover",function(){D.style("opacity",1),T=$e(this).selectAll("path").style("stroke"),z.highlight===void 0?$e(this).selectAll("path:nth-child(1)").style("opacity",.4):$e(this).selectAll("path:nth-child(1)").style("stroke",z.highlight),$e(this).selectAll("path:nth-child(2)").style("stroke-width",z.strokeWidth+1.2)}),Tt(this.interactionG).on("mouseout",function(){D.style("opacity",0),$e(this).selectAll("path").style("opacity",1),$e(this).selectAll("path:nth-child(1)").style("stroke",T),$e(this).selectAll("path:nth-child(2)").style("stroke",z.stroke),$e(this).selectAll("path:nth-child(2)").style("stroke-width",z.strokeWidth)}),Tt(this.interactionG).on("mousemove",function(j){var U=$e(this).attr("attrX"),$=$e(this).attr("attrY"),ae=$e(this).attr("attrHighlightLabel"),me=Lo(this);D.html(z.highlightLabel==="xy"?"x: ".concat(U,"
y: ").concat($):"".concat(ae,"")).attr("class",function(Te){}).style("transform","translate(".concat(me[0]+z.margin.left,`px, + `).concat(me[1]-(z.height+z.margin.top+z.margin.bottom),"px)"))})}},{key:"initRoughObjects",value:function(){var d=t(ar);this.roughSvg=document.getElementById(this.roughId),this.rcAxis=d.d.svg(this.roughSvg,{options:{strokeWidth:this.axisStrokeWidth,roughness:this.axisRoughness}}),this.rc=d.d.svg(this.roughSvg,{options:{stroke:this.stroke==="none"?void 0:this.stroke,strokeWidth:this.innerStrokeWidth,roughness:this.roughness,bowing:this.bowing,fillStyle:this.fillStyle}})}},{key:"drawFromObject",value:function(){var d=this;this.colors===void 0&&(this.colors=sR[0]),this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.data.x.forEach(function(b,T){var D=d.rc.circle(d.xScale(+b),d.yScale(+d.data[d.y][T]),typeof d.radius=="number"?d.radius:d.radius[T],{fill:typeof d.colors=="string"?d.colors:d.colors.length===1?d.colors[0]:d.colors[T],simplification:d.simplification,fillWeight:d.fillWeight}),z=d.roughSvg.appendChild(D);z.setAttribute("class",d.graphClass),z.setAttribute("attrX",b),z.setAttribute("attrY",d.data[d.y][T]),z.setAttribute("attrHighlightLabel",d.data[d.highlightLabel])}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}},{key:"drawFromFile",value:function(){var d=this;this.colors===void 0&&(this.colors=sR),this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.data.forEach(function(b,T){var D=d.rc.circle(d.xScale(+b[d.x]),d.yScale(+b[d.y]),typeof d.radius=="number"?d.radius:d.radiusScale(+b[d.radius]),{fill:d.colorVar===void 0?d.colors[0]:d.colorScale(b[d.colorVar]),simplification:d.simplification,fillWeight:d.fillWeight}),z=d.roughSvg.appendChild(D);z.setAttribute("class",d.graphClass),z.setAttribute("attrX",b[d.x]),z.setAttribute("attrY",b[d.y]),z.setAttribute("attrHighlightLabel",b[d.highlightLabel])}),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}}]),m}();function oR(m){return(oR=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(m)}function BV(m,d){if(!(m instanceof d))throw new TypeError("Cannot call a class as a function")}function aR(m,d){for(var b=0;b20?20:m},GV=function(){function m(d){BV(this,m),this.el=d.element,this.data=d.data,this.element=d.element,this.margin=d.margin||{top:50,right:20,bottom:70,left:100},this.title=d.title,this.colors=d.colors||cr.colors,this.highlight=d.highlight||"coral",this.roughness=HV(d.roughness)||1,this.stroke=d.stroke||"black",this.strokeWidth=d.strokeWidth||1,this.axisStrokeWidth=d.axisStrokeWidth||.5,this.axisRoughness=d.axisRoughness||.5,this.innerStrokeWidth=d.innerStrokeWidth||1,this.fillStyle=d.fillStyle,this.bowing=d.bowing||0,this.fillWeight=d.fillWeight||.5,this.simplification=d.simplification||.2,this.interactive=d.interactive!==!1,this.titleFontSize=d.titleFontSize,this.axisFontSize=d.axisFontSize,this.tooltipFontSize=d.tooltipFontSize||"0.95rem",this.font=d.font||0,this.dataFormat=oR(d.data)==="object"?"object":"file",this.labels=d.labels,this.values=d.values,this.padding=d.padding||.1,this.xLabel=d.xLabel||"",this.yLabel=d.yLabel||"",this.labelFontSize=d.labelFontSize||"1rem",this.initChartValues(d),this.resolveFont(),this.drawChart=this.resolveData(d.data),this.drawChart(),d.title!=="undefined"&&this.setTitle(d.title)}return VV(m,[{key:"initChartValues",value:function(d){var b=d.width?d.width:350,T=d.height?d.height:450;this.width=b-this.margin.left-this.margin.right,this.height=T-this.margin.top-this.margin.bottom,this.roughId=this.el+"_svg",this.graphClass=this.el.substring(1,this.el.length),this.interactionG="g."+this.graphClass,this.setSvg()}},{key:"setSvg",value:function(){this.svg=$e(this.el).append("svg").attr("width",this.width+this.margin.left+this.margin.right).attr("height",this.height+this.margin.top+this.margin.bottom).append("g").attr("id",this.roughId).attr("transform","translate("+this.margin.left+","+this.margin.top+")")}},{key:"resolveFont",value:function(){this.font===0||this.font===void 0||this.font.toString().toLowerCase()==="gaegu"?(l.addFontGaegu(this.svg),this.fontFamily="gaeguregular"):this.font===1||this.font.toString().toLowerCase()==="indie flower"?(l.addFontIndieFlower(this.svg),this.fontFamily="indie_flowerregular"):this.fontFamily=this.font}},{key:"getTotal",value:function(d){for(var b=0;b".concat(z," ").concat(U,": ").concat(j)).style("opacity",.95).attr("class",function(ae){}).style("transform","translate(".concat($[0]+T.margin.left,`px, + `).concat($[1]-(T.height+T.margin.top+T.margin.bottom),"px)"))})}},{key:"initRoughObjects",value:function(){var d=t(ar);this.roughSvg=document.getElementById(this.roughId),this.rcAxis=d.d.svg(this.roughSvg,{options:{strokeWidth:this.axisStrokeWidth,roughness:this.axisRoughness}}),this.rc=d.d.svg(this.roughSvg,{options:{stroke:this.stroke==="none"?void 0:this.stroke,strokeWidth:this.innerStrokeWidth,roughness:this.roughness,bowing:this.bowing,fillStyle:this.fillStyle}})}},{key:"stacking",value:function(){var d=this;this.data.forEach(function(b){var T=Object.keys(b),D=0;T.forEach(function(z,j){if(j>0&&z!=="total"){D+=parseInt(b[z]);var U=d.xScale(b[d.labels]),$=d.yScale(D),ae=d.xScale.bandwidth(),me=d.height-d.yScale(+b[z]),Te=d.rc.rectangle(U,$,ae,me,{fill:d.colors[j],stroke:d.colors[j],simplification:d.simplification,fillWeight:d.fillWeight}),xe=d.roughSvg.appendChild(Te);xe.setAttribute("class",d.graphClass),xe.setAttribute("attrX",b[d.labels]),xe.setAttribute("keyY",z),xe.setAttribute("attrY",+b[z]),xe.setAttribute("x",U),xe.setAttribute("y",$),xe.setAttribute("width",ae),xe.setAttribute("height",me)}})})}},{key:"drawFromObject",value:function(){this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.stacking(),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}},{key:"drawFromFile",value:function(){this.initRoughObjects(),this.addScales(),this.addAxes(),this.makeAxesRough(this.roughSvg,this.rcAxis),this.addLabels(),this.stacking(),Tt(this.interactionG).selectAll("path:nth-child(2)").style("stroke-width",this.strokeWidth),this.interactive===!0&&this.addInteraction()}}]),m}();i={Bar:cd,BarH:Fa,Donut:Nt,Line:kV,Pie:OV,Scatter:zV,StackedBar:GV},n.exports=i})()})(lV);var Uce=lV.exports;Object.defineProperty(ms,"__esModule",{value:!0});ms.StackedBar=ms.Line=mV=ms.Scatter=pV=ms.Pie=dV=ms.Donut=fV=ms.BarH=hV=ms.Bar=void 0;var B1=uV(le),yf=uV(Uce);function cV(){if(typeof WeakMap!="function")return null;var n=new WeakMap;return cV=function(){return n},n}function uV(n){if(n&&n.__esModule)return n;var e=cV();if(e&&e.has(n))return e.get(n);var t={};if(n!=null){var i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var s=i?Object.getOwnPropertyDescriptor(n,r):null;s&&(s.get||s.set)?Object.defineProperty(t,r,s):t[r]=n[r]}}return t.default=n,e&&e.set(n,t),t}function HD(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function zce(n){for(var e=1;e=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function Xce(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,s;for(s=0;s=0)&&(t[r]=n[r]);return t}var qce=0,Yce=function(e){return"".concat(e).concat(""+ ++qce)},vf=function(e){return function(t){var i=t.prefix,r=jce(t,["prefix"]),s=(0,B1.useRef)(),o=(0,B1.useState)(Yce(i||"roughviz")),a=Vce(o,1),l=a[0];return(0,B1.useEffect)(function(){var c=s.current;return c&&new e(zce({element:"#"+l},r)),function(){if(c)for(;c.firstChild;)c.removeChild(c.firstChild)}},[l,r,s]),B1.default.createElement("div",{id:l,ref:s})}},Kce=vf(yf.Bar),hV=ms.Bar=Kce,Zce=vf(yf.BarH),fV=ms.BarH=Zce,Jce=vf(yf.Donut),dV=ms.Donut=Jce,Qce=vf(yf.Pie),pV=ms.Pie=Qce,$ce=vf(yf.Scatter),mV=ms.Scatter=$ce,eue=vf(yf.Line);ms.Line=eue;var tue=vf(yf.StackedBar);ms.StackedBar=tue;const nue=({LeaderboardData:n,colNames:e=[],tableStyleOptions:t={},barData:i=[],barHData:r=[],scatterData:s={},pieData:o=[],donutData:a=[],chartOptions:l={},numGraphs:c,graphTypes:u=[],onClose:f})=>{const[g,y]=le.useState(n?n.map(I=>I.slice(1)):[]),v=le.useRef(null),w=eC(),S=window.devicePixelRatio||1,[x,M]=le.useMemo(()=>{const I=w?Math.min(window.innerWidth*1.5,800):Math.floor(window.innerWidth*.6),R=w?Math.min(window.innerHeight*1.5,800):Math.floor(window.innerHeight*.8);return[I,R]},[w]),A=le.useCallback((I,R)=>{if(!I||!R)return;const W=R.reduce((fe,Se)=>fe+Se,0),se=g.length,Z=Math.floor(M/(se+1))+15,oe=(se+1)*Z;w?(I.width=W*S,I.height=oe*S,I.style.width=`${Math.min(W,x)}px`,I.style.height=`${Math.min(oe,M)}px`,I.getContext("2d").scale(S,S)):(I.width=W,I.height=oe)},[g,M,x,w,S]),C=le.useCallback(I=>{var se;if(!I)return[];const R=((se=g[0])==null?void 0:se.length)||0,W=Array(R).fill(0);return g.forEach(Z=>{Z.forEach((oe,fe)=>{let Se=I.measureText(oe.toString()).width;Se<15&&(Se=15),W[fe]=Math.max(W[fe],Se)})}),e.slice(1).forEach((Z,oe)=>{const fe=I.measureText(Z).width*1.3;W[oe]=Math.max(W[oe],fe)*2.3}),W},[g,e]),N=le.useCallback(()=>{if(!v.current)return;const I=v.current,R=I.getContext("2d");R.clearRect(0,0,I.width,I.height);const W=Fce.canvas(I),se=g.length,Z=C(R);A(I,Z);const oe=Math.floor(M/(se+1))+15,fe=window.innerWidth>window.innerHeight,Se=w?fe?"1.75vw":"4vw":`${Math.min(Math.floor(oe*.055),Math.floor(Math.min(...Z)*.055))}vmin`,Fe=w?fe?"1.75vw":"4vw":`${Math.min(Math.floor(oe*.055),Math.floor(Math.min(...Z)*.055))}vmin`,X=t.headerColors||["#e3968e","#91a6bc","#a8c6a0","#b8a3bb","#e6b87d","#e6e6a3","#b8a690","#e2b0c2","#c9c9c9"],ie=t.cellColor||"#FFFFFF";let re=0;e.slice(1).forEach((de,Oe)=>{const it=Z[Oe],we=X[Oe%X.length];W.rectangle(re,0,it,oe,{fill:we,fillStyle:"hachure",fillWeight:10,hachureAngle:30,roughness:5,bowing:1,stroke:"grey",strokeWidth:3}),R.font=`${Se} Virgil`,R.fillStyle="grey",R.textAlign="center",R.textBaseline="middle",R.fillText(de,re+it/2,oe/2),re+=it}),g.forEach((de,Oe)=>{let it=0;de.forEach((we,Ve)=>{const Ye=Z[Ve],He=(Oe+1)*oe;W.rectangle(it,He,Ye,oe,{fill:ie,fillStyle:"solid",roughness:5,bowing:1,stroke:"grey",strokeWidth:4}),R.font=`${Fe} Virgil`,R.fillStyle="grey",R.textAlign="center",R.textBaseline="middle",R.fillText(we.toString(),it+Ye/2,He+oe/2),it+=Ye})})},[g,e,t,C,A,M,w]);le.useEffect(()=>{N()},[N]);const L=(I,R)=>{switch(I){case"bar":case"barH":case"pie":case"donut":return{labels:R[0],values:R[1]};case"scatter":return{x:R[0],y:R[1]};default:return R}},F=le.useCallback((I,R)=>{if(!R)return null;try{const W=L(I,R);if(I==="pie"&&(!Array.isArray(W.values)||W.values.some(oe=>oe<=0)))throw new Error("Values prop must be an array of positive numbers for pie chart.");const se={...l[I]||{},labels:{show:!0,fontSize:"1rem",fontFamily:"Virgil",color:"grey"},margin:{top:100,right:40,bottom:80,left:150}},Z={data:W,labels:"labels",values:"values",...se,font:"Virgil",height:400,width:600};switch(I){case"bar":return Ke.createElement(hV,Z);case"barH":return Ke.createElement(fV,Z);case"scatter":return Ke.createElement(mV,Z);case"pie":return Ke.createElement(pV,Z);case"donut":return Ke.createElement(dV,Z);default:return null}}catch(W){return console.error(`Error rendering ${I} graph:`,W),null}},[l]),H=I=>{switch(I){case"bar":return i;case"barH":return r;case"scatter":return s;case"pie":return o;case"donut":return a;default:return[]}};return Ke.createElement(QS.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.3},style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.8)",zIndex:9999}},Ke.createElement("div",{style:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",width:"90%",height:"95%",overflowY:"auto"}},Ke.createElement(wce,{display:"flex",justifyContent:"center",alignItems:"center",mb:2,width:"100%"},Ke.createElement(mce,{variant:"h4",component:"div",fontFamily:"Virgil",style:{fontSize:w?"min(6vw, 6vh)":"min(5vw, 5vh)"},textAlign:"center"},"Leaderboard")),Ke.createElement("div",{style:{display:"flex",flexDirection:w?"column":"row",justifyContent:"space-between",alignItems:"center",width:"100%",height:"100%",gap:"20px"}},Ke.createElement("div",{style:{width:w?"100%":"50%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",overflow:"auto"}},Ke.createElement("div",{style:{display:"flex",overflow:w?"auto":"hidden",maxWidth:"100%",maxHeight:"100%"}},Ke.createElement("canvas",{ref:v,style:{width:w?"auto":"100%",height:w?"auto":"100%",objectFit:"contain",imageRendering:"pixelated"}}))),!w&&Ke.createElement("div",{style:{width:"50%",height:"90%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"20px",marginTop:"600px"}},u.map(I=>Ke.createElement("div",{key:I,style:{display:"flex",justifyContent:"center",paddingTop:"40px"}},F(I,H(I))))),!w&&Ke.createElement("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 text-center px-4 w-full sm:w-auto text-xxs sm:text-xxs"},"All models hosted on ",Ke.createElement("a",{className:"underline",href:"https://huggingface.co/JoshuaKelleyDs",target:"_blank"},"🤗 Hugging Face")),!w&&Ke.createElement("div",{className:"absolute top-24 left-1/2 transform -translate-x-1/2 text-center px-3 w-full sm:w-auto text-xxs sm:text-xxs"},"(This is a fun project... Please don't take this too serious!!!)")),Ke.createElement("button",{onClick:f,type:"button",style:{position:"fixed",bottom:"10px",left:"50%",transform:"translateX(-50%)",fontSize:"min(2vw, 2vh)",padding:"8px 16px",fontWeight:"bold",textShadow:"0 1px 1px rgba(0, 0, 0, 0.2)",borderRadius:"9999px",color:"#fff",backgroundColor:"#6b7280",transition:"background-color 150ms ease-in-out",cursor:"pointer"},onMouseEnter:I=>{I.target.style.backgroundColor="#4b5563"},onMouseLeave:I=>{I.target.style.backgroundColor="#6b7280"}},"Close")))},iue="modulepreload",rue=function(n){return"/"+n},GD={},om=function(e,t,i){if(!t||t.length===0)return e();const r=document.getElementsByTagName("link");return Promise.all(t.map(s=>{if(s=rue(s),s in GD)return;GD[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!i)for(let u=r.length-1;u>=0;u--){const f=r[u];if(f.href===s&&(!o||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const c=document.createElement("link");if(c.rel=o?"stylesheet":iue,o||(c.as="script",c.crossOrigin=""),c.href=s,document.head.appendChild(c),o)return new Promise((u,f)=>{c.addEventListener("load",u),c.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})},sue=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>om(()=>Promise.resolve().then(()=>Yy),void 0).then(({default:i})=>i(...t)):e=fetch,(...t)=>e(...t)};class YP extends Error{constructor(e,t="FunctionsError",i){super(e),this.name=t,this.context=i}}class oue extends YP{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class aue extends YP{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class lue extends YP{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var $T;(function(n){n.Any="any",n.ApNortheast1="ap-northeast-1",n.ApNortheast2="ap-northeast-2",n.ApSouth1="ap-south-1",n.ApSoutheast1="ap-southeast-1",n.ApSoutheast2="ap-southeast-2",n.CaCentral1="ca-central-1",n.EuCentral1="eu-central-1",n.EuWest1="eu-west-1",n.EuWest2="eu-west-2",n.EuWest3="eu-west-3",n.SaEast1="sa-east-1",n.UsEast1="us-east-1",n.UsWest1="us-west-1",n.UsWest2="us-west-2"})($T||($T={}));var cue=globalThis&&globalThis.__awaiter||function(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(f){o(f)}}function l(u){try{c(i.throw(u))}catch(f){o(f)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,e||[])).next())})};class uue{constructor(e,{headers:t={},customFetch:i,region:r=$T.Any}={}){this.url=e,this.headers=t,this.region=r,this.fetch=sue(i)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var i;return cue(this,void 0,void 0,function*(){try{const{headers:r,method:s,body:o}=t;let a={},{region:l}=t;l||(l=this.region),l&&l!=="any"&&(a["x-region"]=l);let c;o&&(r&&!Object.prototype.hasOwnProperty.call(r,"Content-Type")||!r)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",c=o):typeof o=="string"?(a["Content-Type"]="text/plain",c=o):typeof FormData<"u"&&o instanceof FormData?c=o:(a["Content-Type"]="application/json",c=JSON.stringify(o)));const u=yield this.fetch(`${this.url}/${e}`,{method:s||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),r),body:c}).catch(v=>{throw new oue(v)}),f=u.headers.get("x-relay-error");if(f&&f==="true")throw new aue(u);if(!u.ok)throw new lue(u);let g=((i=u.headers.get("Content-Type"))!==null&&i!==void 0?i:"text/plain").split(";")[0].trim(),y;return g==="application/json"?y=yield u.json():g==="application/octet-stream"?y=yield u.blob():g==="text/event-stream"?y=u:g==="multipart/form-data"?y=yield u.formData():y=yield u.text(),{data:y,error:null}}catch(r){return{data:null,error:r}}})}}var hue=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},am=hue();const fue=am.fetch,KP=am.fetch.bind(am),gV=am.Headers,due=am.Request,pue=am.Response,Yy=Object.freeze(Object.defineProperty({__proto__:null,Headers:gV,Request:due,Response:pue,default:KP,fetch:fue},Symbol.toStringTag,{value:"Module"}));class mue extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}class gue{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=KP:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const i=this.fetch;let r=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async s=>{var o,a,l;let c=null,u=null,f=null,g=s.status,y=s.statusText;if(s.ok){if(this.method!=="HEAD"){const x=await s.text();x===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?u=x:u=JSON.parse(x))}const w=(o=this.headers.Prefer)===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),S=(a=s.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");w&&S&&S.length>1&&(f=parseInt(S[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(u)&&(u.length>1?(c={code:"PGRST116",details:`Results contain ${u.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},u=null,f=null,g=406,y="Not Acceptable"):u.length===1?u=u[0]:u=null)}else{const w=await s.text();try{c=JSON.parse(w),Array.isArray(c)&&s.status===404&&(u=[],c=null,g=200,y="OK")}catch{s.status===404&&w===""?(g=204,y="No Content"):c={message:w}}if(c&&this.isMaybeSingle&&(!((l=c==null?void 0:c.details)===null||l===void 0)&&l.includes("0 rows"))&&(c=null,g=200,y="OK"),c&&this.shouldThrowOnError)throw new mue(c)}return{error:c,data:u,count:f,status:g,statusText:y}});return this.shouldThrowOnError||(r=r.catch(s=>{var o,a,l;return{error:{message:`${(o=s==null?void 0:s.name)!==null&&o!==void 0?o:"FetchError"}: ${s==null?void 0:s.message}`,details:`${(a=s==null?void 0:s.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(l=s==null?void 0:s.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),r.then(e,t)}}class yue extends gue{select(e){let t=!1;const i=(e??"*").split("").map(r=>/\s/.test(r)&&!t?"":(r==='"'&&(t=!t),r)).join("");return this.url.searchParams.set("select",i),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:i,foreignTable:r,referencedTable:s=r}={}){const o=s?`${s}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${i===void 0?"":i?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:i=t}={}){const r=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:i,referencedTable:r=i}={}){const s=typeof r>"u"?"offset":`${r}.offset`,o=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:i=!1,buffers:r=!1,wal:s=!1,format:o="text"}={}){var a;const l=[e?"analyze":null,t?"verbose":null,i?"settings":null,r?"buffers":null,s?"wal":null].filter(Boolean).join("|"),c=(a=this.headers.Accept)!==null&&a!==void 0?a:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${c}"; options=${l};`,o==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class op extends yue{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const i=Array.from(new Set(t)).map(r=>typeof r=="string"&&new RegExp("[,()]").test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(e,`in.(${i})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:i,type:r}={}){let s="";r==="plain"?s="pl":r==="phrase"?s="ph":r==="websearch"&&(s="w");const o=i===void 0?"":`(${i})`;return this.url.searchParams.append(e,`${s}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,i])=>{this.url.searchParams.append(t,`eq.${i}`)}),this}not(e,t,i){return this.url.searchParams.append(e,`not.${t}.${i}`),this}or(e,{foreignTable:t,referencedTable:i=t}={}){const r=i?`${i}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,i){return this.url.searchParams.append(e,`${t}.${i}`),this}}class vue{constructor(e,{headers:t={},schema:i,fetch:r}){this.url=e,this.headers=t,this.schema=i,this.fetch=r}select(e,{head:t=!1,count:i}={}){const r=t?"HEAD":"GET";let s=!1;const o=(e??"*").split("").map(a=>/\s/.test(a)&&!s?"":(a==='"'&&(s=!s),a)).join("");return this.url.searchParams.set("select",o),i&&(this.headers.Prefer=`count=${i}`),new op({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:i=!0}={}){const r="POST",s=[];if(this.headers.Prefer&&s.push(this.headers.Prefer),t&&s.push(`count=${t}`),i||s.push("missing=default"),this.headers.Prefer=s.join(","),Array.isArray(e)){const o=e.reduce((a,l)=>a.concat(Object.keys(l)),[]);if(o.length>0){const a=[...new Set(o)].map(l=>`"${l}"`);this.url.searchParams.set("columns",a.join(","))}}return new op({method:r,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:i=!1,count:r,defaultToNull:s=!0}={}){const o="POST",a=[`resolution=${i?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&a.push(this.headers.Prefer),r&&a.push(`count=${r}`),s||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){const l=e.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){const c=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new op({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const i="PATCH",r=[];return this.headers.Prefer&&r.push(this.headers.Prefer),t&&r.push(`count=${t}`),this.headers.Prefer=r.join(","),new op({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t="DELETE",i=[];return e&&i.push(`count=${e}`),this.headers.Prefer&&i.unshift(this.headers.Prefer),this.headers.Prefer=i.join(","),new op({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const xue="1.15.2",wue={"X-Client-Info":`postgrest-js/${xue}`};class ZP{constructor(e,{headers:t={},schema:i,fetch:r}={}){this.url=e,this.headers=Object.assign(Object.assign({},wue),t),this.schemaName=i,this.fetch=r}from(e){const t=new URL(`${this.url}/${e}`);return new vue(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new ZP(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:i=!1,get:r=!1,count:s}={}){let o;const a=new URL(`${this.url}/rpc/${e}`);let l;i||r?(o=i?"HEAD":"GET",Object.entries(t).filter(([u,f])=>f!==void 0).map(([u,f])=>[u,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([u,f])=>{a.searchParams.append(u,f)})):(o="POST",l=t);const c=Object.assign({},this.headers);return s&&(c.Prefer=`count=${s}`),new op({method:o,url:a,headers:c,schema:this.schemaName,body:l,fetch:this.fetch,allowEmpty:!1})}}const Sue="2.9.5",_ue={"X-Client-Info":`realtime-js/${Sue}`},Mue="1.0.0",yV=1e4,Aue=1e3;var Bp;(function(n){n[n.connecting=0]="connecting",n[n.open=1]="open",n[n.closing=2]="closing",n[n.closed=3]="closed"})(Bp||(Bp={}));var Qs;(function(n){n.closed="closed",n.errored="errored",n.joined="joined",n.joining="joining",n.leaving="leaving"})(Qs||(Qs={}));var pa;(function(n){n.close="phx_close",n.error="phx_error",n.join="phx_join",n.reply="phx_reply",n.leave="phx_leave",n.access_token="access_token"})(pa||(pa={}));var e2;(function(n){n.websocket="websocket"})(e2||(e2={}));var Th;(function(n){n.Connecting="connecting",n.Open="open",n.Closing="closing",n.Closed="closed"})(Th||(Th={}));class vV{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}class bue{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),i=new TextDecoder;return this._decodeBroadcast(e,t,i)}_decodeBroadcast(e,t,i){const r=t.getUint8(1),s=t.getUint8(2);let o=this.HEADER_LENGTH+2;const a=i.decode(e.slice(o,o+r));o=o+r;const l=i.decode(e.slice(o,o+s));o=o+s;const c=JSON.parse(i.decode(e.slice(o,e.byteLength)));return{ref:null,topic:a,event:l,payload:c}}}class Pb{constructor(e,t,i={},r=yV){this.channel=e,this.event=t,this.payload=i,this.timeout=r,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var i;return this._hasReceived(e)&&t((i=this.receivedResp)===null||i===void 0?void 0:i.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(i=>i.status===e).forEach(i=>i.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var WD;(function(n){n.SYNC="sync",n.JOIN="join",n.LEAVE="leave"})(WD||(WD={}));class A0{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const i=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(i.state,{},r=>{const{onJoin:s,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=A0.syncState(this.state,r,s,o),this.pendingDiffs.forEach(l=>{this.state=A0.syncDiff(this.state,l,s,o)}),this.pendingDiffs=[],a()}),this.channel._on(i.diff,{},r=>{const{onJoin:s,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(r):(this.state=A0.syncDiff(this.state,r,s,o),a())}),this.onJoin((r,s,o)=>{this.channel._trigger("presence",{event:"join",key:r,currentPresences:s,newPresences:o})}),this.onLeave((r,s,o)=>{this.channel._trigger("presence",{event:"leave",key:r,currentPresences:s,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,i,r){const s=this.cloneDeep(e),o=this.transformState(t),a={},l={};return this.map(s,(c,u)=>{o[c]||(l[c]=u)}),this.map(o,(c,u)=>{const f=s[c];if(f){const g=u.map(S=>S.presence_ref),y=f.map(S=>S.presence_ref),v=u.filter(S=>y.indexOf(S.presence_ref)<0),w=f.filter(S=>g.indexOf(S.presence_ref)<0);v.length>0&&(a[c]=v),w.length>0&&(l[c]=w)}else a[c]=u}),this.syncDiff(s,{joins:a,leaves:l},i,r)}static syncDiff(e,t,i,r){const{joins:s,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return i||(i=()=>{}),r||(r=()=>{}),this.map(s,(a,l)=>{var c;const u=(c=e[a])!==null&&c!==void 0?c:[];if(e[a]=this.cloneDeep(l),u.length>0){const f=e[a].map(y=>y.presence_ref),g=u.filter(y=>f.indexOf(y.presence_ref)<0);e[a].unshift(...g)}i(a,u,l)}),this.map(o,(a,l)=>{let c=e[a];if(!c)return;const u=l.map(f=>f.presence_ref);c=c.filter(f=>u.indexOf(f.presence_ref)<0),e[a]=c,r(a,c,l),c.length===0&&delete e[a]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(i=>t(i,e[i]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,i)=>{const r=e[i];return"metas"in r?t[i]=r.metas.map(s=>(s.presence_ref=s.phx_ref,delete s.phx_ref,delete s.phx_ref_prev,s)):t[i]=r,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var ri;(function(n){n.abstime="abstime",n.bool="bool",n.date="date",n.daterange="daterange",n.float4="float4",n.float8="float8",n.int2="int2",n.int4="int4",n.int4range="int4range",n.int8="int8",n.int8range="int8range",n.json="json",n.jsonb="jsonb",n.money="money",n.numeric="numeric",n.oid="oid",n.reltime="reltime",n.text="text",n.time="time",n.timestamp="timestamp",n.timestamptz="timestamptz",n.timetz="timetz",n.tsrange="tsrange",n.tstzrange="tstzrange"})(ri||(ri={}));const jD=(n,e,t={})=>{var i;const r=(i=t.skipTypes)!==null&&i!==void 0?i:[];return Object.keys(e).reduce((s,o)=>(s[o]=Eue(o,n,e,r),s),{})},Eue=(n,e,t,i)=>{const r=e.find(a=>a.name===n),s=r==null?void 0:r.type,o=t[n];return s&&!i.includes(s)?xV(s,o):t2(o)},xV=(n,e)=>{if(n.charAt(0)==="_"){const t=n.slice(1,n.length);return Rue(e,t)}switch(n){case ri.bool:return Tue(e);case ri.float4:case ri.float8:case ri.int2:case ri.int4:case ri.int8:case ri.numeric:case ri.oid:return Cue(e);case ri.json:case ri.jsonb:return Pue(e);case ri.timestamp:return kue(e);case ri.abstime:case ri.date:case ri.daterange:case ri.int4range:case ri.int8range:case ri.money:case ri.reltime:case ri.text:case ri.time:case ri.timestamptz:case ri.timetz:case ri.tsrange:case ri.tstzrange:return t2(e);default:return t2(e)}},t2=n=>n,Tue=n=>{switch(n){case"t":return!0;case"f":return!1;default:return n}},Cue=n=>{if(typeof n=="string"){const e=parseFloat(n);if(!Number.isNaN(e))return e}return n},Pue=n=>{if(typeof n=="string")try{return JSON.parse(n)}catch(e){return console.log(`JSON parse error: ${e}`),n}return n},Rue=(n,e)=>{if(typeof n!="string")return n;const t=n.length-1,i=n[t];if(n[0]==="{"&&i==="}"){let s;const o=n.slice(1,t);try{s=JSON.parse("["+o+"]")}catch{s=o?o.split(","):[]}return s.map(a=>xV(e,a))}return n},kue=n=>typeof n=="string"?n.replace(" ","T"):n;var XD;(function(n){n.ALL="*",n.INSERT="INSERT",n.UPDATE="UPDATE",n.DELETE="DELETE"})(XD||(XD={}));var qD;(function(n){n.BROADCAST="broadcast",n.PRESENCE="presence",n.POSTGRES_CHANGES="postgres_changes"})(qD||(qD={}));var YD;(function(n){n.SUBSCRIBED="SUBSCRIBED",n.TIMED_OUT="TIMED_OUT",n.CLOSED="CLOSED",n.CHANNEL_ERROR="CHANNEL_ERROR"})(YD||(YD={}));class JP{constructor(e,t={config:{}},i){this.topic=e,this.params=t,this.socket=i,this.bindings={},this.state=Qs.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new Pb(this,pa.join,this.params,this.timeout),this.rejoinTimer=new vV(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Qs.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(r=>r.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Qs.closed,this.socket._remove(this)}),this._onError(r=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,r),this.state=Qs.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Qs.errored,this.rejoinTimer.scheduleTimeout())}),this._on(pa.reply,{},(r,s)=>{this._trigger(this._replyEventName(s),r)}),this.presence=new A0(this),this.broadcastEndpointURL=this._broadcastEndpointURL()}subscribe(e,t=this.timeout){var i,r;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:s,presence:o}}=this.params;this._onError(c=>e&&e("CHANNEL_ERROR",c)),this._onClose(()=>e&&e("CLOSED"));const a={},l={broadcast:s,presence:o,postgres_changes:(r=(i=this.bindings.postgres_changes)===null||i===void 0?void 0:i.map(c=>c.filter))!==null&&r!==void 0?r:[]};this.socket.accessToken&&(a.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:l},a)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",({postgres_changes:c})=>{var u;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),c===void 0){e&&e("SUBSCRIBED");return}else{const f=this.bindings.postgres_changes,g=(u=f==null?void 0:f.length)!==null&&u!==void 0?u:0,y=[];for(let v=0;v{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(c).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,i){return this._on(e,t,i)}async send(e,t={}){var i,r;if(!this._canPush()&&e.type==="broadcast"){const{event:s,payload:o}=e,a={method:"POST",headers:{apikey:(i=this.socket.apiKey)!==null&&i!==void 0?i:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:o}]})};try{return(await this._fetchWithTimeout(this.broadcastEndpointURL,a,(r=t.timeout)!==null&&r!==void 0?r:this.timeout)).ok?"ok":"error"}catch(l){return l.name==="AbortError"?"timed out":"error"}}else return new Promise(s=>{var o,a,l;const c=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(o=this.params)===null||o===void 0?void 0:o.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&s("ok"),c.receive("ok",()=>s("ok")),c.receive("error",()=>s("error")),c.receive("timeout",()=>s("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Qs.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(pa.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(i=>{const r=new Pb(this,pa.leave,{},e);r.receive("ok",()=>{t(),i("ok")}).receive("timeout",()=>{t(),i("timed out")}).receive("error",()=>{i("error")}),r.send(),this._canPush()||r.trigger("ok",{})})}_broadcastEndpointURL(){let e=this.socket.endPoint;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"}async _fetchWithTimeout(e,t,i){const r=new AbortController,s=setTimeout(()=>r.abort(),i),o=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:r.signal}));return clearTimeout(s),o}_push(e,t,i=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let r=new Pb(this,e,t,i);return this._canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}_onMessage(e,t,i){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,i){var r,s;const o=e.toLocaleLowerCase(),{close:a,error:l,leave:c,join:u}=pa;if(i&&[a,l,c,u].indexOf(o)>=0&&i!==this._joinRef())return;let g=this._onMessage(o,t,i);if(t&&!g)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(r=this.bindings.postgres_changes)===null||r===void 0||r.filter(y=>{var v,w,S;return((v=y.filter)===null||v===void 0?void 0:v.event)==="*"||((S=(w=y.filter)===null||w===void 0?void 0:w.event)===null||S===void 0?void 0:S.toLocaleLowerCase())===o}).map(y=>y.callback(g,i)):(s=this.bindings[o])===null||s===void 0||s.filter(y=>{var v,w,S,x,M,A;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in y){const C=y.id,N=(v=y.filter)===null||v===void 0?void 0:v.event;return C&&((w=t.ids)===null||w===void 0?void 0:w.includes(C))&&(N==="*"||(N==null?void 0:N.toLocaleLowerCase())===((S=t.data)===null||S===void 0?void 0:S.type.toLocaleLowerCase()))}else{const C=(M=(x=y==null?void 0:y.filter)===null||x===void 0?void 0:x.event)===null||M===void 0?void 0:M.toLocaleLowerCase();return C==="*"||C===((A=t==null?void 0:t.event)===null||A===void 0?void 0:A.toLocaleLowerCase())}else return y.type.toLocaleLowerCase()===o}).map(y=>{if(typeof g=="object"&&"ids"in g){const v=g.data,{schema:w,table:S,commit_timestamp:x,type:M,errors:A}=v;g=Object.assign(Object.assign({},{schema:w,table:S,commit_timestamp:x,eventType:M,new:{},old:{},errors:A}),this._getPayloadRecords(v))}y.callback(g,i)})}_isClosed(){return this.state===Qs.closed}_isJoined(){return this.state===Qs.joined}_isJoining(){return this.state===Qs.joining}_isLeaving(){return this.state===Qs.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,i){const r=e.toLocaleLowerCase(),s={type:r,filter:t,callback:i};return this.bindings[r]?this.bindings[r].push(s):this.bindings[r]=[s],this}_off(e,t){const i=e.toLocaleLowerCase();return this.bindings[i]=this.bindings[i].filter(r=>{var s;return!(((s=r.type)===null||s===void 0?void 0:s.toLocaleLowerCase())===i&&JP.isEqual(r.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(pa.close,{},e)}_onError(e){this._on(pa.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Qs.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=jD(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=jD(e.columns,e.old_record)),t}}const Lue=()=>{},Iue=typeof WebSocket<"u";class Due{constructor(e,t){var i;this.accessToken=null,this.apiKey=null,this.channels=[],this.endPoint="",this.headers=_ue,this.params={},this.timeout=yV,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=Lue,this.conn=null,this.sendBuffer=[],this.serializer=new bue,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this._resolveFetch=s=>{let o;return s?o=s:typeof fetch>"u"?o=(...a)=>om(()=>Promise.resolve().then(()=>Yy),void 0).then(({default:l})=>l(...a)):o=fetch,(...a)=>o(...a)},this.endPoint=`${e}/${e2.websocket}`,t!=null&&t.transport?this.transport=t.transport:this.transport=null,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const r=(i=t==null?void 0:t.params)===null||i===void 0?void 0:i.apikey;r&&(this.accessToken=r,this.apiKey=r),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:s=>[1e3,2e3,5e3,1e4][s-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(s,o)=>o(JSON.stringify(s)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new vV(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(t==null?void 0:t.fetch)}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this._endPointURL(),void 0,{headers:this.headers});return}if(Iue){this.conn=new WebSocket(this._endPointURL()),this.setupConnection();return}this.conn=new Oue(this._endPointURL(),void 0,{close:()=>{this.conn=null}}),om(()=>import("./browser-5a350e84.js").then(e=>e.b),[]).then(({default:e})=>{this.conn=new e(this._endPointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){const t=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),t}async removeAllChannels(){const e=await Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e}log(e,t,i){this.logger(e,t,i)}connectionState(){switch(this.conn&&this.conn.readyState){case Bp.connecting:return Th.Connecting;case Bp.open:return Th.Open;case Bp.closing:return Th.Closing;default:return Th.Closed}}isConnected(){return this.connectionState()===Th.Open}channel(e,t={config:{}}){const i=new JP(`realtime:${e}`,t,this);return this.channels.push(i),i}push(e){const{topic:t,event:i,payload:r,ref:s}=e,o=()=>{this.encode(e,a=>{var l;(l=this.conn)===null||l===void 0||l.send(a)})};this.log("push",`${t} ${i} (${s})`,r),this.isConnected()?o():this.sendBuffer.push(o)}setAuth(e){this.accessToken=e,this.channels.forEach(t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(pa.access_token,{access_token:e})})}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(i=>i.topic===e&&(i._isJoined()||i._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Mue}))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:r,payload:s,ref:o}=t;(o&&o===this.pendingHeartbeatRef||r===(s==null?void 0:s.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${s.status||""} ${i} ${r} ${o&&"("+o+")"||""}`,s),this.channels.filter(a=>a._isMember(i)).forEach(a=>a._trigger(r,s,o)),this.stateChangeCallbacks.message.forEach(a=>a(t))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(pa.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;const i=e.match(/\?/)?"&":"?",r=new URLSearchParams(t);return`${e}${i}${r}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(Aue,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}class Oue{constructor(e,t,i){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=Bp.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=i.close}}class QP extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function Zr(n){return typeof n=="object"&&n!==null&&"__isStorageError"in n}class Nue extends QP{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class KD extends QP{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var Fue=globalThis&&globalThis.__awaiter||function(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(f){o(f)}}function l(u){try{c(i.throw(u))}catch(f){o(f)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,e||[])).next())})};const wV=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>om(()=>Promise.resolve().then(()=>Yy),void 0).then(({default:i})=>i(...t)):e=fetch,(...t)=>e(...t)},Uue=()=>Fue(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield om(()=>Promise.resolve().then(()=>Yy),void 0)).Response:Response});var Sm=globalThis&&globalThis.__awaiter||function(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(f){o(f)}}function l(u){try{c(i.throw(u))}catch(f){o(f)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,e||[])).next())})};const Rb=n=>n.msg||n.message||n.error_description||n.error||JSON.stringify(n),zue=(n,e)=>Sm(void 0,void 0,void 0,function*(){const t=yield Uue();n instanceof t?n.json().then(i=>{e(new Nue(Rb(i),n.status||500))}).catch(i=>{e(new KD(Rb(i),i))}):e(new KD(Rb(n),n))}),Bue=(n,e,t,i)=>{const r={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?r:(r.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),r.body=JSON.stringify(i),Object.assign(Object.assign({},r),t))};function cM(n,e,t,i,r,s){return Sm(this,void 0,void 0,function*(){return new Promise((o,a)=>{n(t,Bue(e,i,r,s)).then(l=>{if(!l.ok)throw l;return i!=null&&i.noResolveJson?l:l.json()}).then(l=>o(l)).catch(l=>zue(l,a))})})}function n2(n,e,t,i){return Sm(this,void 0,void 0,function*(){return cM(n,"GET",e,t,i)})}function Fc(n,e,t,i,r){return Sm(this,void 0,void 0,function*(){return cM(n,"POST",e,i,r,t)})}function Vue(n,e,t,i,r){return Sm(this,void 0,void 0,function*(){return cM(n,"PUT",e,i,r,t)})}function SV(n,e,t,i,r){return Sm(this,void 0,void 0,function*(){return cM(n,"DELETE",e,i,r,t)})}var Fo=globalThis&&globalThis.__awaiter||function(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(f){o(f)}}function l(u){try{c(i.throw(u))}catch(f){o(f)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,e||[])).next())})};const Hue={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},ZD={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Gue{constructor(e,t={},i,r){this.url=e,this.headers=t,this.bucketId=i,this.fetch=wV(r)}uploadOrUpdate(e,t,i,r){return Fo(this,void 0,void 0,function*(){try{let s;const o=Object.assign(Object.assign({},ZD),r),a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});typeof Blob<"u"&&i instanceof Blob?(s=new FormData,s.append("cacheControl",o.cacheControl),s.append("",i)):typeof FormData<"u"&&i instanceof FormData?(s=i,s.append("cacheControl",o.cacheControl)):(s=i,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType);const l=this._removeEmptyFolders(t),c=this._getFinalPath(l),u=yield this.fetch(`${this.url}/object/${c}`,Object.assign({method:e,body:s,headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{})),f=yield u.json();return u.ok?{data:{path:l,id:f.Id,fullPath:f.Key},error:null}:{data:null,error:f}}catch(s){if(Zr(s))return{data:null,error:s};throw s}})}upload(e,t,i){return Fo(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,i)})}uploadToSignedUrl(e,t,i,r){return Fo(this,void 0,void 0,function*(){const s=this._removeEmptyFolders(e),o=this._getFinalPath(s),a=new URL(this.url+`/object/upload/sign/${o}`);a.searchParams.set("token",t);try{let l;const c=Object.assign({upsert:ZD.upsert},r),u=Object.assign(Object.assign({},this.headers),{"x-upsert":String(c.upsert)});typeof Blob<"u"&&i instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),l.append("",i)):typeof FormData<"u"&&i instanceof FormData?(l=i,l.append("cacheControl",c.cacheControl)):(l=i,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType);const f=yield this.fetch(a.toString(),{method:"PUT",body:l,headers:u}),g=yield f.json();return f.ok?{data:{path:s,fullPath:g.Key},error:null}:{data:null,error:g}}catch(l){if(Zr(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e){return Fo(this,void 0,void 0,function*(){try{let t=this._getFinalPath(e);const i=yield Fc(this.fetch,`${this.url}/object/upload/sign/${t}`,{},{headers:this.headers}),r=new URL(this.url+i.url),s=r.searchParams.get("token");if(!s)throw new QP("No token returned by API");return{data:{signedUrl:r.toString(),path:e,token:s},error:null}}catch(t){if(Zr(t))return{data:null,error:t};throw t}})}update(e,t,i){return Fo(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,i)})}move(e,t){return Fo(this,void 0,void 0,function*(){try{return{data:yield Fc(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(i){if(Zr(i))return{data:null,error:i};throw i}})}copy(e,t){return Fo(this,void 0,void 0,function*(){try{return{data:{path:(yield Fc(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers})).Key},error:null}}catch(i){if(Zr(i))return{data:null,error:i};throw i}})}createSignedUrl(e,t,i){return Fo(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e),s=yield Fc(this.fetch,`${this.url}/object/sign/${r}`,Object.assign({expiresIn:t},i!=null&&i.transform?{transform:i.transform}:{}),{headers:this.headers});const o=i!=null&&i.download?`&download=${i.download===!0?"":i.download}`:"";return s={signedUrl:encodeURI(`${this.url}${s.signedURL}${o}`)},{data:s,error:null}}catch(r){if(Zr(r))return{data:null,error:r};throw r}})}createSignedUrls(e,t,i){return Fo(this,void 0,void 0,function*(){try{const r=yield Fc(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),s=i!=null&&i.download?`&download=${i.download===!0?"":i.download}`:"";return{data:r.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${s}`):null})),error:null}}catch(r){if(Zr(r))return{data:null,error:r};throw r}})}download(e,t){return Fo(this,void 0,void 0,function*(){const r=typeof(t==null?void 0:t.transform)<"u"?"render/image/authenticated":"object",s=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),o=s?`?${s}`:"";try{const a=this._getFinalPath(e);return{data:yield(yield n2(this.fetch,`${this.url}/${r}/${a}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(Zr(a))return{data:null,error:a};throw a}})}getPublicUrl(e,t){const i=this._getFinalPath(e),r=[],s=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";s!==""&&r.push(s);const a=typeof(t==null?void 0:t.transform)<"u"?"render/image":"object",l=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});l!==""&&r.push(l);let c=r.join("&");return c!==""&&(c=`?${c}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${i}${c}`)}}}remove(e){return Fo(this,void 0,void 0,function*(){try{return{data:yield SV(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(Zr(t))return{data:null,error:t};throw t}})}list(e,t,i){return Fo(this,void 0,void 0,function*(){try{const r=Object.assign(Object.assign(Object.assign({},Hue),t),{prefix:e||""});return{data:yield Fc(this.fetch,`${this.url}/object/list/${this.bucketId}`,r,{headers:this.headers},i),error:null}}catch(r){if(Zr(r))return{data:null,error:r};throw r}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const Wue="2.5.5",jue={"X-Client-Info":`storage-js/${Wue}`};var ep=globalThis&&globalThis.__awaiter||function(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(f){o(f)}}function l(u){try{c(i.throw(u))}catch(f){o(f)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,e||[])).next())})};class Xue{constructor(e,t={},i){this.url=e,this.headers=Object.assign(Object.assign({},jue),t),this.fetch=wV(i)}listBuckets(){return ep(this,void 0,void 0,function*(){try{return{data:yield n2(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(Zr(e))return{data:null,error:e};throw e}})}getBucket(e){return ep(this,void 0,void 0,function*(){try{return{data:yield n2(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(Zr(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return ep(this,void 0,void 0,function*(){try{return{data:yield Fc(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(i){if(Zr(i))return{data:null,error:i};throw i}})}updateBucket(e,t){return ep(this,void 0,void 0,function*(){try{return{data:yield Vue(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(i){if(Zr(i))return{data:null,error:i};throw i}})}emptyBucket(e){return ep(this,void 0,void 0,function*(){try{return{data:yield Fc(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(Zr(t))return{data:null,error:t};throw t}})}deleteBucket(e){return ep(this,void 0,void 0,function*(){try{return{data:yield SV(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(Zr(t))return{data:null,error:t};throw t}})}}class que extends Xue{constructor(e,t={},i){super(e,t,i)}from(e){return new Gue(this.url,this.headers,e,this.fetch)}}const Yue="2.43.2";let s0="";typeof Deno<"u"?s0="deno":typeof document<"u"?s0="web":typeof navigator<"u"&&navigator.product==="ReactNative"?s0="react-native":s0="node";const Kue={"X-Client-Info":`supabase-js-${s0}/${Yue}`},Zue={headers:Kue},Jue={schema:"public"},Que={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},$ue={};var ehe=globalThis&&globalThis.__awaiter||function(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(f){o(f)}}function l(u){try{c(i.throw(u))}catch(f){o(f)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,e||[])).next())})};const the=n=>{let e;return n?e=n:typeof fetch>"u"?e=KP:e=fetch,(...t)=>e(...t)},nhe=()=>typeof Headers>"u"?gV:Headers,ihe=(n,e,t)=>{const i=the(t),r=nhe();return(s,o)=>ehe(void 0,void 0,void 0,function*(){var a;const l=(a=yield e())!==null&&a!==void 0?a:n;let c=new r(o==null?void 0:o.headers);return c.has("apikey")||c.set("apikey",n),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),i(s,Object.assign(Object.assign({},o),{headers:c}))})};function rhe(n){return n.replace(/\/$/,"")}function she(n,e){const{db:t,auth:i,realtime:r,global:s}=n,{db:o,auth:a,realtime:l,global:c}=e;return{db:Object.assign(Object.assign({},o),t),auth:Object.assign(Object.assign({},a),i),realtime:Object.assign(Object.assign({},l),r),global:Object.assign(Object.assign({},c),s)}}const _V="2.64.2",ohe="http://localhost:9999",ahe="supabase.auth.token",lhe={"X-Client-Info":`gotrue-js/${_V}`},JD=10,i2="X-Supabase-Api-Version",MV={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}};function che(n){return Math.round(Date.now()/1e3)+n}function uhe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){const e=Math.random()*16|0;return(n=="x"?e:e&3|8).toString(16)})}const ua=()=>typeof document<"u",mh={tested:!1,writable:!1},b0=()=>{if(!ua())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(mh.tested)return mh.writable;const n=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(n,n),globalThis.localStorage.removeItem(n),mh.tested=!0,mh.writable=!0}catch{mh.tested=!0,mh.writable=!1}return mh.writable};function kb(n){const e={},t=new URL(n);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((r,s)=>{e[s]=r})}catch{}return t.searchParams.forEach((i,r)=>{e[r]=i}),e}const AV=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>om(()=>Promise.resolve().then(()=>Yy),void 0).then(({default:i})=>i(...t)):e=fetch,(...t)=>e(...t)},hhe=n=>typeof n=="object"&&n!==null&&"status"in n&&"ok"in n&&"json"in n&&typeof n.json=="function",bV=async(n,e,t)=>{await n.setItem(e,JSON.stringify(t))},V1=async(n,e)=>{const t=await n.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}},Lb=async(n,e)=>{await n.removeItem(e)};function fhe(n){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i,r,s,o,a,l,c,u=0;for(n=n.replace("-","+").replace("_","/");u>4,r=(a&15)<<4|l>>2,s=(l&3)<<6|c,t=t+String.fromCharCode(i),l!=64&&r!=0&&(t=t+String.fromCharCode(r)),c!=64&&s!=0&&(t=t+String.fromCharCode(s));return t}class uM{constructor(){this.promise=new uM.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}uM.promiseConstructor=Promise;function QD(n){const e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=n.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");const i=t[1];return JSON.parse(fhe(i))}async function dhe(n){return await new Promise(e=>{setTimeout(()=>e(null),n)})}function phe(n,e){return new Promise((i,r)=>{(async()=>{for(let s=0;s<1/0;s++)try{const o=await n(s);if(!e(s,null,o)){i(o);return}}catch(o){if(!e(s,o)){r(o);return}}})()})}function mhe(n){return("0"+n.toString(16)).substr(-2)}function ghe(){const e=new Uint32Array(56);if(typeof crypto>"u"){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",i=t.length;let r="";for(let s=0;s<56;s++)r+=t.charAt(Math.floor(Math.random()*i));return r}return crypto.getRandomValues(e),Array.from(e,mhe).join("")}async function yhe(n){const t=new TextEncoder().encode(n),i=await crypto.subtle.digest("SHA-256",t),r=new Uint8Array(i);return Array.from(r).map(s=>String.fromCharCode(s)).join("")}function vhe(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function xhe(n){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),n;const t=await yhe(n);return vhe(t)}async function tp(n,e,t=!1){const i=ghe();let r=i;t&&(r+="/PASSWORD_RECOVERY"),await bV(n,`${e}-code-verifier`,r);const s=await xhe(i);return[s,i===s?"plain":"s256"]}const whe=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function She(n){const e=n.headers.get(i2);if(!e||!e.match(whe))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}class $P extends Error{constructor(e,t,i){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=i}}function Mn(n){return typeof n=="object"&&n!==null&&"__isAuthError"in n}class _he extends $P{constructor(e,t,i){super(e,t,i),this.name="AuthApiError",this.status=t,this.code=i}}function Mhe(n){return Mn(n)&&n.name==="AuthApiError"}class EV extends $P{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class xf extends $P{constructor(e,t,i,r){super(e,i,r),this.name=t,this.status=i}}class gh extends xf{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}class Ib extends xf{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class H1 extends xf{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class G1 extends xf{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class $D extends xf{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class r2 extends xf{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function Db(n){return Mn(n)&&n.name==="AuthRetryableFetchError"}class eO extends xf{constructor(e,t,i){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=i}}var Ahe=globalThis&&globalThis.__rest||function(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);rn.msg||n.message||n.error_description||n.error||JSON.stringify(n),bhe=[502,503,504];async function tO(n){var e;if(!hhe(n))throw new r2(Ah(n),0);if(bhe.includes(n.status))throw new r2(Ah(n),n.status);let t;try{t=await n.json()}catch(s){throw new EV(Ah(s),s)}let i;const r=She(n);if(r&&r.getTime()>=MV["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?i=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(i=t.error_code),i){if(i==="weak_password")throw new eO(Ah(t),n.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[])}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((s,o)=>s&&typeof o=="string",!0))throw new eO(Ah(t),n.status,t.weak_password.reasons);throw new _he(Ah(t),n.status||500,i)}const Ehe=(n,e,t,i)=>{const r={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?r:(r.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),r.body=JSON.stringify(i),Object.assign(Object.assign({},r),t))};async function Rn(n,e,t,i){var r;const s=Object.assign({},i==null?void 0:i.headers);s[i2]||(s[i2]=MV["2024-01-01"].name),i!=null&&i.jwt&&(s.Authorization=`Bearer ${i.jwt}`);const o=(r=i==null?void 0:i.query)!==null&&r!==void 0?r:{};i!=null&&i.redirectTo&&(o.redirect_to=i.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await The(n,e,t+a,{headers:s,noResolveJson:i==null?void 0:i.noResolveJson},{},i==null?void 0:i.body);return i!=null&&i.xform?i==null?void 0:i.xform(l):{data:Object.assign({},l),error:null}}async function The(n,e,t,i,r,s){const o=Ehe(e,i,r,s);let a;try{a=await n(t,Object.assign({},o))}catch(l){throw console.error(l),new r2(Ah(l),0)}if(a.ok||await tO(a),i!=null&&i.noResolveJson)return a;try{return await a.json()}catch(l){await tO(l)}}function kc(n){var e;let t=null;khe(n)&&(t=Object.assign({},n),n.expires_at||(t.expires_at=che(n.expires_in)));const i=(e=n.user)!==null&&e!==void 0?e:n;return{data:{session:t,user:i},error:null}}function nO(n){const e=kc(n);return!e.error&&n.weak_password&&typeof n.weak_password=="object"&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.message&&typeof n.weak_password.message=="string"&&n.weak_password.reasons.reduce((t,i)=>t&&typeof i=="string",!0)&&(e.data.weak_password=n.weak_password),e}function Hc(n){var e;return{data:{user:(e=n.user)!==null&&e!==void 0?e:n},error:null}}function Che(n){return{data:n,error:null}}function Phe(n){const{action_link:e,email_otp:t,hashed_token:i,redirect_to:r,verification_type:s}=n,o=Ahe(n,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:t,hashed_token:i,redirect_to:r,verification_type:s},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function Rhe(n){return n}function khe(n){return n.access_token&&n.refresh_token&&n.expires_in}var Lhe=globalThis&&globalThis.__rest||function(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r0&&(y.forEach(v=>{const w=parseInt(v.split(";")[0].split("=")[1].substring(0,1)),S=JSON.parse(v.split(";")[1].split("=")[1]);c[`${S}Page`]=w}),c.total=parseInt(g)),{data:Object.assign(Object.assign({},f),c),error:null}}catch(c){if(Mn(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){try{return await Rn(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Hc})}catch(t){if(Mn(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){try{return await Rn(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:Hc})}catch(i){if(Mn(i))return{data:{user:null},error:i};throw i}}async deleteUser(e,t=!1){try{return await Rn(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:Hc})}catch(i){if(Mn(i))return{data:{user:null},error:i};throw i}}async _listFactors(e){try{const{data:t,error:i}=await Rn(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:r=>({data:{factors:r},error:null})});return{data:t,error:i}}catch(t){if(Mn(t))return{data:null,error:t};throw t}}async _deleteFactor(e){try{return{data:await Rn(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(Mn(t))return{data:null,error:t};throw t}}}const Dhe={getItem:n=>b0()?globalThis.localStorage.getItem(n):null,setItem:(n,e)=>{b0()&&globalThis.localStorage.setItem(n,e)},removeItem:n=>{b0()&&globalThis.localStorage.removeItem(n)}};function iO(n={}){return{getItem:e=>n[e]||null,setItem:(e,t)=>{n[e]=t},removeItem:e=>{delete n[e]}}}function Ohe(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const np={debug:!!(globalThis&&b0()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class TV extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Nhe extends TV{}async function Fhe(n,e,t){np.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",n,e);const i=new globalThis.AbortController;return e>0&&setTimeout(()=>{i.abort(),np.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",n)},e),await globalThis.navigator.locks.request(n,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:i.signal},async r=>{if(r){np.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",n,r.name);try{return await t()}finally{np.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",n,r.name)}}else{if(e===0)throw np.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",n),new Nhe(`Acquiring an exclusive Navigator LockManager lock "${n}" immediately failed`);if(np.debug)try{const s=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(s,null," "))}catch(s){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",s)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await t()}})}Ohe();const Uhe={url:ohe,storageKey:ahe,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:lhe,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1},Yg=30*1e3,rO=3;async function sO(n,e,t){return await t()}class gy{constructor(e){var t,i;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=gy.nextInstanceID,gy.nextInstanceID+=1,this.instanceID>0&&ua()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const r=Object.assign(Object.assign({},Uhe),e);if(this.logDebugMessages=!!r.debug,typeof r.debug=="function"&&(this.logger=r.debug),this.persistSession=r.persistSession,this.storageKey=r.storageKey,this.autoRefreshToken=r.autoRefreshToken,this.admin=new Ihe({url:r.url,headers:r.headers,fetch:r.fetch}),this.url=r.url,this.headers=r.headers,this.fetch=AV(r.fetch),this.lock=r.lock||sO,this.detectSessionInUrl=r.detectSessionInUrl,this.flowType=r.flowType,this.hasCustomAuthorizationHeader=r.hasCustomAuthorizationHeader,r.lock?this.lock=r.lock:ua()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=Fhe:this.lock=sO,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?r.storage?this.storage=r.storage:b0()?this.storage=Dhe:(this.memoryStorage={},this.storage=iO(this.memoryStorage)):(this.memoryStorage={},this.storage=iO(this.memoryStorage)),ua()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(s){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",s)}(i=this.broadcastChannel)===null||i===void 0||i.addEventListener("message",async s=>{this._debug("received broadcast notification from other tab or client",s),await this._notifyAllSubscribers(s.data.event,s.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${_V}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){try{const e=ua()?await this._isPKCEFlow():!1;if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){const{data:t,error:i}=await this._getSessionFromURL(e);if(i)return this._debug("#_initialize()","error detecting session from URL",i),(i==null?void 0:i.message)==="Identity is already linked"||(i==null?void 0:i.message)==="Identity is already linked to another user"?{error:i}:(await this._removeSession(),{error:i});const{session:r,redirectType:s}=t;return this._debug("#_initialize()","detected session in URL",r,"redirect type",s),await this._saveSession(r),setTimeout(async()=>{s==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",r):await this._notifyAllSubscribers("SIGNED_IN",r)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){return Mn(e)?{error:e}:{error:new EV("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,i,r;try{await this._removeSession();const s=await Rn(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(i=(t=e==null?void 0:e.options)===null||t===void 0?void 0:t.data)!==null&&i!==void 0?i:{},gotrue_meta_security:{captcha_token:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}},xform:kc}),{data:o,error:a}=s;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(s){if(Mn(s))return{data:{user:null,session:null},error:s};throw s}}async signUp(e){var t,i,r;try{await this._removeSession();let s;if("email"in e){const{email:u,password:f,options:g}=e;let y=null,v=null;this.flowType==="pkce"&&([y,v]=await tp(this.storage,this.storageKey)),s=await Rn(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:g==null?void 0:g.emailRedirectTo,body:{email:u,password:f,data:(t=g==null?void 0:g.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken},code_challenge:y,code_challenge_method:v},xform:kc})}else if("phone"in e){const{phone:u,password:f,options:g}=e;s=await Rn(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:f,data:(i=g==null?void 0:g.data)!==null&&i!==void 0?i:{},channel:(r=g==null?void 0:g.channel)!==null&&r!==void 0?r:"sms",gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken}},xform:kc})}else throw new H1("You must provide either an email or phone number and a password");const{data:o,error:a}=s;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(s){if(Mn(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithPassword(e){try{await this._removeSession();let t;if("email"in e){const{email:s,password:o,options:a}=e;t=await Rn(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:s,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:nO})}else if("phone"in e){const{phone:s,password:o,options:a}=e;t=await Rn(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:s,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:nO})}else throw new H1("You must provide either an email or phone number and a password");const{data:i,error:r}=t;return r?{data:{user:null,session:null},error:r}:!i||!i.session||!i.user?{data:{user:null,session:null},error:new Ib}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign({user:i.user,session:i.session},i.weak_password?{weakPassword:i.weak_password}:null),error:r})}catch(t){if(Mn(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,i,r,s;return await this._removeSession(),await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(i=e.options)===null||i===void 0?void 0:i.scopes,queryParams:(r=e.options)===null||r===void 0?void 0:r.queryParams,skipBrowserRedirect:(s=e.options)===null||s===void 0?void 0:s.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){const t=await V1(this.storage,`${this.storageKey}-code-verifier`),[i,r]=(t??"").split("/"),{data:s,error:o}=await Rn(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:i},xform:kc});return await Lb(this.storage,`${this.storageKey}-code-verifier`),o?{data:{user:null,session:null,redirectType:null},error:o}:!s||!s.session||!s.user?{data:{user:null,session:null,redirectType:null},error:new Ib}:(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:Object.assign(Object.assign({},s),{redirectType:r??null}),error:o})}async signInWithIdToken(e){await this._removeSession();try{const{options:t,provider:i,token:r,access_token:s,nonce:o}=e,a=await Rn(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:i,id_token:r,access_token:s,nonce:o,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:kc}),{data:l,error:c}=a;return c?{data:{user:null,session:null},error:c}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new Ib}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:c})}catch(t){if(Mn(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,i,r,s,o;try{if(await this._removeSession(),"email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await tp(this.storage,this.storageKey));const{error:f}=await Rn(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(t=l==null?void 0:l.data)!==null&&t!==void 0?t:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await Rn(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(r=l==null?void 0:l.data)!==null&&r!==void 0?r:{},create_user:(s=l==null?void 0:l.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u}}throw new H1("You must provide either an email or phone number.")}catch(a){if(Mn(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var t,i;try{e.type!=="email_change"&&e.type!=="phone_change"&&await this._removeSession();let r,s;"options"in e&&(r=(t=e.options)===null||t===void 0?void 0:t.redirectTo,s=(i=e.options)===null||i===void 0?void 0:i.captchaToken);const{data:o,error:a}=await Rn(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:s}}),redirectTo:r,xform:kc});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(r){if(Mn(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithSSO(e){var t,i,r;try{await this._removeSession();let s=null,o=null;return this.flowType==="pkce"&&([s,o]=await tp(this.storage,this.storageKey)),await Rn(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(i=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&i!==void 0?i:void 0}),!((r=e==null?void 0:e.options)===null||r===void 0)&&r.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:s,code_challenge_method:o}),headers:this.headers,xform:Che})}catch(s){if(Mn(s))return{data:null,error:s};throw s}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:t},error:i}=e;if(i)throw i;if(!t)throw new gh;const{error:r}=await Rn(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:r}})}catch(e){if(Mn(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{e.type!="email_change"&&e.type!="phone_change"&&await this._removeSession();const t=`${this.url}/resend`;if("email"in e){const{email:i,type:r,options:s}=e,{error:o}=await Rn(this.fetch,"POST",t,{headers:this.headers,body:{email:i,type:r,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},redirectTo:s==null?void 0:s.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:i,type:r,options:s}=e,{data:o,error:a}=await Rn(this.fetch,"POST",t,{headers:this.headers,body:{phone:i,type:r,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a}}throw new H1("You must provide either an email or phone number and a type")}catch(t){if(Mn(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const i=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await i,await t()))();return this.pendingInLock.push((async()=>{try{await r}catch{}})()),r}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const i=t();for(this.pendingInLock.push((async()=>{try{await i}catch{}})()),await i;this.pendingInLock.length;){const r=[...this.pendingInLock];await Promise.all(r),this.pendingInLock.splice(0,r.length)}return await i}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const t=await V1(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const i=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${i?"":" not"} expired`,"expires_at",e.expires_at),!i){if(this.storage.isServer){const o=this.suppressGetSessionWarning;e=new Proxy(e,{get(l,c,u){return!o&&c==="user"&&console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and many not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),Reflect.get(l,c,u)}})}return{data:{session:e},error:null}}const{session:r,error:s}=await this._callRefreshToken(e.refresh_token);return s?{data:{session:null},error:s}:{data:{session:r},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await Rn(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Hc}):await this._useSession(async t=>{var i,r,s;const{data:o,error:a}=t;if(a)throw a;return!(!((i=o.session)===null||i===void 0)&&i.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new gh}:await Rn(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(s=(r=o.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0,xform:Hc})})}catch(t){if(Mn(t))return{data:{user:null},error:t};throw t}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async i=>{const{data:r,error:s}=i;if(s)throw s;if(!r.session)throw new gh;const o=r.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await tp(this.storage,this.storageKey));const{data:c,error:u}=await Rn(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:Hc});if(u)throw u;return o.user=c.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(i){if(Mn(i))return{data:{user:null},error:i};throw i}}_decodeJWT(e){return QD(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new gh;const t=Date.now()/1e3;let i=t,r=!0,s=null;const o=QD(e.access_token);if(o.exp&&(i=o.exp,r=i<=t),r){const{session:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!a)return{data:{user:null,session:null},error:null};s=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)throw l;s={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:i-t,expires_at:i},await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)}return{data:{user:s.user,session:s},error:null}}catch(t){if(Mn(t))return{data:{session:null,user:null},error:t};throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var i;if(!e){const{data:o,error:a}=t;if(a)throw a;e=(i=o.session)!==null&&i!==void 0?i:void 0}if(!(e!=null&&e.refresh_token))throw new gh;const{session:r,error:s}=await this._callRefreshToken(e.refresh_token);return s?{data:{user:null,session:null},error:s}:r?{data:{user:r.user,session:r},error:null}:{data:{user:null,session:null},error:null}})}catch(t){if(Mn(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e){try{if(!ua())throw new G1("No browser detected.");if(this.flowType==="implicit"&&!this._isImplicitGrantFlow())throw new G1("Not a valid implicit grant flow url.");if(this.flowType=="pkce"&&!e)throw new $D("Not a valid PKCE flow url.");const t=kb(window.location.href);if(e){if(!t.code)throw new $D("No code detected.");const{data:M,error:A}=await this._exchangeCodeForSession(t.code);if(A)throw A;const C=new URL(window.location.href);return C.searchParams.delete("code"),window.history.replaceState(window.history.state,"",C.toString()),{data:{session:M.session,redirectType:null},error:null}}if(t.error||t.error_description||t.error_code)throw new G1(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});const{provider_token:i,provider_refresh_token:r,access_token:s,refresh_token:o,expires_in:a,expires_at:l,token_type:c}=t;if(!s||!a||!o||!c)throw new G1("No session defined in URL");const u=Math.round(Date.now()/1e3),f=parseInt(a);let g=u+f;l&&(g=parseInt(l));const y=g-u;y*1e3<=Yg&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${f}s`);const v=g-f;u-v>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",v,g,u):u-v<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clok for skew",v,g,u);const{data:w,error:S}=await this._getUser(s);if(S)throw S;const x={provider_token:i,provider_refresh_token:r,access_token:s,expires_in:f,expires_at:g,refresh_token:o,token_type:c,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:x,redirectType:t.type},error:null}}catch(t){if(Mn(t))return{data:{session:null,redirectType:null},error:t};throw t}}_isImplicitGrantFlow(){const e=kb(window.location.href);return!!(ua()&&(e.access_token||e.error_description))}async _isPKCEFlow(){const e=kb(window.location.href),t=await V1(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var i;const{data:r,error:s}=t;if(s)return{error:s};const o=(i=r.session)===null||i===void 0?void 0:i.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(Mhe(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await Lb(this.storage,`${this.storageKey}-code-verifier`),await this._notifyAllSubscribers("SIGNED_OUT",null)),{error:null}})}onAuthStateChange(e){const t=uhe(),i={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,i),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})))(),{data:{subscription:i}}}async _emitInitialSession(e){return await this._useSession(async t=>{var i,r;try{const{data:{session:s},error:o}=t;if(o)throw o;await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",e,"session",s)}catch(s){await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",s),console.error(s)}})}async resetPasswordForEmail(e,t={}){let i=null,r=null;this.flowType==="pkce"&&([i,r]=await tp(this.storage,this.storageKey,!0));try{return await Rn(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:i,code_challenge_method:r,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(s){if(Mn(s))return{data:null,error:s};throw s}}async getUserIdentities(){var e;try{const{data:t,error:i}=await this.getUser();if(i)throw i;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(Mn(t))return{data:null,error:t};throw t}}async linkIdentity(e){var t;try{const{data:i,error:r}=await this._useSession(async s=>{var o,a,l,c,u;const{data:f,error:g}=s;if(g)throw g;const y=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await Rn(this.fetch,"GET",y,{headers:this.headers,jwt:(u=(c=f.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(r)throw r;return ua()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(i==null?void 0:i.url),{data:{provider:e.provider,url:i==null?void 0:i.url},error:null}}catch(i){if(Mn(i))return{data:{provider:e.provider,url:null},error:i};throw i}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var i,r;const{data:s,error:o}=t;if(o)throw o;return await Rn(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(r=(i=s.session)===null||i===void 0?void 0:i.access_token)!==null&&r!==void 0?r:void 0})})}catch(t){if(Mn(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){const t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{const i=Date.now();return await phe(async r=>(r>0&&await dhe(200*Math.pow(2,r-1)),this._debug(t,"refreshing attempt",r),await Rn(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:kc})),(r,s)=>{const o=200*Math.pow(2,r);return s&&Db(s)&&Date.now()+o-i{try{await a.callback(e,t)}catch(l){s.push(l)}});if(await Promise.all(o),s.length>0){for(let a=0;athis._autoRefreshTokenTick(),Yg);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async t=>{const{data:{session:i}}=t;if(!i||!i.refresh_token||!i.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const r=Math.floor((i.expires_at*1e3-e)/Yg);this._debug("#_autoRefreshTokenTick()",`access token expires in ${r} ticks, a tick lasts ${Yg}ms, refresh threshold is ${rO} ticks`),r<=rO&&await this._callRefreshToken(i.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof TV)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ua()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,i){const r=[`provider=${encodeURIComponent(t)}`];if(i!=null&&i.redirectTo&&r.push(`redirect_to=${encodeURIComponent(i.redirectTo)}`),i!=null&&i.scopes&&r.push(`scopes=${encodeURIComponent(i.scopes)}`),this.flowType==="pkce"){const[s,o]=await tp(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(s)}`,code_challenge_method:`${encodeURIComponent(o)}`});r.push(a.toString())}if(i!=null&&i.queryParams){const s=new URLSearchParams(i.queryParams);r.push(s.toString())}return i!=null&&i.skipBrowserRedirect&&r.push(`skip_http_redirect=${i.skipBrowserRedirect}`),`${e}?${r.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var i;const{data:r,error:s}=t;return s?{data:null,error:s}:await Rn(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(i=r==null?void 0:r.session)===null||i===void 0?void 0:i.access_token})})}catch(t){if(Mn(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession(async t=>{var i,r;const{data:s,error:o}=t;if(o)return{data:null,error:o};const{data:a,error:l}=await Rn(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:(i=s==null?void 0:s.session)===null||i===void 0?void 0:i.access_token});return l?{data:null,error:l}:(!((r=a==null?void 0:a.totp)===null||r===void 0)&&r.qr_code&&(a.totp.qr_code=`data:image/svg+xml;utf-8,${a.totp.qr_code}`),{data:a,error:null})})}catch(t){if(Mn(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var i;const{data:r,error:s}=t;if(s)return{data:null,error:s};const{data:o,error:a}=await Rn(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(i=r==null?void 0:r.session)===null||i===void 0?void 0:i.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:a})})}catch(t){if(Mn(t))return{data:null,error:t};throw t}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var i;const{data:r,error:s}=t;return s?{data:null,error:s}:await Rn(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:(i=r==null?void 0:r.session)===null||i===void 0?void 0:i.access_token})})}catch(t){if(Mn(t))return{data:null,error:t};throw t}})}async _challengeAndVerify(e){const{data:t,error:i}=await this._challenge({factorId:e.factorId});return i?{data:null,error:i}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){const{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};const i=(e==null?void 0:e.factors)||[],r=i.filter(s=>s.factor_type==="totp"&&s.status==="verified");return{data:{all:i,totp:r},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,i;const{data:{session:r},error:s}=e;if(s)return{data:null,error:s};if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const o=this._decodeJWT(r.access_token);let a=null;o.aal&&(a=o.aal);let l=a;((i=(t=r.user.factors)===null||t===void 0?void 0:t.filter(f=>f.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(l="aal2");const u=o.amr||[];return{data:{currentLevel:a,nextLevel:l,currentAuthenticationMethods:u},error:null}}))}}gy.nextInstanceID=0;const zhe=gy;class Bhe extends zhe{constructor(e){super(e)}}var Vhe=globalThis&&globalThis.__awaiter||function(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(f){o(f)}}function l(u){try{c(i.throw(u))}catch(f){o(f)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,e||[])).next())})};class Hhe{constructor(e,t,i){var r,s,o,a,l,c,u,f;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const g=rhe(e);this.realtimeUrl=`${g}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${g}/auth/v1`,this.storageUrl=`${g}/storage/v1`,this.functionsUrl=`${g}/functions/v1`;const y=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,v={db:Jue,realtime:$ue,auth:Object.assign(Object.assign({},Que),{storageKey:y}),global:Zue},w=she(i??{},v);this.storageKey=(s=(r=w.auth)===null||r===void 0?void 0:r.storageKey)!==null&&s!==void 0?s:"",this.headers=(a=(o=w.global)===null||o===void 0?void 0:o.headers)!==null&&a!==void 0?a:{},this.auth=this._initSupabaseAuthClient((l=w.auth)!==null&&l!==void 0?l:{},this.headers,(c=w.global)===null||c===void 0?void 0:c.fetch),this.fetch=ihe(t,this._getAccessToken.bind(this),(u=w.global)===null||u===void 0?void 0:u.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},w.realtime)),this.rest=new ZP(`${g}/rest/v1`,{headers:this.headers,schema:(f=w.db)===null||f===void 0?void 0:f.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new uue(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new que(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},i={}){return this.rest.rpc(e,t,i)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return Vhe(this,void 0,void 0,function*(){const{data:i}=yield this.auth.getSession();return(t=(e=i.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:i,storage:r,storageKey:s,flowType:o,debug:a},l,c){var u;const f={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Bhe({url:this.authUrl,headers:Object.assign(Object.assign({},f),l),storageKey:s,autoRefreshToken:e,persistSession:t,detectSessionInUrl:i,storage:r,flowType:o,debug:a,fetch:c,hasCustomAuthorizationHeader:(u="Authorization"in this.headers)!==null&&u!==void 0?u:!1})}_initRealtimeClient(e){return new Due(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,i)=>{this._handleTokenChanged(t,"CLIENT",i==null?void 0:i.access_token)})}_handleTokenChanged(e,t,i){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==i?(this.realtime.setAuth(i??null),this.changedAccessToken=i):e==="SIGNED_OUT"&&(this.realtime.setAuth(this.supabaseKey),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Ghe=(n,e,t)=>new Hhe(n,e,t),CV=Ghe("https://tytiywbrumghycmpthig.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InR5dGl5d2JydW1naHljbXB0aGlnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTYyMzY2MTQsImV4cCI6MjAzMTgxMjYxNH0.P2OVu2yxHYr1VLxzvDRA4TOWH3UKn_kKJd0afCOyuXo"),Whe=async()=>{try{const{data:n,error:e}=await CV.from("leaderboard").select("*").order("rank",{ascending:!0});if(e)throw e;return n.map(i=>[i.id,i.rank,i.model,i.elo,i.avg_time,i.params,i.correct_guesses])}catch(n){return console.error("Error fetching leaderboard data:",n),[]}},jhe=async n=>{try{const e=n.map(r=>({id:r[0],rank:r[1],elo:r[3],avg_time:r[4],correct_guesses:r[6]})),{data:t,error:i}=await CV.from("leaderboard").upsert(e,{onConflict:["id"]});if(i)throw i}catch(e){console.error("Error updating leaderboard data:",e)}},Xhe=n=>{n=Math.floor(n);const e=Math.floor(n/60),t=n%60;return`${e.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`},qhe=n=>{for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[n[e],n[t]]=[n[t],n[e]]}},oO=(n,e)=>{if(!n||n.length===0)return[];const t=n.filter(s=>!Wn.BANNED_LABELS.includes(s.label)),i=e-Wn.REJECT_TIME_DELAY;if(i>0&&t.length>0&&t[0].score>Wn.START_REJECT_THRESHOLD){let s=i/Wn.REJECT_TIME_PER_LABEL;for(let o=0;oo?t[o].score=0:t[o].score*=o-s;t.sort((o,a)=>a.score-o.score)}const r=t.reduce((s,o)=>s+o.score,0);return t.forEach(s=>s.score/=r),t},Yhe=(n,e)=>{try{const t=new Worker(new URL("/assets/worker1-2b12d49f.js",self.location),{type:"module"}),i=new Worker(new URL("/assets/worker2-2b12d49f.js",self.location),{type:"module"});return t.postMessage({action:"setModel",modelName:n}),i.postMessage({action:"setModel",modelName:e}),{worker1:t,worker2:i}}catch(t){return console.error("Error creating workers:",t),null}},Khe=(n,e)=>{e("countdown");const t=setInterval(()=>{n(i=>i-1)},1e3);return()=>{clearInterval(t)}},Zhe=(n,e,t,i)=>{n(performance.now()),e([]),t("playing"),i(r=>({...r,lastPredictionTimeModel1:performance.now(),lastPredictionTimeModel2:performance.now()}))},aO=async(n,e,t,i,r,s,o,a,l)=>{if(i||e(!1),t(!0),n(i?"menu":"end"),s&&l){const c=performance.now(),u=s.correctGuessesModel1>0?(c-s.lastPredictionTimeModel1)/s.correctGuessesModel1/1e3:0,f=s.correctGuessesModel2>0?(c-s.lastPredictionTimeModel2)/s.correctGuessesModel2/1e3:0;let g=efe({...s,avgTimeModel1:u,avgTimeModel2:f},a,l);g=g.sort((y,v)=>v[3]-y[3]),r(g);try{await jhe(g)}catch(y){console.error("Error updating database:",y)}o(y=>({...y,correctGuessesModel1:0,correctGuessesModel2:0,lastPredictionTimeModel1:c,lastPredictionTimeModel2:c}))}else console.error("modelStats or LeaderboardData is undefined or has an incorrect structure")},Ob=(n,e,t,i,r,s,o,a)=>{o||a(l=>l-Wn.SKIP_PENALTY),n(o),e(l=>l+1),t(null),i(null),r(!1),s(!0)},Jhe=(n,e,t,i,r,s,o,a,l,c,u,f,g)=>{e==="playing"&&t!==null&&i!==null&&(t-i)/1e3>Wn.GAME_DURATION&&r(n,l,c,u,s,o,a,f,g)},Qhe=(n,e,t,i,r,s,o,a,l,c,u,f,g,y,v)=>{if(n==="playing"&&e!==null&&t!==null&&i!==null){const w=i[r],S=w===e[0].label,x=w===t[0].label;(S||x)&&(v(M=>{const A=performance.now();let C=M.avgPredictionTimeModel1,N=M.avgPredictionTimeModel2;if(S){const L=(A-M.lastPredictionTimeModel1)/1e3;C=(M.avgPredictionTimeModel1*M.correctGuessesModel1+L)/(M.correctGuessesModel1+1)}if(x){const L=(A-M.lastPredictionTimeModel2)/1e3;N=(M.avgPredictionTimeModel2*M.correctGuessesModel2+L)/(M.correctGuessesModel2+1)}return{...M,correctGuessesModel1:S?M.correctGuessesModel1+1:M.correctGuessesModel1,correctGuessesModel2:x?M.correctGuessesModel2+1:M.correctGuessesModel2,lastPredictionTimeModel1:A,lastPredictionTimeModel2:A,avgPredictionTimeModel1:C,avgPredictionTimeModel2:N}}),s(o,a,l,c,u,f,!0,g))}},$he=(n,e,t,i,r,s,o)=>{if(n==="playing"){const a=setInterval(()=>{i&&!e&&!t&&r(),s(!1),o(performance.now())},Wn.PREDICTION_REFRESH_TIME);return()=>{clearInterval(a)}}},efe=(n,e,t)=>{const i={},r=e[0],s=e[1],o=(w,S,x)=>{let M;w<2100?M=32:w>=2100&&w<2400?M=24:M=16;const A=1/(1+Math.pow(10,(S-w)/400));return Math.floor(w+M*(x-A))},a=t.find(w=>w[2]===Wn.MODELNAMEMAP[r])[3],l=t.find(w=>w[2]===Wn.MODELNAMEMAP[s])[3],c=n.correctGuessesModel1>n.correctGuessesModel2?1:n.correctGuessesModel1{const A=w*S,C=x*M,N=S+M;return N?((A+C)/N).toFixed(2):w.toFixed(2)};return t.map(w=>{const[S,x,M,A,C,N,L]=w;if(M===Wn.MODELNAMEMAP[r]){const F=y(parseFloat(C),L,i[r].avgTime,i[r].correctGuesses);return[S,x,M,i[r].elo,F,N,L+i[r].correctGuesses]}else if(M===Wn.MODELNAMEMAP[s]){const F=y(parseFloat(C),L,i[s].avgTime,i[s].correctGuesses);return[S,x,M,i[s].elo,F,N,L+i[s].correctGuesses]}else return w})};function tfe(){const[n,e]=le.useState(!1),[t,i]=le.useState(!1),[r,s]=le.useState(!1),[o,a]=le.useState("menu"),[l,c]=le.useState(Wn.COUNTDOWN_TIMER),[u,f]=le.useState(null),[g,y]=le.useState(null),[v,w]=le.useState(null),[S,x]=le.useState(!1),[M,A]=le.useState(null),[C,N]=le.useState(!1),[L,F]=le.useState(!1),[H,I]=le.useState(null),[R,W]=le.useState(0),[se,Z]=le.useState([]),[oe,fe]=le.useState(null),[Se,Fe]=le.useState(null),[X,ie]=le.useState(0),[re,de]=le.useState(0),[Oe,it]=le.useState(!1),[we,Ve]=le.useState([]),[Ye,He]=le.useState([]),[Xt,jt]=le.useState([]),[ge,Dt]=le.useState([]),[Ie,Ge]=le.useState([]),[Pe,rt]=le.useState([]),We=le.useRef([]),ft=le.useRef(null),Ct=le.useRef(null),te=le.useRef(null),q=eC();le.useEffect(()=>{(async()=>{let ce=await Whe();ce=ce.sort((Ue,Re)=>Re[3]-Ue[3]),rt(ce)})()},[]),le.useEffect(()=>{if(Pe.length>0){const et=Pe[0].map((Ue,Re)=>Pe.map(nt=>nt[Re]));Ve(et[2]),He(et[3]),jt(et[4].map(Ue=>parseFloat(Ue)));const ce=et[5].map(Ue=>{const Re=parseFloat(Ue);return isNaN(Re)?0:Re*1});Dt(ce),Ge(et[6])}},[Pe]);const Me={correctGuessesModel1:0,correctGuessesModel2:0,lastPredictionTimeModel1:0,lastPredictionTimeModel2:0,avgPredictionTimeModel1:0,avgPredictionTimeModel2:0},[Ne,je]=le.useState(Me);le.useEffect(()=>{const et=Math.floor(Math.random()*Wn.MODELPATHS.length);let ce=Math.floor(Math.random()*Wn.MODELPATHS.length);for(;ce===et;)ce=Math.floor(Math.random()*Wn.MODELPATHS.length);const[Ue,Re]=[Wn.MODELPATHS[et],Wn.MODELPATHS[ce]];We.current=[Ue,Re]},[]),le.useEffect(()=>{const{worker1:et,worker2:ce}=Yhe(We.current[0],We.current[1]);ft.current=et,Ct.current=ce;const Ue=nt=>{const ct=nt.data;switch(ct.status){case"ready":i(!0);break;case"update":break;case"result":x(!1);const pn=oO(ct.data,te.current.getTimeSpentDrawing());w(pn),ie(Tn=>Tn+1);break}},Re=nt=>{const ct=nt.data;switch(ct.status){case"ready":s(!0);break;case"update":break;case"result":N(!1);const pn=oO(ct.data,te.current.getTimeSpentDrawing());A(pn),de(Tn=>Tn+1);break}};return ft.current.addEventListener("message",Ue),Ct.current.addEventListener("message",Re),()=>{ft.current.removeEventListener("message",Ue),Ct.current.removeEventListener("message",Re)}},[]),le.useEffect(()=>{t&&r&&(e(!0),lt())},[t,r]),le.useEffect(()=>{const et=setTimeout(()=>{fe(v)},200);return X%10===0&&(fe(v),clearTimeout(et)),()=>{clearTimeout(et)}},[X,v]),le.useEffect(()=>{const et=setTimeout(()=>{Fe(M)},200);return re%10===0&&(Fe(M),clearTimeout(et)),()=>{clearTimeout(et)}},[re,M]);const ze=le.useCallback(()=>{if(te.current){const et=te.current.getCanvasData();et!==null&&(ft.current&&(x(!0),ft.current.postMessage({action:"classify",image:et})),Ct.current&&(N(!0),Ct.current.postMessage({action:"classify",image:et})))}},[]),At=(et=!1)=>{aO(a,en,at,et,ce=>{const Re=ce.sort((nt,ct)=>ct[3]-nt[3]).map((nt,ct)=>(nt[1]=ct+1,nt));rt(Re)},Ne,je,We.current,Pe)},at=(et=!1)=>{te.current&&te.current.clearCanvas(et)},lt=()=>{c(Wn.COUNTDOWN_TIMER),Khe(c,a);const et=Object.values(Wn.LABELS).filter(ce=>!Wn.BANNED_LABELS.includes(ce));qhe(et),I(et),W(0)},Zt=()=>{n?lt():(a("loading"),ft.current.postMessage({action:"load"}),Ct.current.postMessage({action:"load"}))},Ze=()=>{it(et=>!et)},kt=et=>{et?lt():At(!0)};le.useEffect(()=>{o==="countdown"&&l<=0&&Zhe(y,Z,a,je)},[o,l]);const en=le.useCallback(et=>{const ce=te.current.getCanvasData(),Ue=Wn.MODELNAMEMAP[We.current[0]],Re=Wn.MODELNAMEMAP[We.current[1]];Z(nt=>[...nt,{output1:(v==null?void 0:v[0])??null,output2:(M==null?void 0:M[0])??null,image:ce,correct:et,target:H[R],model1Name:Ue,model2Name:Re}])},[v,M,R,H]);le.useEffect(()=>{Jhe(a,o,u,g,aO,et=>{const ce=et.sort((Ue,Re)=>Re[3]-Ue[3]);rt(ce)},Ne,je,en,at,!1,We.current,Pe)},[o,u,g,Ne,We,Pe]),le.useEffect(()=>{Qhe(o,v,M,H,R,Ob,en,W,w,A,F,at,y,Ne,je)},[o,v,M,H,R,Ob,en,W,w,A,F,at,y,Ne,je]),le.useEffect(()=>$he(o,S,C,L,ze,F,f),[o,S,C,L,ze]),le.useEffect(()=>{if(o==="playing"){const et=ce=>ce.preventDefault();return document.addEventListener("touchmove",et,{passive:!1}),()=>{document.removeEventListener("touchmove",et,{passive:!1})}}},[o]);const Ft=o==="menu"||o==="loading",dt=o==="playing",on=o==="countdown",dn=o==="end",Qn=Wn.chartOptionsArray.reduce((et,ce)=>(et[ce.type]=ce.options,et),{});return Ke.createElement(Ke.Fragment,null,Ke.createElement("div",{className:`h-full w-full top-0 left-0 absolute ${dt?"":"pointer-events-none"}`},Ke.createElement(_G,{onSketchChange:()=>{F(!0)},ref:te})),Ke.createElement(Dx,{initial:!1,mode:"wait"},Ft&&Ke.createElement(Eee,{gameState:o,onClick:Zt,onLeaderboardClick:Ze})),Ke.createElement(Dx,{initial:!1,mode:"wait"},on&&Ke.createElement(kee,{countdown:l})),Ke.createElement(Dx,{initial:!1,mode:"wait"},dn&&Ke.createElement(Pee,{predictions:se,onClick:kt})),Ke.createElement(Dx,{initial:!1,mode:"wait"},Oe&&Ke.createElement(nue,{LeaderboardData:Pe,colNames:Wn.colNames,tableStyleOptions:Wn.tableStyleOptionsArray[0],chartOptions:Qn,numGraphs:3,onClose:Ze,barData:[we,Ie],barHData:[we,Ye],pieData:[we,Xt],donutData:[we,Xt],scatterData:[ge,Xt],graphTypes:["bar","barH","scatter"]})),dt&&u!==null&&H&&Ke.createElement("div",{className:"absolute top-5 text-center"},Ke.createElement("h2",{className:"text-4xl"},'Draw "',H[R],'"'),Ke.createElement("h3",{className:"text-2xl"},Xhe(Math.max(Wn.GAME_DURATION-(u-g)/1e3,0)))),dt&&Ke.createElement(Ke.Fragment,null,Ke.createElement("div",{className:"absolute left-0 top-0"},Ke.createElement(cD,{predictions:oe,i:1})),Ke.createElement("div",{className:"absolute right-0 top-0"},Ke.createElement(cD,{predictions:Se,i:2})),Ke.createElement("div",{className:"absolute bottom-5 text-center w-full"},Ke.createElement("div",{className:"flex justify-center gap-20 mb-5"},Ke.createElement("div",{className:"flex flex-col items-center justify-center w-1/4"},Ke.createElement("h1",{className:"text-2xl font-bold text-center"},v&&v[0]&&Ke.createElement(Ke.Fragment,null,Wn.MODELNAMEMAP[We.current[0]],Ke.createElement("br",null),"Prediction: ",v[0].label," (",(100*v[0].score).toFixed(1),"%)"))),Ke.createElement("div",{className:"flex flex-col items-center justify-center w-1/4"},Ke.createElement("h1",{className:"text-2xl font-bold text-center"},M&&M[0]&&Ke.createElement(Ke.Fragment,null,Wn.MODELNAMEMAP[We.current[1]],Ke.createElement("br",null),"Prediction: ",M[0].label," (",(100*M[0].score).toFixed(1),"%)")))),Ke.createElement("div",{className:"flex gap-4 justify-center"},Ke.createElement("button",{className:"px-6 py-2 bg-blue-200 text-[#555555] text-xl rounded-lg hover:bg-blue-300",onClick:at},"Clear"),Ke.createElement("button",{className:"px-6 py-2 bg-green-200 text-[#555555] text-xl rounded-lg hover:bg-green-300",onClick:()=>Ob(en,W,w,A,F,at,!1,y)},"Skip"),Ke.createElement("button",{className:"px-6 py-2 bg-purple-200 text-[#555555] text-xl rounded-lg hover:bg-purple-300",onClick:()=>At(!0)},"Exit")))),Ft&&Ke.createElement(Ke.Fragment,null,!q&&Ke.createElement("div",{className:"absolute bottom-4 right-1/4 transform translate-x-1/2 text-center px-4 w-full sm:w-auto text-xs sm:text-base"},"All models run locally thanks to ",Ke.createElement("a",{className:"underline",href:"https://github.com/xenova/transformers.js",target:"_blank"},"🤗 Transformers.js")),q?Ke.createElement("div",{className:"absolute bottom-1 left-1/2 transform -translate-x-1/2 text-center px-4 w-full text-xs"},"All models run locally thanks to ",Ke.createElement("a",{className:"underline",href:"https://github.com/xenova/transformers.js",target:"_blank"},"🤗 Transformers.js")):Ke.createElement("div",{className:"absolute bottom-4 left-1/4 transform -translate-x-1/2 text-center px-4 w-full sm:w-auto text-xs sm:text-base"},"Hi, I'm Josh and I like building ",Ke.createElement("a",{className:"underline",href:"https://joshuakelley.netlify.app",target:"_blank"},"Stuff"))))}Nb.createRoot(document.getElementById("root")).render(Or.jsx(Ke.StrictMode,{children:Or.jsx(tfe,{})}));export{s2 as g};