@splinetool/loader 0.9.34 → 0.9.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- var hN=Object.create;var $l=Object.defineProperty,pN=Object.defineProperties,dN=Object.getOwnPropertyDescriptor,mN=Object.getOwnPropertyDescriptors,gN=Object.getOwnPropertyNames,Km=Object.getOwnPropertySymbols,yN=Object.getPrototypeOf,Xm=Object.prototype.hasOwnProperty,xN=Object.prototype.propertyIsEnumerable;var Ym=(i,t,e)=>t in i?$l(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,j=(i,t)=>{for(var e in t||(t={}))Xm.call(t,e)&&Ym(i,e,t[e]);if(Km)for(var e of Km(t))xN.call(t,e)&&Ym(i,e,t[e]);return i},ue=(i,t)=>pN(i,mN(t));var Zm=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),vN=(i,t)=>{for(var e in t)$l(i,e,{get:t[e],enumerable:!0})},bN=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of gN(t))!Xm.call(i,n)&&n!==e&&$l(i,n,{get:()=>t[n],enumerable:!(r=dN(t,n))||r.enumerable});return i};var Qm=(i,t,e)=>(e=i!=null?hN(yN(i)):{},bN(t||!i||!i.__esModule?$l(e,"default",{value:i,enumerable:!0}):e,i));var Dv=Zm((Gu,Av)=>{(function(i,t){typeof Gu=="object"&&typeof Av<"u"?t(Gu):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(Gu,function(i){"use strict";i.SVD=function(t,e,r,n,o){if(e=e===void 0||e,r=r===void 0||r,o=1e-64/(n=n||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,c,f,h,d,m,x,S,w,B,O,T,M=t[0].length,F=t.length;if(F<M)throw new TypeError("Invalid matrix: m < n");for(var k=[],N=[],te=[],A=e==="f"?F:M,b=B=x=0;b<F;b++)N[b]=new Array(A).fill(0);for(b=0;b<M;b++)te[b]=new Array(M).fill(0);var V,P=new Array(M).fill(0);for(b=0;b<F;b++)for(a=0;a<M;a++)N[b][a]=t[b][a];for(b=0;b<M;b++){for(k[b]=x,w=0,f=b+1,a=b;a<F;a++)w+=Math.pow(N[a][b],2);if(w<o)x=0;else for(S=(m=N[b][b])*(x=m<0?Math.sqrt(w):-Math.sqrt(w))-w,N[b][b]=m-x,a=f;a<M;a++){for(w=0,c=b;c<F;c++)w+=N[c][b]*N[c][a];for(m=w/S,c=b;c<F;c++)N[c][a]=N[c][a]+m*N[c][b]}for(P[b]=x,w=0,a=f;a<M;a++)w+=Math.pow(N[b][a],2);if(w<o)x=0;else{for(S=(m=N[b][b+1])*(x=m<0?Math.sqrt(w):-Math.sqrt(w))-w,N[b][b+1]=m-x,a=f;a<M;a++)k[a]=N[b][a]/S;for(a=f;a<F;a++){for(w=0,c=f;c<M;c++)w+=N[a][c]*N[b][c];for(c=f;c<M;c++)N[a][c]=N[a][c]+w*k[c]}}B<(O=Math.abs(P[b])+Math.abs(k[b]))&&(B=O)}if(r)for(b=M-1;0<=b;b--){if(x!==0){for(S=N[b][b+1]*x,a=f;a<M;a++)te[a][b]=N[b][a]/S;for(a=f;a<M;a++){for(w=0,c=f;c<M;c++)w+=N[b][c]*te[c][a];for(c=f;c<M;c++)te[c][a]=te[c][a]+w*te[c][b]}}for(a=f;a<M;a++)te[b][a]=0,te[a][b]=0;te[b][b]=1,x=k[b],f=b}if(e){if(e==="f")for(b=M;b<F;b++){for(a=M;a<F;a++)N[b][a]=0;N[b][b]=1}for(b=M-1;0<=b;b--){for(f=b+1,x=P[b],a=f;a<A;a++)N[b][a]=0;if(x!==0){for(S=N[b][b]*x,a=f;a<A;a++){for(w=0,c=f;c<F;c++)w+=N[c][b]*N[c][a];for(m=w/S,c=b;c<F;c++)N[c][a]=N[c][a]+m*N[c][b]}for(a=b;a<F;a++)N[a][b]=N[a][b]/x}else for(a=b;a<F;a++)N[a][b]=0;N[b][b]=N[b][b]+1}}for(n*=B,c=M-1;0<=c;c--)for(var R=0;R<50;R++){for(V=!1,f=c;0<=f;f--){if(Math.abs(k[f])<=n){V=!0;break}if(Math.abs(P[f-1])<=n)break}if(!V){for(d=0,h=f-(w=1),b=f;b<c+1&&(m=w*k[b],k[b]=d*k[b],!(Math.abs(m)<=n));b++)if(x=P[b],P[b]=Math.sqrt(m*m+x*x),d=x/(S=P[b]),w=-m/S,e)for(a=0;a<F;a++)O=N[a][h],T=N[a][b],N[a][h]=O*d+T*w,N[a][b]=-O*w+T*d}if(T=P[c],f===c){if(T<0&&(P[c]=-T,r))for(a=0;a<M;a++)te[a][c]=-te[a][c];break}for(B=P[f],m=(((O=P[c-1])-T)*(O+T)+((x=k[c-1])-(S=k[c]))*(x+S))/(2*S*O),x=Math.sqrt(m*m+1),m=((B-T)*(B+T)+S*(O/(m<0?m-x:m+x)-S))/B,b=f+(w=d=1);b<c+1;b++){if(x=k[b],O=P[b],S=w*x,x*=d,T=Math.sqrt(m*m+S*S),m=B*(d=m/(k[b-1]=T))+x*(w=S/T),x=-B*w+x*d,S=O*w,O*=d,r)for(a=0;a<M;a++)B=te[a][b-1],T=te[a][b],te[a][b-1]=B*d+T*w,te[a][b]=-B*w+T*d;if(T=Math.sqrt(m*m+S*S),m=(d=m/(P[b-1]=T))*x+(w=S/T)*O,B=-w*x+d*O,e)for(a=0;a<F;a++)O=N[a][b-1],T=N[a][b],N[a][b-1]=O*d+T*w,N[a][b]=-O*w+T*d}k[f]=0,k[c]=m,P[c]=B}for(b=0;b<M;b++)P[b]<n&&(P[b]=0);return{u:N,q:P,v:te}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var Kv=Zm((qs,nl)=>{(function(){var i,t="4.17.20",e=200,r="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",n="Expected a function",o="__lodash_hash_undefined__",a=500,c="__lodash_placeholder__",f=1,h=2,d=4,m=1,x=2,S=1,w=2,B=4,O=8,T=16,M=32,F=64,k=128,N=256,te=512,A=30,b="...",V=800,P=16,R=1,E=2,G=3,ae=1/0,ne=9007199254740991,xe=17976931348623157e292,_e=0/0,Le=4294967295,Ue=Le-1,se=Le>>>1,$=[["ary",k],["bind",S],["bindKey",w],["curry",O],["curryRight",T],["flip",te],["partial",M],["partialRight",F],["rearg",N]],W="[object Arguments]",J="[object Array]",H="[object AsyncFunction]",K="[object Boolean]",fe="[object Date]",me="[object DOMException]",ie="[object Error]",re="[object Function]",q="[object GeneratorFunction]",ee="[object Map]",Te="[object Number]",ce="[object Null]",le="[object Object]",he="[object Promise]",pe="[object Proxy]",de="[object RegExp]",be="[object Set]",Se="[object String]",Ie="[object Symbol]",ft="[object Undefined]",Ve="[object WeakMap]",Lt="[object WeakSet]",qe="[object ArrayBuffer]",_t="[object DataView]",Wt="[object Float32Array]",Rr="[object Float64Array]",Ut="[object Int8Array]",zr="[object Int16Array]",mn="[object Int32Array]",gn="[object Uint8Array]",pt="[object Uint8ClampedArray]",jt="[object Uint16Array]",ir="[object Uint32Array]",Co=/\b__p \+= '';/g,Lo=/\b(__p \+=) '' \+/g,To=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ki=/&(?:amp|lt|gt|quot|#39);/g,Yi=/[&<>"']/g,No=RegExp(Ki.source),Nr=RegExp(Yi.source),Xi=/<%-([\s\S]+?)%>/g,qt=/<%([\s\S]+?)%>/g,Kn=/<%=([\s\S]+?)%>/g,_o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Re=/^\w*$/,Ye=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,He=/[\\^$.*+?()[\]{}|]/g,$e=RegExp(He.source),Qe=/^\s+|\s+$/g,ot=/^\s+/,dt=/\s+$/,mt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,at=/\{\n\/\* \[wrapped with (.+)\] \*/,vt=/,? & /,Bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_r=/\\(\\)?/g,yn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,xn=/\w*$/,Pn=/^[-+]0x[0-9a-f]+$/i,il=/^0b[01]+$/i,eb=/^\[object .+?Constructor\]$/,tb=/^0o[0-7]+$/i,rb=/^(?:0|[1-9]\d*)$/,nb=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ol=/($^)/,ib=/['\n\r\u2028\u2029\\]/g,sl="\\ud800-\\udfff",ob="\\u0300-\\u036f",sb="\\ufe20-\\ufe2f",ab="\\u20d0-\\u20ff",Np=ob+sb+ab,_p="\\u2700-\\u27bf",Ip="a-z\\xdf-\\xf6\\xf8-\\xff",lb="\\xac\\xb1\\xd7\\xf7",cb="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ub="\\u2000-\\u206f",fb=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Op="A-Z\\xc0-\\xd6\\xd8-\\xde",Mp="\\ufe0e\\ufe0f",Pp=lb+cb+ub+fb,Fu="['\u2019]",hb="["+sl+"]",Ap="["+Pp+"]",al="["+Np+"]",Dp="\\d+",pb="["+_p+"]",Ep="["+Ip+"]",Bp="[^"+sl+Pp+Dp+_p+Ip+Op+"]",Vu="\\ud83c[\\udffb-\\udfff]",db="(?:"+al+"|"+Vu+")",Gp="[^"+sl+"]",Uu="(?:\\ud83c[\\udde6-\\uddff]){2}",ju="[\\ud800-\\udbff][\\udc00-\\udfff]",Io="["+Op+"]",Rp="\\u200d",zp="(?:"+Ep+"|"+Bp+")",mb="(?:"+Io+"|"+Bp+")",Fp="(?:"+Fu+"(?:d|ll|m|re|s|t|ve))?",Vp="(?:"+Fu+"(?:D|LL|M|RE|S|T|VE))?",Up=db+"?",jp="["+Mp+"]?",gb="(?:"+Rp+"(?:"+[Gp,Uu,ju].join("|")+")"+jp+Up+")*",yb="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",xb="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",kp=jp+Up+gb,vb="(?:"+[pb,Uu,ju].join("|")+")"+kp,bb="(?:"+[Gp+al+"?",al,Uu,ju,hb].join("|")+")",Sb=RegExp(Fu,"g"),wb=RegExp(al,"g"),ku=RegExp(Vu+"(?="+Vu+")|"+bb+kp,"g"),Cb=RegExp([Io+"?"+Ep+"+"+Fp+"(?="+[Ap,Io,"$"].join("|")+")",mb+"+"+Vp+"(?="+[Ap,Io+zp,"$"].join("|")+")",Io+"?"+zp+"+"+Fp,Io+"+"+Vp,xb,yb,Dp,vb].join("|"),"g"),Lb=RegExp("["+Rp+sl+Np+Mp+"]"),Tb=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Nb=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],_b=-1,Tt={};Tt[Wt]=Tt[Rr]=Tt[Ut]=Tt[zr]=Tt[mn]=Tt[gn]=Tt[pt]=Tt[jt]=Tt[ir]=!0,Tt[W]=Tt[J]=Tt[qe]=Tt[K]=Tt[_t]=Tt[fe]=Tt[ie]=Tt[re]=Tt[ee]=Tt[Te]=Tt[le]=Tt[de]=Tt[be]=Tt[Se]=Tt[Ve]=!1;var bt={};bt[W]=bt[J]=bt[qe]=bt[_t]=bt[K]=bt[fe]=bt[Wt]=bt[Rr]=bt[Ut]=bt[zr]=bt[mn]=bt[ee]=bt[Te]=bt[le]=bt[de]=bt[be]=bt[Se]=bt[Ie]=bt[gn]=bt[pt]=bt[jt]=bt[ir]=!0,bt[ie]=bt[re]=bt[Ve]=!1;var Ib={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Ob={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Mb={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Pb={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ab=parseFloat,Db=parseInt,Hp=typeof global=="object"&&global&&global.Object===Object&&global,Eb=typeof self=="object"&&self&&self.Object===Object&&self,Zt=Hp||Eb||Function("return this")(),Hu=typeof qs=="object"&&qs&&!qs.nodeType&&qs,Zi=Hu&&typeof nl=="object"&&nl&&!nl.nodeType&&nl,Wp=Zi&&Zi.exports===Hu,Wu=Wp&&Hp.process,Zr=function(){try{var I=Zi&&Zi.require&&Zi.require("util").types;return I||Wu&&Wu.binding&&Wu.binding("util")}catch{}}(),qp=Zr&&Zr.isArrayBuffer,$p=Zr&&Zr.isDate,Jp=Zr&&Zr.isMap,Kp=Zr&&Zr.isRegExp,Yp=Zr&&Zr.isSet,Xp=Zr&&Zr.isTypedArray;function Fr(I,Y,U){switch(U.length){case 0:return I.call(Y);case 1:return I.call(Y,U[0]);case 2:return I.call(Y,U[0],U[1]);case 3:return I.call(Y,U[0],U[1],U[2])}return I.apply(Y,U)}function Bb(I,Y,U,Ce){for(var je=-1,st=I==null?0:I.length;++je<st;){var $t=I[je];Y(Ce,$t,U($t),I)}return Ce}function Qr(I,Y){for(var U=-1,Ce=I==null?0:I.length;++U<Ce&&Y(I[U],U,I)!==!1;);return I}function Gb(I,Y){for(var U=I==null?0:I.length;U--&&Y(I[U],U,I)!==!1;);return I}function Zp(I,Y){for(var U=-1,Ce=I==null?0:I.length;++U<Ce;)if(!Y(I[U],U,I))return!1;return!0}function yi(I,Y){for(var U=-1,Ce=I==null?0:I.length,je=0,st=[];++U<Ce;){var $t=I[U];Y($t,U,I)&&(st[je++]=$t)}return st}function ll(I,Y){var U=I==null?0:I.length;return!!U&&Oo(I,Y,0)>-1}function qu(I,Y,U){for(var Ce=-1,je=I==null?0:I.length;++Ce<je;)if(U(Y,I[Ce]))return!0;return!1}function It(I,Y){for(var U=-1,Ce=I==null?0:I.length,je=Array(Ce);++U<Ce;)je[U]=Y(I[U],U,I);return je}function xi(I,Y){for(var U=-1,Ce=Y.length,je=I.length;++U<Ce;)I[je+U]=Y[U];return I}function $u(I,Y,U,Ce){var je=-1,st=I==null?0:I.length;for(Ce&&st&&(U=I[++je]);++je<st;)U=Y(U,I[je],je,I);return U}function Rb(I,Y,U,Ce){var je=I==null?0:I.length;for(Ce&&je&&(U=I[--je]);je--;)U=Y(U,I[je],je,I);return U}function Ju(I,Y){for(var U=-1,Ce=I==null?0:I.length;++U<Ce;)if(Y(I[U],U,I))return!0;return!1}var zb=Ku("length");function Fb(I){return I.split("")}function Vb(I){return I.match(Bt)||[]}function Qp(I,Y,U){var Ce;return U(I,function(je,st,$t){if(Y(je,st,$t))return Ce=st,!1}),Ce}function cl(I,Y,U,Ce){for(var je=I.length,st=U+(Ce?1:-1);Ce?st--:++st<je;)if(Y(I[st],st,I))return st;return-1}function Oo(I,Y,U){return Y===Y?Zb(I,Y,U):cl(I,ed,U)}function Ub(I,Y,U,Ce){for(var je=U-1,st=I.length;++je<st;)if(Ce(I[je],Y))return je;return-1}function ed(I){return I!==I}function td(I,Y){var U=I==null?0:I.length;return U?Xu(I,Y)/U:_e}function Ku(I){return function(Y){return Y==null?i:Y[I]}}function Yu(I){return function(Y){return I==null?i:I[Y]}}function rd(I,Y,U,Ce,je){return je(I,function(st,$t,xt){U=Ce?(Ce=!1,st):Y(U,st,$t,xt)}),U}function jb(I,Y){var U=I.length;for(I.sort(Y);U--;)I[U]=I[U].value;return I}function Xu(I,Y){for(var U,Ce=-1,je=I.length;++Ce<je;){var st=Y(I[Ce]);st!==i&&(U=U===i?st:U+st)}return U}function Zu(I,Y){for(var U=-1,Ce=Array(I);++U<I;)Ce[U]=Y(U);return Ce}function kb(I,Y){return It(Y,function(U){return[U,I[U]]})}function Vr(I){return function(Y){return I(Y)}}function Qu(I,Y){return It(Y,function(U){return I[U]})}function $s(I,Y){return I.has(Y)}function nd(I,Y){for(var U=-1,Ce=I.length;++U<Ce&&Oo(Y,I[U],0)>-1;);return U}function id(I,Y){for(var U=I.length;U--&&Oo(Y,I[U],0)>-1;);return U}function Hb(I,Y){for(var U=I.length,Ce=0;U--;)I[U]===Y&&++Ce;return Ce}var Wb=Yu(Ib),qb=Yu(Ob);function $b(I){return"\\"+Pb[I]}function Jb(I,Y){return I==null?i:I[Y]}function Mo(I){return Lb.test(I)}function Kb(I){return Tb.test(I)}function Yb(I){for(var Y,U=[];!(Y=I.next()).done;)U.push(Y.value);return U}function ef(I){var Y=-1,U=Array(I.size);return I.forEach(function(Ce,je){U[++Y]=[je,Ce]}),U}function od(I,Y){return function(U){return I(Y(U))}}function vi(I,Y){for(var U=-1,Ce=I.length,je=0,st=[];++U<Ce;){var $t=I[U];($t===Y||$t===c)&&(I[U]=c,st[je++]=U)}return st}function ul(I){var Y=-1,U=Array(I.size);return I.forEach(function(Ce){U[++Y]=Ce}),U}function Xb(I){var Y=-1,U=Array(I.size);return I.forEach(function(Ce){U[++Y]=[Ce,Ce]}),U}function Zb(I,Y,U){for(var Ce=U-1,je=I.length;++Ce<je;)if(I[Ce]===Y)return Ce;return-1}function Qb(I,Y,U){for(var Ce=U+1;Ce--;)if(I[Ce]===Y)return Ce;return Ce}function Po(I){return Mo(I)?tS(I):zb(I)}function vn(I){return Mo(I)?rS(I):Fb(I)}var eS=Yu(Mb);function tS(I){for(var Y=ku.lastIndex=0;ku.test(I);)++Y;return Y}function rS(I){return I.match(ku)||[]}function nS(I){return I.match(Cb)||[]}var iS=function I(Y){Y=Y==null?Zt:bi.defaults(Zt.Object(),Y,bi.pick(Zt,Nb));var U=Y.Array,Ce=Y.Date,je=Y.Error,st=Y.Function,$t=Y.Math,xt=Y.Object,tf=Y.RegExp,oS=Y.String,en=Y.TypeError,fl=U.prototype,sS=st.prototype,Ao=xt.prototype,hl=Y["__core-js_shared__"],pl=sS.toString,ht=Ao.hasOwnProperty,aS=0,sd=function(){var s=/[^.]+$/.exec(hl&&hl.keys&&hl.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),dl=Ao.toString,lS=pl.call(xt),cS=Zt._,uS=tf("^"+pl.call(ht).replace(He,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ml=Wp?Y.Buffer:i,Si=Y.Symbol,gl=Y.Uint8Array,ad=ml?ml.allocUnsafe:i,yl=od(xt.getPrototypeOf,xt),ld=xt.create,cd=Ao.propertyIsEnumerable,xl=fl.splice,ud=Si?Si.isConcatSpreadable:i,Js=Si?Si.iterator:i,Qi=Si?Si.toStringTag:i,vl=function(){try{var s=io(xt,"defineProperty");return s({},"",{}),s}catch{}}(),fS=Y.clearTimeout!==Zt.clearTimeout&&Y.clearTimeout,hS=Ce&&Ce.now!==Zt.Date.now&&Ce.now,pS=Y.setTimeout!==Zt.setTimeout&&Y.setTimeout,bl=$t.ceil,Sl=$t.floor,rf=xt.getOwnPropertySymbols,dS=ml?ml.isBuffer:i,fd=Y.isFinite,mS=fl.join,gS=od(xt.keys,xt),Jt=$t.max,fr=$t.min,yS=Ce.now,xS=Y.parseInt,hd=$t.random,vS=fl.reverse,nf=io(Y,"DataView"),Ks=io(Y,"Map"),of=io(Y,"Promise"),Do=io(Y,"Set"),Ys=io(Y,"WeakMap"),Xs=io(xt,"create"),wl=Ys&&new Ys,Eo={},bS=oo(nf),SS=oo(Ks),wS=oo(of),CS=oo(Do),LS=oo(Ys),Cl=Si?Si.prototype:i,Zs=Cl?Cl.valueOf:i,pd=Cl?Cl.toString:i;function y(s){if(Dt(s)&&!ke(s)&&!(s instanceof et)){if(s instanceof tn)return s;if(ht.call(s,"__wrapped__"))return dm(s)}return new tn(s)}var Bo=function(){function s(){}return function(l){if(!Pt(l))return{};if(ld)return ld(l);s.prototype=l;var u=new s;return s.prototype=i,u}}();function Ll(){}function tn(s,l){this.__wrapped__=s,this.__actions__=[],this.__chain__=!!l,this.__index__=0,this.__values__=i}y.templateSettings={escape:Xi,evaluate:qt,interpolate:Kn,variable:"",imports:{_:y}},y.prototype=Ll.prototype,y.prototype.constructor=y,tn.prototype=Bo(Ll.prototype),tn.prototype.constructor=tn;function et(s){this.__wrapped__=s,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Le,this.__views__=[]}function TS(){var s=new et(this.__wrapped__);return s.__actions__=Ir(this.__actions__),s.__dir__=this.__dir__,s.__filtered__=this.__filtered__,s.__iteratees__=Ir(this.__iteratees__),s.__takeCount__=this.__takeCount__,s.__views__=Ir(this.__views__),s}function NS(){if(this.__filtered__){var s=new et(this);s.__dir__=-1,s.__filtered__=!0}else s=this.clone(),s.__dir__*=-1;return s}function _S(){var s=this.__wrapped__.value(),l=this.__dir__,u=ke(s),p=l<0,g=u?s.length:0,v=F1(0,g,this.__views__),C=v.start,L=v.end,_=L-C,Z=p?L:C-1,Q=this.__iteratees__,oe=Q.length,ge=0,Ne=fr(_,this.__takeCount__);if(!u||!p&&g==_&&Ne==_)return Rd(s,this.__actions__);var ze=[];e:for(;_--&&ge<Ne;){Z+=l;for(var Je=-1,Ge=s[Z];++Je<oe;){var Ze=Q[Je],tt=Ze.iteratee,kr=Ze.type,br=tt(Ge);if(kr==E)Ge=br;else if(!br){if(kr==R)continue e;break e}}ze[ge++]=Ge}return ze}et.prototype=Bo(Ll.prototype),et.prototype.constructor=et;function eo(s){var l=-1,u=s==null?0:s.length;for(this.clear();++l<u;){var p=s[l];this.set(p[0],p[1])}}function IS(){this.__data__=Xs?Xs(null):{},this.size=0}function OS(s){var l=this.has(s)&&delete this.__data__[s];return this.size-=l?1:0,l}function MS(s){var l=this.__data__;if(Xs){var u=l[s];return u===o?i:u}return ht.call(l,s)?l[s]:i}function PS(s){var l=this.__data__;return Xs?l[s]!==i:ht.call(l,s)}function AS(s,l){var u=this.__data__;return this.size+=this.has(s)?0:1,u[s]=Xs&&l===i?o:l,this}eo.prototype.clear=IS,eo.prototype.delete=OS,eo.prototype.get=MS,eo.prototype.has=PS,eo.prototype.set=AS;function Yn(s){var l=-1,u=s==null?0:s.length;for(this.clear();++l<u;){var p=s[l];this.set(p[0],p[1])}}function DS(){this.__data__=[],this.size=0}function ES(s){var l=this.__data__,u=Tl(l,s);if(u<0)return!1;var p=l.length-1;return u==p?l.pop():xl.call(l,u,1),--this.size,!0}function BS(s){var l=this.__data__,u=Tl(l,s);return u<0?i:l[u][1]}function GS(s){return Tl(this.__data__,s)>-1}function RS(s,l){var u=this.__data__,p=Tl(u,s);return p<0?(++this.size,u.push([s,l])):u[p][1]=l,this}Yn.prototype.clear=DS,Yn.prototype.delete=ES,Yn.prototype.get=BS,Yn.prototype.has=GS,Yn.prototype.set=RS;function Xn(s){var l=-1,u=s==null?0:s.length;for(this.clear();++l<u;){var p=s[l];this.set(p[0],p[1])}}function zS(){this.size=0,this.__data__={hash:new eo,map:new(Ks||Yn),string:new eo}}function FS(s){var l=Rl(this,s).delete(s);return this.size-=l?1:0,l}function VS(s){return Rl(this,s).get(s)}function US(s){return Rl(this,s).has(s)}function jS(s,l){var u=Rl(this,s),p=u.size;return u.set(s,l),this.size+=u.size==p?0:1,this}Xn.prototype.clear=zS,Xn.prototype.delete=FS,Xn.prototype.get=VS,Xn.prototype.has=US,Xn.prototype.set=jS;function to(s){var l=-1,u=s==null?0:s.length;for(this.__data__=new Xn;++l<u;)this.add(s[l])}function kS(s){return this.__data__.set(s,o),this}function HS(s){return this.__data__.has(s)}to.prototype.add=to.prototype.push=kS,to.prototype.has=HS;function bn(s){var l=this.__data__=new Yn(s);this.size=l.size}function WS(){this.__data__=new Yn,this.size=0}function qS(s){var l=this.__data__,u=l.delete(s);return this.size=l.size,u}function $S(s){return this.__data__.get(s)}function JS(s){return this.__data__.has(s)}function KS(s,l){var u=this.__data__;if(u instanceof Yn){var p=u.__data__;if(!Ks||p.length<e-1)return p.push([s,l]),this.size=++u.size,this;u=this.__data__=new Xn(p)}return u.set(s,l),this.size=u.size,this}bn.prototype.clear=WS,bn.prototype.delete=qS,bn.prototype.get=$S,bn.prototype.has=JS,bn.prototype.set=KS;function dd(s,l){var u=ke(s),p=!u&&so(s),g=!u&&!p&&Ni(s),v=!u&&!p&&!g&&Fo(s),C=u||p||g||v,L=C?Zu(s.length,oS):[],_=L.length;for(var Z in s)(l||ht.call(s,Z))&&!(C&&(Z=="length"||g&&(Z=="offset"||Z=="parent")||v&&(Z=="buffer"||Z=="byteLength"||Z=="byteOffset")||ti(Z,_)))&&L.push(Z);return L}function md(s){var l=s.length;return l?s[gf(0,l-1)]:i}function YS(s,l){return zl(Ir(s),ro(l,0,s.length))}function XS(s){return zl(Ir(s))}function sf(s,l,u){(u!==i&&!Sn(s[l],u)||u===i&&!(l in s))&&Zn(s,l,u)}function Qs(s,l,u){var p=s[l];(!(ht.call(s,l)&&Sn(p,u))||u===i&&!(l in s))&&Zn(s,l,u)}function Tl(s,l){for(var u=s.length;u--;)if(Sn(s[u][0],l))return u;return-1}function ZS(s,l,u,p){return wi(s,function(g,v,C){l(p,g,u(g),C)}),p}function gd(s,l){return s&&Dn(l,Qt(l),s)}function QS(s,l){return s&&Dn(l,Mr(l),s)}function Zn(s,l,u){l=="__proto__"&&vl?vl(s,l,{configurable:!0,enumerable:!0,value:u,writable:!0}):s[l]=u}function af(s,l){for(var u=-1,p=l.length,g=U(p),v=s==null;++u<p;)g[u]=v?i:Uf(s,l[u]);return g}function ro(s,l,u){return s===s&&(u!==i&&(s=s<=u?s:u),l!==i&&(s=s>=l?s:l)),s}function rn(s,l,u,p,g,v){var C,L=l&f,_=l&h,Z=l&d;if(u&&(C=g?u(s,p,g,v):u(s)),C!==i)return C;if(!Pt(s))return s;var Q=ke(s);if(Q){if(C=U1(s),!L)return Ir(s,C)}else{var oe=hr(s),ge=oe==re||oe==q;if(Ni(s))return Vd(s,L);if(oe==le||oe==W||ge&&!g){if(C=_||ge?{}:om(s),!L)return _?M1(s,QS(C,s)):O1(s,gd(C,s))}else{if(!bt[oe])return g?s:{};C=j1(s,oe,L)}}v||(v=new bn);var Ne=v.get(s);if(Ne)return Ne;v.set(s,C),Em(s)?s.forEach(function(Ge){C.add(rn(Ge,l,u,Ge,s,v))}):Am(s)&&s.forEach(function(Ge,Ze){C.set(Ze,rn(Ge,l,u,Ze,s,v))});var ze=Z?_?_f:Nf:_?Mr:Qt,Je=Q?i:ze(s);return Qr(Je||s,function(Ge,Ze){Je&&(Ze=Ge,Ge=s[Ze]),Qs(C,Ze,rn(Ge,l,u,Ze,s,v))}),C}function e1(s){var l=Qt(s);return function(u){return yd(u,s,l)}}function yd(s,l,u){var p=u.length;if(s==null)return!p;for(s=xt(s);p--;){var g=u[p],v=l[g],C=s[g];if(C===i&&!(g in s)||!v(C))return!1}return!0}function xd(s,l,u){if(typeof s!="function")throw new en(n);return sa(function(){s.apply(i,u)},l)}function ea(s,l,u,p){var g=-1,v=ll,C=!0,L=s.length,_=[],Z=l.length;if(!L)return _;u&&(l=It(l,Vr(u))),p?(v=qu,C=!1):l.length>=e&&(v=$s,C=!1,l=new to(l));e:for(;++g<L;){var Q=s[g],oe=u==null?Q:u(Q);if(Q=p||Q!==0?Q:0,C&&oe===oe){for(var ge=Z;ge--;)if(l[ge]===oe)continue e;_.push(Q)}else v(l,oe,p)||_.push(Q)}return _}var wi=Wd(An),vd=Wd(cf,!0);function t1(s,l){var u=!0;return wi(s,function(p,g,v){return u=!!l(p,g,v),u}),u}function Nl(s,l,u){for(var p=-1,g=s.length;++p<g;){var v=s[p],C=l(v);if(C!=null&&(L===i?C===C&&!jr(C):u(C,L)))var L=C,_=v}return _}function r1(s,l,u,p){var g=s.length;for(u=We(u),u<0&&(u=-u>g?0:g+u),p=p===i||p>g?g:We(p),p<0&&(p+=g),p=u>p?0:Gm(p);u<p;)s[u++]=l;return s}function bd(s,l){var u=[];return wi(s,function(p,g,v){l(p,g,v)&&u.push(p)}),u}function or(s,l,u,p,g){var v=-1,C=s.length;for(u||(u=H1),g||(g=[]);++v<C;){var L=s[v];l>0&&u(L)?l>1?or(L,l-1,u,p,g):xi(g,L):p||(g[g.length]=L)}return g}var lf=qd(),Sd=qd(!0);function An(s,l){return s&&lf(s,l,Qt)}function cf(s,l){return s&&Sd(s,l,Qt)}function _l(s,l){return yi(l,function(u){return ri(s[u])})}function no(s,l){l=Li(l,s);for(var u=0,p=l.length;s!=null&&u<p;)s=s[En(l[u++])];return u&&u==p?s:i}function wd(s,l,u){var p=l(s);return ke(s)?p:xi(p,u(s))}function xr(s){return s==null?s===i?ft:ce:Qi&&Qi in xt(s)?z1(s):X1(s)}function uf(s,l){return s>l}function n1(s,l){return s!=null&&ht.call(s,l)}function i1(s,l){return s!=null&&l in xt(s)}function o1(s,l,u){return s>=fr(l,u)&&s<Jt(l,u)}function ff(s,l,u){for(var p=u?qu:ll,g=s[0].length,v=s.length,C=v,L=U(v),_=1/0,Z=[];C--;){var Q=s[C];C&&l&&(Q=It(Q,Vr(l))),_=fr(Q.length,_),L[C]=!u&&(l||g>=120&&Q.length>=120)?new to(C&&Q):i}Q=s[0];var oe=-1,ge=L[0];e:for(;++oe<g&&Z.length<_;){var Ne=Q[oe],ze=l?l(Ne):Ne;if(Ne=u||Ne!==0?Ne:0,!(ge?$s(ge,ze):p(Z,ze,u))){for(C=v;--C;){var Je=L[C];if(!(Je?$s(Je,ze):p(s[C],ze,u)))continue e}ge&&ge.push(ze),Z.push(Ne)}}return Z}function s1(s,l,u,p){return An(s,function(g,v,C){l(p,u(g),v,C)}),p}function ta(s,l,u){l=Li(l,s),s=cm(s,l);var p=s==null?s:s[En(on(l))];return p==null?i:Fr(p,s,u)}function Cd(s){return Dt(s)&&xr(s)==W}function a1(s){return Dt(s)&&xr(s)==qe}function l1(s){return Dt(s)&&xr(s)==fe}function ra(s,l,u,p,g){return s===l?!0:s==null||l==null||!Dt(s)&&!Dt(l)?s!==s&&l!==l:c1(s,l,u,p,ra,g)}function c1(s,l,u,p,g,v){var C=ke(s),L=ke(l),_=C?J:hr(s),Z=L?J:hr(l);_=_==W?le:_,Z=Z==W?le:Z;var Q=_==le,oe=Z==le,ge=_==Z;if(ge&&Ni(s)){if(!Ni(l))return!1;C=!0,Q=!1}if(ge&&!Q)return v||(v=new bn),C||Fo(s)?rm(s,l,u,p,g,v):G1(s,l,_,u,p,g,v);if(!(u&m)){var Ne=Q&&ht.call(s,"__wrapped__"),ze=oe&&ht.call(l,"__wrapped__");if(Ne||ze){var Je=Ne?s.value():s,Ge=ze?l.value():l;return v||(v=new bn),g(Je,Ge,u,p,v)}}return ge?(v||(v=new bn),R1(s,l,u,p,g,v)):!1}function u1(s){return Dt(s)&&hr(s)==ee}function hf(s,l,u,p){var g=u.length,v=g,C=!p;if(s==null)return!v;for(s=xt(s);g--;){var L=u[g];if(C&&L[2]?L[1]!==s[L[0]]:!(L[0]in s))return!1}for(;++g<v;){L=u[g];var _=L[0],Z=s[_],Q=L[1];if(C&&L[2]){if(Z===i&&!(_ in s))return!1}else{var oe=new bn;if(p)var ge=p(Z,Q,_,s,l,oe);if(!(ge===i?ra(Q,Z,m|x,p,oe):ge))return!1}}return!0}function Ld(s){if(!Pt(s)||q1(s))return!1;var l=ri(s)?uS:eb;return l.test(oo(s))}function f1(s){return Dt(s)&&xr(s)==de}function h1(s){return Dt(s)&&hr(s)==be}function p1(s){return Dt(s)&&Hl(s.length)&&!!Tt[xr(s)]}function Td(s){return typeof s=="function"?s:s==null?Pr:typeof s=="object"?ke(s)?Id(s[0],s[1]):_d(s):$m(s)}function pf(s){if(!oa(s))return gS(s);var l=[];for(var u in xt(s))ht.call(s,u)&&u!="constructor"&&l.push(u);return l}function d1(s){if(!Pt(s))return Y1(s);var l=oa(s),u=[];for(var p in s)p=="constructor"&&(l||!ht.call(s,p))||u.push(p);return u}function df(s,l){return s<l}function Nd(s,l){var u=-1,p=Or(s)?U(s.length):[];return wi(s,function(g,v,C){p[++u]=l(g,v,C)}),p}function _d(s){var l=Of(s);return l.length==1&&l[0][2]?am(l[0][0],l[0][1]):function(u){return u===s||hf(u,s,l)}}function Id(s,l){return Pf(s)&&sm(l)?am(En(s),l):function(u){var p=Uf(u,s);return p===i&&p===l?jf(u,s):ra(l,p,m|x)}}function Il(s,l,u,p,g){s!==l&&lf(l,function(v,C){if(g||(g=new bn),Pt(v))m1(s,l,C,u,Il,p,g);else{var L=p?p(Df(s,C),v,C+"",s,l,g):i;L===i&&(L=v),sf(s,C,L)}},Mr)}function m1(s,l,u,p,g,v,C){var L=Df(s,u),_=Df(l,u),Z=C.get(_);if(Z){sf(s,u,Z);return}var Q=v?v(L,_,u+"",s,l,C):i,oe=Q===i;if(oe){var ge=ke(_),Ne=!ge&&Ni(_),ze=!ge&&!Ne&&Fo(_);Q=_,ge||Ne||ze?ke(L)?Q=L:Gt(L)?Q=Ir(L):Ne?(oe=!1,Q=Vd(_,!0)):ze?(oe=!1,Q=Ud(_,!0)):Q=[]:aa(_)||so(_)?(Q=L,so(L)?Q=Rm(L):(!Pt(L)||ri(L))&&(Q=om(_))):oe=!1}oe&&(C.set(_,Q),g(Q,_,p,v,C),C.delete(_)),sf(s,u,Q)}function Od(s,l){var u=s.length;if(!!u)return l+=l<0?u:0,ti(l,u)?s[l]:i}function Md(s,l,u){l.length?l=It(l,function(v){return ke(v)?function(C){return no(C,v.length===1?v[0]:v)}:v}):l=[Pr];var p=-1;l=It(l,Vr(Be()));var g=Nd(s,function(v,C,L){var _=It(l,function(Z){return Z(v)});return{criteria:_,index:++p,value:v}});return jb(g,function(v,C){return I1(v,C,u)})}function g1(s,l){return Pd(s,l,function(u,p){return jf(s,p)})}function Pd(s,l,u){for(var p=-1,g=l.length,v={};++p<g;){var C=l[p],L=no(s,C);u(L,C)&&na(v,Li(C,s),L)}return v}function y1(s){return function(l){return no(l,s)}}function mf(s,l,u,p){var g=p?Ub:Oo,v=-1,C=l.length,L=s;for(s===l&&(l=Ir(l)),u&&(L=It(s,Vr(u)));++v<C;)for(var _=0,Z=l[v],Q=u?u(Z):Z;(_=g(L,Q,_,p))>-1;)L!==s&&xl.call(L,_,1),xl.call(s,_,1);return s}function Ad(s,l){for(var u=s?l.length:0,p=u-1;u--;){var g=l[u];if(u==p||g!==v){var v=g;ti(g)?xl.call(s,g,1):vf(s,g)}}return s}function gf(s,l){return s+Sl(hd()*(l-s+1))}function x1(s,l,u,p){for(var g=-1,v=Jt(bl((l-s)/(u||1)),0),C=U(v);v--;)C[p?v:++g]=s,s+=u;return C}function yf(s,l){var u="";if(!s||l<1||l>ne)return u;do l%2&&(u+=s),l=Sl(l/2),l&&(s+=s);while(l);return u}function Xe(s,l){return Ef(lm(s,l,Pr),s+"")}function v1(s){return md(Vo(s))}function b1(s,l){var u=Vo(s);return zl(u,ro(l,0,u.length))}function na(s,l,u,p){if(!Pt(s))return s;l=Li(l,s);for(var g=-1,v=l.length,C=v-1,L=s;L!=null&&++g<v;){var _=En(l[g]),Z=u;if(_==="__proto__"||_==="constructor"||_==="prototype")return s;if(g!=C){var Q=L[_];Z=p?p(Q,_,L):i,Z===i&&(Z=Pt(Q)?Q:ti(l[g+1])?[]:{})}Qs(L,_,Z),L=L[_]}return s}var Dd=wl?function(s,l){return wl.set(s,l),s}:Pr,S1=vl?function(s,l){return vl(s,"toString",{configurable:!0,enumerable:!1,value:Hf(l),writable:!0})}:Pr;function w1(s){return zl(Vo(s))}function nn(s,l,u){var p=-1,g=s.length;l<0&&(l=-l>g?0:g+l),u=u>g?g:u,u<0&&(u+=g),g=l>u?0:u-l>>>0,l>>>=0;for(var v=U(g);++p<g;)v[p]=s[p+l];return v}function C1(s,l){var u;return wi(s,function(p,g,v){return u=l(p,g,v),!u}),!!u}function Ol(s,l,u){var p=0,g=s==null?p:s.length;if(typeof l=="number"&&l===l&&g<=se){for(;p<g;){var v=p+g>>>1,C=s[v];C!==null&&!jr(C)&&(u?C<=l:C<l)?p=v+1:g=v}return g}return xf(s,l,Pr,u)}function xf(s,l,u,p){var g=0,v=s==null?0:s.length;if(v===0)return 0;l=u(l);for(var C=l!==l,L=l===null,_=jr(l),Z=l===i;g<v;){var Q=Sl((g+v)/2),oe=u(s[Q]),ge=oe!==i,Ne=oe===null,ze=oe===oe,Je=jr(oe);if(C)var Ge=p||ze;else Z?Ge=ze&&(p||ge):L?Ge=ze&&ge&&(p||!Ne):_?Ge=ze&&ge&&!Ne&&(p||!Je):Ne||Je?Ge=!1:Ge=p?oe<=l:oe<l;Ge?g=Q+1:v=Q}return fr(v,Ue)}function Ed(s,l){for(var u=-1,p=s.length,g=0,v=[];++u<p;){var C=s[u],L=l?l(C):C;if(!u||!Sn(L,_)){var _=L;v[g++]=C===0?0:C}}return v}function Bd(s){return typeof s=="number"?s:jr(s)?_e:+s}function Ur(s){if(typeof s=="string")return s;if(ke(s))return It(s,Ur)+"";if(jr(s))return pd?pd.call(s):"";var l=s+"";return l=="0"&&1/s==-ae?"-0":l}function Ci(s,l,u){var p=-1,g=ll,v=s.length,C=!0,L=[],_=L;if(u)C=!1,g=qu;else if(v>=e){var Z=l?null:E1(s);if(Z)return ul(Z);C=!1,g=$s,_=new to}else _=l?[]:L;e:for(;++p<v;){var Q=s[p],oe=l?l(Q):Q;if(Q=u||Q!==0?Q:0,C&&oe===oe){for(var ge=_.length;ge--;)if(_[ge]===oe)continue e;l&&_.push(oe),L.push(Q)}else g(_,oe,u)||(_!==L&&_.push(oe),L.push(Q))}return L}function vf(s,l){return l=Li(l,s),s=cm(s,l),s==null||delete s[En(on(l))]}function Gd(s,l,u,p){return na(s,l,u(no(s,l)),p)}function Ml(s,l,u,p){for(var g=s.length,v=p?g:-1;(p?v--:++v<g)&&l(s[v],v,s););return u?nn(s,p?0:v,p?v+1:g):nn(s,p?v+1:0,p?g:v)}function Rd(s,l){var u=s;return u instanceof et&&(u=u.value()),$u(l,function(p,g){return g.func.apply(g.thisArg,xi([p],g.args))},u)}function bf(s,l,u){var p=s.length;if(p<2)return p?Ci(s[0]):[];for(var g=-1,v=U(p);++g<p;)for(var C=s[g],L=-1;++L<p;)L!=g&&(v[g]=ea(v[g]||C,s[L],l,u));return Ci(or(v,1),l,u)}function zd(s,l,u){for(var p=-1,g=s.length,v=l.length,C={};++p<g;){var L=p<v?l[p]:i;u(C,s[p],L)}return C}function Sf(s){return Gt(s)?s:[]}function wf(s){return typeof s=="function"?s:Pr}function Li(s,l){return ke(s)?s:Pf(s,l)?[s]:pm(lt(s))}var L1=Xe;function Ti(s,l,u){var p=s.length;return u=u===i?p:u,!l&&u>=p?s:nn(s,l,u)}var Fd=fS||function(s){return Zt.clearTimeout(s)};function Vd(s,l){if(l)return s.slice();var u=s.length,p=ad?ad(u):new s.constructor(u);return s.copy(p),p}function Cf(s){var l=new s.constructor(s.byteLength);return new gl(l).set(new gl(s)),l}function T1(s,l){var u=l?Cf(s.buffer):s.buffer;return new s.constructor(u,s.byteOffset,s.byteLength)}function N1(s){var l=new s.constructor(s.source,xn.exec(s));return l.lastIndex=s.lastIndex,l}function _1(s){return Zs?xt(Zs.call(s)):{}}function Ud(s,l){var u=l?Cf(s.buffer):s.buffer;return new s.constructor(u,s.byteOffset,s.length)}function jd(s,l){if(s!==l){var u=s!==i,p=s===null,g=s===s,v=jr(s),C=l!==i,L=l===null,_=l===l,Z=jr(l);if(!L&&!Z&&!v&&s>l||v&&C&&_&&!L&&!Z||p&&C&&_||!u&&_||!g)return 1;if(!p&&!v&&!Z&&s<l||Z&&u&&g&&!p&&!v||L&&u&&g||!C&&g||!_)return-1}return 0}function I1(s,l,u){for(var p=-1,g=s.criteria,v=l.criteria,C=g.length,L=u.length;++p<C;){var _=jd(g[p],v[p]);if(_){if(p>=L)return _;var Z=u[p];return _*(Z=="desc"?-1:1)}}return s.index-l.index}function kd(s,l,u,p){for(var g=-1,v=s.length,C=u.length,L=-1,_=l.length,Z=Jt(v-C,0),Q=U(_+Z),oe=!p;++L<_;)Q[L]=l[L];for(;++g<C;)(oe||g<v)&&(Q[u[g]]=s[g]);for(;Z--;)Q[L++]=s[g++];return Q}function Hd(s,l,u,p){for(var g=-1,v=s.length,C=-1,L=u.length,_=-1,Z=l.length,Q=Jt(v-L,0),oe=U(Q+Z),ge=!p;++g<Q;)oe[g]=s[g];for(var Ne=g;++_<Z;)oe[Ne+_]=l[_];for(;++C<L;)(ge||g<v)&&(oe[Ne+u[C]]=s[g++]);return oe}function Ir(s,l){var u=-1,p=s.length;for(l||(l=U(p));++u<p;)l[u]=s[u];return l}function Dn(s,l,u,p){var g=!u;u||(u={});for(var v=-1,C=l.length;++v<C;){var L=l[v],_=p?p(u[L],s[L],L,u,s):i;_===i&&(_=s[L]),g?Zn(u,L,_):Qs(u,L,_)}return u}function O1(s,l){return Dn(s,Mf(s),l)}function M1(s,l){return Dn(s,nm(s),l)}function Pl(s,l){return function(u,p){var g=ke(u)?Bb:ZS,v=l?l():{};return g(u,s,Be(p,2),v)}}function Go(s){return Xe(function(l,u){var p=-1,g=u.length,v=g>1?u[g-1]:i,C=g>2?u[2]:i;for(v=s.length>3&&typeof v=="function"?(g--,v):i,C&&vr(u[0],u[1],C)&&(v=g<3?i:v,g=1),l=xt(l);++p<g;){var L=u[p];L&&s(l,L,p,v)}return l})}function Wd(s,l){return function(u,p){if(u==null)return u;if(!Or(u))return s(u,p);for(var g=u.length,v=l?g:-1,C=xt(u);(l?v--:++v<g)&&p(C[v],v,C)!==!1;);return u}}function qd(s){return function(l,u,p){for(var g=-1,v=xt(l),C=p(l),L=C.length;L--;){var _=C[s?L:++g];if(u(v[_],_,v)===!1)break}return l}}function P1(s,l,u){var p=l&S,g=ia(s);function v(){var C=this&&this!==Zt&&this instanceof v?g:s;return C.apply(p?u:this,arguments)}return v}function $d(s){return function(l){l=lt(l);var u=Mo(l)?vn(l):i,p=u?u[0]:l.charAt(0),g=u?Ti(u,1).join(""):l.slice(1);return p[s]()+g}}function Ro(s){return function(l){return $u(Wm(Hm(l).replace(Sb,"")),s,"")}}function ia(s){return function(){var l=arguments;switch(l.length){case 0:return new s;case 1:return new s(l[0]);case 2:return new s(l[0],l[1]);case 3:return new s(l[0],l[1],l[2]);case 4:return new s(l[0],l[1],l[2],l[3]);case 5:return new s(l[0],l[1],l[2],l[3],l[4]);case 6:return new s(l[0],l[1],l[2],l[3],l[4],l[5]);case 7:return new s(l[0],l[1],l[2],l[3],l[4],l[5],l[6])}var u=Bo(s.prototype),p=s.apply(u,l);return Pt(p)?p:u}}function A1(s,l,u){var p=ia(s);function g(){for(var v=arguments.length,C=U(v),L=v,_=zo(g);L--;)C[L]=arguments[L];var Z=v<3&&C[0]!==_&&C[v-1]!==_?[]:vi(C,_);if(v-=Z.length,v<u)return Zd(s,l,Al,g.placeholder,i,C,Z,i,i,u-v);var Q=this&&this!==Zt&&this instanceof g?p:s;return Fr(Q,this,C)}return g}function Jd(s){return function(l,u,p){var g=xt(l);if(!Or(l)){var v=Be(u,3);l=Qt(l),u=function(L){return v(g[L],L,g)}}var C=s(l,u,p);return C>-1?g[v?l[C]:C]:i}}function Kd(s){return ei(function(l){var u=l.length,p=u,g=tn.prototype.thru;for(s&&l.reverse();p--;){var v=l[p];if(typeof v!="function")throw new en(n);if(g&&!C&&Gl(v)=="wrapper")var C=new tn([],!0)}for(p=C?p:u;++p<u;){v=l[p];var L=Gl(v),_=L=="wrapper"?If(v):i;_&&Af(_[0])&&_[1]==(k|O|M|N)&&!_[4].length&&_[9]==1?C=C[Gl(_[0])].apply(C,_[3]):C=v.length==1&&Af(v)?C[L]():C.thru(v)}return function(){var Z=arguments,Q=Z[0];if(C&&Z.length==1&&ke(Q))return C.plant(Q).value();for(var oe=0,ge=u?l[oe].apply(this,Z):Q;++oe<u;)ge=l[oe].call(this,ge);return ge}})}function Al(s,l,u,p,g,v,C,L,_,Z){var Q=l&k,oe=l&S,ge=l&w,Ne=l&(O|T),ze=l&te,Je=ge?i:ia(s);function Ge(){for(var Ze=arguments.length,tt=U(Ze),kr=Ze;kr--;)tt[kr]=arguments[kr];if(Ne)var br=zo(Ge),Hr=Hb(tt,br);if(p&&(tt=kd(tt,p,g,Ne)),v&&(tt=Hd(tt,v,C,Ne)),Ze-=Hr,Ne&&Ze<Z){var Rt=vi(tt,br);return Zd(s,l,Al,Ge.placeholder,u,tt,Rt,L,_,Z-Ze)}var wn=oe?u:this,ii=ge?wn[s]:s;return Ze=tt.length,L?tt=Z1(tt,L):ze&&Ze>1&&tt.reverse(),Q&&_<Ze&&(tt.length=_),this&&this!==Zt&&this instanceof Ge&&(ii=Je||ia(ii)),ii.apply(wn,tt)}return Ge}function Yd(s,l){return function(u,p){return s1(u,s,l(p),{})}}function Dl(s,l){return function(u,p){var g;if(u===i&&p===i)return l;if(u!==i&&(g=u),p!==i){if(g===i)return p;typeof u=="string"||typeof p=="string"?(u=Ur(u),p=Ur(p)):(u=Bd(u),p=Bd(p)),g=s(u,p)}return g}}function Lf(s){return ei(function(l){return l=It(l,Vr(Be())),Xe(function(u){var p=this;return s(l,function(g){return Fr(g,p,u)})})})}function El(s,l){l=l===i?" ":Ur(l);var u=l.length;if(u<2)return u?yf(l,s):l;var p=yf(l,bl(s/Po(l)));return Mo(l)?Ti(vn(p),0,s).join(""):p.slice(0,s)}function D1(s,l,u,p){var g=l&S,v=ia(s);function C(){for(var L=-1,_=arguments.length,Z=-1,Q=p.length,oe=U(Q+_),ge=this&&this!==Zt&&this instanceof C?v:s;++Z<Q;)oe[Z]=p[Z];for(;_--;)oe[Z++]=arguments[++L];return Fr(ge,g?u:this,oe)}return C}function Xd(s){return function(l,u,p){return p&&typeof p!="number"&&vr(l,u,p)&&(u=p=i),l=ni(l),u===i?(u=l,l=0):u=ni(u),p=p===i?l<u?1:-1:ni(p),x1(l,u,p,s)}}function Bl(s){return function(l,u){return typeof l=="string"&&typeof u=="string"||(l=sn(l),u=sn(u)),s(l,u)}}function Zd(s,l,u,p,g,v,C,L,_,Z){var Q=l&O,oe=Q?C:i,ge=Q?i:C,Ne=Q?v:i,ze=Q?i:v;l|=Q?M:F,l&=~(Q?F:M),l&B||(l&=~(S|w));var Je=[s,l,g,Ne,oe,ze,ge,L,_,Z],Ge=u.apply(i,Je);return Af(s)&&um(Ge,Je),Ge.placeholder=p,fm(Ge,s,l)}function Tf(s){var l=$t[s];return function(u,p){if(u=sn(u),p=p==null?0:fr(We(p),292),p&&fd(u)){var g=(lt(u)+"e").split("e"),v=l(g[0]+"e"+(+g[1]+p));return g=(lt(v)+"e").split("e"),+(g[0]+"e"+(+g[1]-p))}return l(u)}}var E1=Do&&1/ul(new Do([,-0]))[1]==ae?function(s){return new Do(s)}:$f;function Qd(s){return function(l){var u=hr(l);return u==ee?ef(l):u==be?Xb(l):kb(l,s(l))}}function Qn(s,l,u,p,g,v,C,L){var _=l&w;if(!_&&typeof s!="function")throw new en(n);var Z=p?p.length:0;if(Z||(l&=~(M|F),p=g=i),C=C===i?C:Jt(We(C),0),L=L===i?L:We(L),Z-=g?g.length:0,l&F){var Q=p,oe=g;p=g=i}var ge=_?i:If(s),Ne=[s,l,u,p,g,Q,oe,v,C,L];if(ge&&K1(Ne,ge),s=Ne[0],l=Ne[1],u=Ne[2],p=Ne[3],g=Ne[4],L=Ne[9]=Ne[9]===i?_?0:s.length:Jt(Ne[9]-Z,0),!L&&l&(O|T)&&(l&=~(O|T)),!l||l==S)var ze=P1(s,l,u);else l==O||l==T?ze=A1(s,l,L):(l==M||l==(S|M))&&!g.length?ze=D1(s,l,u,p):ze=Al.apply(i,Ne);var Je=ge?Dd:um;return fm(Je(ze,Ne),s,l)}function em(s,l,u,p){return s===i||Sn(s,Ao[u])&&!ht.call(p,u)?l:s}function tm(s,l,u,p,g,v){return Pt(s)&&Pt(l)&&(v.set(l,s),Il(s,l,i,tm,v),v.delete(l)),s}function B1(s){return aa(s)?i:s}function rm(s,l,u,p,g,v){var C=u&m,L=s.length,_=l.length;if(L!=_&&!(C&&_>L))return!1;var Z=v.get(s),Q=v.get(l);if(Z&&Q)return Z==l&&Q==s;var oe=-1,ge=!0,Ne=u&x?new to:i;for(v.set(s,l),v.set(l,s);++oe<L;){var ze=s[oe],Je=l[oe];if(p)var Ge=C?p(Je,ze,oe,l,s,v):p(ze,Je,oe,s,l,v);if(Ge!==i){if(Ge)continue;ge=!1;break}if(Ne){if(!Ju(l,function(Ze,tt){if(!$s(Ne,tt)&&(ze===Ze||g(ze,Ze,u,p,v)))return Ne.push(tt)})){ge=!1;break}}else if(!(ze===Je||g(ze,Je,u,p,v))){ge=!1;break}}return v.delete(s),v.delete(l),ge}function G1(s,l,u,p,g,v,C){switch(u){case _t:if(s.byteLength!=l.byteLength||s.byteOffset!=l.byteOffset)return!1;s=s.buffer,l=l.buffer;case qe:return!(s.byteLength!=l.byteLength||!v(new gl(s),new gl(l)));case K:case fe:case Te:return Sn(+s,+l);case ie:return s.name==l.name&&s.message==l.message;case de:case Se:return s==l+"";case ee:var L=ef;case be:var _=p&m;if(L||(L=ul),s.size!=l.size&&!_)return!1;var Z=C.get(s);if(Z)return Z==l;p|=x,C.set(s,l);var Q=rm(L(s),L(l),p,g,v,C);return C.delete(s),Q;case Ie:if(Zs)return Zs.call(s)==Zs.call(l)}return!1}function R1(s,l,u,p,g,v){var C=u&m,L=Nf(s),_=L.length,Z=Nf(l),Q=Z.length;if(_!=Q&&!C)return!1;for(var oe=_;oe--;){var ge=L[oe];if(!(C?ge in l:ht.call(l,ge)))return!1}var Ne=v.get(s),ze=v.get(l);if(Ne&&ze)return Ne==l&&ze==s;var Je=!0;v.set(s,l),v.set(l,s);for(var Ge=C;++oe<_;){ge=L[oe];var Ze=s[ge],tt=l[ge];if(p)var kr=C?p(tt,Ze,ge,l,s,v):p(Ze,tt,ge,s,l,v);if(!(kr===i?Ze===tt||g(Ze,tt,u,p,v):kr)){Je=!1;break}Ge||(Ge=ge=="constructor")}if(Je&&!Ge){var br=s.constructor,Hr=l.constructor;br!=Hr&&"constructor"in s&&"constructor"in l&&!(typeof br=="function"&&br instanceof br&&typeof Hr=="function"&&Hr instanceof Hr)&&(Je=!1)}return v.delete(s),v.delete(l),Je}function ei(s){return Ef(lm(s,i,ym),s+"")}function Nf(s){return wd(s,Qt,Mf)}function _f(s){return wd(s,Mr,nm)}var If=wl?function(s){return wl.get(s)}:$f;function Gl(s){for(var l=s.name+"",u=Eo[l],p=ht.call(Eo,l)?u.length:0;p--;){var g=u[p],v=g.func;if(v==null||v==s)return g.name}return l}function zo(s){var l=ht.call(y,"placeholder")?y:s;return l.placeholder}function Be(){var s=y.iteratee||Wf;return s=s===Wf?Td:s,arguments.length?s(arguments[0],arguments[1]):s}function Rl(s,l){var u=s.__data__;return W1(l)?u[typeof l=="string"?"string":"hash"]:u.map}function Of(s){for(var l=Qt(s),u=l.length;u--;){var p=l[u],g=s[p];l[u]=[p,g,sm(g)]}return l}function io(s,l){var u=Jb(s,l);return Ld(u)?u:i}function z1(s){var l=ht.call(s,Qi),u=s[Qi];try{s[Qi]=i;var p=!0}catch{}var g=dl.call(s);return p&&(l?s[Qi]=u:delete s[Qi]),g}var Mf=rf?function(s){return s==null?[]:(s=xt(s),yi(rf(s),function(l){return cd.call(s,l)}))}:Jf,nm=rf?function(s){for(var l=[];s;)xi(l,Mf(s)),s=yl(s);return l}:Jf,hr=xr;(nf&&hr(new nf(new ArrayBuffer(1)))!=_t||Ks&&hr(new Ks)!=ee||of&&hr(of.resolve())!=he||Do&&hr(new Do)!=be||Ys&&hr(new Ys)!=Ve)&&(hr=function(s){var l=xr(s),u=l==le?s.constructor:i,p=u?oo(u):"";if(p)switch(p){case bS:return _t;case SS:return ee;case wS:return he;case CS:return be;case LS:return Ve}return l});function F1(s,l,u){for(var p=-1,g=u.length;++p<g;){var v=u[p],C=v.size;switch(v.type){case"drop":s+=C;break;case"dropRight":l-=C;break;case"take":l=fr(l,s+C);break;case"takeRight":s=Jt(s,l-C);break}}return{start:s,end:l}}function V1(s){var l=s.match(at);return l?l[1].split(vt):[]}function im(s,l,u){l=Li(l,s);for(var p=-1,g=l.length,v=!1;++p<g;){var C=En(l[p]);if(!(v=s!=null&&u(s,C)))break;s=s[C]}return v||++p!=g?v:(g=s==null?0:s.length,!!g&&Hl(g)&&ti(C,g)&&(ke(s)||so(s)))}function U1(s){var l=s.length,u=new s.constructor(l);return l&&typeof s[0]=="string"&&ht.call(s,"index")&&(u.index=s.index,u.input=s.input),u}function om(s){return typeof s.constructor=="function"&&!oa(s)?Bo(yl(s)):{}}function j1(s,l,u){var p=s.constructor;switch(l){case qe:return Cf(s);case K:case fe:return new p(+s);case _t:return T1(s,u);case Wt:case Rr:case Ut:case zr:case mn:case gn:case pt:case jt:case ir:return Ud(s,u);case ee:return new p;case Te:case Se:return new p(s);case de:return N1(s);case be:return new p;case Ie:return _1(s)}}function k1(s,l){var u=l.length;if(!u)return s;var p=u-1;return l[p]=(u>1?"& ":"")+l[p],l=l.join(u>2?", ":" "),s.replace(mt,`{
1
+ var gN=Object.create;var $l=Object.defineProperty,yN=Object.defineProperties,xN=Object.getOwnPropertyDescriptor,vN=Object.getOwnPropertyDescriptors,bN=Object.getOwnPropertyNames,Km=Object.getOwnPropertySymbols,SN=Object.getPrototypeOf,Xm=Object.prototype.hasOwnProperty,wN=Object.prototype.propertyIsEnumerable;var Ym=(i,t,e)=>t in i?$l(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,j=(i,t)=>{for(var e in t||(t={}))Xm.call(t,e)&&Ym(i,e,t[e]);if(Km)for(var e of Km(t))wN.call(t,e)&&Ym(i,e,t[e]);return i},ue=(i,t)=>yN(i,vN(t));var Zm=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),CN=(i,t)=>{for(var e in t)$l(i,e,{get:t[e],enumerable:!0})},LN=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of bN(t))!Xm.call(i,n)&&n!==e&&$l(i,n,{get:()=>t[n],enumerable:!(r=xN(t,n))||r.enumerable});return i};var Qm=(i,t,e)=>(e=i!=null?gN(SN(i)):{},LN(t||!i||!i.__esModule?$l(e,"default",{value:i,enumerable:!0}):e,i));var Ev=Zm((Gu,Dv)=>{(function(i,t){typeof Gu=="object"&&typeof Dv<"u"?t(Gu):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(Gu,function(i){"use strict";i.SVD=function(t,e,r,n,o){if(e=e===void 0||e,r=r===void 0||r,o=1e-64/(n=n||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,c,f,h,d,m,x,S,w,B,O,T,M=t[0].length,F=t.length;if(F<M)throw new TypeError("Invalid matrix: m < n");for(var k=[],N=[],te=[],A=e==="f"?F:M,b=B=x=0;b<F;b++)N[b]=new Array(A).fill(0);for(b=0;b<M;b++)te[b]=new Array(M).fill(0);var V,P=new Array(M).fill(0);for(b=0;b<F;b++)for(a=0;a<M;a++)N[b][a]=t[b][a];for(b=0;b<M;b++){for(k[b]=x,w=0,f=b+1,a=b;a<F;a++)w+=Math.pow(N[a][b],2);if(w<o)x=0;else for(S=(m=N[b][b])*(x=m<0?Math.sqrt(w):-Math.sqrt(w))-w,N[b][b]=m-x,a=f;a<M;a++){for(w=0,c=b;c<F;c++)w+=N[c][b]*N[c][a];for(m=w/S,c=b;c<F;c++)N[c][a]=N[c][a]+m*N[c][b]}for(P[b]=x,w=0,a=f;a<M;a++)w+=Math.pow(N[b][a],2);if(w<o)x=0;else{for(S=(m=N[b][b+1])*(x=m<0?Math.sqrt(w):-Math.sqrt(w))-w,N[b][b+1]=m-x,a=f;a<M;a++)k[a]=N[b][a]/S;for(a=f;a<F;a++){for(w=0,c=f;c<M;c++)w+=N[a][c]*N[b][c];for(c=f;c<M;c++)N[a][c]=N[a][c]+w*k[c]}}B<(O=Math.abs(P[b])+Math.abs(k[b]))&&(B=O)}if(r)for(b=M-1;0<=b;b--){if(x!==0){for(S=N[b][b+1]*x,a=f;a<M;a++)te[a][b]=N[b][a]/S;for(a=f;a<M;a++){for(w=0,c=f;c<M;c++)w+=N[b][c]*te[c][a];for(c=f;c<M;c++)te[c][a]=te[c][a]+w*te[c][b]}}for(a=f;a<M;a++)te[b][a]=0,te[a][b]=0;te[b][b]=1,x=k[b],f=b}if(e){if(e==="f")for(b=M;b<F;b++){for(a=M;a<F;a++)N[b][a]=0;N[b][b]=1}for(b=M-1;0<=b;b--){for(f=b+1,x=P[b],a=f;a<A;a++)N[b][a]=0;if(x!==0){for(S=N[b][b]*x,a=f;a<A;a++){for(w=0,c=f;c<F;c++)w+=N[c][b]*N[c][a];for(m=w/S,c=b;c<F;c++)N[c][a]=N[c][a]+m*N[c][b]}for(a=b;a<F;a++)N[a][b]=N[a][b]/x}else for(a=b;a<F;a++)N[a][b]=0;N[b][b]=N[b][b]+1}}for(n*=B,c=M-1;0<=c;c--)for(var R=0;R<50;R++){for(V=!1,f=c;0<=f;f--){if(Math.abs(k[f])<=n){V=!0;break}if(Math.abs(P[f-1])<=n)break}if(!V){for(d=0,h=f-(w=1),b=f;b<c+1&&(m=w*k[b],k[b]=d*k[b],!(Math.abs(m)<=n));b++)if(x=P[b],P[b]=Math.sqrt(m*m+x*x),d=x/(S=P[b]),w=-m/S,e)for(a=0;a<F;a++)O=N[a][h],T=N[a][b],N[a][h]=O*d+T*w,N[a][b]=-O*w+T*d}if(T=P[c],f===c){if(T<0&&(P[c]=-T,r))for(a=0;a<M;a++)te[a][c]=-te[a][c];break}for(B=P[f],m=(((O=P[c-1])-T)*(O+T)+((x=k[c-1])-(S=k[c]))*(x+S))/(2*S*O),x=Math.sqrt(m*m+1),m=((B-T)*(B+T)+S*(O/(m<0?m-x:m+x)-S))/B,b=f+(w=d=1);b<c+1;b++){if(x=k[b],O=P[b],S=w*x,x*=d,T=Math.sqrt(m*m+S*S),m=B*(d=m/(k[b-1]=T))+x*(w=S/T),x=-B*w+x*d,S=O*w,O*=d,r)for(a=0;a<M;a++)B=te[a][b-1],T=te[a][b],te[a][b-1]=B*d+T*w,te[a][b]=-B*w+T*d;if(T=Math.sqrt(m*m+S*S),m=(d=m/(P[b-1]=T))*x+(w=S/T)*O,B=-w*x+d*O,e)for(a=0;a<F;a++)O=N[a][b-1],T=N[a][b],N[a][b-1]=O*d+T*w,N[a][b]=-O*w+T*d}k[f]=0,k[c]=m,P[c]=B}for(b=0;b<M;b++)P[b]<n&&(P[b]=0);return{u:N,q:P,v:te}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var Xv=Zm(($s,nl)=>{(function(){var i,t="4.17.20",e=200,r="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",n="Expected a function",o="__lodash_hash_undefined__",a=500,c="__lodash_placeholder__",f=1,h=2,d=4,m=1,x=2,S=1,w=2,B=4,O=8,T=16,M=32,F=64,k=128,N=256,te=512,A=30,b="...",V=800,P=16,R=1,E=2,G=3,ae=1/0,ne=9007199254740991,xe=17976931348623157e292,_e=0/0,Le=4294967295,Ue=Le-1,se=Le>>>1,$=[["ary",k],["bind",S],["bindKey",w],["curry",O],["curryRight",T],["flip",te],["partial",M],["partialRight",F],["rearg",N]],W="[object Arguments]",J="[object Array]",H="[object AsyncFunction]",K="[object Boolean]",fe="[object Date]",me="[object DOMException]",ie="[object Error]",re="[object Function]",q="[object GeneratorFunction]",ee="[object Map]",Te="[object Number]",ce="[object Null]",le="[object Object]",he="[object Promise]",pe="[object Proxy]",de="[object RegExp]",be="[object Set]",Se="[object String]",Ie="[object Symbol]",ft="[object Undefined]",Ve="[object WeakMap]",Lt="[object WeakSet]",qe="[object ArrayBuffer]",_t="[object DataView]",Wt="[object Float32Array]",Rr="[object Float64Array]",Ut="[object Int8Array]",zr="[object Int16Array]",mn="[object Int32Array]",gn="[object Uint8Array]",pt="[object Uint8ClampedArray]",jt="[object Uint16Array]",ir="[object Uint32Array]",Lo=/\b__p \+= '';/g,To=/\b(__p \+=) '' \+/g,No=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ki=/&(?:amp|lt|gt|quot|#39);/g,Yi=/[&<>"']/g,_o=RegExp(Ki.source),Nr=RegExp(Yi.source),Xi=/<%-([\s\S]+?)%>/g,qt=/<%([\s\S]+?)%>/g,Kn=/<%=([\s\S]+?)%>/g,Io=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Re=/^\w*$/,Ye=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,He=/[\\^$.*+?()[\]{}|]/g,$e=RegExp(He.source),Qe=/^\s+|\s+$/g,ot=/^\s+/,dt=/\s+$/,mt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,at=/\{\n\/\* \[wrapped with (.+)\] \*/,vt=/,? & /,Bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_r=/\\(\\)?/g,yn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,xn=/\w*$/,Pn=/^[-+]0x[0-9a-f]+$/i,il=/^0b[01]+$/i,ib=/^\[object .+?Constructor\]$/,ob=/^0o[0-7]+$/i,sb=/^(?:0|[1-9]\d*)$/,ab=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ol=/($^)/,lb=/['\n\r\u2028\u2029\\]/g,sl="\\ud800-\\udfff",cb="\\u0300-\\u036f",ub="\\ufe20-\\ufe2f",fb="\\u20d0-\\u20ff",Np=cb+ub+fb,_p="\\u2700-\\u27bf",Ip="a-z\\xdf-\\xf6\\xf8-\\xff",hb="\\xac\\xb1\\xd7\\xf7",pb="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",db="\\u2000-\\u206f",mb=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Op="A-Z\\xc0-\\xd6\\xd8-\\xde",Mp="\\ufe0e\\ufe0f",Pp=hb+pb+db+mb,Fu="['\u2019]",gb="["+sl+"]",Ap="["+Pp+"]",al="["+Np+"]",Dp="\\d+",yb="["+_p+"]",Ep="["+Ip+"]",Bp="[^"+sl+Pp+Dp+_p+Ip+Op+"]",Vu="\\ud83c[\\udffb-\\udfff]",xb="(?:"+al+"|"+Vu+")",Gp="[^"+sl+"]",Uu="(?:\\ud83c[\\udde6-\\uddff]){2}",ju="[\\ud800-\\udbff][\\udc00-\\udfff]",Oo="["+Op+"]",Rp="\\u200d",zp="(?:"+Ep+"|"+Bp+")",vb="(?:"+Oo+"|"+Bp+")",Fp="(?:"+Fu+"(?:d|ll|m|re|s|t|ve))?",Vp="(?:"+Fu+"(?:D|LL|M|RE|S|T|VE))?",Up=xb+"?",jp="["+Mp+"]?",bb="(?:"+Rp+"(?:"+[Gp,Uu,ju].join("|")+")"+jp+Up+")*",Sb="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",wb="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",kp=jp+Up+bb,Cb="(?:"+[yb,Uu,ju].join("|")+")"+kp,Lb="(?:"+[Gp+al+"?",al,Uu,ju,gb].join("|")+")",Tb=RegExp(Fu,"g"),Nb=RegExp(al,"g"),ku=RegExp(Vu+"(?="+Vu+")|"+Lb+kp,"g"),_b=RegExp([Oo+"?"+Ep+"+"+Fp+"(?="+[Ap,Oo,"$"].join("|")+")",vb+"+"+Vp+"(?="+[Ap,Oo+zp,"$"].join("|")+")",Oo+"?"+zp+"+"+Fp,Oo+"+"+Vp,wb,Sb,Dp,Cb].join("|"),"g"),Ib=RegExp("["+Rp+sl+Np+Mp+"]"),Ob=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Mb=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Pb=-1,Tt={};Tt[Wt]=Tt[Rr]=Tt[Ut]=Tt[zr]=Tt[mn]=Tt[gn]=Tt[pt]=Tt[jt]=Tt[ir]=!0,Tt[W]=Tt[J]=Tt[qe]=Tt[K]=Tt[_t]=Tt[fe]=Tt[ie]=Tt[re]=Tt[ee]=Tt[Te]=Tt[le]=Tt[de]=Tt[be]=Tt[Se]=Tt[Ve]=!1;var bt={};bt[W]=bt[J]=bt[qe]=bt[_t]=bt[K]=bt[fe]=bt[Wt]=bt[Rr]=bt[Ut]=bt[zr]=bt[mn]=bt[ee]=bt[Te]=bt[le]=bt[de]=bt[be]=bt[Se]=bt[Ie]=bt[gn]=bt[pt]=bt[jt]=bt[ir]=!0,bt[ie]=bt[re]=bt[Ve]=!1;var Ab={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Db={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Eb={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Bb={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Gb=parseFloat,Rb=parseInt,Hp=typeof global=="object"&&global&&global.Object===Object&&global,zb=typeof self=="object"&&self&&self.Object===Object&&self,Zt=Hp||zb||Function("return this")(),Hu=typeof $s=="object"&&$s&&!$s.nodeType&&$s,Zi=Hu&&typeof nl=="object"&&nl&&!nl.nodeType&&nl,Wp=Zi&&Zi.exports===Hu,Wu=Wp&&Hp.process,Zr=function(){try{var I=Zi&&Zi.require&&Zi.require("util").types;return I||Wu&&Wu.binding&&Wu.binding("util")}catch{}}(),qp=Zr&&Zr.isArrayBuffer,$p=Zr&&Zr.isDate,Jp=Zr&&Zr.isMap,Kp=Zr&&Zr.isRegExp,Yp=Zr&&Zr.isSet,Xp=Zr&&Zr.isTypedArray;function Fr(I,Y,U){switch(U.length){case 0:return I.call(Y);case 1:return I.call(Y,U[0]);case 2:return I.call(Y,U[0],U[1]);case 3:return I.call(Y,U[0],U[1],U[2])}return I.apply(Y,U)}function Fb(I,Y,U,Ce){for(var je=-1,st=I==null?0:I.length;++je<st;){var $t=I[je];Y(Ce,$t,U($t),I)}return Ce}function Qr(I,Y){for(var U=-1,Ce=I==null?0:I.length;++U<Ce&&Y(I[U],U,I)!==!1;);return I}function Vb(I,Y){for(var U=I==null?0:I.length;U--&&Y(I[U],U,I)!==!1;);return I}function Zp(I,Y){for(var U=-1,Ce=I==null?0:I.length;++U<Ce;)if(!Y(I[U],U,I))return!1;return!0}function yi(I,Y){for(var U=-1,Ce=I==null?0:I.length,je=0,st=[];++U<Ce;){var $t=I[U];Y($t,U,I)&&(st[je++]=$t)}return st}function ll(I,Y){var U=I==null?0:I.length;return!!U&&Mo(I,Y,0)>-1}function qu(I,Y,U){for(var Ce=-1,je=I==null?0:I.length;++Ce<je;)if(U(Y,I[Ce]))return!0;return!1}function It(I,Y){for(var U=-1,Ce=I==null?0:I.length,je=Array(Ce);++U<Ce;)je[U]=Y(I[U],U,I);return je}function xi(I,Y){for(var U=-1,Ce=Y.length,je=I.length;++U<Ce;)I[je+U]=Y[U];return I}function $u(I,Y,U,Ce){var je=-1,st=I==null?0:I.length;for(Ce&&st&&(U=I[++je]);++je<st;)U=Y(U,I[je],je,I);return U}function Ub(I,Y,U,Ce){var je=I==null?0:I.length;for(Ce&&je&&(U=I[--je]);je--;)U=Y(U,I[je],je,I);return U}function Ju(I,Y){for(var U=-1,Ce=I==null?0:I.length;++U<Ce;)if(Y(I[U],U,I))return!0;return!1}var jb=Ku("length");function kb(I){return I.split("")}function Hb(I){return I.match(Bt)||[]}function Qp(I,Y,U){var Ce;return U(I,function(je,st,$t){if(Y(je,st,$t))return Ce=st,!1}),Ce}function cl(I,Y,U,Ce){for(var je=I.length,st=U+(Ce?1:-1);Ce?st--:++st<je;)if(Y(I[st],st,I))return st;return-1}function Mo(I,Y,U){return Y===Y?rS(I,Y,U):cl(I,ed,U)}function Wb(I,Y,U,Ce){for(var je=U-1,st=I.length;++je<st;)if(Ce(I[je],Y))return je;return-1}function ed(I){return I!==I}function td(I,Y){var U=I==null?0:I.length;return U?Xu(I,Y)/U:_e}function Ku(I){return function(Y){return Y==null?i:Y[I]}}function Yu(I){return function(Y){return I==null?i:I[Y]}}function rd(I,Y,U,Ce,je){return je(I,function(st,$t,xt){U=Ce?(Ce=!1,st):Y(U,st,$t,xt)}),U}function qb(I,Y){var U=I.length;for(I.sort(Y);U--;)I[U]=I[U].value;return I}function Xu(I,Y){for(var U,Ce=-1,je=I.length;++Ce<je;){var st=Y(I[Ce]);st!==i&&(U=U===i?st:U+st)}return U}function Zu(I,Y){for(var U=-1,Ce=Array(I);++U<I;)Ce[U]=Y(U);return Ce}function $b(I,Y){return It(Y,function(U){return[U,I[U]]})}function Vr(I){return function(Y){return I(Y)}}function Qu(I,Y){return It(Y,function(U){return I[U]})}function Js(I,Y){return I.has(Y)}function nd(I,Y){for(var U=-1,Ce=I.length;++U<Ce&&Mo(Y,I[U],0)>-1;);return U}function id(I,Y){for(var U=I.length;U--&&Mo(Y,I[U],0)>-1;);return U}function Jb(I,Y){for(var U=I.length,Ce=0;U--;)I[U]===Y&&++Ce;return Ce}var Kb=Yu(Ab),Yb=Yu(Db);function Xb(I){return"\\"+Bb[I]}function Zb(I,Y){return I==null?i:I[Y]}function Po(I){return Ib.test(I)}function Qb(I){return Ob.test(I)}function eS(I){for(var Y,U=[];!(Y=I.next()).done;)U.push(Y.value);return U}function ef(I){var Y=-1,U=Array(I.size);return I.forEach(function(Ce,je){U[++Y]=[je,Ce]}),U}function od(I,Y){return function(U){return I(Y(U))}}function vi(I,Y){for(var U=-1,Ce=I.length,je=0,st=[];++U<Ce;){var $t=I[U];($t===Y||$t===c)&&(I[U]=c,st[je++]=U)}return st}function ul(I){var Y=-1,U=Array(I.size);return I.forEach(function(Ce){U[++Y]=Ce}),U}function tS(I){var Y=-1,U=Array(I.size);return I.forEach(function(Ce){U[++Y]=[Ce,Ce]}),U}function rS(I,Y,U){for(var Ce=U-1,je=I.length;++Ce<je;)if(I[Ce]===Y)return Ce;return-1}function nS(I,Y,U){for(var Ce=U+1;Ce--;)if(I[Ce]===Y)return Ce;return Ce}function Ao(I){return Po(I)?oS(I):jb(I)}function vn(I){return Po(I)?sS(I):kb(I)}var iS=Yu(Eb);function oS(I){for(var Y=ku.lastIndex=0;ku.test(I);)++Y;return Y}function sS(I){return I.match(ku)||[]}function aS(I){return I.match(_b)||[]}var lS=function I(Y){Y=Y==null?Zt:bi.defaults(Zt.Object(),Y,bi.pick(Zt,Mb));var U=Y.Array,Ce=Y.Date,je=Y.Error,st=Y.Function,$t=Y.Math,xt=Y.Object,tf=Y.RegExp,cS=Y.String,en=Y.TypeError,fl=U.prototype,uS=st.prototype,Do=xt.prototype,hl=Y["__core-js_shared__"],pl=uS.toString,ht=Do.hasOwnProperty,fS=0,sd=function(){var s=/[^.]+$/.exec(hl&&hl.keys&&hl.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),dl=Do.toString,hS=pl.call(xt),pS=Zt._,dS=tf("^"+pl.call(ht).replace(He,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ml=Wp?Y.Buffer:i,Si=Y.Symbol,gl=Y.Uint8Array,ad=ml?ml.allocUnsafe:i,yl=od(xt.getPrototypeOf,xt),ld=xt.create,cd=Do.propertyIsEnumerable,xl=fl.splice,ud=Si?Si.isConcatSpreadable:i,Ks=Si?Si.iterator:i,Qi=Si?Si.toStringTag:i,vl=function(){try{var s=io(xt,"defineProperty");return s({},"",{}),s}catch{}}(),mS=Y.clearTimeout!==Zt.clearTimeout&&Y.clearTimeout,gS=Ce&&Ce.now!==Zt.Date.now&&Ce.now,yS=Y.setTimeout!==Zt.setTimeout&&Y.setTimeout,bl=$t.ceil,Sl=$t.floor,rf=xt.getOwnPropertySymbols,xS=ml?ml.isBuffer:i,fd=Y.isFinite,vS=fl.join,bS=od(xt.keys,xt),Jt=$t.max,fr=$t.min,SS=Ce.now,wS=Y.parseInt,hd=$t.random,CS=fl.reverse,nf=io(Y,"DataView"),Ys=io(Y,"Map"),of=io(Y,"Promise"),Eo=io(Y,"Set"),Xs=io(Y,"WeakMap"),Zs=io(xt,"create"),wl=Xs&&new Xs,Bo={},LS=oo(nf),TS=oo(Ys),NS=oo(of),_S=oo(Eo),IS=oo(Xs),Cl=Si?Si.prototype:i,Qs=Cl?Cl.valueOf:i,pd=Cl?Cl.toString:i;function y(s){if(Dt(s)&&!ke(s)&&!(s instanceof et)){if(s instanceof tn)return s;if(ht.call(s,"__wrapped__"))return dm(s)}return new tn(s)}var Go=function(){function s(){}return function(l){if(!Pt(l))return{};if(ld)return ld(l);s.prototype=l;var u=new s;return s.prototype=i,u}}();function Ll(){}function tn(s,l){this.__wrapped__=s,this.__actions__=[],this.__chain__=!!l,this.__index__=0,this.__values__=i}y.templateSettings={escape:Xi,evaluate:qt,interpolate:Kn,variable:"",imports:{_:y}},y.prototype=Ll.prototype,y.prototype.constructor=y,tn.prototype=Go(Ll.prototype),tn.prototype.constructor=tn;function et(s){this.__wrapped__=s,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Le,this.__views__=[]}function OS(){var s=new et(this.__wrapped__);return s.__actions__=Ir(this.__actions__),s.__dir__=this.__dir__,s.__filtered__=this.__filtered__,s.__iteratees__=Ir(this.__iteratees__),s.__takeCount__=this.__takeCount__,s.__views__=Ir(this.__views__),s}function MS(){if(this.__filtered__){var s=new et(this);s.__dir__=-1,s.__filtered__=!0}else s=this.clone(),s.__dir__*=-1;return s}function PS(){var s=this.__wrapped__.value(),l=this.__dir__,u=ke(s),p=l<0,g=u?s.length:0,v=k1(0,g,this.__views__),C=v.start,L=v.end,_=L-C,Z=p?L:C-1,Q=this.__iteratees__,oe=Q.length,ge=0,Ne=fr(_,this.__takeCount__);if(!u||!p&&g==_&&Ne==_)return Rd(s,this.__actions__);var ze=[];e:for(;_--&&ge<Ne;){Z+=l;for(var Je=-1,Ge=s[Z];++Je<oe;){var Ze=Q[Je],tt=Ze.iteratee,kr=Ze.type,br=tt(Ge);if(kr==E)Ge=br;else if(!br){if(kr==R)continue e;break e}}ze[ge++]=Ge}return ze}et.prototype=Go(Ll.prototype),et.prototype.constructor=et;function eo(s){var l=-1,u=s==null?0:s.length;for(this.clear();++l<u;){var p=s[l];this.set(p[0],p[1])}}function AS(){this.__data__=Zs?Zs(null):{},this.size=0}function DS(s){var l=this.has(s)&&delete this.__data__[s];return this.size-=l?1:0,l}function ES(s){var l=this.__data__;if(Zs){var u=l[s];return u===o?i:u}return ht.call(l,s)?l[s]:i}function BS(s){var l=this.__data__;return Zs?l[s]!==i:ht.call(l,s)}function GS(s,l){var u=this.__data__;return this.size+=this.has(s)?0:1,u[s]=Zs&&l===i?o:l,this}eo.prototype.clear=AS,eo.prototype.delete=DS,eo.prototype.get=ES,eo.prototype.has=BS,eo.prototype.set=GS;function Yn(s){var l=-1,u=s==null?0:s.length;for(this.clear();++l<u;){var p=s[l];this.set(p[0],p[1])}}function RS(){this.__data__=[],this.size=0}function zS(s){var l=this.__data__,u=Tl(l,s);if(u<0)return!1;var p=l.length-1;return u==p?l.pop():xl.call(l,u,1),--this.size,!0}function FS(s){var l=this.__data__,u=Tl(l,s);return u<0?i:l[u][1]}function VS(s){return Tl(this.__data__,s)>-1}function US(s,l){var u=this.__data__,p=Tl(u,s);return p<0?(++this.size,u.push([s,l])):u[p][1]=l,this}Yn.prototype.clear=RS,Yn.prototype.delete=zS,Yn.prototype.get=FS,Yn.prototype.has=VS,Yn.prototype.set=US;function Xn(s){var l=-1,u=s==null?0:s.length;for(this.clear();++l<u;){var p=s[l];this.set(p[0],p[1])}}function jS(){this.size=0,this.__data__={hash:new eo,map:new(Ys||Yn),string:new eo}}function kS(s){var l=Rl(this,s).delete(s);return this.size-=l?1:0,l}function HS(s){return Rl(this,s).get(s)}function WS(s){return Rl(this,s).has(s)}function qS(s,l){var u=Rl(this,s),p=u.size;return u.set(s,l),this.size+=u.size==p?0:1,this}Xn.prototype.clear=jS,Xn.prototype.delete=kS,Xn.prototype.get=HS,Xn.prototype.has=WS,Xn.prototype.set=qS;function to(s){var l=-1,u=s==null?0:s.length;for(this.__data__=new Xn;++l<u;)this.add(s[l])}function $S(s){return this.__data__.set(s,o),this}function JS(s){return this.__data__.has(s)}to.prototype.add=to.prototype.push=$S,to.prototype.has=JS;function bn(s){var l=this.__data__=new Yn(s);this.size=l.size}function KS(){this.__data__=new Yn,this.size=0}function YS(s){var l=this.__data__,u=l.delete(s);return this.size=l.size,u}function XS(s){return this.__data__.get(s)}function ZS(s){return this.__data__.has(s)}function QS(s,l){var u=this.__data__;if(u instanceof Yn){var p=u.__data__;if(!Ys||p.length<e-1)return p.push([s,l]),this.size=++u.size,this;u=this.__data__=new Xn(p)}return u.set(s,l),this.size=u.size,this}bn.prototype.clear=KS,bn.prototype.delete=YS,bn.prototype.get=XS,bn.prototype.has=ZS,bn.prototype.set=QS;function dd(s,l){var u=ke(s),p=!u&&so(s),g=!u&&!p&&Ni(s),v=!u&&!p&&!g&&Vo(s),C=u||p||g||v,L=C?Zu(s.length,cS):[],_=L.length;for(var Z in s)(l||ht.call(s,Z))&&!(C&&(Z=="length"||g&&(Z=="offset"||Z=="parent")||v&&(Z=="buffer"||Z=="byteLength"||Z=="byteOffset")||ti(Z,_)))&&L.push(Z);return L}function md(s){var l=s.length;return l?s[gf(0,l-1)]:i}function e1(s,l){return zl(Ir(s),ro(l,0,s.length))}function t1(s){return zl(Ir(s))}function sf(s,l,u){(u!==i&&!Sn(s[l],u)||u===i&&!(l in s))&&Zn(s,l,u)}function ea(s,l,u){var p=s[l];(!(ht.call(s,l)&&Sn(p,u))||u===i&&!(l in s))&&Zn(s,l,u)}function Tl(s,l){for(var u=s.length;u--;)if(Sn(s[u][0],l))return u;return-1}function r1(s,l,u,p){return wi(s,function(g,v,C){l(p,g,u(g),C)}),p}function gd(s,l){return s&&Dn(l,Qt(l),s)}function n1(s,l){return s&&Dn(l,Mr(l),s)}function Zn(s,l,u){l=="__proto__"&&vl?vl(s,l,{configurable:!0,enumerable:!0,value:u,writable:!0}):s[l]=u}function af(s,l){for(var u=-1,p=l.length,g=U(p),v=s==null;++u<p;)g[u]=v?i:Uf(s,l[u]);return g}function ro(s,l,u){return s===s&&(u!==i&&(s=s<=u?s:u),l!==i&&(s=s>=l?s:l)),s}function rn(s,l,u,p,g,v){var C,L=l&f,_=l&h,Z=l&d;if(u&&(C=g?u(s,p,g,v):u(s)),C!==i)return C;if(!Pt(s))return s;var Q=ke(s);if(Q){if(C=W1(s),!L)return Ir(s,C)}else{var oe=hr(s),ge=oe==re||oe==q;if(Ni(s))return Vd(s,L);if(oe==le||oe==W||ge&&!g){if(C=_||ge?{}:om(s),!L)return _?E1(s,n1(C,s)):D1(s,gd(C,s))}else{if(!bt[oe])return g?s:{};C=q1(s,oe,L)}}v||(v=new bn);var Ne=v.get(s);if(Ne)return Ne;v.set(s,C),Em(s)?s.forEach(function(Ge){C.add(rn(Ge,l,u,Ge,s,v))}):Am(s)&&s.forEach(function(Ge,Ze){C.set(Ze,rn(Ge,l,u,Ze,s,v))});var ze=Z?_?_f:Nf:_?Mr:Qt,Je=Q?i:ze(s);return Qr(Je||s,function(Ge,Ze){Je&&(Ze=Ge,Ge=s[Ze]),ea(C,Ze,rn(Ge,l,u,Ze,s,v))}),C}function i1(s){var l=Qt(s);return function(u){return yd(u,s,l)}}function yd(s,l,u){var p=u.length;if(s==null)return!p;for(s=xt(s);p--;){var g=u[p],v=l[g],C=s[g];if(C===i&&!(g in s)||!v(C))return!1}return!0}function xd(s,l,u){if(typeof s!="function")throw new en(n);return aa(function(){s.apply(i,u)},l)}function ta(s,l,u,p){var g=-1,v=ll,C=!0,L=s.length,_=[],Z=l.length;if(!L)return _;u&&(l=It(l,Vr(u))),p?(v=qu,C=!1):l.length>=e&&(v=Js,C=!1,l=new to(l));e:for(;++g<L;){var Q=s[g],oe=u==null?Q:u(Q);if(Q=p||Q!==0?Q:0,C&&oe===oe){for(var ge=Z;ge--;)if(l[ge]===oe)continue e;_.push(Q)}else v(l,oe,p)||_.push(Q)}return _}var wi=Wd(An),vd=Wd(cf,!0);function o1(s,l){var u=!0;return wi(s,function(p,g,v){return u=!!l(p,g,v),u}),u}function Nl(s,l,u){for(var p=-1,g=s.length;++p<g;){var v=s[p],C=l(v);if(C!=null&&(L===i?C===C&&!jr(C):u(C,L)))var L=C,_=v}return _}function s1(s,l,u,p){var g=s.length;for(u=We(u),u<0&&(u=-u>g?0:g+u),p=p===i||p>g?g:We(p),p<0&&(p+=g),p=u>p?0:Gm(p);u<p;)s[u++]=l;return s}function bd(s,l){var u=[];return wi(s,function(p,g,v){l(p,g,v)&&u.push(p)}),u}function or(s,l,u,p,g){var v=-1,C=s.length;for(u||(u=J1),g||(g=[]);++v<C;){var L=s[v];l>0&&u(L)?l>1?or(L,l-1,u,p,g):xi(g,L):p||(g[g.length]=L)}return g}var lf=qd(),Sd=qd(!0);function An(s,l){return s&&lf(s,l,Qt)}function cf(s,l){return s&&Sd(s,l,Qt)}function _l(s,l){return yi(l,function(u){return ri(s[u])})}function no(s,l){l=Li(l,s);for(var u=0,p=l.length;s!=null&&u<p;)s=s[En(l[u++])];return u&&u==p?s:i}function wd(s,l,u){var p=l(s);return ke(s)?p:xi(p,u(s))}function xr(s){return s==null?s===i?ft:ce:Qi&&Qi in xt(s)?j1(s):tw(s)}function uf(s,l){return s>l}function a1(s,l){return s!=null&&ht.call(s,l)}function l1(s,l){return s!=null&&l in xt(s)}function c1(s,l,u){return s>=fr(l,u)&&s<Jt(l,u)}function ff(s,l,u){for(var p=u?qu:ll,g=s[0].length,v=s.length,C=v,L=U(v),_=1/0,Z=[];C--;){var Q=s[C];C&&l&&(Q=It(Q,Vr(l))),_=fr(Q.length,_),L[C]=!u&&(l||g>=120&&Q.length>=120)?new to(C&&Q):i}Q=s[0];var oe=-1,ge=L[0];e:for(;++oe<g&&Z.length<_;){var Ne=Q[oe],ze=l?l(Ne):Ne;if(Ne=u||Ne!==0?Ne:0,!(ge?Js(ge,ze):p(Z,ze,u))){for(C=v;--C;){var Je=L[C];if(!(Je?Js(Je,ze):p(s[C],ze,u)))continue e}ge&&ge.push(ze),Z.push(Ne)}}return Z}function u1(s,l,u,p){return An(s,function(g,v,C){l(p,u(g),v,C)}),p}function ra(s,l,u){l=Li(l,s),s=cm(s,l);var p=s==null?s:s[En(on(l))];return p==null?i:Fr(p,s,u)}function Cd(s){return Dt(s)&&xr(s)==W}function f1(s){return Dt(s)&&xr(s)==qe}function h1(s){return Dt(s)&&xr(s)==fe}function na(s,l,u,p,g){return s===l?!0:s==null||l==null||!Dt(s)&&!Dt(l)?s!==s&&l!==l:p1(s,l,u,p,na,g)}function p1(s,l,u,p,g,v){var C=ke(s),L=ke(l),_=C?J:hr(s),Z=L?J:hr(l);_=_==W?le:_,Z=Z==W?le:Z;var Q=_==le,oe=Z==le,ge=_==Z;if(ge&&Ni(s)){if(!Ni(l))return!1;C=!0,Q=!1}if(ge&&!Q)return v||(v=new bn),C||Vo(s)?rm(s,l,u,p,g,v):V1(s,l,_,u,p,g,v);if(!(u&m)){var Ne=Q&&ht.call(s,"__wrapped__"),ze=oe&&ht.call(l,"__wrapped__");if(Ne||ze){var Je=Ne?s.value():s,Ge=ze?l.value():l;return v||(v=new bn),g(Je,Ge,u,p,v)}}return ge?(v||(v=new bn),U1(s,l,u,p,g,v)):!1}function d1(s){return Dt(s)&&hr(s)==ee}function hf(s,l,u,p){var g=u.length,v=g,C=!p;if(s==null)return!v;for(s=xt(s);g--;){var L=u[g];if(C&&L[2]?L[1]!==s[L[0]]:!(L[0]in s))return!1}for(;++g<v;){L=u[g];var _=L[0],Z=s[_],Q=L[1];if(C&&L[2]){if(Z===i&&!(_ in s))return!1}else{var oe=new bn;if(p)var ge=p(Z,Q,_,s,l,oe);if(!(ge===i?na(Q,Z,m|x,p,oe):ge))return!1}}return!0}function Ld(s){if(!Pt(s)||Y1(s))return!1;var l=ri(s)?dS:ib;return l.test(oo(s))}function m1(s){return Dt(s)&&xr(s)==de}function g1(s){return Dt(s)&&hr(s)==be}function y1(s){return Dt(s)&&Hl(s.length)&&!!Tt[xr(s)]}function Td(s){return typeof s=="function"?s:s==null?Pr:typeof s=="object"?ke(s)?Id(s[0],s[1]):_d(s):$m(s)}function pf(s){if(!sa(s))return bS(s);var l=[];for(var u in xt(s))ht.call(s,u)&&u!="constructor"&&l.push(u);return l}function x1(s){if(!Pt(s))return ew(s);var l=sa(s),u=[];for(var p in s)p=="constructor"&&(l||!ht.call(s,p))||u.push(p);return u}function df(s,l){return s<l}function Nd(s,l){var u=-1,p=Or(s)?U(s.length):[];return wi(s,function(g,v,C){p[++u]=l(g,v,C)}),p}function _d(s){var l=Of(s);return l.length==1&&l[0][2]?am(l[0][0],l[0][1]):function(u){return u===s||hf(u,s,l)}}function Id(s,l){return Pf(s)&&sm(l)?am(En(s),l):function(u){var p=Uf(u,s);return p===i&&p===l?jf(u,s):na(l,p,m|x)}}function Il(s,l,u,p,g){s!==l&&lf(l,function(v,C){if(g||(g=new bn),Pt(v))v1(s,l,C,u,Il,p,g);else{var L=p?p(Df(s,C),v,C+"",s,l,g):i;L===i&&(L=v),sf(s,C,L)}},Mr)}function v1(s,l,u,p,g,v,C){var L=Df(s,u),_=Df(l,u),Z=C.get(_);if(Z){sf(s,u,Z);return}var Q=v?v(L,_,u+"",s,l,C):i,oe=Q===i;if(oe){var ge=ke(_),Ne=!ge&&Ni(_),ze=!ge&&!Ne&&Vo(_);Q=_,ge||Ne||ze?ke(L)?Q=L:Gt(L)?Q=Ir(L):Ne?(oe=!1,Q=Vd(_,!0)):ze?(oe=!1,Q=Ud(_,!0)):Q=[]:la(_)||so(_)?(Q=L,so(L)?Q=Rm(L):(!Pt(L)||ri(L))&&(Q=om(_))):oe=!1}oe&&(C.set(_,Q),g(Q,_,p,v,C),C.delete(_)),sf(s,u,Q)}function Od(s,l){var u=s.length;if(!!u)return l+=l<0?u:0,ti(l,u)?s[l]:i}function Md(s,l,u){l.length?l=It(l,function(v){return ke(v)?function(C){return no(C,v.length===1?v[0]:v)}:v}):l=[Pr];var p=-1;l=It(l,Vr(Be()));var g=Nd(s,function(v,C,L){var _=It(l,function(Z){return Z(v)});return{criteria:_,index:++p,value:v}});return qb(g,function(v,C){return A1(v,C,u)})}function b1(s,l){return Pd(s,l,function(u,p){return jf(s,p)})}function Pd(s,l,u){for(var p=-1,g=l.length,v={};++p<g;){var C=l[p],L=no(s,C);u(L,C)&&ia(v,Li(C,s),L)}return v}function S1(s){return function(l){return no(l,s)}}function mf(s,l,u,p){var g=p?Wb:Mo,v=-1,C=l.length,L=s;for(s===l&&(l=Ir(l)),u&&(L=It(s,Vr(u)));++v<C;)for(var _=0,Z=l[v],Q=u?u(Z):Z;(_=g(L,Q,_,p))>-1;)L!==s&&xl.call(L,_,1),xl.call(s,_,1);return s}function Ad(s,l){for(var u=s?l.length:0,p=u-1;u--;){var g=l[u];if(u==p||g!==v){var v=g;ti(g)?xl.call(s,g,1):vf(s,g)}}return s}function gf(s,l){return s+Sl(hd()*(l-s+1))}function w1(s,l,u,p){for(var g=-1,v=Jt(bl((l-s)/(u||1)),0),C=U(v);v--;)C[p?v:++g]=s,s+=u;return C}function yf(s,l){var u="";if(!s||l<1||l>ne)return u;do l%2&&(u+=s),l=Sl(l/2),l&&(s+=s);while(l);return u}function Xe(s,l){return Ef(lm(s,l,Pr),s+"")}function C1(s){return md(Uo(s))}function L1(s,l){var u=Uo(s);return zl(u,ro(l,0,u.length))}function ia(s,l,u,p){if(!Pt(s))return s;l=Li(l,s);for(var g=-1,v=l.length,C=v-1,L=s;L!=null&&++g<v;){var _=En(l[g]),Z=u;if(_==="__proto__"||_==="constructor"||_==="prototype")return s;if(g!=C){var Q=L[_];Z=p?p(Q,_,L):i,Z===i&&(Z=Pt(Q)?Q:ti(l[g+1])?[]:{})}ea(L,_,Z),L=L[_]}return s}var Dd=wl?function(s,l){return wl.set(s,l),s}:Pr,T1=vl?function(s,l){return vl(s,"toString",{configurable:!0,enumerable:!1,value:Hf(l),writable:!0})}:Pr;function N1(s){return zl(Uo(s))}function nn(s,l,u){var p=-1,g=s.length;l<0&&(l=-l>g?0:g+l),u=u>g?g:u,u<0&&(u+=g),g=l>u?0:u-l>>>0,l>>>=0;for(var v=U(g);++p<g;)v[p]=s[p+l];return v}function _1(s,l){var u;return wi(s,function(p,g,v){return u=l(p,g,v),!u}),!!u}function Ol(s,l,u){var p=0,g=s==null?p:s.length;if(typeof l=="number"&&l===l&&g<=se){for(;p<g;){var v=p+g>>>1,C=s[v];C!==null&&!jr(C)&&(u?C<=l:C<l)?p=v+1:g=v}return g}return xf(s,l,Pr,u)}function xf(s,l,u,p){var g=0,v=s==null?0:s.length;if(v===0)return 0;l=u(l);for(var C=l!==l,L=l===null,_=jr(l),Z=l===i;g<v;){var Q=Sl((g+v)/2),oe=u(s[Q]),ge=oe!==i,Ne=oe===null,ze=oe===oe,Je=jr(oe);if(C)var Ge=p||ze;else Z?Ge=ze&&(p||ge):L?Ge=ze&&ge&&(p||!Ne):_?Ge=ze&&ge&&!Ne&&(p||!Je):Ne||Je?Ge=!1:Ge=p?oe<=l:oe<l;Ge?g=Q+1:v=Q}return fr(v,Ue)}function Ed(s,l){for(var u=-1,p=s.length,g=0,v=[];++u<p;){var C=s[u],L=l?l(C):C;if(!u||!Sn(L,_)){var _=L;v[g++]=C===0?0:C}}return v}function Bd(s){return typeof s=="number"?s:jr(s)?_e:+s}function Ur(s){if(typeof s=="string")return s;if(ke(s))return It(s,Ur)+"";if(jr(s))return pd?pd.call(s):"";var l=s+"";return l=="0"&&1/s==-ae?"-0":l}function Ci(s,l,u){var p=-1,g=ll,v=s.length,C=!0,L=[],_=L;if(u)C=!1,g=qu;else if(v>=e){var Z=l?null:z1(s);if(Z)return ul(Z);C=!1,g=Js,_=new to}else _=l?[]:L;e:for(;++p<v;){var Q=s[p],oe=l?l(Q):Q;if(Q=u||Q!==0?Q:0,C&&oe===oe){for(var ge=_.length;ge--;)if(_[ge]===oe)continue e;l&&_.push(oe),L.push(Q)}else g(_,oe,u)||(_!==L&&_.push(oe),L.push(Q))}return L}function vf(s,l){return l=Li(l,s),s=cm(s,l),s==null||delete s[En(on(l))]}function Gd(s,l,u,p){return ia(s,l,u(no(s,l)),p)}function Ml(s,l,u,p){for(var g=s.length,v=p?g:-1;(p?v--:++v<g)&&l(s[v],v,s););return u?nn(s,p?0:v,p?v+1:g):nn(s,p?v+1:0,p?g:v)}function Rd(s,l){var u=s;return u instanceof et&&(u=u.value()),$u(l,function(p,g){return g.func.apply(g.thisArg,xi([p],g.args))},u)}function bf(s,l,u){var p=s.length;if(p<2)return p?Ci(s[0]):[];for(var g=-1,v=U(p);++g<p;)for(var C=s[g],L=-1;++L<p;)L!=g&&(v[g]=ta(v[g]||C,s[L],l,u));return Ci(or(v,1),l,u)}function zd(s,l,u){for(var p=-1,g=s.length,v=l.length,C={};++p<g;){var L=p<v?l[p]:i;u(C,s[p],L)}return C}function Sf(s){return Gt(s)?s:[]}function wf(s){return typeof s=="function"?s:Pr}function Li(s,l){return ke(s)?s:Pf(s,l)?[s]:pm(lt(s))}var I1=Xe;function Ti(s,l,u){var p=s.length;return u=u===i?p:u,!l&&u>=p?s:nn(s,l,u)}var Fd=mS||function(s){return Zt.clearTimeout(s)};function Vd(s,l){if(l)return s.slice();var u=s.length,p=ad?ad(u):new s.constructor(u);return s.copy(p),p}function Cf(s){var l=new s.constructor(s.byteLength);return new gl(l).set(new gl(s)),l}function O1(s,l){var u=l?Cf(s.buffer):s.buffer;return new s.constructor(u,s.byteOffset,s.byteLength)}function M1(s){var l=new s.constructor(s.source,xn.exec(s));return l.lastIndex=s.lastIndex,l}function P1(s){return Qs?xt(Qs.call(s)):{}}function Ud(s,l){var u=l?Cf(s.buffer):s.buffer;return new s.constructor(u,s.byteOffset,s.length)}function jd(s,l){if(s!==l){var u=s!==i,p=s===null,g=s===s,v=jr(s),C=l!==i,L=l===null,_=l===l,Z=jr(l);if(!L&&!Z&&!v&&s>l||v&&C&&_&&!L&&!Z||p&&C&&_||!u&&_||!g)return 1;if(!p&&!v&&!Z&&s<l||Z&&u&&g&&!p&&!v||L&&u&&g||!C&&g||!_)return-1}return 0}function A1(s,l,u){for(var p=-1,g=s.criteria,v=l.criteria,C=g.length,L=u.length;++p<C;){var _=jd(g[p],v[p]);if(_){if(p>=L)return _;var Z=u[p];return _*(Z=="desc"?-1:1)}}return s.index-l.index}function kd(s,l,u,p){for(var g=-1,v=s.length,C=u.length,L=-1,_=l.length,Z=Jt(v-C,0),Q=U(_+Z),oe=!p;++L<_;)Q[L]=l[L];for(;++g<C;)(oe||g<v)&&(Q[u[g]]=s[g]);for(;Z--;)Q[L++]=s[g++];return Q}function Hd(s,l,u,p){for(var g=-1,v=s.length,C=-1,L=u.length,_=-1,Z=l.length,Q=Jt(v-L,0),oe=U(Q+Z),ge=!p;++g<Q;)oe[g]=s[g];for(var Ne=g;++_<Z;)oe[Ne+_]=l[_];for(;++C<L;)(ge||g<v)&&(oe[Ne+u[C]]=s[g++]);return oe}function Ir(s,l){var u=-1,p=s.length;for(l||(l=U(p));++u<p;)l[u]=s[u];return l}function Dn(s,l,u,p){var g=!u;u||(u={});for(var v=-1,C=l.length;++v<C;){var L=l[v],_=p?p(u[L],s[L],L,u,s):i;_===i&&(_=s[L]),g?Zn(u,L,_):ea(u,L,_)}return u}function D1(s,l){return Dn(s,Mf(s),l)}function E1(s,l){return Dn(s,nm(s),l)}function Pl(s,l){return function(u,p){var g=ke(u)?Fb:r1,v=l?l():{};return g(u,s,Be(p,2),v)}}function Ro(s){return Xe(function(l,u){var p=-1,g=u.length,v=g>1?u[g-1]:i,C=g>2?u[2]:i;for(v=s.length>3&&typeof v=="function"?(g--,v):i,C&&vr(u[0],u[1],C)&&(v=g<3?i:v,g=1),l=xt(l);++p<g;){var L=u[p];L&&s(l,L,p,v)}return l})}function Wd(s,l){return function(u,p){if(u==null)return u;if(!Or(u))return s(u,p);for(var g=u.length,v=l?g:-1,C=xt(u);(l?v--:++v<g)&&p(C[v],v,C)!==!1;);return u}}function qd(s){return function(l,u,p){for(var g=-1,v=xt(l),C=p(l),L=C.length;L--;){var _=C[s?L:++g];if(u(v[_],_,v)===!1)break}return l}}function B1(s,l,u){var p=l&S,g=oa(s);function v(){var C=this&&this!==Zt&&this instanceof v?g:s;return C.apply(p?u:this,arguments)}return v}function $d(s){return function(l){l=lt(l);var u=Po(l)?vn(l):i,p=u?u[0]:l.charAt(0),g=u?Ti(u,1).join(""):l.slice(1);return p[s]()+g}}function zo(s){return function(l){return $u(Wm(Hm(l).replace(Tb,"")),s,"")}}function oa(s){return function(){var l=arguments;switch(l.length){case 0:return new s;case 1:return new s(l[0]);case 2:return new s(l[0],l[1]);case 3:return new s(l[0],l[1],l[2]);case 4:return new s(l[0],l[1],l[2],l[3]);case 5:return new s(l[0],l[1],l[2],l[3],l[4]);case 6:return new s(l[0],l[1],l[2],l[3],l[4],l[5]);case 7:return new s(l[0],l[1],l[2],l[3],l[4],l[5],l[6])}var u=Go(s.prototype),p=s.apply(u,l);return Pt(p)?p:u}}function G1(s,l,u){var p=oa(s);function g(){for(var v=arguments.length,C=U(v),L=v,_=Fo(g);L--;)C[L]=arguments[L];var Z=v<3&&C[0]!==_&&C[v-1]!==_?[]:vi(C,_);if(v-=Z.length,v<u)return Zd(s,l,Al,g.placeholder,i,C,Z,i,i,u-v);var Q=this&&this!==Zt&&this instanceof g?p:s;return Fr(Q,this,C)}return g}function Jd(s){return function(l,u,p){var g=xt(l);if(!Or(l)){var v=Be(u,3);l=Qt(l),u=function(L){return v(g[L],L,g)}}var C=s(l,u,p);return C>-1?g[v?l[C]:C]:i}}function Kd(s){return ei(function(l){var u=l.length,p=u,g=tn.prototype.thru;for(s&&l.reverse();p--;){var v=l[p];if(typeof v!="function")throw new en(n);if(g&&!C&&Gl(v)=="wrapper")var C=new tn([],!0)}for(p=C?p:u;++p<u;){v=l[p];var L=Gl(v),_=L=="wrapper"?If(v):i;_&&Af(_[0])&&_[1]==(k|O|M|N)&&!_[4].length&&_[9]==1?C=C[Gl(_[0])].apply(C,_[3]):C=v.length==1&&Af(v)?C[L]():C.thru(v)}return function(){var Z=arguments,Q=Z[0];if(C&&Z.length==1&&ke(Q))return C.plant(Q).value();for(var oe=0,ge=u?l[oe].apply(this,Z):Q;++oe<u;)ge=l[oe].call(this,ge);return ge}})}function Al(s,l,u,p,g,v,C,L,_,Z){var Q=l&k,oe=l&S,ge=l&w,Ne=l&(O|T),ze=l&te,Je=ge?i:oa(s);function Ge(){for(var Ze=arguments.length,tt=U(Ze),kr=Ze;kr--;)tt[kr]=arguments[kr];if(Ne)var br=Fo(Ge),Hr=Jb(tt,br);if(p&&(tt=kd(tt,p,g,Ne)),v&&(tt=Hd(tt,v,C,Ne)),Ze-=Hr,Ne&&Ze<Z){var Rt=vi(tt,br);return Zd(s,l,Al,Ge.placeholder,u,tt,Rt,L,_,Z-Ze)}var wn=oe?u:this,ii=ge?wn[s]:s;return Ze=tt.length,L?tt=rw(tt,L):ze&&Ze>1&&tt.reverse(),Q&&_<Ze&&(tt.length=_),this&&this!==Zt&&this instanceof Ge&&(ii=Je||oa(ii)),ii.apply(wn,tt)}return Ge}function Yd(s,l){return function(u,p){return u1(u,s,l(p),{})}}function Dl(s,l){return function(u,p){var g;if(u===i&&p===i)return l;if(u!==i&&(g=u),p!==i){if(g===i)return p;typeof u=="string"||typeof p=="string"?(u=Ur(u),p=Ur(p)):(u=Bd(u),p=Bd(p)),g=s(u,p)}return g}}function Lf(s){return ei(function(l){return l=It(l,Vr(Be())),Xe(function(u){var p=this;return s(l,function(g){return Fr(g,p,u)})})})}function El(s,l){l=l===i?" ":Ur(l);var u=l.length;if(u<2)return u?yf(l,s):l;var p=yf(l,bl(s/Ao(l)));return Po(l)?Ti(vn(p),0,s).join(""):p.slice(0,s)}function R1(s,l,u,p){var g=l&S,v=oa(s);function C(){for(var L=-1,_=arguments.length,Z=-1,Q=p.length,oe=U(Q+_),ge=this&&this!==Zt&&this instanceof C?v:s;++Z<Q;)oe[Z]=p[Z];for(;_--;)oe[Z++]=arguments[++L];return Fr(ge,g?u:this,oe)}return C}function Xd(s){return function(l,u,p){return p&&typeof p!="number"&&vr(l,u,p)&&(u=p=i),l=ni(l),u===i?(u=l,l=0):u=ni(u),p=p===i?l<u?1:-1:ni(p),w1(l,u,p,s)}}function Bl(s){return function(l,u){return typeof l=="string"&&typeof u=="string"||(l=sn(l),u=sn(u)),s(l,u)}}function Zd(s,l,u,p,g,v,C,L,_,Z){var Q=l&O,oe=Q?C:i,ge=Q?i:C,Ne=Q?v:i,ze=Q?i:v;l|=Q?M:F,l&=~(Q?F:M),l&B||(l&=~(S|w));var Je=[s,l,g,Ne,oe,ze,ge,L,_,Z],Ge=u.apply(i,Je);return Af(s)&&um(Ge,Je),Ge.placeholder=p,fm(Ge,s,l)}function Tf(s){var l=$t[s];return function(u,p){if(u=sn(u),p=p==null?0:fr(We(p),292),p&&fd(u)){var g=(lt(u)+"e").split("e"),v=l(g[0]+"e"+(+g[1]+p));return g=(lt(v)+"e").split("e"),+(g[0]+"e"+(+g[1]-p))}return l(u)}}var z1=Eo&&1/ul(new Eo([,-0]))[1]==ae?function(s){return new Eo(s)}:$f;function Qd(s){return function(l){var u=hr(l);return u==ee?ef(l):u==be?tS(l):$b(l,s(l))}}function Qn(s,l,u,p,g,v,C,L){var _=l&w;if(!_&&typeof s!="function")throw new en(n);var Z=p?p.length:0;if(Z||(l&=~(M|F),p=g=i),C=C===i?C:Jt(We(C),0),L=L===i?L:We(L),Z-=g?g.length:0,l&F){var Q=p,oe=g;p=g=i}var ge=_?i:If(s),Ne=[s,l,u,p,g,Q,oe,v,C,L];if(ge&&Q1(Ne,ge),s=Ne[0],l=Ne[1],u=Ne[2],p=Ne[3],g=Ne[4],L=Ne[9]=Ne[9]===i?_?0:s.length:Jt(Ne[9]-Z,0),!L&&l&(O|T)&&(l&=~(O|T)),!l||l==S)var ze=B1(s,l,u);else l==O||l==T?ze=G1(s,l,L):(l==M||l==(S|M))&&!g.length?ze=R1(s,l,u,p):ze=Al.apply(i,Ne);var Je=ge?Dd:um;return fm(Je(ze,Ne),s,l)}function em(s,l,u,p){return s===i||Sn(s,Do[u])&&!ht.call(p,u)?l:s}function tm(s,l,u,p,g,v){return Pt(s)&&Pt(l)&&(v.set(l,s),Il(s,l,i,tm,v),v.delete(l)),s}function F1(s){return la(s)?i:s}function rm(s,l,u,p,g,v){var C=u&m,L=s.length,_=l.length;if(L!=_&&!(C&&_>L))return!1;var Z=v.get(s),Q=v.get(l);if(Z&&Q)return Z==l&&Q==s;var oe=-1,ge=!0,Ne=u&x?new to:i;for(v.set(s,l),v.set(l,s);++oe<L;){var ze=s[oe],Je=l[oe];if(p)var Ge=C?p(Je,ze,oe,l,s,v):p(ze,Je,oe,s,l,v);if(Ge!==i){if(Ge)continue;ge=!1;break}if(Ne){if(!Ju(l,function(Ze,tt){if(!Js(Ne,tt)&&(ze===Ze||g(ze,Ze,u,p,v)))return Ne.push(tt)})){ge=!1;break}}else if(!(ze===Je||g(ze,Je,u,p,v))){ge=!1;break}}return v.delete(s),v.delete(l),ge}function V1(s,l,u,p,g,v,C){switch(u){case _t:if(s.byteLength!=l.byteLength||s.byteOffset!=l.byteOffset)return!1;s=s.buffer,l=l.buffer;case qe:return!(s.byteLength!=l.byteLength||!v(new gl(s),new gl(l)));case K:case fe:case Te:return Sn(+s,+l);case ie:return s.name==l.name&&s.message==l.message;case de:case Se:return s==l+"";case ee:var L=ef;case be:var _=p&m;if(L||(L=ul),s.size!=l.size&&!_)return!1;var Z=C.get(s);if(Z)return Z==l;p|=x,C.set(s,l);var Q=rm(L(s),L(l),p,g,v,C);return C.delete(s),Q;case Ie:if(Qs)return Qs.call(s)==Qs.call(l)}return!1}function U1(s,l,u,p,g,v){var C=u&m,L=Nf(s),_=L.length,Z=Nf(l),Q=Z.length;if(_!=Q&&!C)return!1;for(var oe=_;oe--;){var ge=L[oe];if(!(C?ge in l:ht.call(l,ge)))return!1}var Ne=v.get(s),ze=v.get(l);if(Ne&&ze)return Ne==l&&ze==s;var Je=!0;v.set(s,l),v.set(l,s);for(var Ge=C;++oe<_;){ge=L[oe];var Ze=s[ge],tt=l[ge];if(p)var kr=C?p(tt,Ze,ge,l,s,v):p(Ze,tt,ge,s,l,v);if(!(kr===i?Ze===tt||g(Ze,tt,u,p,v):kr)){Je=!1;break}Ge||(Ge=ge=="constructor")}if(Je&&!Ge){var br=s.constructor,Hr=l.constructor;br!=Hr&&"constructor"in s&&"constructor"in l&&!(typeof br=="function"&&br instanceof br&&typeof Hr=="function"&&Hr instanceof Hr)&&(Je=!1)}return v.delete(s),v.delete(l),Je}function ei(s){return Ef(lm(s,i,ym),s+"")}function Nf(s){return wd(s,Qt,Mf)}function _f(s){return wd(s,Mr,nm)}var If=wl?function(s){return wl.get(s)}:$f;function Gl(s){for(var l=s.name+"",u=Bo[l],p=ht.call(Bo,l)?u.length:0;p--;){var g=u[p],v=g.func;if(v==null||v==s)return g.name}return l}function Fo(s){var l=ht.call(y,"placeholder")?y:s;return l.placeholder}function Be(){var s=y.iteratee||Wf;return s=s===Wf?Td:s,arguments.length?s(arguments[0],arguments[1]):s}function Rl(s,l){var u=s.__data__;return K1(l)?u[typeof l=="string"?"string":"hash"]:u.map}function Of(s){for(var l=Qt(s),u=l.length;u--;){var p=l[u],g=s[p];l[u]=[p,g,sm(g)]}return l}function io(s,l){var u=Zb(s,l);return Ld(u)?u:i}function j1(s){var l=ht.call(s,Qi),u=s[Qi];try{s[Qi]=i;var p=!0}catch{}var g=dl.call(s);return p&&(l?s[Qi]=u:delete s[Qi]),g}var Mf=rf?function(s){return s==null?[]:(s=xt(s),yi(rf(s),function(l){return cd.call(s,l)}))}:Jf,nm=rf?function(s){for(var l=[];s;)xi(l,Mf(s)),s=yl(s);return l}:Jf,hr=xr;(nf&&hr(new nf(new ArrayBuffer(1)))!=_t||Ys&&hr(new Ys)!=ee||of&&hr(of.resolve())!=he||Eo&&hr(new Eo)!=be||Xs&&hr(new Xs)!=Ve)&&(hr=function(s){var l=xr(s),u=l==le?s.constructor:i,p=u?oo(u):"";if(p)switch(p){case LS:return _t;case TS:return ee;case NS:return he;case _S:return be;case IS:return Ve}return l});function k1(s,l,u){for(var p=-1,g=u.length;++p<g;){var v=u[p],C=v.size;switch(v.type){case"drop":s+=C;break;case"dropRight":l-=C;break;case"take":l=fr(l,s+C);break;case"takeRight":s=Jt(s,l-C);break}}return{start:s,end:l}}function H1(s){var l=s.match(at);return l?l[1].split(vt):[]}function im(s,l,u){l=Li(l,s);for(var p=-1,g=l.length,v=!1;++p<g;){var C=En(l[p]);if(!(v=s!=null&&u(s,C)))break;s=s[C]}return v||++p!=g?v:(g=s==null?0:s.length,!!g&&Hl(g)&&ti(C,g)&&(ke(s)||so(s)))}function W1(s){var l=s.length,u=new s.constructor(l);return l&&typeof s[0]=="string"&&ht.call(s,"index")&&(u.index=s.index,u.input=s.input),u}function om(s){return typeof s.constructor=="function"&&!sa(s)?Go(yl(s)):{}}function q1(s,l,u){var p=s.constructor;switch(l){case qe:return Cf(s);case K:case fe:return new p(+s);case _t:return O1(s,u);case Wt:case Rr:case Ut:case zr:case mn:case gn:case pt:case jt:case ir:return Ud(s,u);case ee:return new p;case Te:case Se:return new p(s);case de:return M1(s);case be:return new p;case Ie:return P1(s)}}function $1(s,l){var u=l.length;if(!u)return s;var p=u-1;return l[p]=(u>1?"& ":"")+l[p],l=l.join(u>2?", ":" "),s.replace(mt,`{
2
2
  /* [wrapped with `+l+`] */
3
- `)}function H1(s){return ke(s)||so(s)||!!(ud&&s&&s[ud])}function ti(s,l){var u=typeof s;return l=l==null?ne:l,!!l&&(u=="number"||u!="symbol"&&rb.test(s))&&s>-1&&s%1==0&&s<l}function vr(s,l,u){if(!Pt(u))return!1;var p=typeof l;return(p=="number"?Or(u)&&ti(l,u.length):p=="string"&&l in u)?Sn(u[l],s):!1}function Pf(s,l){if(ke(s))return!1;var u=typeof s;return u=="number"||u=="symbol"||u=="boolean"||s==null||jr(s)?!0:Re.test(s)||!_o.test(s)||l!=null&&s in xt(l)}function W1(s){var l=typeof s;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?s!=="__proto__":s===null}function Af(s){var l=Gl(s),u=y[l];if(typeof u!="function"||!(l in et.prototype))return!1;if(s===u)return!0;var p=If(u);return!!p&&s===p[0]}function q1(s){return!!sd&&sd in s}var $1=hl?ri:Kf;function oa(s){var l=s&&s.constructor,u=typeof l=="function"&&l.prototype||Ao;return s===u}function sm(s){return s===s&&!Pt(s)}function am(s,l){return function(u){return u==null?!1:u[s]===l&&(l!==i||s in xt(u))}}function J1(s){var l=jl(s,function(p){return u.size===a&&u.clear(),p}),u=l.cache;return l}function K1(s,l){var u=s[1],p=l[1],g=u|p,v=g<(S|w|k),C=p==k&&u==O||p==k&&u==N&&s[7].length<=l[8]||p==(k|N)&&l[7].length<=l[8]&&u==O;if(!(v||C))return s;p&S&&(s[2]=l[2],g|=u&S?0:B);var L=l[3];if(L){var _=s[3];s[3]=_?kd(_,L,l[4]):L,s[4]=_?vi(s[3],c):l[4]}return L=l[5],L&&(_=s[5],s[5]=_?Hd(_,L,l[6]):L,s[6]=_?vi(s[5],c):l[6]),L=l[7],L&&(s[7]=L),p&k&&(s[8]=s[8]==null?l[8]:fr(s[8],l[8])),s[9]==null&&(s[9]=l[9]),s[0]=l[0],s[1]=g,s}function Y1(s){var l=[];if(s!=null)for(var u in xt(s))l.push(u);return l}function X1(s){return dl.call(s)}function lm(s,l,u){return l=Jt(l===i?s.length-1:l,0),function(){for(var p=arguments,g=-1,v=Jt(p.length-l,0),C=U(v);++g<v;)C[g]=p[l+g];g=-1;for(var L=U(l+1);++g<l;)L[g]=p[g];return L[l]=u(C),Fr(s,this,L)}}function cm(s,l){return l.length<2?s:no(s,nn(l,0,-1))}function Z1(s,l){for(var u=s.length,p=fr(l.length,u),g=Ir(s);p--;){var v=l[p];s[p]=ti(v,u)?g[v]:i}return s}function Df(s,l){if(!(l==="constructor"&&typeof s[l]=="function")&&l!="__proto__")return s[l]}var um=hm(Dd),sa=pS||function(s,l){return Zt.setTimeout(s,l)},Ef=hm(S1);function fm(s,l,u){var p=l+"";return Ef(s,k1(p,Q1(V1(p),u)))}function hm(s){var l=0,u=0;return function(){var p=yS(),g=P-(p-u);if(u=p,g>0){if(++l>=V)return arguments[0]}else l=0;return s.apply(i,arguments)}}function zl(s,l){var u=-1,p=s.length,g=p-1;for(l=l===i?p:l;++u<l;){var v=gf(u,g),C=s[v];s[v]=s[u],s[u]=C}return s.length=l,s}var pm=J1(function(s){var l=[];return s.charCodeAt(0)===46&&l.push(""),s.replace(Ye,function(u,p,g,v){l.push(g?v.replace(_r,"$1"):p||u)}),l});function En(s){if(typeof s=="string"||jr(s))return s;var l=s+"";return l=="0"&&1/s==-ae?"-0":l}function oo(s){if(s!=null){try{return pl.call(s)}catch{}try{return s+""}catch{}}return""}function Q1(s,l){return Qr($,function(u){var p="_."+u[0];l&u[1]&&!ll(s,p)&&s.push(p)}),s.sort()}function dm(s){if(s instanceof et)return s.clone();var l=new tn(s.__wrapped__,s.__chain__);return l.__actions__=Ir(s.__actions__),l.__index__=s.__index__,l.__values__=s.__values__,l}function ew(s,l,u){(u?vr(s,l,u):l===i)?l=1:l=Jt(We(l),0);var p=s==null?0:s.length;if(!p||l<1)return[];for(var g=0,v=0,C=U(bl(p/l));g<p;)C[v++]=nn(s,g,g+=l);return C}function tw(s){for(var l=-1,u=s==null?0:s.length,p=0,g=[];++l<u;){var v=s[l];v&&(g[p++]=v)}return g}function rw(){var s=arguments.length;if(!s)return[];for(var l=U(s-1),u=arguments[0],p=s;p--;)l[p-1]=arguments[p];return xi(ke(u)?Ir(u):[u],or(l,1))}var nw=Xe(function(s,l){return Gt(s)?ea(s,or(l,1,Gt,!0)):[]}),iw=Xe(function(s,l){var u=on(l);return Gt(u)&&(u=i),Gt(s)?ea(s,or(l,1,Gt,!0),Be(u,2)):[]}),ow=Xe(function(s,l){var u=on(l);return Gt(u)&&(u=i),Gt(s)?ea(s,or(l,1,Gt,!0),i,u):[]});function sw(s,l,u){var p=s==null?0:s.length;return p?(l=u||l===i?1:We(l),nn(s,l<0?0:l,p)):[]}function aw(s,l,u){var p=s==null?0:s.length;return p?(l=u||l===i?1:We(l),l=p-l,nn(s,0,l<0?0:l)):[]}function lw(s,l){return s&&s.length?Ml(s,Be(l,3),!0,!0):[]}function cw(s,l){return s&&s.length?Ml(s,Be(l,3),!0):[]}function uw(s,l,u,p){var g=s==null?0:s.length;return g?(u&&typeof u!="number"&&vr(s,l,u)&&(u=0,p=g),r1(s,l,u,p)):[]}function mm(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=u==null?0:We(u);return g<0&&(g=Jt(p+g,0)),cl(s,Be(l,3),g)}function gm(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=p-1;return u!==i&&(g=We(u),g=u<0?Jt(p+g,0):fr(g,p-1)),cl(s,Be(l,3),g,!0)}function ym(s){var l=s==null?0:s.length;return l?or(s,1):[]}function fw(s){var l=s==null?0:s.length;return l?or(s,ae):[]}function hw(s,l){var u=s==null?0:s.length;return u?(l=l===i?1:We(l),or(s,l)):[]}function pw(s){for(var l=-1,u=s==null?0:s.length,p={};++l<u;){var g=s[l];p[g[0]]=g[1]}return p}function xm(s){return s&&s.length?s[0]:i}function dw(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=u==null?0:We(u);return g<0&&(g=Jt(p+g,0)),Oo(s,l,g)}function mw(s){var l=s==null?0:s.length;return l?nn(s,0,-1):[]}var gw=Xe(function(s){var l=It(s,Sf);return l.length&&l[0]===s[0]?ff(l):[]}),yw=Xe(function(s){var l=on(s),u=It(s,Sf);return l===on(u)?l=i:u.pop(),u.length&&u[0]===s[0]?ff(u,Be(l,2)):[]}),xw=Xe(function(s){var l=on(s),u=It(s,Sf);return l=typeof l=="function"?l:i,l&&u.pop(),u.length&&u[0]===s[0]?ff(u,i,l):[]});function vw(s,l){return s==null?"":mS.call(s,l)}function on(s){var l=s==null?0:s.length;return l?s[l-1]:i}function bw(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=p;return u!==i&&(g=We(u),g=g<0?Jt(p+g,0):fr(g,p-1)),l===l?Qb(s,l,g):cl(s,ed,g,!0)}function Sw(s,l){return s&&s.length?Od(s,We(l)):i}var ww=Xe(vm);function vm(s,l){return s&&s.length&&l&&l.length?mf(s,l):s}function Cw(s,l,u){return s&&s.length&&l&&l.length?mf(s,l,Be(u,2)):s}function Lw(s,l,u){return s&&s.length&&l&&l.length?mf(s,l,i,u):s}var Tw=ei(function(s,l){var u=s==null?0:s.length,p=af(s,l);return Ad(s,It(l,function(g){return ti(g,u)?+g:g}).sort(jd)),p});function Nw(s,l){var u=[];if(!(s&&s.length))return u;var p=-1,g=[],v=s.length;for(l=Be(l,3);++p<v;){var C=s[p];l(C,p,s)&&(u.push(C),g.push(p))}return Ad(s,g),u}function Bf(s){return s==null?s:vS.call(s)}function _w(s,l,u){var p=s==null?0:s.length;return p?(u&&typeof u!="number"&&vr(s,l,u)?(l=0,u=p):(l=l==null?0:We(l),u=u===i?p:We(u)),nn(s,l,u)):[]}function Iw(s,l){return Ol(s,l)}function Ow(s,l,u){return xf(s,l,Be(u,2))}function Mw(s,l){var u=s==null?0:s.length;if(u){var p=Ol(s,l);if(p<u&&Sn(s[p],l))return p}return-1}function Pw(s,l){return Ol(s,l,!0)}function Aw(s,l,u){return xf(s,l,Be(u,2),!0)}function Dw(s,l){var u=s==null?0:s.length;if(u){var p=Ol(s,l,!0)-1;if(Sn(s[p],l))return p}return-1}function Ew(s){return s&&s.length?Ed(s):[]}function Bw(s,l){return s&&s.length?Ed(s,Be(l,2)):[]}function Gw(s){var l=s==null?0:s.length;return l?nn(s,1,l):[]}function Rw(s,l,u){return s&&s.length?(l=u||l===i?1:We(l),nn(s,0,l<0?0:l)):[]}function zw(s,l,u){var p=s==null?0:s.length;return p?(l=u||l===i?1:We(l),l=p-l,nn(s,l<0?0:l,p)):[]}function Fw(s,l){return s&&s.length?Ml(s,Be(l,3),!1,!0):[]}function Vw(s,l){return s&&s.length?Ml(s,Be(l,3)):[]}var Uw=Xe(function(s){return Ci(or(s,1,Gt,!0))}),jw=Xe(function(s){var l=on(s);return Gt(l)&&(l=i),Ci(or(s,1,Gt,!0),Be(l,2))}),kw=Xe(function(s){var l=on(s);return l=typeof l=="function"?l:i,Ci(or(s,1,Gt,!0),i,l)});function Hw(s){return s&&s.length?Ci(s):[]}function Ww(s,l){return s&&s.length?Ci(s,Be(l,2)):[]}function qw(s,l){return l=typeof l=="function"?l:i,s&&s.length?Ci(s,i,l):[]}function Gf(s){if(!(s&&s.length))return[];var l=0;return s=yi(s,function(u){if(Gt(u))return l=Jt(u.length,l),!0}),Zu(l,function(u){return It(s,Ku(u))})}function bm(s,l){if(!(s&&s.length))return[];var u=Gf(s);return l==null?u:It(u,function(p){return Fr(l,i,p)})}var $w=Xe(function(s,l){return Gt(s)?ea(s,l):[]}),Jw=Xe(function(s){return bf(yi(s,Gt))}),Kw=Xe(function(s){var l=on(s);return Gt(l)&&(l=i),bf(yi(s,Gt),Be(l,2))}),Yw=Xe(function(s){var l=on(s);return l=typeof l=="function"?l:i,bf(yi(s,Gt),i,l)}),Xw=Xe(Gf);function Zw(s,l){return zd(s||[],l||[],Qs)}function Qw(s,l){return zd(s||[],l||[],na)}var eC=Xe(function(s){var l=s.length,u=l>1?s[l-1]:i;return u=typeof u=="function"?(s.pop(),u):i,bm(s,u)});function Sm(s){var l=y(s);return l.__chain__=!0,l}function tC(s,l){return l(s),s}function Fl(s,l){return l(s)}var rC=ei(function(s){var l=s.length,u=l?s[0]:0,p=this.__wrapped__,g=function(v){return af(v,s)};return l>1||this.__actions__.length||!(p instanceof et)||!ti(u)?this.thru(g):(p=p.slice(u,+u+(l?1:0)),p.__actions__.push({func:Fl,args:[g],thisArg:i}),new tn(p,this.__chain__).thru(function(v){return l&&!v.length&&v.push(i),v}))});function nC(){return Sm(this)}function iC(){return new tn(this.value(),this.__chain__)}function oC(){this.__values__===i&&(this.__values__=Bm(this.value()));var s=this.__index__>=this.__values__.length,l=s?i:this.__values__[this.__index__++];return{done:s,value:l}}function sC(){return this}function aC(s){for(var l,u=this;u instanceof Ll;){var p=dm(u);p.__index__=0,p.__values__=i,l?g.__wrapped__=p:l=p;var g=p;u=u.__wrapped__}return g.__wrapped__=s,l}function lC(){var s=this.__wrapped__;if(s instanceof et){var l=s;return this.__actions__.length&&(l=new et(this)),l=l.reverse(),l.__actions__.push({func:Fl,args:[Bf],thisArg:i}),new tn(l,this.__chain__)}return this.thru(Bf)}function cC(){return Rd(this.__wrapped__,this.__actions__)}var uC=Pl(function(s,l,u){ht.call(s,u)?++s[u]:Zn(s,u,1)});function fC(s,l,u){var p=ke(s)?Zp:t1;return u&&vr(s,l,u)&&(l=i),p(s,Be(l,3))}function hC(s,l){var u=ke(s)?yi:bd;return u(s,Be(l,3))}var pC=Jd(mm),dC=Jd(gm);function mC(s,l){return or(Vl(s,l),1)}function gC(s,l){return or(Vl(s,l),ae)}function yC(s,l,u){return u=u===i?1:We(u),or(Vl(s,l),u)}function wm(s,l){var u=ke(s)?Qr:wi;return u(s,Be(l,3))}function Cm(s,l){var u=ke(s)?Gb:vd;return u(s,Be(l,3))}var xC=Pl(function(s,l,u){ht.call(s,u)?s[u].push(l):Zn(s,u,[l])});function vC(s,l,u,p){s=Or(s)?s:Vo(s),u=u&&!p?We(u):0;var g=s.length;return u<0&&(u=Jt(g+u,0)),Wl(s)?u<=g&&s.indexOf(l,u)>-1:!!g&&Oo(s,l,u)>-1}var bC=Xe(function(s,l,u){var p=-1,g=typeof l=="function",v=Or(s)?U(s.length):[];return wi(s,function(C){v[++p]=g?Fr(l,C,u):ta(C,l,u)}),v}),SC=Pl(function(s,l,u){Zn(s,u,l)});function Vl(s,l){var u=ke(s)?It:Nd;return u(s,Be(l,3))}function wC(s,l,u,p){return s==null?[]:(ke(l)||(l=l==null?[]:[l]),u=p?i:u,ke(u)||(u=u==null?[]:[u]),Md(s,l,u))}var CC=Pl(function(s,l,u){s[u?0:1].push(l)},function(){return[[],[]]});function LC(s,l,u){var p=ke(s)?$u:rd,g=arguments.length<3;return p(s,Be(l,4),u,g,wi)}function TC(s,l,u){var p=ke(s)?Rb:rd,g=arguments.length<3;return p(s,Be(l,4),u,g,vd)}function NC(s,l){var u=ke(s)?yi:bd;return u(s,kl(Be(l,3)))}function _C(s){var l=ke(s)?md:v1;return l(s)}function IC(s,l,u){(u?vr(s,l,u):l===i)?l=1:l=We(l);var p=ke(s)?YS:b1;return p(s,l)}function OC(s){var l=ke(s)?XS:w1;return l(s)}function MC(s){if(s==null)return 0;if(Or(s))return Wl(s)?Po(s):s.length;var l=hr(s);return l==ee||l==be?s.size:pf(s).length}function PC(s,l,u){var p=ke(s)?Ju:C1;return u&&vr(s,l,u)&&(l=i),p(s,Be(l,3))}var AC=Xe(function(s,l){if(s==null)return[];var u=l.length;return u>1&&vr(s,l[0],l[1])?l=[]:u>2&&vr(l[0],l[1],l[2])&&(l=[l[0]]),Md(s,or(l,1),[])}),Ul=hS||function(){return Zt.Date.now()};function DC(s,l){if(typeof l!="function")throw new en(n);return s=We(s),function(){if(--s<1)return l.apply(this,arguments)}}function Lm(s,l,u){return l=u?i:l,l=s&&l==null?s.length:l,Qn(s,k,i,i,i,i,l)}function Tm(s,l){var u;if(typeof l!="function")throw new en(n);return s=We(s),function(){return--s>0&&(u=l.apply(this,arguments)),s<=1&&(l=i),u}}var Rf=Xe(function(s,l,u){var p=S;if(u.length){var g=vi(u,zo(Rf));p|=M}return Qn(s,p,l,u,g)}),Nm=Xe(function(s,l,u){var p=S|w;if(u.length){var g=vi(u,zo(Nm));p|=M}return Qn(l,p,s,u,g)});function _m(s,l,u){l=u?i:l;var p=Qn(s,O,i,i,i,i,i,l);return p.placeholder=_m.placeholder,p}function Im(s,l,u){l=u?i:l;var p=Qn(s,T,i,i,i,i,i,l);return p.placeholder=Im.placeholder,p}function Om(s,l,u){var p,g,v,C,L,_,Z=0,Q=!1,oe=!1,ge=!0;if(typeof s!="function")throw new en(n);l=sn(l)||0,Pt(u)&&(Q=!!u.leading,oe="maxWait"in u,v=oe?Jt(sn(u.maxWait)||0,l):v,ge="trailing"in u?!!u.trailing:ge);function Ne(Rt){var wn=p,ii=g;return p=g=i,Z=Rt,C=s.apply(ii,wn),C}function ze(Rt){return Z=Rt,L=sa(Ze,l),Q?Ne(Rt):C}function Je(Rt){var wn=Rt-_,ii=Rt-Z,Jm=l-wn;return oe?fr(Jm,v-ii):Jm}function Ge(Rt){var wn=Rt-_,ii=Rt-Z;return _===i||wn>=l||wn<0||oe&&ii>=v}function Ze(){var Rt=Ul();if(Ge(Rt))return tt(Rt);L=sa(Ze,Je(Rt))}function tt(Rt){return L=i,ge&&p?Ne(Rt):(p=g=i,C)}function kr(){L!==i&&Fd(L),Z=0,p=_=g=L=i}function br(){return L===i?C:tt(Ul())}function Hr(){var Rt=Ul(),wn=Ge(Rt);if(p=arguments,g=this,_=Rt,wn){if(L===i)return ze(_);if(oe)return Fd(L),L=sa(Ze,l),Ne(_)}return L===i&&(L=sa(Ze,l)),C}return Hr.cancel=kr,Hr.flush=br,Hr}var EC=Xe(function(s,l){return xd(s,1,l)}),BC=Xe(function(s,l,u){return xd(s,sn(l)||0,u)});function GC(s){return Qn(s,te)}function jl(s,l){if(typeof s!="function"||l!=null&&typeof l!="function")throw new en(n);var u=function(){var p=arguments,g=l?l.apply(this,p):p[0],v=u.cache;if(v.has(g))return v.get(g);var C=s.apply(this,p);return u.cache=v.set(g,C)||v,C};return u.cache=new(jl.Cache||Xn),u}jl.Cache=Xn;function kl(s){if(typeof s!="function")throw new en(n);return function(){var l=arguments;switch(l.length){case 0:return!s.call(this);case 1:return!s.call(this,l[0]);case 2:return!s.call(this,l[0],l[1]);case 3:return!s.call(this,l[0],l[1],l[2])}return!s.apply(this,l)}}function RC(s){return Tm(2,s)}var zC=L1(function(s,l){l=l.length==1&&ke(l[0])?It(l[0],Vr(Be())):It(or(l,1),Vr(Be()));var u=l.length;return Xe(function(p){for(var g=-1,v=fr(p.length,u);++g<v;)p[g]=l[g].call(this,p[g]);return Fr(s,this,p)})}),zf=Xe(function(s,l){var u=vi(l,zo(zf));return Qn(s,M,i,l,u)}),Mm=Xe(function(s,l){var u=vi(l,zo(Mm));return Qn(s,F,i,l,u)}),FC=ei(function(s,l){return Qn(s,N,i,i,i,l)});function VC(s,l){if(typeof s!="function")throw new en(n);return l=l===i?l:We(l),Xe(s,l)}function UC(s,l){if(typeof s!="function")throw new en(n);return l=l==null?0:Jt(We(l),0),Xe(function(u){var p=u[l],g=Ti(u,0,l);return p&&xi(g,p),Fr(s,this,g)})}function jC(s,l,u){var p=!0,g=!0;if(typeof s!="function")throw new en(n);return Pt(u)&&(p="leading"in u?!!u.leading:p,g="trailing"in u?!!u.trailing:g),Om(s,l,{leading:p,maxWait:l,trailing:g})}function kC(s){return Lm(s,1)}function HC(s,l){return zf(wf(l),s)}function WC(){if(!arguments.length)return[];var s=arguments[0];return ke(s)?s:[s]}function qC(s){return rn(s,d)}function $C(s,l){return l=typeof l=="function"?l:i,rn(s,d,l)}function JC(s){return rn(s,f|d)}function KC(s,l){return l=typeof l=="function"?l:i,rn(s,f|d,l)}function YC(s,l){return l==null||yd(s,l,Qt(l))}function Sn(s,l){return s===l||s!==s&&l!==l}var XC=Bl(uf),ZC=Bl(function(s,l){return s>=l}),so=Cd(function(){return arguments}())?Cd:function(s){return Dt(s)&&ht.call(s,"callee")&&!cd.call(s,"callee")},ke=U.isArray,QC=qp?Vr(qp):a1;function Or(s){return s!=null&&Hl(s.length)&&!ri(s)}function Gt(s){return Dt(s)&&Or(s)}function eL(s){return s===!0||s===!1||Dt(s)&&xr(s)==K}var Ni=dS||Kf,tL=$p?Vr($p):l1;function rL(s){return Dt(s)&&s.nodeType===1&&!aa(s)}function nL(s){if(s==null)return!0;if(Or(s)&&(ke(s)||typeof s=="string"||typeof s.splice=="function"||Ni(s)||Fo(s)||so(s)))return!s.length;var l=hr(s);if(l==ee||l==be)return!s.size;if(oa(s))return!pf(s).length;for(var u in s)if(ht.call(s,u))return!1;return!0}function iL(s,l){return ra(s,l)}function oL(s,l,u){u=typeof u=="function"?u:i;var p=u?u(s,l):i;return p===i?ra(s,l,i,u):!!p}function Ff(s){if(!Dt(s))return!1;var l=xr(s);return l==ie||l==me||typeof s.message=="string"&&typeof s.name=="string"&&!aa(s)}function sL(s){return typeof s=="number"&&fd(s)}function ri(s){if(!Pt(s))return!1;var l=xr(s);return l==re||l==q||l==H||l==pe}function Pm(s){return typeof s=="number"&&s==We(s)}function Hl(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=ne}function Pt(s){var l=typeof s;return s!=null&&(l=="object"||l=="function")}function Dt(s){return s!=null&&typeof s=="object"}var Am=Jp?Vr(Jp):u1;function aL(s,l){return s===l||hf(s,l,Of(l))}function lL(s,l,u){return u=typeof u=="function"?u:i,hf(s,l,Of(l),u)}function cL(s){return Dm(s)&&s!=+s}function uL(s){if($1(s))throw new je(r);return Ld(s)}function fL(s){return s===null}function hL(s){return s==null}function Dm(s){return typeof s=="number"||Dt(s)&&xr(s)==Te}function aa(s){if(!Dt(s)||xr(s)!=le)return!1;var l=yl(s);if(l===null)return!0;var u=ht.call(l,"constructor")&&l.constructor;return typeof u=="function"&&u instanceof u&&pl.call(u)==lS}var Vf=Kp?Vr(Kp):f1;function pL(s){return Pm(s)&&s>=-ne&&s<=ne}var Em=Yp?Vr(Yp):h1;function Wl(s){return typeof s=="string"||!ke(s)&&Dt(s)&&xr(s)==Se}function jr(s){return typeof s=="symbol"||Dt(s)&&xr(s)==Ie}var Fo=Xp?Vr(Xp):p1;function dL(s){return s===i}function mL(s){return Dt(s)&&hr(s)==Ve}function gL(s){return Dt(s)&&xr(s)==Lt}var yL=Bl(df),xL=Bl(function(s,l){return s<=l});function Bm(s){if(!s)return[];if(Or(s))return Wl(s)?vn(s):Ir(s);if(Js&&s[Js])return Yb(s[Js]());var l=hr(s),u=l==ee?ef:l==be?ul:Vo;return u(s)}function ni(s){if(!s)return s===0?s:0;if(s=sn(s),s===ae||s===-ae){var l=s<0?-1:1;return l*xe}return s===s?s:0}function We(s){var l=ni(s),u=l%1;return l===l?u?l-u:l:0}function Gm(s){return s?ro(We(s),0,Le):0}function sn(s){if(typeof s=="number")return s;if(jr(s))return _e;if(Pt(s)){var l=typeof s.valueOf=="function"?s.valueOf():s;s=Pt(l)?l+"":l}if(typeof s!="string")return s===0?s:+s;s=s.replace(Qe,"");var u=il.test(s);return u||tb.test(s)?Db(s.slice(2),u?2:8):Pn.test(s)?_e:+s}function Rm(s){return Dn(s,Mr(s))}function vL(s){return s?ro(We(s),-ne,ne):s===0?s:0}function lt(s){return s==null?"":Ur(s)}var bL=Go(function(s,l){if(oa(l)||Or(l)){Dn(l,Qt(l),s);return}for(var u in l)ht.call(l,u)&&Qs(s,u,l[u])}),zm=Go(function(s,l){Dn(l,Mr(l),s)}),ql=Go(function(s,l,u,p){Dn(l,Mr(l),s,p)}),SL=Go(function(s,l,u,p){Dn(l,Qt(l),s,p)}),wL=ei(af);function CL(s,l){var u=Bo(s);return l==null?u:gd(u,l)}var LL=Xe(function(s,l){s=xt(s);var u=-1,p=l.length,g=p>2?l[2]:i;for(g&&vr(l[0],l[1],g)&&(p=1);++u<p;)for(var v=l[u],C=Mr(v),L=-1,_=C.length;++L<_;){var Z=C[L],Q=s[Z];(Q===i||Sn(Q,Ao[Z])&&!ht.call(s,Z))&&(s[Z]=v[Z])}return s}),TL=Xe(function(s){return s.push(i,tm),Fr(Fm,i,s)});function NL(s,l){return Qp(s,Be(l,3),An)}function _L(s,l){return Qp(s,Be(l,3),cf)}function IL(s,l){return s==null?s:lf(s,Be(l,3),Mr)}function OL(s,l){return s==null?s:Sd(s,Be(l,3),Mr)}function ML(s,l){return s&&An(s,Be(l,3))}function PL(s,l){return s&&cf(s,Be(l,3))}function AL(s){return s==null?[]:_l(s,Qt(s))}function DL(s){return s==null?[]:_l(s,Mr(s))}function Uf(s,l,u){var p=s==null?i:no(s,l);return p===i?u:p}function EL(s,l){return s!=null&&im(s,l,n1)}function jf(s,l){return s!=null&&im(s,l,i1)}var BL=Yd(function(s,l,u){l!=null&&typeof l.toString!="function"&&(l=dl.call(l)),s[l]=u},Hf(Pr)),GL=Yd(function(s,l,u){l!=null&&typeof l.toString!="function"&&(l=dl.call(l)),ht.call(s,l)?s[l].push(u):s[l]=[u]},Be),RL=Xe(ta);function Qt(s){return Or(s)?dd(s):pf(s)}function Mr(s){return Or(s)?dd(s,!0):d1(s)}function zL(s,l){var u={};return l=Be(l,3),An(s,function(p,g,v){Zn(u,l(p,g,v),p)}),u}function FL(s,l){var u={};return l=Be(l,3),An(s,function(p,g,v){Zn(u,g,l(p,g,v))}),u}var VL=Go(function(s,l,u){Il(s,l,u)}),Fm=Go(function(s,l,u,p){Il(s,l,u,p)}),UL=ei(function(s,l){var u={};if(s==null)return u;var p=!1;l=It(l,function(v){return v=Li(v,s),p||(p=v.length>1),v}),Dn(s,_f(s),u),p&&(u=rn(u,f|h|d,B1));for(var g=l.length;g--;)vf(u,l[g]);return u});function jL(s,l){return Vm(s,kl(Be(l)))}var kL=ei(function(s,l){return s==null?{}:g1(s,l)});function Vm(s,l){if(s==null)return{};var u=It(_f(s),function(p){return[p]});return l=Be(l),Pd(s,u,function(p,g){return l(p,g[0])})}function HL(s,l,u){l=Li(l,s);var p=-1,g=l.length;for(g||(g=1,s=i);++p<g;){var v=s==null?i:s[En(l[p])];v===i&&(p=g,v=u),s=ri(v)?v.call(s):v}return s}function WL(s,l,u){return s==null?s:na(s,l,u)}function qL(s,l,u,p){return p=typeof p=="function"?p:i,s==null?s:na(s,l,u,p)}var Um=Qd(Qt),jm=Qd(Mr);function $L(s,l,u){var p=ke(s),g=p||Ni(s)||Fo(s);if(l=Be(l,4),u==null){var v=s&&s.constructor;g?u=p?new v:[]:Pt(s)?u=ri(v)?Bo(yl(s)):{}:u={}}return(g?Qr:An)(s,function(C,L,_){return l(u,C,L,_)}),u}function JL(s,l){return s==null?!0:vf(s,l)}function KL(s,l,u){return s==null?s:Gd(s,l,wf(u))}function YL(s,l,u,p){return p=typeof p=="function"?p:i,s==null?s:Gd(s,l,wf(u),p)}function Vo(s){return s==null?[]:Qu(s,Qt(s))}function XL(s){return s==null?[]:Qu(s,Mr(s))}function ZL(s,l,u){return u===i&&(u=l,l=i),u!==i&&(u=sn(u),u=u===u?u:0),l!==i&&(l=sn(l),l=l===l?l:0),ro(sn(s),l,u)}function QL(s,l,u){return l=ni(l),u===i?(u=l,l=0):u=ni(u),s=sn(s),o1(s,l,u)}function eT(s,l,u){if(u&&typeof u!="boolean"&&vr(s,l,u)&&(l=u=i),u===i&&(typeof l=="boolean"?(u=l,l=i):typeof s=="boolean"&&(u=s,s=i)),s===i&&l===i?(s=0,l=1):(s=ni(s),l===i?(l=s,s=0):l=ni(l)),s>l){var p=s;s=l,l=p}if(u||s%1||l%1){var g=hd();return fr(s+g*(l-s+Ab("1e-"+((g+"").length-1))),l)}return gf(s,l)}var tT=Ro(function(s,l,u){return l=l.toLowerCase(),s+(u?km(l):l)});function km(s){return kf(lt(s).toLowerCase())}function Hm(s){return s=lt(s),s&&s.replace(nb,Wb).replace(wb,"")}function rT(s,l,u){s=lt(s),l=Ur(l);var p=s.length;u=u===i?p:ro(We(u),0,p);var g=u;return u-=l.length,u>=0&&s.slice(u,g)==l}function nT(s){return s=lt(s),s&&Nr.test(s)?s.replace(Yi,qb):s}function iT(s){return s=lt(s),s&&$e.test(s)?s.replace(He,"\\$&"):s}var oT=Ro(function(s,l,u){return s+(u?"-":"")+l.toLowerCase()}),sT=Ro(function(s,l,u){return s+(u?" ":"")+l.toLowerCase()}),aT=$d("toLowerCase");function lT(s,l,u){s=lt(s),l=We(l);var p=l?Po(s):0;if(!l||p>=l)return s;var g=(l-p)/2;return El(Sl(g),u)+s+El(bl(g),u)}function cT(s,l,u){s=lt(s),l=We(l);var p=l?Po(s):0;return l&&p<l?s+El(l-p,u):s}function uT(s,l,u){s=lt(s),l=We(l);var p=l?Po(s):0;return l&&p<l?El(l-p,u)+s:s}function fT(s,l,u){return u||l==null?l=0:l&&(l=+l),xS(lt(s).replace(ot,""),l||0)}function hT(s,l,u){return(u?vr(s,l,u):l===i)?l=1:l=We(l),yf(lt(s),l)}function pT(){var s=arguments,l=lt(s[0]);return s.length<3?l:l.replace(s[1],s[2])}var dT=Ro(function(s,l,u){return s+(u?"_":"")+l.toLowerCase()});function mT(s,l,u){return u&&typeof u!="number"&&vr(s,l,u)&&(l=u=i),u=u===i?Le:u>>>0,u?(s=lt(s),s&&(typeof l=="string"||l!=null&&!Vf(l))&&(l=Ur(l),!l&&Mo(s))?Ti(vn(s),0,u):s.split(l,u)):[]}var gT=Ro(function(s,l,u){return s+(u?" ":"")+kf(l)});function yT(s,l,u){return s=lt(s),u=u==null?0:ro(We(u),0,s.length),l=Ur(l),s.slice(u,u+l.length)==l}function xT(s,l,u){var p=y.templateSettings;u&&vr(s,l,u)&&(l=i),s=lt(s),l=ql({},l,p,em);var g=ql({},l.imports,p.imports,em),v=Qt(g),C=Qu(g,v),L,_,Z=0,Q=l.interpolate||ol,oe="__p += '",ge=tf((l.escape||ol).source+"|"+Q.source+"|"+(Q===Kn?yn:ol).source+"|"+(l.evaluate||ol).source+"|$","g"),Ne="//# sourceURL="+(ht.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++_b+"]")+`
4
- `;s.replace(ge,function(Ge,Ze,tt,kr,br,Hr){return tt||(tt=kr),oe+=s.slice(Z,Hr).replace(ib,$b),Ze&&(L=!0,oe+=`' +
3
+ `)}function J1(s){return ke(s)||so(s)||!!(ud&&s&&s[ud])}function ti(s,l){var u=typeof s;return l=l==null?ne:l,!!l&&(u=="number"||u!="symbol"&&sb.test(s))&&s>-1&&s%1==0&&s<l}function vr(s,l,u){if(!Pt(u))return!1;var p=typeof l;return(p=="number"?Or(u)&&ti(l,u.length):p=="string"&&l in u)?Sn(u[l],s):!1}function Pf(s,l){if(ke(s))return!1;var u=typeof s;return u=="number"||u=="symbol"||u=="boolean"||s==null||jr(s)?!0:Re.test(s)||!Io.test(s)||l!=null&&s in xt(l)}function K1(s){var l=typeof s;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?s!=="__proto__":s===null}function Af(s){var l=Gl(s),u=y[l];if(typeof u!="function"||!(l in et.prototype))return!1;if(s===u)return!0;var p=If(u);return!!p&&s===p[0]}function Y1(s){return!!sd&&sd in s}var X1=hl?ri:Kf;function sa(s){var l=s&&s.constructor,u=typeof l=="function"&&l.prototype||Do;return s===u}function sm(s){return s===s&&!Pt(s)}function am(s,l){return function(u){return u==null?!1:u[s]===l&&(l!==i||s in xt(u))}}function Z1(s){var l=jl(s,function(p){return u.size===a&&u.clear(),p}),u=l.cache;return l}function Q1(s,l){var u=s[1],p=l[1],g=u|p,v=g<(S|w|k),C=p==k&&u==O||p==k&&u==N&&s[7].length<=l[8]||p==(k|N)&&l[7].length<=l[8]&&u==O;if(!(v||C))return s;p&S&&(s[2]=l[2],g|=u&S?0:B);var L=l[3];if(L){var _=s[3];s[3]=_?kd(_,L,l[4]):L,s[4]=_?vi(s[3],c):l[4]}return L=l[5],L&&(_=s[5],s[5]=_?Hd(_,L,l[6]):L,s[6]=_?vi(s[5],c):l[6]),L=l[7],L&&(s[7]=L),p&k&&(s[8]=s[8]==null?l[8]:fr(s[8],l[8])),s[9]==null&&(s[9]=l[9]),s[0]=l[0],s[1]=g,s}function ew(s){var l=[];if(s!=null)for(var u in xt(s))l.push(u);return l}function tw(s){return dl.call(s)}function lm(s,l,u){return l=Jt(l===i?s.length-1:l,0),function(){for(var p=arguments,g=-1,v=Jt(p.length-l,0),C=U(v);++g<v;)C[g]=p[l+g];g=-1;for(var L=U(l+1);++g<l;)L[g]=p[g];return L[l]=u(C),Fr(s,this,L)}}function cm(s,l){return l.length<2?s:no(s,nn(l,0,-1))}function rw(s,l){for(var u=s.length,p=fr(l.length,u),g=Ir(s);p--;){var v=l[p];s[p]=ti(v,u)?g[v]:i}return s}function Df(s,l){if(!(l==="constructor"&&typeof s[l]=="function")&&l!="__proto__")return s[l]}var um=hm(Dd),aa=yS||function(s,l){return Zt.setTimeout(s,l)},Ef=hm(T1);function fm(s,l,u){var p=l+"";return Ef(s,$1(p,nw(H1(p),u)))}function hm(s){var l=0,u=0;return function(){var p=SS(),g=P-(p-u);if(u=p,g>0){if(++l>=V)return arguments[0]}else l=0;return s.apply(i,arguments)}}function zl(s,l){var u=-1,p=s.length,g=p-1;for(l=l===i?p:l;++u<l;){var v=gf(u,g),C=s[v];s[v]=s[u],s[u]=C}return s.length=l,s}var pm=Z1(function(s){var l=[];return s.charCodeAt(0)===46&&l.push(""),s.replace(Ye,function(u,p,g,v){l.push(g?v.replace(_r,"$1"):p||u)}),l});function En(s){if(typeof s=="string"||jr(s))return s;var l=s+"";return l=="0"&&1/s==-ae?"-0":l}function oo(s){if(s!=null){try{return pl.call(s)}catch{}try{return s+""}catch{}}return""}function nw(s,l){return Qr($,function(u){var p="_."+u[0];l&u[1]&&!ll(s,p)&&s.push(p)}),s.sort()}function dm(s){if(s instanceof et)return s.clone();var l=new tn(s.__wrapped__,s.__chain__);return l.__actions__=Ir(s.__actions__),l.__index__=s.__index__,l.__values__=s.__values__,l}function iw(s,l,u){(u?vr(s,l,u):l===i)?l=1:l=Jt(We(l),0);var p=s==null?0:s.length;if(!p||l<1)return[];for(var g=0,v=0,C=U(bl(p/l));g<p;)C[v++]=nn(s,g,g+=l);return C}function ow(s){for(var l=-1,u=s==null?0:s.length,p=0,g=[];++l<u;){var v=s[l];v&&(g[p++]=v)}return g}function sw(){var s=arguments.length;if(!s)return[];for(var l=U(s-1),u=arguments[0],p=s;p--;)l[p-1]=arguments[p];return xi(ke(u)?Ir(u):[u],or(l,1))}var aw=Xe(function(s,l){return Gt(s)?ta(s,or(l,1,Gt,!0)):[]}),lw=Xe(function(s,l){var u=on(l);return Gt(u)&&(u=i),Gt(s)?ta(s,or(l,1,Gt,!0),Be(u,2)):[]}),cw=Xe(function(s,l){var u=on(l);return Gt(u)&&(u=i),Gt(s)?ta(s,or(l,1,Gt,!0),i,u):[]});function uw(s,l,u){var p=s==null?0:s.length;return p?(l=u||l===i?1:We(l),nn(s,l<0?0:l,p)):[]}function fw(s,l,u){var p=s==null?0:s.length;return p?(l=u||l===i?1:We(l),l=p-l,nn(s,0,l<0?0:l)):[]}function hw(s,l){return s&&s.length?Ml(s,Be(l,3),!0,!0):[]}function pw(s,l){return s&&s.length?Ml(s,Be(l,3),!0):[]}function dw(s,l,u,p){var g=s==null?0:s.length;return g?(u&&typeof u!="number"&&vr(s,l,u)&&(u=0,p=g),s1(s,l,u,p)):[]}function mm(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=u==null?0:We(u);return g<0&&(g=Jt(p+g,0)),cl(s,Be(l,3),g)}function gm(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=p-1;return u!==i&&(g=We(u),g=u<0?Jt(p+g,0):fr(g,p-1)),cl(s,Be(l,3),g,!0)}function ym(s){var l=s==null?0:s.length;return l?or(s,1):[]}function mw(s){var l=s==null?0:s.length;return l?or(s,ae):[]}function gw(s,l){var u=s==null?0:s.length;return u?(l=l===i?1:We(l),or(s,l)):[]}function yw(s){for(var l=-1,u=s==null?0:s.length,p={};++l<u;){var g=s[l];p[g[0]]=g[1]}return p}function xm(s){return s&&s.length?s[0]:i}function xw(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=u==null?0:We(u);return g<0&&(g=Jt(p+g,0)),Mo(s,l,g)}function vw(s){var l=s==null?0:s.length;return l?nn(s,0,-1):[]}var bw=Xe(function(s){var l=It(s,Sf);return l.length&&l[0]===s[0]?ff(l):[]}),Sw=Xe(function(s){var l=on(s),u=It(s,Sf);return l===on(u)?l=i:u.pop(),u.length&&u[0]===s[0]?ff(u,Be(l,2)):[]}),ww=Xe(function(s){var l=on(s),u=It(s,Sf);return l=typeof l=="function"?l:i,l&&u.pop(),u.length&&u[0]===s[0]?ff(u,i,l):[]});function Cw(s,l){return s==null?"":vS.call(s,l)}function on(s){var l=s==null?0:s.length;return l?s[l-1]:i}function Lw(s,l,u){var p=s==null?0:s.length;if(!p)return-1;var g=p;return u!==i&&(g=We(u),g=g<0?Jt(p+g,0):fr(g,p-1)),l===l?nS(s,l,g):cl(s,ed,g,!0)}function Tw(s,l){return s&&s.length?Od(s,We(l)):i}var Nw=Xe(vm);function vm(s,l){return s&&s.length&&l&&l.length?mf(s,l):s}function _w(s,l,u){return s&&s.length&&l&&l.length?mf(s,l,Be(u,2)):s}function Iw(s,l,u){return s&&s.length&&l&&l.length?mf(s,l,i,u):s}var Ow=ei(function(s,l){var u=s==null?0:s.length,p=af(s,l);return Ad(s,It(l,function(g){return ti(g,u)?+g:g}).sort(jd)),p});function Mw(s,l){var u=[];if(!(s&&s.length))return u;var p=-1,g=[],v=s.length;for(l=Be(l,3);++p<v;){var C=s[p];l(C,p,s)&&(u.push(C),g.push(p))}return Ad(s,g),u}function Bf(s){return s==null?s:CS.call(s)}function Pw(s,l,u){var p=s==null?0:s.length;return p?(u&&typeof u!="number"&&vr(s,l,u)?(l=0,u=p):(l=l==null?0:We(l),u=u===i?p:We(u)),nn(s,l,u)):[]}function Aw(s,l){return Ol(s,l)}function Dw(s,l,u){return xf(s,l,Be(u,2))}function Ew(s,l){var u=s==null?0:s.length;if(u){var p=Ol(s,l);if(p<u&&Sn(s[p],l))return p}return-1}function Bw(s,l){return Ol(s,l,!0)}function Gw(s,l,u){return xf(s,l,Be(u,2),!0)}function Rw(s,l){var u=s==null?0:s.length;if(u){var p=Ol(s,l,!0)-1;if(Sn(s[p],l))return p}return-1}function zw(s){return s&&s.length?Ed(s):[]}function Fw(s,l){return s&&s.length?Ed(s,Be(l,2)):[]}function Vw(s){var l=s==null?0:s.length;return l?nn(s,1,l):[]}function Uw(s,l,u){return s&&s.length?(l=u||l===i?1:We(l),nn(s,0,l<0?0:l)):[]}function jw(s,l,u){var p=s==null?0:s.length;return p?(l=u||l===i?1:We(l),l=p-l,nn(s,l<0?0:l,p)):[]}function kw(s,l){return s&&s.length?Ml(s,Be(l,3),!1,!0):[]}function Hw(s,l){return s&&s.length?Ml(s,Be(l,3)):[]}var Ww=Xe(function(s){return Ci(or(s,1,Gt,!0))}),qw=Xe(function(s){var l=on(s);return Gt(l)&&(l=i),Ci(or(s,1,Gt,!0),Be(l,2))}),$w=Xe(function(s){var l=on(s);return l=typeof l=="function"?l:i,Ci(or(s,1,Gt,!0),i,l)});function Jw(s){return s&&s.length?Ci(s):[]}function Kw(s,l){return s&&s.length?Ci(s,Be(l,2)):[]}function Yw(s,l){return l=typeof l=="function"?l:i,s&&s.length?Ci(s,i,l):[]}function Gf(s){if(!(s&&s.length))return[];var l=0;return s=yi(s,function(u){if(Gt(u))return l=Jt(u.length,l),!0}),Zu(l,function(u){return It(s,Ku(u))})}function bm(s,l){if(!(s&&s.length))return[];var u=Gf(s);return l==null?u:It(u,function(p){return Fr(l,i,p)})}var Xw=Xe(function(s,l){return Gt(s)?ta(s,l):[]}),Zw=Xe(function(s){return bf(yi(s,Gt))}),Qw=Xe(function(s){var l=on(s);return Gt(l)&&(l=i),bf(yi(s,Gt),Be(l,2))}),eC=Xe(function(s){var l=on(s);return l=typeof l=="function"?l:i,bf(yi(s,Gt),i,l)}),tC=Xe(Gf);function rC(s,l){return zd(s||[],l||[],ea)}function nC(s,l){return zd(s||[],l||[],ia)}var iC=Xe(function(s){var l=s.length,u=l>1?s[l-1]:i;return u=typeof u=="function"?(s.pop(),u):i,bm(s,u)});function Sm(s){var l=y(s);return l.__chain__=!0,l}function oC(s,l){return l(s),s}function Fl(s,l){return l(s)}var sC=ei(function(s){var l=s.length,u=l?s[0]:0,p=this.__wrapped__,g=function(v){return af(v,s)};return l>1||this.__actions__.length||!(p instanceof et)||!ti(u)?this.thru(g):(p=p.slice(u,+u+(l?1:0)),p.__actions__.push({func:Fl,args:[g],thisArg:i}),new tn(p,this.__chain__).thru(function(v){return l&&!v.length&&v.push(i),v}))});function aC(){return Sm(this)}function lC(){return new tn(this.value(),this.__chain__)}function cC(){this.__values__===i&&(this.__values__=Bm(this.value()));var s=this.__index__>=this.__values__.length,l=s?i:this.__values__[this.__index__++];return{done:s,value:l}}function uC(){return this}function fC(s){for(var l,u=this;u instanceof Ll;){var p=dm(u);p.__index__=0,p.__values__=i,l?g.__wrapped__=p:l=p;var g=p;u=u.__wrapped__}return g.__wrapped__=s,l}function hC(){var s=this.__wrapped__;if(s instanceof et){var l=s;return this.__actions__.length&&(l=new et(this)),l=l.reverse(),l.__actions__.push({func:Fl,args:[Bf],thisArg:i}),new tn(l,this.__chain__)}return this.thru(Bf)}function pC(){return Rd(this.__wrapped__,this.__actions__)}var dC=Pl(function(s,l,u){ht.call(s,u)?++s[u]:Zn(s,u,1)});function mC(s,l,u){var p=ke(s)?Zp:o1;return u&&vr(s,l,u)&&(l=i),p(s,Be(l,3))}function gC(s,l){var u=ke(s)?yi:bd;return u(s,Be(l,3))}var yC=Jd(mm),xC=Jd(gm);function vC(s,l){return or(Vl(s,l),1)}function bC(s,l){return or(Vl(s,l),ae)}function SC(s,l,u){return u=u===i?1:We(u),or(Vl(s,l),u)}function wm(s,l){var u=ke(s)?Qr:wi;return u(s,Be(l,3))}function Cm(s,l){var u=ke(s)?Vb:vd;return u(s,Be(l,3))}var wC=Pl(function(s,l,u){ht.call(s,u)?s[u].push(l):Zn(s,u,[l])});function CC(s,l,u,p){s=Or(s)?s:Uo(s),u=u&&!p?We(u):0;var g=s.length;return u<0&&(u=Jt(g+u,0)),Wl(s)?u<=g&&s.indexOf(l,u)>-1:!!g&&Mo(s,l,u)>-1}var LC=Xe(function(s,l,u){var p=-1,g=typeof l=="function",v=Or(s)?U(s.length):[];return wi(s,function(C){v[++p]=g?Fr(l,C,u):ra(C,l,u)}),v}),TC=Pl(function(s,l,u){Zn(s,u,l)});function Vl(s,l){var u=ke(s)?It:Nd;return u(s,Be(l,3))}function NC(s,l,u,p){return s==null?[]:(ke(l)||(l=l==null?[]:[l]),u=p?i:u,ke(u)||(u=u==null?[]:[u]),Md(s,l,u))}var _C=Pl(function(s,l,u){s[u?0:1].push(l)},function(){return[[],[]]});function IC(s,l,u){var p=ke(s)?$u:rd,g=arguments.length<3;return p(s,Be(l,4),u,g,wi)}function OC(s,l,u){var p=ke(s)?Ub:rd,g=arguments.length<3;return p(s,Be(l,4),u,g,vd)}function MC(s,l){var u=ke(s)?yi:bd;return u(s,kl(Be(l,3)))}function PC(s){var l=ke(s)?md:C1;return l(s)}function AC(s,l,u){(u?vr(s,l,u):l===i)?l=1:l=We(l);var p=ke(s)?e1:L1;return p(s,l)}function DC(s){var l=ke(s)?t1:N1;return l(s)}function EC(s){if(s==null)return 0;if(Or(s))return Wl(s)?Ao(s):s.length;var l=hr(s);return l==ee||l==be?s.size:pf(s).length}function BC(s,l,u){var p=ke(s)?Ju:_1;return u&&vr(s,l,u)&&(l=i),p(s,Be(l,3))}var GC=Xe(function(s,l){if(s==null)return[];var u=l.length;return u>1&&vr(s,l[0],l[1])?l=[]:u>2&&vr(l[0],l[1],l[2])&&(l=[l[0]]),Md(s,or(l,1),[])}),Ul=gS||function(){return Zt.Date.now()};function RC(s,l){if(typeof l!="function")throw new en(n);return s=We(s),function(){if(--s<1)return l.apply(this,arguments)}}function Lm(s,l,u){return l=u?i:l,l=s&&l==null?s.length:l,Qn(s,k,i,i,i,i,l)}function Tm(s,l){var u;if(typeof l!="function")throw new en(n);return s=We(s),function(){return--s>0&&(u=l.apply(this,arguments)),s<=1&&(l=i),u}}var Rf=Xe(function(s,l,u){var p=S;if(u.length){var g=vi(u,Fo(Rf));p|=M}return Qn(s,p,l,u,g)}),Nm=Xe(function(s,l,u){var p=S|w;if(u.length){var g=vi(u,Fo(Nm));p|=M}return Qn(l,p,s,u,g)});function _m(s,l,u){l=u?i:l;var p=Qn(s,O,i,i,i,i,i,l);return p.placeholder=_m.placeholder,p}function Im(s,l,u){l=u?i:l;var p=Qn(s,T,i,i,i,i,i,l);return p.placeholder=Im.placeholder,p}function Om(s,l,u){var p,g,v,C,L,_,Z=0,Q=!1,oe=!1,ge=!0;if(typeof s!="function")throw new en(n);l=sn(l)||0,Pt(u)&&(Q=!!u.leading,oe="maxWait"in u,v=oe?Jt(sn(u.maxWait)||0,l):v,ge="trailing"in u?!!u.trailing:ge);function Ne(Rt){var wn=p,ii=g;return p=g=i,Z=Rt,C=s.apply(ii,wn),C}function ze(Rt){return Z=Rt,L=aa(Ze,l),Q?Ne(Rt):C}function Je(Rt){var wn=Rt-_,ii=Rt-Z,Jm=l-wn;return oe?fr(Jm,v-ii):Jm}function Ge(Rt){var wn=Rt-_,ii=Rt-Z;return _===i||wn>=l||wn<0||oe&&ii>=v}function Ze(){var Rt=Ul();if(Ge(Rt))return tt(Rt);L=aa(Ze,Je(Rt))}function tt(Rt){return L=i,ge&&p?Ne(Rt):(p=g=i,C)}function kr(){L!==i&&Fd(L),Z=0,p=_=g=L=i}function br(){return L===i?C:tt(Ul())}function Hr(){var Rt=Ul(),wn=Ge(Rt);if(p=arguments,g=this,_=Rt,wn){if(L===i)return ze(_);if(oe)return Fd(L),L=aa(Ze,l),Ne(_)}return L===i&&(L=aa(Ze,l)),C}return Hr.cancel=kr,Hr.flush=br,Hr}var zC=Xe(function(s,l){return xd(s,1,l)}),FC=Xe(function(s,l,u){return xd(s,sn(l)||0,u)});function VC(s){return Qn(s,te)}function jl(s,l){if(typeof s!="function"||l!=null&&typeof l!="function")throw new en(n);var u=function(){var p=arguments,g=l?l.apply(this,p):p[0],v=u.cache;if(v.has(g))return v.get(g);var C=s.apply(this,p);return u.cache=v.set(g,C)||v,C};return u.cache=new(jl.Cache||Xn),u}jl.Cache=Xn;function kl(s){if(typeof s!="function")throw new en(n);return function(){var l=arguments;switch(l.length){case 0:return!s.call(this);case 1:return!s.call(this,l[0]);case 2:return!s.call(this,l[0],l[1]);case 3:return!s.call(this,l[0],l[1],l[2])}return!s.apply(this,l)}}function UC(s){return Tm(2,s)}var jC=I1(function(s,l){l=l.length==1&&ke(l[0])?It(l[0],Vr(Be())):It(or(l,1),Vr(Be()));var u=l.length;return Xe(function(p){for(var g=-1,v=fr(p.length,u);++g<v;)p[g]=l[g].call(this,p[g]);return Fr(s,this,p)})}),zf=Xe(function(s,l){var u=vi(l,Fo(zf));return Qn(s,M,i,l,u)}),Mm=Xe(function(s,l){var u=vi(l,Fo(Mm));return Qn(s,F,i,l,u)}),kC=ei(function(s,l){return Qn(s,N,i,i,i,l)});function HC(s,l){if(typeof s!="function")throw new en(n);return l=l===i?l:We(l),Xe(s,l)}function WC(s,l){if(typeof s!="function")throw new en(n);return l=l==null?0:Jt(We(l),0),Xe(function(u){var p=u[l],g=Ti(u,0,l);return p&&xi(g,p),Fr(s,this,g)})}function qC(s,l,u){var p=!0,g=!0;if(typeof s!="function")throw new en(n);return Pt(u)&&(p="leading"in u?!!u.leading:p,g="trailing"in u?!!u.trailing:g),Om(s,l,{leading:p,maxWait:l,trailing:g})}function $C(s){return Lm(s,1)}function JC(s,l){return zf(wf(l),s)}function KC(){if(!arguments.length)return[];var s=arguments[0];return ke(s)?s:[s]}function YC(s){return rn(s,d)}function XC(s,l){return l=typeof l=="function"?l:i,rn(s,d,l)}function ZC(s){return rn(s,f|d)}function QC(s,l){return l=typeof l=="function"?l:i,rn(s,f|d,l)}function eL(s,l){return l==null||yd(s,l,Qt(l))}function Sn(s,l){return s===l||s!==s&&l!==l}var tL=Bl(uf),rL=Bl(function(s,l){return s>=l}),so=Cd(function(){return arguments}())?Cd:function(s){return Dt(s)&&ht.call(s,"callee")&&!cd.call(s,"callee")},ke=U.isArray,nL=qp?Vr(qp):f1;function Or(s){return s!=null&&Hl(s.length)&&!ri(s)}function Gt(s){return Dt(s)&&Or(s)}function iL(s){return s===!0||s===!1||Dt(s)&&xr(s)==K}var Ni=xS||Kf,oL=$p?Vr($p):h1;function sL(s){return Dt(s)&&s.nodeType===1&&!la(s)}function aL(s){if(s==null)return!0;if(Or(s)&&(ke(s)||typeof s=="string"||typeof s.splice=="function"||Ni(s)||Vo(s)||so(s)))return!s.length;var l=hr(s);if(l==ee||l==be)return!s.size;if(sa(s))return!pf(s).length;for(var u in s)if(ht.call(s,u))return!1;return!0}function lL(s,l){return na(s,l)}function cL(s,l,u){u=typeof u=="function"?u:i;var p=u?u(s,l):i;return p===i?na(s,l,i,u):!!p}function Ff(s){if(!Dt(s))return!1;var l=xr(s);return l==ie||l==me||typeof s.message=="string"&&typeof s.name=="string"&&!la(s)}function uL(s){return typeof s=="number"&&fd(s)}function ri(s){if(!Pt(s))return!1;var l=xr(s);return l==re||l==q||l==H||l==pe}function Pm(s){return typeof s=="number"&&s==We(s)}function Hl(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=ne}function Pt(s){var l=typeof s;return s!=null&&(l=="object"||l=="function")}function Dt(s){return s!=null&&typeof s=="object"}var Am=Jp?Vr(Jp):d1;function fL(s,l){return s===l||hf(s,l,Of(l))}function hL(s,l,u){return u=typeof u=="function"?u:i,hf(s,l,Of(l),u)}function pL(s){return Dm(s)&&s!=+s}function dL(s){if(X1(s))throw new je(r);return Ld(s)}function mL(s){return s===null}function gL(s){return s==null}function Dm(s){return typeof s=="number"||Dt(s)&&xr(s)==Te}function la(s){if(!Dt(s)||xr(s)!=le)return!1;var l=yl(s);if(l===null)return!0;var u=ht.call(l,"constructor")&&l.constructor;return typeof u=="function"&&u instanceof u&&pl.call(u)==hS}var Vf=Kp?Vr(Kp):m1;function yL(s){return Pm(s)&&s>=-ne&&s<=ne}var Em=Yp?Vr(Yp):g1;function Wl(s){return typeof s=="string"||!ke(s)&&Dt(s)&&xr(s)==Se}function jr(s){return typeof s=="symbol"||Dt(s)&&xr(s)==Ie}var Vo=Xp?Vr(Xp):y1;function xL(s){return s===i}function vL(s){return Dt(s)&&hr(s)==Ve}function bL(s){return Dt(s)&&xr(s)==Lt}var SL=Bl(df),wL=Bl(function(s,l){return s<=l});function Bm(s){if(!s)return[];if(Or(s))return Wl(s)?vn(s):Ir(s);if(Ks&&s[Ks])return eS(s[Ks]());var l=hr(s),u=l==ee?ef:l==be?ul:Uo;return u(s)}function ni(s){if(!s)return s===0?s:0;if(s=sn(s),s===ae||s===-ae){var l=s<0?-1:1;return l*xe}return s===s?s:0}function We(s){var l=ni(s),u=l%1;return l===l?u?l-u:l:0}function Gm(s){return s?ro(We(s),0,Le):0}function sn(s){if(typeof s=="number")return s;if(jr(s))return _e;if(Pt(s)){var l=typeof s.valueOf=="function"?s.valueOf():s;s=Pt(l)?l+"":l}if(typeof s!="string")return s===0?s:+s;s=s.replace(Qe,"");var u=il.test(s);return u||ob.test(s)?Rb(s.slice(2),u?2:8):Pn.test(s)?_e:+s}function Rm(s){return Dn(s,Mr(s))}function CL(s){return s?ro(We(s),-ne,ne):s===0?s:0}function lt(s){return s==null?"":Ur(s)}var LL=Ro(function(s,l){if(sa(l)||Or(l)){Dn(l,Qt(l),s);return}for(var u in l)ht.call(l,u)&&ea(s,u,l[u])}),zm=Ro(function(s,l){Dn(l,Mr(l),s)}),ql=Ro(function(s,l,u,p){Dn(l,Mr(l),s,p)}),TL=Ro(function(s,l,u,p){Dn(l,Qt(l),s,p)}),NL=ei(af);function _L(s,l){var u=Go(s);return l==null?u:gd(u,l)}var IL=Xe(function(s,l){s=xt(s);var u=-1,p=l.length,g=p>2?l[2]:i;for(g&&vr(l[0],l[1],g)&&(p=1);++u<p;)for(var v=l[u],C=Mr(v),L=-1,_=C.length;++L<_;){var Z=C[L],Q=s[Z];(Q===i||Sn(Q,Do[Z])&&!ht.call(s,Z))&&(s[Z]=v[Z])}return s}),OL=Xe(function(s){return s.push(i,tm),Fr(Fm,i,s)});function ML(s,l){return Qp(s,Be(l,3),An)}function PL(s,l){return Qp(s,Be(l,3),cf)}function AL(s,l){return s==null?s:lf(s,Be(l,3),Mr)}function DL(s,l){return s==null?s:Sd(s,Be(l,3),Mr)}function EL(s,l){return s&&An(s,Be(l,3))}function BL(s,l){return s&&cf(s,Be(l,3))}function GL(s){return s==null?[]:_l(s,Qt(s))}function RL(s){return s==null?[]:_l(s,Mr(s))}function Uf(s,l,u){var p=s==null?i:no(s,l);return p===i?u:p}function zL(s,l){return s!=null&&im(s,l,a1)}function jf(s,l){return s!=null&&im(s,l,l1)}var FL=Yd(function(s,l,u){l!=null&&typeof l.toString!="function"&&(l=dl.call(l)),s[l]=u},Hf(Pr)),VL=Yd(function(s,l,u){l!=null&&typeof l.toString!="function"&&(l=dl.call(l)),ht.call(s,l)?s[l].push(u):s[l]=[u]},Be),UL=Xe(ra);function Qt(s){return Or(s)?dd(s):pf(s)}function Mr(s){return Or(s)?dd(s,!0):x1(s)}function jL(s,l){var u={};return l=Be(l,3),An(s,function(p,g,v){Zn(u,l(p,g,v),p)}),u}function kL(s,l){var u={};return l=Be(l,3),An(s,function(p,g,v){Zn(u,g,l(p,g,v))}),u}var HL=Ro(function(s,l,u){Il(s,l,u)}),Fm=Ro(function(s,l,u,p){Il(s,l,u,p)}),WL=ei(function(s,l){var u={};if(s==null)return u;var p=!1;l=It(l,function(v){return v=Li(v,s),p||(p=v.length>1),v}),Dn(s,_f(s),u),p&&(u=rn(u,f|h|d,F1));for(var g=l.length;g--;)vf(u,l[g]);return u});function qL(s,l){return Vm(s,kl(Be(l)))}var $L=ei(function(s,l){return s==null?{}:b1(s,l)});function Vm(s,l){if(s==null)return{};var u=It(_f(s),function(p){return[p]});return l=Be(l),Pd(s,u,function(p,g){return l(p,g[0])})}function JL(s,l,u){l=Li(l,s);var p=-1,g=l.length;for(g||(g=1,s=i);++p<g;){var v=s==null?i:s[En(l[p])];v===i&&(p=g,v=u),s=ri(v)?v.call(s):v}return s}function KL(s,l,u){return s==null?s:ia(s,l,u)}function YL(s,l,u,p){return p=typeof p=="function"?p:i,s==null?s:ia(s,l,u,p)}var Um=Qd(Qt),jm=Qd(Mr);function XL(s,l,u){var p=ke(s),g=p||Ni(s)||Vo(s);if(l=Be(l,4),u==null){var v=s&&s.constructor;g?u=p?new v:[]:Pt(s)?u=ri(v)?Go(yl(s)):{}:u={}}return(g?Qr:An)(s,function(C,L,_){return l(u,C,L,_)}),u}function ZL(s,l){return s==null?!0:vf(s,l)}function QL(s,l,u){return s==null?s:Gd(s,l,wf(u))}function eT(s,l,u,p){return p=typeof p=="function"?p:i,s==null?s:Gd(s,l,wf(u),p)}function Uo(s){return s==null?[]:Qu(s,Qt(s))}function tT(s){return s==null?[]:Qu(s,Mr(s))}function rT(s,l,u){return u===i&&(u=l,l=i),u!==i&&(u=sn(u),u=u===u?u:0),l!==i&&(l=sn(l),l=l===l?l:0),ro(sn(s),l,u)}function nT(s,l,u){return l=ni(l),u===i?(u=l,l=0):u=ni(u),s=sn(s),c1(s,l,u)}function iT(s,l,u){if(u&&typeof u!="boolean"&&vr(s,l,u)&&(l=u=i),u===i&&(typeof l=="boolean"?(u=l,l=i):typeof s=="boolean"&&(u=s,s=i)),s===i&&l===i?(s=0,l=1):(s=ni(s),l===i?(l=s,s=0):l=ni(l)),s>l){var p=s;s=l,l=p}if(u||s%1||l%1){var g=hd();return fr(s+g*(l-s+Gb("1e-"+((g+"").length-1))),l)}return gf(s,l)}var oT=zo(function(s,l,u){return l=l.toLowerCase(),s+(u?km(l):l)});function km(s){return kf(lt(s).toLowerCase())}function Hm(s){return s=lt(s),s&&s.replace(ab,Kb).replace(Nb,"")}function sT(s,l,u){s=lt(s),l=Ur(l);var p=s.length;u=u===i?p:ro(We(u),0,p);var g=u;return u-=l.length,u>=0&&s.slice(u,g)==l}function aT(s){return s=lt(s),s&&Nr.test(s)?s.replace(Yi,Yb):s}function lT(s){return s=lt(s),s&&$e.test(s)?s.replace(He,"\\$&"):s}var cT=zo(function(s,l,u){return s+(u?"-":"")+l.toLowerCase()}),uT=zo(function(s,l,u){return s+(u?" ":"")+l.toLowerCase()}),fT=$d("toLowerCase");function hT(s,l,u){s=lt(s),l=We(l);var p=l?Ao(s):0;if(!l||p>=l)return s;var g=(l-p)/2;return El(Sl(g),u)+s+El(bl(g),u)}function pT(s,l,u){s=lt(s),l=We(l);var p=l?Ao(s):0;return l&&p<l?s+El(l-p,u):s}function dT(s,l,u){s=lt(s),l=We(l);var p=l?Ao(s):0;return l&&p<l?El(l-p,u)+s:s}function mT(s,l,u){return u||l==null?l=0:l&&(l=+l),wS(lt(s).replace(ot,""),l||0)}function gT(s,l,u){return(u?vr(s,l,u):l===i)?l=1:l=We(l),yf(lt(s),l)}function yT(){var s=arguments,l=lt(s[0]);return s.length<3?l:l.replace(s[1],s[2])}var xT=zo(function(s,l,u){return s+(u?"_":"")+l.toLowerCase()});function vT(s,l,u){return u&&typeof u!="number"&&vr(s,l,u)&&(l=u=i),u=u===i?Le:u>>>0,u?(s=lt(s),s&&(typeof l=="string"||l!=null&&!Vf(l))&&(l=Ur(l),!l&&Po(s))?Ti(vn(s),0,u):s.split(l,u)):[]}var bT=zo(function(s,l,u){return s+(u?" ":"")+kf(l)});function ST(s,l,u){return s=lt(s),u=u==null?0:ro(We(u),0,s.length),l=Ur(l),s.slice(u,u+l.length)==l}function wT(s,l,u){var p=y.templateSettings;u&&vr(s,l,u)&&(l=i),s=lt(s),l=ql({},l,p,em);var g=ql({},l.imports,p.imports,em),v=Qt(g),C=Qu(g,v),L,_,Z=0,Q=l.interpolate||ol,oe="__p += '",ge=tf((l.escape||ol).source+"|"+Q.source+"|"+(Q===Kn?yn:ol).source+"|"+(l.evaluate||ol).source+"|$","g"),Ne="//# sourceURL="+(ht.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Pb+"]")+`
4
+ `;s.replace(ge,function(Ge,Ze,tt,kr,br,Hr){return tt||(tt=kr),oe+=s.slice(Z,Hr).replace(lb,Xb),Ze&&(L=!0,oe+=`' +
5
5
  __e(`+Ze+`) +
6
6
  '`),br&&(_=!0,oe+=`';
7
7
  `+br+`;
@@ -11,17 +11,17 @@ __p += '`),tt&&(oe+=`' +
11
11
  `;var ze=ht.call(l,"variable")&&l.variable;ze||(oe=`with (obj) {
12
12
  `+oe+`
13
13
  }
14
- `),oe=(_?oe.replace(Co,""):oe).replace(Lo,"$1").replace(To,"$1;"),oe="function("+(ze||"obj")+`) {
14
+ `),oe=(_?oe.replace(Lo,""):oe).replace(To,"$1").replace(No,"$1;"),oe="function("+(ze||"obj")+`) {
15
15
  `+(ze?"":`obj || (obj = {});
16
16
  `)+"var __t, __p = ''"+(L?", __e = _.escape":"")+(_?`, __j = Array.prototype.join;
17
17
  function print() { __p += __j.call(arguments, '') }
18
18
  `:`;
19
19
  `)+oe+`return __p
20
- }`;var Je=qm(function(){return st(v,Ne+"return "+oe).apply(i,C)});if(Je.source=oe,Ff(Je))throw Je;return Je}function vT(s){return lt(s).toLowerCase()}function bT(s){return lt(s).toUpperCase()}function ST(s,l,u){if(s=lt(s),s&&(u||l===i))return s.replace(Qe,"");if(!s||!(l=Ur(l)))return s;var p=vn(s),g=vn(l),v=nd(p,g),C=id(p,g)+1;return Ti(p,v,C).join("")}function wT(s,l,u){if(s=lt(s),s&&(u||l===i))return s.replace(dt,"");if(!s||!(l=Ur(l)))return s;var p=vn(s),g=id(p,vn(l))+1;return Ti(p,0,g).join("")}function CT(s,l,u){if(s=lt(s),s&&(u||l===i))return s.replace(ot,"");if(!s||!(l=Ur(l)))return s;var p=vn(s),g=nd(p,vn(l));return Ti(p,g).join("")}function LT(s,l){var u=A,p=b;if(Pt(l)){var g="separator"in l?l.separator:g;u="length"in l?We(l.length):u,p="omission"in l?Ur(l.omission):p}s=lt(s);var v=s.length;if(Mo(s)){var C=vn(s);v=C.length}if(u>=v)return s;var L=u-Po(p);if(L<1)return p;var _=C?Ti(C,0,L).join(""):s.slice(0,L);if(g===i)return _+p;if(C&&(L+=_.length-L),Vf(g)){if(s.slice(L).search(g)){var Z,Q=_;for(g.global||(g=tf(g.source,lt(xn.exec(g))+"g")),g.lastIndex=0;Z=g.exec(Q);)var oe=Z.index;_=_.slice(0,oe===i?L:oe)}}else if(s.indexOf(Ur(g),L)!=L){var ge=_.lastIndexOf(g);ge>-1&&(_=_.slice(0,ge))}return _+p}function TT(s){return s=lt(s),s&&No.test(s)?s.replace(Ki,eS):s}var NT=Ro(function(s,l,u){return s+(u?" ":"")+l.toUpperCase()}),kf=$d("toUpperCase");function Wm(s,l,u){return s=lt(s),l=u?i:l,l===i?Kb(s)?nS(s):Vb(s):s.match(l)||[]}var qm=Xe(function(s,l){try{return Fr(s,i,l)}catch(u){return Ff(u)?u:new je(u)}}),_T=ei(function(s,l){return Qr(l,function(u){u=En(u),Zn(s,u,Rf(s[u],s))}),s});function IT(s){var l=s==null?0:s.length,u=Be();return s=l?It(s,function(p){if(typeof p[1]!="function")throw new en(n);return[u(p[0]),p[1]]}):[],Xe(function(p){for(var g=-1;++g<l;){var v=s[g];if(Fr(v[0],this,p))return Fr(v[1],this,p)}})}function OT(s){return e1(rn(s,f))}function Hf(s){return function(){return s}}function MT(s,l){return s==null||s!==s?l:s}var PT=Kd(),AT=Kd(!0);function Pr(s){return s}function Wf(s){return Td(typeof s=="function"?s:rn(s,f))}function DT(s){return _d(rn(s,f))}function ET(s,l){return Id(s,rn(l,f))}var BT=Xe(function(s,l){return function(u){return ta(u,s,l)}}),GT=Xe(function(s,l){return function(u){return ta(s,u,l)}});function qf(s,l,u){var p=Qt(l),g=_l(l,p);u==null&&!(Pt(l)&&(g.length||!p.length))&&(u=l,l=s,s=this,g=_l(l,Qt(l)));var v=!(Pt(u)&&"chain"in u)||!!u.chain,C=ri(s);return Qr(g,function(L){var _=l[L];s[L]=_,C&&(s.prototype[L]=function(){var Z=this.__chain__;if(v||Z){var Q=s(this.__wrapped__),oe=Q.__actions__=Ir(this.__actions__);return oe.push({func:_,args:arguments,thisArg:s}),Q.__chain__=Z,Q}return _.apply(s,xi([this.value()],arguments))})}),s}function RT(){return Zt._===this&&(Zt._=cS),this}function $f(){}function zT(s){return s=We(s),Xe(function(l){return Od(l,s)})}var FT=Lf(It),VT=Lf(Zp),UT=Lf(Ju);function $m(s){return Pf(s)?Ku(En(s)):y1(s)}function jT(s){return function(l){return s==null?i:no(s,l)}}var kT=Xd(),HT=Xd(!0);function Jf(){return[]}function Kf(){return!1}function WT(){return{}}function qT(){return""}function $T(){return!0}function JT(s,l){if(s=We(s),s<1||s>ne)return[];var u=Le,p=fr(s,Le);l=Be(l),s-=Le;for(var g=Zu(p,l);++u<s;)l(u);return g}function KT(s){return ke(s)?It(s,En):jr(s)?[s]:Ir(pm(lt(s)))}function YT(s){var l=++aS;return lt(s)+l}var XT=Dl(function(s,l){return s+l},0),ZT=Tf("ceil"),QT=Dl(function(s,l){return s/l},1),eN=Tf("floor");function tN(s){return s&&s.length?Nl(s,Pr,uf):i}function rN(s,l){return s&&s.length?Nl(s,Be(l,2),uf):i}function nN(s){return td(s,Pr)}function iN(s,l){return td(s,Be(l,2))}function oN(s){return s&&s.length?Nl(s,Pr,df):i}function sN(s,l){return s&&s.length?Nl(s,Be(l,2),df):i}var aN=Dl(function(s,l){return s*l},1),lN=Tf("round"),cN=Dl(function(s,l){return s-l},0);function uN(s){return s&&s.length?Xu(s,Pr):0}function fN(s,l){return s&&s.length?Xu(s,Be(l,2)):0}return y.after=DC,y.ary=Lm,y.assign=bL,y.assignIn=zm,y.assignInWith=ql,y.assignWith=SL,y.at=wL,y.before=Tm,y.bind=Rf,y.bindAll=_T,y.bindKey=Nm,y.castArray=WC,y.chain=Sm,y.chunk=ew,y.compact=tw,y.concat=rw,y.cond=IT,y.conforms=OT,y.constant=Hf,y.countBy=uC,y.create=CL,y.curry=_m,y.curryRight=Im,y.debounce=Om,y.defaults=LL,y.defaultsDeep=TL,y.defer=EC,y.delay=BC,y.difference=nw,y.differenceBy=iw,y.differenceWith=ow,y.drop=sw,y.dropRight=aw,y.dropRightWhile=lw,y.dropWhile=cw,y.fill=uw,y.filter=hC,y.flatMap=mC,y.flatMapDeep=gC,y.flatMapDepth=yC,y.flatten=ym,y.flattenDeep=fw,y.flattenDepth=hw,y.flip=GC,y.flow=PT,y.flowRight=AT,y.fromPairs=pw,y.functions=AL,y.functionsIn=DL,y.groupBy=xC,y.initial=mw,y.intersection=gw,y.intersectionBy=yw,y.intersectionWith=xw,y.invert=BL,y.invertBy=GL,y.invokeMap=bC,y.iteratee=Wf,y.keyBy=SC,y.keys=Qt,y.keysIn=Mr,y.map=Vl,y.mapKeys=zL,y.mapValues=FL,y.matches=DT,y.matchesProperty=ET,y.memoize=jl,y.merge=VL,y.mergeWith=Fm,y.method=BT,y.methodOf=GT,y.mixin=qf,y.negate=kl,y.nthArg=zT,y.omit=UL,y.omitBy=jL,y.once=RC,y.orderBy=wC,y.over=FT,y.overArgs=zC,y.overEvery=VT,y.overSome=UT,y.partial=zf,y.partialRight=Mm,y.partition=CC,y.pick=kL,y.pickBy=Vm,y.property=$m,y.propertyOf=jT,y.pull=ww,y.pullAll=vm,y.pullAllBy=Cw,y.pullAllWith=Lw,y.pullAt=Tw,y.range=kT,y.rangeRight=HT,y.rearg=FC,y.reject=NC,y.remove=Nw,y.rest=VC,y.reverse=Bf,y.sampleSize=IC,y.set=WL,y.setWith=qL,y.shuffle=OC,y.slice=_w,y.sortBy=AC,y.sortedUniq=Ew,y.sortedUniqBy=Bw,y.split=mT,y.spread=UC,y.tail=Gw,y.take=Rw,y.takeRight=zw,y.takeRightWhile=Fw,y.takeWhile=Vw,y.tap=tC,y.throttle=jC,y.thru=Fl,y.toArray=Bm,y.toPairs=Um,y.toPairsIn=jm,y.toPath=KT,y.toPlainObject=Rm,y.transform=$L,y.unary=kC,y.union=Uw,y.unionBy=jw,y.unionWith=kw,y.uniq=Hw,y.uniqBy=Ww,y.uniqWith=qw,y.unset=JL,y.unzip=Gf,y.unzipWith=bm,y.update=KL,y.updateWith=YL,y.values=Vo,y.valuesIn=XL,y.without=$w,y.words=Wm,y.wrap=HC,y.xor=Jw,y.xorBy=Kw,y.xorWith=Yw,y.zip=Xw,y.zipObject=Zw,y.zipObjectDeep=Qw,y.zipWith=eC,y.entries=Um,y.entriesIn=jm,y.extend=zm,y.extendWith=ql,qf(y,y),y.add=XT,y.attempt=qm,y.camelCase=tT,y.capitalize=km,y.ceil=ZT,y.clamp=ZL,y.clone=qC,y.cloneDeep=JC,y.cloneDeepWith=KC,y.cloneWith=$C,y.conformsTo=YC,y.deburr=Hm,y.defaultTo=MT,y.divide=QT,y.endsWith=rT,y.eq=Sn,y.escape=nT,y.escapeRegExp=iT,y.every=fC,y.find=pC,y.findIndex=mm,y.findKey=NL,y.findLast=dC,y.findLastIndex=gm,y.findLastKey=_L,y.floor=eN,y.forEach=wm,y.forEachRight=Cm,y.forIn=IL,y.forInRight=OL,y.forOwn=ML,y.forOwnRight=PL,y.get=Uf,y.gt=XC,y.gte=ZC,y.has=EL,y.hasIn=jf,y.head=xm,y.identity=Pr,y.includes=vC,y.indexOf=dw,y.inRange=QL,y.invoke=RL,y.isArguments=so,y.isArray=ke,y.isArrayBuffer=QC,y.isArrayLike=Or,y.isArrayLikeObject=Gt,y.isBoolean=eL,y.isBuffer=Ni,y.isDate=tL,y.isElement=rL,y.isEmpty=nL,y.isEqual=iL,y.isEqualWith=oL,y.isError=Ff,y.isFinite=sL,y.isFunction=ri,y.isInteger=Pm,y.isLength=Hl,y.isMap=Am,y.isMatch=aL,y.isMatchWith=lL,y.isNaN=cL,y.isNative=uL,y.isNil=hL,y.isNull=fL,y.isNumber=Dm,y.isObject=Pt,y.isObjectLike=Dt,y.isPlainObject=aa,y.isRegExp=Vf,y.isSafeInteger=pL,y.isSet=Em,y.isString=Wl,y.isSymbol=jr,y.isTypedArray=Fo,y.isUndefined=dL,y.isWeakMap=mL,y.isWeakSet=gL,y.join=vw,y.kebabCase=oT,y.last=on,y.lastIndexOf=bw,y.lowerCase=sT,y.lowerFirst=aT,y.lt=yL,y.lte=xL,y.max=tN,y.maxBy=rN,y.mean=nN,y.meanBy=iN,y.min=oN,y.minBy=sN,y.stubArray=Jf,y.stubFalse=Kf,y.stubObject=WT,y.stubString=qT,y.stubTrue=$T,y.multiply=aN,y.nth=Sw,y.noConflict=RT,y.noop=$f,y.now=Ul,y.pad=lT,y.padEnd=cT,y.padStart=uT,y.parseInt=fT,y.random=eT,y.reduce=LC,y.reduceRight=TC,y.repeat=hT,y.replace=pT,y.result=HL,y.round=lN,y.runInContext=I,y.sample=_C,y.size=MC,y.snakeCase=dT,y.some=PC,y.sortedIndex=Iw,y.sortedIndexBy=Ow,y.sortedIndexOf=Mw,y.sortedLastIndex=Pw,y.sortedLastIndexBy=Aw,y.sortedLastIndexOf=Dw,y.startCase=gT,y.startsWith=yT,y.subtract=cN,y.sum=uN,y.sumBy=fN,y.template=xT,y.times=JT,y.toFinite=ni,y.toInteger=We,y.toLength=Gm,y.toLower=vT,y.toNumber=sn,y.toSafeInteger=vL,y.toString=lt,y.toUpper=bT,y.trim=ST,y.trimEnd=wT,y.trimStart=CT,y.truncate=LT,y.unescape=TT,y.uniqueId=YT,y.upperCase=NT,y.upperFirst=kf,y.each=wm,y.eachRight=Cm,y.first=xm,qf(y,function(){var s={};return An(y,function(l,u){ht.call(y.prototype,u)||(s[u]=l)}),s}(),{chain:!1}),y.VERSION=t,Qr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){y[s].placeholder=y}),Qr(["drop","take"],function(s,l){et.prototype[s]=function(u){u=u===i?1:Jt(We(u),0);var p=this.__filtered__&&!l?new et(this):this.clone();return p.__filtered__?p.__takeCount__=fr(u,p.__takeCount__):p.__views__.push({size:fr(u,Le),type:s+(p.__dir__<0?"Right":"")}),p},et.prototype[s+"Right"]=function(u){return this.reverse()[s](u).reverse()}}),Qr(["filter","map","takeWhile"],function(s,l){var u=l+1,p=u==R||u==G;et.prototype[s]=function(g){var v=this.clone();return v.__iteratees__.push({iteratee:Be(g,3),type:u}),v.__filtered__=v.__filtered__||p,v}}),Qr(["head","last"],function(s,l){var u="take"+(l?"Right":"");et.prototype[s]=function(){return this[u](1).value()[0]}}),Qr(["initial","tail"],function(s,l){var u="drop"+(l?"":"Right");et.prototype[s]=function(){return this.__filtered__?new et(this):this[u](1)}}),et.prototype.compact=function(){return this.filter(Pr)},et.prototype.find=function(s){return this.filter(s).head()},et.prototype.findLast=function(s){return this.reverse().find(s)},et.prototype.invokeMap=Xe(function(s,l){return typeof s=="function"?new et(this):this.map(function(u){return ta(u,s,l)})}),et.prototype.reject=function(s){return this.filter(kl(Be(s)))},et.prototype.slice=function(s,l){s=We(s);var u=this;return u.__filtered__&&(s>0||l<0)?new et(u):(s<0?u=u.takeRight(-s):s&&(u=u.drop(s)),l!==i&&(l=We(l),u=l<0?u.dropRight(-l):u.take(l-s)),u)},et.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},et.prototype.toArray=function(){return this.take(Le)},An(et.prototype,function(s,l){var u=/^(?:filter|find|map|reject)|While$/.test(l),p=/^(?:head|last)$/.test(l),g=y[p?"take"+(l=="last"?"Right":""):l],v=p||/^find/.test(l);!g||(y.prototype[l]=function(){var C=this.__wrapped__,L=p?[1]:arguments,_=C instanceof et,Z=L[0],Q=_||ke(C),oe=function(Ze){var tt=g.apply(y,xi([Ze],L));return p&&ge?tt[0]:tt};Q&&u&&typeof Z=="function"&&Z.length!=1&&(_=Q=!1);var ge=this.__chain__,Ne=!!this.__actions__.length,ze=v&&!ge,Je=_&&!Ne;if(!v&&Q){C=Je?C:new et(this);var Ge=s.apply(C,L);return Ge.__actions__.push({func:Fl,args:[oe],thisArg:i}),new tn(Ge,ge)}return ze&&Je?s.apply(this,L):(Ge=this.thru(oe),ze?p?Ge.value()[0]:Ge.value():Ge)})}),Qr(["pop","push","shift","sort","splice","unshift"],function(s){var l=fl[s],u=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",p=/^(?:pop|shift)$/.test(s);y.prototype[s]=function(){var g=arguments;if(p&&!this.__chain__){var v=this.value();return l.apply(ke(v)?v:[],g)}return this[u](function(C){return l.apply(ke(C)?C:[],g)})}}),An(et.prototype,function(s,l){var u=y[l];if(u){var p=u.name+"";ht.call(Eo,p)||(Eo[p]=[]),Eo[p].push({name:l,func:u})}}),Eo[Al(i,w).name]=[{name:"wrapper",func:i}],et.prototype.clone=TS,et.prototype.reverse=NS,et.prototype.value=_S,y.prototype.at=rC,y.prototype.chain=nC,y.prototype.commit=iC,y.prototype.next=oC,y.prototype.plant=aC,y.prototype.reverse=lC,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=cC,y.prototype.first=y.prototype.head,Js&&(y.prototype[Js]=sC),y},bi=iS();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Zt._=bi,define(function(){return bi})):Zi?((Zi.exports=bi)._=bi,Hu._=bi):Zt._=bi}).call(qs)});import{FileLoader as z3,Loader as F3}from"three";function eg(i){return Array.isArray(i)?i:[i]}var SN=typeof global=="object"&&global&&global.Object===Object&&global,Jl=SN;var wN=typeof self=="object"&&self&&self.Object===Object&&self,CN=Jl||wN||Function("return this")(),kt=CN;var LN=kt.Symbol,Sr=LN;var tg=Object.prototype,TN=tg.hasOwnProperty,NN=tg.toString,la=Sr?Sr.toStringTag:void 0;function _N(i){var t=TN.call(i,la),e=i[la];try{i[la]=void 0;var r=!0}catch{}var n=NN.call(i);return r&&(t?i[la]=e:delete i[la]),n}var rg=_N;var IN=Object.prototype,ON=IN.toString;function MN(i){return ON.call(i)}var ng=MN;var PN="[object Null]",AN="[object Undefined]",ig=Sr?Sr.toStringTag:void 0;function DN(i){return i==null?i===void 0?AN:PN:ig&&ig in Object(i)?rg(i):ng(i)}var Wr=DN;function EN(i){return i!=null&&typeof i=="object"}var pr=EN;var BN="[object Symbol]";function GN(i){return typeof i=="symbol"||pr(i)&&Wr(i)==BN}var Uo=GN;function RN(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var Kl=RN;var zN=Array.isArray,sr=zN;var FN=1/0,og=Sr?Sr.prototype:void 0,sg=og?og.toString:void 0;function ag(i){if(typeof i=="string")return i;if(sr(i))return Kl(i,ag)+"";if(Uo(i))return sg?sg.call(i):"";var t=i+"";return t=="0"&&1/i==-FN?"-0":t}var lg=ag;function VN(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var dr=VN;function UN(i){return i}var Yl=UN;var jN="[object AsyncFunction]",kN="[object Function]",HN="[object GeneratorFunction]",WN="[object Proxy]";function qN(i){if(!dr(i))return!1;var t=Wr(i);return t==kN||t==HN||t==jN||t==WN}var jo=qN;var $N=kt["__core-js_shared__"],Xl=$N;var cg=function(){var i=/[^.]+$/.exec(Xl&&Xl.keys&&Xl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function JN(i){return!!cg&&cg in i}var ug=JN;var KN=Function.prototype,YN=KN.toString;function XN(i){if(i!=null){try{return YN.call(i)}catch{}try{return i+""}catch{}}return""}var oi=XN;var ZN=/[\\^$.*+?()[\]{}|]/g,QN=/^\[object .+?Constructor\]$/,e_=Function.prototype,t_=Object.prototype,r_=e_.toString,n_=t_.hasOwnProperty,i_=RegExp("^"+r_.call(n_).replace(ZN,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function o_(i){if(!dr(i)||ug(i))return!1;var t=jo(i)?i_:QN;return t.test(oi(i))}var fg=o_;function s_(i,t){return i==null?void 0:i[t]}var hg=s_;function a_(i,t){var e=hg(i,t);return fg(e)?e:void 0}var Ar=a_;var l_=Ar(kt,"WeakMap"),Zl=l_;var pg=Object.create,c_=function(){function i(){}return function(t){if(!dr(t))return{};if(pg)return pg(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),dg=c_;function u_(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var mg=u_;function f_(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var Ql=f_;var h_=800,p_=16,d_=Date.now;function m_(i){var t=0,e=0;return function(){var r=d_(),n=p_-(r-e);if(e=r,n>0){if(++t>=h_)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var gg=m_;function g_(i){return function(){return i}}var yg=g_;var y_=function(){try{var i=Ar(Object,"defineProperty");return i({},"",{}),i}catch{}}(),ko=y_;var x_=ko?function(i,t){return ko(i,"toString",{configurable:!0,enumerable:!1,value:yg(t),writable:!0})}:Yl,xg=x_;var v_=gg(xg),ec=v_;function b_(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var vg=b_;var S_=9007199254740991,w_=/^(?:0|[1-9]\d*)$/;function C_(i,t){var e=typeof i;return t=t==null?S_:t,!!t&&(e=="number"||e!="symbol"&&w_.test(i))&&i>-1&&i%1==0&&i<t}var tc=C_;function L_(i,t,e){t=="__proto__"&&ko?ko(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Ho=L_;function T_(i,t){return i===t||i!==i&&t!==t}var _i=T_;var N_=Object.prototype,__=N_.hasOwnProperty;function I_(i,t,e){var r=i[t];(!(__.call(i,t)&&_i(r,e))||e===void 0&&!(t in i))&&Ho(i,t,e)}var rc=I_;function O_(i,t,e,r){var n=!e;e||(e={});for(var o=-1,a=t.length;++o<a;){var c=t[o],f=r?r(e[c],i[c],c,e,i):void 0;f===void 0&&(f=i[c]),n?Ho(e,c,f):rc(e,c,f)}return e}var an=O_;var bg=Math.max;function M_(i,t,e){return t=bg(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,o=bg(r.length-t,0),a=Array(o);++n<o;)a[n]=r[t+n];n=-1;for(var c=Array(t+1);++n<t;)c[n]=r[n];return c[t]=e(a),mg(i,this,c)}}var nc=M_;function P_(i,t){return ec(nc(i,t,Yl),i+"")}var Sg=P_;var A_=9007199254740991;function D_(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=A_}var ic=D_;function E_(i){return i!=null&&ic(i.length)&&!jo(i)}var Ii=E_;function B_(i,t,e){if(!dr(e))return!1;var r=typeof t;return(r=="number"?Ii(e)&&tc(t,e.length):r=="string"&&t in e)?_i(e[t],i):!1}var wg=B_;function G_(i){return Sg(function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,a=n>2?e[2]:void 0;for(o=i.length>3&&typeof o=="function"?(n--,o):void 0,a&&wg(e[0],e[1],a)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var c=e[r];c&&i(t,c,r,o)}return t})}var Cg=G_;var R_=Object.prototype;function z_(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||R_;return i===e}var Wo=z_;function F_(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var Lg=F_;var V_="[object Arguments]";function U_(i){return pr(i)&&Wr(i)==V_}var Yf=U_;var Tg=Object.prototype,j_=Tg.hasOwnProperty,k_=Tg.propertyIsEnumerable,H_=Yf(function(){return arguments}())?Yf:function(i){return pr(i)&&j_.call(i,"callee")&&!k_.call(i,"callee")},ao=H_;function W_(){return!1}var Ng=W_;var Og=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_g=Og&&typeof module=="object"&&module&&!module.nodeType&&module,q_=_g&&_g.exports===Og,Ig=q_?kt.Buffer:void 0,$_=Ig?Ig.isBuffer:void 0,J_=$_||Ng,qo=J_;var K_="[object Arguments]",Y_="[object Array]",X_="[object Boolean]",Z_="[object Date]",Q_="[object Error]",eI="[object Function]",tI="[object Map]",rI="[object Number]",nI="[object Object]",iI="[object RegExp]",oI="[object Set]",sI="[object String]",aI="[object WeakMap]",lI="[object ArrayBuffer]",cI="[object DataView]",uI="[object Float32Array]",fI="[object Float64Array]",hI="[object Int8Array]",pI="[object Int16Array]",dI="[object Int32Array]",mI="[object Uint8Array]",gI="[object Uint8ClampedArray]",yI="[object Uint16Array]",xI="[object Uint32Array]",Nt={};Nt[uI]=Nt[fI]=Nt[hI]=Nt[pI]=Nt[dI]=Nt[mI]=Nt[gI]=Nt[yI]=Nt[xI]=!0;Nt[K_]=Nt[Y_]=Nt[lI]=Nt[X_]=Nt[cI]=Nt[Z_]=Nt[Q_]=Nt[eI]=Nt[tI]=Nt[rI]=Nt[nI]=Nt[iI]=Nt[oI]=Nt[sI]=Nt[aI]=!1;function vI(i){return pr(i)&&ic(i.length)&&!!Nt[Wr(i)]}var Mg=vI;function bI(i){return function(t){return i(t)}}var $o=bI;var Pg=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ca=Pg&&typeof module=="object"&&module&&!module.nodeType&&module,SI=ca&&ca.exports===Pg,Xf=SI&&Jl.process,wI=function(){try{var i=ca&&ca.require&&ca.require("util").types;return i||Xf&&Xf.binding&&Xf.binding("util")}catch{}}(),si=wI;var Ag=si&&si.isTypedArray,CI=Ag?$o(Ag):Mg,oc=CI;var LI=Object.prototype,TI=LI.hasOwnProperty;function NI(i,t){var e=sr(i),r=!e&&ao(i),n=!e&&!r&&qo(i),o=!e&&!r&&!n&&oc(i),a=e||r||n||o,c=a?Lg(i.length,String):[],f=c.length;for(var h in i)(t||TI.call(i,h))&&!(a&&(h=="length"||n&&(h=="offset"||h=="parent")||o&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||tc(h,f)))&&c.push(h);return c}var sc=NI;function _I(i,t){return function(e){return i(t(e))}}var ac=_I;var II=ac(Object.keys,Object),Dg=II;var OI=Object.prototype,MI=OI.hasOwnProperty;function PI(i){if(!Wo(i))return Dg(i);var t=[];for(var e in Object(i))MI.call(i,e)&&e!="constructor"&&t.push(e);return t}var Eg=PI;function AI(i){return Ii(i)?sc(i):Eg(i)}var Jo=AI;function DI(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var Bg=DI;var EI=Object.prototype,BI=EI.hasOwnProperty;function GI(i){if(!dr(i))return Bg(i);var t=Wo(i),e=[];for(var r in i)r=="constructor"&&(t||!BI.call(i,r))||e.push(r);return e}var Gg=GI;function RI(i){return Ii(i)?sc(i,!0):Gg(i)}var Bn=RI;var zI=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,FI=/^\w*$/;function VI(i,t){if(sr(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Uo(i)?!0:FI.test(i)||!zI.test(i)||t!=null&&i in Object(t)}var Rg=VI;var UI=Ar(Object,"create"),ai=UI;function jI(){this.__data__=ai?ai(null):{},this.size=0}var zg=jI;function kI(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var Fg=kI;var HI="__lodash_hash_undefined__",WI=Object.prototype,qI=WI.hasOwnProperty;function $I(i){var t=this.__data__;if(ai){var e=t[i];return e===HI?void 0:e}return qI.call(t,i)?t[i]:void 0}var Vg=$I;var JI=Object.prototype,KI=JI.hasOwnProperty;function YI(i){var t=this.__data__;return ai?t[i]!==void 0:KI.call(t,i)}var Ug=YI;var XI="__lodash_hash_undefined__";function ZI(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=ai&&t===void 0?XI:t,this}var jg=ZI;function Ko(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Ko.prototype.clear=zg;Ko.prototype.delete=Fg;Ko.prototype.get=Vg;Ko.prototype.has=Ug;Ko.prototype.set=jg;var Zf=Ko;function QI(){this.__data__=[],this.size=0}var kg=QI;function eO(i,t){for(var e=i.length;e--;)if(_i(i[e][0],t))return e;return-1}var Oi=eO;var tO=Array.prototype,rO=tO.splice;function nO(i){var t=this.__data__,e=Oi(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():rO.call(t,e,1),--this.size,!0}var Hg=nO;function iO(i){var t=this.__data__,e=Oi(t,i);return e<0?void 0:t[e][1]}var Wg=iO;function oO(i){return Oi(this.__data__,i)>-1}var qg=oO;function sO(i,t){var e=this.__data__,r=Oi(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var $g=sO;function Yo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Yo.prototype.clear=kg;Yo.prototype.delete=Hg;Yo.prototype.get=Wg;Yo.prototype.has=qg;Yo.prototype.set=$g;var Mi=Yo;var aO=Ar(kt,"Map"),Pi=aO;function lO(){this.size=0,this.__data__={hash:new Zf,map:new(Pi||Mi),string:new Zf}}var Jg=lO;function cO(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var Kg=cO;function uO(i,t){var e=i.__data__;return Kg(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ai=uO;function fO(i){var t=Ai(this,i).delete(i);return this.size-=t?1:0,t}var Yg=fO;function hO(i){return Ai(this,i).get(i)}var Xg=hO;function pO(i){return Ai(this,i).has(i)}var Zg=pO;function dO(i,t){var e=Ai(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var Qg=dO;function Xo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Xo.prototype.clear=Jg;Xo.prototype.delete=Yg;Xo.prototype.get=Xg;Xo.prototype.has=Zg;Xo.prototype.set=Qg;var ua=Xo;var mO="Expected a function";function Qf(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(mO);var e=function(){var r=arguments,n=t?t.apply(this,r):r[0],o=e.cache;if(o.has(n))return o.get(n);var a=i.apply(this,r);return e.cache=o.set(n,a)||o,a};return e.cache=new(Qf.Cache||ua),e}Qf.Cache=ua;var ey=Qf;var gO=500;function yO(i){var t=ey(i,function(r){return e.size===gO&&e.clear(),r}),e=t.cache;return t}var ty=yO;var xO=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vO=/\\(\\)?/g,bO=ty(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(xO,function(e,r,n,o){t.push(n?o.replace(vO,"$1"):r||e)}),t}),ry=bO;function SO(i){return i==null?"":lg(i)}var ny=SO;function wO(i,t){return sr(i)?i:Rg(i,t)?[i]:ry(ny(i))}var Zo=wO;var CO=1/0;function LO(i){if(typeof i=="string"||Uo(i))return i;var t=i+"";return t=="0"&&1/i==-CO?"-0":t}var lc=LO;function TO(i,t){t=Zo(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[lc(t[e++])];return e&&e==r?i:void 0}var iy=TO;function NO(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var Qo=NO;var oy=Sr?Sr.isConcatSpreadable:void 0;function _O(i){return sr(i)||ao(i)||!!(oy&&i&&i[oy])}var sy=_O;function ay(i,t,e,r,n){var o=-1,a=i.length;for(e||(e=sy),n||(n=[]);++o<a;){var c=i[o];t>0&&e(c)?t>1?ay(c,t-1,e,r,n):Qo(n,c):r||(n[n.length]=c)}return n}var ly=ay;function IO(i){var t=i==null?0:i.length;return t?ly(i,1):[]}var cy=IO;function OO(i){return ec(nc(i,void 0,cy),i+"")}var uy=OO;var MO=ac(Object.getPrototypeOf,Object),es=MO;var PO="[object Object]",AO=Function.prototype,DO=Object.prototype,fy=AO.toString,EO=DO.hasOwnProperty,BO=fy.call(Object);function GO(i){if(!pr(i)||Wr(i)!=PO)return!1;var t=es(i);if(t===null)return!0;var e=EO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&fy.call(e)==BO}var cc=GO;function RO(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(n);++r<n;)o[r]=i[r+t];return o}var hy=RO;function zO(){this.__data__=new Mi,this.size=0}var py=zO;function FO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var dy=FO;function VO(i){return this.__data__.get(i)}var my=VO;function UO(i){return this.__data__.has(i)}var gy=UO;var jO=200;function kO(i,t){var e=this.__data__;if(e instanceof Mi){var r=e.__data__;if(!Pi||r.length<jO-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new ua(r)}return e.set(i,t),this.size=e.size,this}var yy=kO;function ts(i){var t=this.__data__=new Mi(i);this.size=t.size}ts.prototype.clear=py;ts.prototype.delete=dy;ts.prototype.get=my;ts.prototype.has=gy;ts.prototype.set=yy;var uc=ts;function HO(i,t){return i&&an(t,Jo(t),i)}var xy=HO;function WO(i,t){return i&&an(t,Bn(t),i)}var vy=WO;var Cy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,by=Cy&&typeof module=="object"&&module&&!module.nodeType&&module,qO=by&&by.exports===Cy,Sy=qO?kt.Buffer:void 0,wy=Sy?Sy.allocUnsafe:void 0;function $O(i,t){if(t)return i.slice();var e=i.length,r=wy?wy(e):new i.constructor(e);return i.copy(r),r}var fc=$O;function JO(i,t){for(var e=-1,r=i==null?0:i.length,n=0,o=[];++e<r;){var a=i[e];t(a,e,i)&&(o[n++]=a)}return o}var Ly=JO;function KO(){return[]}var hc=KO;var YO=Object.prototype,XO=YO.propertyIsEnumerable,Ty=Object.getOwnPropertySymbols,ZO=Ty?function(i){return i==null?[]:(i=Object(i),Ly(Ty(i),function(t){return XO.call(i,t)}))}:hc,rs=ZO;function QO(i,t){return an(i,rs(i),t)}var Ny=QO;var eM=Object.getOwnPropertySymbols,tM=eM?function(i){for(var t=[];i;)Qo(t,rs(i)),i=es(i);return t}:hc,pc=tM;function rM(i,t){return an(i,pc(i),t)}var _y=rM;function nM(i,t,e){var r=t(i);return sr(i)?r:Qo(r,e(i))}var dc=nM;function iM(i){return dc(i,Jo,rs)}var Iy=iM;function oM(i){return dc(i,Bn,pc)}var mc=oM;var sM=Ar(kt,"DataView"),gc=sM;var aM=Ar(kt,"Promise"),yc=aM;var lM=Ar(kt,"Set"),xc=lM;var Oy="[object Map]",cM="[object Object]",My="[object Promise]",Py="[object Set]",Ay="[object WeakMap]",Dy="[object DataView]",uM=oi(gc),fM=oi(Pi),hM=oi(yc),pM=oi(xc),dM=oi(Zl),lo=Wr;(gc&&lo(new gc(new ArrayBuffer(1)))!=Dy||Pi&&lo(new Pi)!=Oy||yc&&lo(yc.resolve())!=My||xc&&lo(new xc)!=Py||Zl&&lo(new Zl)!=Ay)&&(lo=function(i){var t=Wr(i),e=t==cM?i.constructor:void 0,r=e?oi(e):"";if(r)switch(r){case uM:return Dy;case fM:return Oy;case hM:return My;case pM:return Py;case dM:return Ay}return t});var ns=lo;var mM=Object.prototype,gM=mM.hasOwnProperty;function yM(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&gM.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var Ey=yM;var xM=kt.Uint8Array,eh=xM;function vM(i){var t=new i.constructor(i.byteLength);return new eh(t).set(new eh(i)),t}var is=vM;function bM(i,t){var e=t?is(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var By=bM;var SM=/\w*$/;function wM(i){var t=new i.constructor(i.source,SM.exec(i));return t.lastIndex=i.lastIndex,t}var Gy=wM;var Ry=Sr?Sr.prototype:void 0,zy=Ry?Ry.valueOf:void 0;function CM(i){return zy?Object(zy.call(i)):{}}var Fy=CM;function LM(i,t){var e=t?is(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var vc=LM;var TM="[object Boolean]",NM="[object Date]",_M="[object Map]",IM="[object Number]",OM="[object RegExp]",MM="[object Set]",PM="[object String]",AM="[object Symbol]",DM="[object ArrayBuffer]",EM="[object DataView]",BM="[object Float32Array]",GM="[object Float64Array]",RM="[object Int8Array]",zM="[object Int16Array]",FM="[object Int32Array]",VM="[object Uint8Array]",UM="[object Uint8ClampedArray]",jM="[object Uint16Array]",kM="[object Uint32Array]";function HM(i,t,e){var r=i.constructor;switch(t){case DM:return is(i);case TM:case NM:return new r(+i);case EM:return By(i,e);case BM:case GM:case RM:case zM:case FM:case VM:case UM:case jM:case kM:return vc(i,e);case _M:return new r;case IM:case PM:return new r(i);case OM:return Gy(i);case MM:return new r;case AM:return Fy(i)}}var Vy=HM;function WM(i){return typeof i.constructor=="function"&&!Wo(i)?dg(es(i)):{}}var bc=WM;var qM="[object Map]";function $M(i){return pr(i)&&ns(i)==qM}var Uy=$M;var jy=si&&si.isMap,JM=jy?$o(jy):Uy,ky=JM;var KM="[object Set]";function YM(i){return pr(i)&&ns(i)==KM}var Hy=YM;var Wy=si&&si.isSet,XM=Wy?$o(Wy):Hy,qy=XM;var ZM=1,QM=2,eP=4,$y="[object Arguments]",tP="[object Array]",rP="[object Boolean]",nP="[object Date]",iP="[object Error]",Jy="[object Function]",oP="[object GeneratorFunction]",sP="[object Map]",aP="[object Number]",Ky="[object Object]",lP="[object RegExp]",cP="[object Set]",uP="[object String]",fP="[object Symbol]",hP="[object WeakMap]",pP="[object ArrayBuffer]",dP="[object DataView]",mP="[object Float32Array]",gP="[object Float64Array]",yP="[object Int8Array]",xP="[object Int16Array]",vP="[object Int32Array]",bP="[object Uint8Array]",SP="[object Uint8ClampedArray]",wP="[object Uint16Array]",CP="[object Uint32Array]",St={};St[$y]=St[tP]=St[pP]=St[dP]=St[rP]=St[nP]=St[mP]=St[gP]=St[yP]=St[xP]=St[vP]=St[sP]=St[aP]=St[Ky]=St[lP]=St[cP]=St[uP]=St[fP]=St[bP]=St[SP]=St[wP]=St[CP]=!0;St[iP]=St[Jy]=St[hP]=!1;function Sc(i,t,e,r,n,o){var a,c=t&ZM,f=t&QM,h=t&eP;if(e&&(a=n?e(i,r,n,o):e(i)),a!==void 0)return a;if(!dr(i))return i;var d=sr(i);if(d){if(a=Ey(i),!c)return Ql(i,a)}else{var m=ns(i),x=m==Jy||m==oP;if(qo(i))return fc(i,c);if(m==Ky||m==$y||x&&!n){if(a=f||x?{}:bc(i),!c)return f?_y(i,vy(a,i)):Ny(i,xy(a,i))}else{if(!St[m])return n?i:{};a=Vy(i,m,c)}}o||(o=new uc);var S=o.get(i);if(S)return S;o.set(i,a),qy(i)?i.forEach(function(O){a.add(Sc(O,t,e,O,i,o))}):ky(i)&&i.forEach(function(O,T){a.set(T,Sc(O,t,e,T,i,o))});var w=h?f?mc:Iy:f?Bn:Jo,B=d?void 0:w(i);return vg(B||i,function(O,T){B&&(T=O,O=i[T]),rc(a,T,Sc(O,t,e,T,i,o))}),a}var wc=Sc;var LP=1,TP=4;function NP(i){return wc(i,LP|TP)}var fa=NP;function _P(i){return function(t,e,r){for(var n=-1,o=Object(t),a=r(t),c=a.length;c--;){var f=a[i?c:++n];if(e(o[f],f,o)===!1)break}return t}}var Yy=_P;var IP=Yy(),Xy=IP;function OP(i,t,e){(e!==void 0&&!_i(i[t],e)||e===void 0&&!(t in i))&&Ho(i,t,e)}var ha=OP;function MP(i){return pr(i)&&Ii(i)}var Zy=MP;function PP(i,t){if(!(t==="constructor"&&typeof i[t]=="function")&&t!="__proto__")return i[t]}var pa=PP;function AP(i){return an(i,Bn(i))}var Qy=AP;function DP(i,t,e,r,n,o,a){var c=pa(i,e),f=pa(t,e),h=a.get(f);if(h){ha(i,e,h);return}var d=o?o(c,f,e+"",i,t,a):void 0,m=d===void 0;if(m){var x=sr(f),S=!x&&qo(f),w=!x&&!S&&oc(f);d=f,x||S||w?sr(c)?d=c:Zy(c)?d=Ql(c):S?(m=!1,d=fc(f,!0)):w?(m=!1,d=vc(f,!0)):d=[]:cc(f)||ao(f)?(d=c,ao(c)?d=Qy(c):(!dr(c)||jo(c))&&(d=bc(f))):m=!1}m&&(a.set(f,d),n(d,f,r,o,a),a.delete(f)),ha(i,e,d)}var ex=DP;function tx(i,t,e,r,n){i!==t&&Xy(t,function(o,a){if(n||(n=new uc),dr(o))ex(i,t,a,e,tx,r,n);else{var c=r?r(pa(i,a),o,a+"",i,t,n):void 0;c===void 0&&(c=o),ha(i,a,c)}},Bn)}var rx=tx;function EP(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var nx=EP;function BP(i,t){return t.length<2?i:iy(i,hy(t,0,-1))}var ix=BP;var GP=Cg(function(i,t,e){rx(i,t,e)}),co=GP;function RP(i,t){return t=Zo(t,i),i=ix(i,t),i==null||delete i[lc(nx(t))]}var ox=RP;function zP(i){return cc(i)?void 0:i}var sx=zP;var FP=1,VP=2,UP=4,jP=uy(function(i,t){var e={};if(i==null)return e;var r=!1;t=Kl(t,function(o){return o=Zo(o,i),r||(r=o.length>1),o}),an(i,mc(i),e),r&&(e=wc(e,FP|VP|UP,sx));for(var n=t.length;n--;)ox(e,t[n]);return e}),os=jP;var ss;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(ss||(ss={}));var uo;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(o){return o.type==="PerspectiveCamera"?o.perspective.zoom:o.orthographic.zoom}n.getZoom=r})(uo||(uo={}));var ax;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]}e.isEqual=i;function t(r,n,o){return[r[0]+(n[0]-r[0])*o,r[1]+(n[1]-r[1])*o]}e.lerp=t})(ax||(ax={}));var as;(n=>{function i(o,a){return o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}n.isEqual=i;function t(o,a){return[o[0]+a[0],o[1]+a[1],o[2]+a[2]]}n.add=t;function e(o,a){return[o[0]-a[0],o[1]-a[1],o[2]-a[2]]}n.sub=e;function r(o,a,c){return[o[0]+(a[0]-o[0])*c,o[1]+(a[1]-o[1])*c,o[2]+(a[2]-o[2])*c]}n.lerp=r})(as||(as={}));var lx;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,o){return[r[0]+(n[0]-r[0])*o,r[1]+(n[1]-r[1])*o,r[2]+(n[2]-r[2])*o,r[3]+(n[3]-r[3])*o]}e.lerp=t})(lx||(lx={}));var Di;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(a,c){for(let f=0;f<16;f++)if(a[f]!==c[f])return!1;return!0}o.isEqual=t;function e(a){return a!=null?a:o.identity}o.simplify=e;function r(a,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3){let m=1/(a[3]*c[h]+a[7]*c[h+1]+a[11]*c[h+2]+a[15]);f[h]=(a[0]*c[h]+a[4]*c[h+1]+a[8]*c[h+2]+a[12])*m,f[h+1]=(a[1]*c[h]+a[5]*c[h+1]+a[9]*c[h+2]+a[13])*m,f[h+2]=(a[2]*c[h]+a[6]*c[h+1]+a[10]*c[h+2]+a[14])*m}return f}o.applyMatrix4=r;function n(a,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3)f[h]=a[0]*c[h]+a[4]*c[h+1]+a[8]*c[h+2],f[h+1]=a[1]*c[h]+a[5]*c[h+1]+a[9]*c[h+2],f[h+2]=a[2]*c[h]+a[6]*c[h+1]+a[10]*c[h+2];return f}o.applyMatrix3Components=n})(Di||(Di={}));var qr;(f=>{f.white={r:1,g:1,b:1},f.red={r:1,g:0,b:0},f.black={r:0,g:0,b:0};function r(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}f.toRgb255a1=r;function n(h){return{r:h.r,g:h.g,b:h.b}}f.clone=n;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}f.fromHex=o;function a(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}f.equals=a;function c(h,d,m){return{r:h.r+(d.r-h.r)*m,g:h.g+(d.g-h.g)*m,b:h.b+(d.b-h.b)*m}}f.lerp=c})(qr||(qr={}));var Gn;(a=>{a.white=ue(j({},qr.white),{a:1});function t(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}a.from0to1=t;function e(c,f){return ue(j({},qr.fromHex(c)),{a:f})}a.fromHexAndA=e;function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}a.toRgb255a1=r;function n(c,f){return qr.equals(c,f)&&c.a===f.a}a.equals=n;function o(c,f,h){return{r:c.r+(f.r-c.r)*h,g:c.g+(f.g-c.g)*h,b:c.b+(f.b-c.b)*h,a:c.a+(f.a-c.a)*h}}a.lerp=o})(Gn||(Gn={}));var Cc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Cc||(Cc={}));var cx;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(cx||(cx={}));var ux;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(ux||(ux={}));var Lc;(t=>{function i(e,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(e[0],e[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[e[0]+e[0]*r,0,0]},grid:{count:[2,2,2],size:e.map(n=>n*(1+r)),useCenter:!0}}}t.defaultData=i})(Lc||(Lc={}));var ln=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let o=ue(j({},r),{[t]:e});return Object.setPrototypeOf(o,ln.prototype),o}}add(t,e){var n;let r=this.runOp({type:1,id:t,data:e});return(n=r==null?void 0:r.data)!=null?n:this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:o,data:a}=t,c=ue(j({},e),{[o]:a});return Object.setPrototypeOf(c,ln.prototype),{data:c,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let o=j({},e);return Object.setPrototypeOf(o,ln.prototype),delete o[r],{data:o,actual:t,reverse:{type:1,id:r,data:n}}}}throw new Error("illegal arg")}};function da(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&da(r)}return Object.freeze(i)}function fx(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Tc=class extends Error{};function Rn(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let o=i;i=t,t=o}let r=[],n=1/(e+1);for(let o=0;o<e;o++){let a=i+(t-i)*(o+.75+Math.random()*.5)*n;r.push(a)}return r}function hx(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function px(){return typeof process<"u"}function dx(i,t){for(let e of i)t(e.id,e.data),dx(e.children,t)}function mx(i,t){t(i.id,i.data);for(let e of i.children)mx(e,t)}var cn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,cn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)da(this[e]),e++}fillCaches0(e,r){var n;if((n=this.objCaches)!=null&&n.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}isDescendantOf(e,r){for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}data(e){var r;return(r=this.get(e))==null?void 0:r.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var r;return e===null?this:(r=this.get(e))==null?void 0:r.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let n=this.get(e);n&&mx(n,r)}}traverse(e){dx(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),a=this.childrenArray(o),c=a.findIndex(d=>d.id===e);if(c<0)throw new Error("not expected");let f=a[c];return a=[...a],a[c]=ue(j({},f),{data:r}),this.modifyArrayBy(o,a)}}modifyArrayBy(e,r){let n=e,o=r;for(;n!==null;){let c=o,f=n;if(n=this.parent(n),n===void 0)throw new Error;o=this.childrenArray(n);let h=o.findIndex(d=>d.id===f);if(h<0)throw new Error;o=[...o],o[h]=ue(j({},o[h]),{children:c})}Object.setPrototypeOf(o,cn.prototype);let a=o;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}}addOp(e){let{parent:r,fi:n,id:o,data:a,children:c}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.get(o)!==void 0)return null;{let f=r,h=this.childrenArray(f),d={fi:n,id:o,data:a,children:c};return h=[...h,d],h.sort((x,S)=>x.fi-S.fi),e.localIndex=h.indexOf(d),{data:this.modifyArrayBy(f,h),actual:e,reverse:{type:8,id:o}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let o=this.childrenArray(n),a=o.findIndex(h=>h.id===r);e.localIndex=a,o=[...o];let c=o.splice(a,1)[0];return{data:this.modifyArrayBy(n,o),actual:e,reverse:ue(j({type:7},c),{parent:n})}}}moveOp(e){let{parent:r,fi:n,id:o}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:o});if(r!==null){let S=r;for(;S!==null;){if(S===void 0)throw new Error;if(S===o)throw new Tc("cyclic tree");S=this.parent(S)}}let a=this.parent(o);if(a===void 0)return null;let c=a,f=this.childrenArray(a),h=f.findIndex(S=>S.id===o);f=[...f];let d=f.splice(h,1)[0],m=this.modifyArrayBy(a,f);a=r,f=m.childrenArray(a);let x=d.fi;return d=ue(j({},d),{fi:n}),f=[...f,d],f.sort((S,w)=>S.fi-w.fi),e.localIndex=f.indexOf(d),m=m.modifyArrayBy(a,f),{data:m,actual:e,reverse:{type:9,parent:c,fi:x,id:o}}}previous(e,r){if(r===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let n=null;for(let o of this.childrenArray(e)){if(o.id===r)return n;n=o.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),o=n.findIndex(a=>a.id===e)+1;if(o<n.length)return n[o].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),o=n.findIndex(a=>a.id===e)-1;return o>=0?this.traverseSortPrevious(n[o].id):r}}getAllSorted(e){let r=[];for(let n of e){let o=this.getWithSortKey(n.id);o!==void 0&&r.push(j(j({},n),o))}r.sort((n,o)=>fx(n.sortKey,o.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],o=this.get(r),a=o;if(o!==void 0){for(;r;)n.splice(0,0,o.fi),r=this.parent(r),r!==null&&(o=this.get(r));return ue(j({},a),{sortKey:n})}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let o=this.childrenArray(e);if(r===null){if(o.length===0)return Rn(0,n,n);{let a=o[0].fi;return Rn(a-n,a,n)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let c=o.find(f=>f.fi>a.fi);if(c===void 0){let f=o[o.length-1].fi;return Rn(f,f+n,n)}else return Rn(a.fi,c.fi,n)}}};var Nc;(t=>{function i(e,r){if(Array.isArray(e)){let n=r.props,o={},a=[...e],c=!1;if(n)for(let f of Object.keys(n)){let h=parseInt(f);if(isNaN(h))throw new Error("wrong index");o[f]=a[h],a[h]=n[f],c=!0}return c?{data:a,actual:r,reverse:{type:0,props:o}}:null}else{let n=r.props,o={},a=j({},e),c=!1;if(n)for(let f of Object.keys(n)){o[f]=a[f];let h=n[f];h===void 0?delete a[f]:a[f]=h,c=!0}return c?{data:a,actual:r,reverse:{type:0,props:o}}:null}}t.runOp=i})(Nc||(Nc={}));var At=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,At.prototype)}deepFreeze(){let e=0;for(;e<this.length;)da(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){var r;return(r=this.get(e))==null?void 0:r.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,a=o.findIndex(h=>h.id===e);if(a<0)throw new Error("not expected");let c=o[a];return o=[...o],o[a]=ue(j({},c),{data:r}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,At.prototype);let r=e;return px()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}}addOp(e){let{fi:r,id:n,data:o}=e,a=this,c={fi:r,id:n,data:o};return a=[...a,c],a.sort((h,d)=>h.fi-d.fi),e.localIndex=a.indexOf(c),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,o=n.findIndex(f=>f.id===r);if(o===-1)return null;e.localIndex=o,n=[...n];let a=n.splice(o,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:j({type:4},a)}}moveOp(e){let{fi:r,id:n}=e,o=this;o=[...o];let a=o.findIndex(d=>d.id===n);if(a===-1)return null;let c=o[a].fi,f=ue(j({},o[a]),{fi:r});return o[a]=f,o.sort((d,m)=>d.fi-m.fi),e.localIndex=o.indexOf(f),{data:this.modifyArrayBy(o),actual:e,reverse:{type:6,fi:c,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return Rn(0,r,r);{let o=n[0].fi;return Rn(o-r,o,r)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let a=n.find(c=>c.fi>o.fi);if(a===void 0){let c=n[n.length-1].fi;return Rn(c,c+r,r)}else return Rn(o.fi,a.fi,r)}}};var gx=Symbol(),Ic=Symbol(),ls=class{reportOp(t,e){let r=this;if(e===null)return;r._current=e.data;let n=[];for(;!(r instanceof _c);){let o=r._path,a=r._current;if(o!==""&&n.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(n,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ic];r&&r(),delete this._children[t]}}}},rh=class extends ls{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=ue(j({},this._current),{[t]:e})}runOp(t){this.reportOp(t,Nc.runOp(this._current,t))}},nh=class extends ls{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current=ue(j({},this._current),{[t]:e}),Object.setPrototypeOf(this._current,ln.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},yx={get(i,t){if(t===Ic)return()=>{i._parent=null};if(t===gx)return i._current;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let o=e[t],a=Oc(i,t,o);return a!==o?(r===void 0&&(r={},i._children=r),r[t]=a,a):o},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},kP=ue(j({},yx),{set(i,t,e){var n;let r={type:0,props:{[t]:(n=sh(e))!=null?n:e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}}),HP=ue(j({},yx),{set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}}),cs=class extends ls{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ic]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){var c;let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let o=(c=e.get(t))==null?void 0:c.data,a=Oc(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}add(t,e,r,n,o){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:o})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,n[o],a.id,a.data,a.children)}}insertBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,n[o],a.id,a.data,a.children)}}moveAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,n[o],a)}}moveBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,n[o],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},us=class extends ls{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ic]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id;t(this.data(this._current[r].id),n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return ue(j({},this._current.get(t)),{data:this.data(t)})}data(t){var c;let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let o=(c=e.get(t))==null?void 0:c.data,a=Oc(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.add(r[n],o.id,o.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.add(r[n],o.id,o.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.move(r[n],o)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.move(r[n],o)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function th(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Mc.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push(ue(j({},t),{path:e}))}var _c=class{constructor(t){this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,n){th(this.ts,e,t),th(this.actual,r,t),th(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Oc(i,t,e){return e instanceof cn?new cs(i,t,e):e instanceof At?new us(i,t,e):e instanceof ln?new Proxy(new nh(i,t,e),HP):e!==null&&typeof e=="object"?hx(e)?e:new Proxy(new rh(i,t,e),kP):e}function ih(i){let t=new _c(i);return[Oc(t,"",i),t]}function oh(i,t){let[e,r]=ih(i);return t(e),r.result()}function sh(i){return i instanceof cs||i instanceof us?i._current:i!==null&&typeof i=="object"?i[gx]:i}var Mc;(r=>{function i(n,o){if(o.length===n.length)for(var a=0;a<n.length;){if(n[a]!==o[a])return!1;a+=1}else return!1;return!0}r.equal=i;function t(n,o,a){let c=e(a,n);if(c!==void 0&&typeof c=="object"&&c!==null){let f=j({},o);return Object.keys(c).forEach(h=>{delete f[h]}),f}else return o}r.removeOverridden=t;function e(n,o,a=0){if(o.length<=a)return n;if((n instanceof cn||n instanceof cs)&&typeof o[a]=="string")return e(n.data(o[a]),o,a+1);if((n instanceof At||n instanceof us)&&typeof o[a]=="string")return e(n.data(o[a]),o,a+1);if(typeof o[a]=="number"&&Array.isArray(n))return e(n[o[a]],o,a+1);if(typeof o[a]=="string"&&typeof n=="object")return e(n[o[a]],o,a+1)}r.zoom=e})(Mc||(Mc={}));var Pc=class{},ma=class extends Pc{constructor(e){super();this.id=e}},ga=class extends Pc{constructor(e){super();this.data=e}};var lh;try{lh=new TextDecoder}catch{}var ye,Bi,D=0;var Tx=[],ch=Tx,uh=0,Dr={},it,Ei,un=0,zn=0,$r,li,wr=[],ct,xx={useRecords:!1,mapsAsObjects:!0},ya=class{},hh=new ya;hh.name="MessagePack 0xC1";var fs=!1,Fn=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(ye)return Mx(()=>(Dc(),this?this.unpack(t,e):Fn.prototype.unpack.call(xx,t,e)));Bi=e>-1?e:t.length,D=0,uh=0,zn=0,Ei=null,ch=Tx,$r=null,ye=t;try{ct=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw ye=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Fn){if(Dr=this,this.structures)return it=this.structures,Ac();(!it||it.length>0)&&(it=[])}else Dr=xx,(!it||it.length>0)&&(it=[]);return Ac()}unpackMultiple(t,e){let r,n=0;try{fs=!0;let o=t.length,a=this?this.unpack(t,o):Gc.unpack(t,o);if(e){for(e(a);D<o;)if(n=D,e(Ac())===!1)return}else{for(r=[a];D<o;)n=D,r.push(Ac());return r}}catch(o){throw o.lastPosition=n,o.values=r,o}finally{fs=!1,Dc()}}_mergeStructures(t,e){t=t||[];for(let r=0,n=t.length;r<n;r++){let o=t[r];o&&(o.isShared=!0,r>=32&&(o.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],o=e[r];o&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=o)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ac(){try{if(!Dr.trusted&&!fs){let t=it.sharedLength||0;t<it.length&&(it.length=t)}let i=Et();if(D==Bi)it.restoreStructures&&vx(),it=null,ye=null,li&&(li=null);else if(D>Bi){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!fs)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw it.restoreStructures&&vx(),Dc(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function vx(){for(let i in it.restoreStructures)it[i]=it.restoreStructures[i];it.restoreStructures=null}function Et(){let i=ye[D++];if(i<160)if(i<128){if(i<64)return i;{let t=it[i&63]||Dr.getStructures&&Nx()[i&63];return t?(t.read||(t.read=ph(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Dr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[Ix()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}else if(i<192){let t=i-160;if(zn>=D)return Ei.slice(D-un,(D+=t)-un);if(zn==0&&Bi<140){let e=t<16?dh(t):_x(t);if(e!=null)return e}return fh(t)}else{let t;switch(i){case 192:return null;case 193:return $r?(t=Et(),t>0?$r[1].slice($r.position1,$r.position1+=t):$r[0].slice($r.position0,$r.position0-=t)):hh;case 194:return!1;case 195:return!0;case 196:return ah(ye[D++]);case 197:return t=ct.getUint16(D),D+=2,ah(t);case 198:return t=ct.getUint32(D),D+=4,ah(t);case 199:return fo(ye[D++]);case 200:return t=ct.getUint16(D),D+=2,fo(t);case 201:return t=ct.getUint32(D),D+=4,fo(t);case 202:if(t=ct.getFloat32(D),Dr.useFloat32>2){let e=Bc[(ye[D]&127)<<1|ye[D+1]>>7];return D+=4,(e*t+(t>0?.5:-.5)>>0)/e}return D+=4,t;case 203:return t=ct.getFloat64(D),D+=8,t;case 204:return ye[D++];case 205:return t=ct.getUint16(D),D+=2,t;case 206:return t=ct.getUint32(D),D+=4,t;case 207:return Dr.int64AsNumber?(t=ct.getUint32(D)*4294967296,t+=ct.getUint32(D+4)):t=ct.getBigUint64(D),D+=8,t;case 208:return ct.getInt8(D++);case 209:return t=ct.getInt16(D),D+=2,t;case 210:return t=ct.getInt32(D),D+=4,t;case 211:return Dr.int64AsNumber?(t=ct.getInt32(D)*4294967296,t+=ct.getUint32(D+4)):t=ct.getBigInt64(D),D+=8,t;case 212:if(t=ye[D++],t==114)return Lx(ye[D++]&63);{let e=wr[t];if(e)return e.read?(D++,e.read(Et())):e.noBuffer?(D++,e()):e(ye.subarray(D,++D));throw new Error("Unknown extension "+t)}case 213:return t=ye[D],t==114?(D++,Lx(ye[D++]&63,ye[D++])):fo(2);case 214:return fo(4);case 215:return fo(8);case 216:return fo(16);case 217:return t=ye[D++],zn>=D?Ei.slice(D-un,(D+=t)-un):qP(t);case 218:return t=ct.getUint16(D),D+=2,zn>=D?Ei.slice(D-un,(D+=t)-un):$P(t);case 219:return t=ct.getUint32(D),D+=4,zn>=D?Ei.slice(D-un,(D+=t)-un):JP(t);case 220:return t=ct.getUint16(D),D+=2,Sx(t);case 221:return t=ct.getUint32(D),D+=4,Sx(t);case 222:return t=ct.getUint16(D),D+=2,wx(t);case 223:return t=ct.getUint32(D),D+=4,wx(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var WP=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ph(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(o=>WP.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"}}")(Et);return i.highByte===0&&(i.read=bx(t,i.read)),n()}let r={};for(let n=0,o=i.length;n<o;n++){let a=i[n];r[a]=Et()}return r}return e.count=0,i.highByte===0?bx(t,e):e}var bx=(i,t)=>function(){let e=ye[D++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=it[r]||Nx()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=ph(n,i)),n.read()};function Nx(){let i=Mx(()=>(ye=null,Dr.getStructures()));return it=Dr._mergeStructures(i,it)}var fh=Ec,qP=Ec,$P=Ec,JP=Ec;function Ec(i){let t;if(i<16&&(t=dh(i)))return t;if(i>64&&lh)return lh.decode(ye.subarray(D,D+=i));let e=D+i,r=[];for(t="";D<e;){let n=ye[D++];if((n&128)===0)r.push(n);else if((n&224)===192){let o=ye[D++]&63;r.push((n&31)<<6|o)}else if((n&240)===224){let o=ye[D++]&63,a=ye[D++]&63;r.push((n&31)<<12|o<<6|a)}else if((n&248)===240){let o=ye[D++]&63,a=ye[D++]&63,c=ye[D++]&63,f=(n&7)<<18|o<<12|a<<6|c;f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|f&1023),r.push(f)}else r.push(n);r.length>=4096&&(t+=er.apply(String,r),r.length=0)}return r.length>0&&(t+=er.apply(String,r)),t}function Sx(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}function wx(i){if(Dr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[Ix()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}}var er=String.fromCharCode;function _x(i){let t=D,e=new Array(i);for(let r=0;r<i;r++){let n=ye[D++];if((n&128)>0){D=t;return}e[r]=n}return er.apply(String,e)}function dh(i){if(i<4)if(i<2){if(i===0)return"";{let t=ye[D++];if((t&128)>1){D-=1;return}return er(t)}}else{let t=ye[D++],e=ye[D++];if((t&128)>0||(e&128)>0){D-=2;return}if(i<3)return er(t,e);let r=ye[D++];if((r&128)>0){D-=3;return}return er(t,e,r)}else{let t=ye[D++],e=ye[D++],r=ye[D++],n=ye[D++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){D-=4;return}if(i<6){if(i===4)return er(t,e,r,n);{let o=ye[D++];if((o&128)>0){D-=5;return}return er(t,e,r,n,o)}}else if(i<8){let o=ye[D++],a=ye[D++];if((o&128)>0||(a&128)>0){D-=6;return}if(i<7)return er(t,e,r,n,o,a);let c=ye[D++];if((c&128)>0){D-=7;return}return er(t,e,r,n,o,a,c)}else{let o=ye[D++],a=ye[D++],c=ye[D++],f=ye[D++];if((o&128)>0||(a&128)>0||(c&128)>0||(f&128)>0){D-=8;return}if(i<10){if(i===8)return er(t,e,r,n,o,a,c,f);{let h=ye[D++];if((h&128)>0){D-=9;return}return er(t,e,r,n,o,a,c,f,h)}}else if(i<12){let h=ye[D++],d=ye[D++];if((h&128)>0||(d&128)>0){D-=10;return}if(i<11)return er(t,e,r,n,o,a,c,f,h,d);let m=ye[D++];if((m&128)>0){D-=11;return}return er(t,e,r,n,o,a,c,f,h,d,m)}else{let h=ye[D++],d=ye[D++],m=ye[D++],x=ye[D++];if((h&128)>0||(d&128)>0||(m&128)>0||(x&128)>0){D-=12;return}if(i<14){if(i===12)return er(t,e,r,n,o,a,c,f,h,d,m,x);{let S=ye[D++];if((S&128)>0){D-=13;return}return er(t,e,r,n,o,a,c,f,h,d,m,x,S)}}else{let S=ye[D++],w=ye[D++];if((S&128)>0||(w&128)>0){D-=14;return}if(i<15)return er(t,e,r,n,o,a,c,f,h,d,m,x,S,w);let B=ye[D++];if((B&128)>0){D-=15;return}return er(t,e,r,n,o,a,c,f,h,d,m,x,S,w,B)}}}}}function ah(i){return Dr.copyBuffers?Uint8Array.prototype.slice.call(ye,D,D+=i):ye.subarray(D,D+=i)}function fo(i){let t=ye[D++];if(wr[t])return wr[t](ye.subarray(D,D+=i));throw new Error("Unknown extension type "+t)}var Cx=new Array(4096);function Ix(){let i=ye[D++];if(i>=160&&i<192){if(i=i-160,zn>=D)return Ei.slice(D-un,(D+=i)-un);if(!(zn==0&&Bi<180))return fh(i)}else return D--,Et();let t=(i<<5^(i>1?ct.getUint16(D):i>0?ye[D]:0))&4095,e=Cx[t],r=D,n=D+i-3,o,a=0;if(e&&e.bytes==i){for(;r<n;){if(o=ct.getUint32(r),o!=e[a++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(o=ye[r++],o!=e[a++]){r=1879048192;break}if(r===n)return D=r,e.string;n-=3,r=D}for(e=[],Cx[t]=e,e.bytes=i;r<n;)o=ct.getUint32(r),e.push(o),r+=4;for(n+=3;r<n;)o=ye[r++],e.push(o);let c=i<16?dh(i):_x(i);return c!=null?e.string=c:e.string=fh(i)}var Lx=(i,t)=>{var e=Et();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=it[i];return n&&n.isShared&&((it.restoreStructures||(it.restoreStructures=[]))[i]=n),it[i]=e,e.read=ph(e,r),e.read()},Ox=typeof self=="object"?self:global;wr[0]=()=>{};wr[0].noBuffer=!0;wr[101]=()=>{let i=Et();return(Ox[i[0]]||Error)(i[1])};wr[105]=i=>{let t=ct.getUint32(D-4);li||(li=new Map);let e=ye[D],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};li.set(t,n);let o=Et();return n.used?Object.assign(r,o):(n.target=o,o)};wr[112]=i=>{let t=ct.getUint32(D-4),e=li.get(t);return e.used=!0,e.target};wr[115]=()=>new Set(Et());var mh=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");wr[116]=i=>{let t=i[0],e=mh[t];if(!e)throw new Error("Could not find typed array for code "+t);return new Ox[e](Uint8Array.prototype.slice.call(i,1).buffer)};wr[120]=()=>{let i=Et();return new RegExp(i[0],i[1])};wr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=D;D+=t-4,$r=[Et(),Et()],$r.position0=0,$r.position1=0;let r=D;D=e;try{return Et()}finally{D=r}};wr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function Mx(i){let t=Bi,e=D,r=uh,n=un,o=zn,a=Ei,c=ch,f=li,h=$r,d=new Uint8Array(ye.slice(0,Bi)),m=it,x=it.slice(0,it.length),S=Dr,w=fs,B=i();return Bi=t,D=e,uh=r,un=n,zn=o,Ei=a,ch=c,li=f,$r=h,ye=d,fs=w,it=m,it.splice(0,it.length,...x),Dr=S,ct=new DataView(ye.buffer,ye.byteOffset,ye.byteLength),B}function Dc(){ye=null,li=null,it=null}function Px(i){i.unpack?wr[i.type]=i.unpack:wr[i.type]=i}var Bc=new Array(147);for(let i=0;i<256;i++)Bc[i]=+("1e"+Math.floor(45.15-i*.30103));var Gc=new Fn({useRecords:!1}),KP=Gc.unpack,YP=Gc.unpackMultiple,XP=Gc.unpack,Rc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},ZP=new Float32Array(1),d4=new Uint8Array(ZP.buffer,0,4);var zc;try{zc=new TextEncoder}catch{}var Fc,yh,Vc=typeof Buffer<"u",gh=Vc?Buffer.allocUnsafeSlow:Uint8Array,Bx=Vc?Buffer:Uint8Array,Ax=Vc?4294967296:2144337920,X,zt,z=0,Vn,Un=null,QP=/[\u0080-\uFFFF]/,xa=Symbol("record-id"),ho=class extends Fn{constructor(t){super(t),this.offset=0;let e,r,n,o,a,c,f=0,h=Bx.prototype.utf8Write?function(b,V,P){return X.utf8Write(b,V,P)}:zc&&zc.encodeInto?function(b,V){return zc.encodeInto(b,X.subarray(V)).written}:!1,d=this;t||(t={});let m=t&&t.sequential,x=t.structures||t.saveStructures,S=t.maxSharedStructures;if(S==null&&(S=x?32:0),S>8160)throw new Error("Maximum maxSharedStructure is 8160");let w=t.maxOwnStructures;w==null&&(w=x?32:64),m&&!t.saveStructures&&(this.structures=[]);let B=S>32||w+S>64,O=S+64,T=S+w+64;if(T>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let M=[],F=0,k=0;this.pack=this.encode=function(b,V){if(X||(X=new gh(8192),zt=new DataView(X.buffer,0,8192),z=0),Vn=X.length-10,Vn-z<2048?(X=new gh(X.length),zt=new DataView(X.buffer,0,X.length),Vn=X.length-10,z=0):z=z+7&2147483640,r=z,c=d.structuredClone?new Map:null,d.bundleStrings?(Un=["",""],X[z++]=214,X[z++]=98,Un.position=z-r,z+=4):Un=null,n=d.structures,n){n.uninitialized&&(n=d._mergeStructures(d.getStructures()));let P=n.sharedLength||0;if(P>S)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let R=0;R<P;R++){let E=n[R];if(!E)continue;let G,ae=n.transitions;for(let ne=0,xe=E.length;ne<xe;ne++){let _e=E[ne];G=ae[_e],G||(G=ae[_e]=Object.create(null)),ae=G}ae[xa]=R+64}f=P}m||(n.nextId=P+64)}o&&(o=!1),a=n||[];try{if(N(b),Un){zt.setUint32(Un.position+r,z-Un.position-r);let P=Un;Un=null,N(P[0]),N(P[1])}if(d.offset=z,c&&c.idsToInsert){z+=c.idsToInsert.length*6,z>Vn&&A(z),d.offset=z;let P=tA(X.subarray(r,z),c.idsToInsert);return c=null,P}return V&Rx?(X.start=r,X.end=z,X):X.subarray(r,z)}finally{if(n){if(k<10&&k++,F>1e4)n.transitions=null,k=0,F=0,M.length>0&&(M=[]);else if(M.length>0&&!m){for(let P=0,R=M.length;P<R;P++)M[P][xa]=0;M=[]}if(o&&d.saveStructures){let P=n.sharedLength||S;n.length>P&&(n=n.slice(0,P));let R=X.subarray(r,z);return d.saveStructures(n,f)===!1?(d._mergeStructures(d.getStructures()),d.pack(b)):(f=P,R)}}V&lA&&(z=r)}};let N=b=>{z>Vn&&(X=A(z));var V=typeof b,P;if(V==="string"){let R=b.length;if(Un&&R>=8&&R<4096){let ae=QP.test(b);Un[ae?0:1]+=b,X[z++]=193,N(ae?-R:R);return}let E;R<32?E=1:R<256?E=2:R<65536?E=3:E=5;let G=R*3;if(z+G>Vn&&(X=A(z+G)),R<64||!h){let ae,ne,xe,_e=z+E;for(ae=0;ae<R;ae++)ne=b.charCodeAt(ae),ne<128?X[_e++]=ne:ne<2048?(X[_e++]=ne>>6|192,X[_e++]=ne&63|128):(ne&64512)===55296&&((xe=b.charCodeAt(ae+1))&64512)===56320?(ne=65536+((ne&1023)<<10)+(xe&1023),ae++,X[_e++]=ne>>18|240,X[_e++]=ne>>12&63|128,X[_e++]=ne>>6&63|128,X[_e++]=ne&63|128):(X[_e++]=ne>>12|224,X[_e++]=ne>>6&63|128,X[_e++]=ne&63|128);P=_e-z-E}else P=h(b,z+E,G);P<32?X[z++]=160|P:P<256?(E<2&&X.copyWithin(z+2,z+1,z+1+P),X[z++]=217,X[z++]=P):P<65536?(E<3&&X.copyWithin(z+3,z+2,z+2+P),X[z++]=218,X[z++]=P>>8,X[z++]=P&255):(E<5&&X.copyWithin(z+5,z+3,z+3+P),X[z++]=219,zt.setUint32(z,P),z+=4),z+=P}else if(V==="number")if(b>>>0===b)b<64?X[z++]=b:b<256?(X[z++]=204,X[z++]=b):b<65536?(X[z++]=205,X[z++]=b>>8,X[z++]=b&255):(X[z++]=206,zt.setUint32(z,b),z+=4);else if(b>>0===b)b>=-32?X[z++]=256+b:b>=-128?(X[z++]=208,X[z++]=b+256):b>=-32768?(X[z++]=209,zt.setInt16(z,b),z+=2):(X[z++]=210,zt.setInt32(z,b),z+=4);else{let R;if((R=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){X[z++]=202,zt.setFloat32(z,b);let E;if(R<4||(E=b*Bc[(X[z]&127)<<1|X[z+1]>>7])>>0===E){z+=4;return}else z--}X[z++]=203,zt.setFloat64(z,b),z+=8}else if(V==="object")if(!b)X[z++]=192;else{if(c){let E=c.get(b);if(E){if(!E.id){let G=c.idsToInsert||(c.idsToInsert=[]);E.id=G.push(E)}X[z++]=214,X[z++]=112,zt.setUint32(z,E.id),z+=4;return}else c.set(b,{offset:z-r})}let R=b.constructor;if(R===Object)te(b,!0);else if(R===Array){P=b.length,P<16?X[z++]=144|P:P<65536?(X[z++]=220,X[z++]=P>>8,X[z++]=P&255):(X[z++]=221,zt.setUint32(z,P),z+=4);for(let E=0;E<P;E++)N(b[E])}else if(R===Map){P=b.size,P<16?X[z++]=128|P:P<65536?(X[z++]=222,X[z++]=P>>8,X[z++]=P&255):(X[z++]=223,zt.setUint32(z,P),z+=4);for(let[E,G]of b)N(E),N(G)}else{for(let E=0,G=Fc.length;E<G;E++){let ae=yh[E];if(b instanceof ae){let ne=Fc[E];if(ne.write){ne.type&&(X[z++]=212,X[z++]=ne.type,X[z++]=0),N(ne.write.call(this,b));return}let xe=X,_e=zt,Le=z;X=null;let Ue;try{Ue=ne.pack.call(this,b,se=>(X=xe,xe=null,z+=se,z>Vn&&A(z),{target:X,targetView:zt,position:z-se}),N)}finally{xe&&(X=xe,zt=_e,z=Le,Vn=X.length-10)}Ue&&(Ue.length+z>Vn&&A(Ue.length+z),z=eA(Ue,X,z,ne.type));return}}te(b,!b.hasOwnProperty)}}else if(V==="boolean")X[z++]=b?195:194;else if(V==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))X[z++]=211,zt.setBigInt64(z,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)X[z++]=207,zt.setBigUint64(z,b);else if(this.largeBigIntToFloat)X[z++]=203,zt.setFloat64(z,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");z+=8}else if(V==="undefined")this.encodeUndefinedAsNil?X[z++]=192:(X[z++]=212,X[z++]=0,X[z++]=0);else if(V==="function")N(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+V)},te=this.useRecords===!1?this.variableMapSize?b=>{let V=Object.keys(b),P=V.length;P<16?X[z++]=128|P:P<65536?(X[z++]=222,X[z++]=P>>8,X[z++]=P&255):(X[z++]=223,zt.setUint32(z,P),z+=4);let R;for(let E=0;E<P;E++)N(R=V[E]),N(b[R])}:(b,V)=>{X[z++]=222;let P=z-r;z+=2;let R=0;for(let E in b)(V||b.hasOwnProperty(E))&&(N(E),N(b[E]),R++);X[P+++r]=R>>8,X[P+r]=R&255}:b=>{let V=Object.keys(b),P,R=a.transitions||(a.transitions=Object.create(null)),E=0;for(let ae=0,ne=V.length;ae<ne;ae++){let xe=V[ae];P=R[xe],P||(P=R[xe]=Object.create(null),E++),R=P}let G=R[xa];if(G)G>=96&&B?(X[z++]=((G-=96)&31)+96,X[z++]=G>>5):X[z++]=G;else{G=a.nextId,G||(G=64),G<O&&this.shouldShareStructure&&!this.shouldShareStructure(V)?(G=a.nextOwnId,G<T||(G=O),a.nextOwnId=G+1):(G>=T&&(G=O),a.nextId=G+1);let ae=V.highByte=G>=96&&B?G-96>>5:-1;R[xa]=G,a[G-64]=V,G<O?(V.isShared=!0,a.sharedLength=G-63,o=!0,ae>=0?(X[z++]=(G&31)+96,X[z++]=ae):X[z++]=G):(ae>=0?(X[z++]=213,X[z++]=114,X[z++]=(G&31)+96,X[z++]=ae):(X[z++]=212,X[z++]=114,X[z++]=G),E&&(F+=k*E),M.length>=w&&(M.shift()[xa]=0),M.push(R),N(V))}for(let ae=0,ne=V.length;ae<ne;ae++)N(b[V[ae]])},A=b=>{let V;if(b>16777216){if(b-r>Ax)throw new Error("Packed buffer would be larger than maximum buffer size");V=Math.min(Ax,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else V=(Math.max(b-r<<2,X.length-1)>>12)+1<<12;let P=new gh(V);return zt=new DataView(P.buffer,0,V),X.copy?X.copy(P,0,r,b):P.set(X.slice(r,b)),z-=r,r=0,Vn=P.length-10,X=P}}useBuffer(t){X=t,zt=new DataView(X.buffer,X.byteOffset,X.byteLength),z=0}};yh=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ya];Fc=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:o,position:a}=t(6);n[a++]=214,n[a++]=255,o.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:n,targetView:o,position:a}=t(10);n[a++]=215,n[a++]=255,o.setUint32(a,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),o.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:n,targetView:o,position:a}=t(3);n[a++]=212,n[a++]=255,n[a++]=255}else{let{target:n,targetView:o,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,o.setUint32(a,i.getMilliseconds()*1e6),o.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(n[o++]=212,n[o++]=115,n[o++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?Dx(i,16,t):Ex(Vc?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==Bx&&this.structuredClone?Dx(i,mh.indexOf(e.name),t):Ex(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function Dx(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:o,position:a}=e(4+n);o[a++]=199,o[a++]=n+1}else if(n+1<65536){var{target:o,position:a}=e(5+n);o[a++]=200,o[a++]=n+1>>8,o[a++]=n+1&255}else{var{target:o,position:a,targetView:c}=e(7+n);o[a++]=201,c.setUint32(a,n+1),a+=4}o[a++]=116,o[a++]=t,o.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function Ex(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:o}=t(e+5);r[n++]=198,o.setUint32(n,e),n+=4}r.set(i,n)}function eA(i,t,e,r){let n=i.length;switch(n){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function tA(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((o,a)=>o.offset>a.offset?1:-1);e=t.pop();){let o=e.offset,a=e.id;i.copyWithin(o+r,o,n),r-=6;let c=o+r;i[c++]=214,i[c++]=105,i[c++]=a>>24,i[c++]=a>>16&255,i[c++]=a>>8&255,i[c++]=a&255,n=o}return i}function po(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");yh.unshift(i.Class),Fc.unshift(i)}Px(i)}var Gx=new ho({useRecords:!1}),rA=Gx.pack,nA=Gx.pack;var{NEVER:iA,ALWAYS:oA,DECIMAL_ROUND:sA,DECIMAL_FIT:aA}=Rc,Rx=512,lA=1024;var zx=new ho({structuredClone:!0});po({Class:ln.prototype.constructor,type:1,write(i){return j({},i)},read(i){return Object.setPrototypeOf(i,ln.prototype),i}});po({Class:At.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,At.prototype),i}});po({Class:cn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,cn.prototype),i}});po({Class:ma.prototype.constructor,type:4,write(i){return i.id},read(i){return new ma(i)}});po({Class:ga.prototype.constructor,type:5,write(i){return i.data},read(i){return new ga(i)}});function cA(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}var Uc;(r=>{function i(n){return zx.pack(n)}r.serialize=i;function t(n){return zx.unpack(n)}r.deserialize=t;function e(n){return cA(i(n)).toString()}r.checksum=e})(Uc||(Uc={}));var jc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(jc||(jc={}));var kc;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Gn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:Gn.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:Gn.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(kc||(kc={}));var xh;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(xh||(xh={}));var vh;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(vh||(vh={}));var Hc;(t=>t.defaultData=ue(j(j({},vh.defaultData),xh.defaultData),{cloner:null}))(Hc||(Hc={}));var bh=(n=>(n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Center=3]="Center",n[n.Justify=4]="Justify",n))(bh||{}),Sh=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Sh||{}),wh=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(wh||{}),Wc;(t=>t.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:Gn.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(Wc||(Wc={}));var hs;(r=>{function i(n,o){return n==="light"&&o?t(o):e(n)}r.defaultData=i;function t(n){switch(n){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function e(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:qr.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:ue(j({},qr.fromHex(6710886)),{a:1}),colorB:ue(j({},qr.fromHex(6710886)),{a:1}),colorC:ue(j({},qr.fromHex(16777215)),{a:1}),colorD:ue(j({},qr.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:Gn.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(hs||(hs={}));var ps;(c=>{function i(f){return!f.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!e(f)}c.isMergable=i;function t(f){let h="";return f.layers.forEach(d=>{Object.entries(d.data).forEach(([m,x])=>{h+=`${m}${x}`,Array.isArray(x)?x.forEach(S=>h+=`${S}`):typeof x=="object"?Object.values(x).forEach(S=>{typeof S=="number"?h+=`${S.toFixed(4)}`:h+=`${S}`}):h+=`${x}`})}),h}c.getHash=t;function e(f){let h=0;for(let d of f.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(h+=(1-h)*d.data.alpha);return h<1}c.isTransparent=e;function r(){return{layers:new At}}c.defaultEmptyData=r;function n(f="layer1",h="layer2"){return o("phong",f,h)}c.defaultData=n;function o(f,h="layer1",d="layer2"){let m=new At;return m.push({fi:0,data:hs.defaultData("light",f),id:h}),m.push({fi:1,data:hs.defaultData("color"),id:d}),{layers:m}}c.defaultTwoLayerData=o;function a(f,h="basic",d="layer1",m="layer2"){let x=hs.defaultData("texture");Object.assign(x.texture,{image:f});let S=new At;return S.push({fi:0,data:x,id:d}),S.push({fi:1,data:hs.defaultData("light",h),id:m}),{layers:S}}c.defaultTwoLayerTextureData=a})(ps||(ps={}));var ds;(r=>{function i(){return{points:new At,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function t(n,o){let{points:a}=o;if(a){for(let c of a)if(c.data.position[0]===n[0]&&c.data.position[1]===n[1])return!0}return!1}r.isOverlappingExistingPoint=t;function e(n,o){let a=n.controlNext,c=o.controlPrevious;return n.position[0]===a.position[0]&&n.position[1]===a.position[1]&&o.position[0]===c.position[0]&&o.position[1]===c.position[1]}r.isStraightLine=e})(ds||(ds={}));var qc;(t=>{function i(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=i})(qc||(qc={}));var $c;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(e==="VectorGeometry")return{width:100,height:100,type:e,subdivisions:12,shape:ds.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}t.defaultData=i})($c||($c={}));var va;(n=>{n.identity=ue(j({},Cc.identity),{hiddenMatrix:Di.identity});function t(o){return{position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix}}n.fromObject=t;function e(o,a){return{position:(a==null?void 0:a.position)||o.position,rotation:(a==null?void 0:a.rotation)||o.rotation,scale:(a==null?void 0:a.scale)||o.scale,hiddenMatrix:(a==null?void 0:a.hiddenMatrix)||o.hiddenMatrix}}n.merge=e;function r(o,a){return{position:as.isEqual(o.position,a.position)?null:a.position,rotation:as.isEqual(o.rotation,a.rotation)?null:a.rotation,scale:as.isEqual(o.scale,a.scale)?null:a.scale,hiddenMatrix:Di.isEqual(o.hiddenMatrix,a.hiddenMatrix)?null:a.hiddenMatrix}}n.diff=r})(va||(va={}));var Gi;(t=>t.defaultData=j({states:new At,events:new At,visible:!0,raycastLock:!1},va.identity))(Gi||(Gi={}));var Fx;(t=>t.defaultData=j({type:"Empty"},Gi.defaultData))(Fx||(Fx={}));var Ch;(t=>t.defaultData=j(j({type:"Mesh"},Gi.defaultData),Hc.defaultData))(Ch||(Ch={}));var Vx;(t=>t.defaultData=j(j({type:"TextFrame"},Gi.defaultData),Wc.defaultData))(Vx||(Vx={}));var Jc;(t=>t.defaultData=j(j(j({},Gi.defaultData),va.identity),uo.defaultData))(Jc||(Jc={}));var Ux;(t=>{function i(e){return j(j({},Gi.defaultData),kc.defaultData(e))}t.defaultData=i})(Ux||(Ux={}));var jx;(e=>(e.defaultCamera=j({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Di.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new At,events:new At},uo.defaultData),e.defaultMeshObject=ue(j(j({name:"Rectangle"},Gi.defaultData),Ch.defaultData),{geometry:$c.defaultData("RectangleGeometry"),material:ps.defaultTwoLayerData("basic","layer1","layer2")})))(jx||(jx={}));var kx;(e=>{function i(r,n){if(n===void 0)return r;let o=j({},r);return"material"in o&&"material"in n&&n.material&&(o.material=oh(o.material,a=>{if(typeof a!="string")for(let[c,f]of Object.entries(n.material.layers)){let h=a.layers.data(c);h&&co(h,f)}}).data),o.materials&&n.materials&&(o.materials=oh(o.materials,a=>{var c,f;for(let h=0;h<o.materials.length;h++){let d=n.materials[h];if(typeof d!="string")for(let[m,x]of Object.entries(d.layers)){let S=(f=(c=a[h])==null?void 0:c.layers)==null?void 0:f.data(m);S&&co(S,x)}}}).data),o}e.patchMaterialState=i;function t(r,n){var a,c;if(n===void 0)return r;let o=j({},r);if(Object.assign(o,va.merge(o,n)),ss.is(r.type)){o.orthographic=j({},o.orthographic),o.perspective=j({},o.perspective);let f=n;((a=f.orthographic)==null?void 0:a.zoom)!==void 0&&(o.orthographic.zoom=f.orthographic.zoom),((c=f.perspective)==null?void 0:c.zoom)!==void 0&&(o.perspective.zoom=f.perspective.zoom)}else if(r.type==="Mesh")o.geometry=j({},o.geometry),Object.assign(o.geometry,n.geometry),o=i(o,n);else if(jc.is(r.type)){let f=n;o.intensity!==void 0&&(o.intensity=f.intensity),f.color!==void 0&&(typeof f.color=="string"?o.color=f.color:o.color=qr.clone(f.color))}return o}e.patch=t})(kx||(kx={}));import{DoubleSide as uA,Mesh as fA,MeshBasicMaterial as hA,ShapeBufferGeometry as pA,Vector2 as dA,Vector3 as mA}from"three";import{FontLoader as gA}from"three/examples/jsm/loaders/FontLoader.js";var Ft=class extends fA{constructor({char:e,originalChar:r,fontFamily:n,letterSpacing:o,fontSize:a,LOD:c=16},f=new hA({color:0,opacity:1,visible:!0,transparent:!0,side:uA})){let h=Ft.loadChar(e,n,c);super(h.geometry,f);this.char=e,this.originalChar=r!=null?r:e,this.fontFamily=n,this.letterSpacing=o,this.fontSize=a,this.LOD=c,this.resolution=h.resolution,this.glyphsHa=h.glyphsHa,this.localPosition=new dA,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Ft._fontPath}static set FONTS_PATH(e){Ft._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let n=new mA(this.localPosition.x,-this.localPosition.y,0);this.position.copy(n).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=Ft.loadChar(this.char,e,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let r=Ft.loadChar(e,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let r=Ft.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Ft(e).copy(this)}static loadFont(e){return new Promise(function(r,n){Ft.fontCache[e]?r(Ft.fontCache[e]):new gA().load(Ft.FONTS_PATH+e+".json",a=>{Ft.fontCache[e]=a,r(a)},void 0,n)})}static loadChar(e,r,n){if(Ft.charCache[e]){if(Ft.charCache[e][n]&&Ft.charCache[e][n].fontFamily===r)return Ft.charCache[e][n]}else Ft.charCache[e]={};let o=Ft.fontCache[r],a=o.generateShapes(e,1);return Ft.charCache[e][n]={geometry:new pA(a,n),fontFamily:r,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Ft.charCache[e][n]}},Cr=Ft;Cr.charCache={},Cr.fontCache={},Cr._fontPath="/_assets/_fonts/";import{DoubleSide as Bu,MeshBasicMaterial as Ov,Vector3 as Mv,Object3D as l3}from"three";import{Mesh as F2}from"three";import{BufferGeometry as Ej,ConeBufferGeometry as vA,Float32BufferAttribute as Bj,Vector2 as Gj,Vector3 as Rj}from"three";import{BufferGeometry as yA,CylinderBufferGeometry as xA,Float32BufferAttribute as Lh,Vector2 as Cn,Vector3 as Kc}from"three";var Wx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var a,c,f,h,d;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=e.width/2,n=(c=e.radiusTop)!=null?c:r,o=(f=e.radiusBottom)!=null?f:r;return n===o?(n=r,o=r):n>o?(n=r,o=o*r/n):(n=n*r/o,o=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((h=e.height)!=null?h:e.width),depth:Math.abs((d=e.depth)!=null?d:e.width),radiusTop:n,radiusBottom:o})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:c,thetaLength:f,radiusTop:h,radiusBottom:d,cornerRadius:m,cornerSegments:x,hollow:S}=i.parameters,w;return m||S?w=new ba(h,d,r,n,o,a,c,f*Math.PI/180,m,m,x,S):w=new xA(h,d,r,n,o,a,c,f*Math.PI/180),w.scale(1,1,e/t),Object.assign(w,{userData:ue(j({},i),{type:"CylinderGeometry"})})}};function Ri(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Hx(i){return new Cn(i.y,-i.x)}var ba=class extends yA{constructor(t,e,r,n,o,a,c,f,h,d,m,x,S=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,o=Math.floor(o)||1,a=a!==void 0?a:!1,c=c!==void 0?c:0,f=f!==void 0?f:Math.PI*2,a&&(h=0,d=0);let w=[],B=[],O=[],T=[],M=0,F=r/2,k=new Kc,N=new Kc;S&&t==0&&(t=h),S&&e==0&&(e=d);let te=new Cn(t,F),A=new Cn(e,-F),b=null,V=null,P=null,R=null,E=te.clone().sub(A),G=0,ae=0,ne=0;x>0&&(G=Math.min(t,e)*(1-x),ae=t-G,ne=e-G);let xe=te.clone();xe.x-=G;let _e=Math.PI-E.angle(),Le=E.angle(),Ue=Math.tan(Le/2),se=Math.tan(_e/2),$=Ue+se,W=x?$:se,J=x?$:Ue;if(h=Math.min(h,(t-ae)/W,E.length()/$),d=Math.min(d,(e-ne)/J,E.length()/$),h>0){let re=h/Ue;b=te.clone().sub(new Cn(re,h)),x&&(P=b.clone(),P.x-=G-$*h),te.sub(E.clone().setLength(re))}if(d>0){let re=d/se;V=A.clone().sub(new Cn(re,-d)),A.add(E.clone().setLength(re)),x&&(R=V.clone(),R.x-=G-$*d,xe.sub(E.clone().setLength(re)))}E=te.clone().sub(A);let H=E.length()<.5,K=[];for(let re=0;re<=n;re++){let q=[],ee=re/n,Te=ee*f+c,ce=new Cn(Math.sin(Te),Math.cos(Te));R&&V?(fe(q,ee,ce,_e,d,R,-1,!0),fe(q,ee,ce,Le,d,V,-1,!1)):V?(me(q,ce,V.x,0,-1),fe(q,ee,ce,Le,d,V,-1,!1)):a||me(q,ce,e,ne,-1);let le=Hx(E).normalize();if(Ri(le,ce,k),!H)for(let he=0;he<=o;he++){let pe=he/o,de=E.clone().multiplyScalar(pe).add(A);Ri(de,ce,N),B.push(N.x,N.y,N.z),O.push(k.x,k.y,k.z),T.push(ee,.5+N.y/r),q.push(M++)}if(P&&b?(fe(q,ee,ce,_e,h,b,1,!1),fe(q,ee,ce,Le,h,P,1,!0)):b?(fe(q,ee,ce,_e,h,b,1,!1),me(q,ce,b.x,0,1)):a||me(q,ce,t,ae,1),x&&!H){let he=Hx(E).multiplyScalar(-1).normalize();Ri(he,ce,k);for(let pe=0;pe<=o;pe++){let de=pe/o,be=E.clone().multiplyScalar(-de).add(xe);Ri(be,ce,N),B.push(N.x,N.y,N.z),O.push(k.x,k.y,k.z),T.push(ee,.5+N.y/r),q.push(M++)}}x&&!a&&q.push(q[0]),K.push(q)}for(let re=0;re<K.length-1;re++)for(let q=0;q<K[0].length-1;q++){if(a&&x&&q==o)continue;let ee=K[re][q],Te=K[re+1][q],ce=K[re+1][q+1],le=K[re][q+1],he=B[ce*3+0],pe=B[ce*3+2];w.push(ee,Te,le),(he!=0||pe!=0)&&w.push(Te,ce,le)}f<Math.PI*2&&(ie(-1,K[0],c),ie(1,K[K.length-1],c+f)),this.setIndex(w),this.setAttribute("position",new Lh(B,3)),this.setAttribute("normal",new Lh(O,3)),this.setAttribute("uv",new Lh(T,2));function fe(re,q,ee,Te,ce,le,he,pe){for(let de=0;de<m+1;de++){let be=de/m,Se=he<0?be:1-be;pe&&(Se-=1),Se*=Te;let Ie=new Cn(Math.sin(Se),Math.cos(Se)*he),ft=Ie.clone().multiplyScalar(ce).add(le);Ri(ft,ee,N),B.push(N.x,N.y,N.z),Ri(Ie,ee,k),O.push(k.x,k.y,k.z),T.push(q,.5+N.y/r),re.push(M++)}}function me(re,q,ee,Te,ce){let le=new Kc,he=new Cn,pe=[ee,Te];ce<0&&pe.reverse();for(let de of pe)he.set(de,F*ce),Ri(he,q,le),B.push(le.x,le.y,le.z),O.push(0,ce,0),T.push(.5,.5),re.push(M++)}function ie(re,q,ee){let Te=new Cn(Math.sin(ee),Math.cos(ee)),ce=new Cn(-Math.cos(ee),Math.sin(ee)),le=new Kc,he=re<0?(be,Se,Ie)=>w.push(be,Se,Ie):(be,Se,Ie)=>w.push(be,Ie,Se),pe=new Cn((t+e+ae+ne)/4,0);Ri(pe,Te,le),B.push(le.x,le.y,le.z),O.push(ce.x,0,ce.y),T.push(.5,.5);let de=M++;for(let be of q){let Se=B.slice(be*3,be*3+3);B.push(...Se),O.push(ce.x,0,ce.y);let Ie=T.slice(be*2,be*2+2);T.push(...Ie),M++}for(let be=de+1;be<M-1;be++)he(de,be,be+1);he(de,M-1,de+1)}}};var qx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:c,thetaLength:f,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:m}=i.parameters,x;return h>0||d>0||f<360?x=new ba(0,t/2,r,n,o,a,c,f*Math.PI/180,h,d,m,0,!0):x=new vA(t/2,r,n,o,a),x.scale(1,1,e/t),Object.assign(x,{userData:ue(j({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as bA,BufferGeometry as SA,Float32BufferAttribute as Th,Vector3 as Sa}from"three";var $x=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:o,depthSegments:a,cornerRadius:c,cornerSegments:f}=i.parameters,h;return c==0?h=new bA(t,e,r,n,o,a):h=new _h(t,e,r,n,o,a,c,f),Object.assign(h,{userData:ue(j({},i),{type:"CubeGeometry"})})}},Nh=Math.PI/2,_h=class extends SA{constructor(t=1,e=1,r=1,n=1,o=1,a=1,c=0,f=4){super(),this.type="BoxBufferGeometry";let h=this;n=Math.floor(n),o=Math.floor(o),a=Math.floor(a),f=Math.floor(f),c=Math.min(c,t/2,e/2,r/2);let d=[],m=[],x=[],S=[],w=0,B=0;O("z","y","x",-1,-1,r,e,t,a,o,0),O("z","y","x",1,-1,r,e,-t,a,o,1),O("x","z","y",1,1,t,r,e,n,a,2),O("x","z","y",1,-1,t,r,-e,n,a,3),O("x","y","z",1,-1,t,e,r,n,o,4),O("x","y","z",-1,-1,t,e,-r,n,o,5),c>0&&(T("z","y","x",-1,-1,1,r,e,t,a,0),T("z","y","x",1,-1,-1,r,e,t,a,1),T("z","y","x",-1,1,-1,r,e,t,a,1),T("z","y","x",1,1,1,r,e,t,a,0),T("x","y","z",-1,-1,-1,t,e,r,n,0),T("x","y","z",1,-1,1,t,e,r,n,1),T("x","y","z",-1,1,1,t,e,r,n,0),T("x","y","z",1,1,-1,t,e,r,n,1),T("y","x","z",-1,-1,1,e,t,r,o,0),T("y","x","z",1,-1,-1,e,t,r,o,1),T("y","x","z",1,1,1,e,t,r,o,1),T("y","x","z",-1,1,-1,e,t,r,o,0),M(1,1,1),M(-1,1,1),M(1,-1,1),M(-1,-1,1),M(1,1,-1),M(-1,1,-1),M(1,-1,-1),M(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new Th(m,3)),this.setAttribute("normal",new Th(x,3)),this.setAttribute("uv",new Th(S,2));function O(F,k,N,te,A,b,V,P,R,E,G){let ae=(b-2*c)/R,ne=(V-2*c)/E,xe=b/2-c,_e=V/2-c,Le=P/2,Ue=R+1,se=E+1,$=0,W=0,J=new Sa;for(let H=0;H<se;H++){let K=H*ne-_e;for(let fe=0;fe<Ue;fe++){let me=fe*ae-xe;J[F]=me*te,J[k]=K*A,J[N]=Le,m.push(J.x,J.y,J.z),J[F]=0,J[k]=0,J[N]=P>0?1:-1,x.push(J.x,J.y,J.z),S.push(fe/R),S.push(1-H/E),$+=1}}for(let H=0;H<E;H++)for(let K=0;K<R;K++){let fe=w+K+Ue*H,me=w+K+Ue*(H+1),ie=w+(K+1)+Ue*(H+1),re=w+(K+1)+Ue*H;d.push(fe,me,re),d.push(me,ie,re),W+=6}h.addGroup(B,W,G),B+=W,w+=$}function T(F,k,N,te,A,b,V,P,R,E,G){let ae=(V-2*c)/E,ne=V/2-c,xe=P/2-c,_e=R/2,Le=E+1,Ue=0,se=0,$=new Sa,W=new Sa;for(let J=0;J<f+1;J++){let H=J/f*Nh,K=Math.sin(H)*c,fe=(1-Math.cos(H))*c,me=Math.sin(H),ie=Math.cos(H);$[k]=(xe+K)*A,$[N]=(_e-fe)*b,W[F]=0,W[k]=me*Math.sign($[k]),W[N]=ie*Math.sign($[N]);for(let re=0;re<Le;re++){let q=re*ae-ne;$[F]=q*te,m.push($.x,$.y,$.z),x.push(W.x,W.y,W.z),S.push(re/E),S.push(0),Ue+=1}}for(let J=0;J<f;J++)for(let H=0;H<E;H++){let K=w+H+Le*J,fe=w+H+Le*(J+1),me=w+(H+1)+Le*(J+1),ie=w+(H+1)+Le*J;d.push(K,fe,ie),d.push(fe,me,ie),se+=6}h.addGroup(B,se,G),B+=se,w+=Ue}function M(F,k,N){let te=new Sa,A=new Sa(t/2,e/2,r/2);A.subScalar(c);let b=[],V=F*k*N>0?(R,E,G)=>d.push(R,E,G):(R,E,G)=>d.push(R,G,E);for(let R=0;R<=f;R++){let E=[],G=Nh*(1-R/f),ae=Math.cos(G),ne=Math.sin(G),xe=0;for(let _e=0;_e<=R;_e++){let Le=Math.cos(xe),Ue=Math.sin(xe);te.x=ae*Le,te.y=ne,te.z=ae*Ue;let se=A.clone().addScaledVector(te,c);m.push(F*se.x,k*se.y,N*se.z),x.push(F*te.x,k*te.y,N*te.z),S.push(0,0),E.push(w++),xe+=Nh/R}b.push(E)}let P=b.length-1;for(let R=0;R<P;R++){let E=b[R],G=b[R+1],ae=E.length-1;V(E[0],G[1],G[0]);for(let ne=1;ne<=ae;ne++)V(E[ne-1],E[ne],G[ne]),V(E[ne],G[ne+1],G[ne])}}}};import{BufferGeometry as wA,Float32BufferAttribute as Ih,Triangle as CA,Vector3 as ci,Vector2 as Oh}from"three";var zi=class extends wA{constructor(t=[],e=[],r="",n=1,o=.2,a=4){super(),this.type="PolyhedronGeometryRound";let c=[],f=[],h=[];d(),m(),this.setAttribute("position",new Ih(c,3)),this.setAttribute("normal",new Ih(h,3)),this.setAttribute("uv",new Ih(f,2));return;function d(){var Ue;o=Math.min(1-1e-5,o),o==0&&(a=0);let S={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],w=new ci,B=w.clone(),O=new CA,T=o*n,M=n-T,F=a+1,k=new ci,N=(se,$)=>k.subVectors(se,$).normalize(),te=(se,$)=>Array(se).fill(void 0).map($),A=te(t.length/3,(se,$)=>new ci().fromArray(t,$*3).setLength(n)),b=[],V=1e6;for(let se=0;se<A.length;se++){let $=A[se],W=[],J,H,K,fe=1e10,me=-1;for(;(me=e.indexOf(se,me+1))!=-1;){let ee=me-me%3;J=e[ee+(me+1)%3],H=e[ee+(me+2)%3],K=$.distanceToSquared(A[J]),fe=Math.min(fe,K),W.push([J,H,K])}fe+=1e-6;let ie=[],re=0,q=W.length;for(let ee=0;ee<q;ee++){[J,H,K]=W[re];let Te=((Ue=b[J])==null?void 0:Ue.includes(se))==!0;K<=fe&&ie.push(J+ +Te*V),re=W.findIndex(ce=>ce[0]==H)}b.push(ie)}let P=[];{let se=0,$=0,W,J,H=S==3;for(let K=0;K<=a;K++){W=K*(K+1)/2,J=(K+1)*(K+2)/2;for(let fe=0;fe<a-K;fe++)[se,$]=[W+fe+K+2,J+fe+K+3],P.push(W,J,...H?[$,W]:[se,J],$,se),[W,J]=[se,$];P.push(W,J,W+a+2)}}let R=w.clone(),E=w.clone(),G=w.clone(),ae=w.clone(),ne=w.clone(),xe=[],_e=te(A.length,()=>te(S,()=>w.clone()));for(let se=0;se<A.length;se++){w.copy(A[se]).normalize(),R.copy(w).multiplyScalar(M);let $=b[se];for(let ie=0;ie<$.length;ie++){let re=$[ie],q=$[(ie+1)%S];O.setFromPointsAndIndices(A,se,re%V,q%V),O.b.sub(O.a).setLength(1e10).add(O.a),O.c.sub(O.a).setLength(1e10).add(O.a),O.closestPointToPoint(R,_e[se][ie])}let W=[],J=[],H=[],K=new ci;a==0&&[..._e[se]].reduce((ie,re)=>ie.add(re),K).multiplyScalar(1/S);for(let ie=0;ie<S;ie++){let re=[],q=(ie-1+S)%S,ee=_e[se][q],Te=_e[se][ie];w.copy(ee).sub(R),B.copy(Te).sub(R);let ce=R.angleTo(w),le=w.angleTo(B),he=Math.cos(ce)*T;a==0?E.copy(K):E.copy(R).setLength(M+he),J.push(he);let pe=[E,ee,Te];for(let de=0;de<2;de++){let be=pe[de],Se=pe[de+1];ae.subVectors(be,R),ne.subVectors(Se,R),G.crossVectors(ae,ne).normalize();for(let Ie=0;Ie<F;Ie++){let ft=[ce,le][de]*Ie/F;w.copy(ae).applyAxisAngle(G,ft).add(R),W.push(w.clone()),de&&(N(w,R),re.push([Ie==0?be:w.clone(),k.clone()]))}de&&(N(Se,R),re.push([Se,k.clone()]))}H.push(re)}xe.push(H);let fe=2*F,me=2;for(let ie=0;ie<S;ie++){let re=fe*ie,q=fe*((ie+1)%S),ee=[W[re]];for(let ce=1;ce<F;ce++){ae=W[re+ce],ne=W[q+ce],ee.push(ae);for(let le=1,he=ce-me+1;le<=he;le++)w.lerpVectors(ae,ne,le/(he+1)),w.sub(R).setLength(J[ie]).add(R),ee.push(w.clone());ee.push(ne)}for(let ce=0;ce<F;ce++)ee.push(W[ce+F+re]);ee.push(W[q+F]);let Te=P.map(ce=>ee[ce]);c.push(...Te.map(ce=>[ce.x,ce.y,ce.z]).flat()),h.push(...Te.map(ce=>(N(ce,R),[k.x,k.y,k.z])).flat())}}let Le=[];for(let se=0;se<b.length;se++)for(let $=0;$<S;$++){let W=b[se][$];if(W<V){let J=b[W].findIndex(fe=>fe%V==se),H=xe[se][$],K=xe[W][J];for(let fe=0;fe<F;fe++){let me=H[fe],ie=K[F-fe],re=H[fe+1],q=K[F-(fe+1)];[me,ie,re,re,ie,q].forEach(ee=>{c.push(ee[0].x,ee[0].y,ee[0].z),h.push(ee[1].x,ee[1].y,ee[1].z)})}Le.push(H[0][0],K[F][0],H[F][0],K[0][0])}}for(;Le.length;){let se,$,W,J;[se,$]=Le.splice(0,2);let H=[se];for(;se!=$;)H.push($),W=Le.indexOf($),J=W%2,$=Le.splice(W-J,2)[1-J];k.subVectors(H[0],H[1]).cross(w.subVectors(H[0],H[2])).normalize();let K=k.dot(H[0])<0;K&&k.negate();for(let fe=1;fe<=H.length-2;fe++)[H[fe+ +K],H[fe+1-+K],H[0]].forEach(me=>{c.push(me.x,me.y,me.z),h.push(k.x,k.y,k.z)})}}function m(){let x=new ci;for(let A=0;A<c.length;A+=3){x.x=c[A+0],x.y=c[A+1],x.z=c[A+2];let b=N(x)/2/Math.PI+.5,V=te(x)/Math.PI+.5;f.push(b,1-V)}let S=new ci,w=new ci,B=new ci,O=new ci,T=new Oh,M=new Oh,F=new Oh,k=(A,b,V,P)=>{P<0&&A.x===1&&(f[b]=A.x-1),V.x===0&&V.z===0&&(f[b]=P/2/Math.PI+.5)};for(let A=0,b=0;A<c.length;A+=9,b+=6){S.set(c[A+0],c[A+1],c[A+2]),w.set(c[A+3],c[A+4],c[A+5]),B.set(c[A+6],c[A+7],c[A+8]),T.set(f[b+0],f[b+1]),M.set(f[b+2],f[b+3]),F.set(f[b+4],f[b+5]),O.copy(S).add(w).add(B).divideScalar(3);let V=N(O);k(T,b+0,S,V),k(M,b+2,w,V),k(F,b+4,B,V)}for(let A=0;A<f.length;A+=6){let b=f[A+0],V=f[A+2],P=f[A+4],R=Math.max(b,V,P),E=Math.min(b,V,P);R>.9&&E<.1&&(b<.2&&(f[A+0]+=1),V<.2&&(f[A+2]+=1),P<.2&&(f[A+4]+=1))}function N(A){return Math.atan2(A.z,-A.x)}function te(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new zi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronBufferGeometry as LA}from"three";var Jx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,c=n===0&&o!==0?new wa(t*.5,o,a):new LA(t*.5,n);return c.scale(1,e/t,r/t),Object.assign(c,{userData:ue(j({},i),{type:"DodecahedronGeometry"})})}},wa=class extends zi{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=1/n,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-o,-n,0,-o,n,0,o,-n,0,o,n,-o,-n,0,-o,n,0,o,-n,0,o,n,0,-n,0,-o,n,0,-o,-n,0,o,n,0,o],c=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],f="DodecahedronGeometry";super(a,c,f,t,e,r),this.type=f}static fromJSON(t){return new wa(t.radius,t.corner,t.cornerSides)}};import{EventDispatcher as BA,Plane as GA,Shape as s0,Vector2 as ui,Vector3 as RA,MathUtils as Gh,LineCurve as Rh,QuadraticBezierCurve as a0,CubicBezierCurve as Zc}from"three";import{CubicBezierCurve as Yc,EllipseCurve as TA,LineCurve as Xc,LineCurve3 as NA,MathUtils as _A,QuadraticBezierCurve as Mh,SplineCurve as IA,Vector2 as Ln,Vector3 as Kx}from"three";var Ca=1e-12,ms=class{constructor(t){this.position=new Ln;this.startPosition=new Ln;this.uuid=_A.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new ms(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},gs=class extends ms{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new gs(this.parent).copy(this)}},Tn=class extends ms{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new gs(this),new gs(this))}static create(e,r){let n=new Tn(e,new Ln(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,o=this.controls.length;n<o;n++){let a=this.controls[n];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Tn(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},Ph=i=>i,Ta=new Ln,Ah=new Ln,OA=new Ln,MA=new Ln,PA=new Ln,AA=new Ln,Yx=new Kx,Xx=new Kx;function Zx(i){let t=new Ln;t.addVectors(i.v0,Ta.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Ln;return e.addVectors(i.v2,Ah.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Yc(i.v0,t,e,i.v2)}function La(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function DA(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function EA(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Dh(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-o*o)/(2*n*r))}function Qx(i,t,e,r,n){let o=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,c=(i.x+t.x)/2,f=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(i.y-t.y)/o,h=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-i.x)/o;return r.set(c+f,a+h),n.set(c-f,a-h),[r,n]}function e0(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function t0(i,t,e,r,n,o){let a=t.x-i.x,c=t.y-i.y,f=e.x-i.x,h=e.y-i.y,d=Math.sqrt((a+f)*(a+f)+(c+h)*(c+h)),m;return Dh(t,i,e)>Math.PI&&(d*=-1),La(h,c)?m=(c+h)*(r/d-.5)*8/3/(a-f):m=(a+f)*(r/d-.5)*8/3/(h-c),n.set(t.x-m*c,t.y+m*a),o.set(e.x+m*h,e.y-m*f),[n,o]}function Eh(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function r0(i,t,e,r,n=.5){let o=Ta.subVectors(t,i).multiplyScalar(n).add(i),a=Ah.subVectors(e,t).multiplyScalar(n).add(t),c=OA.subVectors(r,e).multiplyScalar(n).add(e),f=o,h=MA.subVectors(a,o).multiplyScalar(n).add(o),d=PA.subVectors(c,a).multiplyScalar(n).add(a),m=c,x=AA.subVectors(d,h).multiplyScalar(n).add(h);return[i.x,i.y,f.x,f.y,h.x,h.y,x.x,x.y,d.x,d.y,m.x,m.y,r.x,r.y]}function n0(i,t,e=12,r=!0){let n=Xx.set(0,0,0),o,a=0,c=[];for(let f=0;f<t.length;f++){let h=Ph(t[f]),d=Ta,m=Fi(h,e);c.push(m);for(let x=0;x<=m;x++)if(h instanceof Yc||h instanceof Mh||h instanceof Xc){if(h.getPoint(x/m,d),n.set(d.x,d.y,0),o!==void 0&&EA(o,n))continue;o===void 0&&(o=Yx),o.copy(n),i.setXYZ(a,n.x,n.y,n.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function i0(i,t,e,r=12,n=!0){let o=Xx.set(0,0,0),a=0,c=[];for(let f=0;f<t.length;f++){if(e[f]===!1)continue;let h,d=Ph(t[f]),m=Ta,x=Fi(d,r);c.push(x);for(let S=0;S<=x;S++)if(d instanceof Yc||d instanceof Mh||d instanceof Xc){if(d.getPoint(S/x,m),o.set(m.x,m.y,0),h!=null&&h.equals(o))continue;h===void 0?h=Yx:(i.setXYZ(a,h.x,h.y,h.z),a++,i.setXYZ(a,o.x,o.y,o.z),a++),h.copy(o)}}return n&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),c}function Bh(i,t=12,e=!1){let r=[];for(let n=0,o=i.length;n<o;n++){let a=i[n],c=0;if(e&&a.roundedCurveCorner!==void 0){let f=Fi(a.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=f),c+=f}a.curveAfter!==void 0&&(c+=Fi(a.curveAfter,t)),r.push(c)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Fi(i[0].roundedCurveCorner,t)*.5),r}function Fi(i,t=12){return i&&i instanceof TA?t*2:i&&(i instanceof Xc||i instanceof NA)?1:i&&i instanceof IA?t*i.points.length:t}function o0(i,t,e=12,r=!0){let n,o=0;for(let a=0;a<t.length;a++){let c=Ph(t[a]),f=Fi(c,e),h=Ta;for(let d=0;d<=f;d++)if(c instanceof Yc||c instanceof Mh||c instanceof Xc){if(c.getPoint(d/f,h),n!==void 0&&DA(n,h,Ca))continue;n===void 0&&(n=Ah),n.copy(h),i.push(h.x,h.y),o++}}return La(i[0],i[i.length-2],Ca)&&La(i[1],i[i.length-1],Ca)&&(i.pop(),i.pop()),r&&o>1&&!(La(i[o-1],i[1],Ca)&&La(i[o-2],i[0],Ca))&&(i.push(i[0],i[1]),o++),i}var zh=new ui,zA=new ui,FA=new ui,VA=new ui,UA=new ui,jA=new ui,nt=class extends s0{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new BA;this.plane=new GA(new RA(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Gh.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let o=new nt;return o.isClosed=e.isClosed,o.points=e.points.map(a=>Tn.create(a.id,a.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(a=>nt.createFromState(a)),r!==void 0&&n!==void 0&&o.applySize(r,n),o.update(),o}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){return this.points.findIndex(r=>r.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let r=0,n=this.shapeHoles.length;r<n;r++){let o=this.shapeHoles[r],a=e-this.points.length;if(a<=o.points.length-1)return o.points[a]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,o=this.shapeHoles.length;n<o;n++){let a=this.shapeHoles[n],c=a.points.indexOf(e);if(c>=0)return r+c;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=zh.set(e,r);for(let o=0,a=this.points.length;o<a;o++){let c=this.points[o];c.position.multiply(n),c.controls[0].position.multiply(n),c.controls[1].position.multiply(n)}for(let o=0,a=this.shapeHoles.length;o<a;o++)this.shapeHoles[o].applyScale(e,r);this._update(!1)}createPoint(e,r=0,n=Gh.generateUUID()){let o;e instanceof ui?o=e:o=new ui(e,r);let a=new Tn(n,o);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let o=this.points[r];if(o.uuid===e)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(e=!0){for(let r=0,n=this.shapeHoles.length;r<n;r++)this.shapeHoles[r].update(!1);this._update(e)}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=n?this.roundedCurveDivisions:this.curveDivisions;return n0(e,n?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((a,c)=>a+c,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Bh(this.points,e,!1),this.roundedCurveDivisions=Bh(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return i0(e,this.curves,r,n,this.autoClose).reduce((a,c)=>a+c,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),o0(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=Fi(this.points[0].roundedCurveCorner,this.subdivision)*.5);let c=e-a;c<0&&(c+=o.reduce((f,h)=>f+h,0));for(let f=0,h=o.length;f<h;f++){let d=o[f];if(c<n+d)return[f,(c-n+1)/d];n+=d}return[0,1]}getCurveT(e,r,n){let o=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],c=this.curveDivisions,f=c[e];if(Eh(o,a)){let m=o.position.distanceTo(a.position);return o.position.distanceTo(zh.set(n.x,n.y))/m}let h=0;for(let m=0;m<e;m++)h+=c[m];return(r-h)/f}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,r){Eh(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let o=n.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var n;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,a=this.points.length;o<a;o++){let c=this.points[o];if(o===0)this.moveTo(c.position.x,c.position.y);else{let f=this.points[o-1];this._applyCurveForPoint(c,f)}}let r=this.getLastPoint();if(r!=null&&r.curveAfter&&(r.curveAfter=void 0),this.isClosed){let o=this.points[0],a=this.points[this.points.length-1];this._applyCurveForPoint(o,a)}if(this.points.length>2){let o=0;for(let a=0,c=this.points.length;a<c;a++){let f=this.points[a],h=f.roundness;if(!f.controlsMoved()&&h>0){let d=f.curveBefore,m=f.curveAfter;if(d===void 0||m===void 0)continue;let x=f.roundedCurveBefore,S=f.roundedCurveAfter,w=d.getLength(),B=m.getLength(),O=Math.min(h,w*.499),T=Math.min(h,B*.499),M=Math.min(O,T),F=1-M/w,k=M/B,N=d.getPointAt(F,zh),te=m.getPointAt(k,zA);this._subSplitCurve(d,x,F,N,void 0),this._subSplitCurve(m,S,k,void 0,te);let A;if(this.useCubicForRoundedCorners){let b=Dh(N,f.position,te)/2,V=Math.tan(b)*N.distanceTo(f.position),[P,R]=Qx(N,te,V,FA,VA),E=e0(P,R,f.position),[G,ae]=t0(E,N,te,V,UA,jA);A=new Zc(N.clone(),G.clone(),ae.clone(),te.clone())}else A=new a0(N.clone(),f.position.clone(),te.clone());f.roundedCurveCorner=A,this.roundedCurves.splice(a+o,0,A),o++}}}e&&((n=this.eventDispatcher)==null||n.dispatchEvent({type:"update"}))}_subSplitCurve(e,r,n,o,a){if(e instanceof Rh)o!==void 0&&r.v2.copy(o),a!==void 0&&r.v1.copy(a);else{let c=e,f=r,h=c.getUtoTmapping(n,0),d=r0(c.v0,c.v1,c.v2,c.v3,h);return o!==void 0&&(f.v0.set(d[0],d[1]),f.v1.set(d[2],d[3]),f.v2.set(d[4],d[5]),f.v3.set(d[6],d[7])),a!==void 0&&(f.v0.set(d[6],d[7]),f.v1.set(d[8],d[9]),f.v2.set(d[10],d[11]),f.v3.set(d[12],d[13])),f}return r}clone(){let e=new nt(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var n;this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let a=o*7,c=e.points[a+0],f=e.points[a+1],h=e.points[a+2],d=e.points[a+3],m=e.points[a+4],x=e.points[a+5],S=e.points[a+6],w=new Tn(Gh.generateUUID(),new ui(c,f));w.controls[0].position.set(h,d),w.controls[1].position.set(m,x),w.roundness=S,this.points.push(w)}return this.shapeHoles=(n=e.shapeHoles)!=null&&n.length?e.shapeHoles.map(o=>{let a=new nt;return a.fromJSON(o),a}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let r=(o,a)=>{a instanceof Zc&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},n=o=>{let a=[],c,f;for(c=0,f=o.length;c<f;c++)o[c]instanceof a0&&(o[c]=Zx(o[c]));for(c=0,f=o.length;c<f;c++){let m=o[c],x=c>0?o[c-1]:null,S;m instanceof Zc?(S=this.createPoint(m.v0),S.controls[1].position.copy(m.v1)):m instanceof Rh&&(S=this.createPoint(m.v1)),S!==void 0&&(x!==null&&r(S,x),a.push(S))}let h=o[o.length-1],d=!1;return h instanceof Zc?h.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(h.v2),d=!0):h instanceof Rh&&h.v2.equals(a[0].position)&&(d=!0),this.isClosed=d,a};return this.points=n(e.curves),e instanceof s0&&(this.shapeHoles=e.holes.map(o=>{let a=new nt;return a.fromShape(o),a})),this.update(),this}};var Vh=Math.PI*2;function Fh({x:i,y:t},e,r,n,o){return{x:i*e+n,y:t*r+o}}function kA(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),o=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:o+a*e,y:a-o*e},{x:o,y:a}]}function l0(i,t,e,r){let n=i*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(o)}function HA(i,t,e,r,n,o,a,c,f,h){let d=Math.pow(n,2),m=Math.pow(o,2),x=Math.pow(a,2),S=Math.pow(c,2),w=d*m-d*S-m*x;w<0&&(w=0),w/=d*S+m*x,w=Math.sqrt(w)*(f===h?-1:1);let B=w*n/o*c,O=w*-o/n*a,T=B+(i+e)/2,M=O+(t+r)/2,F=(a-B)/n,k=(c-O)/o,N=(-a-B)/n,te=(-c-O)/o,A=l0(1,0,F,k),b=l0(F,k,N,te);return!h&&b>0&&(b-=Vh),h&&b<0&&(b+=Vh),{centerx:T,centery:M,ang1:A,ang2:b}}function c0({px:i,py:t,cx:e,cy:r,rx:n,ry:o,largeArcFlag:a,sweepFlag:c}){let f=[];if(n===0||o===0)return[];let h=(i-e)/2,d=(t-r)/2;if(h===0&&d===0)return[];n=Math.abs(n),o=Math.abs(o);let m=Math.pow(h,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m));let x=HA(i,t,e,r,n,o,h,d,a,c),{ang1:S,ang2:w}=x,{centerx:B,centery:O}=x,T=Math.abs(w)/(Vh/4);Math.abs(1-T)<1e-7&&(T=1);let M=Math.max(Math.ceil(T),1);w/=M;for(let F=0;F<M;F++)f.push(kA(S,w)),S+=w;return f.map(F=>{let{x:k,y:N}=Fh(F[0],n,o,B,O),{x:te,y:A}=Fh(F[1],n,o,B,O),{x:b,y:V}=Fh(F[2],n,o,B,O);return{x1:k,y1:N,x2:te,y2:A,x:b,y:V}})}import{BufferAttribute as eu,BufferGeometry as KA}from"three";var Ot;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ot||(Ot={}));var Kt;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Kt||(Kt={}));function Ae(i,t){if(!i)throw t||"Assertion Failed!"}var Oe=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Ae(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?n<o?e.t-t.t+(t.t-r.t)*(n/(n+o)):e.t-r.t+(r.t-t.t)*(o/(n+o)):0},i.edgeSign=function(t,e,r){Ae(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?(e.t-r.t)*n+(e.t-t.t)*o:0},i.transEval=function(t,e,r){Ae(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?n<o?e.s-t.s+(t.s-r.s)*(n/(n+o)):e.s-r.s+(r.s-t.s)*(o/(n+o)):0},i.transSign=function(t,e,r){Ae(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?(e.s-r.s)*n+(e.s-t.s)*o:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,o){var a,c,f;i.vertLeq(t,e)||(f=t,t=e,e=f),i.vertLeq(r,n)||(f=r,r=n,n=f),i.vertLeq(t,r)||(f=t,t=r,r=f,f=e,e=n,n=f),i.vertLeq(r,e)?i.vertLeq(e,n)?(a=i.edgeEval(t,r,e),c=i.edgeEval(r,e,n),a+c<0&&(a=-a,c=-c),o.s=i.interpolate(a,r.s,c,e.s)):(a=i.edgeSign(t,r,e),c=-i.edgeSign(t,n,e),a+c<0&&(a=-a,c=-c),o.s=i.interpolate(a,r.s,c,n.s)):o.s=(r.s+e.s)/2,i.transLeq(t,e)||(f=t,t=e,e=f),i.transLeq(r,n)||(f=r,r=n,n=f),i.transLeq(t,r)||(f=t,t=r,r=f,f=e,e=n,n=f),i.transLeq(r,e)?i.transLeq(e,n)?(a=i.transEval(t,r,e),c=i.transEval(r,e,n),a+c<0&&(a=-a,c=-c),o.t=i.interpolate(a,r.t,c,e.t)):(a=i.transSign(t,r,e),c=-i.transSign(t,n,e),a+c<0&&(a=-a,c=-c),o.t=i.interpolate(a,r.t,c,n.t)):o.t=(r.t+e.t)/2},i}(),Na=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Qc=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),ys=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),u0=function(){function i(){var t=new ys,e=new Na,r=new Qc(0),n=new Qc(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new Qc(0),r=new Qc(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;Ae(n,"Vertex can't be null!");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e;var a=e;do a.Org=n,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;Ae(n,"Face can't be null");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var a=e;do a.Lface=n,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.makeEdge=function(){var t=new ys,e=new ys,r=new Na,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var o=new ys;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var a=new Na;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var n=new Na;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new ys;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),o=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(o,e),n.Org=t.Dst,o.Org=e.Org,n.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var a=new Na;this.makeFace_(a,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,o,a,c;n=e.Lnext;do r=n,n=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,c=t.next,c.prev=a,a.next=c},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,o,a,c,f;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;n=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(c=this.countFaceVerts_(e),f=this.countFaceVerts_(o.Lface),c+f-2<=t&&Oe.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&Oe.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(n=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===a);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,o,a,c,f,h;for(o=t,o=t;(n=o.next)!==t;o=n){Ae(n.prev===o),f=n.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Lface===n),f=f.Lnext;while(f!==n.anEdge)}for(Ae(n.prev===o&&n.anEdge===null),c=e,c=e;(a=c.next)!==e;c=a){Ae(a.prev===c),f=a.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Org===a),f=f.Onext;while(f!==a.anEdge)}for(Ae(a.prev===c&&a.anEdge===null),h=r,h=r;(f=h.next)!==r;h=f)Ae(f.Sym.next===h.Sym),Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Org!==null),Ae(f.Dst!==null),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f);Ae(f.Sym.next===h.Sym&&f.Sym===this.eHeadSym&&f.Sym.Sym===f&&f.Org===null&&f.Dst===null&&f.Lface===null&&f.Rface===null)},i}(),f0=function(){function i(){this.handle=null}return i}(),h0=function(){function i(){this.key=null,this.node=0}return i}(),WA=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new f0,this.handles[r]=new h0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Ae(a<=this.max),o=e[a].handle,a>this.size||this.leq(r[n].key,r[o].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t>>1,o=e[a].handle,a===0||this.leq(r[o].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,o;for(o=this.nodes.length,this.nodes.length=this.max+1,n=o;n<this.nodes.length;n++)this.nodes[n]=new f0;for(o=this.handles.length,this.handles.length=this.max+1,n=o;n<this.handles.length;n++)this.handles[n]=new h0}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;Ae(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),Uh=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),p0=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),qA=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new p0,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new p0;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),$A=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,o=e.eUp,a=r.eUp;if(o.Dst===n)return a.Dst===n?Oe.vertLeq(o.Org,a.Org)?Oe.edgeSign(a.Dst,o.Org,a.Org)<=0:Oe.edgeSign(o.Dst,a.Org,o.Org)>=0:Oe.edgeSign(a.Dst,n,a.Org)<=0;if(a.Dst===n)return Oe.edgeSign(o.Dst,n,o.Org)>=0;var c=Oe.edgeEval(o.Dst,n,o.Org),f=Oe.edgeEval(a.Dst,n,a.Org);return c>=f},i.deleteRegion=function(t,e){e.fixUpperEdge&&Ae(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Ae(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new Uh;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case Ot.ODD:return(e&1)!==0;case Ot.NONZERO:return e!==0;case Ot.POSITIVE:return e>0;case Ot.NEGATIVE:return e<0;case Ot.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,o=null,a=e,c=e.eUp;a!==r;){if(a.fixUpperEdge=!1,o=i.regionBelow(a),n=o.eUp,n.Org!=c.Org){if(!o.fixUpperEdge){i.finishRegion(t,a);break}n=t.mesh.connect(c.Lprev,n.Sym),i.fixUpperEdge(t,o,n)}c.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(c,n)),i.finishRegion(t,a),c=o.eUp,a=o}return c},i.addRightEdges=function(t,e,r,n,o,a){var c,f,h,d,m=!0;h=r;do Ae(Oe.vertLeq(h.Org,h.Dst)),i.addRegionBelow(t,e,h.Sym),h=h.Onext;while(h!==n);for(o===null&&(o=i.regionBelow(e).eUp.Rprev),f=e,d=o;c=i.regionBelow(f),h=c.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(d.Oprev,h)),c.windingNumber=f.windingNumber-h.winding,c.inside=i.isWindingInside(t,c.windingNumber),f.dirty=!0,!m&&i.checkForRightSplice(t,f)&&(i.addWinding(h,d),i.deleteRegion(t,f),t.mesh.delete(d)),m=!1,f=c,d=h;f.dirty=!0,Ae(f.windingNumber-h.winding===c.windingNumber),a&&i.walkDirtyRegions(t,f)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Oe.vertL1dist(e,t),o=Oe.vertL1dist(r,t),a=.5*o/(n+o),c=.5*n/(n+o);t.coords[0]+=a*e.coords[0]+c*r.coords[0],t.coords[1]+=a*e.coords[1]+c*r.coords[1],t.coords[2]+=a*e.coords[2]+c*r.coords[2]},i.getIntersectData=function(t,e,r,n,o,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,o,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp;if(Oe.vertLeq(n.Org,o.Org)){if(Oe.edgeSign(o.Dst,n.Org,o.Org)>0)return!1;Oe.vertEq(n.Org,o.Org)?n.Org!==o.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,o.Oprev,n)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(n,o.Oprev),e.dirty=r.dirty=!0)}else{if(Oe.edgeSign(n.Dst,o.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a;if(Ae(!Oe.vertEq(n.Dst,o.Dst)),Oe.vertLeq(n.Dst,o.Dst)){if(Oe.edgeSign(n.Dst,o.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Sym,a),a.Lface.inside=e.inside}else{if(Oe.edgeSign(o.Dst,n.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(n.Lnext,o.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a=n.Org,c=o.Org,f=n.Dst,h=o.Dst,d,m,x=new ys,S,w;if(Ae(!Oe.vertEq(h,f)),Ae(Oe.edgeSign(f,t.event,a)<=0),Ae(Oe.edgeSign(h,t.event,c)>=0),Ae(a!==t.event&&c!==t.event),Ae(!e.fixUpperEdge&&!r.fixUpperEdge),a===c||(d=Math.min(a.t,f.t),m=Math.max(c.t,h.t),d>m))return!1;if(Oe.vertLeq(a,c)){if(Oe.edgeSign(h,a,c)>0)return!1}else if(Oe.edgeSign(f,c,a)<0)return!1;return i.debugEvent(t),Oe.intersect(f,a,h,c,x),Ae(Math.min(a.t,f.t)<=x.t),Ae(x.t<=Math.max(c.t,h.t)),Ae(Math.min(h.s,f.s)<=x.s),Ae(x.s<=Math.max(c.s,a.s)),Oe.vertLeq(x,t.event)&&(x.s=t.event.s,x.t=t.event.t),S=Oe.vertLeq(a,c)?a:c,Oe.vertLeq(S,x)&&(x.s=S.s,x.t=S.t),Oe.vertEq(x,a)||Oe.vertEq(x,c)?(i.checkForRightSplice(t,e),!1):!Oe.vertEq(f,t.event)&&Oe.edgeSign(f,t.event,x)>=0||!Oe.vertEq(h,t.event)&&Oe.edgeSign(h,t.event,x)<=0?h===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):f===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Lnext,o.Oprev),r=e,e=i.topRightRegion(e),w=i.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,o.Onext,n.Rprev,w,!0),!0):(Oe.edgeSign(f,t.event,x)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Oe.edgeSign(h,t.event,x)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,n),n.Org.s=x.s,n.Org.t=x.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,a,f,c,h),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,o;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,o=r.eUp,n.Dst!==o.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(o),r=i.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==o.Org)if(n.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||o.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===o.Org&&n.Dst===o.Dst&&(i.addWinding(o,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,o=r.Onext,a=i.regionBelow(e),c=e.eUp,f=a.eUp,h=!1;if(c.Dst!==f.Dst&&i.checkForIntersect(t,e),Oe.vertEq(c.Org,t.event)&&(t.mesh.splice(o.Oprev,c),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),h=!0),Oe.vertEq(f.Org,t.event)&&(t.mesh.splice(r,f.Oprev),r=i.finishLeftRegions(t,a,null),h=!0),h){i.addRightEdges(t,e,r.Onext,o,o,!0);return}Oe.vertLeq(f.Org,c.Org)?n=f.Oprev:n=c,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,o,a,c,f;if(n=e.eUp,Oe.vertEq(n.Org,r)){Ae(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Oe.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}Ae(!1),e=i.topRightRegion(e),f=i.regionBelow(e),a=f.eUp.Sym,o=c=a.Onext,f.fixUpperEdge&&(Ae(o!==a),i.deleteRegion(t,f),t.mesh.delete(a),a=o.Oprev),t.mesh.splice(r.anEdge,a),Oe.edgeGoesLeft(o)||(o=null),i.addRightEdges(t,e,a.Onext,c,o,!0)},i.connectLeftVertex=function(t,e){var r,n,o,a,c,f,h=new Uh;if(h.eUp=e.anEdge.Sym,r=t.dict.search(h).key,n=i.regionBelow(r),!!n){if(a=r.eUp,c=n.eUp,Oe.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(o=Oe.vertLeq(c.Dst,a.Dst)?r:n,r.inside||o.fixUpperEdge){if(o===r)f=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(c.Dnext,e.anEdge);f=d.Sym}o.fixUpperEdge?i.fixUpperEdge(t,o,f):i.computeWinding(t,i.addRegionBelow(t,r,f)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);Ae(n!==null);var o=i.regionBelow(n),a=o.eUp,c=i.finishLeftRegions(t,o,null);c.Onext===a?i.connectRightVertex(t,n,c):i.addRightEdges(t,n,c.Onext,a,a,!0)},i.addSentinel=function(t,e,r,n){var o=new Uh,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=n,a.Dst.s=e,a.Dst.t=n,t.event=a.Dst,o.eUp=a,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},i.initEdgeDict=function(t){t.dict=new qA(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,o=t.bmax[0]+e,a=t.bmin[1]-r,c=t.bmax[1]+r;i.addSentinel(t,n,o,a),i.addSentinel(t,n,o,c)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ae(e.fixUpperEdge),Ae(++r===1)),Ae(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,n=e.Lnext,Oe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,o=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)o++;for(o+=8,e=t.pq=new WA(o,Oe.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,o;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,o=r.anEdge,Ae(o.Lnext!==o),o.Lnext.Lnext===o&&(i.addWinding(o.Onext,o),t.mesh.delete(o));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Oe.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),JA=function(){function i(){this.mesh=new u0,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Ot.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,o,a,c,f=[0,0,0],h=[0,0,0],d=[0,0,0],m=[0,0,0],x=[0,0,0],S=[null,null,null],w=[null,null,null],B=this.mesh.vHead;e=B.next;for(var O=0;O<3;++O)o=e.coords[O],h[O]=o,w[O]=e,f[O]=o,S[O]=e;for(e=B.next;e!==B;e=e.next)for(var T=0;T<3;++T)o=e.coords[T],o<h[T]&&(h[T]=o,w[T]=e),o>f[T]&&(f[T]=o,S[T]=e);var M=0;if(f[1]-h[1]>f[0]-h[0]&&(M=1),f[2]-h[2]>f[M]-h[M]&&(M=2),h[M]>=f[M]){t[0]=0,t[1]=0,t[2]=1;return}for(c=0,r=w[M],n=S[M],d[0]=r.coords[0]-n.coords[0],d[1]=r.coords[1]-n.coords[1],d[2]=r.coords[2]-n.coords[2],e=B.next;e!==B;e=e.next)m[0]=e.coords[0]-n.coords[0],m[1]=e.coords[1]-n.coords[1],m[2]=e.coords[2]-n.coords[2],x[0]=d[1]*m[2]-d[2]*m[1],x[1]=d[2]*m[0]-d[0]*m[2],x[2]=d[0]*m[1]-d[1]*m[0],a=x[0]*x[0]+x[1]*x[1]+x[2]*x[2],a>c&&(c=a,t[0]=x[0],t[1]=x[1],t[2]=x[2]);c<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,o=0,a=t.next;a!==t;a=a.next)if(n=a.anEdge,!(n.winding<=0))do o+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==a.anEdge);if(o<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,o=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),o=!0),r=this.sUnit,n=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,n[a]=0,n[(a+1)%3]=0,n[(a+2)%3]=e[a]>0?1:-1;for(var c=t.next;c!==t;c=c.next)c.s=this.dot_(c.coords,r),c.t=this.dot_(c.coords,n);o&&this.checkOrientation_();for(var f=!0,h=t.next;h!==t;h=h.next)f?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,f=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Oe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Oe.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var o=void 0;r.Lnext!==n;)if(Oe.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Oe.edgeGoesLeft(n.Lnext)||Oe.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)o=t.connect(n.Lnext,n),n=o.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Oe.edgeGoesRight(r.Lprev)||Oe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)o=t.connect(n.Lnext,n),n=o.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,o=t.eHead.next;o!==t.eHead;o=n)n=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var o,a=0,c=0,f;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){o=d.anEdge,f=0;do{var h=o.Org;h.n===-1&&(h.n=c,c++),f++,o=o.Lnext}while(o!==d.anEdge);if(f>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,e===Kt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=c,this.vertices=[],this.vertices.length=c*n,this.vertexIndices=[],this.vertexIndices.length=c;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var m=h.n*n;this.vertices[m+0]=h.coords[0],this.vertices[m+1]=h.coords[1],n>2&&(this.vertices[m+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var x=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(!!d.inside){o=d.anEdge,f=0;do{var h=o.Org;this.elements[x++]=h.n,f++,o=o.Lnext}while(o!==d.anEdge);for(var S=f;S<r;++S)this.elements[x++]=-1;if(e===Kt.CONNECTED_POLYGONS){o=d.anEdge;do this.elements[x++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==d.anEdge);for(var w=f;w<r;++w)this.elements[x++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,o=0,a=0;this.vertexCount=0,this.elementCount=0;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){n=r=c.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var f=0,h=0,d=0;o=0;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){a=0,n=r=c.anEdge;do this.vertices[f++]=r.Org.coords[0],this.vertices[f++]=r.Org.coords[1],e>2&&(this.vertices[f++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==n);this.elements[d++]=o,this.elements[d++]=a,o+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new u0),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,o,a){if(t===void 0&&(t=Ot.ODD),e===void 0&&(e=Kt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),$A.computeInterior(this,a);var c=this.mesh;return e===Kt.BOUNDARY_CONTOURS?this.setWindingNumber_(c,1,!0):this.tessellateInterior_(c),a&&c.check(),e===Kt.BOUNDARY_CONTOURS?this.outputContours_(c,n):this.outputPolymesh_(c,e,r,n),!0},i}();function mo(i){var t=i.windingRule,e=t===void 0?Ot.ODD:t,r=i.elementType,n=r===void 0?Kt.POLYGONS:r,o=i.polySize,a=o===void 0?3:o,c=i.vertexSize,f=c===void 0?2:c,h=i.normal,d=h===void 0?[0,0,1]:h,m=i.contours,x=m===void 0?[]:m,S=i.strict,w=S===void 0?!0:S,B=i.debug,O=B===void 0?!1:B;if(!x&&w)throw new Error("Contours can't be empty");if(!!x){var T=new JA;i.edgeCreateCallback&&(T.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(T.vertexIdCallback=i.vertexIdCallback);for(var M=0;M<x.length;M++)T.addContour(f||2,x[M]);return T.tesselate(e,n,a,f,d,w),{vertices:T.vertices,vertexIndices:T.vertexIndices,vertexCount:T.vertexCount,elements:T.elements,elementCount:T.elementCount,mesh:O?T.mesh:void 0}}}var ak=Ot.ODD,lk=Ot.NONZERO,ck=Ot.POSITIVE,uk=Ot.NEGATIVE,fk=Ot.ABS_GEQ_TWO,hk=Kt.POLYGONS,pk=Kt.CONNECTED_POLYGONS,dk=Kt.BOUNDARY_CONTOURS;var Vi=class extends KA{constructor(e,r=12,n=100,o={}){super();this.type="ShapeGeometry";this.windingRule=Ot.ODD;this.elementType=Kt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=r,this._maxCount=n,this._maxDrawCount=n*3,this._triangulationOptions=Object.assign({windingRule:Ot.ODD,elementType:Kt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o),this._positionAttribute=new eu(new Float32Array(n*3),3),this._normalAttribute=new eu(new Float32Array(n*3),3),this._uvAttribute=new eu(new Float32Array(n*2),2),this._indexAttribute=new eu(new Uint32Array(n*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),r=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),n,o=!0,a=!0,c,f;for(let h=0,d=e.length/2;h<d;h++){let m=h*2,x=e[m+0],S=e[m+1];if(c!==void 0&&x!==c&&(o=!1),f!==void 0&&S!==f&&(a=!1),c=x,f=S,!o&&!a)break}if(!o&&!a&&(n=mo({contours:[e,...r],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,n){let h=1/0,d=-1/0,m=1/0,x=-1/0;for(let B=0,O=n.vertexCount;B<O;B++){let T=B*2,M=n.vertices[T+0],F=n.vertices[T+1];M<h&&(h=M),M>d&&(d=M),F<m&&(m=F),F>x&&(x=F)}let S=d-h,w=x-m;for(let B=0,O=n.vertexCount;B<O;B++){let T=B*2,M=n.vertices[T+0],F=n.vertices[T+1],k=(M-h)/S,N=(F-m)/w;this._positionAttribute.setXYZ(B,M,F,0),this._normalAttribute.setXYZ(B,0,0,1),this._uvAttribute.setXY(B,k,N)}for(let B=0,O=n.elementCount;B<O;B++){let T=B*3,M=n.elements[T+0],F=n.elements[T+1],k=n.elements[T+2];this._indexAttribute.setX(T+0,M),this._indexAttribute.setX(T+1,F),this._indexAttribute.setX(T+2,k),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}clone(){let e=new Vi(this._shape,this._curveSegments,this._maxCount);return e.userData=fa(this.userData),e}};import{BufferAttribute as ru,BufferGeometry as YA}from"three";var tu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*tu.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,o=0;this.positions=new Float32Array(this.buffer,o*n,3*t),o+=3*t,this.normals=new Float32Array(this.buffer,o*n,3*t),o+=3*t,this.uvs=new Float32Array(this.buffer,o*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*tu.eSize,n=new ArrayBuffer(r),o=Float32Array.BYTES_PER_ELEMENT,a=0,c=new Float32Array(n,a*o,3*t);a+=3*t;let f=new Float32Array(n,a*o,3*t);a+=3*t;let h=new Float32Array(n,a*o,2*t);c.set(this.positions.slice(0,this.size*3)),f.set(this.normals.slice(0,this.size*3)),h.set(this.uvs.slice(0,this.size*2)),this.buffer=n,this.positions=c,this.normals=f,this.uvs=h,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},_a=tu;_a.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var jh=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),xs=class extends YA{constructor(e,r,n=0,o=12,a=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._bevel=n,this._curveSegments=o,this._bevelSegmentsInput=a,n<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(n,r/2-1e-12),this._bevelSegments=Math.floor(a));let c=this._shape.extractShapePointsToFlatArray([],o),f=this._shape.shapeHoles.map(A=>{let b=A.extractShapePointsToFlatArray([],o),V=[];for(let P=b.length-1;P>=1;P-=2){let R=b[P-1],E=b[P-0];V.push(R,E)}return V}),h=mo({windingRule:Ot.ODD,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]}),d=mo({windingRule:Ot.ODD,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...f]});if(!h)throw new Error("error generating geometry");let m=h.elementCount;if(d){h.elementCount+=d.elementCount;for(let A=0;A<d.elements.length;A++){let b=d.elements[A],V=A%2===0?h.vertexCount:0;h.elements.push(b+V)}for(let A=0;A<d.vertexIndices.length;A++){let b=d.vertexIndices[A],V=h.vertexCount;h.vertexIndices.push(b+V)}for(let A=0;A<d.vertices.length;A++){let b=d.vertices[A];h.vertices.push(b)}}let x=1/0,S=-1/0,w=1/0,B=-1/0;for(let A=0,b=h.vertexCount;A<b;A++){let V=A*2,P=h.vertices[V+0],R=h.vertices[V+1];P<x&&(x=P),P>S&&(S=P),R<w&&(w=R),R>B&&(B=R)}this._minX=x,this._minY=w,this._width=S-x,this._height=B-w;let O=h.vertexCount*2*(2+this._bevelSegments);this._buffer=new _a(O);let T=[],M=[];for(let A=h.elementCount-1;A>=0;A--){let b=A>=m,V=A*2,P=h.elements[V+0],R=h.elements[V+1],E=P+R,G={start:P,count:R,normals:[],continuous:[],concave:[]},ae=P,ne=E-1,xe=P+1,_e=this._shape.roundedCurves.length;do{let $=ae-P,W=h.vertices[ne*2+0],J=h.vertices[ne*2+1],H=h.vertices[ae*2+0],K=h.vertices[ae*2+1],fe=h.vertices[xe*2+0],me=h.vertices[xe*2+1],ie=H-W,re=K-J,q=Math.sqrt(ie*ie+re*re);ie/=q,re/=q;let ee=H-fe,Te=K-me,ce=Math.sqrt(ee*ee+Te*Te);ee/=ce,Te/=ce,G.normals[$*2+0]=-Te,G.normals[$*2+1]=ee,G.concave[$]=ie*Te-re*ee>0;let le=h.vertexIndices[ae];if(Array.isArray(le))G.continuous[$]=!1;else{let[he,pe]=this._shape.getCurveIndexFromVertexId(le-1,!0);if(pe>0&&pe<1)G.continuous[$]=!0;else{let de=pe===1?he+1:he-1;de=(de+_e)%_e;let be=pe===1?0:1,Se=this._shape.roundedCurves[he].getTangent(pe),Ie=this._shape.roundedCurves[de].getTangent(be);G.continuous[$]=Se.dot(Ie)>.95}}b&&(G.normals[$*2+0]*=-1,G.normals[$*2+1]*=-1),[ne,ae,xe]=[ae,xe,xe+1],xe>=E&&(xe-=R)}while(xe!==P+1);let Le=[];Le.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(P*2,E*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map(($,W)=>[W,W]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(P*2,E*2)});for(let $=1;$<=this._bevelSegments;$++){let W=$/this._bevelSegments*Math.PI/2,J=(1-Math.cos(W))*this._bevelSize,H=[],K=[],fe=[],me=[],ie=0;for(let q=0;q<R;q++){let ee=q*2,Te=(q-1+R)%R*2,ce=h.vertices[G.start*2+ee+0],le=h.vertices[G.start*2+ee+1],he=-G.normals[Te+0]*J,pe=-G.normals[Te+1]*J,de=-G.normals[ee+0]*J,be=-G.normals[ee+1]*J;if(G.concave[q]||!G.concave[q]&&b){let Se=Math.atan2(pe,he),Ie=Math.atan2(be,de);Ie>Se&&(Ie-=Math.PI*2);let ft=Ie-Se;if(G.continuous[q]||b){let Ve=Se+ft/2,Lt=Math.cos(Ve)*J,qe=Math.sin(Ve)*J;H[2*ie+0]=ce+Lt*(b?-1:1),H[2*ie+1]=le+qe*(b?-1:1),me[ie]=q,ie++}else{let Ve=Math.max(1,Math.floor(o/4*Math.abs(ft)/Math.PI));for(let Lt=0;Lt<=Ve;Lt++){let qe=Se+ft*(Lt/Ve),_t=Math.cos(qe)*J,Wt=Math.sin(qe)*J;H[2*ie+0]=ce+_t,H[2*ie+1]=le+Wt,me[ie]=q,ie++}}}else H[2*ie+0]=ce+he,H[2*ie+1]=le+pe,me[ie]=q,K[q]=ie,ie++,H[2*ie+0]=ce,H[2*ie+1]=le,me[ie]=q,ie++,H[2*ie+0]=ce+de,H[2*ie+1]=le+be,me[ie]=q,fe[q]=ie,ie++}let re=mo({windingRule:Ot.POSITIVE,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[H],edgeCreateCallback:q=>{let Te=q.Org.idx,ce=me[Te],le=me[(Te+1)%me.length];q.idx=[ce,le],q.Sym.idx=[le,ce]},vertexIdCallback:q=>{let ee=q.Lprev.idx;return[ee?ee[1]:0,q.idx[0]]}});if(!re)throw console.log("Error"),new Error(`error generating bevel geometry for ${$}'th loop`);if(!re.vertexCount)break;for(let q=0;q<re.vertexIndices.length;q++){let[ee,Te]=re.vertexIndices[q];if(ee===Te)continue;let ce=Te;Te<ee&&(ce+=R);for(let le=ee;le<ce;le++){let he=le%R,pe=(le+1)%R;if(!G.continuous[he]||!G.continuous[pe]){re.vertexIndices[q]=[ee,he],re.vertexIndices.splice(q+1,0,[pe,Te]),re.vertices.splice((q+1)*2,0,re.vertices[q*2],re.vertices[q*2+1]);break}}}Le.push({bevelI:$,angle:W,size:J,boundary:re,reverseMap:me,insetPoints:H})}let Ue=($,W,J)=>{let H=0,K=$.boundary.vertexIndices.length;for(;H<K&&J($.boundary.vertexIndices[W]);)W=(W+1)%K,H++;return H},se=T.length;for(let $=1;$<Le.length;$++){let W=Le[$-1],J=Le[$],H=W.boundary.vertexIndices.length,K=J.boundary.vertexIndices.length;if(!H||!K)break;let fe=G.concave.length,me=0,ie=jh(me,R);for(;!W.boundary.vertexIndices.filter(ie).length||!J.boundary.vertexIndices.filter(ie).length;)me++,ie=jh(me,R);let re=W.boundary.vertexIndices.findIndex(ie),q=J.boundary.vertexIndices.findIndex(ie);do re=(re+1)%H;while(ie(W.boundary.vertexIndices[re]));do q=(q+1)%K;while(ie(J.boundary.vertexIndices[q]));me=(me+1)%R;let ee=me,Te=this.buildBevelVert(G,W,(re-1+H)%H),ce=this.buildBevelVert(G,J,(q-1+K)%K),le=Te,he=ce,pe,de,be=!1;do{ie=jh(me,R);let Se=Ue(W,re,ie),Ie=Ue(J,q,ie),ft=be;if(be=!1,Se&&!Ie){for(let Ve=0;Ve<Se;Ve++)pe=this.buildBevelVert(G,W,(re+Ve)%H,Ve/(Se-1)),T.push(le.topN,pe.topP,he.topN),T.push(pe.bottomP,le.bottomN,he.bottomN),le=pe;be=!0}else if(!Se&&Ie)for(let Ve=0;Ve<Ie;Ve++)de=this.buildBevelVert(G,J,(q+Ve)%K,Ve/(Ie-1)),T.push(he.topN,le.topP,de.topP),T.push(le.bottomP,he.bottomN,de.bottomP),he=de;else if(Se&&Ie)if(pe=this.buildBevelVert(G,W,re,0),de=this.buildBevelVert(G,J,q,0),ft?(T.push(le.topN,de.topP,he.topN),T.push(le.topN,pe.topP,de.topP),T.push(de.bottomP,le.bottomN,he.bottomN),T.push(pe.bottomP,le.bottomN,de.bottomP)):(T.push(le.topN,pe.topP,he.topN),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,le.bottomN,he.bottomN),T.push(pe.bottomP,he.bottomN,de.bottomP)),le=pe,he=de,Se===Ie)for(let Ve=1;Ve<Se;Ve++)pe=this.buildBevelVert(G,W,(re+Ve)%H,Ve/(Se-1)),de=this.buildBevelVert(G,J,(q+Ve)%K,Ve/(Ie-1)),T.push(le.topN,pe.topP,he.topN),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,le.bottomN,he.bottomN),T.push(pe.bottomP,he.bottomN,de.bottomP),le=pe,he=de;else if(Se>Ie){let Ve=Se/Ie,Lt=0;for(let qe=1;qe<Se;qe++)pe=this.buildBevelVert(G,W,(re+qe)%H,qe/(Se-1)),T.push(le.topN,pe.topP,he.topN),T.push(pe.bottomP,le.bottomN,he.bottomN),le=pe,qe>(Lt+1)*Ve&&(Lt++,de=this.buildBevelVert(G,J,(q+Lt)%K,Lt/(Ie-1)),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,he.bottomN,de.bottomP),he=de)}else{let Ve=Ie/Se,Lt=0;for(let qe=1;qe<Ie;qe++)de=this.buildBevelVert(G,J,(q+qe)%K,qe/(Ie-1)),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,he.bottomN,de.bottomP),he=de,qe>(Lt+1)*Ve&&(Lt++,pe=this.buildBevelVert(G,W,(re+Lt)%H,Lt/(Se-1)),T.push(le.topN,pe.topP,he.topN),T.push(pe.bottomP,le.bottomN,he.bottomN),le=pe)}re=(re+Se)%H,q=(q+Ie)%K,me=(me+1)%fe}while(me!==ee)}{let $=Le[0];for(let W=0,J=$.boundary.vertexCount;W<J;W++){let H=this.buildBevelVert(G,$,W),K=this.buildBevelVert(G,$,(W+1)%J);T.push(K.topP,H.topN,H.bottomN),T.push(K.topP,H.bottomN,K.bottomP)}}if(b){let $=[];for(let W=T.length-1;W>=se+2;W-=3){let J=T[W-2],H=T[W-1],K=T[W-0];$.push(K,H,J)}T.splice(se,T.length-se,...$)}if(b){let $=[];for(let W=Le[Le.length-1].boundary.vertices.length-1;W>=1;W-=2){let J=Le[Le.length-1].boundary.vertices[W-1],H=Le[Le.length-1].boundary.vertices[W-0];$.push(J,H)}M.push($)}if(!b){let $=Le[Le.length-1],W=mo({windingRule:Le.length>1?Ot.POSITIVE:Ot.ODD,elementType:Kt.POLYGONS,vertexSize:2,strict:!0,contours:[$.insetPoints,...M]});if(!W)throw new Error("Error generating geometry for surface");for(let J=0;J<W.elementCount*3;J+=3){let H=this.buildSurfaceVert(W,W.elements[J+0]),K=this.buildSurfaceVert(W,W.elements[J+1]),fe=this.buildSurfaceVert(W,W.elements[J+2]);T.push(H.top,K.top,fe.top),T.push(fe.bottom,K.bottom,H.bottom)}}this.vertexCache={}}this._buffer.shrink();let F=new ru(Uint32Array.from(T),1),k=new ru(this._buffer.positions,3),N=new ru(this._buffer.normals,3),te=new ru(this._buffer.uvs,2);k.needsUpdate=!0,N.needsUpdate=!0,te.needsUpdate=!0,F.needsUpdate=!0,this.setAttribute("position",k),this.setAttribute("normal",N),this.setAttribute("uv",te),this.setIndex(F)}buildSurfaceVert(e,r){let n=r.toString();if(n in this.vertexCache)return this.vertexCache[n];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],c=(o-this._minX)/this._width,f=(a-this._minY)/this._height,h=this._buffer.get(2),d=h*3,m=h*2,x={top:h+0,bottom:h+1};return this._buffer.positions[d+0]=o,this._buffer.positions[d+1]=a,this._buffer.positions[d+2]=this._depth,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[m+0]=c,this._buffer.uvs[m+1]=f,this._buffer.positions[d+3]=o,this._buffer.positions[d+4]=a,this._buffer.positions[d+5]=0,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[m+2]=c,this._buffer.uvs[m+3]=f,this.vertexCache[n]=x,x}buildBevelVert(e,r,n,o=1){let a=`${r.bevelI}:${n}`;if(a in this.vertexCache)return this.vertexCache[a];let[c,f]=r.boundary.vertexIndices[n],h,d,m,x;c!==f?(d=c,h=f,x=!1,m=e.continuous[d]&&e.continuous[h]):(h=c,d=(h-1+e.count)%e.count,x=e.concave[h]&&r.bevelI>0,m=e.continuous[h]||x);let S=Math.cos(r.angle),w=Math.sin(r.angle),B=n*2,O=h*2,T=d*2,M=r.boundary.vertices[B+0],F=r.boundary.vertices[B+1],k=(1-w)*this._bevelSize,N=(M-this._minX)/this._width,te=(F-this._minY)/this._height,A=e.normals[O+0],b=e.normals[O+1],V=e.normals[T+0],P=e.normals[T+1];if(x){let ne=V-A,xe=P-b;A=A+ne*(1-o),b=b+xe*(1-o);let _e=Math.sqrt(A*A+b*b);A/=_e,b/=_e}let R=this._buffer.get(m?2:4),E=R*3,G=R*2,ae={i:n,fi:h,topP:R+0,topN:R+0,bottomP:R+1,bottomN:R+1};return this._buffer.positions[E+0]=M,this._buffer.positions[E+1]=F,this._buffer.positions[E+2]=this._depth-k,this._buffer.normals[E+0]=A*S,this._buffer.normals[E+1]=b*S,this._buffer.normals[E+2]=w,this._buffer.uvs[G+0]=N,this._buffer.uvs[G+1]=te,this._buffer.positions[E+3]=M,this._buffer.positions[E+4]=F,this._buffer.positions[E+5]=k,this._buffer.normals[E+3]=A*S,this._buffer.normals[E+4]=b*S,this._buffer.normals[E+5]=-w,this._buffer.uvs[G+2]=te,this._buffer.uvs[G+3]=N,m||(R+=2,E+=6,G+=4,ae.topP=R+0,ae.bottomP=R+1,this._buffer.positions[E+0]=M,this._buffer.positions[E+1]=F,this._buffer.positions[E+2]=this._depth-k,this._buffer.normals[E+0]=V*S,this._buffer.normals[E+1]=P*S,this._buffer.normals[E+2]=w,this._buffer.uvs[G+0]=N,this._buffer.uvs[G+1]=te,this._buffer.positions[E+3]=M,this._buffer.positions[E+4]=F,this._buffer.positions[E+5]=k,this._buffer.normals[E+3]=V*S,this._buffer.normals[E+4]=P*S,this._buffer.normals[E+5]=-w,this._buffer.uvs[G+2]=te,this._buffer.uvs[G+3]=N),this.vertexCache[a]=ae,ae}clone(){let e=new xs(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fa(this.userData),e}};var ar=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var h,d,m,x,S,w,B;let e=Object.assign({},(h=t==null?void 0:t.parameters)!=null?h:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs((d=e.height)!=null?d:e.width),o=Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(m=e.depth)!=null?m:0),a=(x=i.shape)!=null?x:t==null?void 0:t.shape,c=(S=a==null?void 0:a.roundness)!=null?S:e.roundness;a!==void 0&&(a instanceof nt?(a.width!==r||a.height!==n)&&a.applySize(r,n):a=new nt(r,n).fromJSON(a),((w=i.parameters)==null?void 0:w.roundness)!==void 0&&((B=i.parameters)==null?void 0:B.roundness)>0&&a.update(!1));let f=a!=null?a:new nt(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:o,extrudeDepth:o,roundness:c}),shape:f}}static build(i){let{extrudeDepth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:o,surfaceMaxCount:a}=i.parameters;i.shape.roundness=o;let c;return t<=0?c=new Vi(i.shape,n,a):c=new xs(i.shape,t,e,n,r),Object.assign(c,{userData:ue(j({},i),{type:"VectorGeometry"})})}};import{MathUtils as m0,Vector2 as g0}from"three";var y0=Math.PI*2,x0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(a=e.depth)!=null?a:0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:o,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d=i.shape,m=t*.5,x=e*.5,S=XA(d,m,x,n*Math.PI/180,r,o);d.isClosed=!0,d.update();let w=ar.create({shape:d,parameters:{subdivisions:S,surfaceMaxCount:h,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(w,{userData:ue(j({},i),{type:"EllipseGeometry"})})}};function XA(i,t,e,r,n,o){if(r>=y0)return n>30||n%4===0?(QA(i,t,e,o),Math.round(n/4)):d0(i,r,n,t,e,o);let a={x:0,y:e},c=r+Math.PI*.5,f={x:Math.cos(c)*t,y:Math.sin(c)*e},h=c0({px:a.x,py:a.y,cx:f.x,cy:f.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%h.length===0?ZA(i,a.x,a.y,h,n,t,e,o):d0(i,r,n,t,e,o)}function ZA(i,t,e,r,n,o,a,c){let f=Math.round(n/r.length);i.addPoint(vs(t,e));for(let h=0,d=r.length;h<d;h++){let m=r[h],x=i.points[h],S=vs(m.x,m.y);x.controls[1].position.set(m.x1,m.y1),S.controls[0].position.set(m.x2,m.y2),i.addPoint(S)}return c>0?v0(i,o,a,c):i.addPoint(vs(0,0)),f}function d0(i,t,e,r,n,o){let a=-t/e;for(let c=0;c<=e;c++){let f=a*c,h=Math.sin(f)*r,d=Math.cos(f)*n;i.addPoint(vs(h,d))}return t<y0?o>0?v0(i,r,n,o):i.addPoint(vs(0,0)):(i.removePoint(i.points[i.points.length-1]),o>0&&b0(i,r,n,o)),1}function QA(i,t,e,r=0,n=0,o=0){let a=.5522847498,c=t*a,f=e*a;i.addPoint(nu(n-t,o,n-t,o-f,n-t,o+f)),i.addPoint(nu(n,o+e,n-c,o+e,n+c,o+e)),i.addPoint(nu(n+t,o,n+t,o+f,n+t,o-f)),i.addPoint(nu(n,o-e,n+c,o-e,n-c,o-e)),r>0&&b0(i,t,e,r)}function vs(i,t){return new Tn(m0.generateUUID(),new g0(i,t))}function nu(i,t,e,r,n,o){let a=vs(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(n,o),a}function v0(i,t,e,r){S0(i,t,e,r).forEach(o=>i.addPoint(o))}function b0(i,t,e,r){let n=S0(i,t,e,r),o=new nt;n.forEach(a=>o.addPoint(a)),o.isClosed=!0,i.shapeHoles.push(o)}function S0(i,t,e,r){let n=r*t/100,o=n*(Math.abs(e)/Math.abs(t)),a=new g0(n/t,o/e),c=i.points.map(f=>{let h=f.clone();return h.uuid=m0.generateUUID(),h}).reverse();return c.forEach(f=>{f.position.multiply(a);let h=f.controls[0].position.clone().multiply(a),d=f.controls[1].position.clone().multiply(a);f.controls[0].position.copy(d),f.controls[1].position.copy(h)}),c}import{BufferGeometry as e2,Float32BufferAttribute as kh,Vector3 as w0}from"three";var C0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var c,f,h;let e=Object.assign({},(c=t==null?void 0:t.parameters)!=null?c:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=Math.abs((f=e.height)!=null?f:r),o=Math.abs((h=e.depth)!=null?h:r),a=Math.abs(Math.min(r,o))/2;return{parameters:Object.assign(e,{width:r,height:n,depth:o,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:o,segments:a,pathRadius:c,pathType:f,pathSegments:h,cornerRadius:d,cornerSegments:m}=i.parameters,x=new Ia(!1,t,e,r,n,o,a,c,f,h,d,m);return Object.assign(x,{userData:ue(j({},i),{type:"HelixGeometry"})})}},Ia=class extends e2{constructor(t=!0,e=1,r=1,n=1,o=1,a=1,c=1,f=1,h=1,d=1,m=1,x=1){super();let S=t&&a===1;S&&(x=0),m>100&&(m=100);let w=()=>new w0,B=new w0,O=w(),T=w(),M=w(),F,k,N,te,A,b,V,P,R=w(),E=w(),G=w(),ae=w(),ne=w(),xe=w(),_e=w(),Le=w(),Ue=r-2*f+.001,se=Ue/a,$=Math.ceil(c*a),W=$+1,J=Ue/$,H=-Ue/2,K=d+1,fe=2*Math.PI/d,me=Math.PI/2/x,ie=.01,re=Math.min((1-m/100)*f,f-ie),q=f-re,ee=0,Te=2,ce=x*Te+Te,le=K*ce/Te,he=le+K*W,pe=K*(W+ce),[de,be,Se]=[3,3,2].map(pt=>Array(pe*pt).fill(0)),Ie=[],ft=o-f;function Ve(pt,jt){let ir=Math.PI/2;b=jt*J,P=2*Math.PI*(b%se)/se+ir,b+=H,V=Math.sin(P)*ft,A=Math.cos(P)*ft,t?pt.set(A,V,b):pt.set(A,b,V)}Ve(B,-1e-10),Ve(O,0),R.copy(B),Ve(B,1);let Lt=B.distanceTo(O),qe=q+re,_t=Lt*$+2*qe,Wt=re,Rr=_t-qe;for(let pt=0;pt<=$;pt++){Ve(T,pt),Le.subVectors(T,R).normalize(),R.copy(T),xe.copy(T).setComponent(+t+1,0).normalize(),_e.crossVectors(Le,xe).normalize();let jt=pt===0,ir=pt===$,Co=jt?3*Math.PI/2:me,Lo=jt?Wt:Rr,To=jt?K:he,Ki=jt?0:pe-K,Yi=Le.clone().multiplyScalar(jt?-q:q).add(T),No=Le.clone().multiplyScalar(jt?-1:1).normalize();for(let Nr=0;Nr<K;Nr++){let Xi=Nr*fe;if(E.addVectors(B.copy(xe).multiplyScalar(f*Math.cos(Xi)),O.copy(_e).multiplyScalar(f*Math.sin(Xi))),G.copy(E).normalize(),jt||ir){S||(ee=Ki+Nr,[0,1,2].forEach(qt=>{de[ee*3+qt]=Yi.getComponent(qt),be[ee*3+qt]=No.getComponent(qt)}),Se[ee*2]=+ir,Se[ee*2+1]=Nr/d),O.copy(G).multiplyScalar(re),M.addVectors(T,O);for(let qt=0;qt<x;qt++){let Kn=qt*me+Co;ae.addVectors(B.copy(Le).multiplyScalar(q*Math.sin(Kn)),O.copy(G).multiplyScalar(q*Math.cos(Kn))),ne.copy(ae).normalize(),O.addVectors(M,ae),ae.normalize(),ee=To+qt*K+Nr,[0,1,2].forEach(Re=>{de[ee*3+Re]=O.getComponent(Re),be[ee*3+Re]=ne.getComponent(Re)});let _o=+jt+Math.sin(Kn);Se[ee*2]=(Lo+q*_o)/_t,Se[ee*2+1]=Nr/d}}O.addVectors(T,E),ee=le+pt*K+Nr,[0,1,2].forEach(qt=>{de[ee*3+qt]=O.getComponent(qt),be[ee*3+qt]=G.getComponent(qt)}),Se[ee*2]=(qe+pt*Lt)/_t,Se[ee*2+1]=Nr/d}}let Ut=W+2*x+Te,zr=1,[mn,gn]=S?[zr,zr+W-1]:[0,Ut-1];for(let pt=mn;pt<=gn-1;pt++){let jt=S&&pt===gn-1;for(let ir=0;ir<K-1;ir++)F=pt*K+ir,k=F+1,N=(jt?ir:F)+K,te=(jt?ir+1:k)+K,pt===0?Ie.push(k,te,N):pt===Ut-2?Ie.push(F,k,N):Ie.push(F,k,N,k,te,N)}this.setIndex(Ie),this.setAttribute("position",new kh(de,3)),this.setAttribute("normal",new kh(be,3)),this.setAttribute("uv",new kh(Se,2))}};import{IcosahedronBufferGeometry as t2}from"three";var L0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,c=n===0&&o!==0?new Oa(t*.5,o,a):new t2(t*.5,n);return c.scale(1,e/t,r/t),Object.assign(c,{userData:ue(j({},i),{type:"IcosahedronGeometry"})})}},Oa=class extends zi{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],c="IcosahedronGeometry";super(o,a,c,t,e,r),this.type=c}static fromJSON(t){return new Oa(t.radius,t.corner,t.cornerSides)}};import{LatheBufferGeometry as r2,Shape as n2}from"three";var T0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o,a,c;((n=(r=i.parameters)==null?void 0:r.points)!=null?n:[]).forEach(f=>{Array.isArray(f)&&(f.x=f[0],f.y=f[1])});let e=Object.assign({},(o=t==null?void 0:t.parameters)!=null?o:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs((c=e.depth)!=null?c:e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new n2;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new r2(n.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:ue(j({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as _0,BufferGeometryLoader as u2,Vector3 as f2,BoxBufferGeometry as I0}from"three";import{BufferGeometry as i2,Vector2 as Hh,Vector3 as N0}from"three";import{Geometry as o2,Face3 as s2}from"three/examples/jsm/deprecated/Geometry.js";var a2=["a","b","c"];function l2(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Wh(i,t,e){let r=Math.min(i,t),n=Math.max(i,t),o=r+"_"+n;return e.get(o)}function qh(i,t,e,r,n,o){let a=Math.min(i,t),c=Math.max(i,t),f=a+"_"+c,h;if(r.has(f))h=r.get(f);else{let d=e[a],m=e[c];h={a:d,b:m,newEdge:null,faces:[]},r.set(f,h)}h.faces.push(n),o[i].edges.push(h),o[t].edges.push(h)}function c2(i,t,e,r){let n,o,a;for(n=0,o=i.length;n<o;n++)e[n]={edges:[]};for(n=0,o=t.length;n<o;n++)a=t[n],qh(a.a,a.b,i,r,a,e),qh(a.b,a.c,i,r,a,e),qh(a.c,a.a,i,r,a,e)}function iu(i,t,e,r,n){i.push(new s2(t,e,r,void 0,void 0,n))}function bs(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function ou(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var su=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof i2?t=new o2().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new N0,r,n,o,a,c,f=t.vertices,h=t.faces,d=t.faceVertexUvs[0],m=d!==void 0&&d.length>0,x=[],S=new Map;c2(f,h,x,S);let w=[],B,O,T,M,F,k,N;for(let ie of Array.from(S.keys())){for(O=S.get(ie),T=new N0,F=3/8,k=1/8,N=O.faces.length,N!=2&&(F=.5,k=0,N!=1),T.addVectors(O.a,O.b).multiplyScalar(F),e.set(0,0,0),a=0;a<N;a++){for(M=O.faces[a],c=0;c<3&&(B=f[l2(M,a2[c])],!(B!==O.a&&B!==O.b));c++);B&&e.add(B)}e.multiplyScalar(k),T.add(e),O.newEdge=w.length,w.push(T)}let te,A,b,V,P,R,E,G=[];for(n=0,o=f.length;n<o;n++){for(R=f[n],P=x[n].edges,r=P.length,r==3?te=3/16:r>3&&(te=3/(8*r)),A=1-r*Number(te),b=te,r<=2&&(r==2?(A=3/4,b=1/8):r==1||r==0),E=R.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<r;a++)V=P[a],B=V.a!==R?V.a:V.b,e.add(B);e.multiplyScalar(Number(b)),E.add(e),G.push(E)}let ae=G.concat(w),ne=G.length,xe,_e,Le,Ue=[],se=[],$,W,J,H,K=new Hh,fe=new Hh,me=new Hh;for(n=0,o=h.length;n<o;n++)M=h[n],xe=Number(Wh(M.a,M.b,S).newEdge)+ne,_e=Number(Wh(M.b,M.c,S).newEdge)+ne,Le=Number(Wh(M.c,M.a,S).newEdge)+ne,iu(Ue,xe,_e,Le,M.materialIndex),iu(Ue,M.a,xe,Le,M.materialIndex),iu(Ue,M.b,_e,xe,M.materialIndex),iu(Ue,M.c,Le,_e,M.materialIndex),m&&($=d[n],W=$[0],J=$[1],H=$[2],K.set(bs(W.x,J.x),bs(W.y,J.y)),fe.set(bs(J.x,H.x),bs(J.y,H.y)),me.set(bs(W.x,H.x),bs(W.y,H.y)),ou(se,K,fe,me),ou(se,W,K,me),ou(se,J,fe,K),ou(se,H,me,fe));t.vertices=ae,t.faces=Ue,m&&(t.faceVertexUvs[0]=se)}};var Yt=new f2,O0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var o,a;let e=(a=(o=i.geometry)!=null?o:t==null?void 0:t.geometry)!=null?a:new _0().copy(new I0(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Yt),r={width:Yt.x,height:Yt.y,depth:Yt.z,subdivisions:0}):r=t.parameters;let n=j(j({},r),i.parameters);return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){var f;let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,o=(f=i.geometry)!=null?f:new _0().copy(new I0(100,100,100)),a=o.userData.parameters;a===void 0?(o.computeBoundingBox(),o.boundingBox.getSize(Yt)):Yt.set(a.width,a.height,a.depth),(t!==Yt.x||e!==Yt.y||r!==Yt.z)&&o.scale(Yt.x===0?1:t/Yt.x,Yt.y===0?1:e/Yt.y,Yt.z===0?1:r/Yt.z);let c=o.originalGeometry;return n>0?(c===void 0||(a==null?void 0:a.subdivisions)!==n)&&(c===void 0&&(c=o),o=new su(n).modify(c).toBufferGeometry()):(c!==void 0&&(o=c),c=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()),c!==void 0&&Object.assign(o,{originalGeometry:c}),delete i.geometry,Object.assign(o,{userData:ue(j({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,t,e){new u2(e).load(i,n=>{let o=this.normalizeInputs({geometry:n});n.boundingBox.getSize(Yt);let a=100/Yt.x;Object.assign(o.parameters,{width:100,height:Yt.y*a,depth:Yt.z*a}),t(this.build(o))})}};var M0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a,c;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(c=e.depth)!=null?c:0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=t*.5,m=e*.5,x=0,S=0,w=2*Math.PI/r;for(let O=0;O<r;O++){let T=w*O,M=x+Math.sin(T)*d,F=S+Math.cos(T)*m;h.addPoint(h.createPoint(M,F))}h.isClosed=!0;for(let O=0,T=h.points.length;O<T;O++)h.points[O].roundness=n;h.roundness=n,h.update();let B=ar.create({shape:h,parameters:{surfaceMaxCount:f,roundness:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(B,{userData:ue(j({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as h2,Float32BufferAttribute as $h,Vector2 as jn,Vector3 as tr}from"three";var P0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:o,openEnded:a,cornerRadius:c,cornerSegments:f}=i.parameters,h=new Kh(t*.5,e,n,o,a,c,f);return h.scale(1,1,r/t),Object.assign(h,{userData:ue(j({},i),{type:"PyramidGeometry"})})}};function Ma(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Jh(i,t,e,r,n,o){let a=t.clone().sub(i),c=e.clone().sub(i),f=a.angleTo(c);if(a.normalize(),c.normalize(),r===n){let h=a.add(c).normalize();o.copy(i).addScaledVector(h,r/Math.sin(f/2))}else{let h=a.angleTo(c);o.copy(i),o.addScaledVector(a,n/Math.sin(h)),o.addScaledVector(c,r/Math.sin(h))}}function p2(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var Kh=class extends h2{constructor(t=.5,e=1,r=4,n=1,o=!1,a=0,c=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),c=Math.floor(c);let f=[],h=[],d=[],m=[],x=0,S=e/2,w=Math.PI/r,B=t*Math.cos(Math.PI/r),O=2*Math.PI/r,T=(r-2)*Math.PI/r,M=Math.PI-T,F=new tr(0,-S,0),k=new tr(0,S,0),N=new jn(t,-S),te=new jn(B,-S),A=new jn(0,k.y).sub(te),b=new jn(0,k.y).sub(N),V=new jn(A.y,-A.x).normalize(),P=new jn(b.y,-b.x).normalize(),E=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,E);let G;{let se=new tr(V.x,V.y,0),$=new tr(Math.cos(O)*se.x,se.y,Math.sin(O)*se.x);G=se.angleTo($)}let ae=a/Math.tan((Math.PI-A.angle())/2),ne=a/Math.tan((Math.PI-G)/2),xe=new tr;if(!o){h.push(F.x,F.y,F.z),d.push(0,-1,0),m.push(0,0);let se=x++,$=[],W=N.clone(),J=ae/Math.cos(Math.PI/r);W.x-=J;for(let H=0;H<r;H++){let K=H/r*Math.PI*2+w,fe=new jn(Math.sin(K),Math.cos(K));Ma(W,fe,xe),h.push(xe.x,xe.y,xe.z),d.push(0,-1,0),m.push(0,0),$.push(x++)}for(let H=0;H<$.length;H++)f.push($[H],se,$[(H+1)%$.length])}let _e=[];{let se=new tr,$=new tr,W=new tr,J=new tr,H=new tr,K=new tr;for(let fe=0;fe<r;fe++){let me=fe/r*Math.PI*2+w,ie=(fe+.5)/r*Math.PI*2+w,re=(fe+1)/r*Math.PI*2+w,q=new jn(Math.sin(me),Math.cos(me)),ee=new jn(Math.sin(ie),Math.cos(ie)),Te=new jn(Math.sin(re),Math.cos(re));Ma(N,q,$),Ma(N,Te,W),Ma(V,ee,se),Jh(k,$,W,ne,ne,J),h.push(J.x,J.y,J.z),Jh($,k,W,ne,ae,H),h.push(H.x,H.y,H.z),Jh(W,$,k,ae,ne,K),h.push(K.x,K.y,K.z),d.push(se.x,se.y,se.z),d.push(se.x,se.y,se.z),d.push(se.x,se.y,se.z),m.push(0,0),m.push(0,0),m.push(0,0);let ce=x++,le=x++,he=x++;if(f.push(ce,le,he),a>0){{let be=$.clone().add(W).multiplyScalar(.5),Se=k.clone().sub(be).normalize(),ft=F.clone().sub(be).normalize().add(Se).normalize().multiplyScalar(-1),Ve=K.clone().sub(H);Le(be,Ve,ft,A.angle())}let pe,de;{let be=new tr;Ma(P,Te,be);let Se=K.clone().add(J).multiplyScalar(.5);Se=p2(Se,W,k);let Ie=K.clone().sub(J);[pe,de]=Le(Se,Ie,be,G,J.y)}{let be=pe,Se=be.clone().setY(0).normalize(),Ie=new tr(0,-1,0),ft=Se.clone().cross(Ie);Ue(be,Se,Ie,ft)}_e.concat(de);{let be=A.angle(),Se=Math.PI-be,Ie=k.clone();Ie.y-=a/Math.sin(be-Math.PI/2);let ft=new tr,Ve=[];for(let qe=0;qe<c;qe++){let _t=[],Wt=Math.PI/2-Se*qe/c,Rr=Math.cos(Wt),Ut=Math.sin(Wt),zr=ie;for(let mn=0;mn<=qe;mn++){let gn=Math.cos(zr),pt=Math.sin(zr);se.x=Rr*pt,se.y=Ut,se.z=Rr*gn,ft.copy(Ie).addScaledVector(se,a),h.push(ft.x,ft.y,ft.z),d.push(se.x,se.y,se.z),m.push(0,0),_t.push(x++),zr+=Math.PI*2/qe/r}Ve.push(_t)}de.reverse(),Ve.push(de);let Lt=Ve.length-1;for(let qe=0;qe<Lt;qe++){let _t=Ve[qe],Wt=Ve[qe+1],Rr=_t.length-1;f.push(Wt[1],_t[0],Wt[0]);for(let Ut=1;Ut<=Rr;Ut++)f.push(_t[Ut],_t[Ut-1],Wt[Ut]),f.push(Wt[Ut+1],_t[Ut],Wt[Ut])}}}}}this.setIndex(f),this.setAttribute("position",new $h(h,3)),this.setAttribute("normal",new $h(d,3)),this.setAttribute("uv",new $h(m,2));function Le(se,$,W,J,H){let K=-J/2,fe=(Math.PI-J)/2,me=$.clone().normalize().cross(W);se.addScaledVector(W,-a/Math.sin(fe));let ie=new tr,re=new tr,q=1,ee=x,Te=[];for(let ce=0;ce<=c;ce++){let le=K+ce/c*J;re.set(0,0,0),re.addScaledVector(me,Math.sin(le)),re.addScaledVector(W,Math.cos(le));for(let he=0;he<=q;he++){let pe=he/q-.5;if(ie.copy(se),ie.addScaledVector($,pe),ie.addScaledVector(re,a),H!=null){let de=Math.max(0,ie.y-H);ie.addScaledVector($,-de/$.y)}h.push(ie.x,ie.y,ie.z),d.push(re.x,re.y,re.z),m.push(0,0),he===0&&Te.push(x),x++}}for(let ce=0;ce<c;ce++)for(let le=0;le<q;le++){let he=ee+le+(q+1)*ce,pe=he+(q+1),de=pe+1,be=he+1;f.push(he,pe,be),f.push(pe,de,be)}return[se.clone().addScaledVector($,.5),Te]}function Ue(se,$,W,J){let H=Math.PI/2,K=b.angle()-H,fe=[],me=new tr,ie=new tr;for(let q=0;q<=c;q++){let ee=[],Te=q/c;for(let ce=0;ce<=q;ce++){let he=((q?ce/q:0)-.5)*M,pe=Math.cos(he),de=Math.sin(he),be=Math.atan(Math.tan(K)*pe),Se=(H+be)*Te,Ie=Math.cos(Se),ft=Math.sin(Se);me.set(0,0,0),me.addScaledVector($,ft*pe),me.addScaledVector(W,Ie),me.addScaledVector(J,ft*de),ie.copy(se).addScaledVector(me,a),h.push(ie.x,ie.y,ie.z),d.push(me.x,me.y,me.z),m.push(0,0),ee.push(x++)}fe.push(ee)}let re=fe.length-1;for(let q=0;q<re;q++){let ee=fe[q],Te=fe[q+1],ce=ee.length-1;f.push(ee[0],Te[1],Te[0]);for(let le=1;le<=ce;le++)f.push(ee[le-1],ee[le],Te[le]),f.push(ee[le],Te[le+1],Te[le])}}}};var au=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var a,c,f,h,d;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((c=t==null?void 0:t.ui)!=null?c:{enabledIndieCorners:!1},i.ui),n=e.cornerRadius.reduce((m,x)=>m+x,0);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((f=e.surfaceMaxCount)!=null?f:n>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((h=e.height)!=null?h:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(d=e.depth)!=null?d:0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:o,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d={x:e*.5,y:r*.5},m={x:-d.x,y:-d.y},x={x:d.x,y:d.y};function S(N,te,A){return te>e&&A>r?Math.min(N*e/te,N*r/A):te>e?N*e/te:A>r?N*r/A:N}let w=[];w[0]=n[0]===0?0:S(n[0],n[0]+n[3],n[0]+n[1]),w[1]=n[1]===0?0:S(n[1],n[1]+n[2],n[1]+n[0]),w[2]=n[2]===0?0:S(n[2],n[2]+n[1],n[2]+n[3]),w[3]=n[3]===0?0:S(n[3],n[3]+n[0],n[3]+n[2]);let B=m.x,O=x.x,T=x.y,M=m.y;t.addPoint(t.createPoint(B,T)),t.addPoint(t.createPoint(O,T)),t.addPoint(t.createPoint(O,M)),t.addPoint(t.createPoint(B,M)),t.isClosed=!0;let F=!0;for(let N=0,te=t.points.length;N<te;N++)t.points[N].roundness=w[N],N>0&&w[N]!==w[N-1]&&(F=!1);F&&(t.roundness=w[0]),t.useCubicForRoundedCorners=o!==1,t.update();let k=ar.create({shape:t,parameters:{surfaceMaxCount:h,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(k,{userData:ue(j({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as d2}from"three";var A0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:o=64,phiStart:a,phiLength:c,thetaStart:f,thetaLength:h}=i.parameters,d=new d2(.5*t,n,o,a,c,f,h);return d.scale(1,e/t,r/t),Object.assign(d,{userData:ue(j({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as m2}from"three";var D0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,o=new m2(t,e,r,n);return o.scale(1,1,1),Object.assign(o,{userData:ue(j({},i),{type:"PlaneGeometry"})})}};var E0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a,c;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(c=e.depth)!=null?c:0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:o,angle:a,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h,surfaceMaxCount:d}=i.parameters,m=i.shape,x=t*.5,S=e*.5,w=0,B=0,O=a*Math.PI/360/n,T=Math.PI/2*3*-1,M=x*r/100,F=S*r/100;if(n==3&&r==50){O=2*Math.PI/n;for(let N=0;N<n;N++){let te=O*N,A=w+Math.sin(te)*x,b=B+Math.cos(te)*S;m.addPoint(m.createPoint(A,b))}}else for(let N=0;N<n;N++){let te=w+Math.cos(T)*x,A=B+Math.sin(T)*S;m.addPoint(m.createPoint(te,A)),T+=O,te=w+Math.cos(T)*M,A=B+Math.sin(T)*F,N<=n,m.addPoint(m.createPoint(te,A)),T+=O}m.isClosed=!0;for(let N=0,te=m.points.length;N<te;N++)m.points[N].roundness=o;m.roundness=o,m.update();let k=ar.create({shape:m,parameters:{surfaceMaxCount:d,roundness:o,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h}});return Object.assign(k,{userData:ue(j({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as g2}from"three";var lu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new g2(t,e);return Object.assign(r,{userData:ue(j({},i),{type:"TextFrameGeometry"})})}};var B0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var a,c,f;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs((c=e.height)!=null?c:e.width),o=Math.abs((f=e.depth)!=null?f:e.width*.25);return{parameters:Object.assign(e,{width:r,height:n,depth:o})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:o,arc:a,cornerRadius:c,cornerSegments:f}=i.parameters,h=y2(t,e,r,t*.5,a,o,0,0,n,c,f);return h.scale(1,e/t,1),Object.assign(h,{userData:ue(j({},i),{type:"TorusGeometry"})})}};function y2(i,t,e,r,n,o,a,c,f,h,d){return[t,e]=[e,t],a=t/2,n/=2*Math.PI,n==1&&(h=0),new Ia(!0,i,t,e,r,n,o,a,c,f,h,d)}import{TorusKnotBufferGeometry as x2}from"three";var G0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o,a;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width),tube:(a=e.tube)!=null?a:e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:o,q:a}=i.parameters,c=t*.5;c!==e&&(c-=e);let f=new x2(c,e,r,n,o,a);return Object.assign(f,{userData:ue(j({},i),{type:"TorusKnotGeometry"})})}};var R0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a,c;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(c=e.depth)!=null?c:0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a,isRect:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=t*.5,m=e*.5;c?(h.addPoint(h.createPoint(-d,m)),h.addPoint(h.createPoint(d,-m)),h.addPoint(h.createPoint(-d,-m))):(h.addPoint(h.createPoint(0,m)),h.addPoint(h.createPoint(d,-m)),h.addPoint(h.createPoint(-d,-m))),h.isClosed=!0;for(let S=0,w=h.points.length;S<w;S++)h.points[S].roundness=r;h.roundness=r,h.update();let x=ar.create({shape:h,parameters:{surfaceMaxCount:f,roundness:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(x,{userData:ue(j({},i),{type:"TriangleGeometry"})})}};var Pa={};vN(Pa,{addBarycentricAttribute:()=>C2,fixUvs:()=>T2,loadFromUrl:()=>L2,resizeGeometry:()=>w2,roundShapePolygon:()=>S2});import{BufferGeometryLoader as v2,Float32BufferAttribute as b2,Vector3 as Yh}from"three";var z0=function(i,t){let e=t.x-i.x,r=t.y-i.y,n=Math.sqrt(e*e+r*r),o=e/n,a=r/n,c=Math.atan2(a,o);return{x:e,y:r,len:n,nx:o,ny:a,ang:c}},S2=(i,t,e)=>{let r,n,o,a,c,f,h,d,m,x,S,w,B,O,T=t.length;for(a=t[T-2],i.curves=[],r=1;r<T-1;r++){c=t[r%T],f=t[(r+1)%T];let M=z0(c,a),F=z0(c,f);h=M.nx*F.ny-M.ny*F.nx,d=M.nx*F.nx-M.ny*-F.ny,S=Math.asin(h),m=1,x=!1,d<0?S<0?S=Math.PI+S:(S=Math.PI-S,m=-1,x=!0):S>0&&(m=-1,x=!0),w=S/2,O=Math.abs(Math.cos(w)*e/Math.sin(w)),O>Math.min(M.len/2,F.len/2)?(O=Math.min(M.len/2,F.len/2),B=Math.abs(O*Math.sin(w)/Math.cos(w))):B=e,n=c.x+F.nx*O,o=c.y+F.ny*O,n+=-F.ny*B*m,o+=F.nx*B*m,i.absarc(n,o,B,M.ang+Math.PI/2*m,F.ang-Math.PI/2*m,x),a=c,c=f}i.closePath()},w2=(i,{width:t,height:e,depth:r})=>{t=Math.abs(t),e=Math.abs(e),r=Math.abs(r);let n=i.userData.parameters,o,a,c;t===0?(t=n.width,o=1):o=t/n.width,e===0?(e=n.height,a=1):a=e/n.height,r===0?(r=n.depth,c=1):c=r/n.depth,i.scale(o,a,c),n.width=t,n.height=e,n.depth=r},C2=(i,t)=>{let e=[new Yh(1,0,0),new Yh(0,1,0),new Yh(0,0,1)],r=i.attributes.position,n=new Float32Array(r.count*3);for(let o=0,a=r.count;o<a;o++)e[o%3].toArray(n,o*3);i.setAttribute(t,new b2(n,3))},L2=i=>new Promise(t=>{new v2().load(i,r=>t(r))}),T2=(i,t,e)=>{let r=i.getAttribute("uv");if(r)for(let n=0;n<r.count;n++){let o=r.getX(n),a=r.getY(n);r.setXY(n,(o+t/2)/t,1-(a-e/2)/e*-1)}};import{BufferGeometry as F0,BufferAttribute as V0,Uint32BufferAttribute as Xh,Float32BufferAttribute as Zh,Matrix4 as _2}from"three";import{mergeVertices as I2}from"three/examples/jsm/utils/BufferGeometryUtils.js";var N2,cu=new Promise(i=>{N2=i});var De;cu.then(i=>{De=i});var U0=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),j0=new Uint32Array([0,1,2,3]),k0=new Uint8Array([4]),Jr=class{static build(i,t,e,r,n){let o,a,c;if(i===void 0)o=Jr.allocate(n,e),De.set_destination_refinement_level(o,0),a=Jr.buildLevel(o,!0,r);else if(i.positionWASM!==void 0){t&&t!==0&&(De.free_bvh(t),De.free_subdivision_surface(t));try{o=Jr.allocate(n,void 0,i)}catch(f){console.error(f,i),o=Jr.allocate(n,void 0,{positionWASM:U0,indexWASM:j0,verticesPerFaceWASM:k0})}De.set_destination_refinement_level(o,0),a=Jr.buildLevel(o,!0,r)}else o=t;if(i!==void 0&&i.subdivisions!==void 0){let f=O2(i.subdivisions,i.positionWASM.length);De.set_destination_refinement_level(o,f),f>0?c=Jr.buildLevel(o,!1,r):c=null}return{subdivPointer:o,originalGeometry:a,subdividedGeometry:c}}static allocate(i,t,e){var N;let r,n,o,a=[],c=[];if(e)e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,n=e.indexWASM,o=e.verticesPerFaceWASM):(r=U0,n=j0,o=k0);else{t.deleteAttribute("normal"),t.deleteAttribute("uv");let te=I2(t);r=te.attributes.position.array;let A=te.getIndex().array,b=A.length;switch(t.userData.type==="TorusGeometry"&&(t==null?void 0:t.userData.parameters.arc)===Math.PI*2&&(t.userData.type="ClosedTorusGeometry"),t.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":n=new Uint32Array(b/3*2),o=new Uint8Array(b/6).fill(4);for(let ne=0,xe=0;ne<b;ne+=6)n[xe++]=A[ne],n[xe++]=A[ne+1],n[xe++]=A[ne+4],n[xe++]=A[ne+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let V,P,R;if(t.userData.type==="SphereGeometry")P=t.parameters.heightSegments,V=t.parameters.widthSegments,t.parameters.thetaLength!==Math.PI&&(R=!0);else if(t.userData.type==="CylinderGeometry")P=t.parameters.heightSegments+2,V=t.parameters.radialSegments;else if(t.userData.type==="ConeGeometry")P=t.parameters.heightSegments+1,V=t.parameters.radialSegments;else if(t.userData.type==="TorusGeometry"){let ne=t.userData.parameters;P=Math.ceil(ne.tubularSegments*ne.arc/(2*Math.PI))+2,V=ne.radialSegments}else{let{pathSegments:ne,segments:xe,revolutions:_e}=t.userData.parameters;P=Math.ceil(xe*_e)+2,V=ne}R?(n=new Uint32Array(1*V*3+(P-1)*V*4),o=new Uint8Array(1*V+(P-1)*V)):(n=new Uint32Array(2*V*3+(P-2)*V*4),o=new Uint8Array(2*V+(P-2)*V));let E=0,G=0,ae=0;if(t.userData.type==="SphereGeometry"||t.userData.type==="HelixGeometry"||t.userData.type==="TorusGeometry"){for(;G<3*V;)n[G++]=A[E++],n[G++]=A[E++],n[G++]=A[E++],o[ae++]=3;let ne=R?n.length:3*V+4*(P-2)*V;for(;G<ne;E+=6)n[G++]=A[E],n[G++]=A[E+1],n[G++]=A[E+4],n[G++]=A[E+5],o[ae++]=4}else for(;G<4*(P-2)*V;E+=6)n[G++]=A[E],n[G++]=A[E+1],n[G++]=A[E+4],n[G++]=A[E+5],o[ae++]=4;for(;G<n.length;)n[G++]=A[E++],n[G++]=A[E++],n[G++]=A[E++],o[ae++]=3;break;default:n=A,o=new Uint8Array(b/3).fill(3);break}}let f=r.length,h=n.length,d=o.length,m=r.length+a.length+c.length,x=n.length+o.length,S=m*Float32Array.BYTES_PER_ELEMENT+x*Uint32Array.BYTES_PER_ELEMENT,w=m*Float32Array.BYTES_PER_ELEMENT,B=x*Uint32Array.BYTES_PER_ELEMENT,O=De._malloc(S),T=new Float32Array(De.HEAPF32.buffer,O,m),M=new Uint32Array(De.HEAPU32.buffer,O+w,x);T.set(r,0),T.set(a,r.length),T.set(c,r.length+a.length),M.set(n,0),M.set(o,n.length);let F;(N=e==null?void 0:e.scaleBaked)!=null&&N.some(te=>te!==1)&&(F=new _2().makeScale(...e.scaleBaked)),i&&(F?F.premultiply(i):F=i);let k=F?De.alloc_subdivision_surface2(O,f,O+w,h,O+w+n.length*Uint32Array.BYTES_PER_ELEMENT,d,F.elements):De.alloc_subdivision_surface(O,f,O+w,h,O+w+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return De._free(O),k}static buildLevel(i,t,e,r,n){let o=n?De.get_mesh_data2(i,t?De.Level.CONTROL:De.Level.REFINED,e!=null?e:!t,n.elements):De.get_mesh_data(i,t?De.Level.CONTROL:De.Level.REFINED,e!=null?e:!t),a=8,c=De.HEAPU32.subarray(o>>2,(o>>2)+a),f=c.subarray(4,4+4),h=0,d=De.HEAPU32[c[h]>>2],m=De.HEAPF32.subarray(d>>2,(d>>2)+f[h]);h++;let x=De.HEAPU32[c[h]>>2],S=De.HEAPF32.subarray(x>>2,(x>>2)+f[h]);h++;let w=De.HEAPU32[c[h]>>2],B=De.HEAPU32.subarray(w>>2,(w>>2)+f[h]);h++;let O=De.HEAPU32[c[h]>>2],T=De.HEAPU32.subarray(O>>2,(O>>2)+f[h]);if(h++,r===void 0){let M=new F0;if(M.setIndex(new Xh(T,1)),M.setAttribute("position",new Zh(m,3)),M.setAttribute("normal",new Zh(S,3)),t){M.setAttribute("faceMap",new Xh(B,1));let F=new Float32Array(S.length/3*4).fill(0);M.setAttribute("color",new V0(F,4))}return De.free_mesh_data(o),M.userData.type="SubdivGeometry",M}r.getAttribute("position").copyArray(m),r.getAttribute("normal").copyArray(S),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,De.free_mesh_data(o)}static buildControlCageWireframe(i,t,e){let r=De.get_wireframe_data_for_base_level(i),n=4,o=De.HEAPU32.subarray(r>>2,(r>>2)+n),a=o.subarray(2,2+2),c=0,f=De.HEAPU32[o[c]>>2],h=De.HEAPF32.subarray(f>>2,(f>>2)+a[c]);c++;let d=De.HEAPU32[o[c]>>2],m=De.HEAPU32.subarray(d>>2,(d>>2)+a[c]);if(t===void 0){let x=new F0;x.setAttribute("position",new Zh(h,3));let S=new Float32Array(h.length);for(let w=0,B=h.length;w<B;)S[w++]=e.r,S[w++]=e.g,S[w++]=e.b;return x.setAttribute("color",new V0(S,3)),x.setIndex(new Xh(m,1)),De.free_wireframe_data_for_base_level(r),x}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,De.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,t,e){t||De.set_destination_refinement_level(i,1);let r=e?De.get_topological_data2(i,t?De.Level.CONTROL:De.Level.REFINED,e.elements):De.get_topological_data(i,t?De.Level.CONTROL:De.Level.REFINED),n=6,o=De.HEAPU32.subarray(r>>2,(r>>2)+n),a=o.subarray(3,3+3),c=0,f=De.HEAPU32[o[c]>>2],h=new Float32Array(De.HEAPF32.subarray(f>>2,(f>>2)+a[c]));c++;let d=De.HEAPU32[o[c]>>2],m=new Uint32Array(De.HEAPU32.subarray(d>>2,(d>>2)+a[c]));c++;let x=De.HEAPU32[o[c]>>2],S=new Uint8Array(De.HEAPU32.subarray(x>>2,(x>>2)+a[c]));return De.free_topological_data(r),{positions:h,indices:m,verticesPerFace:S}}};function O2(i,t){let e=i;return e=Math.min(e,3-Math.ceil(Math.log(t/172e3)/Math.log(4))),Math.max(e,0)}var Qh={ConeGeometry:qx,CubeGeometry:$x,CylinderGeometry:Wx,DodecahedronGeometry:Jx,EllipseGeometry:x0,HelixGeometry:C0,IcosahedronGeometry:L0,LatheGeometry:T0,NonParametricGeometry:O0,PolygonGeometry:M0,PyramidGeometry:P0,RectangleGeometry:au,SphereGeometry:A0,PlaneGeometry:D0,StarGeometry:E0,TextFrameGeometry:lu,TorusGeometry:B0,TorusKnotGeometry:G0,TriangleGeometry:R0,VectorGeometry:ar},Aa=i=>Qh[i.type].create(i);import{Matrix4 as tp}from"three";import{Box3 as J0,Line3 as fn,Matrix4 as ep,Vector3 as wt}from"three";import{HemisphereLight as H0}from"three";import{Color as M2}from"three";var Er=class extends M2{constructor(e,r,n,o){super(e,r,n);this.isColorA=!0;this.a=o}setRGBA(e,r,n,o){super.setRGB(e,r,n),this.a=o}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};function Vt(i,t){let e;if(typeof i=="string"){let r=t==null?void 0:t.getColor(i);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Er(0,0,0,0))}else return"a"in i?new Er(i.r,i.g,i.b,i.a):new Er(i.r,i.g,i.b,1);return e}var uu=i=>"isEntity"in i,Ss=i=>"isAbstractMesh"in i;var fi=i=>"objectHelper"in i;function P2(i,t){var r;let e=!1;t.position&&(i.position.fromArray(t.position),e=!0),t.rotation&&(i.rotation.fromArray(t.rotation),e=!0),t.scale&&(e=!0,i.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(e=!0,i.hiddenMatrix.fromArray((r=t.hiddenMatrix)!=null?r:Di.identity)),e&&i.updateMatrix(),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(t.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=t.isUpVectorFlipped),i.updateUp())}function A2(i,t){P2(i,t),t.name!==void 0&&(i.name=t.name),t.visible!==void 0&&(i.isEntity?i.visibility=t.visible:i.visible=t.visible)}function W0(i,t,e){A2(i,t),t.color!==void 0&&(i.color=Vt(t.color,e)),t.intensity!==void 0&&(i.intensity=t.intensity),t.shadows!==void 0&&!(i instanceof H0)&&(i.castShadow=t.shadows),i.shadow&&!(i instanceof H0)&&t.depth!==void 0&&(i.shadow.camera.far=t.depth,i.shadow.needsUpdate=!0),t.helper!==void 0&&fi(i)&&(i.enableHelper=t.helper,i.gizmos.shadowmap.visible=t.helper)}function q0(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var ws=new J0,lr=new wt,Me=new wt,Ht=new ep;function D2(i,t,e=0,r=t.count){let n=1/0,o=1/0,a=1/0,c=-1/0,f=-1/0,h=-1/0;for(let d=e;d<r;d++){let m=t.getX(d),x=t.getY(d),S=t.getZ(d);m<n&&(n=m),x<o&&(o=x),S<a&&(a=S),m>c&&(c=m),x>f&&(f=x),S>h&&(h=S)}return i.min.set(n,o,a),i.max.set(c,f,h),i}var $0=(i,t,e,r)=>{var n;if(Ss(i)){let o=i.geometry.userData.parameters,a=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?lr.copy(i.originalGeometry.boundingSphere.center):(D2(ws,a,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:a.count),ws.getCenter(lr)),i.forceComputeSize?ws.getSize(Me).multiplyScalar(.5):Me.set(o.width,o.height,(n=o.depth)!=null?n:0).multiplyScalar(.5)}else if(fi(i)&&r===!0){let o=i.geometryHelper.getAttribute("position");ws.setFromArray(o.array),ws.getCenter(lr),ws.getSize(Me).multiplyScalar(.5)}else lr.setScalar(0),Me.setScalar(0);Ht.copy(t).multiply(i.matrixWorld),Me.x===0&&Me.y===0&&Me.z===0?e.push(new wt(lr.x,lr.y,lr.z).applyMatrix4(Ht)):e.push(new wt(-Me.x,Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(-Me.x,-Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,-Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(-Me.x,Me.y,-Me.z).add(lr).applyMatrix4(Ht),new wt(-Me.x,-Me.y,-Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,-Me.y,-Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,Me.y,-Me.z).add(lr).applyMatrix4(Ht))},Da=class extends J0{constructor(){super(...arguments);this.matrix=new ep;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let n=new ep().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let o=[];return n===!0?e.traverseEntity(a=>$0(a,r,o,e.enableHelper===!0)):$0(e,r,o,e.enableHelper===!0),this.setFromPoints(o)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Ht.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Me).multiplyScalar(.5),this.getCenter(lr),Ht.copy(this.matrix).setPosition(lr),this.vertices=[new wt(-Me.x,Me.y,Me.z).applyMatrix4(Ht),new wt(-Me.x,-Me.y,Me.z).applyMatrix4(Ht),new wt(Me.x,-Me.y,Me.z).applyMatrix4(Ht),new wt(Me.x,Me.y,Me.z).applyMatrix4(Ht),new wt(-Me.x,Me.y,-Me.z).applyMatrix4(Ht),new wt(-Me.x,-Me.y,-Me.z).applyMatrix4(Ht),new wt(Me.x,-Me.y,-Me.z).applyMatrix4(Ht),new wt(Me.x,Me.y,-Me.z).applyMatrix4(Ht)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new fn(this.vertices[0],this.vertices[3]),new fn(this.vertices[1],this.vertices[2]),new fn(this.vertices[5],this.vertices[6]),new fn(this.vertices[4],this.vertices[7]),new fn(this.vertices[0],this.vertices[1]),new fn(this.vertices[3],this.vertices[2]),new fn(this.vertices[7],this.vertices[6]),new fn(this.vertices[4],this.vertices[5]),new fn(this.vertices[0],this.vertices[4]),new fn(this.vertices[1],this.vertices[5]),new fn(this.vertices[2],this.vertices[6]),new fn(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new wt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new wt().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new wt().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new wt().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new wt().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new wt().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new wt().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as E2,Matrix4 as B2,Light as G2}from"three";function Ea(i){let t=[];for(let e in i){let r=i[e];delete r.metadata,t.push(r)}return t}function R2(i){let t=[];for(let e in i)t.push(i[e]);return t}var fu=i=>class extends i{hasEntityChild(){return this.children.some(e=>uu(e))}isDescendantOf(e){e instanceof E2&&(e=e.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===e)return!0;r=r.parent}return!1}attach(e,r){this.updateWorldMatrix(!0,!1);let n=new B2().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),n.multiply(e.parent.matrixWorld)),uu(e)?e.hiddenMatrix.premultiply(n):e.applyMatrix4(n),e.updateWorldMatrix(!1,!1),this.add(e),r!==void 0&&(this.children.pop(),this.children.splice(r,0,e)),this}copy(e,r=!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.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.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let n=0;n<e.children.length;n++){let o=e.children[n];this.add(o.clone())}return this}toJSON(e){let r=e===void 0,n={object:{uuid:"",objectType:""}};e===void 0&&(e={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},n.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let o={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(o.name=this.name),o.matrix=this.matrix.toArray(),this.castShadow===!0&&(o.castShadow=!0),this.receiveShadow===!0&&(o.receiveShadow=!0),this.visible===!1&&(o.visible=!1),this.frustumCulled===!1&&(o.frustumCulled=!1),this.renderOrder!==0&&(o.renderOrder=this.renderOrder),o.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(o.userData=this.userData),this.children.length>0){o.children=[];for(let a of this.children)(uu(a)||a instanceof G2)&&o.children.push(a.toJSON(e).object)}if(r){let a=Ea(e.geometries),c=Ea(e.materials),f=Ea(e.textures),h=Ea(e.images),d=Ea(e.interactionStates),m=R2(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),f.length>0&&(n.textures=f),h.length>0&&(n.images=h),d.length>0&&(n.interactionStates=d),m.length>0&&(n.nodes=m)}return n.object=o,n}fromJSON(e){return this.uuid=e.uuid,e.name!==void 0&&(this.name=e.name),e.matrix!==void 0?(this.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=e.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(e.position!==void 0&&this.position.fromArray(e.position),e.rotation!==void 0&&this.rotation.fromArray(e.rotation),e.quaternion!==void 0&&this.quaternion.fromArray(e.quaternion),e.scale!==void 0&&this.scale.fromArray(e.scale)),this.castShadow=e.castShadow!==void 0,this.receiveShadow=e.receiveShadow!==void 0,e.visible!==void 0&&(this.visible=e.visible),e.frustumCulled!==void 0&&(this.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(this.renderOrder=e.renderOrder),e.layers!==void 0&&(this.layers.mask=e.layers),e.userData!==void 0&&(this.userData=e.userData),this}};var hn=i=>"isEntity"in i;var pn=i=>class extends fu(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new tp;this._singleBBox=new Da;this._recursiveBBox=new Da;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let n of this.children)hn(n)&&n.traverseEntity(o=>{fi(o)&&o.visible&&(o.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{hn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let n of this.children)hn(n)&&n.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){let o=this.parent;if(r&&o!==null&&o.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),n)for(let a of this.children)a.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,n=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),n===!0)for(let o of r.children)hn(o)&&this.add(o.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,n=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),n===!0)for(let o of r.children)hn(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let r=new tp,n=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(n);for(let o of this.children)hn(o)&&o.hiddenMatrix.premultiply(r)}toJSON(r){let n=super.toJSON(r),o=n.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),n}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let n=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new tp}),this.copy(r),r.children=n,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return os(n,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let n=j({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(r));return os(n,r)}fromState(r,n){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};import{Object3D as z2,Vector3 as Ba,Euler as K0,MathUtils as Ui}from"three";var Ga=class extends z2{constructor(e,r={}){super();this.object=e;let n=e.recursiveBBox.getSize(new Ba),o=.1;this.parameters=Lc.defaultData(n.toArray(),o),co(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(e){let r=this.object.material.map(n=>n.clone());for(let n of this.children)n.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let r=this.object.material.clone();for(let n of this.children)n.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let r=0,n=e-this.children.length;r<n;++r){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,n=this.children.length-e;r<n;++r)this.remove(this.children[0])}_updateRadial(e){let r=e.radial,n=r.start*Ui.DEG2RAD,o=r.end*Ui.DEG2RAD,a=n-o,c=new K0(r.rotation[0]*Ui.DEG2RAD,r.rotation[1]*Ui.DEG2RAD,r.rotation[2]*Ui.DEG2RAD),f;switch(r.axis){case"z":f=new Ba(0,0,1);break;case"y":f=new Ba(0,1,0);break;default:case"x":f=new Ba(1,0,0);break}for(let[h,d]of this.children.entries()){d.hiddenMatrix.identity(),d.scale.x=r.scale[0],d.scale.y=r.scale[1],d.scale.z=r.scale[2],d.position.setScalar(0);let m=a/e.count*h-n;switch(r.axis){case"x":d.rotation.set(0,m,0);break;case"y":d.rotation.set(0,0,m);break;case"z":d.rotation.set(m,0,0);break}d.translateOnAxis(f,r.radius),d.position.x+=r.position[0],d.position.y+=r.position[1],d.position.z+=r.position[2],r.alignment===!0?(d.rotation.x+=c.x,d.rotation.y+=c.y,d.rotation.z+=c.z):d.rotation.copy(c)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,n=new K0(r.rotation[0]*Ui.DEG2RAD,r.rotation[1]*Ui.DEG2RAD,r.rotation[2]*Ui.DEG2RAD);for(let[o,a]of this.children.entries())a.hiddenMatrix.identity(),a.scale.x=1+(r.scale[0]-1)*o,a.scale.y=1+(r.scale[1]-1)*o,a.scale.z=1+(r.scale[2]-1)*o,a.rotation.x=n.x*o,a.rotation.y=n.y*o,a.rotation.z=n.z*o,a.position.x=r.position[0]*o,a.position.y=r.position[1]*o,a.position.z=r.position[2]*o}_updateGrid(e){let r=0,n=e.grid;if(n.useCenter===!0){let o={x:n.count[0]%2===0?2:1,y:n.count[1]%2===0?2:1,z:n.count[2]%2===0?2:1},a=new Ba(n.size[0]*(n.count[0]-o.x)*.5,n.size[1]*(n.count[1]-o.y)*.5,n.size[2]*(n.count[2]-o.z)*.5);for(let c=0;c<n.count[0];c++)for(let f=0;f<n.count[1];f++)for(let h=0;h<n.count[2];h++){let d=this.children[r++];d.hiddenMatrix.identity(),d.scale.setScalar(1),d.rotation.set(0,0,0),d.position.x=n.size[0]*c-a.x,d.position.y=n.size[1]*f-a.y,d.position.z=n.size[2]*h-a.z}}else for(let o=0;o<n.count[0];o++)for(let a=0;a<n.count[1];a++)for(let c=0;c<n.count[2];c++){let f=this.children[r++];f.hiddenMatrix.identity(),f.scale.setScalar(1),f.rotation.set(0,0,0),f.position.x=n.size[0]*o,f.position.y=-n.size[1]*a,f.position.z=-n.size[2]*c}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),co(this.parameters,e),this.update(),this}};var rr=class extends pn(F2){constructor(e,r){super(e,r);this.isAbstractMesh=!0;Array.isArray(r)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r!=null?r:0),r=r!=null?r:this.selectedMaterial,this.material[r].dispose(),this.material[r]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let r=this.geometry,n=Qh[r.userData.type],o=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,a=n.build(n.normalizeInputs(e,o)),c=r.uuid;if(this.geometry.dispose(),this.geometry=a,this.geometry.uuid=c,this.geometry.computeBoundingSphere(),this.cloner)for(let f of this.cloner.children)f.geometry=this.geometry}resizeGeometry(e,r,n){Pa.resizeGeometry(this.geometry,{width:e,height:r,depth:n})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,n=Aa(r),o=Array.isArray(this.material)?this.material.map(a=>a.clone()):this.material.clone();return new this.constructor(n,o).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new Ga(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new Ga(this)),this.cloner.fromClonerState(e))}fromState(e,r){var n,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(n=e.castShadow)!=null?n:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as sD,ShaderMaterial as aD,FrontSide as lD}from"three";import{CubeReflectionMapping as X2,CubeRefractionMapping as Z2,CubeUVReflectionMapping as Q2,LinearEncoding as ev,sRGBEncoding as eD}from"three";var Ra=class{constructor(t){t=t!=null?t:{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};import{MathUtils as V2}from"three";var Pe=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=V2.generateUUID(),this.type=t,this.name="",this.userData={}}analyze(t,e){e=e!=null?e:{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r!=null?r:{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r!=null?r:{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e!=null?e:this.getType(t,e);let n=t.getNodeData(r!=null?r:this);return t.analyzing&&this.appendDepsNode(t,n,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,n,o,a){return""}generate(t,e,r,n,o){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getJSONNode(t){if((t==null?void 0:t.materials)&&(t==null?void 0:t.materials[this.uuid])!==void 0)return t.materials[this.uuid]}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Pe&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)e=this.hashProperties[n],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}copy(t){return this.name=t.name,t.type&&(this.type=t.type),t.frameId&&(this.frameId=t.frameId),t.hashProperties&&(this.hashProperties=t.hashProperties.map(e=>e)),this.userData=JSON.parse(JSON.stringify(t.userData)),this.shortcuts=JSON.parse(JSON.stringify(t.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(t){let e=t===void 0||typeof t=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!e&&t&&(t.nodes[this.uuid]=r),r}toJSON(t){var e;return(e=this.getJSONNode(t))!=null?e:this.createJSONNode(t)}fromJSON(t,e){return this.uuid=t.uuid,this.type=t.type,t.name&&(this.name=t.name),t.userData&&(this.userData=t.userData),this}};var rp=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xt=new rp;import{Vector2 as Y0}from"three";import{MathUtils as U2}from"three";var Ee=class extends Pe{constructor(e,r){super(e);this.scope="";r=r!=null?r:{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,n,o){if(r=r!=null?r:this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=U2.generateUUID()),n=e.getUUID(n!=null?n:this.getUUID(),!a);let c=e.getNodeData(n),f=c.output||this.getType(e);if(e.analyzing)return(c.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,c,r),this.generate(e,r,n)):super.build(e,r,n);if(a)return c.name=c.name||super.build(e,r,n),c.name;if(!this.getLabel()&&(!this.getShared(e,f)||e.context.ignoreCache||c.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let h=this.getTemp(e,n);if(h)return e.format(h,f,r);{h=super.generate(e,r,n,c.output,o);let d=this.generate(e,f,n);return e.addNodeCode(h+" = "+d+";"),e.format(h,f,r)}}return super.build(e,r,n)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,o,a){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n!=null?n:this.uuid,e.getTempVar(n,o!=null?o:this.getType(e),a,this.getLabel()).name}};var Ct=class extends Ee{constructor(e,r){r=r!=null?r:{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let r=super.createJSONNode(e);return this.readonly===!0&&(r.readonly=this.readonly),r}fromJSON(e,r){return super.fromJSON(e,r),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,r,n,o,a,c){n=e.getUUID(n!=null?n:this.getUUID()),o=o!=null?o:this.getType(e);let f=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,o,a,c):e.isShader("vertex")?(f.vertex||(f.vertex=e.createVertexUniform(o,this,a,c,this.getLabel())),e.format(f.vertex.name,o,r)):(f.fragment||(f.fragment=e.createFragmentUniform(o,this,a,c,this.getLabel())),e.format(f.fragment.name,o,r))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var mr=class extends Ct{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Y0?e:new Y0(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,n,o,a,c){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as X0}from"three";var gr=class extends Ct{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof X0?e:new X0(e,r,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,n,o,a,c){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var hi=class extends Ct{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Er?e:new Er(e.r,e.g,e.b,e.a)}generateReadonly(e,r,n,o,a,c){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var j2=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Z0=/[a-z_0-9]+/gi,we=class extends Ee{constructor(e,r,n,o,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,n,o)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,n,o,a){let c,f=0,h=this.src;if(this.includes)for(let m=0;m<this.includes.length;m++)e.include(this.includes[m],this);for(let m in this.extensions)e.extensions[m]=!0;let d=[];for(;c=Z0.exec(this.src);)d.push(c);for(let m=0;m<d.length;m++){let x=d[m],S=x[0],w=this.isMethod?!this.getInputByName(S):!0,B=S;if(this.keywords[S]||this.useKeywords&&w&&Xt.containsKeyword(S)){let O=this.keywords[S];if(!O){let T=Xt.getKeywordData(S);T.cache&&(O=e.keywords[S]),O=O||Xt.getKeyword(S,e),T.cache&&(e.keywords[S]=O)}B=O.build(e)}S!==B&&(h=h.substring(0,x.index+f)+B+h.substring(x.index+S.length+f),f+=B.length-S.length),this.getIncludeByName(B)===void 0&&Xt.contains(B)&&e.include(Xt.get(B))}return r==="source"?h:this.isMethod?(this.isInterface||e.include(this,void 0,h),this.name):e.format("( "+h+" )",this.getType(e),r)}parse(e,r,n,o){if(this.src=e||"",this.includes=r!=null?r:[],this.extensions=n!=null?n:{},this.keywords=o!=null?o:{},this.isMethod){let a=j2.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let c=a[3].match(Z0);if(c){let f=0;for(;f<c.length;){let h=c[f++],d;h==="in"||h==="out"||h==="inout"?d=c[f++]:(d=h,h="");let m=c[f++];this.inputs.push({name:m,type:d,qualifier:h})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var n;let r=this.getJSONNode(e);if(!r){r=this.createJSONNode(e),r.src=this.src,r.isMethod=this.isMethod,r.useKeywords=this.useKeywords,this.isMethod||(r.type=this.type),r.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let a in this.keywords)o[a]=this.keywords[a].toJSON(e).uuid;if(r.keywords=o,(n=this.includes)!=null&&n.length){let a=[];for(let c=0;c<this.includes.length;c++)a.push(this.includes[c].toJSON(e).uuid);r.includes=a}r.isMethod=this.isMethod,r.inputs=this.inputs}return r.nodeType=this.nodeType,r}fromJSON(e,r){if(super.fromJSON(e,r),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&r){this.keywords={};for(let n in e.keywords)this.keywords[n]=r.getNode(e.keywords[n])}return e.includes&&r&&(this.includes=e.includes.map(n=>r.getNode(n))),this}};var k2=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,np=class extends Ee{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||np.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,n,o,a){this.src=e||"";let c,f,h="",d=k2.exec(e);this.useDefine=a!=null?a:this.src.charAt(0)==="#",d&&d.length>1?(f=d[1],c=d[2],h=d[3]):(c=this.src,f="f"),this.name=c,this.type=f,this.value=h}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,n,o,a){return e.format(this.name,this.getType(e),r)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},rt=np;rt.PI="PI",rt.PI2="PI2",rt.RECIPROCAL_PI="RECIPROCAL_PI",rt.RECIPROCAL_PI2="RECIPROCAL_PI2",rt.LOG2="LOG2",rt.EPSILON="EPSILON";var H2=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
21
- )*?)}`,"gim"),W2=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Cs=class extends Ee{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,n,o,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=H2.exec(e);if(r){let n=r[2],o;for(;o=W2.exec(n);)this.inputs.push({type:o[1],name:o[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ls=class extends Ee{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,r){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",o=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(o,this.getType(e),r)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.index=this.index),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.index&&(this.index=e.index),this}};Xt.addKeyword("uv",function(){return new Ls});Xt.addKeyword("uv2",function(){return new Ls(1)});import{LinearEncoding as q2,sRGBEncoding as $2}from"three";var go=class extends Ee{constructor(e=new Pe,r){super("v4");this.nodeType="ColorSpace";this.factor=new Pe;this.input=e,this.method=r!=null?r:go.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case q2:return["Linear"];case $2:return["sRGB"];default:return[]}}generate(e,r){var f;let n=this.input.build(e,"v4"),o=this.getType(e),a=go.Nodes[this.method],c=e.include(a);if(c===go.LINEAR_TO_LINEAR)return e.format(n,o,r);if(((f=a.inputs)==null?void 0:f.length)===2){let h=this.factor.build(e,"f");return e.format(c+"( "+n+", "+h+" )",o,r)}else return e.format(c+"( "+n+" )",o,r)}fromEncoding(e){let r=go.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=go.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},Lr=go;Lr.Nodes={LinearToLinear:new we(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
+ }`;var Je=qm(function(){return st(v,Ne+"return "+oe).apply(i,C)});if(Je.source=oe,Ff(Je))throw Je;return Je}function CT(s){return lt(s).toLowerCase()}function LT(s){return lt(s).toUpperCase()}function TT(s,l,u){if(s=lt(s),s&&(u||l===i))return s.replace(Qe,"");if(!s||!(l=Ur(l)))return s;var p=vn(s),g=vn(l),v=nd(p,g),C=id(p,g)+1;return Ti(p,v,C).join("")}function NT(s,l,u){if(s=lt(s),s&&(u||l===i))return s.replace(dt,"");if(!s||!(l=Ur(l)))return s;var p=vn(s),g=id(p,vn(l))+1;return Ti(p,0,g).join("")}function _T(s,l,u){if(s=lt(s),s&&(u||l===i))return s.replace(ot,"");if(!s||!(l=Ur(l)))return s;var p=vn(s),g=nd(p,vn(l));return Ti(p,g).join("")}function IT(s,l){var u=A,p=b;if(Pt(l)){var g="separator"in l?l.separator:g;u="length"in l?We(l.length):u,p="omission"in l?Ur(l.omission):p}s=lt(s);var v=s.length;if(Po(s)){var C=vn(s);v=C.length}if(u>=v)return s;var L=u-Ao(p);if(L<1)return p;var _=C?Ti(C,0,L).join(""):s.slice(0,L);if(g===i)return _+p;if(C&&(L+=_.length-L),Vf(g)){if(s.slice(L).search(g)){var Z,Q=_;for(g.global||(g=tf(g.source,lt(xn.exec(g))+"g")),g.lastIndex=0;Z=g.exec(Q);)var oe=Z.index;_=_.slice(0,oe===i?L:oe)}}else if(s.indexOf(Ur(g),L)!=L){var ge=_.lastIndexOf(g);ge>-1&&(_=_.slice(0,ge))}return _+p}function OT(s){return s=lt(s),s&&_o.test(s)?s.replace(Ki,iS):s}var MT=zo(function(s,l,u){return s+(u?" ":"")+l.toUpperCase()}),kf=$d("toUpperCase");function Wm(s,l,u){return s=lt(s),l=u?i:l,l===i?Qb(s)?aS(s):Hb(s):s.match(l)||[]}var qm=Xe(function(s,l){try{return Fr(s,i,l)}catch(u){return Ff(u)?u:new je(u)}}),PT=ei(function(s,l){return Qr(l,function(u){u=En(u),Zn(s,u,Rf(s[u],s))}),s});function AT(s){var l=s==null?0:s.length,u=Be();return s=l?It(s,function(p){if(typeof p[1]!="function")throw new en(n);return[u(p[0]),p[1]]}):[],Xe(function(p){for(var g=-1;++g<l;){var v=s[g];if(Fr(v[0],this,p))return Fr(v[1],this,p)}})}function DT(s){return i1(rn(s,f))}function Hf(s){return function(){return s}}function ET(s,l){return s==null||s!==s?l:s}var BT=Kd(),GT=Kd(!0);function Pr(s){return s}function Wf(s){return Td(typeof s=="function"?s:rn(s,f))}function RT(s){return _d(rn(s,f))}function zT(s,l){return Id(s,rn(l,f))}var FT=Xe(function(s,l){return function(u){return ra(u,s,l)}}),VT=Xe(function(s,l){return function(u){return ra(s,u,l)}});function qf(s,l,u){var p=Qt(l),g=_l(l,p);u==null&&!(Pt(l)&&(g.length||!p.length))&&(u=l,l=s,s=this,g=_l(l,Qt(l)));var v=!(Pt(u)&&"chain"in u)||!!u.chain,C=ri(s);return Qr(g,function(L){var _=l[L];s[L]=_,C&&(s.prototype[L]=function(){var Z=this.__chain__;if(v||Z){var Q=s(this.__wrapped__),oe=Q.__actions__=Ir(this.__actions__);return oe.push({func:_,args:arguments,thisArg:s}),Q.__chain__=Z,Q}return _.apply(s,xi([this.value()],arguments))})}),s}function UT(){return Zt._===this&&(Zt._=pS),this}function $f(){}function jT(s){return s=We(s),Xe(function(l){return Od(l,s)})}var kT=Lf(It),HT=Lf(Zp),WT=Lf(Ju);function $m(s){return Pf(s)?Ku(En(s)):S1(s)}function qT(s){return function(l){return s==null?i:no(s,l)}}var $T=Xd(),JT=Xd(!0);function Jf(){return[]}function Kf(){return!1}function KT(){return{}}function YT(){return""}function XT(){return!0}function ZT(s,l){if(s=We(s),s<1||s>ne)return[];var u=Le,p=fr(s,Le);l=Be(l),s-=Le;for(var g=Zu(p,l);++u<s;)l(u);return g}function QT(s){return ke(s)?It(s,En):jr(s)?[s]:Ir(pm(lt(s)))}function eN(s){var l=++fS;return lt(s)+l}var tN=Dl(function(s,l){return s+l},0),rN=Tf("ceil"),nN=Dl(function(s,l){return s/l},1),iN=Tf("floor");function oN(s){return s&&s.length?Nl(s,Pr,uf):i}function sN(s,l){return s&&s.length?Nl(s,Be(l,2),uf):i}function aN(s){return td(s,Pr)}function lN(s,l){return td(s,Be(l,2))}function cN(s){return s&&s.length?Nl(s,Pr,df):i}function uN(s,l){return s&&s.length?Nl(s,Be(l,2),df):i}var fN=Dl(function(s,l){return s*l},1),hN=Tf("round"),pN=Dl(function(s,l){return s-l},0);function dN(s){return s&&s.length?Xu(s,Pr):0}function mN(s,l){return s&&s.length?Xu(s,Be(l,2)):0}return y.after=RC,y.ary=Lm,y.assign=LL,y.assignIn=zm,y.assignInWith=ql,y.assignWith=TL,y.at=NL,y.before=Tm,y.bind=Rf,y.bindAll=PT,y.bindKey=Nm,y.castArray=KC,y.chain=Sm,y.chunk=iw,y.compact=ow,y.concat=sw,y.cond=AT,y.conforms=DT,y.constant=Hf,y.countBy=dC,y.create=_L,y.curry=_m,y.curryRight=Im,y.debounce=Om,y.defaults=IL,y.defaultsDeep=OL,y.defer=zC,y.delay=FC,y.difference=aw,y.differenceBy=lw,y.differenceWith=cw,y.drop=uw,y.dropRight=fw,y.dropRightWhile=hw,y.dropWhile=pw,y.fill=dw,y.filter=gC,y.flatMap=vC,y.flatMapDeep=bC,y.flatMapDepth=SC,y.flatten=ym,y.flattenDeep=mw,y.flattenDepth=gw,y.flip=VC,y.flow=BT,y.flowRight=GT,y.fromPairs=yw,y.functions=GL,y.functionsIn=RL,y.groupBy=wC,y.initial=vw,y.intersection=bw,y.intersectionBy=Sw,y.intersectionWith=ww,y.invert=FL,y.invertBy=VL,y.invokeMap=LC,y.iteratee=Wf,y.keyBy=TC,y.keys=Qt,y.keysIn=Mr,y.map=Vl,y.mapKeys=jL,y.mapValues=kL,y.matches=RT,y.matchesProperty=zT,y.memoize=jl,y.merge=HL,y.mergeWith=Fm,y.method=FT,y.methodOf=VT,y.mixin=qf,y.negate=kl,y.nthArg=jT,y.omit=WL,y.omitBy=qL,y.once=UC,y.orderBy=NC,y.over=kT,y.overArgs=jC,y.overEvery=HT,y.overSome=WT,y.partial=zf,y.partialRight=Mm,y.partition=_C,y.pick=$L,y.pickBy=Vm,y.property=$m,y.propertyOf=qT,y.pull=Nw,y.pullAll=vm,y.pullAllBy=_w,y.pullAllWith=Iw,y.pullAt=Ow,y.range=$T,y.rangeRight=JT,y.rearg=kC,y.reject=MC,y.remove=Mw,y.rest=HC,y.reverse=Bf,y.sampleSize=AC,y.set=KL,y.setWith=YL,y.shuffle=DC,y.slice=Pw,y.sortBy=GC,y.sortedUniq=zw,y.sortedUniqBy=Fw,y.split=vT,y.spread=WC,y.tail=Vw,y.take=Uw,y.takeRight=jw,y.takeRightWhile=kw,y.takeWhile=Hw,y.tap=oC,y.throttle=qC,y.thru=Fl,y.toArray=Bm,y.toPairs=Um,y.toPairsIn=jm,y.toPath=QT,y.toPlainObject=Rm,y.transform=XL,y.unary=$C,y.union=Ww,y.unionBy=qw,y.unionWith=$w,y.uniq=Jw,y.uniqBy=Kw,y.uniqWith=Yw,y.unset=ZL,y.unzip=Gf,y.unzipWith=bm,y.update=QL,y.updateWith=eT,y.values=Uo,y.valuesIn=tT,y.without=Xw,y.words=Wm,y.wrap=JC,y.xor=Zw,y.xorBy=Qw,y.xorWith=eC,y.zip=tC,y.zipObject=rC,y.zipObjectDeep=nC,y.zipWith=iC,y.entries=Um,y.entriesIn=jm,y.extend=zm,y.extendWith=ql,qf(y,y),y.add=tN,y.attempt=qm,y.camelCase=oT,y.capitalize=km,y.ceil=rN,y.clamp=rT,y.clone=YC,y.cloneDeep=ZC,y.cloneDeepWith=QC,y.cloneWith=XC,y.conformsTo=eL,y.deburr=Hm,y.defaultTo=ET,y.divide=nN,y.endsWith=sT,y.eq=Sn,y.escape=aT,y.escapeRegExp=lT,y.every=mC,y.find=yC,y.findIndex=mm,y.findKey=ML,y.findLast=xC,y.findLastIndex=gm,y.findLastKey=PL,y.floor=iN,y.forEach=wm,y.forEachRight=Cm,y.forIn=AL,y.forInRight=DL,y.forOwn=EL,y.forOwnRight=BL,y.get=Uf,y.gt=tL,y.gte=rL,y.has=zL,y.hasIn=jf,y.head=xm,y.identity=Pr,y.includes=CC,y.indexOf=xw,y.inRange=nT,y.invoke=UL,y.isArguments=so,y.isArray=ke,y.isArrayBuffer=nL,y.isArrayLike=Or,y.isArrayLikeObject=Gt,y.isBoolean=iL,y.isBuffer=Ni,y.isDate=oL,y.isElement=sL,y.isEmpty=aL,y.isEqual=lL,y.isEqualWith=cL,y.isError=Ff,y.isFinite=uL,y.isFunction=ri,y.isInteger=Pm,y.isLength=Hl,y.isMap=Am,y.isMatch=fL,y.isMatchWith=hL,y.isNaN=pL,y.isNative=dL,y.isNil=gL,y.isNull=mL,y.isNumber=Dm,y.isObject=Pt,y.isObjectLike=Dt,y.isPlainObject=la,y.isRegExp=Vf,y.isSafeInteger=yL,y.isSet=Em,y.isString=Wl,y.isSymbol=jr,y.isTypedArray=Vo,y.isUndefined=xL,y.isWeakMap=vL,y.isWeakSet=bL,y.join=Cw,y.kebabCase=cT,y.last=on,y.lastIndexOf=Lw,y.lowerCase=uT,y.lowerFirst=fT,y.lt=SL,y.lte=wL,y.max=oN,y.maxBy=sN,y.mean=aN,y.meanBy=lN,y.min=cN,y.minBy=uN,y.stubArray=Jf,y.stubFalse=Kf,y.stubObject=KT,y.stubString=YT,y.stubTrue=XT,y.multiply=fN,y.nth=Tw,y.noConflict=UT,y.noop=$f,y.now=Ul,y.pad=hT,y.padEnd=pT,y.padStart=dT,y.parseInt=mT,y.random=iT,y.reduce=IC,y.reduceRight=OC,y.repeat=gT,y.replace=yT,y.result=JL,y.round=hN,y.runInContext=I,y.sample=PC,y.size=EC,y.snakeCase=xT,y.some=BC,y.sortedIndex=Aw,y.sortedIndexBy=Dw,y.sortedIndexOf=Ew,y.sortedLastIndex=Bw,y.sortedLastIndexBy=Gw,y.sortedLastIndexOf=Rw,y.startCase=bT,y.startsWith=ST,y.subtract=pN,y.sum=dN,y.sumBy=mN,y.template=wT,y.times=ZT,y.toFinite=ni,y.toInteger=We,y.toLength=Gm,y.toLower=CT,y.toNumber=sn,y.toSafeInteger=CL,y.toString=lt,y.toUpper=LT,y.trim=TT,y.trimEnd=NT,y.trimStart=_T,y.truncate=IT,y.unescape=OT,y.uniqueId=eN,y.upperCase=MT,y.upperFirst=kf,y.each=wm,y.eachRight=Cm,y.first=xm,qf(y,function(){var s={};return An(y,function(l,u){ht.call(y.prototype,u)||(s[u]=l)}),s}(),{chain:!1}),y.VERSION=t,Qr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){y[s].placeholder=y}),Qr(["drop","take"],function(s,l){et.prototype[s]=function(u){u=u===i?1:Jt(We(u),0);var p=this.__filtered__&&!l?new et(this):this.clone();return p.__filtered__?p.__takeCount__=fr(u,p.__takeCount__):p.__views__.push({size:fr(u,Le),type:s+(p.__dir__<0?"Right":"")}),p},et.prototype[s+"Right"]=function(u){return this.reverse()[s](u).reverse()}}),Qr(["filter","map","takeWhile"],function(s,l){var u=l+1,p=u==R||u==G;et.prototype[s]=function(g){var v=this.clone();return v.__iteratees__.push({iteratee:Be(g,3),type:u}),v.__filtered__=v.__filtered__||p,v}}),Qr(["head","last"],function(s,l){var u="take"+(l?"Right":"");et.prototype[s]=function(){return this[u](1).value()[0]}}),Qr(["initial","tail"],function(s,l){var u="drop"+(l?"":"Right");et.prototype[s]=function(){return this.__filtered__?new et(this):this[u](1)}}),et.prototype.compact=function(){return this.filter(Pr)},et.prototype.find=function(s){return this.filter(s).head()},et.prototype.findLast=function(s){return this.reverse().find(s)},et.prototype.invokeMap=Xe(function(s,l){return typeof s=="function"?new et(this):this.map(function(u){return ra(u,s,l)})}),et.prototype.reject=function(s){return this.filter(kl(Be(s)))},et.prototype.slice=function(s,l){s=We(s);var u=this;return u.__filtered__&&(s>0||l<0)?new et(u):(s<0?u=u.takeRight(-s):s&&(u=u.drop(s)),l!==i&&(l=We(l),u=l<0?u.dropRight(-l):u.take(l-s)),u)},et.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},et.prototype.toArray=function(){return this.take(Le)},An(et.prototype,function(s,l){var u=/^(?:filter|find|map|reject)|While$/.test(l),p=/^(?:head|last)$/.test(l),g=y[p?"take"+(l=="last"?"Right":""):l],v=p||/^find/.test(l);!g||(y.prototype[l]=function(){var C=this.__wrapped__,L=p?[1]:arguments,_=C instanceof et,Z=L[0],Q=_||ke(C),oe=function(Ze){var tt=g.apply(y,xi([Ze],L));return p&&ge?tt[0]:tt};Q&&u&&typeof Z=="function"&&Z.length!=1&&(_=Q=!1);var ge=this.__chain__,Ne=!!this.__actions__.length,ze=v&&!ge,Je=_&&!Ne;if(!v&&Q){C=Je?C:new et(this);var Ge=s.apply(C,L);return Ge.__actions__.push({func:Fl,args:[oe],thisArg:i}),new tn(Ge,ge)}return ze&&Je?s.apply(this,L):(Ge=this.thru(oe),ze?p?Ge.value()[0]:Ge.value():Ge)})}),Qr(["pop","push","shift","sort","splice","unshift"],function(s){var l=fl[s],u=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",p=/^(?:pop|shift)$/.test(s);y.prototype[s]=function(){var g=arguments;if(p&&!this.__chain__){var v=this.value();return l.apply(ke(v)?v:[],g)}return this[u](function(C){return l.apply(ke(C)?C:[],g)})}}),An(et.prototype,function(s,l){var u=y[l];if(u){var p=u.name+"";ht.call(Bo,p)||(Bo[p]=[]),Bo[p].push({name:l,func:u})}}),Bo[Al(i,w).name]=[{name:"wrapper",func:i}],et.prototype.clone=OS,et.prototype.reverse=MS,et.prototype.value=PS,y.prototype.at=sC,y.prototype.chain=aC,y.prototype.commit=lC,y.prototype.next=cC,y.prototype.plant=fC,y.prototype.reverse=hC,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=pC,y.prototype.first=y.prototype.head,Ks&&(y.prototype[Ks]=uC),y},bi=lS();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Zt._=bi,define(function(){return bi})):Zi?((Zi.exports=bi)._=bi,Hu._=bi):Zt._=bi}).call($s)});import{FileLoader as k3,Loader as H3}from"three";function eg(i){return Array.isArray(i)?i:[i]}var TN=typeof global=="object"&&global&&global.Object===Object&&global,Jl=TN;var NN=typeof self=="object"&&self&&self.Object===Object&&self,_N=Jl||NN||Function("return this")(),kt=_N;var IN=kt.Symbol,Sr=IN;var tg=Object.prototype,ON=tg.hasOwnProperty,MN=tg.toString,ca=Sr?Sr.toStringTag:void 0;function PN(i){var t=ON.call(i,ca),e=i[ca];try{i[ca]=void 0;var r=!0}catch{}var n=MN.call(i);return r&&(t?i[ca]=e:delete i[ca]),n}var rg=PN;var AN=Object.prototype,DN=AN.toString;function EN(i){return DN.call(i)}var ng=EN;var BN="[object Null]",GN="[object Undefined]",ig=Sr?Sr.toStringTag:void 0;function RN(i){return i==null?i===void 0?GN:BN:ig&&ig in Object(i)?rg(i):ng(i)}var Wr=RN;function zN(i){return i!=null&&typeof i=="object"}var pr=zN;var FN="[object Symbol]";function VN(i){return typeof i=="symbol"||pr(i)&&Wr(i)==FN}var jo=VN;function UN(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var Kl=UN;var jN=Array.isArray,sr=jN;var kN=1/0,og=Sr?Sr.prototype:void 0,sg=og?og.toString:void 0;function ag(i){if(typeof i=="string")return i;if(sr(i))return Kl(i,ag)+"";if(jo(i))return sg?sg.call(i):"";var t=i+"";return t=="0"&&1/i==-kN?"-0":t}var lg=ag;function HN(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var dr=HN;function WN(i){return i}var Yl=WN;var qN="[object AsyncFunction]",$N="[object Function]",JN="[object GeneratorFunction]",KN="[object Proxy]";function YN(i){if(!dr(i))return!1;var t=Wr(i);return t==$N||t==JN||t==qN||t==KN}var ko=YN;var XN=kt["__core-js_shared__"],Xl=XN;var cg=function(){var i=/[^.]+$/.exec(Xl&&Xl.keys&&Xl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function ZN(i){return!!cg&&cg in i}var ug=ZN;var QN=Function.prototype,e_=QN.toString;function t_(i){if(i!=null){try{return e_.call(i)}catch{}try{return i+""}catch{}}return""}var oi=t_;var r_=/[\\^$.*+?()[\]{}|]/g,n_=/^\[object .+?Constructor\]$/,i_=Function.prototype,o_=Object.prototype,s_=i_.toString,a_=o_.hasOwnProperty,l_=RegExp("^"+s_.call(a_).replace(r_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function c_(i){if(!dr(i)||ug(i))return!1;var t=ko(i)?l_:n_;return t.test(oi(i))}var fg=c_;function u_(i,t){return i==null?void 0:i[t]}var hg=u_;function f_(i,t){var e=hg(i,t);return fg(e)?e:void 0}var Ar=f_;var h_=Ar(kt,"WeakMap"),Zl=h_;var pg=Object.create,p_=function(){function i(){}return function(t){if(!dr(t))return{};if(pg)return pg(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),dg=p_;function d_(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var mg=d_;function m_(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var Ql=m_;var g_=800,y_=16,x_=Date.now;function v_(i){var t=0,e=0;return function(){var r=x_(),n=y_-(r-e);if(e=r,n>0){if(++t>=g_)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var gg=v_;function b_(i){return function(){return i}}var yg=b_;var S_=function(){try{var i=Ar(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Ho=S_;var w_=Ho?function(i,t){return Ho(i,"toString",{configurable:!0,enumerable:!1,value:yg(t),writable:!0})}:Yl,xg=w_;var C_=gg(xg),ec=C_;function L_(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var vg=L_;var T_=9007199254740991,N_=/^(?:0|[1-9]\d*)$/;function __(i,t){var e=typeof i;return t=t==null?T_:t,!!t&&(e=="number"||e!="symbol"&&N_.test(i))&&i>-1&&i%1==0&&i<t}var tc=__;function I_(i,t,e){t=="__proto__"&&Ho?Ho(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Wo=I_;function O_(i,t){return i===t||i!==i&&t!==t}var _i=O_;var M_=Object.prototype,P_=M_.hasOwnProperty;function A_(i,t,e){var r=i[t];(!(P_.call(i,t)&&_i(r,e))||e===void 0&&!(t in i))&&Wo(i,t,e)}var rc=A_;function D_(i,t,e,r){var n=!e;e||(e={});for(var o=-1,a=t.length;++o<a;){var c=t[o],f=r?r(e[c],i[c],c,e,i):void 0;f===void 0&&(f=i[c]),n?Wo(e,c,f):rc(e,c,f)}return e}var an=D_;var bg=Math.max;function E_(i,t,e){return t=bg(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,o=bg(r.length-t,0),a=Array(o);++n<o;)a[n]=r[t+n];n=-1;for(var c=Array(t+1);++n<t;)c[n]=r[n];return c[t]=e(a),mg(i,this,c)}}var nc=E_;function B_(i,t){return ec(nc(i,t,Yl),i+"")}var Sg=B_;var G_=9007199254740991;function R_(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=G_}var ic=R_;function z_(i){return i!=null&&ic(i.length)&&!ko(i)}var Ii=z_;function F_(i,t,e){if(!dr(e))return!1;var r=typeof t;return(r=="number"?Ii(e)&&tc(t,e.length):r=="string"&&t in e)?_i(e[t],i):!1}var wg=F_;function V_(i){return Sg(function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,a=n>2?e[2]:void 0;for(o=i.length>3&&typeof o=="function"?(n--,o):void 0,a&&wg(e[0],e[1],a)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var c=e[r];c&&i(t,c,r,o)}return t})}var Cg=V_;var U_=Object.prototype;function j_(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||U_;return i===e}var qo=j_;function k_(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var Lg=k_;var H_="[object Arguments]";function W_(i){return pr(i)&&Wr(i)==H_}var Yf=W_;var Tg=Object.prototype,q_=Tg.hasOwnProperty,$_=Tg.propertyIsEnumerable,J_=Yf(function(){return arguments}())?Yf:function(i){return pr(i)&&q_.call(i,"callee")&&!$_.call(i,"callee")},ao=J_;function K_(){return!1}var Ng=K_;var Og=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_g=Og&&typeof module=="object"&&module&&!module.nodeType&&module,Y_=_g&&_g.exports===Og,Ig=Y_?kt.Buffer:void 0,X_=Ig?Ig.isBuffer:void 0,Z_=X_||Ng,$o=Z_;var Q_="[object Arguments]",eI="[object Array]",tI="[object Boolean]",rI="[object Date]",nI="[object Error]",iI="[object Function]",oI="[object Map]",sI="[object Number]",aI="[object Object]",lI="[object RegExp]",cI="[object Set]",uI="[object String]",fI="[object WeakMap]",hI="[object ArrayBuffer]",pI="[object DataView]",dI="[object Float32Array]",mI="[object Float64Array]",gI="[object Int8Array]",yI="[object Int16Array]",xI="[object Int32Array]",vI="[object Uint8Array]",bI="[object Uint8ClampedArray]",SI="[object Uint16Array]",wI="[object Uint32Array]",Nt={};Nt[dI]=Nt[mI]=Nt[gI]=Nt[yI]=Nt[xI]=Nt[vI]=Nt[bI]=Nt[SI]=Nt[wI]=!0;Nt[Q_]=Nt[eI]=Nt[hI]=Nt[tI]=Nt[pI]=Nt[rI]=Nt[nI]=Nt[iI]=Nt[oI]=Nt[sI]=Nt[aI]=Nt[lI]=Nt[cI]=Nt[uI]=Nt[fI]=!1;function CI(i){return pr(i)&&ic(i.length)&&!!Nt[Wr(i)]}var Mg=CI;function LI(i){return function(t){return i(t)}}var Jo=LI;var Pg=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ua=Pg&&typeof module=="object"&&module&&!module.nodeType&&module,TI=ua&&ua.exports===Pg,Xf=TI&&Jl.process,NI=function(){try{var i=ua&&ua.require&&ua.require("util").types;return i||Xf&&Xf.binding&&Xf.binding("util")}catch{}}(),si=NI;var Ag=si&&si.isTypedArray,_I=Ag?Jo(Ag):Mg,oc=_I;var II=Object.prototype,OI=II.hasOwnProperty;function MI(i,t){var e=sr(i),r=!e&&ao(i),n=!e&&!r&&$o(i),o=!e&&!r&&!n&&oc(i),a=e||r||n||o,c=a?Lg(i.length,String):[],f=c.length;for(var h in i)(t||OI.call(i,h))&&!(a&&(h=="length"||n&&(h=="offset"||h=="parent")||o&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||tc(h,f)))&&c.push(h);return c}var sc=MI;function PI(i,t){return function(e){return i(t(e))}}var ac=PI;var AI=ac(Object.keys,Object),Dg=AI;var DI=Object.prototype,EI=DI.hasOwnProperty;function BI(i){if(!qo(i))return Dg(i);var t=[];for(var e in Object(i))EI.call(i,e)&&e!="constructor"&&t.push(e);return t}var Eg=BI;function GI(i){return Ii(i)?sc(i):Eg(i)}var Ko=GI;function RI(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var Bg=RI;var zI=Object.prototype,FI=zI.hasOwnProperty;function VI(i){if(!dr(i))return Bg(i);var t=qo(i),e=[];for(var r in i)r=="constructor"&&(t||!FI.call(i,r))||e.push(r);return e}var Gg=VI;function UI(i){return Ii(i)?sc(i,!0):Gg(i)}var Bn=UI;var jI=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kI=/^\w*$/;function HI(i,t){if(sr(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||jo(i)?!0:kI.test(i)||!jI.test(i)||t!=null&&i in Object(t)}var Rg=HI;var WI=Ar(Object,"create"),ai=WI;function qI(){this.__data__=ai?ai(null):{},this.size=0}var zg=qI;function $I(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var Fg=$I;var JI="__lodash_hash_undefined__",KI=Object.prototype,YI=KI.hasOwnProperty;function XI(i){var t=this.__data__;if(ai){var e=t[i];return e===JI?void 0:e}return YI.call(t,i)?t[i]:void 0}var Vg=XI;var ZI=Object.prototype,QI=ZI.hasOwnProperty;function eO(i){var t=this.__data__;return ai?t[i]!==void 0:QI.call(t,i)}var Ug=eO;var tO="__lodash_hash_undefined__";function rO(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=ai&&t===void 0?tO:t,this}var jg=rO;function Yo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Yo.prototype.clear=zg;Yo.prototype.delete=Fg;Yo.prototype.get=Vg;Yo.prototype.has=Ug;Yo.prototype.set=jg;var Zf=Yo;function nO(){this.__data__=[],this.size=0}var kg=nO;function iO(i,t){for(var e=i.length;e--;)if(_i(i[e][0],t))return e;return-1}var Oi=iO;var oO=Array.prototype,sO=oO.splice;function aO(i){var t=this.__data__,e=Oi(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():sO.call(t,e,1),--this.size,!0}var Hg=aO;function lO(i){var t=this.__data__,e=Oi(t,i);return e<0?void 0:t[e][1]}var Wg=lO;function cO(i){return Oi(this.__data__,i)>-1}var qg=cO;function uO(i,t){var e=this.__data__,r=Oi(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var $g=uO;function Xo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Xo.prototype.clear=kg;Xo.prototype.delete=Hg;Xo.prototype.get=Wg;Xo.prototype.has=qg;Xo.prototype.set=$g;var Mi=Xo;var fO=Ar(kt,"Map"),Pi=fO;function hO(){this.size=0,this.__data__={hash:new Zf,map:new(Pi||Mi),string:new Zf}}var Jg=hO;function pO(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var Kg=pO;function dO(i,t){var e=i.__data__;return Kg(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ai=dO;function mO(i){var t=Ai(this,i).delete(i);return this.size-=t?1:0,t}var Yg=mO;function gO(i){return Ai(this,i).get(i)}var Xg=gO;function yO(i){return Ai(this,i).has(i)}var Zg=yO;function xO(i,t){var e=Ai(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var Qg=xO;function Zo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Zo.prototype.clear=Jg;Zo.prototype.delete=Yg;Zo.prototype.get=Xg;Zo.prototype.has=Zg;Zo.prototype.set=Qg;var fa=Zo;var vO="Expected a function";function Qf(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(vO);var e=function(){var r=arguments,n=t?t.apply(this,r):r[0],o=e.cache;if(o.has(n))return o.get(n);var a=i.apply(this,r);return e.cache=o.set(n,a)||o,a};return e.cache=new(Qf.Cache||fa),e}Qf.Cache=fa;var ey=Qf;var bO=500;function SO(i){var t=ey(i,function(r){return e.size===bO&&e.clear(),r}),e=t.cache;return t}var ty=SO;var wO=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,CO=/\\(\\)?/g,LO=ty(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(wO,function(e,r,n,o){t.push(n?o.replace(CO,"$1"):r||e)}),t}),ry=LO;function TO(i){return i==null?"":lg(i)}var ny=TO;function NO(i,t){return sr(i)?i:Rg(i,t)?[i]:ry(ny(i))}var Qo=NO;var _O=1/0;function IO(i){if(typeof i=="string"||jo(i))return i;var t=i+"";return t=="0"&&1/i==-_O?"-0":t}var lc=IO;function OO(i,t){t=Qo(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[lc(t[e++])];return e&&e==r?i:void 0}var iy=OO;function MO(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var es=MO;var oy=Sr?Sr.isConcatSpreadable:void 0;function PO(i){return sr(i)||ao(i)||!!(oy&&i&&i[oy])}var sy=PO;function ay(i,t,e,r,n){var o=-1,a=i.length;for(e||(e=sy),n||(n=[]);++o<a;){var c=i[o];t>0&&e(c)?t>1?ay(c,t-1,e,r,n):es(n,c):r||(n[n.length]=c)}return n}var ly=ay;function AO(i){var t=i==null?0:i.length;return t?ly(i,1):[]}var cy=AO;function DO(i){return ec(nc(i,void 0,cy),i+"")}var uy=DO;var EO=ac(Object.getPrototypeOf,Object),ts=EO;var BO="[object Object]",GO=Function.prototype,RO=Object.prototype,fy=GO.toString,zO=RO.hasOwnProperty,FO=fy.call(Object);function VO(i){if(!pr(i)||Wr(i)!=BO)return!1;var t=ts(i);if(t===null)return!0;var e=zO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&fy.call(e)==FO}var cc=VO;function UO(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(n);++r<n;)o[r]=i[r+t];return o}var hy=UO;function jO(){this.__data__=new Mi,this.size=0}var py=jO;function kO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var dy=kO;function HO(i){return this.__data__.get(i)}var my=HO;function WO(i){return this.__data__.has(i)}var gy=WO;var qO=200;function $O(i,t){var e=this.__data__;if(e instanceof Mi){var r=e.__data__;if(!Pi||r.length<qO-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new fa(r)}return e.set(i,t),this.size=e.size,this}var yy=$O;function rs(i){var t=this.__data__=new Mi(i);this.size=t.size}rs.prototype.clear=py;rs.prototype.delete=dy;rs.prototype.get=my;rs.prototype.has=gy;rs.prototype.set=yy;var uc=rs;function JO(i,t){return i&&an(t,Ko(t),i)}var xy=JO;function KO(i,t){return i&&an(t,Bn(t),i)}var vy=KO;var Cy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,by=Cy&&typeof module=="object"&&module&&!module.nodeType&&module,YO=by&&by.exports===Cy,Sy=YO?kt.Buffer:void 0,wy=Sy?Sy.allocUnsafe:void 0;function XO(i,t){if(t)return i.slice();var e=i.length,r=wy?wy(e):new i.constructor(e);return i.copy(r),r}var fc=XO;function ZO(i,t){for(var e=-1,r=i==null?0:i.length,n=0,o=[];++e<r;){var a=i[e];t(a,e,i)&&(o[n++]=a)}return o}var Ly=ZO;function QO(){return[]}var hc=QO;var eM=Object.prototype,tM=eM.propertyIsEnumerable,Ty=Object.getOwnPropertySymbols,rM=Ty?function(i){return i==null?[]:(i=Object(i),Ly(Ty(i),function(t){return tM.call(i,t)}))}:hc,ns=rM;function nM(i,t){return an(i,ns(i),t)}var Ny=nM;var iM=Object.getOwnPropertySymbols,oM=iM?function(i){for(var t=[];i;)es(t,ns(i)),i=ts(i);return t}:hc,pc=oM;function sM(i,t){return an(i,pc(i),t)}var _y=sM;function aM(i,t,e){var r=t(i);return sr(i)?r:es(r,e(i))}var dc=aM;function lM(i){return dc(i,Ko,ns)}var Iy=lM;function cM(i){return dc(i,Bn,pc)}var mc=cM;var uM=Ar(kt,"DataView"),gc=uM;var fM=Ar(kt,"Promise"),yc=fM;var hM=Ar(kt,"Set"),xc=hM;var Oy="[object Map]",pM="[object Object]",My="[object Promise]",Py="[object Set]",Ay="[object WeakMap]",Dy="[object DataView]",dM=oi(gc),mM=oi(Pi),gM=oi(yc),yM=oi(xc),xM=oi(Zl),lo=Wr;(gc&&lo(new gc(new ArrayBuffer(1)))!=Dy||Pi&&lo(new Pi)!=Oy||yc&&lo(yc.resolve())!=My||xc&&lo(new xc)!=Py||Zl&&lo(new Zl)!=Ay)&&(lo=function(i){var t=Wr(i),e=t==pM?i.constructor:void 0,r=e?oi(e):"";if(r)switch(r){case dM:return Dy;case mM:return Oy;case gM:return My;case yM:return Py;case xM:return Ay}return t});var is=lo;var vM=Object.prototype,bM=vM.hasOwnProperty;function SM(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&bM.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var Ey=SM;var wM=kt.Uint8Array,eh=wM;function CM(i){var t=new i.constructor(i.byteLength);return new eh(t).set(new eh(i)),t}var os=CM;function LM(i,t){var e=t?os(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var By=LM;var TM=/\w*$/;function NM(i){var t=new i.constructor(i.source,TM.exec(i));return t.lastIndex=i.lastIndex,t}var Gy=NM;var Ry=Sr?Sr.prototype:void 0,zy=Ry?Ry.valueOf:void 0;function _M(i){return zy?Object(zy.call(i)):{}}var Fy=_M;function IM(i,t){var e=t?os(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var vc=IM;var OM="[object Boolean]",MM="[object Date]",PM="[object Map]",AM="[object Number]",DM="[object RegExp]",EM="[object Set]",BM="[object String]",GM="[object Symbol]",RM="[object ArrayBuffer]",zM="[object DataView]",FM="[object Float32Array]",VM="[object Float64Array]",UM="[object Int8Array]",jM="[object Int16Array]",kM="[object Int32Array]",HM="[object Uint8Array]",WM="[object Uint8ClampedArray]",qM="[object Uint16Array]",$M="[object Uint32Array]";function JM(i,t,e){var r=i.constructor;switch(t){case RM:return os(i);case OM:case MM:return new r(+i);case zM:return By(i,e);case FM:case VM:case UM:case jM:case kM:case HM:case WM:case qM:case $M:return vc(i,e);case PM:return new r;case AM:case BM:return new r(i);case DM:return Gy(i);case EM:return new r;case GM:return Fy(i)}}var Vy=JM;function KM(i){return typeof i.constructor=="function"&&!qo(i)?dg(ts(i)):{}}var bc=KM;var YM="[object Map]";function XM(i){return pr(i)&&is(i)==YM}var Uy=XM;var jy=si&&si.isMap,ZM=jy?Jo(jy):Uy,ky=ZM;var QM="[object Set]";function eP(i){return pr(i)&&is(i)==QM}var Hy=eP;var Wy=si&&si.isSet,tP=Wy?Jo(Wy):Hy,qy=tP;var rP=1,nP=2,iP=4,$y="[object Arguments]",oP="[object Array]",sP="[object Boolean]",aP="[object Date]",lP="[object Error]",Jy="[object Function]",cP="[object GeneratorFunction]",uP="[object Map]",fP="[object Number]",Ky="[object Object]",hP="[object RegExp]",pP="[object Set]",dP="[object String]",mP="[object Symbol]",gP="[object WeakMap]",yP="[object ArrayBuffer]",xP="[object DataView]",vP="[object Float32Array]",bP="[object Float64Array]",SP="[object Int8Array]",wP="[object Int16Array]",CP="[object Int32Array]",LP="[object Uint8Array]",TP="[object Uint8ClampedArray]",NP="[object Uint16Array]",_P="[object Uint32Array]",St={};St[$y]=St[oP]=St[yP]=St[xP]=St[sP]=St[aP]=St[vP]=St[bP]=St[SP]=St[wP]=St[CP]=St[uP]=St[fP]=St[Ky]=St[hP]=St[pP]=St[dP]=St[mP]=St[LP]=St[TP]=St[NP]=St[_P]=!0;St[lP]=St[Jy]=St[gP]=!1;function Sc(i,t,e,r,n,o){var a,c=t&rP,f=t&nP,h=t&iP;if(e&&(a=n?e(i,r,n,o):e(i)),a!==void 0)return a;if(!dr(i))return i;var d=sr(i);if(d){if(a=Ey(i),!c)return Ql(i,a)}else{var m=is(i),x=m==Jy||m==cP;if($o(i))return fc(i,c);if(m==Ky||m==$y||x&&!n){if(a=f||x?{}:bc(i),!c)return f?_y(i,vy(a,i)):Ny(i,xy(a,i))}else{if(!St[m])return n?i:{};a=Vy(i,m,c)}}o||(o=new uc);var S=o.get(i);if(S)return S;o.set(i,a),qy(i)?i.forEach(function(O){a.add(Sc(O,t,e,O,i,o))}):ky(i)&&i.forEach(function(O,T){a.set(T,Sc(O,t,e,T,i,o))});var w=h?f?mc:Iy:f?Bn:Ko,B=d?void 0:w(i);return vg(B||i,function(O,T){B&&(T=O,O=i[T]),rc(a,T,Sc(O,t,e,T,i,o))}),a}var wc=Sc;var IP=1,OP=4;function MP(i){return wc(i,IP|OP)}var ha=MP;function PP(i){return function(t,e,r){for(var n=-1,o=Object(t),a=r(t),c=a.length;c--;){var f=a[i?c:++n];if(e(o[f],f,o)===!1)break}return t}}var Yy=PP;var AP=Yy(),Xy=AP;function DP(i,t,e){(e!==void 0&&!_i(i[t],e)||e===void 0&&!(t in i))&&Wo(i,t,e)}var pa=DP;function EP(i){return pr(i)&&Ii(i)}var Zy=EP;function BP(i,t){if(!(t==="constructor"&&typeof i[t]=="function")&&t!="__proto__")return i[t]}var da=BP;function GP(i){return an(i,Bn(i))}var Qy=GP;function RP(i,t,e,r,n,o,a){var c=da(i,e),f=da(t,e),h=a.get(f);if(h){pa(i,e,h);return}var d=o?o(c,f,e+"",i,t,a):void 0,m=d===void 0;if(m){var x=sr(f),S=!x&&$o(f),w=!x&&!S&&oc(f);d=f,x||S||w?sr(c)?d=c:Zy(c)?d=Ql(c):S?(m=!1,d=fc(f,!0)):w?(m=!1,d=vc(f,!0)):d=[]:cc(f)||ao(f)?(d=c,ao(c)?d=Qy(c):(!dr(c)||ko(c))&&(d=bc(f))):m=!1}m&&(a.set(f,d),n(d,f,r,o,a),a.delete(f)),pa(i,e,d)}var ex=RP;function tx(i,t,e,r,n){i!==t&&Xy(t,function(o,a){if(n||(n=new uc),dr(o))ex(i,t,a,e,tx,r,n);else{var c=r?r(da(i,a),o,a+"",i,t,n):void 0;c===void 0&&(c=o),pa(i,a,c)}},Bn)}var rx=tx;function zP(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var nx=zP;function FP(i,t){return t.length<2?i:iy(i,hy(t,0,-1))}var ix=FP;var VP=Cg(function(i,t,e){rx(i,t,e)}),co=VP;function UP(i,t){return t=Qo(t,i),i=ix(i,t),i==null||delete i[lc(nx(t))]}var ox=UP;function jP(i){return cc(i)?void 0:i}var sx=jP;var kP=1,HP=2,WP=4,qP=uy(function(i,t){var e={};if(i==null)return e;var r=!1;t=Kl(t,function(o){return o=Qo(o,i),r||(r=o.length>1),o}),an(i,mc(i),e),r&&(e=wc(e,kP|HP|WP,sx));for(var n=t.length;n--;)ox(e,t[n]);return e}),ss=qP;var as;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(as||(as={}));var uo;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(o){return o.type==="PerspectiveCamera"?o.perspective.zoom:o.orthographic.zoom}n.getZoom=r})(uo||(uo={}));var ax;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]}e.isEqual=i;function t(r,n,o){return[r[0]+(n[0]-r[0])*o,r[1]+(n[1]-r[1])*o]}e.lerp=t})(ax||(ax={}));var ls;(n=>{function i(o,a){return o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}n.isEqual=i;function t(o,a){return[o[0]+a[0],o[1]+a[1],o[2]+a[2]]}n.add=t;function e(o,a){return[o[0]-a[0],o[1]-a[1],o[2]-a[2]]}n.sub=e;function r(o,a,c){return[o[0]+(a[0]-o[0])*c,o[1]+(a[1]-o[1])*c,o[2]+(a[2]-o[2])*c]}n.lerp=r})(ls||(ls={}));var lx;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,o){return[r[0]+(n[0]-r[0])*o,r[1]+(n[1]-r[1])*o,r[2]+(n[2]-r[2])*o,r[3]+(n[3]-r[3])*o]}e.lerp=t})(lx||(lx={}));var Di;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(a,c){for(let f=0;f<16;f++)if(a[f]!==c[f])return!1;return!0}o.isEqual=t;function e(a){return a!=null?a:o.identity}o.simplify=e;function r(a,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3){let m=1/(a[3]*c[h]+a[7]*c[h+1]+a[11]*c[h+2]+a[15]);f[h]=(a[0]*c[h]+a[4]*c[h+1]+a[8]*c[h+2]+a[12])*m,f[h+1]=(a[1]*c[h]+a[5]*c[h+1]+a[9]*c[h+2]+a[13])*m,f[h+2]=(a[2]*c[h]+a[6]*c[h+1]+a[10]*c[h+2]+a[14])*m}return f}o.applyMatrix4=r;function n(a,c){let f=c.slice(0);for(var h=0,d=c.length;h<d;h+=3)f[h]=a[0]*c[h]+a[4]*c[h+1]+a[8]*c[h+2],f[h+1]=a[1]*c[h]+a[5]*c[h+1]+a[9]*c[h+2],f[h+2]=a[2]*c[h]+a[6]*c[h+1]+a[10]*c[h+2];return f}o.applyMatrix3Components=n})(Di||(Di={}));var qr;(f=>{f.white={r:1,g:1,b:1},f.red={r:1,g:0,b:0},f.black={r:0,g:0,b:0};function r(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}f.toRgb255a1=r;function n(h){return{r:h.r,g:h.g,b:h.b}}f.clone=n;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}f.fromHex=o;function a(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}f.equals=a;function c(h,d,m){return{r:h.r+(d.r-h.r)*m,g:h.g+(d.g-h.g)*m,b:h.b+(d.b-h.b)*m}}f.lerp=c})(qr||(qr={}));var Gn;(a=>{a.white=ue(j({},qr.white),{a:1});function t(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}a.from0to1=t;function e(c,f){return ue(j({},qr.fromHex(c)),{a:f})}a.fromHexAndA=e;function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}a.toRgb255a1=r;function n(c,f){return qr.equals(c,f)&&c.a===f.a}a.equals=n;function o(c,f,h){return{r:c.r+(f.r-c.r)*h,g:c.g+(f.g-c.g)*h,b:c.b+(f.b-c.b)*h,a:c.a+(f.a-c.a)*h}}a.lerp=o})(Gn||(Gn={}));var Cc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Cc||(Cc={}));var cx;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(cx||(cx={}));var ux;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(ux||(ux={}));var Lc;(t=>{function i(e,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(e[0],e[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[e[0]+e[0]*r,0,0]},grid:{count:[2,2,2],size:e.map(n=>n*(1+r)),useCenter:!0}}}t.defaultData=i})(Lc||(Lc={}));var ln=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let o=ue(j({},r),{[t]:e});return Object.setPrototypeOf(o,ln.prototype),o}}add(t,e){var n;let r=this.runOp({type:1,id:t,data:e});return(n=r==null?void 0:r.data)!=null?n:this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:o,data:a}=t,c=ue(j({},e),{[o]:a});return Object.setPrototypeOf(c,ln.prototype),{data:c,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let o=j({},e);return Object.setPrototypeOf(o,ln.prototype),delete o[r],{data:o,actual:t,reverse:{type:1,id:r,data:n}}}}throw new Error("illegal arg")}};function ma(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&ma(r)}return Object.freeze(i)}function fx(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Tc=class extends Error{};function Rn(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let o=i;i=t,t=o}let r=[],n=1/(e+1);for(let o=0;o<e;o++){let a=i+(t-i)*(o+.75+Math.random()*.5)*n;r.push(a)}return r}function hx(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function px(){return typeof process<"u"}function dx(i,t){for(let e of i)t(e.id,e.data),dx(e.children,t)}function mx(i,t){t(i.id,i.data);for(let e of i.children)mx(e,t)}var cn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,cn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ma(this[e]),e++}fillCaches0(e,r){var n;if((n=this.objCaches)!=null&&n.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}isDescendantOf(e,r){for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}data(e){var r;return(r=this.get(e))==null?void 0:r.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var r;return e===null?this:(r=this.get(e))==null?void 0:r.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let n=this.get(e);n&&mx(n,r)}}traverse(e){dx(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),a=this.childrenArray(o),c=a.findIndex(d=>d.id===e);if(c<0)throw new Error("not expected");let f=a[c];return a=[...a],a[c]=ue(j({},f),{data:r}),this.modifyArrayBy(o,a)}}modifyArrayBy(e,r){let n=e,o=r;for(;n!==null;){let c=o,f=n;if(n=this.parent(n),n===void 0)throw new Error;o=this.childrenArray(n);let h=o.findIndex(d=>d.id===f);if(h<0)throw new Error;o=[...o],o[h]=ue(j({},o[h]),{children:c})}Object.setPrototypeOf(o,cn.prototype);let a=o;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}}addOp(e){let{parent:r,fi:n,id:o,data:a,children:c}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.get(o)!==void 0)return null;{let f=r,h=this.childrenArray(f),d={fi:n,id:o,data:a,children:c};return h=[...h,d],h.sort((x,S)=>x.fi-S.fi),e.localIndex=h.indexOf(d),{data:this.modifyArrayBy(f,h),actual:e,reverse:{type:8,id:o}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let o=this.childrenArray(n),a=o.findIndex(h=>h.id===r);e.localIndex=a,o=[...o];let c=o.splice(a,1)[0];return{data:this.modifyArrayBy(n,o),actual:e,reverse:ue(j({type:7},c),{parent:n})}}}moveOp(e){let{parent:r,fi:n,id:o}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:o});if(r!==null){let S=r;for(;S!==null;){if(S===void 0)throw new Error;if(S===o)throw new Tc("cyclic tree");S=this.parent(S)}}let a=this.parent(o);if(a===void 0)return null;let c=a,f=this.childrenArray(a),h=f.findIndex(S=>S.id===o);f=[...f];let d=f.splice(h,1)[0],m=this.modifyArrayBy(a,f);a=r,f=m.childrenArray(a);let x=d.fi;return d=ue(j({},d),{fi:n}),f=[...f,d],f.sort((S,w)=>S.fi-w.fi),e.localIndex=f.indexOf(d),m=m.modifyArrayBy(a,f),{data:m,actual:e,reverse:{type:9,parent:c,fi:x,id:o}}}previous(e,r){if(r===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let n=null;for(let o of this.childrenArray(e)){if(o.id===r)return n;n=o.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),o=n.findIndex(a=>a.id===e)+1;if(o<n.length)return n[o].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),o=n.findIndex(a=>a.id===e)-1;return o>=0?this.traverseSortPrevious(n[o].id):r}}getAllSorted(e){let r=[];for(let n of e){let o=this.getWithSortKey(n.id);o!==void 0&&r.push(j(j({},n),o))}r.sort((n,o)=>fx(n.sortKey,o.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],o=this.get(r),a=o;if(o!==void 0){for(;r;)n.splice(0,0,o.fi),r=this.parent(r),r!==null&&(o=this.get(r));return ue(j({},a),{sortKey:n})}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let o=this.childrenArray(e);if(r===null){if(o.length===0)return Rn(0,n,n);{let a=o[0].fi;return Rn(a-n,a,n)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let c=o.find(f=>f.fi>a.fi);if(c===void 0){let f=o[o.length-1].fi;return Rn(f,f+n,n)}else return Rn(a.fi,c.fi,n)}}};var Nc;(t=>{function i(e,r){if(Array.isArray(e)){let n=r.props,o={},a=[...e],c=!1;if(n)for(let f of Object.keys(n)){let h=parseInt(f);if(isNaN(h))throw new Error("wrong index");o[f]=a[h],a[h]=n[f],c=!0}return c?{data:a,actual:r,reverse:{type:0,props:o}}:null}else{let n=r.props,o={},a=j({},e),c=!1;if(n)for(let f of Object.keys(n)){o[f]=a[f];let h=n[f];h===void 0?delete a[f]:a[f]=h,c=!0}return c?{data:a,actual:r,reverse:{type:0,props:o}}:null}}t.runOp=i})(Nc||(Nc={}));var At=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,At.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ma(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){var r;return(r=this.get(e))==null?void 0:r.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,a=o.findIndex(h=>h.id===e);if(a<0)throw new Error("not expected");let c=o[a];return o=[...o],o[a]=ue(j({},c),{data:r}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,At.prototype);let r=e;return px()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}}addOp(e){let{fi:r,id:n,data:o}=e,a=this,c={fi:r,id:n,data:o};return a=[...a,c],a.sort((h,d)=>h.fi-d.fi),e.localIndex=a.indexOf(c),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,o=n.findIndex(f=>f.id===r);if(o===-1)return null;e.localIndex=o,n=[...n];let a=n.splice(o,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:j({type:4},a)}}moveOp(e){let{fi:r,id:n}=e,o=this;o=[...o];let a=o.findIndex(d=>d.id===n);if(a===-1)return null;let c=o[a].fi,f=ue(j({},o[a]),{fi:r});return o[a]=f,o.sort((d,m)=>d.fi-m.fi),e.localIndex=o.indexOf(f),{data:this.modifyArrayBy(o),actual:e,reverse:{type:6,fi:c,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return Rn(0,r,r);{let o=n[0].fi;return Rn(o-r,o,r)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let a=n.find(c=>c.fi>o.fi);if(a===void 0){let c=n[n.length-1].fi;return Rn(c,c+r,r)}else return Rn(o.fi,a.fi,r)}}};var gx=Symbol(),Ic=Symbol(),cs=class{reportOp(t,e){let r=this;if(e===null)return;r._current=e.data;let n=[];for(;!(r instanceof _c);){let o=r._path,a=r._current;if(o!==""&&n.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(n,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ic];r&&r(),delete this._children[t]}}}},rh=class extends cs{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=ue(j({},this._current),{[t]:e})}runOp(t){this.reportOp(t,Nc.runOp(this._current,t))}},nh=class extends cs{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current=ue(j({},this._current),{[t]:e}),Object.setPrototypeOf(this._current,ln.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},yx={get(i,t){if(t===Ic)return()=>{i._parent=null};if(t===gx)return i._current;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let o=e[t],a=Oc(i,t,o);return a!==o?(r===void 0&&(r={},i._children=r),r[t]=a,a):o},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},$P=ue(j({},yx),{set(i,t,e){var n;let r={type:0,props:{[t]:(n=sh(e))!=null?n:e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}}),JP=ue(j({},yx),{set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}}),us=class extends cs{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ic]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){var c;let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let o=(c=e.get(t))==null?void 0:c.data,a=Oc(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}add(t,e,r,n,o){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:o})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,n[o],a.id,a.data,a.children)}}insertBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,n[o],a.id,a.data,a.children)}}moveAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,n[o],a)}}moveBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,n[o],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},fs=class extends cs{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ic]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id;t(this.data(this._current[r].id),n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return ue(j({},this._current.get(t)),{data:this.data(t)})}data(t){var c;let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let o=(c=e.get(t))==null?void 0:c.data,a=Oc(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.add(r[n],o.id,o.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.add(r[n],o.id,o.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.move(r[n],o)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let o=e[n];this.move(r[n],o)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function th(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Mc.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push(ue(j({},t),{path:e}))}var _c=class{constructor(t){this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,n){th(this.ts,e,t),th(this.actual,r,t),th(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Oc(i,t,e){return e instanceof cn?new us(i,t,e):e instanceof At?new fs(i,t,e):e instanceof ln?new Proxy(new nh(i,t,e),JP):e!==null&&typeof e=="object"?hx(e)?e:new Proxy(new rh(i,t,e),$P):e}function ih(i){let t=new _c(i);return[Oc(t,"",i),t]}function oh(i,t){let[e,r]=ih(i);return t(e),r.result()}function sh(i){return i instanceof us||i instanceof fs?i._current:i!==null&&typeof i=="object"?i[gx]:i}var Mc;(r=>{function i(n,o){if(o.length===n.length)for(var a=0;a<n.length;){if(n[a]!==o[a])return!1;a+=1}else return!1;return!0}r.equal=i;function t(n,o,a){let c=e(a,n);if(c!==void 0&&typeof c=="object"&&c!==null){let f=j({},o);return Object.keys(c).forEach(h=>{delete f[h]}),f}else return o}r.removeOverridden=t;function e(n,o,a=0){if(o.length<=a)return n;if((n instanceof cn||n instanceof us)&&typeof o[a]=="string")return e(n.data(o[a]),o,a+1);if((n instanceof At||n instanceof fs)&&typeof o[a]=="string")return e(n.data(o[a]),o,a+1);if(typeof o[a]=="number"&&Array.isArray(n))return e(n[o[a]],o,a+1);if(typeof o[a]=="string"&&typeof n=="object")return e(n[o[a]],o,a+1)}r.zoom=e})(Mc||(Mc={}));var Pc=class{},ga=class extends Pc{constructor(e){super();this.id=e}},ya=class extends Pc{constructor(e){super();this.data=e}};var lh;try{lh=new TextDecoder}catch{}var ye,Bi,D=0;var Tx=[],ch=Tx,uh=0,Dr={},it,Ei,un=0,zn=0,$r,li,wr=[],ct,xx={useRecords:!1,mapsAsObjects:!0},xa=class{},hh=new xa;hh.name="MessagePack 0xC1";var hs=!1,Fn=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(ye)return Mx(()=>(Dc(),this?this.unpack(t,e):Fn.prototype.unpack.call(xx,t,e)));Bi=e>-1?e:t.length,D=0,uh=0,zn=0,Ei=null,ch=Tx,$r=null,ye=t;try{ct=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw ye=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Fn){if(Dr=this,this.structures)return it=this.structures,Ac();(!it||it.length>0)&&(it=[])}else Dr=xx,(!it||it.length>0)&&(it=[]);return Ac()}unpackMultiple(t,e){let r,n=0;try{hs=!0;let o=t.length,a=this?this.unpack(t,o):Gc.unpack(t,o);if(e){for(e(a);D<o;)if(n=D,e(Ac())===!1)return}else{for(r=[a];D<o;)n=D,r.push(Ac());return r}}catch(o){throw o.lastPosition=n,o.values=r,o}finally{hs=!1,Dc()}}_mergeStructures(t,e){t=t||[];for(let r=0,n=t.length;r<n;r++){let o=t[r];o&&(o.isShared=!0,r>=32&&(o.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],o=e[r];o&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=o)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ac(){try{if(!Dr.trusted&&!hs){let t=it.sharedLength||0;t<it.length&&(it.length=t)}let i=Et();if(D==Bi)it.restoreStructures&&vx(),it=null,ye=null,li&&(li=null);else if(D>Bi){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!hs)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw it.restoreStructures&&vx(),Dc(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function vx(){for(let i in it.restoreStructures)it[i]=it.restoreStructures[i];it.restoreStructures=null}function Et(){let i=ye[D++];if(i<160)if(i<128){if(i<64)return i;{let t=it[i&63]||Dr.getStructures&&Nx()[i&63];return t?(t.read||(t.read=ph(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Dr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[Ix()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}else if(i<192){let t=i-160;if(zn>=D)return Ei.slice(D-un,(D+=t)-un);if(zn==0&&Bi<140){let e=t<16?dh(t):_x(t);if(e!=null)return e}return fh(t)}else{let t;switch(i){case 192:return null;case 193:return $r?(t=Et(),t>0?$r[1].slice($r.position1,$r.position1+=t):$r[0].slice($r.position0,$r.position0-=t)):hh;case 194:return!1;case 195:return!0;case 196:return ah(ye[D++]);case 197:return t=ct.getUint16(D),D+=2,ah(t);case 198:return t=ct.getUint32(D),D+=4,ah(t);case 199:return fo(ye[D++]);case 200:return t=ct.getUint16(D),D+=2,fo(t);case 201:return t=ct.getUint32(D),D+=4,fo(t);case 202:if(t=ct.getFloat32(D),Dr.useFloat32>2){let e=Bc[(ye[D]&127)<<1|ye[D+1]>>7];return D+=4,(e*t+(t>0?.5:-.5)>>0)/e}return D+=4,t;case 203:return t=ct.getFloat64(D),D+=8,t;case 204:return ye[D++];case 205:return t=ct.getUint16(D),D+=2,t;case 206:return t=ct.getUint32(D),D+=4,t;case 207:return Dr.int64AsNumber?(t=ct.getUint32(D)*4294967296,t+=ct.getUint32(D+4)):t=ct.getBigUint64(D),D+=8,t;case 208:return ct.getInt8(D++);case 209:return t=ct.getInt16(D),D+=2,t;case 210:return t=ct.getInt32(D),D+=4,t;case 211:return Dr.int64AsNumber?(t=ct.getInt32(D)*4294967296,t+=ct.getUint32(D+4)):t=ct.getBigInt64(D),D+=8,t;case 212:if(t=ye[D++],t==114)return Lx(ye[D++]&63);{let e=wr[t];if(e)return e.read?(D++,e.read(Et())):e.noBuffer?(D++,e()):e(ye.subarray(D,++D));throw new Error("Unknown extension "+t)}case 213:return t=ye[D],t==114?(D++,Lx(ye[D++]&63,ye[D++])):fo(2);case 214:return fo(4);case 215:return fo(8);case 216:return fo(16);case 217:return t=ye[D++],zn>=D?Ei.slice(D-un,(D+=t)-un):YP(t);case 218:return t=ct.getUint16(D),D+=2,zn>=D?Ei.slice(D-un,(D+=t)-un):XP(t);case 219:return t=ct.getUint32(D),D+=4,zn>=D?Ei.slice(D-un,(D+=t)-un):ZP(t);case 220:return t=ct.getUint16(D),D+=2,Sx(t);case 221:return t=ct.getUint32(D),D+=4,Sx(t);case 222:return t=ct.getUint16(D),D+=2,wx(t);case 223:return t=ct.getUint32(D),D+=4,wx(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var KP=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ph(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(o=>KP.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"}}")(Et);return i.highByte===0&&(i.read=bx(t,i.read)),n()}let r={};for(let n=0,o=i.length;n<o;n++){let a=i[n];r[a]=Et()}return r}return e.count=0,i.highByte===0?bx(t,e):e}var bx=(i,t)=>function(){let e=ye[D++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=it[r]||Nx()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=ph(n,i)),n.read()};function Nx(){let i=Mx(()=>(ye=null,Dr.getStructures()));return it=Dr._mergeStructures(i,it)}var fh=Ec,YP=Ec,XP=Ec,ZP=Ec;function Ec(i){let t;if(i<16&&(t=dh(i)))return t;if(i>64&&lh)return lh.decode(ye.subarray(D,D+=i));let e=D+i,r=[];for(t="";D<e;){let n=ye[D++];if((n&128)===0)r.push(n);else if((n&224)===192){let o=ye[D++]&63;r.push((n&31)<<6|o)}else if((n&240)===224){let o=ye[D++]&63,a=ye[D++]&63;r.push((n&31)<<12|o<<6|a)}else if((n&248)===240){let o=ye[D++]&63,a=ye[D++]&63,c=ye[D++]&63,f=(n&7)<<18|o<<12|a<<6|c;f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|f&1023),r.push(f)}else r.push(n);r.length>=4096&&(t+=er.apply(String,r),r.length=0)}return r.length>0&&(t+=er.apply(String,r)),t}function Sx(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}function wx(i){if(Dr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[Ix()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}}var er=String.fromCharCode;function _x(i){let t=D,e=new Array(i);for(let r=0;r<i;r++){let n=ye[D++];if((n&128)>0){D=t;return}e[r]=n}return er.apply(String,e)}function dh(i){if(i<4)if(i<2){if(i===0)return"";{let t=ye[D++];if((t&128)>1){D-=1;return}return er(t)}}else{let t=ye[D++],e=ye[D++];if((t&128)>0||(e&128)>0){D-=2;return}if(i<3)return er(t,e);let r=ye[D++];if((r&128)>0){D-=3;return}return er(t,e,r)}else{let t=ye[D++],e=ye[D++],r=ye[D++],n=ye[D++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){D-=4;return}if(i<6){if(i===4)return er(t,e,r,n);{let o=ye[D++];if((o&128)>0){D-=5;return}return er(t,e,r,n,o)}}else if(i<8){let o=ye[D++],a=ye[D++];if((o&128)>0||(a&128)>0){D-=6;return}if(i<7)return er(t,e,r,n,o,a);let c=ye[D++];if((c&128)>0){D-=7;return}return er(t,e,r,n,o,a,c)}else{let o=ye[D++],a=ye[D++],c=ye[D++],f=ye[D++];if((o&128)>0||(a&128)>0||(c&128)>0||(f&128)>0){D-=8;return}if(i<10){if(i===8)return er(t,e,r,n,o,a,c,f);{let h=ye[D++];if((h&128)>0){D-=9;return}return er(t,e,r,n,o,a,c,f,h)}}else if(i<12){let h=ye[D++],d=ye[D++];if((h&128)>0||(d&128)>0){D-=10;return}if(i<11)return er(t,e,r,n,o,a,c,f,h,d);let m=ye[D++];if((m&128)>0){D-=11;return}return er(t,e,r,n,o,a,c,f,h,d,m)}else{let h=ye[D++],d=ye[D++],m=ye[D++],x=ye[D++];if((h&128)>0||(d&128)>0||(m&128)>0||(x&128)>0){D-=12;return}if(i<14){if(i===12)return er(t,e,r,n,o,a,c,f,h,d,m,x);{let S=ye[D++];if((S&128)>0){D-=13;return}return er(t,e,r,n,o,a,c,f,h,d,m,x,S)}}else{let S=ye[D++],w=ye[D++];if((S&128)>0||(w&128)>0){D-=14;return}if(i<15)return er(t,e,r,n,o,a,c,f,h,d,m,x,S,w);let B=ye[D++];if((B&128)>0){D-=15;return}return er(t,e,r,n,o,a,c,f,h,d,m,x,S,w,B)}}}}}function ah(i){return Dr.copyBuffers?Uint8Array.prototype.slice.call(ye,D,D+=i):ye.subarray(D,D+=i)}function fo(i){let t=ye[D++];if(wr[t])return wr[t](ye.subarray(D,D+=i));throw new Error("Unknown extension type "+t)}var Cx=new Array(4096);function Ix(){let i=ye[D++];if(i>=160&&i<192){if(i=i-160,zn>=D)return Ei.slice(D-un,(D+=i)-un);if(!(zn==0&&Bi<180))return fh(i)}else return D--,Et();let t=(i<<5^(i>1?ct.getUint16(D):i>0?ye[D]:0))&4095,e=Cx[t],r=D,n=D+i-3,o,a=0;if(e&&e.bytes==i){for(;r<n;){if(o=ct.getUint32(r),o!=e[a++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(o=ye[r++],o!=e[a++]){r=1879048192;break}if(r===n)return D=r,e.string;n-=3,r=D}for(e=[],Cx[t]=e,e.bytes=i;r<n;)o=ct.getUint32(r),e.push(o),r+=4;for(n+=3;r<n;)o=ye[r++],e.push(o);let c=i<16?dh(i):_x(i);return c!=null?e.string=c:e.string=fh(i)}var Lx=(i,t)=>{var e=Et();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=it[i];return n&&n.isShared&&((it.restoreStructures||(it.restoreStructures=[]))[i]=n),it[i]=e,e.read=ph(e,r),e.read()},Ox=typeof self=="object"?self:global;wr[0]=()=>{};wr[0].noBuffer=!0;wr[101]=()=>{let i=Et();return(Ox[i[0]]||Error)(i[1])};wr[105]=i=>{let t=ct.getUint32(D-4);li||(li=new Map);let e=ye[D],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};li.set(t,n);let o=Et();return n.used?Object.assign(r,o):(n.target=o,o)};wr[112]=i=>{let t=ct.getUint32(D-4),e=li.get(t);return e.used=!0,e.target};wr[115]=()=>new Set(Et());var mh=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");wr[116]=i=>{let t=i[0],e=mh[t];if(!e)throw new Error("Could not find typed array for code "+t);return new Ox[e](Uint8Array.prototype.slice.call(i,1).buffer)};wr[120]=()=>{let i=Et();return new RegExp(i[0],i[1])};wr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=D;D+=t-4,$r=[Et(),Et()],$r.position0=0,$r.position1=0;let r=D;D=e;try{return Et()}finally{D=r}};wr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function Mx(i){let t=Bi,e=D,r=uh,n=un,o=zn,a=Ei,c=ch,f=li,h=$r,d=new Uint8Array(ye.slice(0,Bi)),m=it,x=it.slice(0,it.length),S=Dr,w=hs,B=i();return Bi=t,D=e,uh=r,un=n,zn=o,Ei=a,ch=c,li=f,$r=h,ye=d,hs=w,it=m,it.splice(0,it.length,...x),Dr=S,ct=new DataView(ye.buffer,ye.byteOffset,ye.byteLength),B}function Dc(){ye=null,li=null,it=null}function Px(i){i.unpack?wr[i.type]=i.unpack:wr[i.type]=i}var Bc=new Array(147);for(let i=0;i<256;i++)Bc[i]=+("1e"+Math.floor(45.15-i*.30103));var Gc=new Fn({useRecords:!1}),QP=Gc.unpack,eA=Gc.unpackMultiple,tA=Gc.unpack,Rc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},rA=new Float32Array(1),v4=new Uint8Array(rA.buffer,0,4);var zc;try{zc=new TextEncoder}catch{}var Fc,yh,Vc=typeof Buffer<"u",gh=Vc?Buffer.allocUnsafeSlow:Uint8Array,Bx=Vc?Buffer:Uint8Array,Ax=Vc?4294967296:2144337920,X,zt,z=0,Vn,Un=null,nA=/[\u0080-\uFFFF]/,va=Symbol("record-id"),ho=class extends Fn{constructor(t){super(t),this.offset=0;let e,r,n,o,a,c,f=0,h=Bx.prototype.utf8Write?function(b,V,P){return X.utf8Write(b,V,P)}:zc&&zc.encodeInto?function(b,V){return zc.encodeInto(b,X.subarray(V)).written}:!1,d=this;t||(t={});let m=t&&t.sequential,x=t.structures||t.saveStructures,S=t.maxSharedStructures;if(S==null&&(S=x?32:0),S>8160)throw new Error("Maximum maxSharedStructure is 8160");let w=t.maxOwnStructures;w==null&&(w=x?32:64),m&&!t.saveStructures&&(this.structures=[]);let B=S>32||w+S>64,O=S+64,T=S+w+64;if(T>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let M=[],F=0,k=0;this.pack=this.encode=function(b,V){if(X||(X=new gh(8192),zt=new DataView(X.buffer,0,8192),z=0),Vn=X.length-10,Vn-z<2048?(X=new gh(X.length),zt=new DataView(X.buffer,0,X.length),Vn=X.length-10,z=0):z=z+7&2147483640,r=z,c=d.structuredClone?new Map:null,d.bundleStrings?(Un=["",""],X[z++]=214,X[z++]=98,Un.position=z-r,z+=4):Un=null,n=d.structures,n){n.uninitialized&&(n=d._mergeStructures(d.getStructures()));let P=n.sharedLength||0;if(P>S)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let R=0;R<P;R++){let E=n[R];if(!E)continue;let G,ae=n.transitions;for(let ne=0,xe=E.length;ne<xe;ne++){let _e=E[ne];G=ae[_e],G||(G=ae[_e]=Object.create(null)),ae=G}ae[va]=R+64}f=P}m||(n.nextId=P+64)}o&&(o=!1),a=n||[];try{if(N(b),Un){zt.setUint32(Un.position+r,z-Un.position-r);let P=Un;Un=null,N(P[0]),N(P[1])}if(d.offset=z,c&&c.idsToInsert){z+=c.idsToInsert.length*6,z>Vn&&A(z),d.offset=z;let P=oA(X.subarray(r,z),c.idsToInsert);return c=null,P}return V&Rx?(X.start=r,X.end=z,X):X.subarray(r,z)}finally{if(n){if(k<10&&k++,F>1e4)n.transitions=null,k=0,F=0,M.length>0&&(M=[]);else if(M.length>0&&!m){for(let P=0,R=M.length;P<R;P++)M[P][va]=0;M=[]}if(o&&d.saveStructures){let P=n.sharedLength||S;n.length>P&&(n=n.slice(0,P));let R=X.subarray(r,z);return d.saveStructures(n,f)===!1?(d._mergeStructures(d.getStructures()),d.pack(b)):(f=P,R)}}V&hA&&(z=r)}};let N=b=>{z>Vn&&(X=A(z));var V=typeof b,P;if(V==="string"){let R=b.length;if(Un&&R>=8&&R<4096){let ae=nA.test(b);Un[ae?0:1]+=b,X[z++]=193,N(ae?-R:R);return}let E;R<32?E=1:R<256?E=2:R<65536?E=3:E=5;let G=R*3;if(z+G>Vn&&(X=A(z+G)),R<64||!h){let ae,ne,xe,_e=z+E;for(ae=0;ae<R;ae++)ne=b.charCodeAt(ae),ne<128?X[_e++]=ne:ne<2048?(X[_e++]=ne>>6|192,X[_e++]=ne&63|128):(ne&64512)===55296&&((xe=b.charCodeAt(ae+1))&64512)===56320?(ne=65536+((ne&1023)<<10)+(xe&1023),ae++,X[_e++]=ne>>18|240,X[_e++]=ne>>12&63|128,X[_e++]=ne>>6&63|128,X[_e++]=ne&63|128):(X[_e++]=ne>>12|224,X[_e++]=ne>>6&63|128,X[_e++]=ne&63|128);P=_e-z-E}else P=h(b,z+E,G);P<32?X[z++]=160|P:P<256?(E<2&&X.copyWithin(z+2,z+1,z+1+P),X[z++]=217,X[z++]=P):P<65536?(E<3&&X.copyWithin(z+3,z+2,z+2+P),X[z++]=218,X[z++]=P>>8,X[z++]=P&255):(E<5&&X.copyWithin(z+5,z+3,z+3+P),X[z++]=219,zt.setUint32(z,P),z+=4),z+=P}else if(V==="number")if(b>>>0===b)b<64?X[z++]=b:b<256?(X[z++]=204,X[z++]=b):b<65536?(X[z++]=205,X[z++]=b>>8,X[z++]=b&255):(X[z++]=206,zt.setUint32(z,b),z+=4);else if(b>>0===b)b>=-32?X[z++]=256+b:b>=-128?(X[z++]=208,X[z++]=b+256):b>=-32768?(X[z++]=209,zt.setInt16(z,b),z+=2):(X[z++]=210,zt.setInt32(z,b),z+=4);else{let R;if((R=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){X[z++]=202,zt.setFloat32(z,b);let E;if(R<4||(E=b*Bc[(X[z]&127)<<1|X[z+1]>>7])>>0===E){z+=4;return}else z--}X[z++]=203,zt.setFloat64(z,b),z+=8}else if(V==="object")if(!b)X[z++]=192;else{if(c){let E=c.get(b);if(E){if(!E.id){let G=c.idsToInsert||(c.idsToInsert=[]);E.id=G.push(E)}X[z++]=214,X[z++]=112,zt.setUint32(z,E.id),z+=4;return}else c.set(b,{offset:z-r})}let R=b.constructor;if(R===Object)te(b,!0);else if(R===Array){P=b.length,P<16?X[z++]=144|P:P<65536?(X[z++]=220,X[z++]=P>>8,X[z++]=P&255):(X[z++]=221,zt.setUint32(z,P),z+=4);for(let E=0;E<P;E++)N(b[E])}else if(R===Map){P=b.size,P<16?X[z++]=128|P:P<65536?(X[z++]=222,X[z++]=P>>8,X[z++]=P&255):(X[z++]=223,zt.setUint32(z,P),z+=4);for(let[E,G]of b)N(E),N(G)}else{for(let E=0,G=Fc.length;E<G;E++){let ae=yh[E];if(b instanceof ae){let ne=Fc[E];if(ne.write){ne.type&&(X[z++]=212,X[z++]=ne.type,X[z++]=0),N(ne.write.call(this,b));return}let xe=X,_e=zt,Le=z;X=null;let Ue;try{Ue=ne.pack.call(this,b,se=>(X=xe,xe=null,z+=se,z>Vn&&A(z),{target:X,targetView:zt,position:z-se}),N)}finally{xe&&(X=xe,zt=_e,z=Le,Vn=X.length-10)}Ue&&(Ue.length+z>Vn&&A(Ue.length+z),z=iA(Ue,X,z,ne.type));return}}te(b,!b.hasOwnProperty)}}else if(V==="boolean")X[z++]=b?195:194;else if(V==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))X[z++]=211,zt.setBigInt64(z,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)X[z++]=207,zt.setBigUint64(z,b);else if(this.largeBigIntToFloat)X[z++]=203,zt.setFloat64(z,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");z+=8}else if(V==="undefined")this.encodeUndefinedAsNil?X[z++]=192:(X[z++]=212,X[z++]=0,X[z++]=0);else if(V==="function")N(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+V)},te=this.useRecords===!1?this.variableMapSize?b=>{let V=Object.keys(b),P=V.length;P<16?X[z++]=128|P:P<65536?(X[z++]=222,X[z++]=P>>8,X[z++]=P&255):(X[z++]=223,zt.setUint32(z,P),z+=4);let R;for(let E=0;E<P;E++)N(R=V[E]),N(b[R])}:(b,V)=>{X[z++]=222;let P=z-r;z+=2;let R=0;for(let E in b)(V||b.hasOwnProperty(E))&&(N(E),N(b[E]),R++);X[P+++r]=R>>8,X[P+r]=R&255}:b=>{let V=Object.keys(b),P,R=a.transitions||(a.transitions=Object.create(null)),E=0;for(let ae=0,ne=V.length;ae<ne;ae++){let xe=V[ae];P=R[xe],P||(P=R[xe]=Object.create(null),E++),R=P}let G=R[va];if(G)G>=96&&B?(X[z++]=((G-=96)&31)+96,X[z++]=G>>5):X[z++]=G;else{G=a.nextId,G||(G=64),G<O&&this.shouldShareStructure&&!this.shouldShareStructure(V)?(G=a.nextOwnId,G<T||(G=O),a.nextOwnId=G+1):(G>=T&&(G=O),a.nextId=G+1);let ae=V.highByte=G>=96&&B?G-96>>5:-1;R[va]=G,a[G-64]=V,G<O?(V.isShared=!0,a.sharedLength=G-63,o=!0,ae>=0?(X[z++]=(G&31)+96,X[z++]=ae):X[z++]=G):(ae>=0?(X[z++]=213,X[z++]=114,X[z++]=(G&31)+96,X[z++]=ae):(X[z++]=212,X[z++]=114,X[z++]=G),E&&(F+=k*E),M.length>=w&&(M.shift()[va]=0),M.push(R),N(V))}for(let ae=0,ne=V.length;ae<ne;ae++)N(b[V[ae]])},A=b=>{let V;if(b>16777216){if(b-r>Ax)throw new Error("Packed buffer would be larger than maximum buffer size");V=Math.min(Ax,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else V=(Math.max(b-r<<2,X.length-1)>>12)+1<<12;let P=new gh(V);return zt=new DataView(P.buffer,0,V),X.copy?X.copy(P,0,r,b):P.set(X.slice(r,b)),z-=r,r=0,Vn=P.length-10,X=P}}useBuffer(t){X=t,zt=new DataView(X.buffer,X.byteOffset,X.byteLength),z=0}};yh=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,xa];Fc=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:o,position:a}=t(6);n[a++]=214,n[a++]=255,o.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:n,targetView:o,position:a}=t(10);n[a++]=215,n[a++]=255,o.setUint32(a,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),o.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:n,targetView:o,position:a}=t(3);n[a++]=212,n[a++]=255,n[a++]=255}else{let{target:n,targetView:o,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,o.setUint32(a,i.getMilliseconds()*1e6),o.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(n[o++]=212,n[o++]=115,n[o++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?Dx(i,16,t):Ex(Vc?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==Bx&&this.structuredClone?Dx(i,mh.indexOf(e.name),t):Ex(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function Dx(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:o,position:a}=e(4+n);o[a++]=199,o[a++]=n+1}else if(n+1<65536){var{target:o,position:a}=e(5+n);o[a++]=200,o[a++]=n+1>>8,o[a++]=n+1&255}else{var{target:o,position:a,targetView:c}=e(7+n);o[a++]=201,c.setUint32(a,n+1),a+=4}o[a++]=116,o[a++]=t,o.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function Ex(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:o}=t(e+5);r[n++]=198,o.setUint32(n,e),n+=4}r.set(i,n)}function iA(i,t,e,r){let n=i.length;switch(n){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function oA(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((o,a)=>o.offset>a.offset?1:-1);e=t.pop();){let o=e.offset,a=e.id;i.copyWithin(o+r,o,n),r-=6;let c=o+r;i[c++]=214,i[c++]=105,i[c++]=a>>24,i[c++]=a>>16&255,i[c++]=a>>8&255,i[c++]=a&255,n=o}return i}function po(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");yh.unshift(i.Class),Fc.unshift(i)}Px(i)}var Gx=new ho({useRecords:!1}),sA=Gx.pack,aA=Gx.pack;var{NEVER:lA,ALWAYS:cA,DECIMAL_ROUND:uA,DECIMAL_FIT:fA}=Rc,Rx=512,hA=1024;var zx=new ho({structuredClone:!0});po({Class:ln.prototype.constructor,type:1,write(i){return j({},i)},read(i){return Object.setPrototypeOf(i,ln.prototype),i}});po({Class:At.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,At.prototype),i}});po({Class:cn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,cn.prototype),i}});po({Class:ga.prototype.constructor,type:4,write(i){return i.id},read(i){return new ga(i)}});po({Class:ya.prototype.constructor,type:5,write(i){return i.data},read(i){return new ya(i)}});function pA(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}var Uc;(r=>{function i(n){return zx.pack(n)}r.serialize=i;function t(n){return zx.unpack(n)}r.deserialize=t;function e(n){return pA(i(n)).toString()}r.checksum=e})(Uc||(Uc={}));var jc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(jc||(jc={}));var kc;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Gn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:Gn.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:Gn.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(kc||(kc={}));var xh;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(xh||(xh={}));var vh;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(vh||(vh={}));var Hc;(t=>t.defaultData=ue(j(j({},vh.defaultData),xh.defaultData),{cloner:null}))(Hc||(Hc={}));var bh=(n=>(n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Center=3]="Center",n[n.Justify=4]="Justify",n))(bh||{}),Sh=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Sh||{}),wh=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(wh||{}),Wc;(t=>t.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:Gn.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(Wc||(Wc={}));var ps;(r=>{function i(n,o){return n==="light"&&o?t(o):e(n)}r.defaultData=i;function t(n){switch(n){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function e(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:qr.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:ue(j({},qr.fromHex(6710886)),{a:1}),colorB:ue(j({},qr.fromHex(6710886)),{a:1}),colorC:ue(j({},qr.fromHex(16777215)),{a:1}),colorD:ue(j({},qr.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:Gn.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(ps||(ps={}));var ds;(c=>{function i(f){return!f.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!e(f)}c.isMergable=i;function t(f){let h="";return f.layers.forEach(d=>{Object.entries(d.data).forEach(([m,x])=>{h+=`${m}${x}`,Array.isArray(x)?x.forEach(S=>h+=`${S}`):typeof x=="object"?Object.values(x).forEach(S=>{typeof S=="number"?h+=`${S.toFixed(4)}`:h+=`${S}`}):h+=`${x}`})}),h}c.getHash=t;function e(f){let h=0;for(let d of f.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(h+=(1-h)*d.data.alpha);return h<1}c.isTransparent=e;function r(){return{layers:new At}}c.defaultEmptyData=r;function n(f="layer1",h="layer2"){return o("phong",f,h)}c.defaultData=n;function o(f,h="layer1",d="layer2"){let m=new At;return m.push({fi:0,data:ps.defaultData("light",f),id:h}),m.push({fi:1,data:ps.defaultData("color"),id:d}),{layers:m}}c.defaultTwoLayerData=o;function a(f,h="basic",d="layer1",m="layer2"){let x=ps.defaultData("texture");Object.assign(x.texture,{image:f});let S=new At;return S.push({fi:0,data:x,id:d}),S.push({fi:1,data:ps.defaultData("light",h),id:m}),{layers:S}}c.defaultTwoLayerTextureData=a})(ds||(ds={}));var ms;(r=>{function i(){return{points:new At,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function t(n,o){let{points:a}=o;if(a){for(let c of a)if(c.data.position[0]===n[0]&&c.data.position[1]===n[1])return!0}return!1}r.isOverlappingExistingPoint=t;function e(n,o){let a=n.controlNext,c=o.controlPrevious;return n.position[0]===a.position[0]&&n.position[1]===a.position[1]&&o.position[0]===c.position[0]&&o.position[1]===c.position[1]}r.isStraightLine=e})(ms||(ms={}));var qc;(t=>{function i(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=i})(qc||(qc={}));var $c;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(e==="VectorGeometry")return{width:100,height:100,type:e,subdivisions:12,shape:ms.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}t.defaultData=i})($c||($c={}));var ba;(n=>{n.identity=ue(j({},Cc.identity),{hiddenMatrix:Di.identity});function t(o){return{position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix}}n.fromObject=t;function e(o,a){return{position:(a==null?void 0:a.position)||o.position,rotation:(a==null?void 0:a.rotation)||o.rotation,scale:(a==null?void 0:a.scale)||o.scale,hiddenMatrix:(a==null?void 0:a.hiddenMatrix)||o.hiddenMatrix}}n.merge=e;function r(o,a){return{position:ls.isEqual(o.position,a.position)?null:a.position,rotation:ls.isEqual(o.rotation,a.rotation)?null:a.rotation,scale:ls.isEqual(o.scale,a.scale)?null:a.scale,hiddenMatrix:Di.isEqual(o.hiddenMatrix,a.hiddenMatrix)?null:a.hiddenMatrix}}n.diff=r})(ba||(ba={}));var Gi;(t=>t.defaultData=j({states:new At,events:new At,visible:!0,raycastLock:!1},ba.identity))(Gi||(Gi={}));var Fx;(t=>t.defaultData=j({type:"Empty"},Gi.defaultData))(Fx||(Fx={}));var Ch;(t=>t.defaultData=j(j({type:"Mesh"},Gi.defaultData),Hc.defaultData))(Ch||(Ch={}));var Vx;(t=>t.defaultData=j(j({type:"TextFrame"},Gi.defaultData),Wc.defaultData))(Vx||(Vx={}));var Jc;(t=>t.defaultData=j(j(j({},Gi.defaultData),ba.identity),uo.defaultData))(Jc||(Jc={}));var Ux;(t=>{function i(e){return j(j({},Gi.defaultData),kc.defaultData(e))}t.defaultData=i})(Ux||(Ux={}));var jx;(e=>(e.defaultCamera=j({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Di.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new At,events:new At},uo.defaultData),e.defaultMeshObject=ue(j(j({name:"Rectangle"},Gi.defaultData),Ch.defaultData),{geometry:$c.defaultData("RectangleGeometry"),material:ds.defaultTwoLayerData("basic","layer1","layer2")})))(jx||(jx={}));var kx;(e=>{function i(r,n){if(n===void 0)return r;let o=j({},r);return"material"in o&&"material"in n&&n.material&&(o.material=oh(o.material,a=>{if(typeof a!="string")for(let[c,f]of Object.entries(n.material.layers)){let h=a.layers.data(c);h&&co(h,f)}}).data),o.materials&&n.materials&&(o.materials=oh(o.materials,a=>{var c,f;for(let h=0;h<o.materials.length;h++){let d=n.materials[h];if(typeof d!="string")for(let[m,x]of Object.entries(d.layers)){let S=(f=(c=a[h])==null?void 0:c.layers)==null?void 0:f.data(m);S&&co(S,x)}}}).data),o}e.patchMaterialState=i;function t(r,n){var a,c;if(n===void 0)return r;let o=j({},r);if(Object.assign(o,ba.merge(o,n)),as.is(r.type)){o.orthographic=j({},o.orthographic),o.perspective=j({},o.perspective);let f=n;((a=f.orthographic)==null?void 0:a.zoom)!==void 0&&(o.orthographic.zoom=f.orthographic.zoom),((c=f.perspective)==null?void 0:c.zoom)!==void 0&&(o.perspective.zoom=f.perspective.zoom)}else if(r.type==="Mesh")o.geometry=j({},o.geometry),Object.assign(o.geometry,n.geometry),o=i(o,n);else if(jc.is(r.type)){let f=n;o.intensity!==void 0&&(o.intensity=f.intensity),f.color!==void 0&&(typeof f.color=="string"?o.color=f.color:o.color=qr.clone(f.color))}return o}e.patch=t})(kx||(kx={}));import{BufferGeometry as Ej,ConeBufferGeometry as gA,Float32BufferAttribute as Bj,Vector2 as Gj,Vector3 as Rj}from"three";import{BufferGeometry as dA,CylinderBufferGeometry as mA,Float32BufferAttribute as Lh,Vector2 as Cn,Vector3 as Kc}from"three";var Wx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var a,c,f,h,d;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=e.width/2,n=(c=e.radiusTop)!=null?c:r,o=(f=e.radiusBottom)!=null?f:r;return n===o?(n=r,o=r):n>o?(n=r,o=o*r/n):(n=n*r/o,o=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((h=e.height)!=null?h:e.width),depth:Math.abs((d=e.depth)!=null?d:e.width),radiusTop:n,radiusBottom:o})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:c,thetaLength:f,radiusTop:h,radiusBottom:d,cornerRadius:m,cornerSegments:x,hollow:S}=i.parameters,w;return m||S?w=new Sa(h,d,r,n,o,a,c,f*Math.PI/180,m,m,x,S):w=new mA(h,d,r,n,o,a,c,f*Math.PI/180),w.scale(1,1,e/t),Object.assign(w,{userData:ue(j({},i),{type:"CylinderGeometry"})})}};function Ri(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Hx(i){return new Cn(i.y,-i.x)}var Sa=class extends dA{constructor(t,e,r,n,o,a,c,f,h,d,m,x,S=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,o=Math.floor(o)||1,a=a!==void 0?a:!1,c=c!==void 0?c:0,f=f!==void 0?f:Math.PI*2,a&&(h=0,d=0);let w=[],B=[],O=[],T=[],M=0,F=r/2,k=new Kc,N=new Kc;S&&t==0&&(t=h),S&&e==0&&(e=d);let te=new Cn(t,F),A=new Cn(e,-F),b=null,V=null,P=null,R=null,E=te.clone().sub(A),G=0,ae=0,ne=0;x>0&&(G=Math.min(t,e)*(1-x),ae=t-G,ne=e-G);let xe=te.clone();xe.x-=G;let _e=Math.PI-E.angle(),Le=E.angle(),Ue=Math.tan(Le/2),se=Math.tan(_e/2),$=Ue+se,W=x?$:se,J=x?$:Ue;if(h=Math.min(h,(t-ae)/W,E.length()/$),d=Math.min(d,(e-ne)/J,E.length()/$),h>0){let re=h/Ue;b=te.clone().sub(new Cn(re,h)),x&&(P=b.clone(),P.x-=G-$*h),te.sub(E.clone().setLength(re))}if(d>0){let re=d/se;V=A.clone().sub(new Cn(re,-d)),A.add(E.clone().setLength(re)),x&&(R=V.clone(),R.x-=G-$*d,xe.sub(E.clone().setLength(re)))}E=te.clone().sub(A);let H=E.length()<.5,K=[];for(let re=0;re<=n;re++){let q=[],ee=re/n,Te=ee*f+c,ce=new Cn(Math.sin(Te),Math.cos(Te));R&&V?(fe(q,ee,ce,_e,d,R,-1,!0),fe(q,ee,ce,Le,d,V,-1,!1)):V?(me(q,ce,V.x,0,-1),fe(q,ee,ce,Le,d,V,-1,!1)):a||me(q,ce,e,ne,-1);let le=Hx(E).normalize();if(Ri(le,ce,k),!H)for(let he=0;he<=o;he++){let pe=he/o,de=E.clone().multiplyScalar(pe).add(A);Ri(de,ce,N),B.push(N.x,N.y,N.z),O.push(k.x,k.y,k.z),T.push(ee,.5+N.y/r),q.push(M++)}if(P&&b?(fe(q,ee,ce,_e,h,b,1,!1),fe(q,ee,ce,Le,h,P,1,!0)):b?(fe(q,ee,ce,_e,h,b,1,!1),me(q,ce,b.x,0,1)):a||me(q,ce,t,ae,1),x&&!H){let he=Hx(E).multiplyScalar(-1).normalize();Ri(he,ce,k);for(let pe=0;pe<=o;pe++){let de=pe/o,be=E.clone().multiplyScalar(-de).add(xe);Ri(be,ce,N),B.push(N.x,N.y,N.z),O.push(k.x,k.y,k.z),T.push(ee,.5+N.y/r),q.push(M++)}}x&&!a&&q.push(q[0]),K.push(q)}for(let re=0;re<K.length-1;re++)for(let q=0;q<K[0].length-1;q++){if(a&&x&&q==o)continue;let ee=K[re][q],Te=K[re+1][q],ce=K[re+1][q+1],le=K[re][q+1],he=B[ce*3+0],pe=B[ce*3+2];w.push(ee,Te,le),(he!=0||pe!=0)&&w.push(Te,ce,le)}f<Math.PI*2&&(ie(-1,K[0],c),ie(1,K[K.length-1],c+f)),this.setIndex(w),this.setAttribute("position",new Lh(B,3)),this.setAttribute("normal",new Lh(O,3)),this.setAttribute("uv",new Lh(T,2));function fe(re,q,ee,Te,ce,le,he,pe){for(let de=0;de<m+1;de++){let be=de/m,Se=he<0?be:1-be;pe&&(Se-=1),Se*=Te;let Ie=new Cn(Math.sin(Se),Math.cos(Se)*he),ft=Ie.clone().multiplyScalar(ce).add(le);Ri(ft,ee,N),B.push(N.x,N.y,N.z),Ri(Ie,ee,k),O.push(k.x,k.y,k.z),T.push(q,.5+N.y/r),re.push(M++)}}function me(re,q,ee,Te,ce){let le=new Kc,he=new Cn,pe=[ee,Te];ce<0&&pe.reverse();for(let de of pe)he.set(de,F*ce),Ri(he,q,le),B.push(le.x,le.y,le.z),O.push(0,ce,0),T.push(.5,.5),re.push(M++)}function ie(re,q,ee){let Te=new Cn(Math.sin(ee),Math.cos(ee)),ce=new Cn(-Math.cos(ee),Math.sin(ee)),le=new Kc,he=re<0?(be,Se,Ie)=>w.push(be,Se,Ie):(be,Se,Ie)=>w.push(be,Ie,Se),pe=new Cn((t+e+ae+ne)/4,0);Ri(pe,Te,le),B.push(le.x,le.y,le.z),O.push(ce.x,0,ce.y),T.push(.5,.5);let de=M++;for(let be of q){let Se=B.slice(be*3,be*3+3);B.push(...Se),O.push(ce.x,0,ce.y);let Ie=T.slice(be*2,be*2+2);T.push(...Ie),M++}for(let be=de+1;be<M-1;be++)he(de,be,be+1);he(de,M-1,de+1)}}};var qx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:c,thetaLength:f,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:m}=i.parameters,x;return h>0||d>0||f<360?x=new Sa(0,t/2,r,n,o,a,c,f*Math.PI/180,h,d,m,0,!0):x=new gA(t/2,r,n,o,a),x.scale(1,1,e/t),Object.assign(x,{userData:ue(j({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as yA,BufferGeometry as xA,Float32BufferAttribute as Th,Vector3 as wa}from"three";var $x=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:o,depthSegments:a,cornerRadius:c,cornerSegments:f}=i.parameters,h;return c==0?h=new yA(t,e,r,n,o,a):h=new _h(t,e,r,n,o,a,c,f),Object.assign(h,{userData:ue(j({},i),{type:"CubeGeometry"})})}},Nh=Math.PI/2,_h=class extends xA{constructor(t=1,e=1,r=1,n=1,o=1,a=1,c=0,f=4){super(),this.type="BoxBufferGeometry";let h=this;n=Math.floor(n),o=Math.floor(o),a=Math.floor(a),f=Math.floor(f),c=Math.min(c,t/2,e/2,r/2);let d=[],m=[],x=[],S=[],w=0,B=0;O("z","y","x",-1,-1,r,e,t,a,o,0),O("z","y","x",1,-1,r,e,-t,a,o,1),O("x","z","y",1,1,t,r,e,n,a,2),O("x","z","y",1,-1,t,r,-e,n,a,3),O("x","y","z",1,-1,t,e,r,n,o,4),O("x","y","z",-1,-1,t,e,-r,n,o,5),c>0&&(T("z","y","x",-1,-1,1,r,e,t,a,0),T("z","y","x",1,-1,-1,r,e,t,a,1),T("z","y","x",-1,1,-1,r,e,t,a,1),T("z","y","x",1,1,1,r,e,t,a,0),T("x","y","z",-1,-1,-1,t,e,r,n,0),T("x","y","z",1,-1,1,t,e,r,n,1),T("x","y","z",-1,1,1,t,e,r,n,0),T("x","y","z",1,1,-1,t,e,r,n,1),T("y","x","z",-1,-1,1,e,t,r,o,0),T("y","x","z",1,-1,-1,e,t,r,o,1),T("y","x","z",1,1,1,e,t,r,o,1),T("y","x","z",-1,1,-1,e,t,r,o,0),M(1,1,1),M(-1,1,1),M(1,-1,1),M(-1,-1,1),M(1,1,-1),M(-1,1,-1),M(1,-1,-1),M(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new Th(m,3)),this.setAttribute("normal",new Th(x,3)),this.setAttribute("uv",new Th(S,2));function O(F,k,N,te,A,b,V,P,R,E,G){let ae=(b-2*c)/R,ne=(V-2*c)/E,xe=b/2-c,_e=V/2-c,Le=P/2,Ue=R+1,se=E+1,$=0,W=0,J=new wa;for(let H=0;H<se;H++){let K=H*ne-_e;for(let fe=0;fe<Ue;fe++){let me=fe*ae-xe;J[F]=me*te,J[k]=K*A,J[N]=Le,m.push(J.x,J.y,J.z),J[F]=0,J[k]=0,J[N]=P>0?1:-1,x.push(J.x,J.y,J.z),S.push(fe/R),S.push(1-H/E),$+=1}}for(let H=0;H<E;H++)for(let K=0;K<R;K++){let fe=w+K+Ue*H,me=w+K+Ue*(H+1),ie=w+(K+1)+Ue*(H+1),re=w+(K+1)+Ue*H;d.push(fe,me,re),d.push(me,ie,re),W+=6}h.addGroup(B,W,G),B+=W,w+=$}function T(F,k,N,te,A,b,V,P,R,E,G){let ae=(V-2*c)/E,ne=V/2-c,xe=P/2-c,_e=R/2,Le=E+1,Ue=0,se=0,$=new wa,W=new wa;for(let J=0;J<f+1;J++){let H=J/f*Nh,K=Math.sin(H)*c,fe=(1-Math.cos(H))*c,me=Math.sin(H),ie=Math.cos(H);$[k]=(xe+K)*A,$[N]=(_e-fe)*b,W[F]=0,W[k]=me*Math.sign($[k]),W[N]=ie*Math.sign($[N]);for(let re=0;re<Le;re++){let q=re*ae-ne;$[F]=q*te,m.push($.x,$.y,$.z),x.push(W.x,W.y,W.z),S.push(re/E),S.push(0),Ue+=1}}for(let J=0;J<f;J++)for(let H=0;H<E;H++){let K=w+H+Le*J,fe=w+H+Le*(J+1),me=w+(H+1)+Le*(J+1),ie=w+(H+1)+Le*J;d.push(K,fe,ie),d.push(fe,me,ie),se+=6}h.addGroup(B,se,G),B+=se,w+=Ue}function M(F,k,N){let te=new wa,A=new wa(t/2,e/2,r/2);A.subScalar(c);let b=[],V=F*k*N>0?(R,E,G)=>d.push(R,E,G):(R,E,G)=>d.push(R,G,E);for(let R=0;R<=f;R++){let E=[],G=Nh*(1-R/f),ae=Math.cos(G),ne=Math.sin(G),xe=0;for(let _e=0;_e<=R;_e++){let Le=Math.cos(xe),Ue=Math.sin(xe);te.x=ae*Le,te.y=ne,te.z=ae*Ue;let se=A.clone().addScaledVector(te,c);m.push(F*se.x,k*se.y,N*se.z),x.push(F*te.x,k*te.y,N*te.z),S.push(0,0),E.push(w++),xe+=Nh/R}b.push(E)}let P=b.length-1;for(let R=0;R<P;R++){let E=b[R],G=b[R+1],ae=E.length-1;V(E[0],G[1],G[0]);for(let ne=1;ne<=ae;ne++)V(E[ne-1],E[ne],G[ne]),V(E[ne],G[ne+1],G[ne])}}}};import{BufferGeometry as vA,Float32BufferAttribute as Ih,Triangle as bA,Vector3 as ci,Vector2 as Oh}from"three";var zi=class extends vA{constructor(t=[],e=[],r="",n=1,o=.2,a=4){super(),this.type="PolyhedronGeometryRound";let c=[],f=[],h=[];d(),m(),this.setAttribute("position",new Ih(c,3)),this.setAttribute("normal",new Ih(h,3)),this.setAttribute("uv",new Ih(f,2));return;function d(){var Ue;o=Math.min(1-1e-5,o),o==0&&(a=0);let S={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],w=new ci,B=w.clone(),O=new bA,T=o*n,M=n-T,F=a+1,k=new ci,N=(se,$)=>k.subVectors(se,$).normalize(),te=(se,$)=>Array(se).fill(void 0).map($),A=te(t.length/3,(se,$)=>new ci().fromArray(t,$*3).setLength(n)),b=[],V=1e6;for(let se=0;se<A.length;se++){let $=A[se],W=[],J,H,K,fe=1e10,me=-1;for(;(me=e.indexOf(se,me+1))!=-1;){let ee=me-me%3;J=e[ee+(me+1)%3],H=e[ee+(me+2)%3],K=$.distanceToSquared(A[J]),fe=Math.min(fe,K),W.push([J,H,K])}fe+=1e-6;let ie=[],re=0,q=W.length;for(let ee=0;ee<q;ee++){[J,H,K]=W[re];let Te=((Ue=b[J])==null?void 0:Ue.includes(se))==!0;K<=fe&&ie.push(J+ +Te*V),re=W.findIndex(ce=>ce[0]==H)}b.push(ie)}let P=[];{let se=0,$=0,W,J,H=S==3;for(let K=0;K<=a;K++){W=K*(K+1)/2,J=(K+1)*(K+2)/2;for(let fe=0;fe<a-K;fe++)[se,$]=[W+fe+K+2,J+fe+K+3],P.push(W,J,...H?[$,W]:[se,J],$,se),[W,J]=[se,$];P.push(W,J,W+a+2)}}let R=w.clone(),E=w.clone(),G=w.clone(),ae=w.clone(),ne=w.clone(),xe=[],_e=te(A.length,()=>te(S,()=>w.clone()));for(let se=0;se<A.length;se++){w.copy(A[se]).normalize(),R.copy(w).multiplyScalar(M);let $=b[se];for(let ie=0;ie<$.length;ie++){let re=$[ie],q=$[(ie+1)%S];O.setFromPointsAndIndices(A,se,re%V,q%V),O.b.sub(O.a).setLength(1e10).add(O.a),O.c.sub(O.a).setLength(1e10).add(O.a),O.closestPointToPoint(R,_e[se][ie])}let W=[],J=[],H=[],K=new ci;a==0&&[..._e[se]].reduce((ie,re)=>ie.add(re),K).multiplyScalar(1/S);for(let ie=0;ie<S;ie++){let re=[],q=(ie-1+S)%S,ee=_e[se][q],Te=_e[se][ie];w.copy(ee).sub(R),B.copy(Te).sub(R);let ce=R.angleTo(w),le=w.angleTo(B),he=Math.cos(ce)*T;a==0?E.copy(K):E.copy(R).setLength(M+he),J.push(he);let pe=[E,ee,Te];for(let de=0;de<2;de++){let be=pe[de],Se=pe[de+1];ae.subVectors(be,R),ne.subVectors(Se,R),G.crossVectors(ae,ne).normalize();for(let Ie=0;Ie<F;Ie++){let ft=[ce,le][de]*Ie/F;w.copy(ae).applyAxisAngle(G,ft).add(R),W.push(w.clone()),de&&(N(w,R),re.push([Ie==0?be:w.clone(),k.clone()]))}de&&(N(Se,R),re.push([Se,k.clone()]))}H.push(re)}xe.push(H);let fe=2*F,me=2;for(let ie=0;ie<S;ie++){let re=fe*ie,q=fe*((ie+1)%S),ee=[W[re]];for(let ce=1;ce<F;ce++){ae=W[re+ce],ne=W[q+ce],ee.push(ae);for(let le=1,he=ce-me+1;le<=he;le++)w.lerpVectors(ae,ne,le/(he+1)),w.sub(R).setLength(J[ie]).add(R),ee.push(w.clone());ee.push(ne)}for(let ce=0;ce<F;ce++)ee.push(W[ce+F+re]);ee.push(W[q+F]);let Te=P.map(ce=>ee[ce]);c.push(...Te.map(ce=>[ce.x,ce.y,ce.z]).flat()),h.push(...Te.map(ce=>(N(ce,R),[k.x,k.y,k.z])).flat())}}let Le=[];for(let se=0;se<b.length;se++)for(let $=0;$<S;$++){let W=b[se][$];if(W<V){let J=b[W].findIndex(fe=>fe%V==se),H=xe[se][$],K=xe[W][J];for(let fe=0;fe<F;fe++){let me=H[fe],ie=K[F-fe],re=H[fe+1],q=K[F-(fe+1)];[me,ie,re,re,ie,q].forEach(ee=>{c.push(ee[0].x,ee[0].y,ee[0].z),h.push(ee[1].x,ee[1].y,ee[1].z)})}Le.push(H[0][0],K[F][0],H[F][0],K[0][0])}}for(;Le.length;){let se,$,W,J;[se,$]=Le.splice(0,2);let H=[se];for(;se!=$;)H.push($),W=Le.indexOf($),J=W%2,$=Le.splice(W-J,2)[1-J];k.subVectors(H[0],H[1]).cross(w.subVectors(H[0],H[2])).normalize();let K=k.dot(H[0])<0;K&&k.negate();for(let fe=1;fe<=H.length-2;fe++)[H[fe+ +K],H[fe+1-+K],H[0]].forEach(me=>{c.push(me.x,me.y,me.z),h.push(k.x,k.y,k.z)})}}function m(){let x=new ci;for(let A=0;A<c.length;A+=3){x.x=c[A+0],x.y=c[A+1],x.z=c[A+2];let b=N(x)/2/Math.PI+.5,V=te(x)/Math.PI+.5;f.push(b,1-V)}let S=new ci,w=new ci,B=new ci,O=new ci,T=new Oh,M=new Oh,F=new Oh,k=(A,b,V,P)=>{P<0&&A.x===1&&(f[b]=A.x-1),V.x===0&&V.z===0&&(f[b]=P/2/Math.PI+.5)};for(let A=0,b=0;A<c.length;A+=9,b+=6){S.set(c[A+0],c[A+1],c[A+2]),w.set(c[A+3],c[A+4],c[A+5]),B.set(c[A+6],c[A+7],c[A+8]),T.set(f[b+0],f[b+1]),M.set(f[b+2],f[b+3]),F.set(f[b+4],f[b+5]),O.copy(S).add(w).add(B).divideScalar(3);let V=N(O);k(T,b+0,S,V),k(M,b+2,w,V),k(F,b+4,B,V)}for(let A=0;A<f.length;A+=6){let b=f[A+0],V=f[A+2],P=f[A+4],R=Math.max(b,V,P),E=Math.min(b,V,P);R>.9&&E<.1&&(b<.2&&(f[A+0]+=1),V<.2&&(f[A+2]+=1),P<.2&&(f[A+4]+=1))}function N(A){return Math.atan2(A.z,-A.x)}function te(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new zi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronBufferGeometry as SA}from"three";var Jx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,c=n===0&&o!==0?new Ca(t*.5,o,a):new SA(t*.5,n);return c.scale(1,e/t,r/t),Object.assign(c,{userData:ue(j({},i),{type:"DodecahedronGeometry"})})}},Ca=class extends zi{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=1/n,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-o,-n,0,-o,n,0,o,-n,0,o,n,-o,-n,0,-o,n,0,o,-n,0,o,n,0,-n,0,-o,n,0,-o,-n,0,o,n,0,o],c=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],f="DodecahedronGeometry";super(a,c,f,t,e,r),this.type=f}static fromJSON(t){return new Ca(t.radius,t.corner,t.cornerSides)}};import{EventDispatcher as AA,Plane as DA,Shape as s0,Vector2 as ui,Vector3 as EA,MathUtils as Gh,LineCurve as Rh,QuadraticBezierCurve as a0,CubicBezierCurve as Zc}from"three";import{CubicBezierCurve as Yc,EllipseCurve as wA,LineCurve as Xc,LineCurve3 as CA,MathUtils as LA,QuadraticBezierCurve as Mh,SplineCurve as TA,Vector2 as Ln,Vector3 as Kx}from"three";var La=1e-12,gs=class{constructor(t){this.position=new Ln;this.startPosition=new Ln;this.uuid=LA.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new gs(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ys=class extends gs{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ys(this.parent).copy(this)}},Tn=class extends gs{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ys(this),new ys(this))}static create(e,r){let n=new Tn(e,new Ln(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,o=this.controls.length;n<o;n++){let a=this.controls[n];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Tn(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},Ph=i=>i,Na=new Ln,Ah=new Ln,NA=new Ln,_A=new Ln,IA=new Ln,OA=new Ln,Yx=new Kx,Xx=new Kx;function Zx(i){let t=new Ln;t.addVectors(i.v0,Na.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Ln;return e.addVectors(i.v2,Ah.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Yc(i.v0,t,e,i.v2)}function Ta(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function MA(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function PA(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Dh(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-o*o)/(2*n*r))}function Qx(i,t,e,r,n){let o=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,c=(i.x+t.x)/2,f=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(i.y-t.y)/o,h=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-i.x)/o;return r.set(c+f,a+h),n.set(c-f,a-h),[r,n]}function e0(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function t0(i,t,e,r,n,o){let a=t.x-i.x,c=t.y-i.y,f=e.x-i.x,h=e.y-i.y,d=Math.sqrt((a+f)*(a+f)+(c+h)*(c+h)),m;return Dh(t,i,e)>Math.PI&&(d*=-1),Ta(h,c)?m=(c+h)*(r/d-.5)*8/3/(a-f):m=(a+f)*(r/d-.5)*8/3/(h-c),n.set(t.x-m*c,t.y+m*a),o.set(e.x+m*h,e.y-m*f),[n,o]}function Eh(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function r0(i,t,e,r,n=.5){let o=Na.subVectors(t,i).multiplyScalar(n).add(i),a=Ah.subVectors(e,t).multiplyScalar(n).add(t),c=NA.subVectors(r,e).multiplyScalar(n).add(e),f=o,h=_A.subVectors(a,o).multiplyScalar(n).add(o),d=IA.subVectors(c,a).multiplyScalar(n).add(a),m=c,x=OA.subVectors(d,h).multiplyScalar(n).add(h);return[i.x,i.y,f.x,f.y,h.x,h.y,x.x,x.y,d.x,d.y,m.x,m.y,r.x,r.y]}function n0(i,t,e=12,r=!0){let n=Xx.set(0,0,0),o,a=0,c=[];for(let f=0;f<t.length;f++){let h=Ph(t[f]),d=Na,m=Fi(h,e);c.push(m);for(let x=0;x<=m;x++)if(h instanceof Yc||h instanceof Mh||h instanceof Xc){if(h.getPoint(x/m,d),n.set(d.x,d.y,0),o!==void 0&&PA(o,n))continue;o===void 0&&(o=Yx),o.copy(n),i.setXYZ(a,n.x,n.y,n.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function i0(i,t,e,r=12,n=!0){let o=Xx.set(0,0,0),a=0,c=[];for(let f=0;f<t.length;f++){if(e[f]===!1)continue;let h,d=Ph(t[f]),m=Na,x=Fi(d,r);c.push(x);for(let S=0;S<=x;S++)if(d instanceof Yc||d instanceof Mh||d instanceof Xc){if(d.getPoint(S/x,m),o.set(m.x,m.y,0),h!=null&&h.equals(o))continue;h===void 0?h=Yx:(i.setXYZ(a,h.x,h.y,h.z),a++,i.setXYZ(a,o.x,o.y,o.z),a++),h.copy(o)}}return n&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),c}function Bh(i,t=12,e=!1){let r=[];for(let n=0,o=i.length;n<o;n++){let a=i[n],c=0;if(e&&a.roundedCurveCorner!==void 0){let f=Fi(a.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=f),c+=f}a.curveAfter!==void 0&&(c+=Fi(a.curveAfter,t)),r.push(c)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Fi(i[0].roundedCurveCorner,t)*.5),r}function Fi(i,t=12){return i&&i instanceof wA?t*2:i&&(i instanceof Xc||i instanceof CA)?1:i&&i instanceof TA?t*i.points.length:t}function o0(i,t,e=12,r=!0){let n,o=0;for(let a=0;a<t.length;a++){let c=Ph(t[a]),f=Fi(c,e),h=Na;for(let d=0;d<=f;d++)if(c instanceof Yc||c instanceof Mh||c instanceof Xc){if(c.getPoint(d/f,h),n!==void 0&&MA(n,h,La))continue;n===void 0&&(n=Ah),n.copy(h),i.push(h.x,h.y),o++}}return Ta(i[0],i[i.length-2],La)&&Ta(i[1],i[i.length-1],La)&&(i.pop(),i.pop()),r&&o>1&&!(Ta(i[o-1],i[1],La)&&Ta(i[o-2],i[0],La))&&(i.push(i[0],i[1]),o++),i}var zh=new ui,BA=new ui,GA=new ui,RA=new ui,zA=new ui,FA=new ui,nt=class extends s0{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new AA;this.plane=new DA(new EA(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Gh.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let o=new nt;return o.isClosed=e.isClosed,o.points=e.points.map(a=>Tn.create(a.id,a.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(a=>nt.createFromState(a)),r!==void 0&&n!==void 0&&o.applySize(r,n),o.update(),o}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){return this.points.findIndex(r=>r.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let r=0,n=this.shapeHoles.length;r<n;r++){let o=this.shapeHoles[r],a=e-this.points.length;if(a<=o.points.length-1)return o.points[a]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,o=this.shapeHoles.length;n<o;n++){let a=this.shapeHoles[n],c=a.points.indexOf(e);if(c>=0)return r+c;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=zh.set(e,r);for(let o=0,a=this.points.length;o<a;o++){let c=this.points[o];c.position.multiply(n),c.controls[0].position.multiply(n),c.controls[1].position.multiply(n)}for(let o=0,a=this.shapeHoles.length;o<a;o++)this.shapeHoles[o].applyScale(e,r);this._update(!1)}createPoint(e,r=0,n=Gh.generateUUID()){let o;e instanceof ui?o=e:o=new ui(e,r);let a=new Tn(n,o);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let o=this.points[r];if(o.uuid===e)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(e=!0){for(let r=0,n=this.shapeHoles.length;r<n;r++)this.shapeHoles[r].update(!1);this._update(e)}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=n?this.roundedCurveDivisions:this.curveDivisions;return n0(e,n?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((a,c)=>a+c,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Bh(this.points,e,!1),this.roundedCurveDivisions=Bh(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return i0(e,this.curves,r,n,this.autoClose).reduce((a,c)=>a+c,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),o0(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=Fi(this.points[0].roundedCurveCorner,this.subdivision)*.5);let c=e-a;c<0&&(c+=o.reduce((f,h)=>f+h,0));for(let f=0,h=o.length;f<h;f++){let d=o[f];if(c<n+d)return[f,(c-n+1)/d];n+=d}return[0,1]}getCurveT(e,r,n){let o=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],c=this.curveDivisions,f=c[e];if(Eh(o,a)){let m=o.position.distanceTo(a.position);return o.position.distanceTo(zh.set(n.x,n.y))/m}let h=0;for(let m=0;m<e;m++)h+=c[m];return(r-h)/f}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,r){Eh(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let o=n.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var n;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,a=this.points.length;o<a;o++){let c=this.points[o];if(o===0)this.moveTo(c.position.x,c.position.y);else{let f=this.points[o-1];this._applyCurveForPoint(c,f)}}let r=this.getLastPoint();if(r!=null&&r.curveAfter&&(r.curveAfter=void 0),this.isClosed){let o=this.points[0],a=this.points[this.points.length-1];this._applyCurveForPoint(o,a)}if(this.points.length>2){let o=0;for(let a=0,c=this.points.length;a<c;a++){let f=this.points[a],h=f.roundness;if(!f.controlsMoved()&&h>0){let d=f.curveBefore,m=f.curveAfter;if(d===void 0||m===void 0)continue;let x=f.roundedCurveBefore,S=f.roundedCurveAfter,w=d.getLength(),B=m.getLength(),O=Math.min(h,w*.499),T=Math.min(h,B*.499),M=Math.min(O,T),F=1-M/w,k=M/B,N=d.getPointAt(F,zh),te=m.getPointAt(k,BA);this._subSplitCurve(d,x,F,N,void 0),this._subSplitCurve(m,S,k,void 0,te);let A;if(this.useCubicForRoundedCorners){let b=Dh(N,f.position,te)/2,V=Math.tan(b)*N.distanceTo(f.position),[P,R]=Qx(N,te,V,GA,RA),E=e0(P,R,f.position),[G,ae]=t0(E,N,te,V,zA,FA);A=new Zc(N.clone(),G.clone(),ae.clone(),te.clone())}else A=new a0(N.clone(),f.position.clone(),te.clone());f.roundedCurveCorner=A,this.roundedCurves.splice(a+o,0,A),o++}}}e&&((n=this.eventDispatcher)==null||n.dispatchEvent({type:"update"}))}_subSplitCurve(e,r,n,o,a){if(e instanceof Rh)o!==void 0&&r.v2.copy(o),a!==void 0&&r.v1.copy(a);else{let c=e,f=r,h=c.getUtoTmapping(n,0),d=r0(c.v0,c.v1,c.v2,c.v3,h);return o!==void 0&&(f.v0.set(d[0],d[1]),f.v1.set(d[2],d[3]),f.v2.set(d[4],d[5]),f.v3.set(d[6],d[7])),a!==void 0&&(f.v0.set(d[6],d[7]),f.v1.set(d[8],d[9]),f.v2.set(d[10],d[11]),f.v3.set(d[12],d[13])),f}return r}clone(){let e=new nt(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var n;this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let a=o*7,c=e.points[a+0],f=e.points[a+1],h=e.points[a+2],d=e.points[a+3],m=e.points[a+4],x=e.points[a+5],S=e.points[a+6],w=new Tn(Gh.generateUUID(),new ui(c,f));w.controls[0].position.set(h,d),w.controls[1].position.set(m,x),w.roundness=S,this.points.push(w)}return this.shapeHoles=(n=e.shapeHoles)!=null&&n.length?e.shapeHoles.map(o=>{let a=new nt;return a.fromJSON(o),a}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let r=(o,a)=>{a instanceof Zc&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},n=o=>{let a=[],c,f;for(c=0,f=o.length;c<f;c++)o[c]instanceof a0&&(o[c]=Zx(o[c]));for(c=0,f=o.length;c<f;c++){let m=o[c],x=c>0?o[c-1]:null,S;m instanceof Zc?(S=this.createPoint(m.v0),S.controls[1].position.copy(m.v1)):m instanceof Rh&&(S=this.createPoint(m.v1)),S!==void 0&&(x!==null&&r(S,x),a.push(S))}let h=o[o.length-1],d=!1;return h instanceof Zc?h.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(h.v2),d=!0):h instanceof Rh&&h.v2.equals(a[0].position)&&(d=!0),this.isClosed=d,a};return this.points=n(e.curves),e instanceof s0&&(this.shapeHoles=e.holes.map(o=>{let a=new nt;return a.fromShape(o),a})),this.update(),this}};var Vh=Math.PI*2;function Fh({x:i,y:t},e,r,n,o){return{x:i*e+n,y:t*r+o}}function VA(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),o=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:o+a*e,y:a-o*e},{x:o,y:a}]}function l0(i,t,e,r){let n=i*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(o)}function UA(i,t,e,r,n,o,a,c,f,h){let d=Math.pow(n,2),m=Math.pow(o,2),x=Math.pow(a,2),S=Math.pow(c,2),w=d*m-d*S-m*x;w<0&&(w=0),w/=d*S+m*x,w=Math.sqrt(w)*(f===h?-1:1);let B=w*n/o*c,O=w*-o/n*a,T=B+(i+e)/2,M=O+(t+r)/2,F=(a-B)/n,k=(c-O)/o,N=(-a-B)/n,te=(-c-O)/o,A=l0(1,0,F,k),b=l0(F,k,N,te);return!h&&b>0&&(b-=Vh),h&&b<0&&(b+=Vh),{centerx:T,centery:M,ang1:A,ang2:b}}function c0({px:i,py:t,cx:e,cy:r,rx:n,ry:o,largeArcFlag:a,sweepFlag:c}){let f=[];if(n===0||o===0)return[];let h=(i-e)/2,d=(t-r)/2;if(h===0&&d===0)return[];n=Math.abs(n),o=Math.abs(o);let m=Math.pow(h,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m));let x=UA(i,t,e,r,n,o,h,d,a,c),{ang1:S,ang2:w}=x,{centerx:B,centery:O}=x,T=Math.abs(w)/(Vh/4);Math.abs(1-T)<1e-7&&(T=1);let M=Math.max(Math.ceil(T),1);w/=M;for(let F=0;F<M;F++)f.push(VA(S,w)),S+=w;return f.map(F=>{let{x:k,y:N}=Fh(F[0],n,o,B,O),{x:te,y:A}=Fh(F[1],n,o,B,O),{x:b,y:V}=Fh(F[2],n,o,B,O);return{x1:k,y1:N,x2:te,y2:A,x:b,y:V}})}import{BufferAttribute as eu,BufferGeometry as qA}from"three";var Ot;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ot||(Ot={}));var Kt;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Kt||(Kt={}));function Ae(i,t){if(!i)throw t||"Assertion Failed!"}var Oe=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Ae(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?n<o?e.t-t.t+(t.t-r.t)*(n/(n+o)):e.t-r.t+(r.t-t.t)*(o/(n+o)):0},i.edgeSign=function(t,e,r){Ae(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?(e.t-r.t)*n+(e.t-t.t)*o:0},i.transEval=function(t,e,r){Ae(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?n<o?e.s-t.s+(t.s-r.s)*(n/(n+o)):e.s-r.s+(r.s-t.s)*(o/(n+o)):0},i.transSign=function(t,e,r){Ae(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?(e.s-r.s)*n+(e.s-t.s)*o:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,o){var a,c,f;i.vertLeq(t,e)||(f=t,t=e,e=f),i.vertLeq(r,n)||(f=r,r=n,n=f),i.vertLeq(t,r)||(f=t,t=r,r=f,f=e,e=n,n=f),i.vertLeq(r,e)?i.vertLeq(e,n)?(a=i.edgeEval(t,r,e),c=i.edgeEval(r,e,n),a+c<0&&(a=-a,c=-c),o.s=i.interpolate(a,r.s,c,e.s)):(a=i.edgeSign(t,r,e),c=-i.edgeSign(t,n,e),a+c<0&&(a=-a,c=-c),o.s=i.interpolate(a,r.s,c,n.s)):o.s=(r.s+e.s)/2,i.transLeq(t,e)||(f=t,t=e,e=f),i.transLeq(r,n)||(f=r,r=n,n=f),i.transLeq(t,r)||(f=t,t=r,r=f,f=e,e=n,n=f),i.transLeq(r,e)?i.transLeq(e,n)?(a=i.transEval(t,r,e),c=i.transEval(r,e,n),a+c<0&&(a=-a,c=-c),o.t=i.interpolate(a,r.t,c,e.t)):(a=i.transSign(t,r,e),c=-i.transSign(t,n,e),a+c<0&&(a=-a,c=-c),o.t=i.interpolate(a,r.t,c,n.t)):o.t=(r.t+e.t)/2},i}(),_a=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Qc=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),xs=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),u0=function(){function i(){var t=new xs,e=new _a,r=new Qc(0),n=new Qc(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new Qc(0),r=new Qc(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;Ae(n,"Vertex can't be null!");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e;var a=e;do a.Org=n,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;Ae(n,"Face can't be null");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var a=e;do a.Lface=n,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.makeEdge=function(){var t=new xs,e=new xs,r=new _a,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var o=new xs;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var a=new _a;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var n=new _a;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new xs;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),o=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(o,e),n.Org=t.Dst,o.Org=e.Org,n.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var a=new _a;this.makeFace_(a,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,o,a,c;n=e.Lnext;do r=n,n=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,c=t.next,c.prev=a,a.next=c},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,o,a,c,f;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;n=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(c=this.countFaceVerts_(e),f=this.countFaceVerts_(o.Lface),c+f-2<=t&&Oe.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&Oe.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(n=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===a);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,o,a,c,f,h;for(o=t,o=t;(n=o.next)!==t;o=n){Ae(n.prev===o),f=n.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Lface===n),f=f.Lnext;while(f!==n.anEdge)}for(Ae(n.prev===o&&n.anEdge===null),c=e,c=e;(a=c.next)!==e;c=a){Ae(a.prev===c),f=a.anEdge;do Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f),Ae(f.Org===a),f=f.Onext;while(f!==a.anEdge)}for(Ae(a.prev===c&&a.anEdge===null),h=r,h=r;(f=h.next)!==r;h=f)Ae(f.Sym.next===h.Sym),Ae(f.Sym!==f),Ae(f.Sym.Sym===f),Ae(f.Org!==null),Ae(f.Dst!==null),Ae(f.Lnext.Onext.Sym===f),Ae(f.Onext.Sym.Lnext===f);Ae(f.Sym.next===h.Sym&&f.Sym===this.eHeadSym&&f.Sym.Sym===f&&f.Org===null&&f.Dst===null&&f.Lface===null&&f.Rface===null)},i}(),f0=function(){function i(){this.handle=null}return i}(),h0=function(){function i(){this.key=null,this.node=0}return i}(),jA=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new f0,this.handles[r]=new h0;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Ae(a<=this.max),o=e[a].handle,a>this.size||this.leq(r[n].key,r[o].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t>>1,o=e[a].handle,a===0||this.leq(r[o].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,o;for(o=this.nodes.length,this.nodes.length=this.max+1,n=o;n<this.nodes.length;n++)this.nodes[n]=new f0;for(o=this.handles.length,this.handles.length=this.max+1,n=o;n<this.handles.length;n++)this.handles[n]=new h0}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;Ae(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),Uh=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),p0=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),kA=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new p0,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new p0;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),HA=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,o=e.eUp,a=r.eUp;if(o.Dst===n)return a.Dst===n?Oe.vertLeq(o.Org,a.Org)?Oe.edgeSign(a.Dst,o.Org,a.Org)<=0:Oe.edgeSign(o.Dst,a.Org,o.Org)>=0:Oe.edgeSign(a.Dst,n,a.Org)<=0;if(a.Dst===n)return Oe.edgeSign(o.Dst,n,o.Org)>=0;var c=Oe.edgeEval(o.Dst,n,o.Org),f=Oe.edgeEval(a.Dst,n,a.Org);return c>=f},i.deleteRegion=function(t,e){e.fixUpperEdge&&Ae(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Ae(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new Uh;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case Ot.ODD:return(e&1)!==0;case Ot.NONZERO:return e!==0;case Ot.POSITIVE:return e>0;case Ot.NEGATIVE:return e<0;case Ot.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,o=null,a=e,c=e.eUp;a!==r;){if(a.fixUpperEdge=!1,o=i.regionBelow(a),n=o.eUp,n.Org!=c.Org){if(!o.fixUpperEdge){i.finishRegion(t,a);break}n=t.mesh.connect(c.Lprev,n.Sym),i.fixUpperEdge(t,o,n)}c.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(c,n)),i.finishRegion(t,a),c=o.eUp,a=o}return c},i.addRightEdges=function(t,e,r,n,o,a){var c,f,h,d,m=!0;h=r;do Ae(Oe.vertLeq(h.Org,h.Dst)),i.addRegionBelow(t,e,h.Sym),h=h.Onext;while(h!==n);for(o===null&&(o=i.regionBelow(e).eUp.Rprev),f=e,d=o;c=i.regionBelow(f),h=c.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(d.Oprev,h)),c.windingNumber=f.windingNumber-h.winding,c.inside=i.isWindingInside(t,c.windingNumber),f.dirty=!0,!m&&i.checkForRightSplice(t,f)&&(i.addWinding(h,d),i.deleteRegion(t,f),t.mesh.delete(d)),m=!1,f=c,d=h;f.dirty=!0,Ae(f.windingNumber-h.winding===c.windingNumber),a&&i.walkDirtyRegions(t,f)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Oe.vertL1dist(e,t),o=Oe.vertL1dist(r,t),a=.5*o/(n+o),c=.5*n/(n+o);t.coords[0]+=a*e.coords[0]+c*r.coords[0],t.coords[1]+=a*e.coords[1]+c*r.coords[1],t.coords[2]+=a*e.coords[2]+c*r.coords[2]},i.getIntersectData=function(t,e,r,n,o,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,o,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp;if(Oe.vertLeq(n.Org,o.Org)){if(Oe.edgeSign(o.Dst,n.Org,o.Org)>0)return!1;Oe.vertEq(n.Org,o.Org)?n.Org!==o.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,o.Oprev,n)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(n,o.Oprev),e.dirty=r.dirty=!0)}else{if(Oe.edgeSign(n.Dst,o.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a;if(Ae(!Oe.vertEq(n.Dst,o.Dst)),Oe.vertLeq(n.Dst,o.Dst)){if(Oe.edgeSign(n.Dst,o.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Sym,a),a.Lface.inside=e.inside}else{if(Oe.edgeSign(o.Dst,n.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(n.Lnext,o.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a=n.Org,c=o.Org,f=n.Dst,h=o.Dst,d,m,x=new xs,S,w;if(Ae(!Oe.vertEq(h,f)),Ae(Oe.edgeSign(f,t.event,a)<=0),Ae(Oe.edgeSign(h,t.event,c)>=0),Ae(a!==t.event&&c!==t.event),Ae(!e.fixUpperEdge&&!r.fixUpperEdge),a===c||(d=Math.min(a.t,f.t),m=Math.max(c.t,h.t),d>m))return!1;if(Oe.vertLeq(a,c)){if(Oe.edgeSign(h,a,c)>0)return!1}else if(Oe.edgeSign(f,c,a)<0)return!1;return i.debugEvent(t),Oe.intersect(f,a,h,c,x),Ae(Math.min(a.t,f.t)<=x.t),Ae(x.t<=Math.max(c.t,h.t)),Ae(Math.min(h.s,f.s)<=x.s),Ae(x.s<=Math.max(c.s,a.s)),Oe.vertLeq(x,t.event)&&(x.s=t.event.s,x.t=t.event.t),S=Oe.vertLeq(a,c)?a:c,Oe.vertLeq(S,x)&&(x.s=S.s,x.t=S.t),Oe.vertEq(x,a)||Oe.vertEq(x,c)?(i.checkForRightSplice(t,e),!1):!Oe.vertEq(f,t.event)&&Oe.edgeSign(f,t.event,x)>=0||!Oe.vertEq(h,t.event)&&Oe.edgeSign(h,t.event,x)<=0?h===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):f===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Lnext,o.Oprev),r=e,e=i.topRightRegion(e),w=i.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,o.Onext,n.Rprev,w,!0),!0):(Oe.edgeSign(f,t.event,x)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Oe.edgeSign(h,t.event,x)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,n),n.Org.s=x.s,n.Org.t=x.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,a,f,c,h),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,o;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,o=r.eUp,n.Dst!==o.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(o),r=i.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==o.Org)if(n.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||o.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===o.Org&&n.Dst===o.Dst&&(i.addWinding(o,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,o=r.Onext,a=i.regionBelow(e),c=e.eUp,f=a.eUp,h=!1;if(c.Dst!==f.Dst&&i.checkForIntersect(t,e),Oe.vertEq(c.Org,t.event)&&(t.mesh.splice(o.Oprev,c),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),h=!0),Oe.vertEq(f.Org,t.event)&&(t.mesh.splice(r,f.Oprev),r=i.finishLeftRegions(t,a,null),h=!0),h){i.addRightEdges(t,e,r.Onext,o,o,!0);return}Oe.vertLeq(f.Org,c.Org)?n=f.Oprev:n=c,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,o,a,c,f;if(n=e.eUp,Oe.vertEq(n.Org,r)){Ae(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Oe.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}Ae(!1),e=i.topRightRegion(e),f=i.regionBelow(e),a=f.eUp.Sym,o=c=a.Onext,f.fixUpperEdge&&(Ae(o!==a),i.deleteRegion(t,f),t.mesh.delete(a),a=o.Oprev),t.mesh.splice(r.anEdge,a),Oe.edgeGoesLeft(o)||(o=null),i.addRightEdges(t,e,a.Onext,c,o,!0)},i.connectLeftVertex=function(t,e){var r,n,o,a,c,f,h=new Uh;if(h.eUp=e.anEdge.Sym,r=t.dict.search(h).key,n=i.regionBelow(r),!!n){if(a=r.eUp,c=n.eUp,Oe.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(o=Oe.vertLeq(c.Dst,a.Dst)?r:n,r.inside||o.fixUpperEdge){if(o===r)f=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(c.Dnext,e.anEdge);f=d.Sym}o.fixUpperEdge?i.fixUpperEdge(t,o,f):i.computeWinding(t,i.addRegionBelow(t,r,f)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);Ae(n!==null);var o=i.regionBelow(n),a=o.eUp,c=i.finishLeftRegions(t,o,null);c.Onext===a?i.connectRightVertex(t,n,c):i.addRightEdges(t,n,c.Onext,a,a,!0)},i.addSentinel=function(t,e,r,n){var o=new Uh,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=n,a.Dst.s=e,a.Dst.t=n,t.event=a.Dst,o.eUp=a,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},i.initEdgeDict=function(t){t.dict=new kA(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,o=t.bmax[0]+e,a=t.bmin[1]-r,c=t.bmax[1]+r;i.addSentinel(t,n,o,a),i.addSentinel(t,n,o,c)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ae(e.fixUpperEdge),Ae(++r===1)),Ae(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,n=e.Lnext,Oe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,o=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)o++;for(o+=8,e=t.pq=new jA(o,Oe.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,o;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,o=r.anEdge,Ae(o.Lnext!==o),o.Lnext.Lnext===o&&(i.addWinding(o.Onext,o),t.mesh.delete(o));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Oe.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),WA=function(){function i(){this.mesh=new u0,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Ot.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,o,a,c,f=[0,0,0],h=[0,0,0],d=[0,0,0],m=[0,0,0],x=[0,0,0],S=[null,null,null],w=[null,null,null],B=this.mesh.vHead;e=B.next;for(var O=0;O<3;++O)o=e.coords[O],h[O]=o,w[O]=e,f[O]=o,S[O]=e;for(e=B.next;e!==B;e=e.next)for(var T=0;T<3;++T)o=e.coords[T],o<h[T]&&(h[T]=o,w[T]=e),o>f[T]&&(f[T]=o,S[T]=e);var M=0;if(f[1]-h[1]>f[0]-h[0]&&(M=1),f[2]-h[2]>f[M]-h[M]&&(M=2),h[M]>=f[M]){t[0]=0,t[1]=0,t[2]=1;return}for(c=0,r=w[M],n=S[M],d[0]=r.coords[0]-n.coords[0],d[1]=r.coords[1]-n.coords[1],d[2]=r.coords[2]-n.coords[2],e=B.next;e!==B;e=e.next)m[0]=e.coords[0]-n.coords[0],m[1]=e.coords[1]-n.coords[1],m[2]=e.coords[2]-n.coords[2],x[0]=d[1]*m[2]-d[2]*m[1],x[1]=d[2]*m[0]-d[0]*m[2],x[2]=d[0]*m[1]-d[1]*m[0],a=x[0]*x[0]+x[1]*x[1]+x[2]*x[2],a>c&&(c=a,t[0]=x[0],t[1]=x[1],t[2]=x[2]);c<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,o=0,a=t.next;a!==t;a=a.next)if(n=a.anEdge,!(n.winding<=0))do o+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==a.anEdge);if(o<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,o=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),o=!0),r=this.sUnit,n=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,n[a]=0,n[(a+1)%3]=0,n[(a+2)%3]=e[a]>0?1:-1;for(var c=t.next;c!==t;c=c.next)c.s=this.dot_(c.coords,r),c.t=this.dot_(c.coords,n);o&&this.checkOrientation_();for(var f=!0,h=t.next;h!==t;h=h.next)f?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,f=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Oe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Oe.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var o=void 0;r.Lnext!==n;)if(Oe.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Oe.edgeGoesLeft(n.Lnext)||Oe.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)o=t.connect(n.Lnext,n),n=o.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Oe.edgeGoesRight(r.Lprev)||Oe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)o=t.connect(n.Lnext,n),n=o.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,o=t.eHead.next;o!==t.eHead;o=n)n=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var o,a=0,c=0,f;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){o=d.anEdge,f=0;do{var h=o.Org;h.n===-1&&(h.n=c,c++),f++,o=o.Lnext}while(o!==d.anEdge);if(f>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,e===Kt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=c,this.vertices=[],this.vertices.length=c*n,this.vertexIndices=[],this.vertexIndices.length=c;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var m=h.n*n;this.vertices[m+0]=h.coords[0],this.vertices[m+1]=h.coords[1],n>2&&(this.vertices[m+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var x=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(!!d.inside){o=d.anEdge,f=0;do{var h=o.Org;this.elements[x++]=h.n,f++,o=o.Lnext}while(o!==d.anEdge);for(var S=f;S<r;++S)this.elements[x++]=-1;if(e===Kt.CONNECTED_POLYGONS){o=d.anEdge;do this.elements[x++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==d.anEdge);for(var w=f;w<r;++w)this.elements[x++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,o=0,a=0;this.vertexCount=0,this.elementCount=0;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){n=r=c.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var f=0,h=0,d=0;o=0;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){a=0,n=r=c.anEdge;do this.vertices[f++]=r.Org.coords[0],this.vertices[f++]=r.Org.coords[1],e>2&&(this.vertices[f++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==n);this.elements[d++]=o,this.elements[d++]=a,o+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new u0),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,o,a){if(t===void 0&&(t=Ot.ODD),e===void 0&&(e=Kt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),HA.computeInterior(this,a);var c=this.mesh;return e===Kt.BOUNDARY_CONTOURS?this.setWindingNumber_(c,1,!0):this.tessellateInterior_(c),a&&c.check(),e===Kt.BOUNDARY_CONTOURS?this.outputContours_(c,n):this.outputPolymesh_(c,e,r,n),!0},i}();function mo(i){var t=i.windingRule,e=t===void 0?Ot.ODD:t,r=i.elementType,n=r===void 0?Kt.POLYGONS:r,o=i.polySize,a=o===void 0?3:o,c=i.vertexSize,f=c===void 0?2:c,h=i.normal,d=h===void 0?[0,0,1]:h,m=i.contours,x=m===void 0?[]:m,S=i.strict,w=S===void 0?!0:S,B=i.debug,O=B===void 0?!1:B;if(!x&&w)throw new Error("Contours can't be empty");if(!!x){var T=new WA;i.edgeCreateCallback&&(T.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(T.vertexIdCallback=i.vertexIdCallback);for(var M=0;M<x.length;M++)T.addContour(f||2,x[M]);return T.tesselate(e,n,a,f,d,w),{vertices:T.vertices,vertexIndices:T.vertexIndices,vertexCount:T.vertexCount,elements:T.elements,elementCount:T.elementCount,mesh:O?T.mesh:void 0}}}var ak=Ot.ODD,lk=Ot.NONZERO,ck=Ot.POSITIVE,uk=Ot.NEGATIVE,fk=Ot.ABS_GEQ_TWO,hk=Kt.POLYGONS,pk=Kt.CONNECTED_POLYGONS,dk=Kt.BOUNDARY_CONTOURS;var Vi=class extends qA{constructor(e,r=12,n=100,o={}){super();this.type="ShapeGeometry";this.windingRule=Ot.ODD;this.elementType=Kt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=r,this._maxCount=n,this._maxDrawCount=n*3,this._triangulationOptions=Object.assign({windingRule:Ot.ODD,elementType:Kt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o),this._positionAttribute=new eu(new Float32Array(n*3),3),this._normalAttribute=new eu(new Float32Array(n*3),3),this._uvAttribute=new eu(new Float32Array(n*2),2),this._indexAttribute=new eu(new Uint32Array(n*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),r=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),n,o=!0,a=!0,c,f;for(let h=0,d=e.length/2;h<d;h++){let m=h*2,x=e[m+0],S=e[m+1];if(c!==void 0&&x!==c&&(o=!1),f!==void 0&&S!==f&&(a=!1),c=x,f=S,!o&&!a)break}if(!o&&!a&&(n=mo({contours:[e,...r],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,n){let h=1/0,d=-1/0,m=1/0,x=-1/0;for(let B=0,O=n.vertexCount;B<O;B++){let T=B*2,M=n.vertices[T+0],F=n.vertices[T+1];M<h&&(h=M),M>d&&(d=M),F<m&&(m=F),F>x&&(x=F)}let S=d-h,w=x-m;for(let B=0,O=n.vertexCount;B<O;B++){let T=B*2,M=n.vertices[T+0],F=n.vertices[T+1],k=(M-h)/S,N=(F-m)/w;this._positionAttribute.setXYZ(B,M,F,0),this._normalAttribute.setXYZ(B,0,0,1),this._uvAttribute.setXY(B,k,N)}for(let B=0,O=n.elementCount;B<O;B++){let T=B*3,M=n.elements[T+0],F=n.elements[T+1],k=n.elements[T+2];this._indexAttribute.setX(T+0,M),this._indexAttribute.setX(T+1,F),this._indexAttribute.setX(T+2,k),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}clone(){let e=new Vi(this._shape,this._curveSegments,this._maxCount);return e.userData=ha(this.userData),e}};import{BufferAttribute as ru,BufferGeometry as $A}from"three";var tu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*tu.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,o=0;this.positions=new Float32Array(this.buffer,o*n,3*t),o+=3*t,this.normals=new Float32Array(this.buffer,o*n,3*t),o+=3*t,this.uvs=new Float32Array(this.buffer,o*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*tu.eSize,n=new ArrayBuffer(r),o=Float32Array.BYTES_PER_ELEMENT,a=0,c=new Float32Array(n,a*o,3*t);a+=3*t;let f=new Float32Array(n,a*o,3*t);a+=3*t;let h=new Float32Array(n,a*o,2*t);c.set(this.positions.slice(0,this.size*3)),f.set(this.normals.slice(0,this.size*3)),h.set(this.uvs.slice(0,this.size*2)),this.buffer=n,this.positions=c,this.normals=f,this.uvs=h,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Ia=tu;Ia.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var jh=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),vs=class extends $A{constructor(e,r,n=0,o=12,a=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._bevel=n,this._curveSegments=o,this._bevelSegmentsInput=a,n<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(n,r/2-1e-12),this._bevelSegments=Math.floor(a));let c=this._shape.extractShapePointsToFlatArray([],o),f=this._shape.shapeHoles.map(A=>{let b=A.extractShapePointsToFlatArray([],o),V=[];for(let P=b.length-1;P>=1;P-=2){let R=b[P-1],E=b[P-0];V.push(R,E)}return V}),h=mo({windingRule:Ot.ODD,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]}),d=mo({windingRule:Ot.ODD,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...f]});if(!h)throw new Error("error generating geometry");let m=h.elementCount;if(d){h.elementCount+=d.elementCount;for(let A=0;A<d.elements.length;A++){let b=d.elements[A],V=A%2===0?h.vertexCount:0;h.elements.push(b+V)}for(let A=0;A<d.vertexIndices.length;A++){let b=d.vertexIndices[A],V=h.vertexCount;h.vertexIndices.push(b+V)}for(let A=0;A<d.vertices.length;A++){let b=d.vertices[A];h.vertices.push(b)}}let x=1/0,S=-1/0,w=1/0,B=-1/0;for(let A=0,b=h.vertexCount;A<b;A++){let V=A*2,P=h.vertices[V+0],R=h.vertices[V+1];P<x&&(x=P),P>S&&(S=P),R<w&&(w=R),R>B&&(B=R)}this._minX=x,this._minY=w,this._width=S-x,this._height=B-w;let O=h.vertexCount*2*(2+this._bevelSegments);this._buffer=new Ia(O);let T=[],M=[];for(let A=h.elementCount-1;A>=0;A--){let b=A>=m,V=A*2,P=h.elements[V+0],R=h.elements[V+1],E=P+R,G={start:P,count:R,normals:[],continuous:[],concave:[]},ae=P,ne=E-1,xe=P+1,_e=this._shape.roundedCurves.length;do{let $=ae-P,W=h.vertices[ne*2+0],J=h.vertices[ne*2+1],H=h.vertices[ae*2+0],K=h.vertices[ae*2+1],fe=h.vertices[xe*2+0],me=h.vertices[xe*2+1],ie=H-W,re=K-J,q=Math.sqrt(ie*ie+re*re);ie/=q,re/=q;let ee=H-fe,Te=K-me,ce=Math.sqrt(ee*ee+Te*Te);ee/=ce,Te/=ce,G.normals[$*2+0]=-Te,G.normals[$*2+1]=ee,G.concave[$]=ie*Te-re*ee>0;let le=h.vertexIndices[ae];if(Array.isArray(le))G.continuous[$]=!1;else{let[he,pe]=this._shape.getCurveIndexFromVertexId(le-1,!0);if(pe>0&&pe<1)G.continuous[$]=!0;else{let de=pe===1?he+1:he-1;de=(de+_e)%_e;let be=pe===1?0:1,Se=this._shape.roundedCurves[he].getTangent(pe),Ie=this._shape.roundedCurves[de].getTangent(be);G.continuous[$]=Se.dot(Ie)>.95}}b&&(G.normals[$*2+0]*=-1,G.normals[$*2+1]*=-1),[ne,ae,xe]=[ae,xe,xe+1],xe>=E&&(xe-=R)}while(xe!==P+1);let Le=[];Le.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(P*2,E*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map(($,W)=>[W,W]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(P*2,E*2)});for(let $=1;$<=this._bevelSegments;$++){let W=$/this._bevelSegments*Math.PI/2,J=(1-Math.cos(W))*this._bevelSize,H=[],K=[],fe=[],me=[],ie=0;for(let q=0;q<R;q++){let ee=q*2,Te=(q-1+R)%R*2,ce=h.vertices[G.start*2+ee+0],le=h.vertices[G.start*2+ee+1],he=-G.normals[Te+0]*J,pe=-G.normals[Te+1]*J,de=-G.normals[ee+0]*J,be=-G.normals[ee+1]*J;if(G.concave[q]||!G.concave[q]&&b){let Se=Math.atan2(pe,he),Ie=Math.atan2(be,de);Ie>Se&&(Ie-=Math.PI*2);let ft=Ie-Se;if(G.continuous[q]||b){let Ve=Se+ft/2,Lt=Math.cos(Ve)*J,qe=Math.sin(Ve)*J;H[2*ie+0]=ce+Lt*(b?-1:1),H[2*ie+1]=le+qe*(b?-1:1),me[ie]=q,ie++}else{let Ve=Math.max(1,Math.floor(o/4*Math.abs(ft)/Math.PI));for(let Lt=0;Lt<=Ve;Lt++){let qe=Se+ft*(Lt/Ve),_t=Math.cos(qe)*J,Wt=Math.sin(qe)*J;H[2*ie+0]=ce+_t,H[2*ie+1]=le+Wt,me[ie]=q,ie++}}}else H[2*ie+0]=ce+he,H[2*ie+1]=le+pe,me[ie]=q,K[q]=ie,ie++,H[2*ie+0]=ce,H[2*ie+1]=le,me[ie]=q,ie++,H[2*ie+0]=ce+de,H[2*ie+1]=le+be,me[ie]=q,fe[q]=ie,ie++}let re=mo({windingRule:Ot.POSITIVE,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[H],edgeCreateCallback:q=>{let Te=q.Org.idx,ce=me[Te],le=me[(Te+1)%me.length];q.idx=[ce,le],q.Sym.idx=[le,ce]},vertexIdCallback:q=>{let ee=q.Lprev.idx;return[ee?ee[1]:0,q.idx[0]]}});if(!re)throw console.log("Error"),new Error(`error generating bevel geometry for ${$}'th loop`);if(!re.vertexCount)break;for(let q=0;q<re.vertexIndices.length;q++){let[ee,Te]=re.vertexIndices[q];if(ee===Te)continue;let ce=Te;Te<ee&&(ce+=R);for(let le=ee;le<ce;le++){let he=le%R,pe=(le+1)%R;if(!G.continuous[he]||!G.continuous[pe]){re.vertexIndices[q]=[ee,he],re.vertexIndices.splice(q+1,0,[pe,Te]),re.vertices.splice((q+1)*2,0,re.vertices[q*2],re.vertices[q*2+1]);break}}}Le.push({bevelI:$,angle:W,size:J,boundary:re,reverseMap:me,insetPoints:H})}let Ue=($,W,J)=>{let H=0,K=$.boundary.vertexIndices.length;for(;H<K&&J($.boundary.vertexIndices[W]);)W=(W+1)%K,H++;return H},se=T.length;for(let $=1;$<Le.length;$++){let W=Le[$-1],J=Le[$],H=W.boundary.vertexIndices.length,K=J.boundary.vertexIndices.length;if(!H||!K)break;let fe=G.concave.length,me=0,ie=jh(me,R);for(;!W.boundary.vertexIndices.filter(ie).length||!J.boundary.vertexIndices.filter(ie).length;)me++,ie=jh(me,R);let re=W.boundary.vertexIndices.findIndex(ie),q=J.boundary.vertexIndices.findIndex(ie);do re=(re+1)%H;while(ie(W.boundary.vertexIndices[re]));do q=(q+1)%K;while(ie(J.boundary.vertexIndices[q]));me=(me+1)%R;let ee=me,Te=this.buildBevelVert(G,W,(re-1+H)%H),ce=this.buildBevelVert(G,J,(q-1+K)%K),le=Te,he=ce,pe,de,be=!1;do{ie=jh(me,R);let Se=Ue(W,re,ie),Ie=Ue(J,q,ie),ft=be;if(be=!1,Se&&!Ie){for(let Ve=0;Ve<Se;Ve++)pe=this.buildBevelVert(G,W,(re+Ve)%H,Ve/(Se-1)),T.push(le.topN,pe.topP,he.topN),T.push(pe.bottomP,le.bottomN,he.bottomN),le=pe;be=!0}else if(!Se&&Ie)for(let Ve=0;Ve<Ie;Ve++)de=this.buildBevelVert(G,J,(q+Ve)%K,Ve/(Ie-1)),T.push(he.topN,le.topP,de.topP),T.push(le.bottomP,he.bottomN,de.bottomP),he=de;else if(Se&&Ie)if(pe=this.buildBevelVert(G,W,re,0),de=this.buildBevelVert(G,J,q,0),ft?(T.push(le.topN,de.topP,he.topN),T.push(le.topN,pe.topP,de.topP),T.push(de.bottomP,le.bottomN,he.bottomN),T.push(pe.bottomP,le.bottomN,de.bottomP)):(T.push(le.topN,pe.topP,he.topN),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,le.bottomN,he.bottomN),T.push(pe.bottomP,he.bottomN,de.bottomP)),le=pe,he=de,Se===Ie)for(let Ve=1;Ve<Se;Ve++)pe=this.buildBevelVert(G,W,(re+Ve)%H,Ve/(Se-1)),de=this.buildBevelVert(G,J,(q+Ve)%K,Ve/(Ie-1)),T.push(le.topN,pe.topP,he.topN),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,le.bottomN,he.bottomN),T.push(pe.bottomP,he.bottomN,de.bottomP),le=pe,he=de;else if(Se>Ie){let Ve=Se/Ie,Lt=0;for(let qe=1;qe<Se;qe++)pe=this.buildBevelVert(G,W,(re+qe)%H,qe/(Se-1)),T.push(le.topN,pe.topP,he.topN),T.push(pe.bottomP,le.bottomN,he.bottomN),le=pe,qe>(Lt+1)*Ve&&(Lt++,de=this.buildBevelVert(G,J,(q+Lt)%K,Lt/(Ie-1)),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,he.bottomN,de.bottomP),he=de)}else{let Ve=Ie/Se,Lt=0;for(let qe=1;qe<Ie;qe++)de=this.buildBevelVert(G,J,(q+qe)%K,qe/(Ie-1)),T.push(he.topN,pe.topP,de.topP),T.push(pe.bottomP,he.bottomN,de.bottomP),he=de,qe>(Lt+1)*Ve&&(Lt++,pe=this.buildBevelVert(G,W,(re+Lt)%H,Lt/(Se-1)),T.push(le.topN,pe.topP,he.topN),T.push(pe.bottomP,le.bottomN,he.bottomN),le=pe)}re=(re+Se)%H,q=(q+Ie)%K,me=(me+1)%fe}while(me!==ee)}{let $=Le[0];for(let W=0,J=$.boundary.vertexCount;W<J;W++){let H=this.buildBevelVert(G,$,W),K=this.buildBevelVert(G,$,(W+1)%J);T.push(K.topP,H.topN,H.bottomN),T.push(K.topP,H.bottomN,K.bottomP)}}if(b){let $=[];for(let W=T.length-1;W>=se+2;W-=3){let J=T[W-2],H=T[W-1],K=T[W-0];$.push(K,H,J)}T.splice(se,T.length-se,...$)}if(b){let $=[];for(let W=Le[Le.length-1].boundary.vertices.length-1;W>=1;W-=2){let J=Le[Le.length-1].boundary.vertices[W-1],H=Le[Le.length-1].boundary.vertices[W-0];$.push(J,H)}M.push($)}if(!b){let $=Le[Le.length-1],W=mo({windingRule:Le.length>1?Ot.POSITIVE:Ot.ODD,elementType:Kt.POLYGONS,vertexSize:2,strict:!0,contours:[$.insetPoints,...M]});if(!W)throw new Error("Error generating geometry for surface");for(let J=0;J<W.elementCount*3;J+=3){let H=this.buildSurfaceVert(W,W.elements[J+0]),K=this.buildSurfaceVert(W,W.elements[J+1]),fe=this.buildSurfaceVert(W,W.elements[J+2]);T.push(H.top,K.top,fe.top),T.push(fe.bottom,K.bottom,H.bottom)}}this.vertexCache={}}this._buffer.shrink();let F=new ru(Uint32Array.from(T),1),k=new ru(this._buffer.positions,3),N=new ru(this._buffer.normals,3),te=new ru(this._buffer.uvs,2);k.needsUpdate=!0,N.needsUpdate=!0,te.needsUpdate=!0,F.needsUpdate=!0,this.setAttribute("position",k),this.setAttribute("normal",N),this.setAttribute("uv",te),this.setIndex(F)}buildSurfaceVert(e,r){let n=r.toString();if(n in this.vertexCache)return this.vertexCache[n];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],c=(o-this._minX)/this._width,f=(a-this._minY)/this._height,h=this._buffer.get(2),d=h*3,m=h*2,x={top:h+0,bottom:h+1};return this._buffer.positions[d+0]=o,this._buffer.positions[d+1]=a,this._buffer.positions[d+2]=this._depth,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[m+0]=c,this._buffer.uvs[m+1]=f,this._buffer.positions[d+3]=o,this._buffer.positions[d+4]=a,this._buffer.positions[d+5]=0,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[m+2]=c,this._buffer.uvs[m+3]=f,this.vertexCache[n]=x,x}buildBevelVert(e,r,n,o=1){let a=`${r.bevelI}:${n}`;if(a in this.vertexCache)return this.vertexCache[a];let[c,f]=r.boundary.vertexIndices[n],h,d,m,x;c!==f?(d=c,h=f,x=!1,m=e.continuous[d]&&e.continuous[h]):(h=c,d=(h-1+e.count)%e.count,x=e.concave[h]&&r.bevelI>0,m=e.continuous[h]||x);let S=Math.cos(r.angle),w=Math.sin(r.angle),B=n*2,O=h*2,T=d*2,M=r.boundary.vertices[B+0],F=r.boundary.vertices[B+1],k=(1-w)*this._bevelSize,N=(M-this._minX)/this._width,te=(F-this._minY)/this._height,A=e.normals[O+0],b=e.normals[O+1],V=e.normals[T+0],P=e.normals[T+1];if(x){let ne=V-A,xe=P-b;A=A+ne*(1-o),b=b+xe*(1-o);let _e=Math.sqrt(A*A+b*b);A/=_e,b/=_e}let R=this._buffer.get(m?2:4),E=R*3,G=R*2,ae={i:n,fi:h,topP:R+0,topN:R+0,bottomP:R+1,bottomN:R+1};return this._buffer.positions[E+0]=M,this._buffer.positions[E+1]=F,this._buffer.positions[E+2]=this._depth-k,this._buffer.normals[E+0]=A*S,this._buffer.normals[E+1]=b*S,this._buffer.normals[E+2]=w,this._buffer.uvs[G+0]=N,this._buffer.uvs[G+1]=te,this._buffer.positions[E+3]=M,this._buffer.positions[E+4]=F,this._buffer.positions[E+5]=k,this._buffer.normals[E+3]=A*S,this._buffer.normals[E+4]=b*S,this._buffer.normals[E+5]=-w,this._buffer.uvs[G+2]=te,this._buffer.uvs[G+3]=N,m||(R+=2,E+=6,G+=4,ae.topP=R+0,ae.bottomP=R+1,this._buffer.positions[E+0]=M,this._buffer.positions[E+1]=F,this._buffer.positions[E+2]=this._depth-k,this._buffer.normals[E+0]=V*S,this._buffer.normals[E+1]=P*S,this._buffer.normals[E+2]=w,this._buffer.uvs[G+0]=N,this._buffer.uvs[G+1]=te,this._buffer.positions[E+3]=M,this._buffer.positions[E+4]=F,this._buffer.positions[E+5]=k,this._buffer.normals[E+3]=V*S,this._buffer.normals[E+4]=P*S,this._buffer.normals[E+5]=-w,this._buffer.uvs[G+2]=te,this._buffer.uvs[G+3]=N),this.vertexCache[a]=ae,ae}clone(){let e=new vs(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ha(this.userData),e}};var ar=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var h,d,m,x,S,w,B;let e=Object.assign({},(h=t==null?void 0:t.parameters)!=null?h:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs((d=e.height)!=null?d:e.width),o=Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(m=e.depth)!=null?m:0),a=(x=i.shape)!=null?x:t==null?void 0:t.shape,c=(S=a==null?void 0:a.roundness)!=null?S:e.roundness;a!==void 0&&(a instanceof nt?(a.width!==r||a.height!==n)&&a.applySize(r,n):a=new nt(r,n).fromJSON(a),((w=i.parameters)==null?void 0:w.roundness)!==void 0&&((B=i.parameters)==null?void 0:B.roundness)>0&&a.update(!1));let f=a!=null?a:new nt(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:o,extrudeDepth:o,roundness:c}),shape:f}}static build(i){let{extrudeDepth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:o,surfaceMaxCount:a}=i.parameters;i.shape.roundness=o;let c;return t<=0?c=new Vi(i.shape,n,a):c=new vs(i.shape,t,e,n,r),Object.assign(c,{userData:ue(j({},i),{type:"VectorGeometry"})})}};import{MathUtils as m0,Vector2 as g0}from"three";var y0=Math.PI*2,x0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(a=e.depth)!=null?a:0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:o,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d=i.shape,m=t*.5,x=e*.5,S=JA(d,m,x,n*Math.PI/180,r,o);d.isClosed=!0,d.update();let w=ar.create({shape:d,parameters:{subdivisions:S,surfaceMaxCount:h,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(w,{userData:ue(j({},i),{type:"EllipseGeometry"})})}};function JA(i,t,e,r,n,o){if(r>=y0)return n>30||n%4===0?(YA(i,t,e,o),Math.round(n/4)):d0(i,r,n,t,e,o);let a={x:0,y:e},c=r+Math.PI*.5,f={x:Math.cos(c)*t,y:Math.sin(c)*e},h=c0({px:a.x,py:a.y,cx:f.x,cy:f.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%h.length===0?KA(i,a.x,a.y,h,n,t,e,o):d0(i,r,n,t,e,o)}function KA(i,t,e,r,n,o,a,c){let f=Math.round(n/r.length);i.addPoint(bs(t,e));for(let h=0,d=r.length;h<d;h++){let m=r[h],x=i.points[h],S=bs(m.x,m.y);x.controls[1].position.set(m.x1,m.y1),S.controls[0].position.set(m.x2,m.y2),i.addPoint(S)}return c>0?v0(i,o,a,c):i.addPoint(bs(0,0)),f}function d0(i,t,e,r,n,o){let a=-t/e;for(let c=0;c<=e;c++){let f=a*c,h=Math.sin(f)*r,d=Math.cos(f)*n;i.addPoint(bs(h,d))}return t<y0?o>0?v0(i,r,n,o):i.addPoint(bs(0,0)):(i.removePoint(i.points[i.points.length-1]),o>0&&b0(i,r,n,o)),1}function YA(i,t,e,r=0,n=0,o=0){let a=.5522847498,c=t*a,f=e*a;i.addPoint(nu(n-t,o,n-t,o-f,n-t,o+f)),i.addPoint(nu(n,o+e,n-c,o+e,n+c,o+e)),i.addPoint(nu(n+t,o,n+t,o+f,n+t,o-f)),i.addPoint(nu(n,o-e,n+c,o-e,n-c,o-e)),r>0&&b0(i,t,e,r)}function bs(i,t){return new Tn(m0.generateUUID(),new g0(i,t))}function nu(i,t,e,r,n,o){let a=bs(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(n,o),a}function v0(i,t,e,r){S0(i,t,e,r).forEach(o=>i.addPoint(o))}function b0(i,t,e,r){let n=S0(i,t,e,r),o=new nt;n.forEach(a=>o.addPoint(a)),o.isClosed=!0,i.shapeHoles.push(o)}function S0(i,t,e,r){let n=r*t/100,o=n*(Math.abs(e)/Math.abs(t)),a=new g0(n/t,o/e),c=i.points.map(f=>{let h=f.clone();return h.uuid=m0.generateUUID(),h}).reverse();return c.forEach(f=>{f.position.multiply(a);let h=f.controls[0].position.clone().multiply(a),d=f.controls[1].position.clone().multiply(a);f.controls[0].position.copy(d),f.controls[1].position.copy(h)}),c}import{BufferGeometry as XA,Float32BufferAttribute as kh,Vector3 as w0}from"three";var C0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var c,f,h;let e=Object.assign({},(c=t==null?void 0:t.parameters)!=null?c:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=Math.abs((f=e.height)!=null?f:r),o=Math.abs((h=e.depth)!=null?h:r),a=Math.abs(Math.min(r,o))/2;return{parameters:Object.assign(e,{width:r,height:n,depth:o,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:o,segments:a,pathRadius:c,pathType:f,pathSegments:h,cornerRadius:d,cornerSegments:m}=i.parameters,x=new Oa(!1,t,e,r,n,o,a,c,f,h,d,m);return Object.assign(x,{userData:ue(j({},i),{type:"HelixGeometry"})})}},Oa=class extends XA{constructor(t=!0,e=1,r=1,n=1,o=1,a=1,c=1,f=1,h=1,d=1,m=1,x=1){super();let S=t&&a===1;S&&(x=0),m>100&&(m=100);let w=()=>new w0,B=new w0,O=w(),T=w(),M=w(),F,k,N,te,A,b,V,P,R=w(),E=w(),G=w(),ae=w(),ne=w(),xe=w(),_e=w(),Le=w(),Ue=r-2*f+.001,se=Ue/a,$=Math.ceil(c*a),W=$+1,J=Ue/$,H=-Ue/2,K=d+1,fe=2*Math.PI/d,me=Math.PI/2/x,ie=.01,re=Math.min((1-m/100)*f,f-ie),q=f-re,ee=0,Te=2,ce=x*Te+Te,le=K*ce/Te,he=le+K*W,pe=K*(W+ce),[de,be,Se]=[3,3,2].map(pt=>Array(pe*pt).fill(0)),Ie=[],ft=o-f;function Ve(pt,jt){let ir=Math.PI/2;b=jt*J,P=2*Math.PI*(b%se)/se+ir,b+=H,V=Math.sin(P)*ft,A=Math.cos(P)*ft,t?pt.set(A,V,b):pt.set(A,b,V)}Ve(B,-1e-10),Ve(O,0),R.copy(B),Ve(B,1);let Lt=B.distanceTo(O),qe=q+re,_t=Lt*$+2*qe,Wt=re,Rr=_t-qe;for(let pt=0;pt<=$;pt++){Ve(T,pt),Le.subVectors(T,R).normalize(),R.copy(T),xe.copy(T).setComponent(+t+1,0).normalize(),_e.crossVectors(Le,xe).normalize();let jt=pt===0,ir=pt===$,Lo=jt?3*Math.PI/2:me,To=jt?Wt:Rr,No=jt?K:he,Ki=jt?0:pe-K,Yi=Le.clone().multiplyScalar(jt?-q:q).add(T),_o=Le.clone().multiplyScalar(jt?-1:1).normalize();for(let Nr=0;Nr<K;Nr++){let Xi=Nr*fe;if(E.addVectors(B.copy(xe).multiplyScalar(f*Math.cos(Xi)),O.copy(_e).multiplyScalar(f*Math.sin(Xi))),G.copy(E).normalize(),jt||ir){S||(ee=Ki+Nr,[0,1,2].forEach(qt=>{de[ee*3+qt]=Yi.getComponent(qt),be[ee*3+qt]=_o.getComponent(qt)}),Se[ee*2]=+ir,Se[ee*2+1]=Nr/d),O.copy(G).multiplyScalar(re),M.addVectors(T,O);for(let qt=0;qt<x;qt++){let Kn=qt*me+Lo;ae.addVectors(B.copy(Le).multiplyScalar(q*Math.sin(Kn)),O.copy(G).multiplyScalar(q*Math.cos(Kn))),ne.copy(ae).normalize(),O.addVectors(M,ae),ae.normalize(),ee=No+qt*K+Nr,[0,1,2].forEach(Re=>{de[ee*3+Re]=O.getComponent(Re),be[ee*3+Re]=ne.getComponent(Re)});let Io=+jt+Math.sin(Kn);Se[ee*2]=(To+q*Io)/_t,Se[ee*2+1]=Nr/d}}O.addVectors(T,E),ee=le+pt*K+Nr,[0,1,2].forEach(qt=>{de[ee*3+qt]=O.getComponent(qt),be[ee*3+qt]=G.getComponent(qt)}),Se[ee*2]=(qe+pt*Lt)/_t,Se[ee*2+1]=Nr/d}}let Ut=W+2*x+Te,zr=1,[mn,gn]=S?[zr,zr+W-1]:[0,Ut-1];for(let pt=mn;pt<=gn-1;pt++){let jt=S&&pt===gn-1;for(let ir=0;ir<K-1;ir++)F=pt*K+ir,k=F+1,N=(jt?ir:F)+K,te=(jt?ir+1:k)+K,pt===0?Ie.push(k,te,N):pt===Ut-2?Ie.push(F,k,N):Ie.push(F,k,N,k,te,N)}this.setIndex(Ie),this.setAttribute("position",new kh(de,3)),this.setAttribute("normal",new kh(be,3)),this.setAttribute("uv",new kh(Se,2))}};import{IcosahedronBufferGeometry as ZA}from"three";var L0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,c=n===0&&o!==0?new Ma(t*.5,o,a):new ZA(t*.5,n);return c.scale(1,e/t,r/t),Object.assign(c,{userData:ue(j({},i),{type:"IcosahedronGeometry"})})}},Ma=class extends zi{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],c="IcosahedronGeometry";super(o,a,c,t,e,r),this.type=c}static fromJSON(t){return new Ma(t.radius,t.corner,t.cornerSides)}};import{LatheBufferGeometry as QA,Shape as e2}from"three";var T0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o,a,c;((n=(r=i.parameters)==null?void 0:r.points)!=null?n:[]).forEach(f=>{Array.isArray(f)&&(f.x=f[0],f.y=f[1])});let e=Object.assign({},(o=t==null?void 0:t.parameters)!=null?o:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs((c=e.depth)!=null?c:e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new e2;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new QA(n.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:ue(j({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as _0,BufferGeometryLoader as a2,Vector3 as l2,BoxBufferGeometry as I0}from"three";import{BufferGeometry as t2,Vector2 as Hh,Vector3 as N0}from"three";import{Geometry as r2,Face3 as n2}from"three/examples/jsm/deprecated/Geometry.js";var i2=["a","b","c"];function o2(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Wh(i,t,e){let r=Math.min(i,t),n=Math.max(i,t),o=r+"_"+n;return e.get(o)}function qh(i,t,e,r,n,o){let a=Math.min(i,t),c=Math.max(i,t),f=a+"_"+c,h;if(r.has(f))h=r.get(f);else{let d=e[a],m=e[c];h={a:d,b:m,newEdge:null,faces:[]},r.set(f,h)}h.faces.push(n),o[i].edges.push(h),o[t].edges.push(h)}function s2(i,t,e,r){let n,o,a;for(n=0,o=i.length;n<o;n++)e[n]={edges:[]};for(n=0,o=t.length;n<o;n++)a=t[n],qh(a.a,a.b,i,r,a,e),qh(a.b,a.c,i,r,a,e),qh(a.c,a.a,i,r,a,e)}function iu(i,t,e,r,n){i.push(new n2(t,e,r,void 0,void 0,n))}function Ss(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function ou(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var su=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof t2?t=new r2().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new N0,r,n,o,a,c,f=t.vertices,h=t.faces,d=t.faceVertexUvs[0],m=d!==void 0&&d.length>0,x=[],S=new Map;s2(f,h,x,S);let w=[],B,O,T,M,F,k,N;for(let ie of Array.from(S.keys())){for(O=S.get(ie),T=new N0,F=3/8,k=1/8,N=O.faces.length,N!=2&&(F=.5,k=0,N!=1),T.addVectors(O.a,O.b).multiplyScalar(F),e.set(0,0,0),a=0;a<N;a++){for(M=O.faces[a],c=0;c<3&&(B=f[o2(M,i2[c])],!(B!==O.a&&B!==O.b));c++);B&&e.add(B)}e.multiplyScalar(k),T.add(e),O.newEdge=w.length,w.push(T)}let te,A,b,V,P,R,E,G=[];for(n=0,o=f.length;n<o;n++){for(R=f[n],P=x[n].edges,r=P.length,r==3?te=3/16:r>3&&(te=3/(8*r)),A=1-r*Number(te),b=te,r<=2&&(r==2?(A=3/4,b=1/8):r==1||r==0),E=R.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<r;a++)V=P[a],B=V.a!==R?V.a:V.b,e.add(B);e.multiplyScalar(Number(b)),E.add(e),G.push(E)}let ae=G.concat(w),ne=G.length,xe,_e,Le,Ue=[],se=[],$,W,J,H,K=new Hh,fe=new Hh,me=new Hh;for(n=0,o=h.length;n<o;n++)M=h[n],xe=Number(Wh(M.a,M.b,S).newEdge)+ne,_e=Number(Wh(M.b,M.c,S).newEdge)+ne,Le=Number(Wh(M.c,M.a,S).newEdge)+ne,iu(Ue,xe,_e,Le,M.materialIndex),iu(Ue,M.a,xe,Le,M.materialIndex),iu(Ue,M.b,_e,xe,M.materialIndex),iu(Ue,M.c,Le,_e,M.materialIndex),m&&($=d[n],W=$[0],J=$[1],H=$[2],K.set(Ss(W.x,J.x),Ss(W.y,J.y)),fe.set(Ss(J.x,H.x),Ss(J.y,H.y)),me.set(Ss(W.x,H.x),Ss(W.y,H.y)),ou(se,K,fe,me),ou(se,W,K,me),ou(se,J,fe,K),ou(se,H,me,fe));t.vertices=ae,t.faces=Ue,m&&(t.faceVertexUvs[0]=se)}};var Yt=new l2,O0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var o,a;let e=(a=(o=i.geometry)!=null?o:t==null?void 0:t.geometry)!=null?a:new _0().copy(new I0(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Yt),r={width:Yt.x,height:Yt.y,depth:Yt.z,subdivisions:0}):r=t.parameters;let n=j(j({},r),i.parameters);return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){var f;let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,o=(f=i.geometry)!=null?f:new _0().copy(new I0(100,100,100)),a=o.userData.parameters;a===void 0?(o.computeBoundingBox(),o.boundingBox.getSize(Yt)):Yt.set(a.width,a.height,a.depth),(t!==Yt.x||e!==Yt.y||r!==Yt.z)&&o.scale(Yt.x===0?1:t/Yt.x,Yt.y===0?1:e/Yt.y,Yt.z===0?1:r/Yt.z);let c=o.originalGeometry;return n>0?(c===void 0||(a==null?void 0:a.subdivisions)!==n)&&(c===void 0&&(c=o),o=new su(n).modify(c).toBufferGeometry()):(c!==void 0&&(o=c),c=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()),c!==void 0&&Object.assign(o,{originalGeometry:c}),delete i.geometry,Object.assign(o,{userData:ue(j({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,t,e){new a2(e).load(i,n=>{let o=this.normalizeInputs({geometry:n});n.boundingBox.getSize(Yt);let a=100/Yt.x;Object.assign(o.parameters,{width:100,height:Yt.y*a,depth:Yt.z*a}),t(this.build(o))})}};var M0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a,c;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(c=e.depth)!=null?c:0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=t*.5,m=e*.5,x=0,S=0,w=2*Math.PI/r;for(let O=0;O<r;O++){let T=w*O,M=x+Math.sin(T)*d,F=S+Math.cos(T)*m;h.addPoint(h.createPoint(M,F))}h.isClosed=!0;for(let O=0,T=h.points.length;O<T;O++)h.points[O].roundness=n;h.roundness=n,h.update();let B=ar.create({shape:h,parameters:{surfaceMaxCount:f,roundness:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(B,{userData:ue(j({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as c2,Float32BufferAttribute as $h,Vector2 as jn,Vector3 as tr}from"three";var P0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:o,openEnded:a,cornerRadius:c,cornerSegments:f}=i.parameters,h=new Kh(t*.5,e,n,o,a,c,f);return h.scale(1,1,r/t),Object.assign(h,{userData:ue(j({},i),{type:"PyramidGeometry"})})}};function Pa(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Jh(i,t,e,r,n,o){let a=t.clone().sub(i),c=e.clone().sub(i),f=a.angleTo(c);if(a.normalize(),c.normalize(),r===n){let h=a.add(c).normalize();o.copy(i).addScaledVector(h,r/Math.sin(f/2))}else{let h=a.angleTo(c);o.copy(i),o.addScaledVector(a,n/Math.sin(h)),o.addScaledVector(c,r/Math.sin(h))}}function u2(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var Kh=class extends c2{constructor(t=.5,e=1,r=4,n=1,o=!1,a=0,c=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),c=Math.floor(c);let f=[],h=[],d=[],m=[],x=0,S=e/2,w=Math.PI/r,B=t*Math.cos(Math.PI/r),O=2*Math.PI/r,T=(r-2)*Math.PI/r,M=Math.PI-T,F=new tr(0,-S,0),k=new tr(0,S,0),N=new jn(t,-S),te=new jn(B,-S),A=new jn(0,k.y).sub(te),b=new jn(0,k.y).sub(N),V=new jn(A.y,-A.x).normalize(),P=new jn(b.y,-b.x).normalize(),E=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,E);let G;{let se=new tr(V.x,V.y,0),$=new tr(Math.cos(O)*se.x,se.y,Math.sin(O)*se.x);G=se.angleTo($)}let ae=a/Math.tan((Math.PI-A.angle())/2),ne=a/Math.tan((Math.PI-G)/2),xe=new tr;if(!o){h.push(F.x,F.y,F.z),d.push(0,-1,0),m.push(0,0);let se=x++,$=[],W=N.clone(),J=ae/Math.cos(Math.PI/r);W.x-=J;for(let H=0;H<r;H++){let K=H/r*Math.PI*2+w,fe=new jn(Math.sin(K),Math.cos(K));Pa(W,fe,xe),h.push(xe.x,xe.y,xe.z),d.push(0,-1,0),m.push(0,0),$.push(x++)}for(let H=0;H<$.length;H++)f.push($[H],se,$[(H+1)%$.length])}let _e=[];{let se=new tr,$=new tr,W=new tr,J=new tr,H=new tr,K=new tr;for(let fe=0;fe<r;fe++){let me=fe/r*Math.PI*2+w,ie=(fe+.5)/r*Math.PI*2+w,re=(fe+1)/r*Math.PI*2+w,q=new jn(Math.sin(me),Math.cos(me)),ee=new jn(Math.sin(ie),Math.cos(ie)),Te=new jn(Math.sin(re),Math.cos(re));Pa(N,q,$),Pa(N,Te,W),Pa(V,ee,se),Jh(k,$,W,ne,ne,J),h.push(J.x,J.y,J.z),Jh($,k,W,ne,ae,H),h.push(H.x,H.y,H.z),Jh(W,$,k,ae,ne,K),h.push(K.x,K.y,K.z),d.push(se.x,se.y,se.z),d.push(se.x,se.y,se.z),d.push(se.x,se.y,se.z),m.push(0,0),m.push(0,0),m.push(0,0);let ce=x++,le=x++,he=x++;if(f.push(ce,le,he),a>0){{let be=$.clone().add(W).multiplyScalar(.5),Se=k.clone().sub(be).normalize(),ft=F.clone().sub(be).normalize().add(Se).normalize().multiplyScalar(-1),Ve=K.clone().sub(H);Le(be,Ve,ft,A.angle())}let pe,de;{let be=new tr;Pa(P,Te,be);let Se=K.clone().add(J).multiplyScalar(.5);Se=u2(Se,W,k);let Ie=K.clone().sub(J);[pe,de]=Le(Se,Ie,be,G,J.y)}{let be=pe,Se=be.clone().setY(0).normalize(),Ie=new tr(0,-1,0),ft=Se.clone().cross(Ie);Ue(be,Se,Ie,ft)}_e.concat(de);{let be=A.angle(),Se=Math.PI-be,Ie=k.clone();Ie.y-=a/Math.sin(be-Math.PI/2);let ft=new tr,Ve=[];for(let qe=0;qe<c;qe++){let _t=[],Wt=Math.PI/2-Se*qe/c,Rr=Math.cos(Wt),Ut=Math.sin(Wt),zr=ie;for(let mn=0;mn<=qe;mn++){let gn=Math.cos(zr),pt=Math.sin(zr);se.x=Rr*pt,se.y=Ut,se.z=Rr*gn,ft.copy(Ie).addScaledVector(se,a),h.push(ft.x,ft.y,ft.z),d.push(se.x,se.y,se.z),m.push(0,0),_t.push(x++),zr+=Math.PI*2/qe/r}Ve.push(_t)}de.reverse(),Ve.push(de);let Lt=Ve.length-1;for(let qe=0;qe<Lt;qe++){let _t=Ve[qe],Wt=Ve[qe+1],Rr=_t.length-1;f.push(Wt[1],_t[0],Wt[0]);for(let Ut=1;Ut<=Rr;Ut++)f.push(_t[Ut],_t[Ut-1],Wt[Ut]),f.push(Wt[Ut+1],_t[Ut],Wt[Ut])}}}}}this.setIndex(f),this.setAttribute("position",new $h(h,3)),this.setAttribute("normal",new $h(d,3)),this.setAttribute("uv",new $h(m,2));function Le(se,$,W,J,H){let K=-J/2,fe=(Math.PI-J)/2,me=$.clone().normalize().cross(W);se.addScaledVector(W,-a/Math.sin(fe));let ie=new tr,re=new tr,q=1,ee=x,Te=[];for(let ce=0;ce<=c;ce++){let le=K+ce/c*J;re.set(0,0,0),re.addScaledVector(me,Math.sin(le)),re.addScaledVector(W,Math.cos(le));for(let he=0;he<=q;he++){let pe=he/q-.5;if(ie.copy(se),ie.addScaledVector($,pe),ie.addScaledVector(re,a),H!=null){let de=Math.max(0,ie.y-H);ie.addScaledVector($,-de/$.y)}h.push(ie.x,ie.y,ie.z),d.push(re.x,re.y,re.z),m.push(0,0),he===0&&Te.push(x),x++}}for(let ce=0;ce<c;ce++)for(let le=0;le<q;le++){let he=ee+le+(q+1)*ce,pe=he+(q+1),de=pe+1,be=he+1;f.push(he,pe,be),f.push(pe,de,be)}return[se.clone().addScaledVector($,.5),Te]}function Ue(se,$,W,J){let H=Math.PI/2,K=b.angle()-H,fe=[],me=new tr,ie=new tr;for(let q=0;q<=c;q++){let ee=[],Te=q/c;for(let ce=0;ce<=q;ce++){let he=((q?ce/q:0)-.5)*M,pe=Math.cos(he),de=Math.sin(he),be=Math.atan(Math.tan(K)*pe),Se=(H+be)*Te,Ie=Math.cos(Se),ft=Math.sin(Se);me.set(0,0,0),me.addScaledVector($,ft*pe),me.addScaledVector(W,Ie),me.addScaledVector(J,ft*de),ie.copy(se).addScaledVector(me,a),h.push(ie.x,ie.y,ie.z),d.push(me.x,me.y,me.z),m.push(0,0),ee.push(x++)}fe.push(ee)}let re=fe.length-1;for(let q=0;q<re;q++){let ee=fe[q],Te=fe[q+1],ce=ee.length-1;f.push(ee[0],Te[1],Te[0]);for(let le=1;le<=ce;le++)f.push(ee[le-1],ee[le],Te[le]),f.push(ee[le],Te[le+1],Te[le])}}}};var au=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var a,c,f,h,d;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((c=t==null?void 0:t.ui)!=null?c:{enabledIndieCorners:!1},i.ui),n=e.cornerRadius.reduce((m,x)=>m+x,0);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((f=e.surfaceMaxCount)!=null?f:n>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((h=e.height)!=null?h:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(d=e.depth)!=null?d:0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:o,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f,surfaceMaxCount:h}=i.parameters,d={x:e*.5,y:r*.5},m={x:-d.x,y:-d.y},x={x:d.x,y:d.y};function S(N,te,A){return te>e&&A>r?Math.min(N*e/te,N*r/A):te>e?N*e/te:A>r?N*r/A:N}let w=[];w[0]=n[0]===0?0:S(n[0],n[0]+n[3],n[0]+n[1]),w[1]=n[1]===0?0:S(n[1],n[1]+n[2],n[1]+n[0]),w[2]=n[2]===0?0:S(n[2],n[2]+n[1],n[2]+n[3]),w[3]=n[3]===0?0:S(n[3],n[3]+n[0],n[3]+n[2]);let B=m.x,O=x.x,T=x.y,M=m.y;t.addPoint(t.createPoint(B,T)),t.addPoint(t.createPoint(O,T)),t.addPoint(t.createPoint(O,M)),t.addPoint(t.createPoint(B,M)),t.isClosed=!0;let F=!0;for(let N=0,te=t.points.length;N<te;N++)t.points[N].roundness=w[N],N>0&&w[N]!==w[N-1]&&(F=!1);F&&(t.roundness=w[0]),t.useCubicForRoundedCorners=o!==1,t.update();let k=ar.create({shape:t,parameters:{surfaceMaxCount:h,depth:a,extrudeBevelSize:c,extrudeBevelSegments:f}});return Object.assign(k,{userData:ue(j({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as f2}from"three";var A0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:o=64,phiStart:a,phiLength:c,thetaStart:f,thetaLength:h}=i.parameters,d=new f2(.5*t,n,o,a,c,f,h);return d.scale(1,e/t,r/t),Object.assign(d,{userData:ue(j({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as h2}from"three";var D0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,o=new h2(t,e,r,n);return o.scale(1,1,1),Object.assign(o,{userData:ue(j({},i),{type:"PlaneGeometry"})})}};var E0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a,c;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(c=e.depth)!=null?c:0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:o,angle:a,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h,surfaceMaxCount:d}=i.parameters,m=i.shape,x=t*.5,S=e*.5,w=0,B=0,O=a*Math.PI/360/n,T=Math.PI/2*3*-1,M=x*r/100,F=S*r/100;if(n==3&&r==50){O=2*Math.PI/n;for(let N=0;N<n;N++){let te=O*N,A=w+Math.sin(te)*x,b=B+Math.cos(te)*S;m.addPoint(m.createPoint(A,b))}}else for(let N=0;N<n;N++){let te=w+Math.cos(T)*x,A=B+Math.sin(T)*S;m.addPoint(m.createPoint(te,A)),T+=O,te=w+Math.cos(T)*M,A=B+Math.sin(T)*F,N<=n,m.addPoint(m.createPoint(te,A)),T+=O}m.isClosed=!0;for(let N=0,te=m.points.length;N<te;N++)m.points[N].roundness=o;m.roundness=o,m.update();let k=ar.create({shape:m,parameters:{surfaceMaxCount:d,roundness:o,depth:c,extrudeBevelSize:f,extrudeBevelSegments:h}});return Object.assign(k,{userData:ue(j({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as p2}from"three";var lu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new p2(t,e);return Object.assign(r,{userData:ue(j({},i),{type:"TextFrameGeometry"})})}};var B0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var a,c,f;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs((c=e.height)!=null?c:e.width),o=Math.abs((f=e.depth)!=null?f:e.width*.25);return{parameters:Object.assign(e,{width:r,height:n,depth:o})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:o,arc:a,cornerRadius:c,cornerSegments:f}=i.parameters,h=d2(t,e,r,t*.5,a,o,0,0,n,c,f);return h.scale(1,e/t,1),Object.assign(h,{userData:ue(j({},i),{type:"TorusGeometry"})})}};function d2(i,t,e,r,n,o,a,c,f,h,d){return[t,e]=[e,t],a=t/2,n/=2*Math.PI,n==1&&(h=0),new Oa(!0,i,t,e,r,n,o,a,c,f,h,d)}import{TorusKnotBufferGeometry as m2}from"three";var G0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var r,n,o,a;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((n=e.height)!=null?n:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width),tube:(a=e.tube)!=null?a:e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:o,q:a}=i.parameters,c=t*.5;c!==e&&(c-=e);let f=new m2(c,e,r,n,o,a);return Object.assign(f,{userData:ue(j({},i),{type:"TorusKnotGeometry"})})}};var R0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){var n,o,a,c;let e=Object.assign({},(n=t==null?void 0:t.parameters)!=null?n:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof nt?i.shape:new nt,parameters:Object.assign(e,{surfaceMaxCount:((o=e.surfaceMaxCount)!=null?o:e.cornerRadius>0)?1e3:100,width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(c=e.depth)!=null?c:0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a,isRect:c,surfaceMaxCount:f}=i.parameters,h=i.shape,d=t*.5,m=e*.5;c?(h.addPoint(h.createPoint(-d,m)),h.addPoint(h.createPoint(d,-m)),h.addPoint(h.createPoint(-d,-m))):(h.addPoint(h.createPoint(0,m)),h.addPoint(h.createPoint(d,-m)),h.addPoint(h.createPoint(-d,-m))),h.isClosed=!0;for(let S=0,w=h.points.length;S<w;S++)h.points[S].roundness=r;h.roundness=r,h.update();let x=ar.create({shape:h,parameters:{surfaceMaxCount:f,roundness:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(x,{userData:ue(j({},i),{type:"TriangleGeometry"})})}};var Aa={};CN(Aa,{addBarycentricAttribute:()=>b2,fixUvs:()=>w2,loadFromUrl:()=>S2,resizeGeometry:()=>v2,roundShapePolygon:()=>x2});import{BufferGeometryLoader as g2,Float32BufferAttribute as y2,Vector3 as Yh}from"three";var z0=function(i,t){let e=t.x-i.x,r=t.y-i.y,n=Math.sqrt(e*e+r*r),o=e/n,a=r/n,c=Math.atan2(a,o);return{x:e,y:r,len:n,nx:o,ny:a,ang:c}},x2=(i,t,e)=>{let r,n,o,a,c,f,h,d,m,x,S,w,B,O,T=t.length;for(a=t[T-2],i.curves=[],r=1;r<T-1;r++){c=t[r%T],f=t[(r+1)%T];let M=z0(c,a),F=z0(c,f);h=M.nx*F.ny-M.ny*F.nx,d=M.nx*F.nx-M.ny*-F.ny,S=Math.asin(h),m=1,x=!1,d<0?S<0?S=Math.PI+S:(S=Math.PI-S,m=-1,x=!0):S>0&&(m=-1,x=!0),w=S/2,O=Math.abs(Math.cos(w)*e/Math.sin(w)),O>Math.min(M.len/2,F.len/2)?(O=Math.min(M.len/2,F.len/2),B=Math.abs(O*Math.sin(w)/Math.cos(w))):B=e,n=c.x+F.nx*O,o=c.y+F.ny*O,n+=-F.ny*B*m,o+=F.nx*B*m,i.absarc(n,o,B,M.ang+Math.PI/2*m,F.ang-Math.PI/2*m,x),a=c,c=f}i.closePath()},v2=(i,{width:t,height:e,depth:r})=>{t=Math.abs(t),e=Math.abs(e),r=Math.abs(r);let n=i.userData.parameters,o,a,c;t===0?(t=n.width,o=1):o=t/n.width,e===0?(e=n.height,a=1):a=e/n.height,r===0?(r=n.depth,c=1):c=r/n.depth,i.scale(o,a,c),n.width=t,n.height=e,n.depth=r},b2=(i,t)=>{let e=[new Yh(1,0,0),new Yh(0,1,0),new Yh(0,0,1)],r=i.attributes.position,n=new Float32Array(r.count*3);for(let o=0,a=r.count;o<a;o++)e[o%3].toArray(n,o*3);i.setAttribute(t,new y2(n,3))},S2=i=>new Promise(t=>{new g2().load(i,r=>t(r))}),w2=(i,t,e)=>{let r=i.getAttribute("uv");if(r)for(let n=0;n<r.count;n++){let o=r.getX(n),a=r.getY(n);r.setXY(n,(o+t/2)/t,1-(a-e/2)/e*-1)}};import{BufferGeometry as F0,BufferAttribute as V0,Uint32BufferAttribute as Xh,Float32BufferAttribute as Zh,Matrix4 as L2}from"three";import{mergeVertices as T2}from"three/examples/jsm/utils/BufferGeometryUtils.js";var C2,cu=new Promise(i=>{C2=i});var De;cu.then(i=>{De=i});var U0=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),j0=new Uint32Array([0,1,2,3]),k0=new Uint8Array([4]),Jr=class{static build(i,t,e,r,n){let o,a,c;if(i===void 0)o=Jr.allocate(n,e),De.set_destination_refinement_level(o,0),a=Jr.buildLevel(o,!0,r);else if(i.positionWASM!==void 0){t&&t!==0&&(De.free_bvh(t),De.free_subdivision_surface(t));try{o=Jr.allocate(n,void 0,i)}catch(f){console.error(f,i),o=Jr.allocate(n,void 0,{positionWASM:U0,indexWASM:j0,verticesPerFaceWASM:k0})}De.set_destination_refinement_level(o,0),a=Jr.buildLevel(o,!0,r)}else o=t;if(i!==void 0&&i.subdivisions!==void 0){let f=N2(i.subdivisions,i.positionWASM.length);De.set_destination_refinement_level(o,f),f>0?c=Jr.buildLevel(o,!1,r):c=null}return{subdivPointer:o,originalGeometry:a,subdividedGeometry:c}}static allocate(i,t,e){var N;let r,n,o,a=[],c=[];if(e)e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,n=e.indexWASM,o=e.verticesPerFaceWASM):(r=U0,n=j0,o=k0);else{t.deleteAttribute("normal"),t.deleteAttribute("uv");let te=T2(t);r=te.attributes.position.array;let A=te.getIndex().array,b=A.length;switch(t.userData.type==="TorusGeometry"&&(t==null?void 0:t.userData.parameters.arc)===Math.PI*2&&(t.userData.type="ClosedTorusGeometry"),t.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":n=new Uint32Array(b/3*2),o=new Uint8Array(b/6).fill(4);for(let ne=0,xe=0;ne<b;ne+=6)n[xe++]=A[ne],n[xe++]=A[ne+1],n[xe++]=A[ne+4],n[xe++]=A[ne+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let V,P,R;if(t.userData.type==="SphereGeometry")P=t.parameters.heightSegments,V=t.parameters.widthSegments,t.parameters.thetaLength!==Math.PI&&(R=!0);else if(t.userData.type==="CylinderGeometry")P=t.parameters.heightSegments+2,V=t.parameters.radialSegments;else if(t.userData.type==="ConeGeometry")P=t.parameters.heightSegments+1,V=t.parameters.radialSegments;else if(t.userData.type==="TorusGeometry"){let ne=t.userData.parameters;P=Math.ceil(ne.tubularSegments*ne.arc/(2*Math.PI))+2,V=ne.radialSegments}else{let{pathSegments:ne,segments:xe,revolutions:_e}=t.userData.parameters;P=Math.ceil(xe*_e)+2,V=ne}R?(n=new Uint32Array(1*V*3+(P-1)*V*4),o=new Uint8Array(1*V+(P-1)*V)):(n=new Uint32Array(2*V*3+(P-2)*V*4),o=new Uint8Array(2*V+(P-2)*V));let E=0,G=0,ae=0;if(t.userData.type==="SphereGeometry"||t.userData.type==="HelixGeometry"||t.userData.type==="TorusGeometry"){for(;G<3*V;)n[G++]=A[E++],n[G++]=A[E++],n[G++]=A[E++],o[ae++]=3;let ne=R?n.length:3*V+4*(P-2)*V;for(;G<ne;E+=6)n[G++]=A[E],n[G++]=A[E+1],n[G++]=A[E+4],n[G++]=A[E+5],o[ae++]=4}else for(;G<4*(P-2)*V;E+=6)n[G++]=A[E],n[G++]=A[E+1],n[G++]=A[E+4],n[G++]=A[E+5],o[ae++]=4;for(;G<n.length;)n[G++]=A[E++],n[G++]=A[E++],n[G++]=A[E++],o[ae++]=3;break;default:n=A,o=new Uint8Array(b/3).fill(3);break}}let f=r.length,h=n.length,d=o.length,m=r.length+a.length+c.length,x=n.length+o.length,S=m*Float32Array.BYTES_PER_ELEMENT+x*Uint32Array.BYTES_PER_ELEMENT,w=m*Float32Array.BYTES_PER_ELEMENT,B=x*Uint32Array.BYTES_PER_ELEMENT,O=De._malloc(S),T=new Float32Array(De.HEAPF32.buffer,O,m),M=new Uint32Array(De.HEAPU32.buffer,O+w,x);T.set(r,0),T.set(a,r.length),T.set(c,r.length+a.length),M.set(n,0),M.set(o,n.length);let F;(N=e==null?void 0:e.scaleBaked)!=null&&N.some(te=>te!==1)&&(F=new L2().makeScale(...e.scaleBaked)),i&&(F?F.premultiply(i):F=i);let k=F?De.alloc_subdivision_surface2(O,f,O+w,h,O+w+n.length*Uint32Array.BYTES_PER_ELEMENT,d,F.elements):De.alloc_subdivision_surface(O,f,O+w,h,O+w+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return De._free(O),k}static buildLevel(i,t,e,r,n){let o=n?De.get_mesh_data2(i,t?De.Level.CONTROL:De.Level.REFINED,e!=null?e:!t,n.elements):De.get_mesh_data(i,t?De.Level.CONTROL:De.Level.REFINED,e!=null?e:!t),a=8,c=De.HEAPU32.subarray(o>>2,(o>>2)+a),f=c.subarray(4,4+4),h=0,d=De.HEAPU32[c[h]>>2],m=De.HEAPF32.subarray(d>>2,(d>>2)+f[h]);h++;let x=De.HEAPU32[c[h]>>2],S=De.HEAPF32.subarray(x>>2,(x>>2)+f[h]);h++;let w=De.HEAPU32[c[h]>>2],B=De.HEAPU32.subarray(w>>2,(w>>2)+f[h]);h++;let O=De.HEAPU32[c[h]>>2],T=De.HEAPU32.subarray(O>>2,(O>>2)+f[h]);if(h++,r===void 0){let M=new F0;if(M.setIndex(new Xh(T,1)),M.setAttribute("position",new Zh(m,3)),M.setAttribute("normal",new Zh(S,3)),t){M.setAttribute("faceMap",new Xh(B,1));let F=new Float32Array(S.length/3*4).fill(0);M.setAttribute("color",new V0(F,4))}return De.free_mesh_data(o),M.userData.type="SubdivGeometry",M}r.getAttribute("position").copyArray(m),r.getAttribute("normal").copyArray(S),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,De.free_mesh_data(o)}static buildControlCageWireframe(i,t,e){let r=De.get_wireframe_data_for_base_level(i),n=4,o=De.HEAPU32.subarray(r>>2,(r>>2)+n),a=o.subarray(2,2+2),c=0,f=De.HEAPU32[o[c]>>2],h=De.HEAPF32.subarray(f>>2,(f>>2)+a[c]);c++;let d=De.HEAPU32[o[c]>>2],m=De.HEAPU32.subarray(d>>2,(d>>2)+a[c]);if(t===void 0){let x=new F0;x.setAttribute("position",new Zh(h,3));let S=new Float32Array(h.length);for(let w=0,B=h.length;w<B;)S[w++]=e.r,S[w++]=e.g,S[w++]=e.b;return x.setAttribute("color",new V0(S,3)),x.setIndex(new Xh(m,1)),De.free_wireframe_data_for_base_level(r),x}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,De.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,t,e){t||De.set_destination_refinement_level(i,1);let r=e?De.get_topological_data2(i,t?De.Level.CONTROL:De.Level.REFINED,e.elements):De.get_topological_data(i,t?De.Level.CONTROL:De.Level.REFINED),n=6,o=De.HEAPU32.subarray(r>>2,(r>>2)+n),a=o.subarray(3,3+3),c=0,f=De.HEAPU32[o[c]>>2],h=new Float32Array(De.HEAPF32.subarray(f>>2,(f>>2)+a[c]));c++;let d=De.HEAPU32[o[c]>>2],m=new Uint32Array(De.HEAPU32.subarray(d>>2,(d>>2)+a[c]));c++;let x=De.HEAPU32[o[c]>>2],S=new Uint8Array(De.HEAPU32.subarray(x>>2,(x>>2)+a[c]));return De.free_topological_data(r),{positions:h,indices:m,verticesPerFace:S}}};function N2(i,t){let e=i;return e=Math.min(e,3-Math.ceil(Math.log(t/172e3)/Math.log(4))),Math.max(e,0)}var Qh={ConeGeometry:qx,CubeGeometry:$x,CylinderGeometry:Wx,DodecahedronGeometry:Jx,EllipseGeometry:x0,HelixGeometry:C0,IcosahedronGeometry:L0,LatheGeometry:T0,NonParametricGeometry:O0,PolygonGeometry:M0,PyramidGeometry:P0,RectangleGeometry:au,SphereGeometry:A0,PlaneGeometry:D0,StarGeometry:E0,TextFrameGeometry:lu,TorusGeometry:B0,TorusKnotGeometry:G0,TriangleGeometry:R0,VectorGeometry:ar},Da=i=>Qh[i.type].create(i);import{HemisphereLight as H0}from"three";import{Color as _2}from"three";var Er=class extends _2{constructor(e,r,n,o){super(e,r,n);this.isColorA=!0;this.a=o}setRGBA(e,r,n,o){super.setRGB(e,r,n),this.a=o}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};function Ft(i,t){let e;if(typeof i=="string"){let r=t==null?void 0:t.getColor(i);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Er(0,0,0,0))}else return"a"in i?new Er(i.r,i.g,i.b,i.a):new Er(i.r,i.g,i.b,1);return e}var uu=i=>"isEntity"in i,ws=i=>"isAbstractMesh"in i,W0=i=>i.objectType==="CombinedCamera";var fi=i=>"objectHelper"in i;function I2(i,t){var r;let e=!1;t.position&&(i.position.fromArray(t.position),e=!0),t.rotation&&(i.rotation.fromArray(t.rotation),e=!0),t.scale&&(e=!0,i.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(e=!0,i.hiddenMatrix.fromArray((r=t.hiddenMatrix)!=null?r:Di.identity)),e&&i.updateMatrix(),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(t.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=t.isUpVectorFlipped),i.updateUp())}function O2(i,t){I2(i,t),t.name!==void 0&&(i.name=t.name),t.visible!==void 0&&(i.isEntity?i.visibility=t.visible:i.visible=t.visible)}function q0(i,t,e){O2(i,t),t.color!==void 0&&(i.color=Ft(t.color,e)),t.intensity!==void 0&&(i.intensity=t.intensity),t.shadows!==void 0&&!(i instanceof H0)&&(i.castShadow=t.shadows),i.shadow&&!(i instanceof H0)&&t.depth!==void 0&&(i.shadow.camera.far=t.depth,i.shadow.needsUpdate=!0),t.helper!==void 0&&fi(i)&&(i.enableHelper=t.helper,i.gizmos.shadowmap.visible=t.helper)}function $0(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}import{VideoTexture as _D}from"three";import{Mesh as G2}from"three";import{Matrix4 as tp}from"three";import{Box3 as K0,Line3 as fn,Matrix4 as ep,Vector3 as wt}from"three";var Cs=new K0,lr=new wt,Me=new wt,Ht=new ep;function M2(i,t,e=0,r=t.count){let n=1/0,o=1/0,a=1/0,c=-1/0,f=-1/0,h=-1/0;for(let d=e;d<r;d++){let m=t.getX(d),x=t.getY(d),S=t.getZ(d);m<n&&(n=m),x<o&&(o=x),S<a&&(a=S),m>c&&(c=m),x>f&&(f=x),S>h&&(h=S)}return i.min.set(n,o,a),i.max.set(c,f,h),i}var J0=(i,t,e,r)=>{var n;if(ws(i)){let o=i.geometry.userData.parameters,a=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?lr.copy(i.originalGeometry.boundingSphere.center):(M2(Cs,a,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:a.count),Cs.getCenter(lr)),i.forceComputeSize?Cs.getSize(Me).multiplyScalar(.5):Me.set(o.width,o.height,(n=o.depth)!=null?n:0).multiplyScalar(.5)}else if(fi(i)&&r===!0){let o=i.geometryHelper.getAttribute("position");Cs.setFromArray(o.array),Cs.getCenter(lr),Cs.getSize(Me).multiplyScalar(.5)}else lr.setScalar(0),Me.setScalar(0);Ht.copy(t).multiply(i.matrixWorld),Me.x===0&&Me.y===0&&Me.z===0?e.push(new wt(lr.x,lr.y,lr.z).applyMatrix4(Ht)):e.push(new wt(-Me.x,Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(-Me.x,-Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,-Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,Me.y,Me.z).add(lr).applyMatrix4(Ht),new wt(-Me.x,Me.y,-Me.z).add(lr).applyMatrix4(Ht),new wt(-Me.x,-Me.y,-Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,-Me.y,-Me.z).add(lr).applyMatrix4(Ht),new wt(Me.x,Me.y,-Me.z).add(lr).applyMatrix4(Ht))},Ea=class extends K0{constructor(){super(...arguments);this.matrix=new ep;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let n=new ep().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let o=[];return n===!0?e.traverseEntity(a=>J0(a,r,o,e.enableHelper===!0)):J0(e,r,o,e.enableHelper===!0),this.setFromPoints(o)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Ht.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Me).multiplyScalar(.5),this.getCenter(lr),Ht.copy(this.matrix).setPosition(lr),this.vertices=[new wt(-Me.x,Me.y,Me.z).applyMatrix4(Ht),new wt(-Me.x,-Me.y,Me.z).applyMatrix4(Ht),new wt(Me.x,-Me.y,Me.z).applyMatrix4(Ht),new wt(Me.x,Me.y,Me.z).applyMatrix4(Ht),new wt(-Me.x,Me.y,-Me.z).applyMatrix4(Ht),new wt(-Me.x,-Me.y,-Me.z).applyMatrix4(Ht),new wt(Me.x,-Me.y,-Me.z).applyMatrix4(Ht),new wt(Me.x,Me.y,-Me.z).applyMatrix4(Ht)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new fn(this.vertices[0],this.vertices[3]),new fn(this.vertices[1],this.vertices[2]),new fn(this.vertices[5],this.vertices[6]),new fn(this.vertices[4],this.vertices[7]),new fn(this.vertices[0],this.vertices[1]),new fn(this.vertices[3],this.vertices[2]),new fn(this.vertices[7],this.vertices[6]),new fn(this.vertices[4],this.vertices[5]),new fn(this.vertices[0],this.vertices[4]),new fn(this.vertices[1],this.vertices[5]),new fn(this.vertices[2],this.vertices[6]),new fn(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new wt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new wt().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new wt().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new wt().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new wt().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new wt().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new wt().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as P2,Matrix4 as A2,Light as D2}from"three";function Ba(i){let t=[];for(let e in i){let r=i[e];delete r.metadata,t.push(r)}return t}function E2(i){let t=[];for(let e in i)t.push(i[e]);return t}var fu=i=>class extends i{hasEntityChild(){return this.children.some(e=>uu(e))}isDescendantOf(e){e instanceof P2&&(e=e.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===e)return!0;r=r.parent}return!1}attach(e,r){this.updateWorldMatrix(!0,!1);let n=new A2().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),n.multiply(e.parent.matrixWorld)),uu(e)?e.hiddenMatrix.premultiply(n):e.applyMatrix4(n),e.updateWorldMatrix(!1,!1),this.add(e),r!==void 0&&(this.children.pop(),this.children.splice(r,0,e)),this}copy(e,r=!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.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.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let n=0;n<e.children.length;n++){let o=e.children[n];this.add(o.clone())}return this}toJSON(e){let r=e===void 0,n={object:{uuid:"",objectType:""}};e===void 0&&(e={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},n.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let o={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(o.name=this.name),o.matrix=this.matrix.toArray(),this.castShadow===!0&&(o.castShadow=!0),this.receiveShadow===!0&&(o.receiveShadow=!0),this.visible===!1&&(o.visible=!1),this.frustumCulled===!1&&(o.frustumCulled=!1),this.renderOrder!==0&&(o.renderOrder=this.renderOrder),o.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(o.userData=this.userData),this.children.length>0){o.children=[];for(let a of this.children)(uu(a)||a instanceof D2)&&o.children.push(a.toJSON(e).object)}if(r){let a=Ba(e.geometries),c=Ba(e.materials),f=Ba(e.textures),h=Ba(e.images),d=Ba(e.interactionStates),m=E2(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),f.length>0&&(n.textures=f),h.length>0&&(n.images=h),d.length>0&&(n.interactionStates=d),m.length>0&&(n.nodes=m)}return n.object=o,n}fromJSON(e){return this.uuid=e.uuid,e.name!==void 0&&(this.name=e.name),e.matrix!==void 0?(this.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=e.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(e.position!==void 0&&this.position.fromArray(e.position),e.rotation!==void 0&&this.rotation.fromArray(e.rotation),e.quaternion!==void 0&&this.quaternion.fromArray(e.quaternion),e.scale!==void 0&&this.scale.fromArray(e.scale)),this.castShadow=e.castShadow!==void 0,this.receiveShadow=e.receiveShadow!==void 0,e.visible!==void 0&&(this.visible=e.visible),e.frustumCulled!==void 0&&(this.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(this.renderOrder=e.renderOrder),e.layers!==void 0&&(this.layers.mask=e.layers),e.userData!==void 0&&(this.userData=e.userData),this}};var hn=i=>"isEntity"in i;var pn=i=>class extends fu(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new tp;this._singleBBox=new Ea;this._recursiveBBox=new Ea;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let n of this.children)hn(n)&&n.traverseEntity(o=>{fi(o)&&o.visible&&(o.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{hn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let n of this.children)hn(n)&&n.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){let o=this.parent;if(r&&o!==null&&o.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),n)for(let a of this.children)a.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,n=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),n===!0)for(let o of r.children)hn(o)&&this.add(o.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,n=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),n===!0)for(let o of r.children)hn(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let r=new tp,n=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(n);for(let o of this.children)hn(o)&&o.hiddenMatrix.premultiply(r)}toJSON(r){let n=super.toJSON(r),o=n.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),n}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let n=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new tp}),this.copy(r),r.children=n,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ss(n,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let n=j({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(r));return ss(n,r)}fromState(r,n){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};import{Object3D as B2,Vector3 as Ga,Euler as Y0,MathUtils as Ui}from"three";var go=class extends B2{constructor(e,r={}){super();this.object=e;let n=e.recursiveBBox.getSize(new Ga),o=.1;this.parameters=Lc.defaultData(n.toArray(),o),co(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(e){let r=this.object.material.map(n=>n.clone());for(let n of this.children)n.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let r=this.object.material.clone();for(let n of this.children)n.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let r=0,n=e-this.children.length;r<n;++r){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,n=this.children.length-e;r<n;++r)this.remove(this.children[0])}_updateRadial(e){let r=e.radial,n=r.start*Ui.DEG2RAD,o=r.end*Ui.DEG2RAD,a=n-o,c=new Y0(r.rotation[0]*Ui.DEG2RAD,r.rotation[1]*Ui.DEG2RAD,r.rotation[2]*Ui.DEG2RAD),f;switch(r.axis){case"z":f=new Ga(0,0,1);break;case"y":f=new Ga(0,1,0);break;default:case"x":f=new Ga(1,0,0);break}for(let[h,d]of this.children.entries()){d.hiddenMatrix.identity(),d.scale.x=r.scale[0],d.scale.y=r.scale[1],d.scale.z=r.scale[2],d.position.setScalar(0);let m=a/e.count*h-n;switch(r.axis){case"x":d.rotation.set(0,m,0);break;case"y":d.rotation.set(0,0,m);break;case"z":d.rotation.set(m,0,0);break}d.translateOnAxis(f,r.radius),d.position.x+=r.position[0],d.position.y+=r.position[1],d.position.z+=r.position[2],r.alignment===!0?(d.rotation.x+=c.x,d.rotation.y+=c.y,d.rotation.z+=c.z):d.rotation.copy(c)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,n=new Y0(r.rotation[0]*Ui.DEG2RAD,r.rotation[1]*Ui.DEG2RAD,r.rotation[2]*Ui.DEG2RAD);for(let[o,a]of this.children.entries())a.hiddenMatrix.identity(),a.scale.x=1+(r.scale[0]-1)*o,a.scale.y=1+(r.scale[1]-1)*o,a.scale.z=1+(r.scale[2]-1)*o,a.rotation.x=n.x*o,a.rotation.y=n.y*o,a.rotation.z=n.z*o,a.position.x=r.position[0]*o,a.position.y=r.position[1]*o,a.position.z=r.position[2]*o}_updateGrid(e){let r=0,n=e.grid;if(n.useCenter===!0){let o={x:n.count[0]%2===0?2:1,y:n.count[1]%2===0?2:1,z:n.count[2]%2===0?2:1},a=new Ga(n.size[0]*(n.count[0]-o.x)*.5,n.size[1]*(n.count[1]-o.y)*.5,n.size[2]*(n.count[2]-o.z)*.5);for(let c=0;c<n.count[0];c++)for(let f=0;f<n.count[1];f++)for(let h=0;h<n.count[2];h++){let d=this.children[r++];d.hiddenMatrix.identity(),d.scale.setScalar(1),d.rotation.set(0,0,0),d.position.x=n.size[0]*c-a.x,d.position.y=n.size[1]*f-a.y,d.position.z=n.size[2]*h-a.z}}else for(let o=0;o<n.count[0];o++)for(let a=0;a<n.count[1];a++)for(let c=0;c<n.count[2];c++){let f=this.children[r++];f.hiddenMatrix.identity(),f.scale.setScalar(1),f.rotation.set(0,0,0),f.position.x=n.size[0]*o,f.position.y=-n.size[1]*a,f.position.z=-n.size[2]*c}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),co(this.parameters,e),this.update(),this}};var rr=class extends pn(G2){constructor(e,r){super(e,r);this.isAbstractMesh=!0;Array.isArray(r)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r!=null?r:0),r=r!=null?r:this.selectedMaterial,this.material[r].dispose(),this.material[r]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let r=this.geometry,n=Qh[r.userData.type],o=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,a=n.build(n.normalizeInputs(e,o)),c=r.uuid;if(this.geometry.dispose(),this.geometry=a,this.geometry.uuid=c,this.geometry.computeBoundingSphere(),this.cloner)for(let f of this.cloner.children)f.geometry=this.geometry}resizeGeometry(e,r,n){Aa.resizeGeometry(this.geometry,{width:e,height:r,depth:n})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,n=Da(r),o=Array.isArray(this.material)?this.material.map(a=>a.clone()):this.material.clone();return new this.constructor(n,o).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new go(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new go(this)),this.cloner.fromClonerState(e))}fromState(e,r){var n,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(n=e.castShadow)!=null?n:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as nD,ShaderMaterial as iD,FrontSide as oD}from"three";import{CubeReflectionMapping as J2,CubeRefractionMapping as K2,CubeUVReflectionMapping as Y2,LinearEncoding as tv,sRGBEncoding as X2}from"three";var Ra=class{constructor(t){t=t!=null?t:{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};import{MathUtils as R2}from"three";var Pe=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=R2.generateUUID(),this.type=t,this.name="",this.userData={}}analyze(t,e){e=e!=null?e:{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r!=null?r:{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r!=null?r:{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e!=null?e:this.getType(t,e);let n=t.getNodeData(r!=null?r:this);return t.analyzing&&this.appendDepsNode(t,n,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,n,o,a){return""}generate(t,e,r,n,o){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getJSONNode(t){if((t==null?void 0:t.materials)&&(t==null?void 0:t.materials[this.uuid])!==void 0)return t.materials[this.uuid]}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Pe&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)e=this.hashProperties[n],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}copy(t){return this.name=t.name,t.type&&(this.type=t.type),t.frameId&&(this.frameId=t.frameId),t.hashProperties&&(this.hashProperties=t.hashProperties.map(e=>e)),this.userData=JSON.parse(JSON.stringify(t.userData)),this.shortcuts=JSON.parse(JSON.stringify(t.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(t){let e=t===void 0||typeof t=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!e&&t&&(t.nodes[this.uuid]=r),r}toJSON(t){var e;return(e=this.getJSONNode(t))!=null?e:this.createJSONNode(t)}fromJSON(t,e){return this.uuid=t.uuid,this.type=t.type,t.name&&(this.name=t.name),t.userData&&(this.userData=t.userData),this}};var rp=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xt=new rp;import{Vector2 as X0}from"three";import{MathUtils as z2}from"three";var Ee=class extends Pe{constructor(e,r){super(e);this.scope="";r=r!=null?r:{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,n,o){if(r=r!=null?r:this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=z2.generateUUID()),n=e.getUUID(n!=null?n:this.getUUID(),!a);let c=e.getNodeData(n),f=c.output||this.getType(e);if(e.analyzing)return(c.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,c,r),this.generate(e,r,n)):super.build(e,r,n);if(a)return c.name=c.name||super.build(e,r,n),c.name;if(!this.getLabel()&&(!this.getShared(e,f)||e.context.ignoreCache||c.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let h=this.getTemp(e,n);if(h)return e.format(h,f,r);{h=super.generate(e,r,n,c.output,o);let d=this.generate(e,f,n);return e.addNodeCode(h+" = "+d+";"),e.format(h,f,r)}}return super.build(e,r,n)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,o,a){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n!=null?n:this.uuid,e.getTempVar(n,o!=null?o:this.getType(e),a,this.getLabel()).name}};var Ct=class extends Ee{constructor(e,r){r=r!=null?r:{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let r=super.createJSONNode(e);return this.readonly===!0&&(r.readonly=this.readonly),r}fromJSON(e,r){return super.fromJSON(e,r),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,r,n,o,a,c){n=e.getUUID(n!=null?n:this.getUUID()),o=o!=null?o:this.getType(e);let f=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,o,a,c):e.isShader("vertex")?(f.vertex||(f.vertex=e.createVertexUniform(o,this,a,c,this.getLabel())),e.format(f.vertex.name,o,r)):(f.fragment||(f.fragment=e.createFragmentUniform(o,this,a,c,this.getLabel())),e.format(f.fragment.name,o,r))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var mr=class extends Ct{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof X0?e:new X0(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,n,o,a,c){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as Z0}from"three";var gr=class extends Ct{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof Z0?e:new Z0(e,r,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,n,o,a,c){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var hi=class extends Ct{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Er?e:new Er(e.r,e.g,e.b,e.a)}generateReadonly(e,r,n,o,a,c){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var F2=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Q0=/[a-z_0-9]+/gi,we=class extends Ee{constructor(e,r,n,o,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,n,o)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,n,o,a){let c,f=0,h=this.src;if(this.includes)for(let m=0;m<this.includes.length;m++)e.include(this.includes[m],this);for(let m in this.extensions)e.extensions[m]=!0;let d=[];for(;c=Q0.exec(this.src);)d.push(c);for(let m=0;m<d.length;m++){let x=d[m],S=x[0],w=this.isMethod?!this.getInputByName(S):!0,B=S;if(this.keywords[S]||this.useKeywords&&w&&Xt.containsKeyword(S)){let O=this.keywords[S];if(!O){let T=Xt.getKeywordData(S);T.cache&&(O=e.keywords[S]),O=O||Xt.getKeyword(S,e),T.cache&&(e.keywords[S]=O)}B=O.build(e)}S!==B&&(h=h.substring(0,x.index+f)+B+h.substring(x.index+S.length+f),f+=B.length-S.length),this.getIncludeByName(B)===void 0&&Xt.contains(B)&&e.include(Xt.get(B))}return r==="source"?h:this.isMethod?(this.isInterface||e.include(this,void 0,h),this.name):e.format("( "+h+" )",this.getType(e),r)}parse(e,r,n,o){if(this.src=e||"",this.includes=r!=null?r:[],this.extensions=n!=null?n:{},this.keywords=o!=null?o:{},this.isMethod){let a=F2.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let c=a[3].match(Q0);if(c){let f=0;for(;f<c.length;){let h=c[f++],d;h==="in"||h==="out"||h==="inout"?d=c[f++]:(d=h,h="");let m=c[f++];this.inputs.push({name:m,type:d,qualifier:h})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var n;let r=this.getJSONNode(e);if(!r){r=this.createJSONNode(e),r.src=this.src,r.isMethod=this.isMethod,r.useKeywords=this.useKeywords,this.isMethod||(r.type=this.type),r.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let a in this.keywords)o[a]=this.keywords[a].toJSON(e).uuid;if(r.keywords=o,(n=this.includes)!=null&&n.length){let a=[];for(let c=0;c<this.includes.length;c++)a.push(this.includes[c].toJSON(e).uuid);r.includes=a}r.isMethod=this.isMethod,r.inputs=this.inputs}return r.nodeType=this.nodeType,r}fromJSON(e,r){if(super.fromJSON(e,r),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&r){this.keywords={};for(let n in e.keywords)this.keywords[n]=r.getNode(e.keywords[n])}return e.includes&&r&&(this.includes=e.includes.map(n=>r.getNode(n))),this}};var V2=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,np=class extends Ee{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||np.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,n,o,a){this.src=e||"";let c,f,h="",d=V2.exec(e);this.useDefine=a!=null?a:this.src.charAt(0)==="#",d&&d.length>1?(f=d[1],c=d[2],h=d[3]):(c=this.src,f="f"),this.name=c,this.type=f,this.value=h}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,n,o,a){return e.format(this.name,this.getType(e),r)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},rt=np;rt.PI="PI",rt.PI2="PI2",rt.RECIPROCAL_PI="RECIPROCAL_PI",rt.RECIPROCAL_PI2="RECIPROCAL_PI2",rt.LOG2="LOG2",rt.EPSILON="EPSILON";var U2=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
21
+ )*?)}`,"gim"),j2=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ls=class extends Ee{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,n,o,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=U2.exec(e);if(r){let n=r[2],o;for(;o=j2.exec(n);)this.inputs.push({type:o[1],name:o[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ts=class extends Ee{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,r){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",o=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(o,this.getType(e),r)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.index=this.index),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.index&&(this.index=e.index),this}};Xt.addKeyword("uv",function(){return new Ts});Xt.addKeyword("uv2",function(){return new Ts(1)});import{LinearEncoding as k2,sRGBEncoding as H2}from"three";var yo=class extends Ee{constructor(e=new Pe,r){super("v4");this.nodeType="ColorSpace";this.factor=new Pe;this.input=e,this.method=r!=null?r:yo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case k2:return["Linear"];case H2:return["sRGB"];default:return[]}}generate(e,r){var f;let n=this.input.build(e,"v4"),o=this.getType(e),a=yo.Nodes[this.method],c=e.include(a);if(c===yo.LINEAR_TO_LINEAR)return e.format(n,o,r);if(((f=a.inputs)==null?void 0:f.length)===2){let h=this.factor.build(e,"f");return e.format(c+"( "+n+", "+h+" )",o,r)}else return e.format(c+"( "+n+" )",o,r)}fromEncoding(e){let r=yo.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=yo.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},Cr=yo;Cr.Nodes={LinearToLinear:new we(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
22
22
  `)),sRGBToLinear:new we(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
23
23
  `)),LinearTosRGB:new we(["vec4 LinearTosRGB( 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.w );","}"].join(`
24
- `))},Lr.LINEAR_TO_LINEAR="LinearToLinear",Lr.SRGB_TO_LINEAR="sRGBToLinear",Lr.LINEAR_TO_SRGB="LinearTosRGB";var gt=class extends we{constructor(e="",r,n,o,a){super(e,a,o,n,r);this.nodeType="Expression"}};import{Texture as J2}from"three";var kn=class extends J2{toJSON(t){let e=super.toJSON(t),r=t===void 0||typeof t=="string";if(this.image!==void 0&&!r){let n=this.image;if(Array.isArray(n)){t.images[n.uuid].url=[];for(let o=0;o<n.length;o++)t.images[n.uuid].url[o]=Q0(n[o])}else t.images[n.uuid].url=Q0(n)}return e}};function Q0(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?K2(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var Ts;function K2(i){if(/^data:/i.test(i.src))return i.src;let t;if(i instanceof HTMLCanvasElement)t=i;else{Ts===void 0&&(Ts=document.createElement("canvas")),Ts.width=i.width,Ts.height=i.height;let r=Ts.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),t=Ts}let e=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(e)?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var Tr=class extends Ct{constructor(e=new kn,r,n,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r!=null?r:new Ls,this.bias=n,this.project=o!==void 0?o:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){var m;if(r==="sampler2D")return this.getTexture(e,r);let n=this.getTexture(e,r),o=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let c,f;this.project?c="texture2DProj":c=a?"tex2DBias":"tex2D",a?f=c+"( "+n+", "+o+", "+a+" )":f=c+"( "+n+", "+o+" )";let h={include:e.isShader("vertex"),ignoreCache:!0},d=this.getType(e);return e.addContext(h),this.colorSpace=(m=this.colorSpace)!=null?m:new Lr(new gt("",d)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(f),f=this.colorSpace.build(e,d),e.removeContext(),e.format(f,d,r)}copy(e){return super.copy(e),e.value.isRenderTargetTexture?this.value=e.value:this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,e.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}};var ve=class extends Ct{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,r,n,o,a,c){return e.format(this.value+(this.value%1?"":".0"),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var za=class extends Ee{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r!=null?r:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,n,o,a){o=this.getType(e);let c=this.value,f=c.build(e,r)+"( ",h=[];if(c.inputs){for(let d=0;d<c.inputs.length;d++){let m=c.inputs[d],x=this.inputs[d]||this.inputs[m.name];h.push(x.build(e,e.getTypeByFormat(m.type)))}f+=h.join(", ")+" )"}return e.format(f,o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(r=>r.clone()),this}toJSON(e){var n;let r=this.getJSONNode(e);if(!r){let o=this.value;if(r=this.createJSONNode(e),r.value=this.value.toJSON(e).uuid,(n=o.inputs)!=null&&n.length){r.inputs={};for(let a=0;a<o.inputs.length;a++){let c=o.inputs[a],f=this.inputs[a];r.inputs[c.name]=f.toJSON(e).uuid}}}return r}};var ip=class extends Ee{constructor(e=new Pe,r=new Pe,n=ip.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=n}getType(e){let r=this.a.getType(e),n=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(n)>e.getTypeLength(r)?n:r}generate(e,r){let n=this.getType(e);this.type=n;let o=this.a.build(e,n),a=this.b.build(e,n);return e.format("( "+o+" "+this.op+" "+a+" )",n,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},Br=ip;Br.ADD="+",Br.SUB="-",Br.MUL="*",Br.DIV="/";var ut=class extends Ee{constructor(e=new Pe,r=ut.ABS,n,o){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:o=r,typeof n!="string"?this.c=n:o=n,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case ut.MIX:case ut.CLAMP:case ut.REFRACT:case ut.SMOOTHSTEP:case ut.FACEFORWARD:return 3;case ut.MIN:case ut.MAX:case ut.MOD:case ut.STEP:case ut.REFLECT:case ut.DISTANCE:case ut.DOT:case ut.CROSS:case ut.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),n=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return r>n&&r>o?this.a.getType(e):n>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case ut.LENGTH:case ut.DISTANCE:case ut.DOT:return"f";case ut.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let n,o,a,c=this.a?e.getTypeLength(this.a.getType(e)):0,f=this.b?e.getTypeLength(this.b.getType(e)):0,h=this.c?e.getTypeLength(this.c.getType(e)):0,d=this.getInputType(e),m=this.getType(e);switch(this.type=m,this.method){case ut.NEGATE:return e.format("( -"+this.a.build(e,d)+" )",d,r);case ut.INVERT:return e.format("( 1.0 - "+this.a.build(e,d)+" )",d,r);case ut.CROSS:n=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case ut.STEP:n=this.a.build(e,c===1?"f":d),o=this.b.build(e,d);break;case ut.MIN:case ut.MAX:case ut.MOD:n=this.a.build(e,d),o=this.b.build(e,f===1?"f":d);break;case ut.REFRACT:n=this.a.build(e,d),o=this.b.build(e,d),a=this.c.build(e,"f");break;case ut.MIX:n=this.a.build(e,d),o=this.b.build(e,d),a=this.c.build(e,h===1?"f":d);break;default:n=this.a.build(e,d),this.b&&(o=this.b.build(e,d)),this.c&&(a=this.c.build(e,d));break}let x=[];x.push(n),o&&x.push(o),a&&x.push(a);let S=this.getNumInputs(e);if(x.length!==S)throw Error(`Arguments not match used in "${this.method}". Require ${S}, currently ${x.length}.`);return e.format(this.method+"( "+x.join(", ")+" )",m,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof Pe?e.b.clone():e.b,this.c=e.c instanceof Pe?e.c.clone():e.c,this.method=e.method,this}},Fe=ut;Fe.RAD="radians",Fe.DEG="degrees",Fe.EXP="exp",Fe.EXP2="exp2",Fe.LOG="log",Fe.LOG2="log2",Fe.SQRT="sqrt",Fe.INV_SQRT="inversesqrt",Fe.FLOOR="floor",Fe.CEIL="ceil",Fe.NORMALIZE="normalize",Fe.FRACT="fract",Fe.SATURATE="saturate",Fe.SIN="sin",Fe.COS="cos",Fe.TAN="tan",Fe.ASIN="asin",Fe.ACOS="acos",Fe.ARCTAN="atan",Fe.ABS="abs",Fe.SIGN="sign",Fe.LENGTH="length",Fe.NEGATE="negate",Fe.INVERT="invert",Fe.MIN="min",Fe.MAX="max",Fe.MOD="mod",Fe.STEP="step",Fe.REFLECT="reflect",Fe.DISTANCE="distance",Fe.DOT="dot",Fe.CROSS="cross",Fe.POW="pow",Fe.MIX="mix",Fe.CLAMP="clamp",Fe.REFRACT="refract",Fe.SMOOTHSTEP="smoothstep",Fe.FACEFORWARD="faceforward";var Ns=class extends Ee{constructor(e=new Pe,r=new Pe,n=new Pe){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=n}bilinearCubeUV(e,r,n,o){var h,d,m,x;let a=new za(Ns.Nodes.bilinearCubeUV,[r,n,o]);this.colorSpaceTL=(h=this.colorSpaceTL)!=null?h:new Lr(new gt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=(d=this.colorSpaceTR)!=null?d:new Lr(new gt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=(m=this.colorSpaceBL)!=null?m:new Lr(new gt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=(x=this.colorSpaceBR)!=null?x:new Lr(new gt("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let c={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(c),this.colorSpaceTLExp=new gt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new gt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new gt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new gt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let f=new gt("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return f.keywords.cubeUV_TL=this.colorSpaceTLExp,f.keywords.cubeUV_TR=this.colorSpaceTRExp,f.keywords.cubeUV_BL=this.colorSpaceBLExp,f.keywords.cubeUV_BR=this.colorSpaceBRExp,f.keywords.cubeUV=a,f}generate(e,r){if(e.isShader("fragment")){let n=this.uv,o=this.bias||e.context.roughness,a=new za(Ns.Nodes.roughnessToMip,[o]),c=new Fe(a,Ns.Nodes.m0,Ns.Nodes.cubeUV_maxMipLevel,Fe.CLAMP),f=new Fe(c,Fe.FLOOR),h=new Fe(c,Fe.FRACT),d=this.bilinearCubeUV(e,this.value,n,f),m=this.bilinearCubeUV(e,this.value,n,new Br(f,new ve(1).setReadonly(!0),Br.ADD)),x=new Fe(d,m,h,Fe.MIX);return e.format(x.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}},_s=Ns;_s.Nodes=function(){let e=new Cs(`struct TextureCubeUVData {
24
+ `))},Cr.LINEAR_TO_LINEAR="LinearToLinear",Cr.SRGB_TO_LINEAR="sRGBToLinear",Cr.LINEAR_TO_SRGB="LinearTosRGB";var gt=class extends we{constructor(e="",r,n,o,a){super(e,a,o,n,r);this.nodeType="Expression"}};import{Texture as W2}from"three";var kn=class extends W2{toJSON(t){let e=super.toJSON(t),r=t===void 0||typeof t=="string";if(this.image!==void 0&&!r){let n=this.image;if(Array.isArray(n)){t.images[n.uuid].url=[];for(let o=0;o<n.length;o++)t.images[n.uuid].url[o]=ev(n[o])}else t.images[n.uuid].url=ev(n)}return e}};function ev(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?q2(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var Ns;function q2(i){if(/^data:/i.test(i.src))return i.src;let t;if(i instanceof HTMLCanvasElement)t=i;else{Ns===void 0&&(Ns=document.createElement("canvas")),Ns.width=i.width,Ns.height=i.height;let r=Ns.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),t=Ns}let e=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(e)?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var Lr=class extends Ct{constructor(e=new kn,r,n,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r!=null?r:new Ts,this.bias=n,this.project=o!==void 0?o:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){var m;if(r==="sampler2D")return this.getTexture(e,r);let n=this.getTexture(e,r),o=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let c,f;this.project?c="texture2DProj":c=a?"tex2DBias":"tex2D",a?f=c+"( "+n+", "+o+", "+a+" )":f=c+"( "+n+", "+o+" )";let h={include:e.isShader("vertex"),ignoreCache:!0},d=this.getType(e);return e.addContext(h),this.colorSpace=(m=this.colorSpace)!=null?m:new Cr(new gt("",d)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(f),f=this.colorSpace.build(e,d),e.removeContext(),e.format(f,d,r)}copy(e){return super.copy(e),e.value.isRenderTargetTexture?this.value=e.value:this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,e.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}};var ve=class extends Ct{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,r,n,o,a,c){return e.format(this.value+(this.value%1?"":".0"),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var za=class extends Ee{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r!=null?r:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,n,o,a){o=this.getType(e);let c=this.value,f=c.build(e,r)+"( ",h=[];if(c.inputs){for(let d=0;d<c.inputs.length;d++){let m=c.inputs[d],x=this.inputs[d]||this.inputs[m.name];h.push(x.build(e,e.getTypeByFormat(m.type)))}f+=h.join(", ")+" )"}return e.format(f,o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(r=>r.clone()),this}toJSON(e){var n;let r=this.getJSONNode(e);if(!r){let o=this.value;if(r=this.createJSONNode(e),r.value=this.value.toJSON(e).uuid,(n=o.inputs)!=null&&n.length){r.inputs={};for(let a=0;a<o.inputs.length;a++){let c=o.inputs[a],f=this.inputs[a];r.inputs[c.name]=f.toJSON(e).uuid}}}return r}};var ip=class extends Ee{constructor(e=new Pe,r=new Pe,n=ip.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=n}getType(e){let r=this.a.getType(e),n=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(n)>e.getTypeLength(r)?n:r}generate(e,r){let n=this.getType(e);this.type=n;let o=this.a.build(e,n),a=this.b.build(e,n);return e.format("( "+o+" "+this.op+" "+a+" )",n,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},Br=ip;Br.ADD="+",Br.SUB="-",Br.MUL="*",Br.DIV="/";var ut=class extends Ee{constructor(e=new Pe,r=ut.ABS,n,o){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:o=r,typeof n!="string"?this.c=n:o=n,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case ut.MIX:case ut.CLAMP:case ut.REFRACT:case ut.SMOOTHSTEP:case ut.FACEFORWARD:return 3;case ut.MIN:case ut.MAX:case ut.MOD:case ut.STEP:case ut.REFLECT:case ut.DISTANCE:case ut.DOT:case ut.CROSS:case ut.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),n=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return r>n&&r>o?this.a.getType(e):n>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case ut.LENGTH:case ut.DISTANCE:case ut.DOT:return"f";case ut.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let n,o,a,c=this.a?e.getTypeLength(this.a.getType(e)):0,f=this.b?e.getTypeLength(this.b.getType(e)):0,h=this.c?e.getTypeLength(this.c.getType(e)):0,d=this.getInputType(e),m=this.getType(e);switch(this.type=m,this.method){case ut.NEGATE:return e.format("( -"+this.a.build(e,d)+" )",d,r);case ut.INVERT:return e.format("( 1.0 - "+this.a.build(e,d)+" )",d,r);case ut.CROSS:n=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case ut.STEP:n=this.a.build(e,c===1?"f":d),o=this.b.build(e,d);break;case ut.MIN:case ut.MAX:case ut.MOD:n=this.a.build(e,d),o=this.b.build(e,f===1?"f":d);break;case ut.REFRACT:n=this.a.build(e,d),o=this.b.build(e,d),a=this.c.build(e,"f");break;case ut.MIX:n=this.a.build(e,d),o=this.b.build(e,d),a=this.c.build(e,h===1?"f":d);break;default:n=this.a.build(e,d),this.b&&(o=this.b.build(e,d)),this.c&&(a=this.c.build(e,d));break}let x=[];x.push(n),o&&x.push(o),a&&x.push(a);let S=this.getNumInputs(e);if(x.length!==S)throw Error(`Arguments not match used in "${this.method}". Require ${S}, currently ${x.length}.`);return e.format(this.method+"( "+x.join(", ")+" )",m,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof Pe?e.b.clone():e.b,this.c=e.c instanceof Pe?e.c.clone():e.c,this.method=e.method,this}},Fe=ut;Fe.RAD="radians",Fe.DEG="degrees",Fe.EXP="exp",Fe.EXP2="exp2",Fe.LOG="log",Fe.LOG2="log2",Fe.SQRT="sqrt",Fe.INV_SQRT="inversesqrt",Fe.FLOOR="floor",Fe.CEIL="ceil",Fe.NORMALIZE="normalize",Fe.FRACT="fract",Fe.SATURATE="saturate",Fe.SIN="sin",Fe.COS="cos",Fe.TAN="tan",Fe.ASIN="asin",Fe.ACOS="acos",Fe.ARCTAN="atan",Fe.ABS="abs",Fe.SIGN="sign",Fe.LENGTH="length",Fe.NEGATE="negate",Fe.INVERT="invert",Fe.MIN="min",Fe.MAX="max",Fe.MOD="mod",Fe.STEP="step",Fe.REFLECT="reflect",Fe.DISTANCE="distance",Fe.DOT="dot",Fe.CROSS="cross",Fe.POW="pow",Fe.MIX="mix",Fe.CLAMP="clamp",Fe.REFRACT="refract",Fe.SMOOTHSTEP="smoothstep",Fe.FACEFORWARD="faceforward";var _s=class extends Ee{constructor(e=new Pe,r=new Pe,n=new Pe){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=n}bilinearCubeUV(e,r,n,o){var h,d,m,x;let a=new za(_s.Nodes.bilinearCubeUV,[r,n,o]);this.colorSpaceTL=(h=this.colorSpaceTL)!=null?h:new Cr(new gt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=(d=this.colorSpaceTR)!=null?d:new Cr(new gt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=(m=this.colorSpaceBL)!=null?m:new Cr(new gt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=(x=this.colorSpaceBR)!=null?x:new Cr(new gt("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let c={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(c),this.colorSpaceTLExp=new gt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new gt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new gt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new gt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let f=new gt("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return f.keywords.cubeUV_TL=this.colorSpaceTLExp,f.keywords.cubeUV_TR=this.colorSpaceTRExp,f.keywords.cubeUV_BL=this.colorSpaceBLExp,f.keywords.cubeUV_BR=this.colorSpaceBRExp,f.keywords.cubeUV=a,f}generate(e,r){if(e.isShader("fragment")){let n=this.uv,o=this.bias||e.context.roughness,a=new za(_s.Nodes.roughnessToMip,[o]),c=new Fe(a,_s.Nodes.m0,_s.Nodes.cubeUV_maxMipLevel,Fe.CLAMP),f=new Fe(c,Fe.FLOOR),h=new Fe(c,Fe.FRACT),d=this.bilinearCubeUV(e,this.value,n,f),m=this.bilinearCubeUV(e,this.value,n,new Br(f,new ve(1).setReadonly(!0),Br.ADD)),x=new Fe(d,m,h,Fe.MIX);return e.format(x.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}},Is=_s;Is.Nodes=function(){let e=new Ls(`struct TextureCubeUVData {
25
25
  vec4 tl;
26
26
  vec4 tr;
27
27
  vec4 br;
@@ -100,7 +100,7 @@ function print() { __p += __j.call(arguments, '') }
100
100
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
101
101
  }
102
102
  return mip;
103
- }`,V);return{bilinearCubeUV:h,roughnessToMip:P,m0:x,cubeUV_maxMipLevel:r}}();var yo=class extends Ee{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:yo.VIEW}getShared(){return this.scope===yo.WORLD}build(e,r,n,o){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,n,o):super.build(e,r,n)}generate(e,r,n,o,a){let c;switch(this.scope){case yo.VIEW:e.isShader("vertex")?c="transformedNormal":c="geometryNormal";break;case yo.LOCAL:e.isShader("vertex")?c="objectNormal":(e.requires.normal=!0,c="vObjectNormal");break;case yo.WORLD:e.isShader("vertex")?c="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,c="vWNormal");break}return e.format(c,this.getType(e),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},nr=yo;nr.LOCAL="local",nr.WORLD="world",nr.VIEW="view",nr.NORMAL="normal";Xt.addKeyword("viewNormal",function(){return new nr(nr.VIEW)});Xt.addKeyword("localNormal",function(){return new nr(nr.NORMAL)});Xt.addKeyword("worldNormal",function(){return new nr(nr.WORLD)});var Hn=class extends Ee{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:Hn.LOCAL}getType(){switch(this.scope){case Hn.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Hn.LOCAL:case Hn.WORLD:return!1}return!0}generate(e,r,n,o,a){let c;switch(this.scope){case Hn.LOCAL:e.isShader("vertex")?c="transformed":(e.requires.position=!0,c="vPosition");break;case Hn.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,c="vWPosition";break;case Hn.VIEW:c=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Hn.PROJECTION:c=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(c,this.getType(),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},cr=Hn;cr.LOCAL="local",cr.WORLD="world",cr.VIEW="view",cr.PROJECTION="projection";Xt.addKeyword("position",function(){return new cr});Xt.addKeyword("worldPosition",function(){return new cr(cr.WORLD)});Xt.addKeyword("viewPosition",function(){return new cr(cr.VIEW)});var Nn=class extends Ee{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:Nn.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Nn.SPHERE:return"v2"}return this.type}generate(e,r){let n=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case Nn.VECTOR:{let a=new nr(nr.VIEW),c=e.context.roughness,f=a.build(e,"v3"),h=new cr(cr.VIEW).build(e,"v3"),d=c?c.build(e,"f"):void 0,m=`reflect( -normalize( ${h} ), ${f} )`;d&&(m=`normalize( mix( ${m}, ${f}, ${d} * ${d} ) )`);let x=`inverseTransformDirection( ${m}, viewMatrix )`;n?(e.addNodeCode(`vec3 reflectVec = ${x};`),o="reflectVec"):o=x;break}case Nn.CUBE:{let a=new Nn(Nn.VECTOR).build(e,"v3"),c="vec3( -"+a+".x, "+a+".yz )";n?(e.addNodeCode(`vec3 reflectCubeVec = ${c};`),o="reflectCubeVec"):o=c;break}case Nn.SPHERE:{let a=new Nn(Nn.VECTOR).build(e,"v3"),c="normalize( ( viewMatrix * vec4( "+a+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";n?(e.addNodeCode(`vec2 reflectSphereVec = ${c};`),o="reflectSphereVec"):o=c;break}}return e.format(o,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},Wn=Nn;Wn.CUBE="cube",Wn.SPHERE="sphere",Wn.VECTOR="vector";var hu=class extends Ee{constructor(e=new Tr,r,n){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new _s(this.value,r!=null?r:new Wn(Wn.VECTOR),n),this.irradianceNode=new _s(this.value,new nr(nr.WORLD),new ve(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}};import{CubeTexture as Y2}from"three";var pu=class extends Ct{constructor(e=new Y2,r,n){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r!=null?r:new Wn,this.bias=n}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){var d,m;if(r==="samplerCube")return this.getTexture(e,r);let n=this.getTexture(e,r),o=(d=this.uv)==null?void 0:d.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let c;a?c="texCubeBias( "+n+", "+o+", "+a+" )":c="texCube( "+n+", "+o+" )";let f={include:e.isShader("vertex"),ignoreCache:!0},h=this.getType(e);return e.addContext(f),this.colorSpace=(m=this.colorSpace)!=null?m:new Lr(new gt("",h)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,h),e.removeContext(),e.format(c,h,r)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}};var tv=["x","y","z","w"],tD=["float","vec2","vec3","vec4"],rD={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},nD={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},du=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,n){let o=this.getIncludes(r,n);if(!o)return"";let a="";o=o.sort(t);for(let c=0;c<o.length;c++)o[c].src&&(a+=o[c].src+`
103
+ }`,V);return{bilinearCubeUV:h,roughnessToMip:P,m0:x,cubeUV_maxMipLevel:r}}();var xo=class extends Ee{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:xo.VIEW}getShared(){return this.scope===xo.WORLD}build(e,r,n,o){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,n,o):super.build(e,r,n)}generate(e,r,n,o,a){let c;switch(this.scope){case xo.VIEW:e.isShader("vertex")?c="transformedNormal":c="geometryNormal";break;case xo.LOCAL:e.isShader("vertex")?c="objectNormal":(e.requires.normal=!0,c="vObjectNormal");break;case xo.WORLD:e.isShader("vertex")?c="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,c="vWNormal");break}return e.format(c,this.getType(e),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},nr=xo;nr.LOCAL="local",nr.WORLD="world",nr.VIEW="view",nr.NORMAL="normal";Xt.addKeyword("viewNormal",function(){return new nr(nr.VIEW)});Xt.addKeyword("localNormal",function(){return new nr(nr.NORMAL)});Xt.addKeyword("worldNormal",function(){return new nr(nr.WORLD)});var Hn=class extends Ee{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:Hn.LOCAL}getType(){switch(this.scope){case Hn.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Hn.LOCAL:case Hn.WORLD:return!1}return!0}generate(e,r,n,o,a){let c;switch(this.scope){case Hn.LOCAL:e.isShader("vertex")?c="transformed":(e.requires.position=!0,c="vPosition");break;case Hn.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,c="vWPosition";break;case Hn.VIEW:c=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Hn.PROJECTION:c=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(c,this.getType(),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},cr=Hn;cr.LOCAL="local",cr.WORLD="world",cr.VIEW="view",cr.PROJECTION="projection";Xt.addKeyword("position",function(){return new cr});Xt.addKeyword("worldPosition",function(){return new cr(cr.WORLD)});Xt.addKeyword("viewPosition",function(){return new cr(cr.VIEW)});var Nn=class extends Ee{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:Nn.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Nn.SPHERE:return"v2"}return this.type}generate(e,r){let n=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case Nn.VECTOR:{let a=new nr(nr.VIEW),c=e.context.roughness,f=a.build(e,"v3"),h=new cr(cr.VIEW).build(e,"v3"),d=c?c.build(e,"f"):void 0,m=`reflect( -normalize( ${h} ), ${f} )`;d&&(m=`normalize( mix( ${m}, ${f}, ${d} * ${d} ) )`);let x=`inverseTransformDirection( ${m}, viewMatrix )`;n?(e.addNodeCode(`vec3 reflectVec = ${x};`),o="reflectVec"):o=x;break}case Nn.CUBE:{let a=new Nn(Nn.VECTOR).build(e,"v3"),c="vec3( -"+a+".x, "+a+".yz )";n?(e.addNodeCode(`vec3 reflectCubeVec = ${c};`),o="reflectCubeVec"):o=c;break}case Nn.SPHERE:{let a=new Nn(Nn.VECTOR).build(e,"v3"),c="normalize( ( viewMatrix * vec4( "+a+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";n?(e.addNodeCode(`vec2 reflectSphereVec = ${c};`),o="reflectSphereVec"):o=c;break}}return e.format(o,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},Wn=Nn;Wn.CUBE="cube",Wn.SPHERE="sphere",Wn.VECTOR="vector";var hu=class extends Ee{constructor(e=new Lr,r,n){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Is(this.value,r!=null?r:new Wn(Wn.VECTOR),n),this.irradianceNode=new Is(this.value,new nr(nr.WORLD),new ve(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}};import{CubeTexture as $2}from"three";var pu=class extends Ct{constructor(e=new $2,r,n){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r!=null?r:new Wn,this.bias=n}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){var d,m;if(r==="samplerCube")return this.getTexture(e,r);let n=this.getTexture(e,r),o=(d=this.uv)==null?void 0:d.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let c;a?c="texCubeBias( "+n+", "+o+", "+a+" )":c="texCube( "+n+", "+o+" )";let f={include:e.isShader("vertex"),ignoreCache:!0},h=this.getType(e);return e.addContext(f),this.colorSpace=(m=this.colorSpace)!=null?m:new Cr(new gt("",h)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,h),e.removeContext(),e.format(c,h,r)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}};var rv=["x","y","z","w"],Z2=["float","vec2","vec3","vec4"],Q2={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},eD={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},du=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,n){let o=this.getIncludes(r,n);if(!o)return"";let a="";o=o.sort(t);for(let c=0;c<o.length;c++)o[c].src&&(a+=o[c].src+`
104
104
  `);return a}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
105
105
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
106
106
  #define SPE_BLENDING_NORMAL 0
@@ -145,8 +145,8 @@ function print() { __p += __j.call(arguments, '') }
145
145
  `}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,n="varying",o="V",a=""){let c=this.getVars(n),f=c[t];if(!f){let h=c.length;f={name:r||"node"+o+h+(a?"_"+a:""),type:e},c.push(f),c[t]=f}return f}getTempVar(t,e,r,n){return this.getVar(t,e,r,this.shader,"T",n)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
146
146
  `)}getVarListCode(t,e){e=e!=null?e:"";let r="";for(let n=0,o=t.length;n<o;++n){let a=t[n],c=a.type,f=a.name,h=a.size,d=this.getFormatByType(c);if(d===void 0)throw new Error("Node pars "+d+" not found.");d.includes("[]")?r+=e+" "+d.substring(0,d.length-2)+" "+f+`[${h}];
147
147
  `:r+=e+" "+d+" "+f+`;
148
- `}return r}getVars(t){return this.inputs.vars[t!=null?t:this.shader]}getNodeData(t){let e=t instanceof Pe?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,n,o,a){if(e.includes("[]")){let c=this.inputs.arrayUniforms,f=c.list.length,h=new Ra({type:e,size:r.size,name:n||"nodeUA"+f+(a?"_"+a:""),node:r,needsUpdate:o});return c.list.push(h),c[t].push(h),c[t][h.name]=h,this.uniforms[h.name]=h,h}else{let c=this.inputs.uniforms,f=c.list.length,h=new Ra({type:e,name:n||"nodeU"+f+(a?"_"+a:""),node:r,needsUpdate:o});return c.list.push(h),c[t].push(h),c[t][h.name]=h,this.uniforms[h.name]=h,h}}createVertexUniform(t,e,r,n,o){return this.createUniform("vertex",t,e,r,n,o)}createFragmentUniform(t,e,r,n,o){return this.createUniform("fragment",t,e,r,n,o)}include(t,e,r){var a;let n;if(t=typeof t=="string"?Xt.get(t):t,this.context.include===!1)return t.name;t instanceof we?n=this.includes.functions:t instanceof rt?n=this.includes.consts:t instanceof Cs&&(n=this.includes.structs);let o=n[this.shader]=n[this.shader]||[];if(t){let c=o[t.name];if(c||(c=o[t.name]={node:t,deps:[]},o.push(c),c.src=t.build(this,"source")),t instanceof we&&e&&o[e.name]&&o[e.name].deps.indexOf(t)===-1&&(o[e.name].deps.push(t),(a=t.includes)!=null&&a.length)){let f=0;do this.include(t.includes[f++],e);while(f<t.includes.length)}return r&&(c.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return tD[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!=null&&r.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case X2:case Z2:return new pu(r);case Q2:return new hu(new Tr(r));default:return new Tr(r)}else{if(r.isVector2)return new mr(r);if(r.isVector3)return new gr(r);if(r.isVector4)return new hi(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return rD[t]||t}getFormatByType(t){return nD[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return tv[t]}getIndexByElement(t){return tv.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=ev,e===ev&&this.context.gamma&&(e=eD),e}};var Fa=class extends Pe{constructor(e=new Pe){super("v4");this.nodeType="Raw";this.value=e}generate(e){let r=this.value.analyzeAndFlow(e,this.type),n=r.code+`
149
- `;return e.isShader("vertex")?n+="gl_Position = "+r.result+";":n+="gl_FragColor = "+r.result+";",n}copy(e){return super.copy(e),this.value.copy(e.value),this}};var yt=class extends Ct{constructor(e=0,r,n,o){super("c");this.nodeType="Color";this.value=e instanceof Er?e:new Er(e||0,r,n,o)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,n,o,a,c){n=e.getUUID(n!=null?n:this.getUUID()),o=o!=null?o:this.getType(e);let f=e.getNodeData(n),h=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let d=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${d};`)}return h?this.generateReadonly(e,r,n,o,a,c):e.isShader("vertex")?(f.vertex||(f.vertex=e.createVertexUniform(o,this,a,c,this.getLabel())),e.format(f.vertex.name,o,r)):(f.fragment||(f.fragment=e.createFragmentUniform(o,this,a,c,this.getLabel())),e.format(f.fragment.name,o,r))}generateReadonly(e,r,n,o,a,c){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",o,r)}};import{MathUtils as pi,Vector2 as ji,Vector3 as ki,Vector4 as mu}from"three";import{Texture as iD}from"three";var Ke=class extends Ct{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,r,n,o,a,c){return e.format(this.value.toString(),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var Mt=class{constructor(t,e,r,n){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=t,this.uuid=e,r){this.type=r.type;for(let o in r)o!=="type"&&o!=="calpha"&&(this.uniforms[`f${this.id}_${o}`]=r[o]);for(let o in n)this.defines[o]=n[o]}}copy(t){this.id=t.id,this.type=t.type,this.defines=j({},t.defines);for(let e in t.uniforms)this.getName(e)==="transmissionSamplerMap"||this.getName(e)==="transmissionDepthMap"||(this.uniforms[e]?this.uniforms[e].copy(t.uniforms[e]):this.uniforms[e]=t.uniforms[e].clone());return this}clone(){return new Mt(this.id).copy(this)}fromJSON(t,e){this.id=t.id,this.defines=j({},t.defines);for(let r in t.uniforms)this.uniforms[r]=e.getNode(t.uniforms[r]);if(t.type==="texture"){if(!(`f${this.id}_textureSize`in this.uniforms)){let r=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${t.id}_textureSize`]=new gr(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new mr(200,200)),`f${t.id}_axis`in this.uniforms||(this.uniforms[`f${t.id}_axis`]=new Ke(0)),`f${t.id}_projection`in this.uniforms||(this.uniforms[`f${t.id}_projection`]=new Ke(0))}else t.type==="noise"?(`f${t.id}_noiseType`in this.uniforms||(this.uniforms[`f${t.id}_noiseType`]=new Ke(0)),`f${t.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new gr(-1,-1,-1))):t.type==="depth"&&(`f${t.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${t.id}_isWorldSpace`]=new ve(1)));return this}toJSON(t){let e={};for(let n in this.uniforms)e[n]=this.uniforms[n].toJSON(t).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:e,next:this.next==null?void 0:this.next.toJSON(t)}}copyUniforms(t){for(let e in this.uniforms){let r=this.getName(e);r!==void 0&&t.uniforms[`f${t.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[e].copy(t.uniforms[`f${t.id}_${r}`])}return this}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getValues(){let t={type:this.type};for(let e in this.uniforms){let r=this.getName(e);if(r===void 0)continue;let o=this.uniforms[`f${this.id}_${r}`].value;o!==void 0&&(Array.isArray(o)?t[r]=o.map(a=>a.clone?a.clone():a):t[r]=o.clone?o.clone():o)}return t}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}isEqual(t){for(let e in t.uniforms){let r=t.getName(e);if(!r)return!1;let n=this.getValue(r),o=t.uniforms[e].value;if(o.value instanceof iD){if(n.image!==o.image)return!1}else if(Array.isArray(o)){let a=n;for(let c=0,f=a.length;c<f;++c)if(a[c]!==o[c])return!1}else{let a=n;if(a.equals){if(!a.equals(o))return!1}else if(n!==o)return!1}}return!0}dispose(){}};function rv(i){let t=i instanceof Mt?i.type:i;return t==="texture"||t==="displace_map"||t==="matcap"}var Va=class extends Ct{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,r,n,o){return e.format(this.value?"true":"false",o,r)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector4 as nv}from"three";var xo=class extends Ct{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof nv?new Array(e).fill(r):new Array(e).fill(new nv(0))}copy(e){return super.copy(e),this.value=e.value.map(r=>r.clone()),this}};var vo=class extends Ct{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}};import{Matrix3 as oD}from"three";var Is=class extends Ct{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new oD}generateReadonly(e,r,n,o,a,c){return e.format("mat3("+this.value.elements.join(", ")+")",o,r)}copy(e){return super.copy(e),this.elements=e.elements,this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var ja=class extends Ee{constructor(e=new Tr,r,n,o,a,c,f,h){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=r,this.crop=n,this.projection=o,this.axis=a,this.size=c,this.mat=new Is(this.texture.value.matrix),this.alpha=f,this.mode=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let n;switch(this.projection.value){case 3:n=e.include(ja.Nodes.cylindrical);break;case 2:n=e.include(ja.Nodes.spherical);break;case 1:let a=new we(`
148
+ `}return r}getVars(t){return this.inputs.vars[t!=null?t:this.shader]}getNodeData(t){let e=t instanceof Pe?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,n,o,a){if(e.includes("[]")){let c=this.inputs.arrayUniforms,f=c.list.length,h=new Ra({type:e,size:r.size,name:n||"nodeUA"+f+(a?"_"+a:""),node:r,needsUpdate:o});return c.list.push(h),c[t].push(h),c[t][h.name]=h,this.uniforms[h.name]=h,h}else{let c=this.inputs.uniforms,f=c.list.length,h=new Ra({type:e,name:n||"nodeU"+f+(a?"_"+a:""),node:r,needsUpdate:o});return c.list.push(h),c[t].push(h),c[t][h.name]=h,this.uniforms[h.name]=h,h}}createVertexUniform(t,e,r,n,o){return this.createUniform("vertex",t,e,r,n,o)}createFragmentUniform(t,e,r,n,o){return this.createUniform("fragment",t,e,r,n,o)}include(t,e,r){var a;let n;if(t=typeof t=="string"?Xt.get(t):t,this.context.include===!1)return t.name;t instanceof we?n=this.includes.functions:t instanceof rt?n=this.includes.consts:t instanceof Ls&&(n=this.includes.structs);let o=n[this.shader]=n[this.shader]||[];if(t){let c=o[t.name];if(c||(c=o[t.name]={node:t,deps:[]},o.push(c),c.src=t.build(this,"source")),t instanceof we&&e&&o[e.name]&&o[e.name].deps.indexOf(t)===-1&&(o[e.name].deps.push(t),(a=t.includes)!=null&&a.length)){let f=0;do this.include(t.includes[f++],e);while(f<t.includes.length)}return r&&(c.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return Z2[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!=null&&r.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case J2:case K2:return new pu(r);case Y2:return new hu(new Lr(r));default:return new Lr(r)}else{if(r.isVector2)return new mr(r);if(r.isVector3)return new gr(r);if(r.isVector4)return new hi(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return Q2[t]||t}getFormatByType(t){return eD[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return rv[t]}getIndexByElement(t){return rv.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=tv,e===tv&&this.context.gamma&&(e=X2),e}};var Fa=class extends Pe{constructor(e=new Pe){super("v4");this.nodeType="Raw";this.value=e}generate(e){let r=this.value.analyzeAndFlow(e,this.type),n=r.code+`
149
+ `;return e.isShader("vertex")?n+="gl_Position = "+r.result+";":n+="gl_FragColor = "+r.result+";",n}copy(e){return super.copy(e),this.value.copy(e.value),this}};var yt=class extends Ct{constructor(e=0,r,n,o){super("c");this.nodeType="Color";this.value=e instanceof Er?e:new Er(e||0,r,n,o)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,n,o,a,c){n=e.getUUID(n!=null?n:this.getUUID()),o=o!=null?o:this.getType(e);let f=e.getNodeData(n),h=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let d=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${d};`)}return h?this.generateReadonly(e,r,n,o,a,c):e.isShader("vertex")?(f.vertex||(f.vertex=e.createVertexUniform(o,this,a,c,this.getLabel())),e.format(f.vertex.name,o,r)):(f.fragment||(f.fragment=e.createFragmentUniform(o,this,a,c,this.getLabel())),e.format(f.fragment.name,o,r))}generateReadonly(e,r,n,o,a,c){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",o,r)}};import{MathUtils as pi,Vector2 as ji,Vector3 as ki,Vector4 as mu}from"three";import{Texture as tD}from"three";var Ke=class extends Ct{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,r,n,o,a,c){return e.format(this.value.toString(),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var Mt=class{constructor(t,e,r,n){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=t,this.uuid=e,r){this.type=r.type;for(let o in r)o!=="type"&&o!=="calpha"&&(this.uniforms[`f${this.id}_${o}`]=r[o]);for(let o in n)this.defines[o]=n[o]}}copy(t){this.id=t.id,this.type=t.type,this.defines=j({},t.defines);for(let e in t.uniforms)this.getName(e)==="transmissionSamplerMap"||this.getName(e)==="transmissionDepthMap"||(this.uniforms[e]?this.uniforms[e].copy(t.uniforms[e]):this.uniforms[e]=t.uniforms[e].clone());return this}clone(){return new Mt(this.id).copy(this)}fromJSON(t,e){this.id=t.id,this.defines=j({},t.defines);for(let r in t.uniforms)this.uniforms[r]=e.getNode(t.uniforms[r]);if(t.type==="texture"){if(!(`f${this.id}_textureSize`in this.uniforms)){let r=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${t.id}_textureSize`]=new gr(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new mr(200,200)),`f${t.id}_axis`in this.uniforms||(this.uniforms[`f${t.id}_axis`]=new Ke(0)),`f${t.id}_projection`in this.uniforms||(this.uniforms[`f${t.id}_projection`]=new Ke(0))}else t.type==="noise"?(`f${t.id}_noiseType`in this.uniforms||(this.uniforms[`f${t.id}_noiseType`]=new Ke(0)),`f${t.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new gr(-1,-1,-1))):t.type==="depth"&&(`f${t.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${t.id}_isWorldSpace`]=new ve(1)));return this}toJSON(t){let e={};for(let n in this.uniforms)e[n]=this.uniforms[n].toJSON(t).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:e,next:this.next==null?void 0:this.next.toJSON(t)}}copyUniforms(t){for(let e in this.uniforms){let r=this.getName(e);r!==void 0&&t.uniforms[`f${t.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[e].copy(t.uniforms[`f${t.id}_${r}`])}return this}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getValues(){let t={type:this.type};for(let e in this.uniforms){let r=this.getName(e);if(r===void 0)continue;let o=this.uniforms[`f${this.id}_${r}`].value;o!==void 0&&(Array.isArray(o)?t[r]=o.map(a=>a.clone?a.clone():a):t[r]=o.clone?o.clone():o)}return t}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}isEqual(t){for(let e in t.uniforms){let r=t.getName(e);if(!r)return!1;let n=this.getValue(r),o=t.uniforms[e].value;if(o.value instanceof tD){if(n.image!==o.image)return!1}else if(Array.isArray(o)){let a=n;for(let c=0,f=a.length;c<f;++c)if(a[c]!==o[c])return!1}else{let a=n;if(a.equals){if(!a.equals(o))return!1}else if(n!==o)return!1}}return!0}dispose(){}};function nv(i){let t=i instanceof Mt?i.type:i;return t==="texture"||t==="displace_map"||t==="matcap"}var Va=class extends Ct{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,r,n,o){return e.format(this.value?"true":"false",o,r)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector4 as iv}from"three";var vo=class extends Ct{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof iv?new Array(e).fill(r):new Array(e).fill(new iv(0))}copy(e){return super.copy(e),this.value=e.value.map(r=>r.clone()),this}};var bo=class extends Ct{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}};import{Matrix3 as rD}from"three";var Os=class extends Ct{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new rD}generateReadonly(e,r,n,o,a,c){return e.format("mat3("+this.value.elements.join(", ")+")",o,r)}copy(e){return super.copy(e),this.elements=e.elements,this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var ja=class extends Ee{constructor(e=new Lr,r,n,o,a,c,f,h){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=r,this.crop=n,this.projection=o,this.axis=a,this.size=c,this.mat=new Os(this.texture.value.matrix),this.alpha=f,this.mode=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let n;switch(this.projection.value){case 3:n=e.include(ja.Nodes.cylindrical);break;case 2:n=e.include(ja.Nodes.spherical);break;case 1:let a=new we(`
150
150
  vec3 g${this.uuid.toString().replace(/-/g,"")}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
151
151
 
152
152
  vec2 uvs = ( mat * vec3( (g${this.uuid.toString().replace(/-/g,"")}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -597,7 +597,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
597
597
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
598
598
 
599
599
  return color.xyz;
600
- }`)}}();var up=(e=>(e.NOISE="noise",e.MAP="map",e))(up||{}),fp=class extends Ee{constructor(e=new Ke(0),r,n,o,a,c){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=r,this.movementOrTexture=n,Object.values(up)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Is(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=a,this.noiseFunctionIndex=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let n,o=[];switch(o.push("displaced_position"),o.push("displaced_normal"),Object.values(up)[this.displacementTypeIndex.value]){case"map":{n=e.include(fp.Nodes.map),o.push(this.movementOrTexture.getTexture(e,"t")),o.push("uv"),o.push(this.cropOrOffset.build(e,"f")),this.mat&&o.push(this.mat.build(e,"mat3"));break}case"noise":{let c=Object.values(Ha)[this.noiseFunctionIndex.value],f=new we(`vec3 orthogonal(vec3 v) {
600
+ }`)}}();var up=(e=>(e.NOISE="noise",e.MAP="map",e))(up||{}),fp=class extends Ee{constructor(e=new Ke(0),r,n,o,a,c){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=r,this.movementOrTexture=n,Object.values(up)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Os(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=a,this.noiseFunctionIndex=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let n,o=[];switch(o.push("displaced_position"),o.push("displaced_normal"),Object.values(up)[this.displacementTypeIndex.value]){case"map":{n=e.include(fp.Nodes.map),o.push(this.movementOrTexture.getTexture(e,"t")),o.push("uv"),o.push(this.cropOrOffset.build(e,"f")),this.mat&&o.push(this.mat.build(e,"mat3"));break}case"noise":{let c=Object.values(Ha)[this.noiseFunctionIndex.value],f=new we(`vec3 orthogonal(vec3 v) {
601
601
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
602
602
  }`),h=new we(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
603
603
  return p + n * ${c}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
@@ -617,7 +617,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
617
617
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
618
618
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
619
619
  return displaced_position;
620
- }`,[h,f]);n=e.include(d),o.push(this.scale.build(e,"f")),o.push(this.cropOrOffset.build(e,"v3")),o.push(this.movementOrTexture.build(e,"f"));break}}return o.push(this.intensity.build(e,"f")),o.push("displaced_normal"),e.format(n+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){var r,n;return super.copy(e),this.noiseFunctionIndex=(r=e.noiseFunctionIndex)==null?void 0:r.clone(),this.scale=(n=e.scale)==null?void 0:n.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},Os=fp;Os.Nodes=function(){let e=new we(`vec3 orthogonal(vec3 v) {
620
+ }`,[h,f]);n=e.include(d),o.push(this.scale.build(e,"f")),o.push(this.cropOrOffset.build(e,"v3")),o.push(this.movementOrTexture.build(e,"f"));break}}return o.push(this.intensity.build(e,"f")),o.push("displaced_normal"),e.format(n+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){var r,n;return super.copy(e),this.noiseFunctionIndex=(r=e.noiseFunctionIndex)==null?void 0:r.clone(),this.scale=(n=e.scale)==null?void 0:n.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},Ms=fp;Ms.Nodes=function(){let e=new we(`vec3 orthogonal(vec3 v) {
621
621
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
622
622
  }`),r=new we(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
623
623
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
@@ -659,7 +659,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
659
659
 
660
660
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
661
661
  return clamp(color, 0.0, 1.0).rgb;
662
- }`,[Gr.simplex,Gr.simplexFractal,Gr.simplexAshima,Gr.fbm,Gr.perlin]),h=e.include(f),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(h+"("+d.join(",")+")",this.getType(e),r)}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.alpha.copy(e.alpha),this.calpha=e.calpha,this.noiseType.copy(e.noiseType),this}};Ka.numOctaves=5;var Ya=class extends Ee{constructor(e=new Pe,r=new Pe,n=new Pe,o=new Pe){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=n,this.mode=o}generate(e,r){if(e.isShader("fragment")){let n=[];return n.push(this.a.build(e,"c")),n.push(this.b.build(e,"c")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),e.format("spe_blend("+n.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}};var Ms=class extends Ee{constructor(e,r,n,o,a,c,f,h,d,m,x,S){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=n,this.far=o,this.isVector=a,this.isWorldSpace=c,this.origin=f,this.direction=h,this.colors=d,this.steps=m,this.num=x,this.alpha=S,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let n=`g${this.uuid.toString().replace(/-/g,"")}`,o=new we(`vec3 ${n}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${n}_MAX_COLORS], float steps[10], float alpha, out float calpha) {
662
+ }`,[Gr.simplex,Gr.simplexFractal,Gr.simplexAshima,Gr.fbm,Gr.perlin]),h=e.include(f),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(h+"("+d.join(",")+")",this.getType(e),r)}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.alpha.copy(e.alpha),this.calpha=e.calpha,this.noiseType.copy(e.noiseType),this}};Ka.numOctaves=5;var Ya=class extends Ee{constructor(e=new Pe,r=new Pe,n=new Pe,o=new Pe){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=n,this.mode=o}generate(e,r){if(e.isShader("fragment")){let n=[];return n.push(this.a.build(e,"c")),n.push(this.b.build(e,"c")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),e.format("spe_blend("+n.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}};var Ps=class extends Ee{constructor(e,r,n,o,a,c,f,h,d,m,x,S){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=n,this.far=o,this.isVector=a,this.isWorldSpace=c,this.origin=f,this.direction=h,this.colors=d,this.steps=m,this.num=x,this.alpha=S,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let n=`g${this.uuid.toString().replace(/-/g,"")}`,o=new we(`vec3 ${n}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${n}_MAX_COLORS], float steps[10], float alpha, out float calpha) {
663
663
  vec4 color = colors[0];
664
664
  #ifdef ${n}_IS_VECTOR
665
665
  #ifdef ${n}_LINEAR
@@ -699,7 +699,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
699
699
 
700
700
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
701
701
  return color.rgb;
702
- }`,[Ms.Nodes.vectorLinearWorldSpaceDepth,Ms.Nodes.vectorLinearObjectSpaceDepth,Ms.Nodes.vectorSphericalObjectSpaceDepth,Ms.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${n}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${n}_SMOOTH`),this.isVector.value>.5&&e.define(`${n}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${n}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${n}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(o),c=[];return c.push(this.near.build(e,"f")),c.push(this.far.build(e,"f")),c.push(this.origin.build(e,"v3")),c.push(this.direction.build(e,"v3")),c.push(this.colors.build(e,"v4[]")),c.push(this.steps.build(e,"f[]")),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(a+"("+c.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.near=e.near.clone(),this.far=e.far.clone(),this.isVector=e.isVector.clone(),this.isWorldSpace=e.isWorldSpace.clone(),this.origin=e.origin.clone(),this.direction=e.direction.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},Xa=Ms;Xa.Nodes=function(){let e=new we(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
702
+ }`,[Ps.Nodes.vectorLinearWorldSpaceDepth,Ps.Nodes.vectorLinearObjectSpaceDepth,Ps.Nodes.vectorSphericalObjectSpaceDepth,Ps.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${n}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${n}_SMOOTH`),this.isVector.value>.5&&e.define(`${n}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${n}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${n}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(o),c=[];return c.push(this.near.build(e,"f")),c.push(this.far.build(e,"f")),c.push(this.origin.build(e,"v3")),c.push(this.direction.build(e,"v3")),c.push(this.colors.build(e,"v4[]")),c.push(this.steps.build(e,"f[]")),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(a+"("+c.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.near=e.near.clone(),this.far=e.far.clone(),this.isVector=e.isVector.clone(),this.isWorldSpace=e.isWorldSpace.clone(),this.origin=e.origin.clone(),this.direction=e.direction.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},Xa=Ps;Xa.Nodes=function(){let e=new we(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
703
703
  vec3 n = normalize(direction);
704
704
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
705
705
  return ( dist - near ) / ( far - near );
@@ -725,7 +725,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
725
725
 
726
726
  return matcapColor.rgb;
727
727
  }
728
- `)}}();var yr=class{constructor(t){this.id=2,this.layerCount=2,this.uuid=pi.generateUUID(),this.needsUpdate=!1,this._material=t,this._layerNodes=[];let e=this._createLayer({id:0,type:"color"});this._material.color=e.color,this._material.alpha===void 0&&(this._material.alpha=new ve(1));let r=new ve(1),n=new Ke(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=n),this._layerNodes.push({id:0,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),this._layerNodes.push({id:1,type:"light",alpha:r,mode:n}),this.head=e.layer,this.head.next=new Mt(1,void 0,{type:"light",alpha:r,mode:n}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(t){var o;this._material=t;let e,r,n=this.head;for(;n!==void 0;){if(n.type==="light"){e=n.uniforms[`f${n.id}_alpha`],r=n.uniforms[`f${n.id}_mode`];break}n=n.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=e,this._material.shadingBlend=r),this.attachLightNodes((o=t.userData.layers)==null?void 0:o.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(t){let e=[],r=this.head;for(;r;)r.type===t&&e.push(r),r=r.next;return e}addLayer(t){var n;if(t.id=(n=t.id)!=null?n:++this.id,this.layerCount++,t.type==="light"){let o=this.createLightLayer(t);return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}let e=this._createLayer(t),r=e.layer;if(this.head===void 0)this.head=r;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=r}return e.color&&this._layerNodes.push({id:r.id,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),e.position&&this._layerNodes.push({id:r.id,type:"position",position:e.position}),this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(t,e){var c;let r=this.head;t.id=(c=t.id)!=null?c:++this.id,this.layerCount++;let n=this._createLayer(t),o=n.layer;o.next=e;let a=0;if(r===e)this.head=o,n.color&&this._layerNodes.splice(0,0,{id:o.id,type:"color",color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(0,0,{id:o.id,type:"position",position:n.position});else{for(a=1;(r==null?void 0:r.next)!==e;)r=r==null?void 0:r.next,a++;r.next=o,n.color&&this._layerNodes.splice(a,0,{id:o.id,type:"color",color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(a,0,{id:o.id,type:"position",position:n.position})}return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}addLayerAt(t,e){var o;e.id=(o=e.id)!=null?o:++this.id,this.layerCount++;let r=this._createLayer(e),n=r.layer;if(r.color&&this._layerNodes.splice(t,0,{id:n.id,type:"color",color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(t,0,{id:n.id,type:"position",position:r.position}),t==0)n.next=this.head,this.head=n;else{let a=this.head,c=this.head.next;for(let f=0;f<t-1;f++)a=c,c=c.next;n.next=c,a.next=n}return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}removeLayer(t){let e=this.head,r,n=0;if((e==null?void 0:e.id)==t)this.head=e.next;else for(n=1,r=e,e=e==null?void 0:e.next;e!=null;){if(e.id==t){r.next=e.next;break}n++,r=e,e=e.next}return this.cleanupChangedLayer(e),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=pi.generateUUID(),this.layerCount--,n}changeLayer(t,e){let r,n=this.head,o;if((n==null?void 0:n.id)==t){let a=this._createLayer(j({id:t,uuid:n.uuid},e));o=a.layer,o.next=n.next,this.head=o,a.color&&(this._layerNodes[0]={id:o.id,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[0]={id:o.id,type:"position",position:a.position}),o.uniforms[`f${t}_mode`].value=n.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=n.uniforms[`f${t}_alpha`].value}else{r=n,n=n.next;let a=1;for(;n!=null;){if(n.id==t){let c=this._createLayer(j({id:t,uuid:n.uuid},e));o=c.layer,r.next=o,o.next=n.next,c.color&&(this._layerNodes[a]={id:t,type:"color",color:c.color,alpha:c.alpha,mode:c.mode}),c.position&&(this._layerNodes[a]={id:t,type:"position",position:c.position}),o.uniforms[`f${t}_mode`].value=n.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=n.uniforms[`f${t}_alpha`].value;break}r=n,n=n.next,a++}}return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}getLayer(t){let e=this.head;for(;e!=null&&e.id!=t;)e=e.next;return e}getLayerByUuid(t){let e=this.head;for(;e!==void 0;){if(e.uuid===t)return e;e=e.next}}getLayers(){let t=[],e=this.head;for(;e!=null;)t.push(e),e=e.next;return t}getLayerPosition(t){let e=this.head,r=0;for(;e!==void 0&&e.id!=t;)r++,e=e.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(t,e){let r,n=this.head,o;if(t==0)r=this.head,this.head=r.next;else{for(let c=0;c<t;c++)o=n,n=n.next;o.next=n.next,r=n}if(n=this.head,o=void 0,e==0)r.next=this.head,this.head=r;else{for(let c=0;c<e-1;c++)n=n.next;r.next=n==null?void 0:n.next,n.next=r}let a=this._layerNodes.splice(t,1)[0];this._layerNodes.splice(e,0,a),this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(t){this.needsUpdate=!1,this.layerCount=t.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,t.head);let e=t.head,r=this.head;for(;e.next!=null;)this.rebuildLayerNodes(r,e.next),r=r.next,e=e.next;return this.id=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(t){let e=new ve(t.alpha),r=new Ke(t.mode);this._material.shadingAlpha=e,this._material.shadingBlend=r,this._layerNodes.push({id:t.id,type:"light",alpha:e,mode:r});let n=new Mt(t.id,void 0,{type:"light",alpha:e,mode:r});if(this.head===void 0)this.head=n;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=n}return this.attachLightNodes(this.getLightLayer()),n}rebuildLayerNodes(t,e,r=!1){if(e.type==="light"){let n=r?e.uniforms[`f${e.id}_alpha`]:new ve(e.uniforms[`f${e.id}_alpha`].value),o=r?e.uniforms[`f${e.id}_mode`]:new Ke(e.uniforms[`f${e.id}_mode`].value);this._material.shadingAlpha=n,this._material.shadingBlend=o,this._layerNodes.push({id:e.id,type:"light",alpha:n,mode:o}),this.head===void 0?this.head=new Mt(e.id,e.uuid,{type:"light",alpha:n,mode:o}):t&&(t.next=new Mt(e.id,e.uuid,{type:"light",alpha:n,mode:o})),this.attachLightNodes(e)}else{let n={type:e.type,id:e.id};for(let o in e.uniforms){let a=e.getName(o);if(!a)continue;let c=`f${e.id}_${a}`;if(Array.isArray(e.uniforms[c].value))n[a]=e.uniforms[c].value.map(f=>f.clone&&!r?f.clone():f);else{let f=e.uniforms[c].value;if(a==="transmissionDepthMap"){n[a]=f;continue}f!=null&&(n[a]=f.clone&&!r&&!f.isRenderTargetTexture?f.clone():f)}}this.addLayer(n)}}attachLightNodes(t){var n,o,a,c,f,h,d,m,x,S,w;let e={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":e.emissive=new yt((o=(n=t==null?void 0:t.getValue("emissive"))==null?void 0:n.clone())!=null?o:0);break;case"Phong":e.shininess=new ve((a=t==null?void 0:t.getValue("shininess"))!=null?a:30),e.specular=new yt((f=(c=t==null?void 0:t.getValue("specular"))==null?void 0:c.clone())!=null?f:1118481);break;case"Toon":e.shininess=new ve((h=t==null?void 0:t.getValue("shininess"))!=null?h:30),e.specular=new yt((m=(d=t==null?void 0:t.getValue("specular"))==null?void 0:d.clone())!=null?m:1118481);break;case"Physical":e.roughness=new ve((x=t==null?void 0:t.getValue("roughness"))!=null?x:.3),e.metalness=new ve((S=t==null?void 0:t.getValue("metalness"))!=null?S:0),e.reflectivity=new ve((w=t==null?void 0:t.getValue("reflectivity"))!=null?w:.5);break;default:break}Object.keys(e).forEach(B=>{this._material[B]=e[B],r.uniforms[`f${r.id}_${B}`]=e[B]})}clone(t){return new yr(t).copy(this)}toJSON(t){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(t)}}fromJSON(t,e,r){let n=new Mt(t.head.id,void 0,{type:t.head.type}).fromJSON(t.head,e),o=t.head.next,a=n;for(;o!=null;)a.next=new Mt(o.id,void 0,{type:o.type}).fromJSON(o,e),o=o.next,a=a.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,n,!0);let c=n;for(a=this.head;c.next!=null;)this.rebuildLayerNodes(a,c.next,!0),a=a.next,c=c.next;return this._material=r,this.id=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var e;let t=this.head;for(;t!==void 0&&t.type!=="light";)t=(e=t.next)!=null?e:t;return t}dispose(){let t=this.head;for(this._layerNodes=[],this.layerCount=0;t!==void 0;)t.hasOwnProperty("dispose")===!0&&t.dispose(),t=t.next;this.head=void 0}_createLayer(t){var r,n,o,a,c,f,h,d,m,x,S,w,B,O,T,M,F,k,N,te,A,b,V,P,R,E,G,ae,ne,xe,_e,Le,Ue,se,$,W,J,H,K,fe,me,ie,re,q,ee,Te,ce,le,he,pe,de,be,Se,Ie,ft,Ve,Lt,qe,_t,Wt,Rr,Ut,zr,mn,gn,pt,jt,ir,Co,Lo,To,Ki,Yi,No,Nr,Xi,qt,Kn,_o;let e=t.type;switch(e){case"color":{let Re=new yt((r=t.color)!=null?r:5855577),Ye=new ve((n=t.alpha)!=null?n:1),He=new gt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");He.keywords.alpha=Ye;let $e=new Ke((o=t.mode)!=null?o:0);return Re.alpha=Ye,{layer:new Mt(t.id,t.uuid,{type:e,color:Re,alpha:Ye,calpha:He,mode:$e}),color:Re,alpha:He,mode:$e}}case"texture":{let Re=(a=t.texture)!=null?a:new kn,Ye=Re.matrix;t.mat&&Ye.copy(t.mat),Re.needsUpdate=!0;let He=new ve((c=t.crop)!=null?c:0),$e=new Ke((f=t.projection)!=null?f:0),Qe=new Ke((h=t.axis)!=null?h:0),ot=new mr(t.size?new ji(t.size[0],t.size[1]):new ji(100,100)),dt=new ve((d=t.alpha)!=null?d:1),mt=new Ke((m=t.mode)!=null?m:0),at=new Tr(Re),vt=new gr((x=t.textureSize)!=null?x:new ki(Re.image?Re.image.width:0,Re.image?Re.image.height:0)),Bt=new Ua(at,vt,He,$e,Qe,ot,dt,mt),_r=new gt(Bt.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,texture:at,textureSize:vt,crop:He,projection:$e,axis:Qe,size:ot,mat:Bt.mat,alpha:dt,calpha:_r,mode:mt}),color:Bt,alpha:_r,mode:mt}}case"matcap":{let Re=(S=t.texture)!=null?S:new kn;Re.needsUpdate=!0;let Ye=new ve((w=t.alpha)!=null?w:1),He=new Tr(Re),$e=new Ke((B=t.mode)!=null?B:0),Qe=new Za(He,Ye,$e),ot=new gt(Qe.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,texture:He,alpha:Ye,calpha:ot,mode:$e}),color:Qe,alpha:ot,mode:$e}}case"fresnel":{let Re=new yt((O=t.color)!=null?O:16777215),Ye=new ve((T=t.bias)!=null?T:.1),He=new ve((M=t.scale)!=null?M:1),$e=new ve((F=t.intensity)!=null?F:2),Qe=new ve((k=t.factor)!=null?k:1),ot=new ve((N=t.alpha)!=null?N:1),dt=new Ke((te=t.mode)!=null?te:0),mt=new ka(Re,Ye,He,$e,Qe,ot,dt),at=new gt(mt.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,color:Re,bias:Ye,scale:He,intensity:$e,factor:Qe,alpha:ot,calpha:at,mode:dt}),color:mt,alpha:at,mode:dt}}case"rainbow":{let Re=new ve((A=t.filmThickness)!=null?A:30),Ye=new ve((b=t.movement)!=null?b:0),He=new gr((V=t.wavelengths)!=null?V:new ki(0,0,0)),$e=new ve((P=t.noiseStrength)!=null?P:0),Qe=new ve((R=t.noiseScale)!=null?R:1),ot=new gr((E=t.offset)!=null?E:new ki(0,0,0)),dt=new ve((G=t.alpha)!=null?G:1),mt=new Wa(Re,Ye,He,$e,Qe,ot,dt),at=new gt(mt.calpha,"f"),vt=new Ke((ae=t.mode)!=null?ae:0);return{layer:new Mt(t.id,t.uuid,{type:e,filmThickness:Re,movement:Ye,wavelengths:He,noiseStrength:$e,noiseScale:Qe,offset:ot,alpha:dt,calpha:at,mode:vt}),color:mt,alpha:at,mode:vt}}case"transmission":{let Re=new ve((ne=t.thickness)!=null?ne:10),Ye=new ve((xe=t.ior)!=null?xe:1.5),He=new ve((_e=t.roughness)!=null?_e:.5),$e=new mr((Le=t.transmissionSamplerSize)!=null?Le:new ji(2048,2048)),Qe=(Ue=t.transmissionSamplerMap)!=null?Ue:new kn,ot=(se=t.transmissionDepthMap)!=null?se:new kn,dt=new Tr(Qe),mt=new Tr(ot),at=window.innerWidth,vt=window.innerHeight,Bt=at>=vt?new mr(vt/at,1):new mr(1,at/vt),_r=new ve(($=t.alpha)!=null?$:1),yn=new qa(Re,Ye,He,$e,dt,mt,Bt,_r),xn=new gt(yn.calpha,"f"),Pn=new Ke((W=t.mode)!=null?W:0);return{layer:new Mt(t.id,t.uuid,{type:e,thickness:Re,ior:Ye,roughness:He,transmissionSamplerSize:$e,transmissionSamplerMap:dt,transmissionDepthMap:mt,aspectRatio:Bt,alpha:_r,calpha:xn,mode:Pn}),color:yn,alpha:xn,mode:Pn}}case"depth":{let Re=new Ke((J=t.gradientType)!=null?J:0),Ye=new Va((H=t.smooth)!=null?H:!1),He=new ve((K=t.near)!=null?K:50),$e=new ve((fe=t.far)!=null?fe:200),Qe=new ve((me=t.isVector)!=null?me:1),ot=new ve((ie=t.isWorldSpace)!=null?ie:0),dt=new gr((re=t.origin)!=null?re:new ki),mt=new gr((q=t.direction)!=null?q:new ki),at=new Ke((ee=t.num)!=null?ee:0),vt;t.colors?vt=new xo(at.value+1,t.colors):(vt=new xo(at.value+1,new mu(0,0,0,1)),vt.value[1]=new mu(1,1,1,1));let Bt;t.steps?Bt=new vo(t.steps.length,t.steps):(Bt=new vo(10,1),Bt.value[0]=0);let _r=new ve((Te=t.alpha)!=null?Te:1),yn=new Ke((ce=t.mode)!=null?ce:0),xn=new Xa(Re,Ye,He,$e,Qe,ot,dt,mt,vt,Bt,at,_r),Pn=new gt(xn.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,gradientType:Re,smooth:Ye,near:He,far:$e,isVector:Qe,isWorldSpace:ot,origin:dt,direction:mt,colors:vt,steps:Bt,num:at,alpha:_r,calpha:Pn,mode:yn}),color:xn,alpha:Pn,mode:yn}}case"noise":{let Re=new ve((le=t.scale)!=null?le:1),Ye=new gr((he=t.size)!=null?he:new ki(100,100,100)),He=new ve((pe=t.move)!=null?pe:1),$e=new mr((de=t.fA)!=null?de:new ji(1.7,9.2)),Qe=new mr((be=t.fB)!=null?be:new ji(8.3,2.8)),ot=new mr((Se=t.distortion)!=null?Se:new ji(1,1)),dt=new hi(t.colorA),mt=new hi(t.colorB),at=new hi(t.colorC),vt=new hi(t.colorD),Bt=new ve((Ie=t.alpha)!=null?Ie:1),_r=new Ke((ft=t.mode)!=null?ft:0),yn=new Ke((Ve=t.noiseType)!=null?Ve:0),xn=new Ka(Re,Ye,He,$e,Qe,ot,dt,mt,at,vt,Bt,yn),Pn=new gt(xn.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,scale:Re,size:Ye,move:He,fA:$e,fB:Qe,distortion:ot,colorA:dt,colorB:mt,colorC:at,colorD:vt,alpha:Bt,calpha:Pn,mode:_r,noiseType:yn}),color:xn,alpha:Pn,mode:_r}}case"normal":{let Re=new gr((Lt=t.cnormal)!=null?Lt:new ki(1,1,1)),Ye=new ve((qe=t.alpha)!=null?qe:1),He=new Ke((_t=t.mode)!=null?_t:0),$e=new $a(Re,Ye),Qe=new gt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Qe.keywords.alpha=Ye,{layer:new Mt(t.id,t.uuid,{type:e,cnormal:Re,alpha:Ye,calpha:Qe,mode:He}),color:$e,alpha:Qe,mode:He}}case"gradient":{let Re=new Ke((Wt=t.gradientType)!=null?Wt:0),Ye=new Va((Rr=t.smooth)!=null?Rr:!1),He;t.colors?He=new xo(t.colors.length,t.colors):(He=new xo(10,new mu(0,0,0,1)),He.value[1]=new mu(1,1,1,1));let $e;t.steps?$e=new vo(t.steps.length,t.steps):($e=new vo(10,1),$e.value[0]=0);let Qe=new mr((Ut=t.offset)!=null?Ut:new ji(0,0)),ot=new mr((zr=t.morph)!=null?zr:new ji(0,0)),dt=new ve((mn=t.angle)!=null?mn:0),mt=new ve((gn=t.alpha)!=null?gn:1),at=new Ke((pt=t.mode)!=null?pt:0),vt=new Ja(Re,Ye,He,$e,Qe,ot,dt,mt),Bt=new gt(vt.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,gradientType:Re,smooth:Ye,colors:He,steps:$e,offset:Qe,morph:ot,angle:dt,alpha:mt,calpha:Bt,mode:at}),color:vt,alpha:Bt,mode:at}}case"displace":{let Re=new Ke((jt=t.displacementType)!=null?jt:0);if(Re.value===0){let Ye=new gr((ir=t.offset)!=null?ir:new ki(0,0,0)),He=new ve((Co=t.scale)!=null?Co:10),$e=new ve((Lo=t.intensity)!=null?Lo:8),Qe=new ve((To=t.movement)!=null?To:1),ot=new ve((Ki=t.alpha)!=null?Ki:1),dt=new Ke((Yi=t.mode)!=null?Yi:0),mt=new Ke((No=t.noiseType)!=null?No:0),at=new Os(Re,$e,Qe,Ye,He,mt);return{layer:new Mt(t.id,t.uuid,{displacementType:Re,type:e,offset:Ye,scale:He,intensity:$e,movement:Qe,alpha:ot,mode:dt,noiseType:mt}),position:at}}else if(Re.value===1){let Ye=(Nr=t.texture)!=null?Nr:new kn,He=Ye.matrix;t.mat&&He.copy(t.mat),Ye.needsUpdate=!0;let $e=new ve((Xi=t.intensity)!=null?Xi:8),Qe=new Tr(Ye),ot=new ve((qt=t.crop)!=null?qt:0),dt=new ve((Kn=t.alpha)!=null?Kn:1),mt=new Ke((_o=t.mode)!=null?_o:0),at=new Os(Re,$e,Qe,ot);return{layer:new Mt(t.id,t.uuid,{displacementType:Re,type:e,intensity:$e,texture:Qe,crop:ot,mat:at.mat,alpha:dt,mode:mt}),position:at}}return{}}}return{}}blendColors(){let t=this._layerNodes.findIndex(r=>r.type==="color"),e=this._layerNodes.findIndex(r=>r.type==="light");if(t!==-1&&t<e){let r=this._layerNodes[t].color;for(let n=t+1;n<e;++n){let o=this._layerNodes[n];o.type==="color"&&(r=new Ya(r,o.color,o.alpha,o.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let t=new gt("outgoingLight","f"),e=this._layerNodes.findIndex(r=>r.type==="light");if(this._layerNodes.length>e+1){for(let r=e+1;r<this._layerNodes.length;++r){let n=this._layerNodes[r];n.type==="color"&&(t=new Ya(t,n.color,n.alpha,n.mode))}"afterColor"in this._material&&(this._material.afterColor=t)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let t=this._layerNodes.filter(e=>e.type==="position");if(t.length>0){let e=t[0].position;for(let r=1;r<t.length;++r)t[r]&&(e=new Br(e,t[r].position,Br.ADD),e=new Br(e,new ve(.5).setReadonly(!0),Br.MUL));this._material.position=e}else this._material.position=void 0}cleanupChangedLayer(t){switch(this._layerNodes=this._layerNodes.filter(e=>e.id!==t.id),t.type){case"displace":{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var Kr=class extends aD{constructor(e,r,n){super(n);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new Fa(new cr(cr.PROJECTION)),this.fragment=r!=null?r:new Fa(new yt(5855577)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,r){this.build({renderer:r}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(e){let r=new yr(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(n=>requestAnimationFrame(n));r.addLayerAt(1,{type:"texture",texture:e}),this.dispose()})(),r}clampUniformsForPreview(e,r){let n=(o,a,c)=>Math.min(Math.max(o,a),c);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type=="displace"){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let a=n(o.uniforms[`f${o.id}_intensity`].value,e,r);o.uniforms[`f${o.id}_intensity`].value=a}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type=="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){var n;e=e!=null?e:{};let r=(n=e.builder)!=null?n:new du;return r.setMaterial(this,e.renderer),r.build(this.vertex,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.fog=r.requires.fog,this.lights=r.requires.lights,this.transparent=r.requires.transparent||this.blending>sD,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let r=this.uuid;for(let n in e)this[n]=e[n];return this.uuid=r,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let r=this.userData.layers;this.userData.layers=void 0;let n=super.toJSON(e);return n.type="ShaderMaterial",n.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:r.toJSON(e)},n.vertex=this.vertex.toJSON(e).uuid,n.fragment=this.fragment.toJSON(e).uuid,delete n.vertexShader,delete n.fragmentShader,delete n.color,delete n.shininess,delete n.specular,delete n.roughness,delete n.metalness,delete n.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=n),this.userData.layers=r,n}fromJSON(e,r){var n;this.defines=(n=e.defines)!=null?n:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:lD,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,r,this)}};Object.defineProperties(Kr.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as cD,UniformsUtils as uD}from"three";var gu=class extends Pe{constructor(){super("basic");this.nodeType="Basic";this.color=new yt(5855577)}generate(e){let r;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(uD.merge([cD.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
728
+ `)}}();var yr=class{constructor(t){this.id=2,this.layerCount=2,this.uuid=pi.generateUUID(),this.needsUpdate=!1,this._material=t,this._layerNodes=[];let e=this._createLayer({id:0,type:"color"});this._material.color=e.color,this._material.alpha===void 0&&(this._material.alpha=new ve(1));let r=new ve(1),n=new Ke(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=n),this._layerNodes.push({id:0,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),this._layerNodes.push({id:1,type:"light",alpha:r,mode:n}),this.head=e.layer,this.head.next=new Mt(1,void 0,{type:"light",alpha:r,mode:n}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(t){var o;this._material=t;let e,r,n=this.head;for(;n!==void 0;){if(n.type==="light"){e=n.uniforms[`f${n.id}_alpha`],r=n.uniforms[`f${n.id}_mode`];break}n=n.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=e,this._material.shadingBlend=r),this.attachLightNodes((o=t.userData.layers)==null?void 0:o.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(t){let e=[],r=this.head;for(;r;)r.type===t&&e.push(r),r=r.next;return e}addLayer(t){var n;if(t.id=(n=t.id)!=null?n:++this.id,this.layerCount++,t.type==="light"){let o=this.createLightLayer(t);return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}let e=this._createLayer(t),r=e.layer;if(this.head===void 0)this.head=r;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=r}return e.color&&this._layerNodes.push({id:r.id,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),e.position&&this._layerNodes.push({id:r.id,type:"position",position:e.position}),this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(t,e){var c;let r=this.head;t.id=(c=t.id)!=null?c:++this.id,this.layerCount++;let n=this._createLayer(t),o=n.layer;o.next=e;let a=0;if(r===e)this.head=o,n.color&&this._layerNodes.splice(0,0,{id:o.id,type:"color",color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(0,0,{id:o.id,type:"position",position:n.position});else{for(a=1;(r==null?void 0:r.next)!==e;)r=r==null?void 0:r.next,a++;r.next=o,n.color&&this._layerNodes.splice(a,0,{id:o.id,type:"color",color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(a,0,{id:o.id,type:"position",position:n.position})}return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}addLayerAt(t,e){var o;e.id=(o=e.id)!=null?o:++this.id,this.layerCount++;let r=this._createLayer(e),n=r.layer;if(r.color&&this._layerNodes.splice(t,0,{id:n.id,type:"color",color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(t,0,{id:n.id,type:"position",position:r.position}),t==0)n.next=this.head,this.head=n;else{let a=this.head,c=this.head.next;for(let f=0;f<t-1;f++)a=c,c=c.next;n.next=c,a.next=n}return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}removeLayer(t){let e=this.head,r,n=0;if((e==null?void 0:e.id)==t)this.head=e.next;else for(n=1,r=e,e=e==null?void 0:e.next;e!=null;){if(e.id==t){r.next=e.next;break}n++,r=e,e=e.next}return this.cleanupChangedLayer(e),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=pi.generateUUID(),this.layerCount--,n}changeLayer(t,e){let r,n=this.head,o;if((n==null?void 0:n.id)==t){let a=this._createLayer(j({id:t,uuid:n.uuid},e));o=a.layer,o.next=n.next,this.head=o,a.color&&(this._layerNodes[0]={id:o.id,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[0]={id:o.id,type:"position",position:a.position}),o.uniforms[`f${t}_mode`].value=n.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=n.uniforms[`f${t}_alpha`].value}else{r=n,n=n.next;let a=1;for(;n!=null;){if(n.id==t){let c=this._createLayer(j({id:t,uuid:n.uuid},e));o=c.layer,r.next=o,o.next=n.next,c.color&&(this._layerNodes[a]={id:t,type:"color",color:c.color,alpha:c.alpha,mode:c.mode}),c.position&&(this._layerNodes[a]={id:t,type:"position",position:c.position}),o.uniforms[`f${t}_mode`].value=n.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=n.uniforms[`f${t}_alpha`].value;break}r=n,n=n.next,a++}}return this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}getLayer(t){let e=this.head;for(;e!=null&&e.id!=t;)e=e.next;return e}getLayerByUuid(t){let e=this.head;for(;e!==void 0;){if(e.uuid===t)return e;e=e.next}}getLayers(){let t=[],e=this.head;for(;e!=null;)t.push(e),e=e.next;return t}getLayerPosition(t){let e=this.head,r=0;for(;e!==void 0&&e.id!=t;)r++,e=e.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(t,e){let r,n=this.head,o;if(t==0)r=this.head,this.head=r.next;else{for(let c=0;c<t;c++)o=n,n=n.next;o.next=n.next,r=n}if(n=this.head,o=void 0,e==0)r.next=this.head,this.head=r;else{for(let c=0;c<e-1;c++)n=n.next;r.next=n==null?void 0:n.next,n.next=r}let a=this._layerNodes.splice(t,1)[0];this._layerNodes.splice(e,0,a),this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=pi.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(t){this.needsUpdate=!1,this.layerCount=t.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,t.head);let e=t.head,r=this.head;for(;e.next!=null;)this.rebuildLayerNodes(r,e.next),r=r.next,e=e.next;return this.id=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(t){let e=new ve(t.alpha),r=new Ke(t.mode);this._material.shadingAlpha=e,this._material.shadingBlend=r,this._layerNodes.push({id:t.id,type:"light",alpha:e,mode:r});let n=new Mt(t.id,void 0,{type:"light",alpha:e,mode:r});if(this.head===void 0)this.head=n;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=n}return this.attachLightNodes(this.getLightLayer()),n}rebuildLayerNodes(t,e,r=!1){if(e.type==="light"){let n=r?e.uniforms[`f${e.id}_alpha`]:new ve(e.uniforms[`f${e.id}_alpha`].value),o=r?e.uniforms[`f${e.id}_mode`]:new Ke(e.uniforms[`f${e.id}_mode`].value);this._material.shadingAlpha=n,this._material.shadingBlend=o,this._layerNodes.push({id:e.id,type:"light",alpha:n,mode:o}),this.head===void 0?this.head=new Mt(e.id,e.uuid,{type:"light",alpha:n,mode:o}):t&&(t.next=new Mt(e.id,e.uuid,{type:"light",alpha:n,mode:o})),this.attachLightNodes(e)}else{let n={type:e.type,id:e.id};for(let o in e.uniforms){let a=e.getName(o);if(!a)continue;let c=`f${e.id}_${a}`;if(Array.isArray(e.uniforms[c].value))n[a]=e.uniforms[c].value.map(f=>f.clone&&!r?f.clone():f);else{let f=e.uniforms[c].value;if(a==="transmissionDepthMap"){n[a]=f;continue}f!=null&&(n[a]=f.clone&&!r&&!f.isRenderTargetTexture?f.clone():f)}}this.addLayer(n)}}attachLightNodes(t){var n,o,a,c,f,h,d,m,x,S,w;let e={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":e.emissive=new yt((o=(n=t==null?void 0:t.getValue("emissive"))==null?void 0:n.clone())!=null?o:0);break;case"Phong":e.shininess=new ve((a=t==null?void 0:t.getValue("shininess"))!=null?a:30),e.specular=new yt((f=(c=t==null?void 0:t.getValue("specular"))==null?void 0:c.clone())!=null?f:1118481);break;case"Toon":e.shininess=new ve((h=t==null?void 0:t.getValue("shininess"))!=null?h:30),e.specular=new yt((m=(d=t==null?void 0:t.getValue("specular"))==null?void 0:d.clone())!=null?m:1118481);break;case"Physical":e.roughness=new ve((x=t==null?void 0:t.getValue("roughness"))!=null?x:.3),e.metalness=new ve((S=t==null?void 0:t.getValue("metalness"))!=null?S:0),e.reflectivity=new ve((w=t==null?void 0:t.getValue("reflectivity"))!=null?w:.5);break;default:break}Object.keys(e).forEach(B=>{this._material[B]=e[B],r.uniforms[`f${r.id}_${B}`]=e[B]})}clone(t){return new yr(t).copy(this)}toJSON(t){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(t)}}fromJSON(t,e,r){let n=new Mt(t.head.id,void 0,{type:t.head.type}).fromJSON(t.head,e),o=t.head.next,a=n;for(;o!=null;)a.next=new Mt(o.id,void 0,{type:o.type}).fromJSON(o,e),o=o.next,a=a.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,n,!0);let c=n;for(a=this.head;c.next!=null;)this.rebuildLayerNodes(a,c.next,!0),a=a.next,c=c.next;return this._material=r,this.id=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var e;let t=this.head;for(;t!==void 0&&t.type!=="light";)t=(e=t.next)!=null?e:t;return t}dispose(){let t=this.head;for(this._layerNodes=[],this.layerCount=0;t!==void 0;)t.hasOwnProperty("dispose")===!0&&t.dispose(),t=t.next;this.head=void 0}_createLayer(t){var r,n,o,a,c,f,h,d,m,x,S,w,B,O,T,M,F,k,N,te,A,b,V,P,R,E,G,ae,ne,xe,_e,Le,Ue,se,$,W,J,H,K,fe,me,ie,re,q,ee,Te,ce,le,he,pe,de,be,Se,Ie,ft,Ve,Lt,qe,_t,Wt,Rr,Ut,zr,mn,gn,pt,jt,ir,Lo,To,No,Ki,Yi,_o,Nr,Xi,qt,Kn,Io;let e=t.type;switch(e){case"color":{let Re=new yt((r=t.color)!=null?r:5855577),Ye=new ve((n=t.alpha)!=null?n:1),He=new gt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");He.keywords.alpha=Ye;let $e=new Ke((o=t.mode)!=null?o:0);return Re.alpha=Ye,{layer:new Mt(t.id,t.uuid,{type:e,color:Re,alpha:Ye,calpha:He,mode:$e}),color:Re,alpha:He,mode:$e}}case"texture":{let Re=(a=t.texture)!=null?a:new kn,Ye=Re.matrix;t.mat&&Ye.copy(t.mat),Re.needsUpdate=!0;let He=new ve((c=t.crop)!=null?c:0),$e=new Ke((f=t.projection)!=null?f:0),Qe=new Ke((h=t.axis)!=null?h:0),ot=new mr(t.size?new ji(t.size[0],t.size[1]):new ji(100,100)),dt=new ve((d=t.alpha)!=null?d:1),mt=new Ke((m=t.mode)!=null?m:0),at=new Lr(Re),vt=new gr((x=t.textureSize)!=null?x:new ki(Re.image?Re.image.width:0,Re.image?Re.image.height:0)),Bt=new Ua(at,vt,He,$e,Qe,ot,dt,mt),_r=new gt(Bt.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,texture:at,textureSize:vt,crop:He,projection:$e,axis:Qe,size:ot,mat:Bt.mat,alpha:dt,calpha:_r,mode:mt}),color:Bt,alpha:_r,mode:mt}}case"matcap":{let Re=(S=t.texture)!=null?S:new kn;Re.needsUpdate=!0;let Ye=new ve((w=t.alpha)!=null?w:1),He=new Lr(Re),$e=new Ke((B=t.mode)!=null?B:0),Qe=new Za(He,Ye,$e),ot=new gt(Qe.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,texture:He,alpha:Ye,calpha:ot,mode:$e}),color:Qe,alpha:ot,mode:$e}}case"fresnel":{let Re=new yt((O=t.color)!=null?O:16777215),Ye=new ve((T=t.bias)!=null?T:.1),He=new ve((M=t.scale)!=null?M:1),$e=new ve((F=t.intensity)!=null?F:2),Qe=new ve((k=t.factor)!=null?k:1),ot=new ve((N=t.alpha)!=null?N:1),dt=new Ke((te=t.mode)!=null?te:0),mt=new ka(Re,Ye,He,$e,Qe,ot,dt),at=new gt(mt.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,color:Re,bias:Ye,scale:He,intensity:$e,factor:Qe,alpha:ot,calpha:at,mode:dt}),color:mt,alpha:at,mode:dt}}case"rainbow":{let Re=new ve((A=t.filmThickness)!=null?A:30),Ye=new ve((b=t.movement)!=null?b:0),He=new gr((V=t.wavelengths)!=null?V:new ki(0,0,0)),$e=new ve((P=t.noiseStrength)!=null?P:0),Qe=new ve((R=t.noiseScale)!=null?R:1),ot=new gr((E=t.offset)!=null?E:new ki(0,0,0)),dt=new ve((G=t.alpha)!=null?G:1),mt=new Wa(Re,Ye,He,$e,Qe,ot,dt),at=new gt(mt.calpha,"f"),vt=new Ke((ae=t.mode)!=null?ae:0);return{layer:new Mt(t.id,t.uuid,{type:e,filmThickness:Re,movement:Ye,wavelengths:He,noiseStrength:$e,noiseScale:Qe,offset:ot,alpha:dt,calpha:at,mode:vt}),color:mt,alpha:at,mode:vt}}case"transmission":{let Re=new ve((ne=t.thickness)!=null?ne:10),Ye=new ve((xe=t.ior)!=null?xe:1.5),He=new ve((_e=t.roughness)!=null?_e:.5),$e=new mr((Le=t.transmissionSamplerSize)!=null?Le:new ji(2048,2048)),Qe=(Ue=t.transmissionSamplerMap)!=null?Ue:new kn,ot=(se=t.transmissionDepthMap)!=null?se:new kn,dt=new Lr(Qe),mt=new Lr(ot),at=window.innerWidth,vt=window.innerHeight,Bt=at>=vt?new mr(vt/at,1):new mr(1,at/vt),_r=new ve(($=t.alpha)!=null?$:1),yn=new qa(Re,Ye,He,$e,dt,mt,Bt,_r),xn=new gt(yn.calpha,"f"),Pn=new Ke((W=t.mode)!=null?W:0);return{layer:new Mt(t.id,t.uuid,{type:e,thickness:Re,ior:Ye,roughness:He,transmissionSamplerSize:$e,transmissionSamplerMap:dt,transmissionDepthMap:mt,aspectRatio:Bt,alpha:_r,calpha:xn,mode:Pn}),color:yn,alpha:xn,mode:Pn}}case"depth":{let Re=new Ke((J=t.gradientType)!=null?J:0),Ye=new Va((H=t.smooth)!=null?H:!1),He=new ve((K=t.near)!=null?K:50),$e=new ve((fe=t.far)!=null?fe:200),Qe=new ve((me=t.isVector)!=null?me:1),ot=new ve((ie=t.isWorldSpace)!=null?ie:0),dt=new gr((re=t.origin)!=null?re:new ki),mt=new gr((q=t.direction)!=null?q:new ki),at=new Ke((ee=t.num)!=null?ee:0),vt;t.colors?vt=new vo(at.value+1,t.colors):(vt=new vo(at.value+1,new mu(0,0,0,1)),vt.value[1]=new mu(1,1,1,1));let Bt;t.steps?Bt=new bo(t.steps.length,t.steps):(Bt=new bo(10,1),Bt.value[0]=0);let _r=new ve((Te=t.alpha)!=null?Te:1),yn=new Ke((ce=t.mode)!=null?ce:0),xn=new Xa(Re,Ye,He,$e,Qe,ot,dt,mt,vt,Bt,at,_r),Pn=new gt(xn.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,gradientType:Re,smooth:Ye,near:He,far:$e,isVector:Qe,isWorldSpace:ot,origin:dt,direction:mt,colors:vt,steps:Bt,num:at,alpha:_r,calpha:Pn,mode:yn}),color:xn,alpha:Pn,mode:yn}}case"noise":{let Re=new ve((le=t.scale)!=null?le:1),Ye=new gr((he=t.size)!=null?he:new ki(100,100,100)),He=new ve((pe=t.move)!=null?pe:1),$e=new mr((de=t.fA)!=null?de:new ji(1.7,9.2)),Qe=new mr((be=t.fB)!=null?be:new ji(8.3,2.8)),ot=new mr((Se=t.distortion)!=null?Se:new ji(1,1)),dt=new hi(t.colorA),mt=new hi(t.colorB),at=new hi(t.colorC),vt=new hi(t.colorD),Bt=new ve((Ie=t.alpha)!=null?Ie:1),_r=new Ke((ft=t.mode)!=null?ft:0),yn=new Ke((Ve=t.noiseType)!=null?Ve:0),xn=new Ka(Re,Ye,He,$e,Qe,ot,dt,mt,at,vt,Bt,yn),Pn=new gt(xn.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,scale:Re,size:Ye,move:He,fA:$e,fB:Qe,distortion:ot,colorA:dt,colorB:mt,colorC:at,colorD:vt,alpha:Bt,calpha:Pn,mode:_r,noiseType:yn}),color:xn,alpha:Pn,mode:_r}}case"normal":{let Re=new gr((Lt=t.cnormal)!=null?Lt:new ki(1,1,1)),Ye=new ve((qe=t.alpha)!=null?qe:1),He=new Ke((_t=t.mode)!=null?_t:0),$e=new $a(Re,Ye),Qe=new gt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Qe.keywords.alpha=Ye,{layer:new Mt(t.id,t.uuid,{type:e,cnormal:Re,alpha:Ye,calpha:Qe,mode:He}),color:$e,alpha:Qe,mode:He}}case"gradient":{let Re=new Ke((Wt=t.gradientType)!=null?Wt:0),Ye=new Va((Rr=t.smooth)!=null?Rr:!1),He;t.colors?He=new vo(t.colors.length,t.colors):(He=new vo(10,new mu(0,0,0,1)),He.value[1]=new mu(1,1,1,1));let $e;t.steps?$e=new bo(t.steps.length,t.steps):($e=new bo(10,1),$e.value[0]=0);let Qe=new mr((Ut=t.offset)!=null?Ut:new ji(0,0)),ot=new mr((zr=t.morph)!=null?zr:new ji(0,0)),dt=new ve((mn=t.angle)!=null?mn:0),mt=new ve((gn=t.alpha)!=null?gn:1),at=new Ke((pt=t.mode)!=null?pt:0),vt=new Ja(Re,Ye,He,$e,Qe,ot,dt,mt),Bt=new gt(vt.calpha,"f");return{layer:new Mt(t.id,t.uuid,{type:e,gradientType:Re,smooth:Ye,colors:He,steps:$e,offset:Qe,morph:ot,angle:dt,alpha:mt,calpha:Bt,mode:at}),color:vt,alpha:Bt,mode:at}}case"displace":{let Re=new Ke((jt=t.displacementType)!=null?jt:0);if(Re.value===0){let Ye=new gr((ir=t.offset)!=null?ir:new ki(0,0,0)),He=new ve((Lo=t.scale)!=null?Lo:10),$e=new ve((To=t.intensity)!=null?To:8),Qe=new ve((No=t.movement)!=null?No:1),ot=new ve((Ki=t.alpha)!=null?Ki:1),dt=new Ke((Yi=t.mode)!=null?Yi:0),mt=new Ke((_o=t.noiseType)!=null?_o:0),at=new Ms(Re,$e,Qe,Ye,He,mt);return{layer:new Mt(t.id,t.uuid,{displacementType:Re,type:e,offset:Ye,scale:He,intensity:$e,movement:Qe,alpha:ot,mode:dt,noiseType:mt}),position:at}}else if(Re.value===1){let Ye=(Nr=t.texture)!=null?Nr:new kn,He=Ye.matrix;t.mat&&He.copy(t.mat),Ye.needsUpdate=!0;let $e=new ve((Xi=t.intensity)!=null?Xi:8),Qe=new Lr(Ye),ot=new ve((qt=t.crop)!=null?qt:0),dt=new ve((Kn=t.alpha)!=null?Kn:1),mt=new Ke((Io=t.mode)!=null?Io:0),at=new Ms(Re,$e,Qe,ot);return{layer:new Mt(t.id,t.uuid,{displacementType:Re,type:e,intensity:$e,texture:Qe,crop:ot,mat:at.mat,alpha:dt,mode:mt}),position:at}}return{}}}return{}}blendColors(){let t=this._layerNodes.findIndex(r=>r.type==="color"),e=this._layerNodes.findIndex(r=>r.type==="light");if(t!==-1&&t<e){let r=this._layerNodes[t].color;for(let n=t+1;n<e;++n){let o=this._layerNodes[n];o.type==="color"&&(r=new Ya(r,o.color,o.alpha,o.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let t=new gt("outgoingLight","f"),e=this._layerNodes.findIndex(r=>r.type==="light");if(this._layerNodes.length>e+1){for(let r=e+1;r<this._layerNodes.length;++r){let n=this._layerNodes[r];n.type==="color"&&(t=new Ya(t,n.color,n.alpha,n.mode))}"afterColor"in this._material&&(this._material.afterColor=t)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let t=this._layerNodes.filter(e=>e.type==="position");if(t.length>0){let e=t[0].position;for(let r=1;r<t.length;++r)t[r]&&(e=new Br(e,t[r].position,Br.ADD),e=new Br(e,new ve(.5).setReadonly(!0),Br.MUL));this._material.position=e}else this._material.position=void 0}cleanupChangedLayer(t){switch(this._layerNodes=this._layerNodes.filter(e=>e.id!==t.id),t.type){case"displace":{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var Kr=class extends iD{constructor(e,r,n){super(n);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new Fa(new cr(cr.PROJECTION)),this.fragment=r!=null?r:new Fa(new yt(5855577)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,r){this.build({renderer:r}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(e){let r=new yr(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(n=>requestAnimationFrame(n));r.addLayerAt(1,{type:"texture",texture:e}),this.dispose()})(),r}clampUniformsForPreview(e,r){let n=(o,a,c)=>Math.min(Math.max(o,a),c);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type=="displace"){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let a=n(o.uniforms[`f${o.id}_intensity`].value,e,r);o.uniforms[`f${o.id}_intensity`].value=a}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type=="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){var n;e=e!=null?e:{};let r=(n=e.builder)!=null?n:new du;return r.setMaterial(this,e.renderer),r.build(this.vertex,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.fog=r.requires.fog,this.lights=r.requires.lights,this.transparent=r.requires.transparent||this.blending>nD,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let r=this.uuid;for(let n in e)this[n]=e[n];return this.uuid=r,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let r=this.userData.layers;this.userData.layers=void 0;let n=super.toJSON(e);return n.type="ShaderMaterial",n.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:r.toJSON(e)},n.vertex=this.vertex.toJSON(e).uuid,n.fragment=this.fragment.toJSON(e).uuid,delete n.vertexShader,delete n.fragmentShader,delete n.color,delete n.shininess,delete n.specular,delete n.roughness,delete n.metalness,delete n.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=n),this.userData.layers=r,n}fromJSON(e,r){var n;this.defines=(n=e.defines)!=null?n:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:oD,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,r,this)}};Object.defineProperties(Kr.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as sD,UniformsUtils as aD}from"three";var gu=class extends Pe{constructor(){super("basic");this.nodeType="Basic";this.color=new yt(5855577)}generate(e){let r;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(aD.merge([sD.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
729
729
  `));let o=["#include <beginnormal_vertex>",`
730
730
  #if !defined( USE_LAYER_DISPLACE )
731
731
  #include <defaultnormal_vertex>
@@ -745,7 +745,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
745
745
  `];n&&o.push(n.code,n.result?"displaced_position = "+n.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),o.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),r=o.join(`
746
746
  `)}else{this.color===void 0&&(this.color=new yt(5855577)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let n=this.color.flow(e,"c",{slot:"color"}),o=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=o!==void 0,e.addParsCode(["#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
747
747
  `));let c=["#include <normal_fragment_begin>",n.code];o&&c.push(o.code,"#ifdef ALPHATEST"," if ( "+o.result+" <= ALPHATEST ) discard;","#endif"),a?c.push(a.code,`vec3 outgoingLight = ${n.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`):c.push(`vec3 finalColor = ${n.result};`),o?c.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${o.result} );`):c.push("gl_FragColor = vec4("+n.result+", 1.0 );"),c.push("#include <fog_fragment>","#include <dithering_fragment>"),r=c.join(`
748
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var yu=class extends Kr{constructor(e=new gu,r){super(e,e,r);this.type="BasicNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}};var ur=class extends yu{constructor(t,e,r){super(e,t),this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new ur(void 0,n);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new ur(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as ov,UniformsUtils as fD}from"three";var xu=class extends Pe{constructor(){super("phong");this.nodeType="Phong";this.color=new yt(5855577),this.specular=new yt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(fD.merge([ov.fog,ov.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
748
+ `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var yu=class extends Kr{constructor(e=new gu,r){super(e,e,r);this.type="BasicNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}};var ur=class extends yu{constructor(t,e,r){super(e,t),this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new ur(void 0,n);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new ur(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as sv,UniformsUtils as lD}from"three";var xu=class extends Pe{constructor(){super("phong");this.nodeType="Phong";this.color=new yt(5855577),this.specular=new yt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(lD.merge([sv.fog,sv.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
749
749
  `));let o=["#include <beginnormal_vertex>",`
750
750
  #ifndef USE_LAYER_DISPLACE
751
751
  #include <defaultnormal_vertex>
@@ -779,7 +779,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
779
779
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result}, ${f.result} );
780
780
  }
781
781
  `),h&&m.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
782
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var vu=class extends Kr{constructor(e=new xu,r){super(e,e,r);this.type="PhongNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var Yr=class extends vu{constructor(t,e,r){super(e,t),this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new Yr(void 0,n);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new Yr(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as sv,UniformsUtils as hD}from"three";var bu=class extends Pe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new yt(5855577),this.emissive=new yt(0),this.emissiveIntensity=new ve(1),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(hD.merge([sv.fog,sv.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
782
+ `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var vu=class extends Kr{constructor(e=new xu,r){super(e,e,r);this.type="PhongNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var Yr=class extends vu{constructor(t,e,r){super(e,t),this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new Yr(void 0,n);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new Yr(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as av,UniformsUtils as cD}from"three";var bu=class extends Pe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new yt(5855577),this.emissive=new yt(0),this.emissiveIntensity=new ve(1),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(cD.merge([av.fog,av.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
783
783
  `));let o=["#include <beginnormal_vertex>",`
784
784
  #ifndef USE_LAYER_DISPLACE
785
785
  #include <defaultnormal_vertex>
@@ -885,7 +885,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
885
885
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result}, ${f.result} );
886
886
  }
887
887
  `),h&&m.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
888
- `)}return r}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var Su=class extends Kr{constructor(e=new bu,r){super(e,e,r);this.type="LambertNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}};var Ps=class extends Su{constructor(t,e,r){super(e,t),this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new Ps(void 0,n);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as av,UniformsUtils as pD}from"three";var wu=class extends Pe{constructor(){super("toon");this.nodeType="Toon";this.color=new yt(5855577),this.specular=new yt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(pD.merge([av.fog,av.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
888
+ `)}return r}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var Su=class extends Kr{constructor(e=new bu,r){super(e,e,r);this.type="LambertNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}};var As=class extends Su{constructor(t,e,r){super(e,t),this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new As(void 0,n);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as lv,UniformsUtils as uD}from"three";var wu=class extends Pe{constructor(){super("toon");this.nodeType="Toon";this.color=new yt(5855577),this.specular=new yt(1118481),this.shininess=new ve(30),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(uD.merge([lv.fog,lv.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
889
889
  `));let o=["#include <beginnormal_vertex>",`
890
890
  #ifndef USE_LAYER_DISPLACE
891
891
  #include <defaultnormal_vertex>
@@ -939,7 +939,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
939
939
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result}, ${f.result} );
940
940
  }
941
941
  `),h&&m.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
942
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Cu=class extends Kr{constructor(e=new wu,r){super(e,e,r);this.type="ToonNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var As=class extends Cu{constructor(t,e,r){super(e,t),this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new As(void 0,n);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as pp,UniformsUtils as dD}from"three";var Lu=class extends Pe{constructor(){super("standard");this.nodeType="Standard";this.color=new yt(5855577),this.roughness=new ve(.3),this.metalness=new ve(0),this.reflectivity=new ve(.5),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(dD.merge([pp.fog,pp.lights])),pp.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
942
+ `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Cu=class extends Kr{constructor(e=new wu,r){super(e,e,r);this.type="ToonNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var Ds=class extends Cu{constructor(t,e,r){super(e,t),this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new Ds(void 0,n);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as pp,UniformsUtils as fD}from"three";var Lu=class extends Pe{constructor(){super("standard");this.nodeType="Standard";this.color=new yt(5855577),this.roughness=new ve(.3),this.metalness=new ve(0),this.reflectivity=new ve(.5),this.shadingAlpha=new ve(1),this.shadingBlend=new Ke(0)}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(fD.merge([pp.fog,pp.lights])),pp.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
943
943
  `));let o=["#include <beginnormal_vertex>",`
944
944
  #if !defined( USE_LAYER_DISPLACE )
945
945
  #include <defaultnormal_vertex>
@@ -973,5 +973,5 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
973
973
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${f.result}, ${h.result} );
974
974
  }
975
975
  `),d&&S.push(d.code,`outgoingLight = spe_blend(outgoingLight, ${d.result}, 1.0, SPE_BLENDING_NORMAL);`),m?S.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${m.result} );`):S.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),S.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=S.join(`
976
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Tu=class extends Kr{constructor(e=new Lu,r){super(e,e,r);this.type="StandardNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}};var Ds=class extends Tu{constructor(t,e,r){super(e,t),this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new Ds(void 0,n);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{Color as mp}from"three";import{Matrix3 as lv,Texture as dp,Vector2 as Qa,Vector3 as Hi,Vector4 as cv}from"three";function uv(i,t){switch(i.data.type){case"light":return In(i);case"fresnel":return gD(i,t);case"gradient":return yD(i);case"depth":return xD(i);case"normal":return vD(i);case"noise":return bD(i,t);case"texture":return SD(i,t);case"rainbow":return wD(i);case"transmission":return CD(i,t);case"matcap":return LD(i,t);case"displace":return TD(i);case"color":default:return mD(i,t)}}function fv(i){return{type:i.data.type}}function In(i){let{alpha:t,mode:e}=i.data;return ue(j({},fv(i)),{alpha:t,mode:e})}function mD(i,t){return ue(j({},In(i)),{color:Vt(i.data.color,t)})}function gD(i,t){let{bias:e,scale:r,intensity:n,factor:o,color:a}=i.data;return ue(j({},In(i)),{color:Vt(a,t),bias:e,scale:r,intensity:n,factor:o})}function yD(i){let{gradientType:t,smooth:e,colors:r,steps:n,angle:o,offset:a,morph:c}=i.data;return ue(j({},In(i)),{gradientType:t,smooth:e,colors:r.map(f=>new cv(f[0],f[1],f[2],f[3])),num:r.length,steps:n,offset:new Qa(...a),morph:new Qa(...c),angle:o})}function xD(i){let{gradientType:t,near:e,far:r,isVector:n,isWorldSpace:o,origin:a,direction:c,colors:f,steps:h,smooth:d,num:m}=i.data;return ue(j({},In(i)),{gradientType:t,near:e,far:r,isVector:n,isWorldSpace:o,origin:new Hi(...a),direction:c?new Hi(...c):new Hi(1,0,0),num:m,colors:f.map(x=>new cv(x[0],x[1],x[2],x[3])),steps:h,smooth:d})}function vD(i){let{cnormal:t}=i.data;return ue(j({},In(i)),{cnormal:new Hi(t[0],t[1],t[2])})}function bD(i,t){let{data:e}=i;return ue(j({},In(i)),{scale:e.scale,move:e.move,fA:new Qa(...e.fA),fB:new Qa(...e.fB),size:new Hi(...e.size),distortion:new Qa(...e.distortion),colorA:Vt(e.colorA,t),colorB:Vt(e.colorB,t),colorC:Vt(e.colorC,t),colorD:Vt(e.colorD,t),noiseType:e.noiseType})}function SD(i,t){let{projection:e,axis:r,crop:n,size:o}=i.data,{image:a,wrapping:c,repeat:f,offset:h}=i.data.texture,d=new dp,m;if(typeof a=="string")m=t==null?void 0:t.getImage(a);else{let x=new Image;x.src=a.data,x.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(a.data))},m=x}return d.image=m,d.repeat.set(f[0],f[1]),d.offset.set(h[0],h[1]),d.wrapS=d.wrapT=c,ue(j({},In(i)),{texture:d,mat:new lv().setUvTransform(h[0],h[1],f[0],f[1],0,0,0),crop:n,projection:e,axis:["x","y","z"].indexOf(r),size:o})}function wD(i){let{data:t}=i;return ue(j({},In(i)),{filmThickness:t.filmThickness,movement:t.movement,wavelengths:new Hi(...t.wavelengths),noiseStrength:t.noiseStrength,noiseScale:t.noiseScale,offset:new Hi(...t.offset)})}function CD(i,t){let{data:e}=i;return ue(j({},In(i)),{thickness:e.thickness,ior:e.ior,roughness:e.roughness,transmissionSamplerMap:t.transmissionSamplerMap,transmissionDepthMap:t.transmissionDepthMap})}function LD(i,t){let e=new dp,{image:r}=i.data.texture,n;if(typeof r=="string")n=t==null?void 0:t.getImage(r);else{let a=new Image;a.src=r.data,a.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(r.data))},n=a}e.image=n;let o=16777215;return ue(j({},In(i)),{color:o,texture:e})}function TD(i){let{data:t}=i,e=ue(j({},fv(i)),{intensity:t.intensity});if(t.displacementType==="noise")return ue(j({},e),{offset:new Hi(...t.offset),scale:t.scale,movement:t.movement,noiseType:t.noiseType});{let r=new dp,n=new lv().setUvTransform(0,0,1,1,0,0,0);return ue(j({},e),{texture:r,mat:n,crop:t.crop})}}function hv(i,t,e){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let r=t.uniforms[`f${t.id}_alpha`];return r?(r.value=e.alpha*(e.visible?1:0),r):void 0}}import{Color as mv,Vector4 as ND}from"three";var Es;(t=>{function i(e){return new mv(e.x,e.y,e.z).getHex()}t.getHex=i})(Es||(Es={}));var pv;(t=>{function i(e){return new ND(e.r,e.g,e.b,e.a)}t.getThreeVector4=i})(pv||(pv={}));var dv;(e=>{function i(r,n){r.setRGB(n.r,n.g,n.b)}e.setThreeColor=i;function t(r){return new mv(r.r,r.g,r.b).getHex()}e.getHex=t})(dv||(dv={}));function el(i,t){return typeof i=="string"?t.getMaterialOrDeletedPlaceholder(i):gp(i,t)}function gv(i,t){return i.map(e=>el(e,t))}function gp(i,t){var a,c;let e=(a=i.layers)!=null?a:ps.defaultTwoLayerData("phong").layers,r=_D(e),n;switch(r.category){case"basic":n=new ur;break;case"lambert":{n=new Ps;break}case"toon":{n=new As;break}case"physical":n=new Ds;break;case"phong":default:{n=new Yr;break}}n.name=(c=i.name)!=null?c:"Untitled Material";let o=n.userData.layers;ID(o);for(let f=e.length-1;f>=0;f--)OD(o,e[f],t);switch(r.category){case"basic":break;case"lambert":{let d=n,x=Vt(r.emissive,t);x instanceof mp?d.emissive.value=x:d.emissive.value.setHex(Es.getHex(x));break}case"toon":{let d=n,m=r;d.shininess.value=m.shininess;let x=Vt(m.specular,t);x instanceof mp?d.specular.value=x:d.specular.value.setHex(Es.getHex(x));break}case"physical":let f=n,h=r;f.metalness.value=h.metalness,f.roughness.value=h.roughness,f.reflectivity.value=h.reflectivity;break;case"phong":default:{let d=n,m=r;d.shininess.value=m.shininess;let x=Vt(m.specular,t);x instanceof mp?d.specular.value=x:d.specular.value.setHex(Es.getHex(x));break}}return o.blendColors(),o.blendAfterColors(),o.blendPositions(),n}function _D(i){for(let t of i)if(t.data.type==="light")return t.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:0}}function ID(i){for(let t of i.getLayers())i.removeLayer(t.id)}function OD(i,t,e){let r=uv(t,e);r.type==="transmission"&&(r.transmissionSamplerMap=e==null?void 0:e.transmissionSamplerMap,r.transmissionDepthMap=e==null?void 0:e.transmissionDepthMap);let n=i.addLayer(r);n.uuid=t.id;for(let o in t.data)hv(o,n,t.data)}import{Vector2 as yv}from"three";var Nu=new yv,Wi=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new yv(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,n=this.message.length;r<n;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,n;for(n=t;n>=0;n-=1)if(this.message[n].char===" "){r=!1,e.length===0&&(n-=1,e.splice(0,0,this.message[n]));break}else e.splice(0,0,this.message[n]);return r?e=[]:this.message.splice(n+1,e.length),e}getWord(t=0,e=1){let r=[],n=t;for(n=t;;n+=e){if(!this.message[n]||this.message[n].char===" "){r.length===0&&this.message[n]&&(r.push(this.message[n]),this.message.splice(n,1));break}e>0?(r.push(this.message[n]),this.message.splice(n,1),n-=e):(r.splice(0,0,this.message[n]),this.message.splice(n,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,n=t;for(;n>=0&&n<this.message.length;){if(this.message[n].char===" "){r===0&&(r=this.message[n].charSize);break}r+=this.message[n].charSize,n+=e}return(n<0||n>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let n=e;n<=r;n+=1)this.message[n].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,n,o){switch(r){case 1:this.leftAlign(t,o);break;case 3:this.centerAlign(this.spaceLeft(e),t,o);break;case 2:this.rightAlign(this.spaceLeft(e),t,o);break;case 4:this.justifyAlign(this.spaceLeft(e),t,o);break}}offsetCharacters(t,e,r){Nu.set(e,r);let n=this.message.length;for(let o=0;o<n;o++)this.message[o].updatePosition(this.message[o].localPosition.add(Nu),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let n=this.countSpaces();if(n===0){this.offsetCharacters(e,0,r);return}let o=t/n,a=0;for(let c=0;c<this.message.length;c++)this.message[c].char===" "&&(a+=o),Nu.set(a,r),this.message[c].updatePosition(this.message[c].localPosition.add(Nu),e)}clone(){let t=new Wi(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};import{DoubleSide as MD,EventDispatcher as PD,Matrix3 as AD,Vector3 as yp}from"three";var DD=new yp(0,0,1),xv=new yp,vv=new yp,bv=new AD,qi=class extends rr{constructor(e=ar.create({}),r=new ur({side:MD})){var n;super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new PD;this._onShapeUpdate=()=>{if(this.geometry instanceof Vi){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,r=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(r.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(n=this.shape.eventDispatcher)==null||n.addEventListener("update",this._onShapeUpdate)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="VectorObject",r}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){var r,n;this.shape&&((r=this.shape.eventDispatcher)==null||r.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(n=this.shape.eventDispatcher)==null||n.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),bv.getNormalMatrix(this.matrixWorld),xv.copy(DD).applyMatrix3(bv).normalize(),vv.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(xv,vv)}clone(e){let r=this.shape.clone(),n=this.material.clone(),o=this.geometry.userData,a=ar.create(Object.assign({},o,{shape:r})),c=new qi(a,n).copy(this,e);return c.shape=r,r.update(),c}raycast(e,r){rr.prototype.raycast.call(this,e,r)}};import{Camera as KD,OrthographicCamera as YD,PerspectiveCamera as XD,Vector3 as Xr,Object3D as Cv,Quaternion as ZD}from"three";import{BoxBufferGeometry as ED}from"three";var qn=i=>{var t;return t=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new ED(30,30,30),t};import{Camera as FD,LineSegments as VD,BufferGeometry as UD,LineBasicMaterial as jD,Color as vp,Vector3 as kD,Float32BufferAttribute as wv}from"three";import{Ray as BD,Sphere as GD,Matrix4 as RD,Vector3 as di}from"three";var _u=new BD,xp=new GD,Sv=new RD,$n=(i,t,e,r,n=!1)=>{let o=t,a=i.matrixWorld;if(o.boundingSphere===null&&o.computeBoundingSphere(),xp.copy(o.boundingSphere),xp.applyMatrix4(a),e.ray.intersectsSphere(xp)===!1||(Sv.copy(a).invert(),_u.copy(e.ray).applyMatrix4(Sv),o.boundingBox!==null&&_u.intersectsBox(o.boundingBox)===!1))return;let c,f,h,d,m=o.index,x=o.attributes.position,S=o.drawRange,w,B;if(n===!1){let T=Math.max(0,S.start),M=Math.min(m.count,S.start+S.count);for(w=T,B=M;w<B;w+=3)if(f=m.getX(w),h=m.getX(w+1),d=m.getX(w+2),c=O(i,e,_u,x,f,h,d),c){c.faceIndex=Math.floor(w/3),r.push(c);return}}else{let M=o.attributes.position,F=new di,k=new di,N=new di,te=new di,A=2,V=1/((i.scale.x+i.scale.y+i.scale.z)/3),P=V*V,R=Math.max(0,S.start),E=Math.min(M.count,S.start+S.count);for(let G=R,ae=E-1;G<ae;G+=A){if(F.fromBufferAttribute(M,G),k.fromBufferAttribute(M,G+1),_u.distanceSqToSegment(F,k,te,N)>P)continue;te.applyMatrix4(i.matrixWorld);let xe=e.ray.origin.distanceTo(te);xe<e.near||xe>e.far||r.push({distance:xe,point:N.clone().applyMatrix4(i.matrixWorld),object:i})}}function O(T,M,F,k,N,te,A){let b=new di,V=new di,P=new di,R=new di,E=new di;if(b.fromBufferAttribute(k,N),V.fromBufferAttribute(k,te),P.fromBufferAttribute(k,A),F.intersectTriangle(b,V,P,!1,R)===null)return null;E.copy(R),E.applyMatrix4(T.matrixWorld);let ae=M.ray.origin.distanceTo(E);return ae<M.near||ae>M.far?null:{faceIndex:1,distance:ae,point:E.clone(),object:T}}};var Iu=new kD,dn=new FD,bp=class extends VD{constructor(e){let r=new UD,n=new jD({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],c={},f=new vp(15711266),h=new vp(15711266),d=new vp(2857471);m("n1","n2",f),m("n2","n4",f),m("n4","n3",f),m("n3","n1",f),m("f1","f2",f),m("f2","f4",f),m("f4","f3",f),m("f3","f1",f),m("n1","f1",f),m("n2","f2",f),m("n3","f3",f),m("n4","f4",f),m("p","n1",h),m("p","n2",h),m("p","n3",h),m("p","n4",h),m("u1","u2",d),m("u2","u3",d),m("u3","u1",d);function m(S,w,B){x(S,B),x(w,B)}function x(S,w){o.push(0,0,0),a.push(w.r,w.g,w.b),c[S]===void 0&&(c[S]=[]),c[S].push(o.length/3-1)}r.setAttribute("position",new wv(o,3)),r.setAttribute("color",new wv(a,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=c,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;dn.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,c=n?.8:1e-4;On("n1",r,e,dn,-o,-a,c),On("n2",r,e,dn,o,-a,c),On("n3",r,e,dn,-o,a,c),On("n4",r,e,dn,o,a,c);let f=c;On("f1",r,e,dn,-o,-a,f),On("f2",r,e,dn,o,-a,f),On("f3",r,e,dn,-o,a,f),On("f4",r,e,dn,o,a,f);let h=f,d=.5;On("u1",r,e,dn,o*.7*d,a*1.1,h),On("u2",r,e,dn,-o*.7*d,a*1.1,h),On("u3",r,e,dn,0,a*(1.1+.9*d),h),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function On(i,t,e,r,n,o,a){Iu.set(n,o,a).unproject(r);let c=t[i];if(c!==void 0){let f=e.getAttribute("position");for(let h=0,d=c.length;h<d;h++)f.setXYZ(c[h],Iu.x,Iu.y,Iu.z)}}var Ou=class extends qn(bp){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){$n(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as HD}from"three";var Bs=class extends qn(HD){constructor(e,r=15,n=10066329){super(e,r,n);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){$n(this.object,Bs.geometryHelper,e,r)}};import{AxesHelper as WD}from"three";var Gs=class extends qn(WD){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){$n(this.object,Gs.geometryHelper,e,r)}update(){}};import{PointLightHelper as qD}from"three";var Rs=class extends qn(qD){constructor(e,r=15,n=6710886){super(e,r,n);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){$n(this.object,Rs.geometryHelper,e,r)}};import{SpotLightHelper as $D,Vector3 as JD}from"three";var Mu=class extends qn($D){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){$n(this.object,Mu.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=Mu._vector,r=this.object.distance?this.object.distance:1e3,n=r*Math.tan(this.object.angle);this.cone.scale.set(n,n,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let o=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,c=this.cone.material.length;a<c;a++)this.cone.material[a].color.set(o);else this.cone.material.color.set(o)}}},tl=Mu;tl._vector=new JD;var Jn=(i,t)=>class extends i{constructor(){super(...arguments);this.objectHelper=new t(this);this.enableHelper=!1}set visibility(n){this.visible=n,this.setHelperVisibility(n),this.setHelperChildrenVisibility(n)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(n){this.objectHelper.visible=n}setHelperChildrenVisibility(n){for(let o of this.children)hn(o)&&o.traverseEntity(a=>{fi(a)&&a.visible&&(a.objectHelper.visible=n)})}raycast(n,o){this.objectHelper.raycast(n,o)}copy(n,o=!0){return super.copy(n,o),n.enableHelper!==void 0&&(this.enableHelper=n.enableHelper),n.objectHelper!==void 0&&(this.objectHelper.visible=n.objectHelper.visible),this}toJSON(n){let o=super.toJSON(n),a=o.object;return a.enableHelper=this.enableHelper,o}fromJSON(n){return super.fromJSON(n),n.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(n,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let a=this;n.color!==void 0&&(a.color=Vt(n.color,o)),n.intensity!==void 0&&(a.intensity=n.intensity),n.depth!==void 0&&(a.shadow.camera.far=n.depth,a.shadow.needsUpdate=!0),n.shadows!==void 0&&(this.castShadow=n.shadows),n.helper!==void 0&&(this.enableHelper=n.helper,a.gizmos.shadowmap.visible=n.helper)}return this}};var zs=new Xr,Sp=new Xr,mi=class extends Jn(pn(KD),Ou){constructor(e=window.innerWidth,r=window.innerHeight,n=45,o,a=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=uo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new YD(e*-.5,e*.5,r*.5,r*-.5,o!=null?o:-5e4,a),this.perspCamera=new XD(n,e/r,o!=null?o:50,a),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,r){let n=new mi().fromState(r);return n.enableHelper=!0,n.objectHelper.update(),n.uuid=e,n}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(zs),this.targetOffset=zs.distanceTo(e)}getTarget(e=new Xr){return this.getWorldDirection(Sp),this.getWorldPosition(zs),Sp.multiplyScalar(this.targetOffset),e.copy(zs).add(Sp),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(zs),zs.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new ZD),r=new Xr(0,0,1).applyQuaternion(e),n=new Xr().copy(Cv.DefaultUp);this.isUpVectorFlipped&&n.negate(),n.applyQuaternion(e);let o=new Xr().copy(Cv.DefaultUp).projectOnPlane(r),a=new Xr().crossVectors(o,n).dot(r)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(n)*a}getViewFrontToObject(e){let r=e.getWorldPosition(new Xr),o=e.getWorldDirection(new Xr).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToObject(e){let r=e.getWorldPosition(new Xr),o=this.getWorldDirection(new Xr).multiplyScalar(this.targetOffset);return{position:r.clone().sub(o),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,o,a,c){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,o,a,c):this.orthoCamera.setViewOffset(e,r,n,o,a,c)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},n={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=n.near,this.perspCamera.far=n.far,this.updateProjectionMatrix(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="CombinedCamera",n.cameraType=this.cameraType,n.targetOffset=this.targetOffset,n.isUpVectorFlipped=this.isUpVectorFlipped,n.angleOffsetFromUp=this.angleOffsetFromUp,n.left=this.left,n.right=this.right,n.top=this.top,n.bottom=this.bottom,this.view!==null&&(n.view=Object.assign({},this.view)),n.zoomOrtho=this.orthoCamera.zoom,n.nearOrtho=this.orthoCamera.near,n.far=this.far,n.aspect=this.aspect,n.fov=this.fov,n.focus=this.focus,n.filmGauge=this.filmGauge,n.filmOffset=this.filmOffset,n.zoomPersp=this.perspCamera.zoom,n.nearPersp=this.perspCamera.near,r}fromJSON(e){var r;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let n=this.getWorldPosition(new Xr),o=new Xr().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(n)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(r=e.angleOffsetFromUp)!=null?r:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return os(r,e)}fromCameraState(e){let{orthographic:r,perspective:n}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),n!==void 0&&(n.near!==void 0&&(this.perspCamera.near=n.near),n.fov!==void 0&&(this.perspCamera.fov=n.fov),n.zoom!==void 0&&(this.perspCamera.zoom=n.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return ue(j(j({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as QD}from"three";var gi=class extends Jn(pn(QD),Gs){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let n=new gi().fromState(r);return n.uuid=e,n.enableHelper=!0,n.objectHelper.update(),n}toJSON(e){let r=super.toJSON(e);return r.object.objectType="EmptyObject",r}};import{DirectionalLight as e3,CameraHelper as Pu}from"three";var Fs=class extends Jn(pn(e3),Bs){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=1,n.far=2500;let o=new Pu(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,n){let o=new Fs().fromState(r,n);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Pu&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Pu&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Pu&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="LightDirectional",n.color=this.color.getHex(),n.intensity=this.intensity,n.shadow=this.shadow.toJSON(),r}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let r=this.shadow.camera,n=e.shadow.camera;return r.near=n.near,r.far=n.far,r.zoom=n.zoom,r.left=n.left,r.right=n.right,r.top=n.top,r.bottom=n.bottom,n.view!==void 0&&(r.view=Object.assign({},n.view)),this}fromDirectionalLightState(e,r){let n=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,r),e.size!==void 0&&q0(this,e.size),n&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as t3,Vector3 as Au,Box3 as r3,Box3Helper as Du,Color as n3}from"three";var Vs=class extends Jn(pn(t3),Rs){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let o=new Au(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new Au(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),c=new r3(o,a),f=new Du(c,new n3(16755200));f.visible=!1,this._gizmos.shadowmap=f,this.update()}static createFromState(e,r,n){let o=new Vs().fromState(r,n);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Du&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Du&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof Du){let n=this.shadow.camera,o=new Au(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new Au(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z);r.box.set(o,a),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="LightPoint",n.color=this.color.getHex(),n.intensity=this.intensity,n.distance=this.distance,n.decay=this.decay,n.shadow=this.shadow.toJSON(),r}fromJSON(e){var o,a;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((a=e.shadow.mapSize)!=null?a:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,n=e.shadow.camera;return r.near=n.near,r.far=n.far,r.zoom=n.zoom,r.fov=n.fov,r.focus=n.focus,r.aspect=n.aspect,r.filmGauge=n.filmGauge,r.filmOffset=n.filmOffset,n.view!==void 0&&(r.view=Object.assign({},n.view)),this}fromPointLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromPointLightState(e,r),this}};import{SpotLight as i3,CameraHelper as Eu,MathUtils as o3,Vector3 as _v,Quaternion as s3}from"three";var Lv=new _v,Tv=new _v,Nv=new s3,Us=class extends Jn(pn(i3),tl){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.fov=o3.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let o=new Eu(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,n){let o=new Us().fromState(r,n);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Eu&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Eu&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Eu&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Tv.setFromMatrixPosition(this.matrixWorld),Nv.setFromRotationMatrix(this.matrixWorld),Lv.copy(this.up).applyQuaternion(Nv).negate().multiplyScalar(this.distance),this.target.position.copy(Tv).add(Lv),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="LightSpot",n.color=this.color.getHex(),n.intensity=this.intensity,n.distance=this.distance,n.angle=this.angle,n.decay=this.decay,n.penumbra=this.penumbra,n.shadow=this.shadow.toJSON(),r}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let r=this.shadow.camera,n=e.shadow.camera;return r.near=n.near,r.far=n.far,r.zoom=n.zoom,r.fov=n.fov,r.focus=n.focus,r.aspect=n.aspect,r.filmGauge=n.filmGauge,r.filmOffset=n.filmOffset,n.view!==void 0&&(r.view=Object.assign({},n.view)),this}fromSpotLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};import{VideoTexture as a3}from"three";var Iv=i=>i.tagName==="VIDEO",bo=class{static resize(t,e,r){let n=t/e,o;if(!r.image)return;let a=r.image;Iv(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,n>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/n):r.repeat.set(1,1*o/n)),n<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/o*-1,1):r.repeat.set(1*n/o,1)),n==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let n=t/e,o=r.image!==void 0?r.image.width/r.image.height:1,a;n>o?a={x:1,y:o/n}:n<o?a={x:n/o,y:1}:a={x:1,y:1},r.repeat.set(a.x,a.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let n=r.userData.layers,o=n.getLayers();for(let a=0;a<o.length;a++){let c=o[a];rv(c)&&(bo.resizeTextureLayer(t,e,c.uniforms[`f${c.id}_texture`].value),n.updateLayerUniform())}}static resizeComplex(t,e,r,n){let o=t/e,a,c=r.image;Iv(c)?a=c.videoWidth/c.videoHeight:a=c.width/c.height,n.geometry.type.includes("Shape")?(o>a&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*a/o):r.repeat.set(1/t,1/e*a/o)),o<a&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*o/a*-1,1/e):r.repeat.set(1/t*o/a,1/e)),o==a&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(o>a&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*a/o):r.repeat.set(1,1*a/o)),o<a&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/a*-1,1):r.repeat.set(1*o/a,1)),o==a&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var js=class extends rr{constructor(e,r=new ur){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&bo.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,r){super.resizeGeometry(e,r,0),this.material.userData.layers&&bo.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh2D",r}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let r,n;if(e instanceof a3){let c=e.image;r=c.videoWidth*.5,n=c.videoHeight*.5}else{let c=e.image;r=c.width*.5,n=c.height*.5}let o=au.create({parameters:{width:r,height:n}}),a=new ur;return a.layersList.changeLayer(0,{type:"texture",texture:e}),a.layersList.moveLayer(0,1),a.dispose(),new js(o,a)}};var ks=class extends rr{constructor(e,r=new Yr){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh3D",r}};var Hs=class extends ks{constructor(e,r=new Yr){super(e,r);this.objectType="NonParametric"}toJSON(e){let r=super.toJSON(e);return r.object.objectType="NonParametric",r}};var wp=class extends rr{constructor(e,r=new ur({transparent:!0,opacity:1,visible:!1,side:Bu})){super(e,r);this.objectType="TextFrame";this.charContainer=new l3,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new Mv(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,n){let o=lu.create({parameters:{width:r.width,height:r.height}}),a=new wp(o).fromState(r,n);return a.uuid=e,a}async updateText(e){this.clearText();let r=this.userData.textFrame,n=r.fontFamily;await Cr.loadFont(n),r.text=e;let o=r.textOrigin,a=new Ov({visible:r.visible,transparent:!0,side:Bu}),c=e.split(`
977
- `),f=0;this.userData.textFrame.textLines=c.map((h,d)=>{let m=new Wi(f,r.lineHeight,r.fontSize);return m.message=h.split("").map(x=>{let S={char:x,fontFamily:n,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},w=a.clone();w.color=r.hexColor,w.opacity=r.opacity;let B=new Cr(S,w);return m.addChar3D(B,o),this.charContainer.add(B),B}),f+=m.maxCharSize*m.lineHeight,m}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let n=[];if(super.raycast(e,n),n.length>0){r.push(n[0]);return}let o=[];for(let a=0,c=this.charContainer.children.length;a<c;++a)if(this.charContainer.children[a]instanceof Cr&&(e.intersectObject(this.charContainer.children[a],!1,o),o.length>0)){o[0].object=this,r.push(o[0]);return}}updateGeometry(e){var d,m,x,S;let r=this.userData,n=this.geometry.userData,o=n.parameters.width,a=n.parameters.height,c=(m=(d=e.parameters)==null?void 0:d.width)!=null?m:o,f=(S=(x=e.parameters)==null?void 0:x.height)!=null?S:a,h=r.textFrame;super.updateGeometry(e),h.maxLineSize=c,h.textOrigin.set(-.5*c,.5*f,0),f!==a?(this.checkOverFlow(),this.checkCapacity()):c!==o&&(o<c?this.checkCapacity():o>c&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,n=r.textFrame.textOrigin,o=r.textFrame.textLines;for(let a=e;a<o.length;a++){o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(n);let c=[];for(;o[a].checkOverFlow(r.textFrame.maxLineSize);)o[a].containSpaceOverFlow()?c.unshift(o[a].getWord(o[a].message.length-1,-1)):c.unshift(o[a].popChar());if(c.length>0){o[a+1]===void 0?(o[a].isEndLine(!1),this.createTextLine()):o[a].endLine&&(this.createTextLine(a+1),o[a].isEndLine(!1),o[a+1].isEndLine(!0));let f=0;for(let h=0;h<c.length;h+=1)for(let d=0;d<c[h].length;d+=1)o[a+1].addChar3D(c[h][d],n,f),f+=1;o[a+1].fullUpdate(n)}o[a].fullUpdate(n)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,n=r.textFrame.textOrigin,o=r.textFrame.maxLineSize,a=r.textFrame.textLines;for(let c=e;c<a.length;c+=1)if(a[c].updateYLinePos(this.getNewLinePosition(c)),a[c].fullUpdate(n),!!a[c-1])for(;!a[c-1].endLine;){let f,h=a[c-1].spaceLeft(o);if(a[c].wordSize(0,1)<=h){a[c].containSpace()?f=a[c].getWord(0,1):f=a[c].popChar(0);for(let d=0;d<f.length;d+=1)f[d]&&a[c-1].addChar3D(f[d],n)}else{a[c].isEmpty()?(a[c].endLine&&a[c-1].isEndLine(!0),a.splice(c,1),c-=1):(a[c].updateYLinePos(this.getNewLinePosition(c)),a[c].fullUpdate(n));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let n=this.userData.textFrame;n.textLines.splice(e,0,new Wi(this.getNewLinePosition(e),n.lineHeight,n.fontSize))}textFullUpdate(e=0){let n=this.userData.textFrame,o=n.textLines,a=this.getVerticalAlignmentOffSet();for(let c=e;c<o.length;c++)o[c].updateYLinePos(this.getNewLinePosition(c)),o[c].fullUpdate(n.textOrigin),o[c].alignText(n.textOrigin,n.maxLineSize,n.horizontalAlignment,n.verticalAlignment,a)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(e){let n=this.userData.textFrame.textLines,o=0;for(let a=0;a<e;a+=1)o+=n[a].maxCharSize*n[a].lineHeight;return o}updateColor(e){var o;let r=this.userData;r.textFrame.hexColor=e;let n=r.textFrame.textLines;for(let a=0;a<n.length;a++){let c=n[a].message;for(let f=0;f<c.length;f++){let h=c[f].material;(o=h.color)!=null&&o.isColor&&(h.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let n=r.textFrame.textLines;for(let o=0;o<n.length;o++){let a=n[o].message;for(let c=0;c<a.length;c++){let f=a[c].material;f.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let n=r.textFrame.textLines;for(let o=0;o<n.length;o++){let a=n[o].message;for(let c=0;c<a.length;c++){let f=a[c].material;f.visible=e}}}async updateFontFamily(e){await Cr.loadFont(e);let n=this.userData.textFrame,o=n.textLines;n.fontFamily=e;for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)c[f].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let n=this.userData.textFrame,o=n.textLines,a=n.fontSize;n.fontSize=e;for(let c=0;c<o.length;c++)o[c].updateFontSize(e);this.textFullUpdate(),e>a?this.checkOverFlow():e<a&&this.checkCapacity()}async updateTextTransform(e){let n=this.userData.textFrame;await Cr.loadFont(n.fontFamily);let o=n.textLines;switch(n.textTransform=e,e){case 2:for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)o[a].message[f].updateChar(c[f].char.toUpperCase())}break;case 3:for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)o[a].message[f].updateChar(c[f].char.toLowerCase())}break;default:for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)o[a].message[f].updateChar(c[f].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,n=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let o=0;o<n.length;o++){let a=n[o].message;for(let c=0;c<a.length;c++)a[c].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let n=r.textFrame.textLines;for(let o=0;o<n.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,n=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let o=0;o<n.length;o++)n[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let r=super.toJSON(e),n=r.object;n.objectType="TextFrame";let a=this.userData.textFrame.textLines.map(c=>{let f=c.message.map(h=>({char:h.char,originalChar:h.originalChar,fontFamily:h.fontFamily,letterSpacing:h.letterSpacing,fontSize:h.fontSize,LOD:h.LOD}));return{align:c.align,endLine:c.endLine,lineHeight:c.lineHeight,maxCharSize:c.maxCharSize,yLinePos:c.yLinePos,message:f}});return n.userData.textFrame.textLinesData=a,r}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let r=e.userData.textFrame;await Cr.loadFont(r.fontFamily),r.textOrigin=new Mv(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let n=new Ov({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:Bu});r.textLinesData&&(r.textLines=r.textLinesData.map((o,a)=>{let c=new Wi(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),f=o.message.map((h,d)=>{if(h.char===void 0){let S=r.textLines[a].message[d];if("geometries"in S){let w=S.geometries[0].userData.parameters;Object.assign(h,{LOD:w.lod,char:w.char,fontFamily:w.fontFamily,fontSize:w.fontSize,letterSpacing:w.letterSpacing,originalChar:w.char})}}let m={char:h.char,fontFamily:h.fontFamily,letterSpacing:Number(h.letterSpacing),fontSize:Number(h.fontSize),LOD:h.LOD},x=new Cr(m,n.clone());return c.addChar3D(x,r.textOrigin),this.charContainer.add(x),x});return c.message=f,c}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(e,r){if(e.color!==void 0){let n=Vt(e.color,r);this.updateColor(n),this.updateOpacity(n.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}convertToVector(){let{fontFamily:e,hexColor:r}=this.userData.textFrame,n=new gi;n.name="Text Shape";let o=Cr.fontCache[e];for(let a of this.charContainer.children)a instanceof Cr&&o.generateShapes(a.char,1).forEach(c=>{let f=new nt().fromShape(c);f.applyScale(a.scale.x,a.scale.y);let h=ar.create({shape:f}),d=new ur({side:Bu});d.color=r;let m=new qi(h,d);m.name=a.char,m.position.copy(a.position),m.rotation.copy(a.rotation),n.attach(m)});return n}},So=wp;So.VerticalAlign=Sh,So.HorizontalAlign=bh,So.TextTransform=wh;import{HemisphereLight as C3,Scene as L3,Vector3 as T3,Color as Hv,Fog as N3,Box3 as _3}from"three";import{BufferGeometryLoader as c3}from"three";function Pv(i,t){return u3(i)}function u3(i){let t={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=nt.createFromState(i.shape,i.width,i.height);t.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>{var n;return r.materialIndex=Math.max((n=r.materialIndex)!=null?n:0,0)}),t.geometry=new c3().parse(i));let e;try{e=Aa(t)}catch(r){console.error(r)}if(!e){let r=nt.createFromState(ds.defaultData(),100,100);t.shape=r,e=Aa(t)}return e}import{Box3 as f3,Matrix4 as wo,Sphere as Ev,Vector3 as h3}from"three";var Gv=Qm(Dv());var Cp;cu.then(i=>{Cp=i});var Rv=new wo,p3=new wo,d3=new wo,Mn=new f3,$i=new h3,m3=new wo,g3=new wo,Ws=class extends rr{constructor(e,r,n,o=new Yr){super(n!=null?n:r,o);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=n;this.objectType="SubdivObject";this.hiddenMatrixOld=new wo;this.smoothShading=!0;this.matrixWorldRigid=new wo;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,n){let{subdivPointer:o,originalGeometry:a,subdividedGeometry:c}=Jr.build(r.geometry,void 0,void 0,!r.flatShading),f=el(r.material,n),h=new Ws(o,a,c||void 0,f);return h.calcBoundingBox(),h.freeSubdivPointer(),h.uuid=e,h.fromState(r),h}shallowClone(e){return new Hs(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="SubdivObject",r}buildFromStore(e){var a,c,f;let{originalGeometry:r,subdividedGeometry:n,subdivPointer:o}=Jr.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,r!==void 0&&((a=this.originalGeometry)==null||a.dispose(),this.originalGeometry=r),n!==void 0&&((c=this.subdividedGeometry)==null||c.dispose(),this.subdividedGeometry=n!=null?n:void 0),this.geometry=(f=this.subdividedGeometry)!=null?f:this.originalGeometry,this.cloner)for(let h of this.cloner.children)h.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Jr.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Jr.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=Jr.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Jr.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,r){var n;this.geometry=this.originalGeometry,rr.prototype.raycast.call(this,e,r),this.geometry=(n=this.subdividedGeometry)!=null?n:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:n,v:o,q:a}=(0,Gv.SVD)(r),c=Rv.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),f=p3.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),h=d3.copy(f).transpose();this.shearScale=m3.makeScale(a[0],a[1],a[2]).multiply(h).premultiply(f),this.shearScaleInv=g3.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,h),a.every(d=>Math.abs(a[0]-d)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ev);let r=e.attributes.position,n=e.boundingSphere.center;Mn.setFromBufferAttribute(r),Mn.getCenter(n),e.boundingSphere.radius=n.distanceTo(Mn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Mn.getSize($i);let o={width:$i.x,height:$i.y,depth:$i.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let r=this.originalGeometry;Mn.min.set(e[0],e[2],e[4]),Mn.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Mn.min.applyMatrix4(this.shearScaleInv),Mn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Ev);let n=r.boundingSphere.center;Mn.getCenter(n),r.boundingSphere.radius=n.distanceTo(Mn.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Mn.getSize($i);let o={width:$i.x,height:$i.y,depth:$i.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(Cp.free_bvh(this.subdivPointer),Cp.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Bv(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Bv(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=j({},e.parameters)}};function Bv(i,t,e,r){let n=i.position.array,o=i.normal.array,a=Rv.makeScale(t,e,r).invert().elements,c,f,h;for(var d=0,m=n.length;d<m;d+=3)n[d]*=t,n[d+1]*=e,n[d+2]*=r,c=o[d],f=o[d+1],h=o[d+2],o[d]=a[0]*c+a[4]*f+a[8]*h,o[d+1]=a[1]*c+a[5]*f+a[9]*h,o[d+2]=a[2]*c+a[6]*f+a[10]*h}import{BackSide as y3,DoubleSide as x3,FrontSide as v3}from"three";function zv(i,t){t.flatShading!==void 0&&(i.flatShading=t.flatShading,i.needsUpdate=!0),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?i.side=v3:t.side===1?i.side=y3:i.side=x3)}function b3(i,t){if(Array.isArray(i.material))for(let e of i.material)zv(e,t);else{let e=i.material;zv(e,t)}i.objectType==="SubdivObject"&&t.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!t.flatShading,i.updateMesh())}function Fv(i,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=Ws.createFromState(i,t,e);else{let n=Pv(t.geometry,e),o="materials"in t?gv(t.materials,e):el(t.material,e);qc.is2DParametricMesh(n.userData.type)?r=new js(n,o):(n==null?void 0:n.userData.type)==="VectorGeometry"?r=new qi(n,o):t.geometry.type==="NonParametricGeometry"?r=new Hs(n,o):r=new ks(n,o),r.uuid=i,r.fromState(t)}return b3(r,t),r}function Vv(i,t,e){return t.type==="Mesh"?Fv(i,t,e):t.type==="TextFrame"?So.createFromState(i,t,e):t.type==="Empty"?gi.createFromState(i,t):t.type==="PointLight"?Vs.createFromState(i,t,e):t.type==="SpotLight"?Us.createFromState(i,t,e):t.type==="DirectionalLight"?Fs.createFromState(i,t,e):ss.is(t.type)?mi.createFromState(i,t):(console.error(t),new gi)}function S3(i,t){t.uniforms[`f${t.id}_transmissionSamplerMap`].value=i.texture,t.uniforms[`f${t.id}_transmissionDepthMap`].value=i.depthTexture}function Uv(i,t,e){if(!e.userData.layers)return!1;let r=!1,n=e.userData.layers.getLayersOfType("transmission");return n.length>0?(t.layers.set(3),r=!0,i!==void 0&&n.forEach(o=>S3(i,o))):t.layers.set(0),r}function jv(i,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof rr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)Uv(i,r,r.material[n])&&(e=!0);else Uv(i,r,r.material)&&(e=!0)}),e}function kv(i,t){"material"in i&&w3(i.material,t),"geometry"in i&&i.geometry.dispose()}function w3(i,t){eg(i).forEach(e=>{t.isSharedMaterial(e)||e.dispose()})}var Wv=new T3,Lp=class extends fu(L3){constructor(e,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new N3(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Hv(1,0,0);this.bgColor=new Hv(1,1,1);this.entityByUuid={};this.ambientLight=new C3(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(e,r)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=jv(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Vt(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let n=this.find(e.publish.playCamera);n instanceof mi&&this.switchActiveCamera(n)}}clearScene(e){this.traverseEntity(r=>{kv(r,e)});for(let r of this.children)hn(r)&&r.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=mi.createFromState(Lp.PERSONAL_CAMERA_ID,ue(j({},Jc.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],n=o=>{for(let a of o.children)hn(a)&&!a.raycastLock&&a.visible&&((Ss(a)||fi(a)&&a.enableHelper&&a.objectHelper.parent)&&e.intersectObject(a,!1,r),n(a))};return n(this),r}traverseEntity(e){for(let r of this.children)hn(r)&&r.traverseEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Vt(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,r){W0(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Vt(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,r,n){for(let o of e)this.createChildObject(o.id,o.data,o.children,r,n)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,n,o,a){let c=Vv(e,r,a);return c&&(this.entityByUuid[e]=c,o.add(c),this.createChildrenObjects(n,c,a)),c}getCenter(e){let r=[];for(let o=0,a=e.length;o<a;++o){let{id:c,recursive:f}=e[o],h=this.find(c),d=f?h.recursiveBBox:h.singleBBox;r.push(...d.vertices)}let n=new _3;return n.setFromPoints(r),n.getCenter(Wv),Wv}copyMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e);n?r.copy(n.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){var o;if(e===null){r.identity();return}let n=(o=this.find(e))==null?void 0:o.parent;n?r.copy(n.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof rr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)e(r.material[n]);else e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let n,o;e>=r?(n=r/e,o=1):(n=1,o=e/r),this.traverseMaterial(a=>{a.layersList.getLayersOfType("transmission").forEach(f=>{f.uniforms[`f${f.id}_aspectRatio`].value.x=n,f.uniforms[`f${f.id}_aspectRatio`].value.y=o})})}},rl=Lp;rl.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as I3}from"three/examples/jsm/loaders/DRACOLoader.js";var Ji;function O3(){return Ji||(Ji=new I3,Ji.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Ji.decoderPending}async function M3(i){if(Ji){let t={attributeIDs:Ji.defaultAttributeIDs,attributeTypes:Ji.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Ji.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function qv(i){let[t,e]=ih(Uc.deserialize(new Uint8Array(i))),r=[];t.scene.objects.traverse((n,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await O3();for(let n of r){let o=await M3(sh(n.geometry.data.draco));if(o){o.index&&(n.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:c,array:f,itemSize:h})=>{a[c]={array:f,itemSize:h,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return e.result().data}import{WebGLRenderTarget as P3,LinearMipmapLinearFilter as A3,LinearFilter as D3,ClampToEdgeWrapping as $v,DepthTexture as E3}from"three";var Jv=new ur,Ru=class extends Er{},zu=class{constructor(t){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new P3(2048,2048,{generateMipmaps:!0,minFilter:A3,magFilter:D3,wrapS:$v,wrapT:$v}),this.transmissionRenderTarget.depthTexture=new E3(2048,2048),this.reset(t)}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.data);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,gp(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}isSharedMaterial(t){return t.uuid in this.materials||t===Jv}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){var e;return(e=this.materials[t])!=null?e:Jv}getMaterials(){return this.materials}addImage(t,e){if(this.images[t])return this.images[t].onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t].src=e,!0;{let r=new Image;return r.src=e,r.onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t]=r,!1}}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Ru(e.r,e.g,e.b,e.a):this.colors[t]=new Ru(e.r,e.g,e.b,1),!1)}updateColor(t,e){var r,n,o,a;if(this.colors[t]){let c=this.colors[t];return this.colors[t].r=(r=e.r)!=null?r:c.r,this.colors[t].g=(n=e.g)!=null?n:c.g,this.colors[t].b=(o=e.b)!=null?o:c.b,this.colors[t].a=(a=e.a)!=null?a:c.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{Color as Yv,ShaderLib as B3}from"three";var Xv=Qm(Kv());function Zv(i){let t=new Set;return i.traverse(e=>{if(Ss(e))if((0,Xv.isArray)(e.material))e.material.forEach(r=>{let n=r;t.has(n)||t.add(n)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{let r=e.onBeforeCompile.bind(e);G3(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Yv,specularColor:new Yv}),e.onBeforeCompile=(n,o)=>{r&&r(n,o),n.uniforms=Object.assign(B3.physical.uniforms,n.uniforms),e.userData.layers.getLayersOfType("transmission").forEach(a=>{n.uniforms.transmissionSamplerMap.value&&(a.uniforms["f"+a.id+"_transmissionSamplerMap"].value=n.uniforms.transmissionSamplerMap.value,a.uniforms["f"+a.id+"_transmissionSamplerSize"].value=n.uniforms.transmissionSamplerSize.value)})}):R3(e)||(e.onBeforeCompile=(n,o)=>{r&&r(n,o),e.transparent=!1})}),i}function G3(i){return i.userData.layers.getLayersOfType("transmission").length>0}function R3(i){let t=i.userData.layers.head,e=0;for(;t!==void 0;){if(t.type!=="light"&&t.type!=="fresnel"){let r=t.uniforms["f"+t.id+"_alpha"];r&&(e+=(1-e)*r.value)}t=t.next}return e<1}function Qv(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}var Tp=class extends F3{load(t,e,r,n=console.error){let o=new z3(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let c=await this.parse(a);e(c)}catch(c){n(c)}},r,n)}async parse(t){let e=await qv(t),r=new zu(e.shared),n=new rl(e.scene,r);return Qv(Zv(n))}};export{Tp as default};
976
+ `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Tu=class extends Kr{constructor(e=new Lu,r){super(e,e,r);this.type="StandardNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}};var Es=class extends Tu{constructor(t,e,r){super(e,t),this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof yr){let e=t.userData.layers,r=t.fragment;super.copy(t);let n=r.clone();this.fragment=n,this.vertex=n;let o=e.clone(this);this.userData.layers=o,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let n=r.getNode(e.vertex),o=new Es(void 0,n);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{Color as mp}from"three";import{Matrix3 as cv,Texture as dp,Vector2 as Qa,Vector3 as Hi,Vector4 as uv}from"three";function fv(i,t){switch(i.data.type){case"light":return In(i);case"fresnel":return pD(i,t);case"gradient":return dD(i);case"depth":return mD(i);case"normal":return gD(i);case"noise":return yD(i,t);case"texture":return xD(i,t);case"rainbow":return vD(i);case"transmission":return bD(i,t);case"matcap":return SD(i,t);case"displace":return wD(i);case"color":default:return hD(i,t)}}function hv(i){return{type:i.data.type}}function In(i){let{alpha:t,mode:e}=i.data;return ue(j({},hv(i)),{alpha:t,mode:e})}function hD(i,t){return ue(j({},In(i)),{color:Ft(i.data.color,t)})}function pD(i,t){let{bias:e,scale:r,intensity:n,factor:o,color:a}=i.data;return ue(j({},In(i)),{color:Ft(a,t),bias:e,scale:r,intensity:n,factor:o})}function dD(i){let{gradientType:t,smooth:e,colors:r,steps:n,angle:o,offset:a,morph:c}=i.data;return ue(j({},In(i)),{gradientType:t,smooth:e,colors:r.map(f=>new uv(f[0],f[1],f[2],f[3])),num:r.length,steps:n,offset:new Qa(...a),morph:new Qa(...c),angle:o})}function mD(i){let{gradientType:t,near:e,far:r,isVector:n,isWorldSpace:o,origin:a,direction:c,colors:f,steps:h,smooth:d,num:m}=i.data;return ue(j({},In(i)),{gradientType:t,near:e,far:r,isVector:n,isWorldSpace:o,origin:new Hi(...a),direction:c?new Hi(...c):new Hi(1,0,0),num:m,colors:f.map(x=>new uv(x[0],x[1],x[2],x[3])),steps:h,smooth:d})}function gD(i){let{cnormal:t}=i.data;return ue(j({},In(i)),{cnormal:new Hi(t[0],t[1],t[2])})}function yD(i,t){let{data:e}=i;return ue(j({},In(i)),{scale:e.scale,move:e.move,fA:new Qa(...e.fA),fB:new Qa(...e.fB),size:new Hi(...e.size),distortion:new Qa(...e.distortion),colorA:Ft(e.colorA,t),colorB:Ft(e.colorB,t),colorC:Ft(e.colorC,t),colorD:Ft(e.colorD,t),noiseType:e.noiseType})}function xD(i,t){let{projection:e,axis:r,crop:n,size:o}=i.data,{image:a,wrapping:c,repeat:f,offset:h}=i.data.texture,d=new dp,m;if(typeof a=="string")m=t==null?void 0:t.getImage(a);else{let x=new Image;x.src=a.data,x.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(a.data))},m=x}return d.image=m,d.repeat.set(f[0],f[1]),d.offset.set(h[0],h[1]),d.wrapS=d.wrapT=c,ue(j({},In(i)),{texture:d,mat:new cv().setUvTransform(h[0],h[1],f[0],f[1],0,0,0),crop:n,projection:e,axis:["x","y","z"].indexOf(r),size:o})}function vD(i){let{data:t}=i;return ue(j({},In(i)),{filmThickness:t.filmThickness,movement:t.movement,wavelengths:new Hi(...t.wavelengths),noiseStrength:t.noiseStrength,noiseScale:t.noiseScale,offset:new Hi(...t.offset)})}function bD(i,t){let{data:e}=i;return ue(j({},In(i)),{thickness:e.thickness,ior:e.ior,roughness:e.roughness,transmissionSamplerMap:t.transmissionSamplerMap,transmissionDepthMap:t.transmissionDepthMap})}function SD(i,t){let e=new dp,{image:r}=i.data.texture,n;if(typeof r=="string")n=t==null?void 0:t.getImage(r);else{let a=new Image;a.src=r.data,a.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(r.data))},n=a}e.image=n;let o=16777215;return ue(j({},In(i)),{color:o,texture:e})}function wD(i){let{data:t}=i,e=ue(j({},hv(i)),{intensity:t.intensity});if(t.displacementType==="noise")return ue(j({},e),{offset:new Hi(...t.offset),scale:t.scale,movement:t.movement,noiseType:t.noiseType});{let r=new dp,n=new cv().setUvTransform(0,0,1,1,0,0,0);return ue(j({},e),{texture:r,mat:n,crop:t.crop})}}function pv(i,t,e){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let r=t.uniforms[`f${t.id}_alpha`];return r?(r.value=e.alpha*(e.visible?1:0),r):void 0}}import{Color as gv,Vector4 as CD}from"three";var Bs;(t=>{function i(e){return new gv(e.x,e.y,e.z).getHex()}t.getHex=i})(Bs||(Bs={}));var dv;(t=>{function i(e){return new CD(e.r,e.g,e.b,e.a)}t.getThreeVector4=i})(dv||(dv={}));var mv;(e=>{function i(r,n){r.setRGB(n.r,n.g,n.b)}e.setThreeColor=i;function t(r){return new gv(r.r,r.g,r.b).getHex()}e.getHex=t})(mv||(mv={}));function el(i,t){return typeof i=="string"?t.getMaterialOrDeletedPlaceholder(i):gp(i,t)}function yv(i,t){return i.map(e=>el(e,t))}function gp(i,t){var a,c;let e=(a=i.layers)!=null?a:ds.defaultTwoLayerData("phong").layers,r=LD(e),n;switch(r.category){case"basic":n=new ur;break;case"lambert":{n=new As;break}case"toon":{n=new Ds;break}case"physical":n=new Es;break;case"phong":default:{n=new Yr;break}}n.name=(c=i.name)!=null?c:"Untitled Material";let o=n.userData.layers;TD(o);for(let f=e.length-1;f>=0;f--)ND(o,e[f],t);switch(r.category){case"basic":break;case"lambert":{let d=n,x=Ft(r.emissive,t);x instanceof mp?d.emissive.value=x:d.emissive.value.setHex(Bs.getHex(x));break}case"toon":{let d=n,m=r;d.shininess.value=m.shininess;let x=Ft(m.specular,t);x instanceof mp?d.specular.value=x:d.specular.value.setHex(Bs.getHex(x));break}case"physical":let f=n,h=r;f.metalness.value=h.metalness,f.roughness.value=h.roughness,f.reflectivity.value=h.reflectivity;break;case"phong":default:{let d=n,m=r;d.shininess.value=m.shininess;let x=Ft(m.specular,t);x instanceof mp?d.specular.value=x:d.specular.value.setHex(Bs.getHex(x));break}}return o.blendColors(),o.blendAfterColors(),o.blendPositions(),n}function LD(i){for(let t of i)if(t.data.type==="light")return t.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:0}}function TD(i){for(let t of i.getLayers())i.removeLayer(t.id)}function ND(i,t,e){let r=fv(t,e);r.type==="transmission"&&(r.transmissionSamplerMap=e==null?void 0:e.transmissionSamplerMap,r.transmissionDepthMap=e==null?void 0:e.transmissionDepthMap);let n=i.addLayer(r);n.uuid=t.id;for(let o in t.data)pv(o,n,t.data)}var xv=i=>i.tagName==="VIDEO",So=class{static resize(t,e,r){let n=t/e,o;if(!r.image)return;let a=r.image;xv(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,n>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/n):r.repeat.set(1,1*o/n)),n<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/o*-1,1):r.repeat.set(1*n/o,1)),n==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let n=t/e,o=r.image!==void 0?r.image.width/r.image.height:1,a;n>o?a={x:1,y:o/n}:n<o?a={x:n/o,y:1}:a={x:1,y:1},r.repeat.set(a.x,a.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let n=r.userData.layers,o=n.getLayers();for(let a=0;a<o.length;a++){let c=o[a];nv(c)&&(So.resizeTextureLayer(t,e,c.uniforms[`f${c.id}_texture`].value),n.updateLayerUniform())}}static resizeComplex(t,e,r,n){let o=t/e,a,c=r.image;xv(c)?a=c.videoWidth/c.videoHeight:a=c.width/c.height,n.geometry.type.includes("Shape")?(o>a&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*a/o):r.repeat.set(1/t,1/e*a/o)),o<a&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*o/a*-1,1/e):r.repeat.set(1/t*o/a,1/e)),o==a&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(o>a&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*a/o):r.repeat.set(1,1*a/o)),o<a&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/a*-1,1):r.repeat.set(1*o/a,1)),o==a&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Gs=class extends rr{constructor(e,r=new ur){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&So.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,r){super.resizeGeometry(e,r,0),this.material.userData.layers&&So.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh2D",r}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let r,n;if(e instanceof _D){let c=e.image;r=c.videoWidth*.5,n=c.videoHeight*.5}else{let c=e.image;r=c.width*.5,n=c.height*.5}let o=au.create({parameters:{width:r,height:n}}),a=new ur;return a.layersList.changeLayer(0,{type:"texture",texture:e}),a.layersList.moveLayer(0,1),a.dispose(),new Gs(o,a)}};import{DoubleSide as ID,EventDispatcher as OD,Matrix3 as MD,Vector3 as yp}from"three";var PD=new yp(0,0,1),vv=new yp,bv=new yp,Sv=new MD,Wi=class extends rr{constructor(e=ar.create({}),r=new ur({side:ID})){var n;super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new OD;this._onShapeUpdate=()=>{if(this.geometry instanceof Vi){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,r=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(r.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(n=this.shape.eventDispatcher)==null||n.addEventListener("update",this._onShapeUpdate)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="VectorObject",r}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){var r,n;this.shape&&((r=this.shape.eventDispatcher)==null||r.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(n=this.shape.eventDispatcher)==null||n.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Sv.getNormalMatrix(this.matrixWorld),vv.copy(PD).applyMatrix3(Sv).normalize(),bv.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(vv,bv)}clone(e){let r=this.shape.clone(),n=this.material.clone(),o=this.geometry.userData,a=ar.create(Object.assign({},o,{shape:r})),c=new Wi(a,n).copy(this,e);return c.shape=r,r.update(),c}raycast(e,r){rr.prototype.raycast.call(this,e,r)}};import{Camera as $D,OrthographicCamera as JD,PerspectiveCamera as KD,Vector3 as Xr,Object3D as Lv,Quaternion as YD}from"three";import{BoxBufferGeometry as AD}from"three";var qn=i=>{var t;return t=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new AD(30,30,30),t};import{Camera as RD,LineSegments as zD,BufferGeometry as FD,LineBasicMaterial as VD,Color as vp,Vector3 as UD,Float32BufferAttribute as Cv}from"three";import{Ray as DD,Sphere as ED,Matrix4 as BD,Vector3 as di}from"three";var Nu=new DD,xp=new ED,wv=new BD,$n=(i,t,e,r,n=!1)=>{let o=t,a=i.matrixWorld;if(o.boundingSphere===null&&o.computeBoundingSphere(),xp.copy(o.boundingSphere),xp.applyMatrix4(a),e.ray.intersectsSphere(xp)===!1||(wv.copy(a).invert(),Nu.copy(e.ray).applyMatrix4(wv),o.boundingBox!==null&&Nu.intersectsBox(o.boundingBox)===!1))return;let c,f,h,d,m=o.index,x=o.attributes.position,S=o.drawRange,w,B;if(n===!1){let T=Math.max(0,S.start),M=Math.min(m.count,S.start+S.count);for(w=T,B=M;w<B;w+=3)if(f=m.getX(w),h=m.getX(w+1),d=m.getX(w+2),c=O(i,e,Nu,x,f,h,d),c){c.faceIndex=Math.floor(w/3),r.push(c);return}}else{let M=o.attributes.position,F=new di,k=new di,N=new di,te=new di,A=2,V=1/((i.scale.x+i.scale.y+i.scale.z)/3),P=V*V,R=Math.max(0,S.start),E=Math.min(M.count,S.start+S.count);for(let G=R,ae=E-1;G<ae;G+=A){if(F.fromBufferAttribute(M,G),k.fromBufferAttribute(M,G+1),Nu.distanceSqToSegment(F,k,te,N)>P)continue;te.applyMatrix4(i.matrixWorld);let xe=e.ray.origin.distanceTo(te);xe<e.near||xe>e.far||r.push({distance:xe,point:N.clone().applyMatrix4(i.matrixWorld),object:i})}}function O(T,M,F,k,N,te,A){let b=new di,V=new di,P=new di,R=new di,E=new di;if(b.fromBufferAttribute(k,N),V.fromBufferAttribute(k,te),P.fromBufferAttribute(k,A),F.intersectTriangle(b,V,P,!1,R)===null)return null;E.copy(R),E.applyMatrix4(T.matrixWorld);let ae=M.ray.origin.distanceTo(E);return ae<M.near||ae>M.far?null:{faceIndex:1,distance:ae,point:E.clone(),object:T}}};var _u=new UD,dn=new RD,bp=class extends zD{constructor(e){let r=new FD,n=new VD({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],c={},f=new vp(15711266),h=new vp(15711266),d=new vp(2857471);m("n1","n2",f),m("n2","n4",f),m("n4","n3",f),m("n3","n1",f),m("f1","f2",f),m("f2","f4",f),m("f4","f3",f),m("f3","f1",f),m("n1","f1",f),m("n2","f2",f),m("n3","f3",f),m("n4","f4",f),m("p","n1",h),m("p","n2",h),m("p","n3",h),m("p","n4",h),m("u1","u2",d),m("u2","u3",d),m("u3","u1",d);function m(S,w,B){x(S,B),x(w,B)}function x(S,w){o.push(0,0,0),a.push(w.r,w.g,w.b),c[S]===void 0&&(c[S]=[]),c[S].push(o.length/3-1)}r.setAttribute("position",new Cv(o,3)),r.setAttribute("color",new Cv(a,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=c,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;dn.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,c=n?.8:1e-4;On("n1",r,e,dn,-o,-a,c),On("n2",r,e,dn,o,-a,c),On("n3",r,e,dn,-o,a,c),On("n4",r,e,dn,o,a,c);let f=c;On("f1",r,e,dn,-o,-a,f),On("f2",r,e,dn,o,-a,f),On("f3",r,e,dn,-o,a,f),On("f4",r,e,dn,o,a,f);let h=f,d=.5;On("u1",r,e,dn,o*.7*d,a*1.1,h),On("u2",r,e,dn,-o*.7*d,a*1.1,h),On("u3",r,e,dn,0,a*(1.1+.9*d),h),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function On(i,t,e,r,n,o,a){_u.set(n,o,a).unproject(r);let c=t[i];if(c!==void 0){let f=e.getAttribute("position");for(let h=0,d=c.length;h<d;h++)f.setXYZ(c[h],_u.x,_u.y,_u.z)}}var Iu=class extends qn(bp){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){$n(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as jD}from"three";var Rs=class extends qn(jD){constructor(e,r=15,n=10066329){super(e,r,n);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){$n(this.object,Rs.geometryHelper,e,r)}};import{AxesHelper as kD}from"three";var zs=class extends qn(kD){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){$n(this.object,zs.geometryHelper,e,r)}update(){}};import{PointLightHelper as HD}from"three";var Fs=class extends qn(HD){constructor(e,r=15,n=6710886){super(e,r,n);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){$n(this.object,Fs.geometryHelper,e,r)}};import{SpotLightHelper as WD,Vector3 as qD}from"three";var Ou=class extends qn(WD){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){$n(this.object,Ou.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=Ou._vector,r=this.object.distance?this.object.distance:1e3,n=r*Math.tan(this.object.angle);this.cone.scale.set(n,n,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let o=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,c=this.cone.material.length;a<c;a++)this.cone.material[a].color.set(o);else this.cone.material.color.set(o)}}},tl=Ou;tl._vector=new qD;var Jn=(i,t)=>class extends i{constructor(){super(...arguments);this.objectHelper=new t(this);this.enableHelper=!1}set visibility(n){this.visible=n,this.setHelperVisibility(n),this.setHelperChildrenVisibility(n)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(n){this.objectHelper.visible=n}setHelperChildrenVisibility(n){for(let o of this.children)hn(o)&&o.traverseEntity(a=>{fi(a)&&a.visible&&(a.objectHelper.visible=n)})}raycast(n,o){this.objectHelper.raycast(n,o)}copy(n,o=!0){return super.copy(n,o),n.enableHelper!==void 0&&(this.enableHelper=n.enableHelper),n.objectHelper!==void 0&&(this.objectHelper.visible=n.objectHelper.visible),this}toJSON(n){let o=super.toJSON(n),a=o.object;return a.enableHelper=this.enableHelper,o}fromJSON(n){return super.fromJSON(n),n.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(n,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let a=this;n.color!==void 0&&(a.color=Ft(n.color,o)),n.intensity!==void 0&&(a.intensity=n.intensity),n.depth!==void 0&&(a.shadow.camera.far=n.depth,a.shadow.needsUpdate=!0),n.shadows!==void 0&&(this.castShadow=n.shadows),n.helper!==void 0&&(this.enableHelper=n.helper,a.gizmos.shadowmap.visible=n.helper)}return this}};var Vs=new Xr,Sp=new Xr,mi=class extends Jn(pn($D),Iu){constructor(e=window.innerWidth,r=window.innerHeight,n=45,o,a=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=uo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new JD(e*-.5,e*.5,r*.5,r*-.5,o!=null?o:-5e4,a),this.perspCamera=new KD(n,e/r,o!=null?o:50,a),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,r){let n=new mi().fromState(r);return n.enableHelper=!0,n.objectHelper.update(),n.uuid=e,n}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(Vs),this.targetOffset=Vs.distanceTo(e)}getTarget(e=new Xr){return this.getWorldDirection(Sp),this.getWorldPosition(Vs),Sp.multiplyScalar(this.targetOffset),e.copy(Vs).add(Sp),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Vs),Vs.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new YD),r=new Xr(0,0,1).applyQuaternion(e),n=new Xr().copy(Lv.DefaultUp);this.isUpVectorFlipped&&n.negate(),n.applyQuaternion(e);let o=new Xr().copy(Lv.DefaultUp).projectOnPlane(r),a=new Xr().crossVectors(o,n).dot(r)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(n)*a}getViewFrontToObject(e){let r=e.getWorldPosition(new Xr),o=e.getWorldDirection(new Xr).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToObject(e){let r=e.getWorldPosition(new Xr),o=this.getWorldDirection(new Xr).multiplyScalar(this.targetOffset);return{position:r.clone().sub(o),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,o,a,c){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,o,a,c):this.orthoCamera.setViewOffset(e,r,n,o,a,c)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},n={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=n.near,this.perspCamera.far=n.far,this.updateProjectionMatrix(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="CombinedCamera",n.cameraType=this.cameraType,n.targetOffset=this.targetOffset,n.isUpVectorFlipped=this.isUpVectorFlipped,n.angleOffsetFromUp=this.angleOffsetFromUp,n.left=this.left,n.right=this.right,n.top=this.top,n.bottom=this.bottom,this.view!==null&&(n.view=Object.assign({},this.view)),n.zoomOrtho=this.orthoCamera.zoom,n.nearOrtho=this.orthoCamera.near,n.far=this.far,n.aspect=this.aspect,n.fov=this.fov,n.focus=this.focus,n.filmGauge=this.filmGauge,n.filmOffset=this.filmOffset,n.zoomPersp=this.perspCamera.zoom,n.nearPersp=this.perspCamera.near,r}fromJSON(e){var r;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let n=this.getWorldPosition(new Xr),o=new Xr().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(n)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(r=e.angleOffsetFromUp)!=null?r:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ss(r,e)}fromCameraState(e){let{orthographic:r,perspective:n}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),n!==void 0&&(n.near!==void 0&&(this.perspCamera.near=n.near),n.fov!==void 0&&(this.perspCamera.fov=n.fov),n.zoom!==void 0&&(this.perspCamera.zoom=n.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return ue(j(j({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as XD}from"three";var gi=class extends Jn(pn(XD),zs){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let n=new gi().fromState(r);return n.uuid=e,n.enableHelper=!0,n.objectHelper.update(),n}toJSON(e){let r=super.toJSON(e);return r.object.objectType="EmptyObject",r}};import{DirectionalLight as ZD,CameraHelper as Mu}from"three";var Us=class extends Jn(pn(ZD),Rs){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=1,n.far=2500;let o=new Mu(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,n){let o=new Us().fromState(r,n);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Mu&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Mu&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Mu&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="LightDirectional",n.color=this.color.getHex(),n.intensity=this.intensity,n.shadow=this.shadow.toJSON(),r}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let r=this.shadow.camera,n=e.shadow.camera;return r.near=n.near,r.far=n.far,r.zoom=n.zoom,r.left=n.left,r.right=n.right,r.top=n.top,r.bottom=n.bottom,n.view!==void 0&&(r.view=Object.assign({},n.view)),this}fromDirectionalLightState(e,r){let n=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,r),e.size!==void 0&&$0(this,e.size),n&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as QD,Vector3 as Pu,Box3 as e3,Box3Helper as Au,Color as t3}from"three";var js=class extends Jn(pn(QD),Fs){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let o=new Pu(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new Pu(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),c=new e3(o,a),f=new Au(c,new t3(16755200));f.visible=!1,this._gizmos.shadowmap=f,this.update()}static createFromState(e,r,n){let o=new js().fromState(r,n);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Au&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Au&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof Au){let n=this.shadow.camera,o=new Pu(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new Pu(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z);r.box.set(o,a),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="LightPoint",n.color=this.color.getHex(),n.intensity=this.intensity,n.distance=this.distance,n.decay=this.decay,n.shadow=this.shadow.toJSON(),r}fromJSON(e){var o,a;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((a=e.shadow.mapSize)!=null?a:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,n=e.shadow.camera;return r.near=n.near,r.far=n.far,r.zoom=n.zoom,r.fov=n.fov,r.focus=n.focus,r.aspect=n.aspect,r.filmGauge=n.filmGauge,r.filmOffset=n.filmOffset,n.view!==void 0&&(r.view=Object.assign({},n.view)),this}fromPointLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromPointLightState(e,r),this}};import{SpotLight as r3,CameraHelper as Du,MathUtils as n3,Vector3 as Iv,Quaternion as i3}from"three";var Tv=new Iv,Nv=new Iv,_v=new i3,ks=class extends Jn(pn(r3),tl){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.fov=n3.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let o=new Du(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,n){let o=new ks().fromState(r,n);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Du&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Du&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Du&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Nv.setFromMatrixPosition(this.matrixWorld),_v.setFromRotationMatrix(this.matrixWorld),Tv.copy(this.up).applyQuaternion(_v).negate().multiplyScalar(this.distance),this.target.position.copy(Nv).add(Tv),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),n=r.object;return n.objectType="LightSpot",n.color=this.color.getHex(),n.intensity=this.intensity,n.distance=this.distance,n.angle=this.angle,n.decay=this.decay,n.penumbra=this.penumbra,n.shadow=this.shadow.toJSON(),r}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let r=this.shadow.camera,n=e.shadow.camera;return r.near=n.near,r.far=n.far,r.zoom=n.zoom,r.fov=n.fov,r.focus=n.focus,r.aspect=n.aspect,r.filmGauge=n.filmGauge,r.filmOffset=n.filmOffset,n.view!==void 0&&(r.view=Object.assign({},n.view)),this}fromSpotLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};var Hs=class extends rr{constructor(e,r=new Yr){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh3D",r}};var Ws=class extends Hs{constructor(e,r=new Yr){super(e,r);this.objectType="NonParametric"}toJSON(e){let r=super.toJSON(e);return r.object.objectType="NonParametric",r}};import{DoubleSide as o3,Mesh as s3,MeshBasicMaterial as a3,ShapeBufferGeometry as l3,Vector2 as c3,Vector3 as u3}from"three";import{FontLoader as f3}from"three/examples/jsm/loaders/FontLoader.js";var Vt=class extends s3{constructor({char:e,originalChar:r,fontFamily:n,letterSpacing:o,fontSize:a,LOD:c=16},f=new a3({color:0,opacity:1,visible:!0,transparent:!0,side:o3})){let h=Vt.loadChar(e,n,c);super(h.geometry,f);this.char=e,this.originalChar=r!=null?r:e,this.fontFamily=n,this.letterSpacing=o,this.fontSize=a,this.LOD=c,this.resolution=h.resolution,this.glyphsHa=h.glyphsHa,this.localPosition=new c3,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Vt._fontPath}static set FONTS_PATH(e){Vt._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let n=new u3(this.localPosition.x,-this.localPosition.y,0);this.position.copy(n).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=Vt.loadChar(this.char,e,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let r=Vt.loadChar(e,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let r=Vt.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Vt(e).copy(this)}static loadFont(e){return new Promise(function(r,n){Vt.fontCache[e]?r(Vt.fontCache[e]):new f3().load(Vt.FONTS_PATH+e+".json",a=>{Vt.fontCache[e]=a,r(a)},void 0,n)})}static loadChar(e,r,n){if(Vt.charCache[e]){if(Vt.charCache[e][n]&&Vt.charCache[e][n].fontFamily===r)return Vt.charCache[e][n]}else Vt.charCache[e]={};let o=Vt.fontCache[r],a=o.generateShapes(e,1);return Vt.charCache[e][n]={geometry:new l3(a,n),fontFamily:r,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Vt.charCache[e][n]}},Tr=Vt;Tr.charCache={},Tr.fontCache={},Tr._fontPath="/_assets/_fonts/";import{DoubleSide as Bu,MeshBasicMaterial as Mv,Vector3 as Pv,Object3D as h3}from"three";import{Vector2 as Ov}from"three";var Eu=new Ov,qi=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new Ov(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,n=this.message.length;r<n;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,n;for(n=t;n>=0;n-=1)if(this.message[n].char===" "){r=!1,e.length===0&&(n-=1,e.splice(0,0,this.message[n]));break}else e.splice(0,0,this.message[n]);return r?e=[]:this.message.splice(n+1,e.length),e}getWord(t=0,e=1){let r=[],n=t;for(n=t;;n+=e){if(!this.message[n]||this.message[n].char===" "){r.length===0&&this.message[n]&&(r.push(this.message[n]),this.message.splice(n,1));break}e>0?(r.push(this.message[n]),this.message.splice(n,1),n-=e):(r.splice(0,0,this.message[n]),this.message.splice(n,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,n=t;for(;n>=0&&n<this.message.length;){if(this.message[n].char===" "){r===0&&(r=this.message[n].charSize);break}r+=this.message[n].charSize,n+=e}return(n<0||n>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let n=e;n<=r;n+=1)this.message[n].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,n,o){switch(r){case 1:this.leftAlign(t,o);break;case 3:this.centerAlign(this.spaceLeft(e),t,o);break;case 2:this.rightAlign(this.spaceLeft(e),t,o);break;case 4:this.justifyAlign(this.spaceLeft(e),t,o);break}}offsetCharacters(t,e,r){Eu.set(e,r);let n=this.message.length;for(let o=0;o<n;o++)this.message[o].updatePosition(this.message[o].localPosition.add(Eu),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let n=this.countSpaces();if(n===0){this.offsetCharacters(e,0,r);return}let o=t/n,a=0;for(let c=0;c<this.message.length;c++)this.message[c].char===" "&&(a+=o),Eu.set(a,r),this.message[c].updatePosition(this.message[c].localPosition.add(Eu),e)}clone(){let t=new qi(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};var wp=class extends rr{constructor(e,r=new ur({transparent:!0,opacity:1,visible:!1,side:Bu})){super(e,r);this.objectType="TextFrame";this.charContainer=new h3,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new Pv(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,n){let o=lu.create({parameters:{width:r.width,height:r.height}}),a=new wp(o).fromState(r,n);return a.uuid=e,a}async updateText(e){this.clearText();let r=this.userData.textFrame,n=r.fontFamily;await Tr.loadFont(n),r.text=e;let o=r.textOrigin,a=new Mv({visible:r.visible,transparent:!0,side:Bu}),c=e.split(`
977
+ `),f=0;this.userData.textFrame.textLines=c.map((h,d)=>{let m=new qi(f,r.lineHeight,r.fontSize);return m.message=h.split("").map(x=>{let S={char:x,fontFamily:n,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},w=a.clone();w.color=r.hexColor,w.opacity=r.opacity;let B=new Tr(S,w);return m.addChar3D(B,o),this.charContainer.add(B),B}),f+=m.maxCharSize*m.lineHeight,m}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let n=[];if(super.raycast(e,n),n.length>0){r.push(n[0]);return}let o=[];for(let a=0,c=this.charContainer.children.length;a<c;++a)if(this.charContainer.children[a]instanceof Tr&&(e.intersectObject(this.charContainer.children[a],!1,o),o.length>0)){o[0].object=this,r.push(o[0]);return}}updateGeometry(e){var d,m,x,S;let r=this.userData,n=this.geometry.userData,o=n.parameters.width,a=n.parameters.height,c=(m=(d=e.parameters)==null?void 0:d.width)!=null?m:o,f=(S=(x=e.parameters)==null?void 0:x.height)!=null?S:a,h=r.textFrame;super.updateGeometry(e),h.maxLineSize=c,h.textOrigin.set(-.5*c,.5*f,0),f!==a?(this.checkOverFlow(),this.checkCapacity()):c!==o&&(o<c?this.checkCapacity():o>c&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,n=r.textFrame.textOrigin,o=r.textFrame.textLines;for(let a=e;a<o.length;a++){o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(n);let c=[];for(;o[a].checkOverFlow(r.textFrame.maxLineSize);)o[a].containSpaceOverFlow()?c.unshift(o[a].getWord(o[a].message.length-1,-1)):c.unshift(o[a].popChar());if(c.length>0){o[a+1]===void 0?(o[a].isEndLine(!1),this.createTextLine()):o[a].endLine&&(this.createTextLine(a+1),o[a].isEndLine(!1),o[a+1].isEndLine(!0));let f=0;for(let h=0;h<c.length;h+=1)for(let d=0;d<c[h].length;d+=1)o[a+1].addChar3D(c[h][d],n,f),f+=1;o[a+1].fullUpdate(n)}o[a].fullUpdate(n)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,n=r.textFrame.textOrigin,o=r.textFrame.maxLineSize,a=r.textFrame.textLines;for(let c=e;c<a.length;c+=1)if(a[c].updateYLinePos(this.getNewLinePosition(c)),a[c].fullUpdate(n),!!a[c-1])for(;!a[c-1].endLine;){let f,h=a[c-1].spaceLeft(o);if(a[c].wordSize(0,1)<=h){a[c].containSpace()?f=a[c].getWord(0,1):f=a[c].popChar(0);for(let d=0;d<f.length;d+=1)f[d]&&a[c-1].addChar3D(f[d],n)}else{a[c].isEmpty()?(a[c].endLine&&a[c-1].isEndLine(!0),a.splice(c,1),c-=1):(a[c].updateYLinePos(this.getNewLinePosition(c)),a[c].fullUpdate(n));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let n=this.userData.textFrame;n.textLines.splice(e,0,new qi(this.getNewLinePosition(e),n.lineHeight,n.fontSize))}textFullUpdate(e=0){let n=this.userData.textFrame,o=n.textLines,a=this.getVerticalAlignmentOffSet();for(let c=e;c<o.length;c++)o[c].updateYLinePos(this.getNewLinePosition(c)),o[c].fullUpdate(n.textOrigin),o[c].alignText(n.textOrigin,n.maxLineSize,n.horizontalAlignment,n.verticalAlignment,a)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(e){let n=this.userData.textFrame.textLines,o=0;for(let a=0;a<e;a+=1)o+=n[a].maxCharSize*n[a].lineHeight;return o}updateColor(e){var o;let r=this.userData;r.textFrame.hexColor=e;let n=r.textFrame.textLines;for(let a=0;a<n.length;a++){let c=n[a].message;for(let f=0;f<c.length;f++){let h=c[f].material;(o=h.color)!=null&&o.isColor&&(h.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let n=r.textFrame.textLines;for(let o=0;o<n.length;o++){let a=n[o].message;for(let c=0;c<a.length;c++){let f=a[c].material;f.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let n=r.textFrame.textLines;for(let o=0;o<n.length;o++){let a=n[o].message;for(let c=0;c<a.length;c++){let f=a[c].material;f.visible=e}}}async updateFontFamily(e){await Tr.loadFont(e);let n=this.userData.textFrame,o=n.textLines;n.fontFamily=e;for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)c[f].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let n=this.userData.textFrame,o=n.textLines,a=n.fontSize;n.fontSize=e;for(let c=0;c<o.length;c++)o[c].updateFontSize(e);this.textFullUpdate(),e>a?this.checkOverFlow():e<a&&this.checkCapacity()}async updateTextTransform(e){let n=this.userData.textFrame;await Tr.loadFont(n.fontFamily);let o=n.textLines;switch(n.textTransform=e,e){case 2:for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)o[a].message[f].updateChar(c[f].char.toUpperCase())}break;case 3:for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)o[a].message[f].updateChar(c[f].char.toLowerCase())}break;default:for(let a=0;a<o.length;a++){let c=o[a].message;for(let f=0;f<c.length;f++)o[a].message[f].updateChar(c[f].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,n=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let o=0;o<n.length;o++){let a=n[o].message;for(let c=0;c<a.length;c++)a[c].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let n=r.textFrame.textLines;for(let o=0;o<n.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,n=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let o=0;o<n.length;o++)n[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let r=super.toJSON(e),n=r.object;n.objectType="TextFrame";let a=this.userData.textFrame.textLines.map(c=>{let f=c.message.map(h=>({char:h.char,originalChar:h.originalChar,fontFamily:h.fontFamily,letterSpacing:h.letterSpacing,fontSize:h.fontSize,LOD:h.LOD}));return{align:c.align,endLine:c.endLine,lineHeight:c.lineHeight,maxCharSize:c.maxCharSize,yLinePos:c.yLinePos,message:f}});return n.userData.textFrame.textLinesData=a,r}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let r=e.userData.textFrame;await Tr.loadFont(r.fontFamily),r.textOrigin=new Pv(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let n=new Mv({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:Bu});r.textLinesData&&(r.textLines=r.textLinesData.map((o,a)=>{let c=new qi(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),f=o.message.map((h,d)=>{if(h.char===void 0){let S=r.textLines[a].message[d];if("geometries"in S){let w=S.geometries[0].userData.parameters;Object.assign(h,{LOD:w.lod,char:w.char,fontFamily:w.fontFamily,fontSize:w.fontSize,letterSpacing:w.letterSpacing,originalChar:w.char})}}let m={char:h.char,fontFamily:h.fontFamily,letterSpacing:Number(h.letterSpacing),fontSize:Number(h.fontSize),LOD:h.LOD},x=new Tr(m,n.clone());return c.addChar3D(x,r.textOrigin),this.charContainer.add(x),x});return c.message=f,c}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(e,r){if(e.color!==void 0){let n=Ft(e.color,r);this.updateColor(n),this.updateOpacity(n.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}convertToVector(){let{fontFamily:e,hexColor:r}=this.userData.textFrame,n=new gi;n.name="Text Shape";let o=Tr.fontCache[e];for(let a of this.charContainer.children)a instanceof Tr&&o.generateShapes(a.char,1).forEach(c=>{let f=new nt().fromShape(c);f.applyScale(a.scale.x,a.scale.y);let h=ar.create({shape:f}),d=new ur({side:Bu});d.color=r;let m=new Wi(h,d);m.name=a.char,m.position.copy(a.position),m.rotation.copy(a.rotation),n.attach(m)});return n}},wo=wp;wo.VerticalAlign=Sh,wo.HorizontalAlign=bh,wo.TextTransform=wh;import{HemisphereLight as _3,Scene as I3,Vector3 as O3,Color as Wv,Fog as M3,Box3 as P3}from"three";import{BufferGeometryLoader as p3}from"three";function Av(i,t){return d3(i)}function d3(i){let t={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=nt.createFromState(i.shape,i.width,i.height);t.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>{var n;return r.materialIndex=Math.max((n=r.materialIndex)!=null?n:0,0)}),t.geometry=new p3().parse(i));let e;try{e=Da(t)}catch(r){console.error(r)}if(!e){let r=nt.createFromState(ms.defaultData(),100,100);t.shape=r,e=Da(t)}return e}import{Box3 as m3,Matrix4 as Co,Sphere as Bv,Vector3 as g3}from"three";var Rv=Qm(Ev());var Cp;cu.then(i=>{Cp=i});var zv=new Co,y3=new Co,x3=new Co,Mn=new m3,$i=new g3,v3=new Co,b3=new Co,qs=class extends rr{constructor(e,r,n,o=new Yr){super(n!=null?n:r,o);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=n;this.objectType="SubdivObject";this.hiddenMatrixOld=new Co;this.smoothShading=!0;this.matrixWorldRigid=new Co;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,n){let{subdivPointer:o,originalGeometry:a,subdividedGeometry:c}=Jr.build(r.geometry,void 0,void 0,!r.flatShading),f=el(r.material,n),h=new qs(o,a,c||void 0,f);return h.calcBoundingBox(),h.freeSubdivPointer(),h.uuid=e,h.fromState(r),h}shallowClone(e){return new Ws(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="SubdivObject",r}buildFromStore(e){var a,c,f;let{originalGeometry:r,subdividedGeometry:n,subdivPointer:o}=Jr.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,r!==void 0&&((a=this.originalGeometry)==null||a.dispose(),this.originalGeometry=r),n!==void 0&&((c=this.subdividedGeometry)==null||c.dispose(),this.subdividedGeometry=n!=null?n:void 0),this.geometry=(f=this.subdividedGeometry)!=null?f:this.originalGeometry,this.cloner)for(let h of this.cloner.children)h.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Jr.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Jr.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=Jr.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Jr.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,r){var n;this.geometry=this.originalGeometry,rr.prototype.raycast.call(this,e,r),this.geometry=(n=this.subdividedGeometry)!=null?n:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:n,v:o,q:a}=(0,Rv.SVD)(r),c=zv.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),f=y3.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),h=x3.copy(f).transpose();this.shearScale=v3.makeScale(a[0],a[1],a[2]).multiply(h).premultiply(f),this.shearScaleInv=b3.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,h),a.every(d=>Math.abs(a[0]-d)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Bv);let r=e.attributes.position,n=e.boundingSphere.center;Mn.setFromBufferAttribute(r),Mn.getCenter(n),e.boundingSphere.radius=n.distanceTo(Mn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Mn.getSize($i);let o={width:$i.x,height:$i.y,depth:$i.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let r=this.originalGeometry;Mn.min.set(e[0],e[2],e[4]),Mn.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Mn.min.applyMatrix4(this.shearScaleInv),Mn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Bv);let n=r.boundingSphere.center;Mn.getCenter(n),r.boundingSphere.radius=n.distanceTo(Mn.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Mn.getSize($i);let o={width:$i.x,height:$i.y,depth:$i.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(Cp.free_bvh(this.subdivPointer),Cp.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Gv(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Gv(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=j({},e.parameters)}};function Gv(i,t,e,r){let n=i.position.array,o=i.normal.array,a=zv.makeScale(t,e,r).invert().elements,c,f,h;for(var d=0,m=n.length;d<m;d+=3)n[d]*=t,n[d+1]*=e,n[d+2]*=r,c=o[d],f=o[d+1],h=o[d+2],o[d]=a[0]*c+a[4]*f+a[8]*h,o[d+1]=a[1]*c+a[5]*f+a[9]*h,o[d+2]=a[2]*c+a[6]*f+a[10]*h}import{BackSide as S3,DoubleSide as w3,FrontSide as C3}from"three";function Fv(i,t){t.flatShading!==void 0&&(i.flatShading=t.flatShading,i.needsUpdate=!0),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?i.side=C3:t.side===1?i.side=S3:i.side=w3)}function L3(i,t){if(Array.isArray(i.material))for(let e of i.material)Fv(e,t);else{let e=i.material;Fv(e,t)}i.objectType==="SubdivObject"&&t.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!t.flatShading,i.updateMesh())}function Vv(i,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=qs.createFromState(i,t,e);else{let n=Av(t.geometry,e),o="materials"in t?yv(t.materials,e):el(t.material,e);qc.is2DParametricMesh(n.userData.type)?r=new Gs(n,o):(n==null?void 0:n.userData.type)==="VectorGeometry"?r=new Wi(n,o):t.geometry.type==="NonParametricGeometry"?r=new Ws(n,o):r=new Hs(n,o),r.uuid=i,r.fromState(t)}return L3(r,t),r}function Uv(i,t,e){return t.type==="Mesh"?Vv(i,t,e):t.type==="TextFrame"?wo.createFromState(i,t,e):t.type==="Empty"?gi.createFromState(i,t):t.type==="PointLight"?js.createFromState(i,t,e):t.type==="SpotLight"?ks.createFromState(i,t,e):t.type==="DirectionalLight"?Us.createFromState(i,t,e):as.is(t.type)?mi.createFromState(i,t):(console.error(t),new gi)}function T3(i,t){t.uniforms[`f${t.id}_transmissionSamplerMap`].value=i.texture,t.uniforms[`f${t.id}_transmissionDepthMap`].value=i.depthTexture}function jv(i,t,e){if(!e.userData.layers)return!1;let r=!1,n=e.userData.layers.getLayersOfType("transmission");return n.length>0?(t.layers.set(3),r=!0,i!==void 0&&n.forEach(o=>T3(i,o))):t.layers.set(0),r}function kv(i,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof rr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)jv(i,r,r.material[n])&&(e=!0);else jv(i,r,r.material)&&(e=!0)}),e}function Hv(i,t){"material"in i&&N3(i.material,t),"geometry"in i&&i.geometry.dispose()}function N3(i,t){eg(i).forEach(e=>{t.isSharedMaterial(e)||e.dispose()})}var qv=new O3,Lp=class extends fu(I3){constructor(e,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new M3(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Wv(1,0,0);this.bgColor=new Wv(1,1,1);this.entityByUuid={};this.ambientLight=new _3(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(e,r)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=kv(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ft(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let n=this.find(e.publish.playCamera);n instanceof mi&&this.switchActiveCamera(n)}}clearScene(e){this.traverseEntity(r=>{Hv(r,e)});for(let r of this.children)hn(r)&&r.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=mi.createFromState(Lp.PERSONAL_CAMERA_ID,ue(j({},Jc.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],n=o=>{for(let a of o.children)hn(a)&&!a.raycastLock&&a.visible&&((ws(a)||fi(a)&&a.enableHelper&&a.objectHelper.parent)&&e.intersectObject(a,!1,r),n(a))};return n(this),r}traverseEntity(e){for(let r of this.children)hn(r)&&r.traverseEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ft(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,r){q0(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ft(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,r,n){for(let o of e)this.createChildObject(o.id,o.data,o.children,r,n)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,n,o,a){let c=Uv(e,r,a);return c&&(this.entityByUuid[e]=c,o.add(c),this.createChildrenObjects(n,c,a)),c}getCenter(e){let r=[];for(let o=0,a=e.length;o<a;++o){let{id:c,recursive:f}=e[o],h=this.find(c),d=f?h.recursiveBBox:h.singleBBox;r.push(...d.vertices)}let n=new P3;return n.setFromPoints(r),n.getCenter(qv),qv}copyMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e);n?r.copy(n.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){var o;if(e===null){r.identity();return}let n=(o=this.find(e))==null?void 0:o.parent;n?r.copy(n.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof rr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)e(r.material[n]);else e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let n,o;e>=r?(n=r/e,o=1):(n=1,o=e/r),this.traverseMaterial(a=>{a.layersList.getLayersOfType("transmission").forEach(f=>{f.uniforms[`f${f.id}_aspectRatio`].value.x=n,f.uniforms[`f${f.id}_aspectRatio`].value.y=o})})}},rl=Lp;rl.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as A3}from"three/examples/jsm/loaders/DRACOLoader.js";var Ji;function D3(){return Ji||(Ji=new A3,Ji.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Ji.decoderPending}async function E3(i){if(Ji){let t={attributeIDs:Ji.defaultAttributeIDs,attributeTypes:Ji.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Ji.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function $v(i){let[t,e]=ih(Uc.deserialize(new Uint8Array(i))),r=[];t.scene.objects.traverse((n,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await D3();for(let n of r){let o=await E3(sh(n.geometry.data.draco));if(o){o.index&&(n.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:c,array:f,itemSize:h})=>{a[c]={array:f,itemSize:h,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return e.result().data}import{WebGLRenderTarget as B3,LinearMipmapLinearFilter as G3,LinearFilter as R3,ClampToEdgeWrapping as Jv,DepthTexture as z3}from"three";var Kv=new ur,Ru=class extends Er{},zu=class{constructor(t){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new B3(2048,2048,{generateMipmaps:!0,minFilter:G3,magFilter:R3,wrapS:Jv,wrapT:Jv}),this.transmissionRenderTarget.depthTexture=new z3(2048,2048),this.reset(t)}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.data);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,gp(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}isSharedMaterial(t){return t.uuid in this.materials||t===Kv}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){var e;return(e=this.materials[t])!=null?e:Kv}getMaterials(){return this.materials}addImage(t,e){if(this.images[t])return this.images[t].onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t].src=e,!0;{let r=new Image;return r.src=e,r.onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t]=r,!1}}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Ru(e.r,e.g,e.b,e.a):this.colors[t]=new Ru(e.r,e.g,e.b,1),!1)}updateColor(t,e){var r,n,o,a;if(this.colors[t]){let c=this.colors[t];return this.colors[t].r=(r=e.r)!=null?r:c.r,this.colors[t].g=(n=e.g)!=null?n:c.g,this.colors[t].b=(o=e.b)!=null?o:c.b,this.colors[t].a=(a=e.a)!=null?a:c.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{Mesh as jX}from"three";import{mergeBufferGeometries as WX}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Yv(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as Zv,ShaderLib as F3}from"three";var Qv=Qm(Xv());function eb(i){let t=new Set;return i.traverse(e=>{if(ws(e))if((0,Qv.isArray)(e.material))e.material.forEach(r=>{let n=r;t.has(n)||t.add(n)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);V3(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Zv,specularColor:new Zv}),e.onBeforeCompile=(n,o)=>{r&&r(n,o),n.uniforms=Object.assign(F3.physical.uniforms,n.uniforms),e.userData.layers.getLayersOfType("transmission").forEach(a=>{n.uniforms.transmissionSamplerMap.value&&(a.uniforms["f"+a.id+"_transmissionSamplerMap"].value=n.uniforms.transmissionSamplerMap.value,a.uniforms["f"+a.id+"_transmissionSamplerSize"].value=n.uniforms.transmissionSamplerSize.value)})}):U3(e)||(e.onBeforeCompile=(n,o)=>{r&&r(n,o),e.transparent=!1})}),i}function V3(i){return i.userData.layers.getLayersOfType("transmission").length>0}function U3(i){let t=i.userData.layers.head,e=0;for(;t!==void 0;){if(t.type!=="light"&&t.type!=="fresnel"){let r=t.uniforms["f"+t.id+"_alpha"];r&&(e+=(1-e)*r.value)}t=t.next}return e<1}function tb(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function rb(i){let t=[],e=(r,n=0)=>{let o=n>0?r+n:r;return t.includes(o)?e(r,n+1):o};return i.traverse(r=>{if(t.includes(r.name)){let n=r.name,o=e(r.name);if(r.name=o,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(c=>{c.name=c.name.replace(n,o)}):a.material.isAsset||(a.material.name=a.material.name.replace(n,o))}}t.push(r.name)}),i}import{mergeBufferGeometries as j3}from"three/examples/jsm/utils/BufferGeometryUtils";function nb(i){let t=[];return i.traverse(e=>{e instanceof go&&t.push(e)}),t.forEach(e=>{let r=e.object,n=e.children,o=n.map(c=>{c.updateMatrix();let f=c.geometry.clone().applyMatrix4(c.matrix);return c.matrix.determinant()<0&&Yv(f),f}),a=j3(e.parameters.hideBase?o:[r.geometry,...o]);r.geometry=a,r.material=n[0].material,r.remove(e)}),i}var Tp=class extends H3{load(t,e,r,n=console.error){let o=new k3(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let c=await this.parse(a);e(c)}catch(c){n(c)}},r,n)}async parse(t){let e=await $v(t),r=new zu(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let n=new rl(e.scene,r);n.remove(n.personalCamera),e.scene.environment.ambientLight.enabled||n.remove(n.ambientLight);let o=e.scene.publish.playCamera;if(o){let a=n.find(o);a&&W0(a)&&Object.assign(a,{makeDefault:!0})}return n=nb(n),n=eb(n),n=tb(n),n=rb(n),n}};export{Tp as default};